akhauriyash/Code-Regression huggingface dataset:
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

use input::*;

fn main() {
    let (n, k): (isize, isize);
    input!(n, k);
    let v = input_vector::<isize>();
    let mut l = v.iter().position(|&x| x == 1).unwrap() as isize;
    let mut r = l;
    let mut ans = 0;
    while l >= 0 || r < n - 1 {
        if l >= 0 {
            if l < k - 1 {
                r += k - 1 - l;
            }
            l -= k - 1;
            ans += 1;
            continue;
        }
        r += k - 1;
        ans += 1;
    }
    p(ans);
}

Measured memory_bytes: 6396
/*input

*/
#include <bits/stdc++.h>
#define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i))
#define down(i,b,a) for(int (i) = (b);i>=(a);--i)
#define debug(x) cerr << (x) << '\n';
#define bits(x,i) ((x >> i) & 1)
#define mid ((l+r)/2)
#define pr pair<int,int>
using namespace std;
const int N = 200005;
int a[N];
int n;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    int s = 0;
    up(i,1,n) {
        cin >> a[i];
        s ^= a[i];
    }
    up(i,1,n) cout << (s ^ a[i]) << ' ';
}

Measured memory_bytes: 4436
#include <bits/stdc++.h>
using namespace std;
int c[10][10];

int main(){
	ios::sync_with_stdio(0);
	cout << setprecision(10) << fixed;
	int n;
	cin >> n;
	memset(c, 0, sizeof(c));
	for (int i = 1; i <= n; ++i){
		c[to_string(i)[0] - '0'][i % 10]++;
	}
	long long ans = 0;
	for (int i = 0; i <= 9; ++i){
		for (int j = 0; j <= 9; ++j){
			ans += (1LL * c[i][j] * c[j][i]);
		}
	}
	cout << ans;
	return 0;
}



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

const int N = (int) 1e5 + 5;

struct TQuery {
	int u, v;
	TQuery() {}
	TQuery(int u, int v) : u(u), v(v) {}
	bool operator < (const TQuery &op) const {
		return v == op.v ? u < op.u : v < op.v;
	}
} q[N];

int n, m;

int main() {
	//freopen(".inp", "r", stdin); freopen(".out", "w", stdout);
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= m; i++) scanf("%d %d", &q[i].u, &q[i].v);
	sort(q + 1, q + 1 + m); 
	int cnt = 1, last = q[1].v;
	for (int i = 2; i <= m; i++) {
		if (q[i].u >= last) {
			cnt++;
			last = q[i].v;
		}
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;

int main() {
  int N, L;
  cin >> N >> L;
  vector<string> Ss;
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    Ss.pb(S);
  }
  sort(all(Ss));
  for (size_t i = 0; i < Ss.size(); i++) {
    cout << Ss[i];
  }
  cout << endl;
  return 0;
}

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

int main(){
	int a,b;
	while(std::cin >> a >> b){
		if(a == 0 && b == 0){
			break;
		}
		std::vector< std::vector<int> > intersection(a, std::vector<int>(b, 1));
		int n;
		std::cin >> n;
		int close_a, close_b;
		for(int i = 0; i < n; ++i){
			std::cin >> close_a >> close_b;
			intersection[close_a - 1][close_b - 1] = 0;
			if(close_a == 1) {
				for(int i = (close_b - 1); i < b; ++i){
					intersection[close_a - 1][i] = 0;
				}
			}
			if(close_b == 1) {
				for(int i = (close_a - 1); i < a; ++i){
					intersection[i][close_b - 1] = 0;
				}
			}
		}
		for(int i = 1; i < a; ++i){
			for(int j = 1; j < b; ++j){
				if(intersection[i][j] != 0){
					intersection[i][j] = intersection[i - 1][j] + intersection[i][j - 1];
				}
			}
		}
		std::cout << intersection[a - 1][b - 1] << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define ll long long
#define db double
using namespace std;
const int M=2e5+10;
int sz[M],fa[M],n,m;
int find(int x)
{return fa[x]==x?x:fa[x]=find(fa[x]);}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        sz[i]=1,fa[i]=i;
    for(int i=0,x,y;i<m;i++)
    {
        scanf("%d%d",&x,&y);
        x=find(x),y=find(y);
        if(x!=y) fa[y]=x,sz[x]+=sz[y];
    }
    int ans=0;
    for(int i=1;i<=n;i++)
        ans=max(ans,sz[i]);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 5380
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<list>
using namespace std;

int n;
vector<int> v(2000);

bool solve(int i, int m) {
	if (m == 0) {
		return true;
	}
	else if (i >= n) {
		return false;
	}
	else {
		return solve(i + 1, m) || solve(i + 1, m - v[i]);
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> n;
	for (int i = 0; i < n; i++)cin >> v[i];

	int q;
	cin >> q;
	int m;
	for (int i = 0; i < q; i++) {
		cin >> m;
		if (solve(0, m)) {
			cout << "yes" << endl;
		}
		else {
			cout << "no" << endl;
		}
	}

	return 0;
}

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

int main() {
    int n;cin>>n;
    int a[100];rep(i,100)a[i]=0;
    
    for(int i=2;i<=n;++i){
        int t=i;
        int j=2;
        while(t>1){
            while(t%j==0){
                ++a[j];
                t/=j;
            }
            ++j;
        }
    }
    int ans=0;
    int c75=0;
    int c25=0;
    int c15=0;
    int c5=0;
    int c3=0;
    
    rep(i,n){
        if(a[i]>=74)++c75;
        if(a[i]>=24)++c25;
        if(a[i]>=14)++c15;
      if(a[i]>= 4)++c5;
        if(a[i]>= 2)++c3;
    }
    ans+=c75;
    ans+=max(c25*(c3-1),0);
    ans+=max(c15*(c5-1),0);
    ans+=max(c5*(c5-1)/2*(c3-2),0);

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

Measured memory_bytes: 3600
#include<stdio.h>
int main(){
long long int h, w, c;
scanf("%lld %lld", &h, &w);
    if(h==1){
printf("1\n");
return 0;
  }
    if(w==1){
printf("1\n");
return 0;
  }
  if(h*w%2==0){
printf("%lld\n", w*h/2);
return 0;
  }

    
  c=w*h+1;
    printf("%lld\n", c/2);
return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<iterator>
#include<queue>
#include<algorithm>
#include<functional>

typedef long long ll;
typedef std::map<char, int> string_type;
typedef std::map<string_type, int> type_occurences;

struct abc_170_b {
	std::string run(int X, int Y) {
		const int tsuru = 2, kame = 4;
		int x1, x2;

		x1 = (kame * X - Y)/2;
		x2 = X - x1;

		// positive check
		if(x1 < 0 || x2 < 0) {
			return "No";
		}

		if(tsuru * x1 + kame * x2 == Y) {
			return "Yes";
		}
		return "No";
	}
};

int main(void) {
	abc_170_b solver;
	int X, Y;
	int t;

	std::cin >> X >> Y;

	std::cout << solver.run(X, Y) << std::endl;

	return 0;
}


Measured memory_bytes: 3624
def dfs(v):
    visited[v]=True
    for v2 in range(n):
        if graph[v][v2]==False:
            continue
        if visited[v2]==True:
            continue
        dfs(v2)
        
n, m = map(int, input().split())

alis=[]
blis=[]
graph=[[False] * n for i in range(n)]

#隣接行列のセット
for i in range(m):
    a, b = map(int, input().split())
    graph[a-1][b-1]=True
    graph[b-1][a-1]=True
    alis.append(a-1)
    blis.append(b-1)
    
ans=0

for i in range(m):
    #1本辺を落とす
    graph[alis[i]][blis[i]]=False
    graph[blis[i]][alis[i]]=False
    visited=[False]*n
    dfs(0)
    bridge=False
    for j in range(n):
        if visited[j]==False:
            bridge=True
    if bridge:
        ans+=1
    graph[alis[i]][blis[i]]=True
    graph[blis[i]][alis[i]]=True

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str */

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll s,w;
	cin >> s >> w;
	if(w>=s)
		cout << "unsafe" << endl;
	else
		cout << "safe" << endl;
}

Measured memory_bytes: 3624
N, K = map(int, input().split())
h = list(map(int, input().split()))

cost = [0] + [float("inf") for _ in range(N-1)]
    
for i in range(1,N):
    t = max(0, i - K)
    for j in range(t,i):
        cost[i] = min(cost[i], cost[j] + abs(h[i] - h[j])) 
    
print(cost[-1])

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

int main(){
    string S; cin >> S;
    vector<int> values(26);
    for (int i = 0; i < S.size(); i++)
    {
        values.at(S.at(i) - 'a') = 1;
    }

    char ans = 'N';
    for (int i = 0; i < values.size(); i++)
    {
        if(values.at(i) != 1){
            ans = 'a' + i;
            cout << ans << endl;
            break;
        } 
    }
    if(ans == 'N') cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int n,w,h,s,t,tmpx,tmpy,result;
    
    while(cin>>n,n){
        cin>>w>>h;
        vector<vector<int>> grid(h,vector<int>(w,0));
        REP(i,n){
            cin>>tmpx>>tmpy;
            grid[tmpy-1][tmpx-1]++;
        }
        cin >> s >> t;
        /*
        REP(i,h){
            REP(j,w){
                cout << grid[i][j] << " ";
            }
            cout << endl;
        }*/

        REP(i,h){
            FOR(j,1,w){
                grid[i][j]+=grid[i][j-1];
            }
        }
        REP(i,w){
            FOR(j,1,h){
                grid[j][i]+=grid[j-1][i];
            }
        }
        /*
        REP(i,h){
            REP(j,w){
                cout << grid[i][j] << " ";
            }
            cout << endl;
        }*/

        result = grid[t - 1][s - 1];
        FOR(i,1,w-s+1){
            result = max(result, grid[t - 1][i + s - 1] - grid[t - 1][i - 1]);
        }
        FOR(i,1,h-t+1){
            result = max(result, grid[i+t-1][s - 1] - grid[i - 1][s - 1]);
        }
        
        FOR(i,1,h-t+1){
            FOR(j,1,w-s+1){
                result = max(result, grid[i + t - 1][j + s - 1] - grid[i + t - 1][j - 1] - grid[i - 1][j + s - 1] + grid[i - 1][j - 1]);
            }
        }

        cout<<result<<endl;
    }

    return 0;
}



Measured memory_bytes: 3200
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("Os")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    // #endif
}
int main()
{
    vok();
    ld a,b;
    IN a>>b;
    ld ans=a*b;
    ll res=ans;
    OUT res<<endl
    return 0;
}

Measured memory_bytes: 3832
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

typedef struct node{
    int x;
    int y;
    int f;
}node;

int cmpAscX(const void* a, const void* b){
    int x = ((node*)a)->x, y = ((node*)b)->x;
    if(x > y){
        return 1;
    }
    if(x < y){
        return -1;
    }
    return 0;
}

int cmpDscY(const void* a, const void* b){
    int x = ((node*)a)->y, y = ((node*)b)->y;
    if(x < y){
        return 1;
    }
    if(x > y){
        return -1;
    }
    return 0;
}

int main(){
    int n;
    scanf("%d", &n);
    node red[n];
    node blu[n];
    rep(i, 0, n){
        int x, y;
        scanf("%d %d", &x, &y);
        red[i].x = x;
        red[i].y = y;
        red[i].f = 1;
    }
    rep(i, 0, n){
        int x, y;
        scanf("%d %d", &x, &y);
        blu[i].x = x;
        blu[i].y = y;
        blu[i].f = 1;
    }
    int ans = 0;
    qsort(red, n, sizeof(node), cmpDscY);
    qsort(blu, n, sizeof(node), cmpAscX);
    rep(i, 0, n){
        rep(j, 0, n){
            if(red[j].x < blu[i].x && red[j].y < blu[i].y && red[j].f == 1){
                red[j].f = 0;
                ans++;
                break;
            }
        }
    }
    printf("%d", ans);

    return 0;
}

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

#define int long long
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; }

char mas[20][1010];

signed main(){
	int h, w, K;
	cin >> h >> w >> K;

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

	int ans = INT_MAX;
	for(int i = 0;i < (1 << (h-1));i++){
		int x[20][1010] = {};
		int idx = 0;
		int bit = (i << 1);
		for(int j = 0;j < h;j++){
			if(bit & (1 << j)){
				idx++;
			}
			for(int k = 0;k < w;k++){
				x[idx][k] += mas[j][k] - '0';
			}
		}

		int tmp = idx;
		int le = 0;
		int now[20] = {};
		int n = idx+1;
		for(int j = 0;j < w;j++){
			for(int k = 0;k < n;k++){
				now[k] += x[k][j];
			}
			bool f = false;
			for(int k = 0;k < n;k++){
				if(now[k] > K){
					f = true;
				}
			}

			if(f){
				if(le == 0){
					tmp = INT_MAX;
					break;
				}
				for(int k = 0;k < n;k++){
					now[k] = 0;
				}
				tmp++;
				j--;
			}else{
				le++;
			}
		}
		ans = min(ans, tmp);
	}

	cout << ans << endl;

	return 0;
}


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

def med(s: list):
    n = len(s)
    s = sorted(s, reverse = True)
    return s[(n + 1) // 2 - 1] if n & 1 else (s[n // 2] + s[n // 2 - 1]) / 2

n = int(input())
a, b = [], []
for i in range(n):
    aa, bb = map(int, input().split())
    a.append(aa), b.append(bb)
ma, mb = med(a), med(b)
print(int((mb - ma) + 1) if n & 1 else int((mb - ma) * 2 + 1))

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define out(S) cout<<(S)<<endl;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define beginend(v) v.begin(),v.end()

using pii=pair<int,int>;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvc=vector<vector<char>>;
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }


bool isRect(const vvc& sq,int l,int r,int t,int b,char c){
  for(int y=t;y<=b;++y)for(int x=l;x<=r;++x){
    if(sq[y][x]!='-'&&sq[y][x]!=c) return false;
  }
  return true;
}

void trim(vvc& sq,int l,int r,int t,int b){
  for(int y=t;y<=b;++y)for(int x=l;x<=r;++x) sq[y][x]='-';
}

bool isClear(vvc& sq,int h,int w){
  rep(y,h)rep(x,w) if(sq[y][x]!='.'&&sq[y][x]!='-') return false;
  return true;
}

bool solve3(vvc& sq,int h,int w,char c){
  int t=h,b=0,l=w,r=0;
  rep(y,h) rep(x,w) if(sq[y][x]==c){
    t=min(t,y);
    b=max(b,y);
    l=min(l,x);
    r=max(r,x);
  }


  if(isRect(sq,l,r,t,b,c)){
    trim(sq,l,r,t,b);
    return true;
  }
  return false;
}

bool solve2(vvc& sq,int h,int w){
  map<char,bool> hash;
  hash['-']=true;
  hash['.']=true;
  for(char c='A';c<='Z';c++) hash[c]=false;
  rep(y,h)rep(x,w) {
    if(!hash[sq[y][x]]){
      if(solve3(sq,h,w,sq[y][x])) return true;
    }
    hash[sq[y][x]]=true;
  }
  return false;
}

bool solve(){
  int h,w;
  cin >> h>>w;
  vvc box(h,vector<char>(w));
  rep(y,h)rep(x,w){
    cin >> box[y][x];
  }

  while(solve2(box,h,w));
  

  return isClear(box,h,w);
}

int main(){
  int n;
  cin >> n;
  rep(i,n) if(solve()) cout << "SAFE" << endl; else cout << "SUSPICIOUS" << endl;
}



Measured memory_bytes: 3088
#include <stdio.h>
#define MAX 10000
#define NIL -1

typedef struct{int parent,left,right;}Node;

Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int,int);
int setHeight(int);
int getSibling(int);
void print(int);

int main(){
    int i,j,v,l,r,root=0;
    scanf("%d",&n);

    for(int i=0;i<n;i++) T[i].parent=NIL;

    for(i=0;i<n;i++){
        scanf("%d%d%d",&v,&l,&r);
        T[v].left=l;
        T[v].right=r;
        if(l!=NIL) T[l].parent=v;
        if(r!=NIL) T[r].parent=v;
    }
    for(i=0;i<n;i++) if(T[i].parent==NIL) root=i;

    setDepth(root,0);
    setHeight(root);

    for(i=0;i<n;i++) print(i);

    return 0;
}
void setDepth(int u,int d){
    if(u==NIL) return;
    D[u]=d;
    setDepth(T[u].left,d+1);
    setDepth(T[u].right,d+1);
}

int setHeight(int u){
    int f1=0,f2=0;
    if(T[u].left!=NIL) f1=setHeight(T[u].left)+1;
    if(T[u].right!=NIL) f2=setHeight(T[u].right)+1;

    if(f1>f2) return H[u]=f1;
    else return H[u]=f2;
}

int getSibling(int u){
    if(T[u].parent==NIL) return NIL;
    if(T[T[u].parent].left!=u && T[T[u].parent].left!=NIL) return T[T[u].parent].left;
    if(T[T[u].parent].right!=u && T[T[u].parent].right!=NIL) return T[T[u].parent].right;
    return NIL;
}

void print(int u){
    int d=0;
    printf("node %d: ",u);
    printf("parent = %d, ",T[u].parent);
    printf("sibling = %d, ",getSibling(u));
    if(T[u].left!=NIL) d++;
    if(T[u].right!=NIL) d++;
    printf("degree = %d, ",d);
    printf("depth = %d, ",D[u]);
    printf("height = %d, ",H[u]);

    if(T[u].parent==NIL){
        printf("root\n");
    }
    else if(T[u].left==NIL && T[u].right==NIL){
        printf("leaf\n");
    }
    else{
        printf("internal node\n");
    }
}


Measured memory_bytes: 2104
#include <stdio.h>
#include <cmath>

using namespace std;

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  double ans = 0.0;
  for (int i = 1; i <= n; i++) {
    if (i >= k) {
      ans += 1.0 / n;
    } else {
      ans += pow(0.5, ceil(log2((double)k/(double)i))) / n;
    }
  }

  printf("%.12f", ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define sz(v)           (int)v.size()
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p,int m = inf) {int ans=1;x%=m;while(p>0){if(p&1)ans=(ans*x)%m;p=p>>1;x=(x*x)%m;}return ans;}
int inv(int x,int m=mod){return po(x,m-2,m)%m;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=================================================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f;








void sol()
{   
    cin>>n>>m;
    vi v(n+1,-1);
    while(m--)
    {
        cin>>x>>y;
        if(v[x]!=-1 && v[x]!=y){cout<<-1;return;}
        v[x]=y;
    }
    if(v[1]==0 && n!=1){cout<<-1;return;}
    if(v[1]==-1 && n==1) v[1]=0;
    if(v[1]==-1 && n!=1) v[1]=1;
    

    fo1(i,n)cout<<((v[i]==-1)?0:v[i]);
    

    
    //cout<<  <<endl;
}





int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //sp(10);
    // w(t)
    sol();
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, K;
  cin>>N>>K;
  ll A[N];
  for(int i=0;i<N;++i) cin>>A[i];

  ll flag;
  ll ans = 0;
  for(ll i=42;i>=0;--i) {
    flag = 0;
    for(int j=0;j<N;++j) {
      if((A[j]&(1ull<<i))!=0) flag++;
    }
    if(flag<N-flag && K>=(1ull<<i)) {
      K -= (1ull<<i);
      flag = N-flag;
    }
    ans += flag*(1ull<<i);
  }
  cout<<ans<<endl;
}



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

int main(void)
{
	long int n, ice[4], ans;
	cin >> ice[0] >> ice[1] >> ice[2] >> ice[3] >> n;
	cout << n / 2 * min({ 8 * ice[0],4 * ice[1],2 * ice[2],ice[3] }) + n % 2 * min({ 4 * ice[0],2 * ice[1], ice[2] }) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf 1e18
#define g(x) cout<<x<<" "<<endl;
#define gg(x,y) cout<<x<<" & "<<y<<" "<<endl
#define jam(t) cout<<"Case #"<<t<<": "
#define ggg(x,y,z) cout<<x<<" & "<<y<<" & "<<z<<" "<<endl
#define all(x) x.begin(),x.end()
#define input_from_file  freopen("input.txt", "r", stdin);
#define mod 1000000007ll
#define sz 400005
#define bitcnt(x) __builtin_popcountll(x)
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<int SZ> struct Combo {
    ll fac[SZ+1], ifac[SZ+1];
    
    Combo() {
        fac[0] = ifac[0] = 1;
        for(ll i=1;i< (SZ+1);i++) {
            fac[i] = i*fac[i-1] % mod;
            ifac[i] = inv(fac[i]);
        }
    }
    
    ll po (ll b, ll p) {
        return !p?1:po(b*b%mod,p/2)*(p&1?b:1)%mod;
    }
    
    ll inv (ll b) { return po(b,mod-2); }
    
    ll comb(ll a, ll b) {
        if (a < b) return 0;
        ll tmp = fac[a]*ifac[b] % mod;
        tmp = tmp*ifac[a-b] % mod;
        return tmp;
    }
};
Combo <1000000> C;

ll get(ll n,ll x){
    ll re = 1;
    for(ll j=0;j<x;j++){
        re*=(n-j);
        re%=mod;
    }
    re*=C.ifac[x];
    re%=mod;
    return re;
}
void solve(){
    ll n,a,b;
    cin >> n >> a >> b;
    ll an = C.po(2,n);
    an-=1;
    if(an <0)
        an+=mod;
    an%=mod;
    an -= get(n,a);
    if(an <0)
        an+=mod;
    an%=mod;
    an -= get(n,b);
    if(an <0)
        an+=mod;
    an%=mod;
    g(an);


}
int main()
{

    FASTIO
    cin.tie(NULL);
    fflush(stdout);
    ll t = 1;
   // cin >> t;
    for(ll tcase = 1;tcase <= t;tcase++){
        solve();
        
    }
return 0;
}

Measured memory_bytes: 15872
arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = gets.chomp.to_i

puts arr[k-1]

Measured memory_bytes: 1788
def main():
  n, a, b = map(int, input().split())
  cnt = 0
  for i in range(1, n+1):
    if a <= i//10000 + (i//1000)%10 + (i//100)%10 + (i//10)%10 + i%10<= b:
      cnt += i
  print(cnt)
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 2940
#include<stdio.h>
int main(void)
{
	int a,b,d,r;
	double f;
	scanf("%d""%d",&a,&b);
	d=a/b;
	r=a%b;
	f=(double)a/(double)b;
	printf("%d %d %lf\n",d,r,f);
	

return 0;
}

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

#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
#define nrep(i,a,b) for(int i=int(a);i>=int(b);--i)
#define trv(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define watch(x) cout<<"\n"<<#x<<" is "<<x<<"\n"
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define ZERO(box) memset(box, 0, sizeof(box));
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define chkbit(s, b) (s & (1<<b))
#define leadzero(a) __builtin_clz(a) // count leading zeroes
#define trailzero(a) __builtin_ctz(a) // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod=1e9+7;

ll sq(ll a){ return a*a;}

void solve(){
	int n;cin>>n;
	vi a(n);
	double sum=0;
	rep(i,0,n-1) cin>>a[i],sum+=a[i];
	sum = sum/double(n);
	sum = round(sum);
	ll cost=0;
	rep(i,0,n-1){
		cost += sq(sum-a[i]);
	}
	cout<<cost;
	
}


int main(){
	int t=1;
	//cin>>t;
	while(t--){
		solve();	
	}	
}
/*input
3
4 2 5
*/

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

using namespace std;

int main() {
  int n, a;
  while (cin >> n >> a) {
    vector<int> v(n);
    for (auto &a: v) cin >> a;
    
    static long long dp[51][51][2501];
    for (int i = 0; i < 51; ++i)
      for (int j = 0; j < 51; ++j)
	for (int k = 0; k < 2501; ++k)
	  dp[i][j][k] = 0;
    dp[0][0][0] = 1;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
	for (int k = 0; k < n * a; ++k) {
	  dp[i+1][j+1][k+v[i]] += dp[i][j][k];
	  dp[i+1][j][k] += dp[i][j][k];
	}
      }
    }

    long long result = 0;
    for (int j = 1; j <= n; ++j) {
      result += dp[n][j][j*a];
    }
    cout << result << endl;
  }
}


Measured memory_bytes: 51072
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int calc(int a){
  if(a%2 == 0) return a/2;
  else return 3 * a + 1;
}

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

  vector<int> a(1000010,-1);
  a[0] = s;

  int ans = -1;
  for(int i = 1; i < 1000000; i++){
    a[i] = calc(a[i-1]);
    for(int j = 0;  j < i; j++){
      if(a[i] == a[j]){
        cout << i+1 << endl;
        return 0;
      }
    }
  }
  
  return 0;
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000

int main()
{
  double a, b; cin >> a >> b;
  string res;
  if (a < b) res = "LESS";
  else if (a == b) res = "EQUAL";
  else if (b < a) res = "GREATER";
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<vector<int>> a(2,vector<int>(n));
    int s1=0,s2=0;
    for(int i=0;i<2;i++){
        for(int j=0;j<n;j++){
            cin>>a.at(i).at(j);
            if(i==0)s1+=a.at(i).at(j);
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        s2+=a.at(1).at(n-i-1);
        ans=max(ans,s1+s2);
        s1-=a.at(0).at(n-i-1);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
k, n = map(int, input().split())
a = list(map(int, input().split()))
a2 = []
for i, d in enumerate(a):
    if i != 0:
        a2.append(d - a[i - 1])
    else:
        a2.append(d + k - a[n - 1])
# print(a, a2)
a2.sort(reverse=True)
# print(a, a2)
print(k - a2[0])

Measured memory_bytes: 25840
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>
#include <functional>
#include <algorithm>
using namespace std;

typedef tuple<int, int, int> t3i;
const int INF = 0x3f3f3f3f;

int solve() {
    int H, W, K;
    cin >> H >> W >> K;

    int sr, sc, tr, tc;
    cin >> sr >> sc >> tr >> tc;
    sr--; sc--; tr--; tc--;

    vector<string> A(H);
    for (int r = 0; r < H; r++) {
        cin >> A[r];
    }

    auto deltas = vector<t3i>();
    deltas.push_back({+1, 0, 1});
    deltas.push_back({-1, 0, 1});
    deltas.push_back({0, +1, 1});
    deltas.push_back({0, -1, 1});

    auto dis = vector<vector<int>>(H, vector<int>(W, INF));
    auto que = priority_queue<t3i, vector<t3i>, greater<t3i>>();

    dis[sr][sc] = 0;
    que.push({0, sr, sc});

    while (!que.empty()) {
        auto [d, r, c] = que.top(); que.pop();
        if (d > dis[r][c]) continue;
        for (auto&& [dr, dc, w]: deltas) {
            for (int k = 1; k <= K; k++) {
                int nr = r + k * dr;
                int nc = c + k * dc;
                if (nr < 0 || nr >= H) break;
                if (nc < 0 || nc >= W) break;
                if (A[nr][nc] == '@') break;
                if (dis[nr][nc] < d + w) break;
                if (dis[nr][nc] > d + w) {
                    dis[nr][nc] = d + w;
                    que.push({dis[nr][nc], nr, nc});
                }
            }
        }
    }

    return ((dis[tr][tc] == INF) ? -1: dis[tr][tc]);
}

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

    cout << solve() << endl;

    return 0;
}

Measured memory_bytes: 12152
#include<bits/stdc++.h>
using namespace std;
long long dis1[100001],dis2[100001],ans[100001];
vector<pair<long long,long long> > adj1[100001],adj2[100001];
int main(){
	int n,m,s,t;
	scanf("%d%d%d%d",&n,&m,&s,&t);
	while (m--){
		 long long x,y,a,b;
		 scanf("%lld%lld%lld%lld",&x,&y,&a,&b);
		 adj1[x].push_back(make_pair(y,a));adj1[y].push_back(make_pair(x,a));
		 adj2[x].push_back(make_pair(y,b));adj2[y].push_back(make_pair(x,b));
	}
	memset(dis1,0x7f,sizeof(dis1));
	memset(dis2,0x7f,sizeof(dis2));
	priority_queue<pair<long long,long long> > q;
	dis1[s]=0;
	q.push(make_pair(0,s));
	while (!q.empty()){
		long long x=q.top().second;q.pop();
		for (int i=0;i<adj1[x].size();i++){
			long long y=adj1[x][i].first,z=adj1[x][i].second+dis1[x];
			if (dis1[y]>z){
				dis1[y]=z;
				q.push(make_pair(-dis1[y],y));
			}
		}
	}
	dis2[t]=0;
	q.push(make_pair(0,t));
	while (!q.empty()){
		long long x=q.top().second;q.pop();
		for (int i=0;i<adj2[x].size();i++){
			long long y=adj2[x][i].first,z=adj2[x][i].second+dis2[x];
			if (dis2[y]>z){
				dis2[y]=z;
				q.push(make_pair(-dis2[y],y));
			}
		}
	}
	ans[n+1]=dis1[0];
	for (int i=n;i;i--) ans[i]=min(ans[i+1],dis1[i]+dis2[i]);
	for (int i=1;i<=n;i++) printf("%lld\n",((long long)(1e15+1e-8))-ans[i]);
	return 0;
}

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

int main(){
    int n, k; cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];
    sort(h.begin(), h.end());
    int ans = 1000000003;
    for(int i = 0; i <= n-k; i++){
        if(ans > h[i+k-1]-h[i]) ans = h[i+k-1]-h[i]; 
    }
    cout << ans << endl;
    return 0;
}


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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<double> x(N), y(N);
  for (int i = 0; i < N; i++)
    cin >> x[i] >> y[i];
  vector<int> v(N);
  iota(v.begin(), v.end(), 0);
  int num = 1;
  for (int i = 1; i <= N; i++)
    num *= i;
  vector<vector<int>> b(num);
  int l = 0;
  do
  {
    for (auto x : v)
      b[l].push_back(x);
    l++;
  } while (next_permutation(v.begin(), v.end()));

  double sum = 0.0;

  for (int i = 0; i < b.size(); i++)
  {
    for (int j = 1; j < N; j++)
    {
      sum += sqrt(pow((x[b[i][j]]) - x[b[i][j - 1]], 2) + pow((y[b[i][j]] - y[b[i][j - 1]]), 2));
    }
  }

  double ans = sum / num;
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

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

int main(void){
    
  int x_1,y_1,x_2,y_2,len;
  cin >> x_1 >> y_1 >> x_2 >> y_2;

  int x_3,y_3,x_4,y_4;
  
  x_3 = x_2 - (y_2 - y_1);
  y_3 = y_2 + (x_2 - x_1);
  x_4 = x_3 - (x_2 - x_1);
  y_4 = y_3 - (y_2 - y_1);
  cout << x_3 << " " << y_3 << " " << x_4 << " " << y_4 << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 1e6+3;

int main() {
    Int n, k, q;
    cin >> n >> k >> q;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) cin >> a[i];
    vector<Int> b = a;
    sort(b.begin(), b.end());
    vector<pair<Int, Int>> c(n);
    for (Int i = 0; i < n; i++) c[i] = {a[i], i};
    sort(c.begin(), c.end());
    Int mi = b[q - 1] - b[0];
    vector<bool> use(n, true);
    for (Int i = 0; i < n - q; i++) {
        use[c[i].se] = false;
        vector<Int> v;
        Int j = 0;
        while (j < n) {
            vector<Int> vx;
            while (use[j] && j < n) {
                vx.emplace_back(a[j]);
                j++;
            }
            if ((Int)vx.size() >= k) {
                sort(vx.begin(), vx.end());
                for (Int l = 0; l <= (Int)vx.size() - k; l++) {
                    v.emplace_back(vx[l]);
                }
            }
            j++;
        }
        if ((Int)v.size() < q) {
            break;
        }
        else {
            sort(v.begin(), v.end());
            mi = min(mi, v[q - 1] - v[0]);
        }
    }
    dump(mi);
    return 0;
}

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

int main(){
    //freopen("3test.txt","r",stdin);
    int h,w;
    cin>>h>>w;
    char imageline[w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>imageline[j];
            cout<<imageline[j];
        }
        cout<<endl;
        for(int j=0;j<w;j++){
            cout<<imageline[j];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
def C_RemainderMinimization2019():
    L, R = map(int, input().split())
    ans = (L * R) % 2019
    if R - L < 2019:
        for i in range(L, R ):
            for j in range(i + 1, R + 1):
                ans = min(ans, (i * j) % 2019)
    else:
        for i in range(L, L + 2019):
            for j in range(i + 1, L + 2020):
                ans = min(ans, (i*j) % 2019)
                if ans == 0:
                    break
    print(ans)
if __name__ == "__main__":
    C_RemainderMinimization2019()

Measured memory_bytes: 3064
#pragma GCC optimize("O3")

#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "


VI V2;
void iter(VI &V)
  {
  V2.clear();
  FOR(j, 1, (int)V.size()-1)
    {
    V2.PB(abs(V[j-1]-V[j]));
    }

  V = V2;
  }

VI simulate2(VI V)
  {
  while(V.size() > 1)
    {
    int pot = 1;
    while(pot * 2 < V.size())pot *= 2;
    VI nxt;

    int prev_1 = -1;
    REP(i, pot)if(V[i] == 1)prev_1 = i;

    FOR(i, pot, V.size()-1)
      {
      if(V[i] == 1)prev_1 = i;

      if(V[i] == 1 || V[i-pot] == 1)
        {
        nxt.PB(abs(V[i] - V[i-pot]));
        continue;
        }
      if(V[i] == 0 && V[i-pot] == 0)
        {
        nxt.PB(0);
        continue;
        }

      if(V[i] == 2 && V[i-pot] == 2)
        {
        nxt.PB(0);
        continue;
        }

      if(V[i] != V[i-pot])
        {
        int bede = (prev_1 < i-pot) * 2;
        nxt.PB(bede);
        continue;
        }
      }
    V = nxt;
    }
  return V;
  }



int main()
{
  int n;
  scanf("%d", &n);
  VI V, Vpom;
  string s;
  int sum = 0;
  REP(i, n)
    {
    char a;
    scanf(" %c", &a);
    s += a;
    V.PB(a-'0');
    sum += a;
    
    }
  iter(V);
  V = simulate2(V);
  printf("%d\n", V[0]);
}


Measured memory_bytes: 17392
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

bitset<100005> ok;
string s;
string f[] = {"dream", "dreamer", "erase", "eraser"};

signed main() {
	ok[0] = 1;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (!ok[i]) continue;
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < f[j].size(); k++) {
				if (f[j][k] != s[i+k]) {
					goto no;
				}
			}
			ok[i + f[j].size()] = 1;
			no:;
		}
	}
	if (ok[s.length()]) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
}

Measured memory_bytes: 512
//ABC082B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	string s, t;
	cin >> s >> t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end());
	reverse(t.begin(),t.end());
	if(s < t){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define BRK(x) { (x); break; }
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mt make_tuple
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


llint x;


llint solve(){
	if(x <= 6) return 1;
	if(x%11 == 0) return 2*(x/11);
	if(x%11 <= 6) return 2*(x/11)+1;
	return 2*(x/11)+2;
}


signed main(){
	cin >> x;
	
	cout << solve() << endl;
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())

T_s = 0
H_s = 0

for i in range(n):
    animals = input().split()
    T_a = animals[0]
    H_a = animals[1]
    if T_a < H_a:
        H_s += 3
    elif T_a > H_a:
        T_s += 3
    else:
        T_s += 1
        H_s += 1

print(T_s, H_s)

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

typedef long long ll;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    int x = n/1000;
    if(abs(n-1000*x-1000)==1000) cout<<0<<'\n';
    else cout<<abs(n-1000*x-1000)<<'\n';

    return 0;
}


Measured memory_bytes: 3652
#include <random>    //ランダム
#include <algorithm> //アルゴリズム
#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <algorithm>
#include <iterator>
#include <cstdlib>
#include <fstream>
#include <cmath>
#include <cstring>
#include <string>
#include <sstream>
#include <cassert>
#include <cfloat>
#include <numeric>
#include <climits>
#include <stdint.h>
#include <ctime>
#include <functional>
using namespace std;
// vector<int> temple(7,0);
    // for(int i=0; i<temple.size(); i++){
    
    // }
    // int maxtemp=*max_element(temple.begin(), temple.end());;
    // int mintemp=*min_element(temple.begin(), temple.end());;
    // int answer=0;
    // for(int i=0; i<temple.size(); i++){
    //     if(temple[i]==maxtemp||temple[i]==mintemp){
            
    //     }else{
    //         answer+=temple[i];
    //     }
    // }
    // answer/=5;
    // cout << answer << std::endl;
    void ifmagic(int select, int depth, int kaisuu, int h1, int h2, int h3, int& answer, vector<long>& leng){
        if(depth==1){
            h1=leng[select];
        }else if(depth==2){
            h2=leng[select];
        }else if(depth==3){
            h3=leng[select];
        }
        if(h1==h2||h1==h3||h2==h3){
            return;
        }
        if(depth>kaisuu){
            return;
        }else if(depth==kaisuu){
            if(h1+h2>h3&&h1+h3>h2&&h2+h3>h1){
                answer++;
                return;
            }else{
                return;
            }        
        }
        //cout<<h1<<" "<<h2<<" "<<h3<<endl;
        // cout<<"red=="<<red<<endl;
        // cout<<"green=="<<green<<endl;
        // cout<<"blue=="<<blue<<endl;
        for(int i=select+1; i<leng.size(); i++){
            ifmagic(i,depth+1,kaisuu,h1,h2,h3,answer,leng);
        }
        return;
    }
int main()
{
    int N;
    cin >> N ;
    vector<long> leng(N);
    for(unsigned int i=0; i<N; i++){
        cin >> leng[i] ;
    }
    int answer=0;
    ifmagic(-1, 0, 3, -1, -2, -3, answer, leng);
    cout<< answer <<endl;
    
}


Measured memory_bytes: 3588