akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
10
1 2 4 8 16 32 64 128 256 512
)");
#define cin input
#endif

ll inv_mod( ll a, ll m )
{
  ll b, x, u, q, abs_m, tmp; 

  abs_m = ( m < 0 ) ? -m : m;
  b = m; x = 1; u = 0; 
  while ( b > 0 ) {
    q = a / b; 
    tmp = u; u = x - q * u; x = tmp;
    tmp = b; b = a - q * b; a = tmp;
  }

  return ( x < 0 ) ? abs_m + x : x;
}

// 長さ m の中間列が用いられる回数: fm = m! 2 (n - m - 2)! n! / (n - m - 2)! / (m + 2)! = n! m! 2 / (m + 2)! = 2 n! / (m + 1) / (m + 2)
// 長さ m の端列が用いられる回数: gm = m! 1 (n - m - 1)! n! / (n - m - 1)! / (m + 1)! = n! m! 1 / (m + 1)! = n! / (m + 1)
// 長さ n の列が用いられる回数: n!

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

	const ll mod = 1000000007ull;

    vector<ll> frac(n + 1);
    frac[0] = 1;
    REP (i, n)
        frac[i + 1] = frac[i] * (i + 1) % mod;

	vector<ll> inv(n + 1);
    REP (i, n)
        inv[i + 1] = inv_mod(i + 1, mod);

    vector<ll> fraci(n + 1);
    fraci[n] = inv_mod(frac[n], mod);
    for (auto i = n; i > 0; --i)
        fraci[i - 1] = fraci[i] * i % mod;
	
	vector<ll> sum(n - 1);
	REP (i, n - 2)
		sum[i + 1] = (sum[i] + 2 * frac[n] * inv[i + 2] % mod * inv[i + 3] % mod) % mod;

	ll c = 0;
	for (int i = 1; i <= n; ++i)
	{
		if (i != n)
			c += frac[n] * inv[i + 1];
		else
			c += frac[n];
		c %= mod;
	}

	ll r = 0;
	REP (i, n)
	{
		int a;
		cin >> a;
		r += a * c;
		r %= mod;

		c += mod * mod - frac[n] * inv[i + 2];
		c %= mod;
		c += frac[n] * inv[n - i];
		c %= mod;

		if ((i + 1) * 2 < n)
		{
			c += sum[n - i - 2] + mod - sum[i];
			c %= mod;
		}
		if ((i + 1) * 2 > n)
		{
			int j = n - i;
			if (j >= 2)
			{
				c += mod - sum[n - j] + sum[j - 2];
				c %= mod;
			}
		}
	}

	cout << r << endl;

	return 0;
}


Measured memory_bytes: 3456
q = int(input())
S = set([])

for i in range(q):
    query, x = list(map(int, input().split()))

    # insert
    if query == 0:
        S.add(x)
        print(len(S))

    # find
    else:
        if x in S:
            print(1)
        else:
            print(0)



Measured memory_bytes: 23364
n, a, b = map(int, input().split())

r = 10**9 + 7

def comb(s, t):
    x = 1
    y = 1
    for i in range(t):
        x = (x*(s-i))%r
        y = (y*(i+1))%r

    y_inverse = pow(y, r-2, r)
    return (x*y_inverse)%r

total = pow(2, n, r) - 1

ans = (total-comb(n,a)-comb(n,b))%r

print(ans)

Measured memory_bytes: 3064
#include <iostream>

int main() {
  unsigned N, A, B;
  std::cin >> N >> A >> B;
  std::string S;
  std::cin >> S;
  unsigned passed = 0;
  unsigned foreign_passed = 0;
  for (unsigned i = 0; i < N; ++i) {
    if (S[i] == 'a') {
      if (passed < A + B) {
        std::cout << "Yes";
        ++passed;
      } else {
        std::cout << "No";
      }
    } else if (S[i] == 'b') {
      if (passed < A + B && foreign_passed < B) {
        std::cout << "Yes";
        ++passed;
        ++foreign_passed;
      } else {
        std::cout << "No";
      }
    } else {
      std::cout << "No";
    }
    if (i != N - 1) {
      std::cout << std::endl;
    }
  }
  return 0;
}

Measured memory_bytes: 896
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rep1n(i, n) for(int i=1;i<=(int)(n);i++)
#define repe(i, a, n) for(int i=(a);i<(int)(n);i++)
#define repi(i, a, n) for(int i=(a);i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
int main() {
	int a, b;
	cin >> a >> b;
	char wh = '.', bl = '#';
	int h, w;
	h = w = 100;
	vector<string>t(h, string(w, wh));
	repe(i, h / 2, h) {
		t[i] = string(w, bl);
	}
	auto f = [&](int st, int en, char ch, int lim) {
		int cnt = 1;
		repe(i, st, en) {
			rep(j, w) {
				if (cnt >= lim)return;
				t[i][j] = ch;
				j++;
				cnt++;
			}
			i++;
		}
	};
	f(1, 50, bl, b);
	f(51, h, wh, a);
	cout << h << " " << w << endl;
	rep(i, h) {

		rep(j, w)cout << t[i][j];
		cout << endl;
	}

	return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define ll long long

using namespace std;
priority_queue < int , vector < int > > Q;
int a[100100];

int main()
{
    int n,m;  cin >> n >> m;
    for(int i = 0;i<n;i++)  cin >> a[i] , Q.push(a[i]);
    while(m--){
        int x = Q.top();
        Q.pop();
        x/=2;
        Q.push(x);
    }
    ll Ans = 0;
    while(!Q.empty())  Ans+=Q.top() , Q.pop();
    cout << Ans;
    return 0;
}


Measured memory_bytes: 1148
//abc053_a.cpp
//Fri Oct 19 23:06:36 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	if (n<1200){
		cout << "ABC" << endl;
	}else {
		cout << "ARC" << endl;
	}

}

Measured memory_bytes: 256
// Think twice, Code once
// 1SAC
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
 
/*============================ DEBUGGING =============================*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
/*============================= DEFINES ==============================*/
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
/*============================== TYPEDEFS ============================*/
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef long double ld;
/*============================ START FROM HERE =======================*/
 
int main(){
	FIO
	
	ll a,b,k;cin >> a>> b >>k;
	ll sub = min(a,k);
	a = a-sub;
	k-=sub;
	if(k>0)b-=min(b,k);
	cout << a<< " " << b;
	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&&a!=c)cout<<a<<endl;
    else if(b!=a&&b!=c)cout<<b<<endl;
    else cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	char C = getcha();
	int A = C - '0';
	while ((C = getcha()) >= '0') A = A * 10 + C - '0';
	return A;
}

const int dm = 1 << 12;
char dn[dm], * di = dn;

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


	int N = getint(), K = getint(), Q = getint();

	int P[100001];
	rep1(i, N) {
		P[i] = K - Q;
	}
	rep(i, Q) {
		P[getint()]++;
	}
	rep1(i, N) {
		if (P[i] > 0) {
			*di++ = 'Y';
			*di++ = 'e';
			*di++ = 's';
			*di++ = '\n';
		}
		else {
			*di++ = 'N';
			*di++ = 'o';
			*di++ = '\n';
		}
		if (i % 100 == 0) {
			fwrite(dn, 1, di - dn, stdout);
			di = dn;
		}
	}
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n;//人数
  cin >> m;//ゲーム回数
  int s[m];//ターゲット
  for(int i=0 ; i<m ; i++ ){
    cin >> s[i];
  }
  vector<vector<int> > data(m+1, vector<int>(n));

  // 入力
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      cin >> data.at(i).at(j);
    }
  }

  for (int i = 0; i < n; i++) {
    data.at(m).at(i)=0;
  }
//点数の初期化

  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if(j+1==s[i]){
        data.at(m).at(j)+=n;
      }
      if(data.at(i).at(j)==s[i]){
        data.at(m).at(j)++;
        data.at(m).at(s[i]-1)-=1;
      }
    }
  }
  //点数計算
  for (int j = 0; j < n; j++){
    cout << data.at(m).at(j) << endl;
  }
}



Measured memory_bytes: 3184
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int get_parent_idx(vector<int> &vec, int x) {
  if (x == vec[x])
    return x;
  return vec[x] = get_parent_idx(vec, vec[x]);
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> vec(n + 1);
  for (int i = 1; i <= n; ++i)
    vec[i] = i;

  int x, y, z;
  while (cin >> x >> y >> z) {
    int px = get_parent_idx(vec, x);
    int py = get_parent_idx(vec, y);
    if (px < py) {
      do {
        int tmp = x;
        x = vec[x];
        vec[tmp] = py;
      } while (x != px);
      vec[x] = py;
    }
    else {
      do {
        int tmp = y;
        y = vec[y];
        vec[tmp] = px;
      } while(y != px);
      vec[y] = px;
    }
  }

  for (int i = 1; i <= n; ++i)
    get_parent_idx(vec, i);

  set<int> s;
  for (int i = 1; i <= n; ++i)
    s.insert(vec[i]);

  cout << static_cast<int>(s.size()) << endl;
}

Measured memory_bytes: 8188
#include <bits/stdc++.h>
using namespace std;
string field[2160];
int l[2160][2160];
int r[2160][2160];
int u[2160][2160];
int d[2160][2160];


int main(){
  int h, w;
  cin >> h >> w;
  for(int i = 0;i < h;i++){
    cin >> field[i];
  }
  for(int i = 0;i<h;i++){
    for(int j = 0; j<w;j++){
      if(field[i][j] == '#'){
        l[i][j] = 0;
        u[i][j] = 0;
      }
      else{
        u[i][j] = (i == 0)?1:u[i-1][j]+1;
        l[i][j] = (j == 0)?1:l[i][j - 1] + 1;
      }
    }
  }
  for(int i = h-1;i >= 0;i--){
    for(int j = w-1; j >= 0;j--){
      if(field[i][j] == '#'){
        r[i][j] = 0;
        d[i][j] = 0;
      }
      else{
        d[i][j] = (i == h-1)?1:d[i+1][j]+1;
        r[i][j] = (j == w-1)?1:r[i][j + 1] + 1;
      }
    }
  }
  int res = 0;
  for(int i = 0;i<h;i++){
    for(int j = 0;j < w;j++){
      if(field[i][j] == '#')continue;
      res = max(res, r[i][j] + l[i][j] + d[i][j] + u[i][j] - 3);
    }
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 76032
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*4
#define REP(a,b) for(long long a = 0;a < b;++a)
vector<long long> inputs;
long long powing(long long a, long long b) {
	long long ans = 1;
	while (b != 0) {
		if (b % 2) {
			ans *= a;
			ans %= MAX_MOD;
		}
		a *= a;
		a %= MAX_MOD;
		b /= 2;
	}
	return ans;
}
pair<long long, long long> dfs(long long left, long long right) {
	pair<long long, long long> ans = make_pair(0, 1);
	if (left == right) return ans;
	long long height = 1e9;
	for (int i = left; i < right; ++i) {
		height = min(height, inputs[i]);
	}
	for (int i = left; i < right; ++i) {
		inputs[i] -= height;
	}
	vector<pair<long long, long long>> kouho;
	int back_itr = left;
	int cnt = 0;
	for (int i = left; i < right; ++i) {
		if (inputs[i] == 0) {
			kouho.push_back(dfs(back_itr, i));
			back_itr = i + 1;
			cnt++;
		}
	}
	kouho.push_back(dfs(back_itr, right));
	for (int i = 0; i < kouho.size(); ++i) {
		ans.second *= kouho[i].second;
		ans.second %= MAX_MOD;
	}
	ans.first = 1;
	for (int q = 0; q < kouho.size(); ++q) {
		ans.first *= (kouho[q].first + kouho[q].second);
		ans.first %= MAX_MOD;
	}
	ans.first *= powing(2LL, cnt);
	ans.first %= MAX_MOD;
	ans.first += MAX_MOD - ((ans.second * 2LL) % MAX_MOD);
	ans.first %= MAX_MOD;
	ans.second *= powing(2LL, height);
	ans.second %= MAX_MOD;
	ans.first += ans.second;
	ans.first %= MAX_MOD;
	return ans;
}
int main() {
	int n;
	cin >> n;
	REP(i, n) {
		long long a;
		cin >> a;
		inputs.push_back(a);
	}
	cout << dfs(0, inputs.size()).first << endl;
}

Measured memory_bytes: 888
#include <iostream>

int main(){
	
	int e;
	int f=0;
	while(std::cin>>e){
		for(int a=0;a<10;a++){
			for(int b=0;b<10;b++){
				for(int c=0;c<10;c++){
					for(int d=0;d<10;d++){
						if(a+b+c+d==e){
							
							f++;
						}
		            }
		        }
		    }
		}
		std::cout<<f<<std::endl;
		f=0;
	}
    
    return 0;
    
}

Measured memory_bytes: 3064
#!/usr/bin/env run-cargo-script

use std::cmp;
use std::fmt::Debug;
use std::io;
use std::io::{Read, Stdin};
use std::str;
use std::str::FromStr;

fn main() {
    let mut sc = Scanner::new();
    let n = sc.parse::<usize>();
    let v = sc.vec::<String>(n);
    println!("{}", solve(v));

}


fn solve(v: Vec<String>) -> String {
    fn to_index(b: u8) -> usize {
        (b - 'a' as u8) as usize
    }
    fn to_counter(s: &String) -> [usize; 26] {
        let mut result = [0; 26];
        for c in s.bytes() {
            result[to_index(c)] += 1;
        }
        result
    }

    let mut min_numbers_of_chars = to_counter(&v[0]);
    for s in &v[1..] {
        let counter = to_counter(s);
        for i in 0..26 {
            min_numbers_of_chars[i] = cmp::min(min_numbers_of_chars[i], counter[i]);
        }
    }

    let mut result = Vec::<u8>::new();
    for i in 0..26 {
        let c = 'a' as u8 + i as u8;
        for _ in 0..min_numbers_of_chars[i] {
            result.push(c);
        }
    }
    String::from_utf8(result).unwrap()
}


struct Scanner {
    stdin: Stdin,
    buf: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            buf: Vec::with_capacity(256),
        }
    }

    fn parse<T: FromStr>(&mut self) -> T
        where <T as FromStr>::Err: Debug
    {
        self.buf.clear();
        let mut it = self.stdin.lock().bytes();
        let mut c = it.next().unwrap().unwrap();
        while c == ' ' as u8 || c == '\n' as u8 {
            c = it.next().unwrap().unwrap();
        }
        while !(c == ' ' as u8 || c == '\n' as u8) {
            self.buf.push(c);
            c = it.next().unwrap().unwrap();
        }
        str::from_utf8(&self.buf).unwrap().parse::<T>().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
        where <T as FromStr>::Err: Debug
    {
        (0..n).map(|_| self.parse()).collect()
    }
}


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

int main() {
     
     long long n,h,i,j,t,m,l,r,q;
     long long p=0,k,w,z,x,y,d,p1,h1;
     string s="",st="",s1="",s2="";
     q=1;
     for(l=0;l<q;l++)
     {
          std::cin >> n >> x >> t;
          p=n/x;
          if(n%x!=0)
               p++;
          std::cout << p*t << std::endl;
     }
     return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
int n, k, inv[200005];
const int M = 1000000007;
void init(){
    n = read(), k = read();
}
void solve(){
    inv[1] = 1;
    for (int i = 2; i <= n; ++i)
        inv[i] = 1ll * (M - M / i) * inv[M % i] % M;
    int ans = 0, fz = 1, fz2 = 1, fm = 1;
    for (int i = 0; i <= min(n - 1, k); ++i){
        int t = 1ll * fz * fm % M;
        t = 1ll * fz2 * t % M;
        t = 1ll * fm * t % M;
        ans = (ans + t) % M;
        fz = 1ll * fz * (n - i - 1) % M;
        fz2 = 1ll * fz2 * (n - i) % M;
        fm = 1ll * fm * inv[i + 1] % M;
    }
    printf("%d\n", ans);
}
int main(){
    init();
    solve();
    return 0;
}

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

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

int main()
{
	llong n,a,b; scanf("%lld%lld%lld",&n,&a,&b);
	if(a<b) swap(a,b);
	if((a-b)&1ll)
	{
		llong ans = min(a-1ll,n-b);
		ans = min(ans,n-a+1ll+(a-b-1ll>>1));
		ans = min(ans,b+(a-b-1ll>>1));
		printf("%lld\n",ans);
	}
	else {printf("%lld\n",(a-b)>>1);}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;

int main(){
   ll x,k,d; cin >> x >> k >> d;
   ll ans;
   ll X=abs(x);
   if(X/d > k){
       ans=X-k*d;
   }
   else if(X/d == k){
       ans=X%d;
   }
   else{
       if((k-X/d)%2==0) ans=X%d;
       else if(X%d==0) ans=d;
       else ans=d-X%d;
   }
   cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3568
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include <iomanip>

using namespace std;

int N, M;
vector<int> k;
vector<vector<int>> s;
vector<int> p;

int ans = 0;
bool solve(string str){
    //cout << str << endl;
    for(int i = 0; i < M; i++){
        int sw = 0;
        for(int j = 0; j < k[i]; j++){
            //cout << "str " <<str[s[i][j] - 1] << endl;
            if(str[s[i][j] - 1] == '0'){
                sw += 1;
                //cout << "in";
            }
        }
        //cout << "sw" << sw << "p" << p[i];
        if(sw%2 != p[i]){
           // cout << "false\n";
            return false;
            }
    }
    //cout << "true\n";
    return true;
}
void subBin(string str, int n)
{
    if (n == 0){
        if(solve(str)){
            ans++;
        }
    }
    if (n > 0) {
        subBin(str + "0", n - 1);
        subBin(str + "1", n - 1);
    }
}
int main(){
    cin >> N>>M;
    for(int i = 0; i < M; i++){
        int k_i;
        scanf("%d", &k_i);
        k.push_back(k_i);
        vector<int> s_i;
        for(int j = 0; j < k_i; j++){
            int tmp;
            scanf("%d", &tmp);
            s_i.push_back(tmp);
        }
        s.push_back(s_i);
    }
    for(int i = 0; i < M; i++){
        int p_i;
        cin >> p_i;
        p.push_back(p_i);
    }

    string str = "";
    subBin(str, N);
    cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ll long long
#define int long long
#define ull unsigned long long
#define mod 1000000007
#define vi vector<ll>
#define pb push_back
#define mp make_pair
#define str string
#define p(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}
#define sp(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type) type *arr=new type[n];
#define w(x) ll x; cin>>x; while(x--)
#define endl '\n'
#define all(v) v.begin(), v.end()
#define test cout<<"LOL_ABHISHEK"<<endl;
void kehsihba() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int32_t main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//kehsihba();
	double pi = 2*acos(0.0);
	ll a,b,n,m;
	cin>>a>>b>>n>>m;
	double ans=a*a+b*b;
	double angle=abs(30*n-(5.5*m));
	angle=min(angle,360-angle);
	ans-=2*(a*b*cos(angle*pi/180));
	ans=sqrt(ans);
	cout<<sp(ans,15);

	return 0;
}

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

int cross(double x1, double y1, double x2, double y2) {
    if (0 < x1 * y2 - y1 * x2) return 1;
    return -1;
}

int main() {
    int n;
    while (cin >> n, n) {
        char c;
        vector<double> x(n), y(n);
        for (int i=0; i<n; ++i) {
            cin >> x[i] >> c >> y[i];
        }
        vector<bool> touch(n, false);
        for (int i=0; i<n; ++i) {
            for (int j=i+1; j<n; ++j) {
                bool ok = true;
                int d = 0;
                for (int k=0; k<n; ++k) {
                    if (k == i || k == j) continue;
                    int dd = cross(x[j] - x[i], y[j] - y[i], x[k] - x[i], y[k] - y[i]);
                    if (d == 0) {
                        d = dd;
                    } else if (d != dd) {
                        ok = false;
                        break;
                    }
                }
                if (ok) {
                    touch[i] = touch[j] = true;
                }
            }
        }
        int cnt = n;
        for (int i=0; i<n; ++i) cnt -= touch[i];
        cout << cnt << endl;
    }
    return 0;
}

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

int main()
{
    long long int taka=100, i, x;
    cin >> x;

    for(i=1; ; i++)
    {
        taka=taka+taka*0.01;
        taka=floor(taka);

        if(taka>=x) break;
    }

    cout << i << endl;

    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

const int MAX = 2000010;
ll fac[MAX], finv[MAX], inv[MAX];
bool Pre = true;
void cominit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    FOR(i, 2, MAX) {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
ll com(int n, int k) {
    if (Pre) {
        cominit();
        Pre = false;
    }
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main() {
    init();

    int n, k; cin >> n >> k;
    chmin(k, n - 1);
    ll ans = 0;
    eFOR(i, 0, k)(ans += com(n, i) * com(n - 1, i) % mod) %= mod;
    cout << ans << "\n";
}

Measured memory_bytes: 47104
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define datatype char *

//比較関数
int compare(datatype a, datatype b){
	return strcmp(a, b);
}

//昇順
void sort_sub(datatype *origin, int left, int right, datatype *tmp){
	if(right - left > 1){
		int i, j, k, half = (left + right) / 2;
		sort_sub(origin, left, half, tmp);
		sort_sub(origin, half, right, tmp);
		for(i = left; i < right; i++){
			tmp[i] = origin[i];
		}
		for(i = left, j = left, k = half; i < right; i++){
			if(k == right){
				origin[i] = tmp[j];
				j++;
			}
			else if(compare(tmp[j], tmp[k]) <= 0 && j < half){
				origin[i] = tmp[j];
				j++;
			}
			else{
				origin[i] = tmp[k];
				k++;
			}
		}
	}
}

void sort(datatype *origin, int N){
	datatype *tmp = (datatype *)malloc(sizeof(datatype) * N);
	sort_sub(origin, 0, N, tmp);
	free(tmp);
}

int main(){
	int N, L, i, j;
	scanf("%d%d", &N, &L);
	char **S = (char **)malloc(sizeof(char *) * N);
	for(i = 0; i < N; i++){
		S[i] = (char *)malloc(sizeof(char) * (L + 1));
		scanf("%s", S[i]);
	}
	sort(S, N);
	for(i = 0; i < N; i++){
		for(j = 0; j < L; j++){
			printf("%c", S[i][j]);
		}
	}
	printf("\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;
ll mx = 1e18;

int main() {
  int n;
  cin >> n;
  bool ng = false;
  ll ans = 1;
  rep(i, n) {
    ll a;
    cin >> a;
    if(a==0) {
      cout << 0 << endl;
      return 0;
    }
    if(ng || mx/ans <a) {
      ng = true;
    }
    ans *= a;
  }
  if(ng) {cout << -1 << endl;}
  else {cout << ans << endl;}

  return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;

int main(){
	double a,b;
	cin>>a>>b;
	for(int i=0;i<=1145;i++){
		if(floor(i*0.08)==a&&floor(i*0.1)==b){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main( int argc, char *argv[] ) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll tot = 0;
	ll n, m, tmp, c = 0;
	cin >> n >> m;
	vector<ll> v(n);
	for ( int i = 0 ; i < n ; i++ ){
		cin >> v[i];
		tot += v[i];
	}
	for ( int i = 0 ; i < n ; i++ ){
		if ( 4 * m * v[i] >= tot )
			c++;
	}
	cout << (c >= m ? "Yes" : "No") << "\n";

	return 0;
}


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

#define ll long long

template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

void solve() {
  string s; cin >> s;
  int x, y;
  for(int i=0; i<s.size(); ++i) {
    if(s[i]=='A') {
      x=i; break;
    }
  }
  for(int i=s.size(); i>=0; --i) {
    if(s[i]=='Z') {
      y=i+1; break;
    }
  }

  cout << y-x << endl;

  return;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 3724
H,W = map(int,input().split())
C = []
for i in range(10):
  c = list(map(int,input().split()))
  C.append(c)
  
A = []
for i in range(H):
  a = list(map(int,input().split()))
  A.append(a)

for i in range(10):
  for j in range(10):
    for k in range(10):
      C[j][k] = min(C[j][k],C[j][i]+C[i][k])

ans = 0
for i in range(H):
  for j in range(W):
    if(A[i][j] != -1):
      ans += C[A[i][j]][1]
print(ans)

Measured memory_bytes: 3444
#include<stdio.h>
void insertionSort(int*,int); // N個の要素を含む0-オリジンの配列A
int main(){
    int array[100];
    int a,b,i,j;
    scanf("%d",&a);
    for(i=0;i<a;i++){
        scanf("%d",&array[i]);
    }
    insertionSort(array,a);
}

void insertionSort(int* a,int b){
    int i,j,k,v;
    for(i=0;i<b;i++){
        v=a[i];
        j=i-1;
        while(j>=0 && a[j]>v){
            a[j+1] = a[j];
            j--;
            a[j+1] = v;
        }
        for(k=0;k<b;k++){
            if(k==b-1){
                printf("%d",a[k]);
            }
            else{
            printf("%d ",a[k]);
            }
        }
        printf("\n");
    }
}


Measured memory_bytes: 2068
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
  int n;
  cin >> n;
  int cnt = 0;
  rep(i,n){
    int d1,d2;
    cin >> d1 >> d2;
    if(d1 == d2) cnt++;
    else cnt = 0;
    
    if(cnt == 3){
      YES;
      return 0;
    }
  }
  NO;
  return 0;
}

Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int L, R, d;
	cin >> L >> R >> d;

	int ans = 0;
	for (int ii = L; ii <= R; ++ii){
		if (ii % d == 0){
			ans++;
		}
	}



	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	cin >> n;
	if(n%2==1){
		cout << 0;
		return 0;
	}
	long long res=0;
	while(n>0){
		res+=n/10;
		n/=5;
	}
	cout << res << endl;
}

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

using namespace std;
using Graph=vector<vector<int> >;

int main()
{
    int n,x,y;//頂点数
    cin >> n >> x >> y;
    x--;y--;
    //graph 入力
    Graph g(n);
    vector<int > ans(n+100,0);
    for(int i=0;i<n-1;i++){
        g[i].push_back(i+1);
        g[i+1].push_back(i);
    }
    g[y].push_back(x);
    g[x].push_back(y);
    for(int i=0;i<n;i++){
        //bfs date
        vector<int> dist(n,-1);
        queue <int > que;
        //初期条件
        dist[i]=0;
        que.push(i);
        //bfs start
        while(!que.empty()){
            int v=que.front();
            que.pop();
            for(int nv:g[v]){
                if(dist[nv]!=-1)continue;
                dist[nv]=dist[v]+1;
                que.push(nv);
            }
        }
        for(int i=0;i<n;i++){
            ans[dist[i]]++;
        }
    }
    for(int i=1;i<n;i++){
        cout << ans[i]/2<< endl;
    }
    return 0;

}


Measured memory_bytes: 384
/* kadai2_3 
   Saikyo_Kazune
*/
#include <stdio.h>
 
 
 
int main(void){
 
    //N,Aを格納する変数を宣言
    int N,A;
    //標準入力から受け取り
    scanf("%d",&N);
    scanf("%d",&A);
    //N^2-Aを出力
    printf("%d\n",N*N-A);
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()


using namespace std;

int main()
{
	int N;
	cin >> N;
	int ans = 0;
	int count = 0;

	for (int i = 1; i <= N; i += 2)
	{
		for (int l = 1; l <= i; l++)
		{
			if (i % l == 0)
			{
				count++;
			}
		}

		if (count == 8)
		{
			ans++;
		}

		count = 0;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (1e+18) + 7;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 10000;
modint fact[max_n], factinv[max_n];
ll pas[3002][3002];
void init_f() {
	rep(i, 3002)rep(j, 3002) {
		if (i == 0 || j == 0)pas[i][j] = 1;
		else pas[i][j] = pas[i - 1][j] + pas[i][j - 1];
	}
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
ll comb(int a, int b) {
	return pas[a - b][b];
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

void solve() {
	int ans = 0;
	string s; cin >> s;
	int n = s.size();
	rep(i, n - 1)if (s[i] != s[i + 1])ans++;
	cout << ans << endl;
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init_f();
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <cstring>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    int n; cin >> n;
    int a = 100000;
    rep(i, n){
        int b = a / 20;
        a += b;
        //cout << a << " ";
        int k = a % 1000;
        if(k){
            a -= k;
            a += 1000;
        }
        //cout << a << endl;
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 1160
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  int N;
  cin >> N;
  string w[N];
  for(int i=0; i<N; i++){
    cin >> w[i];
  }
  string ans = "Yes";
  set<string> visited;
  visited.insert(w[0]);
  for(int i=1; i<N; i++){
    if(w[i-1].back() != w[i].front() || visited.find(w[i]) != visited.end()){
      ans = "No";
      break;
    } else {
      visited.insert(w[i]);
    }
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, m; cin >> n >> m;
  vi ac(n, 0), wa(n, 0);

  rep(i, m) {
    int x; cin >> x;
    string s; cin >> s;

    if (s == "AC") ac[x-1] = 1;
    else if (s == "WA" && !ac[x-1]) ++wa[x-1];
  }

  int a = 0, w = 0;
  rep(i, n) if (ac[i]) ++a, w += wa[i];

  cout << a << " " << w << endl;

  return (0);
}


Measured memory_bytes: 3924
#include<stdio.h>
int main(){
  int x1,x2,x3,x4;
  int y1,y2,y3,y4;
  int a,b;
  scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
  x3=x2+(y1-y2);
  y3=y2-(x1-x2);
  x4=x1+(y1-y2);
  y4=y1-(x1-x2);
  printf("%d%*s%d%*s%d%*s%d\n", x3,1,"", y3,1,"", x4,1,"", y4);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void){
	double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
	int cnt;

	while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &xa1, &ya1, &xa2, &ya2, &xb1, &yb1, &xb2, &yb2) != EOF){
		cnt = 0;
		if(xb1 <= xa2 && xb1 >= xa1 && yb2 >= ya1 && yb2 <= ya2) cnt++; 
		if(xb1 <= xa2 && xb1 >= xa1 && yb1 >= ya1 && yb1 <= ya2) cnt++; 
		if(xb2 <= xa2 && xb2 >= xa1 && yb1 >= ya1 && yb1 <= ya2) cnt++; 
		if(xb2 <= xa2 && xb2 >= xa1 && yb2 >= ya1 && yb2 <= ya2) cnt++;

		if(xa1 <= xb2 && xa1 >= xb1 && ya2 >= yb1 && ya2 <= yb2) cnt++; 
		if(xa1 <= xb2 && xa1 >= xb1 && ya1 >= yb1 && ya1 <= yb2) cnt++; 
		if(xa2 <= xb2 && xa2 >= xb1 && ya1 >= yb1 && ya1 <= yb2) cnt++; 
		if(xa2 <= xb2 && xa2 >= xb1 && ya2 >= yb1 && ya2 <= yb2) cnt++;

		if(xa2 > xb2 && xa1 < xb1 && ya2 < yb2 && ya1 > yb1) cnt++;
		if(xa2 < xb2 && xa1 > xb1 && ya2 > yb2 && ya1 < yb1) cnt++;

		if(cnt > 0){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct{
  int id;
  int parent;
  int left;
  int right;
}tree;

tree *T;

void preorder(int r){
  printf(" %d",r);
  if(T[r].left != -1) preorder(T[r].left);
  if(T[r].right != -1) preorder(T[r].right);
}

void inorder(int r){
  if(T[r].left != -1) inorder(T[r].left);
  printf(" %d",r);
  if(T[r].right != -1) inorder(T[r].right);
}

void postorder(int r){
  if(T[r].left != -1) postorder(T[r].left);
  if(T[r].right != -1) postorder(T[r].right);
  printf(" %d",r);
}

int main(){
  int i, n, id, root;
  scanf("%d",&n);
  T = malloc(sizeof(tree)*n);
  for(i = 0; i < n; i++) T[i].parent = -1;
  for(i = 0; i < n; i++){
    scanf("%d",&id);
    scanf("%d%d",&T[id].left, &T[id].right);
    T[T[id].left].parent = id;
    T[T[id].right].parent = id;
  }
  for(i = 0; i < n; i++){
    if(T[i].parent == -1){
      root=i;
      break;
    }
  }
  printf("Preorder\n");
  preorder(root);
  printf("\nInorder\n");
  inorder(root);
  printf("\nPostorder\n");
  postorder(root);
  printf("\n");
  return 0;
}

Measured memory_bytes: 616
#include<bits/stdc++.h>
using namespace std;
void solve()
{
    int n; cin >> n;
    if(n >= 400 && n <= 599)
    {
        cout << "8" << endl;
    }
    if(n >= 600 && n <= 799)
    {
        cout << "7" << endl;
    }
    if(n >= 800 && n <= 999)
    {
        cout << "6" << endl;
    }
    if(n >= 1000 && n <= 1199)
    {
        cout << "5" << endl;
    }
    if(n >= 1200 && n <= 1399)
    {
        cout << "4" << endl;
    }
    if(n >= 1400 && n <= 1599)
    {
        cout << "3" << endl;
    }
    if(n >= 1600 && n <= 1799)
    {
        cout << "2" << endl;
    }
    if(n >= 1800 && n <= 1999)
    {
        cout << "1" << endl;
    }
}
int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 3624
def prime_factorize(n):
  a = []
  while n % 2 == 0:
    a.append(2)
    n //= 2
  f = 3
  while f**2 <= n:
    if n % f == 0:
      a.append(f)
      n //= f
    else:
      f += 2
  if n != 1:
    a.append(n)
  return a

n = int(input())
prime_factorize(n)
print('{}:'.format(n), *prime_factorize(n))


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,b=0;
  cin>>n>>m;
  vector<int> a(m);
  for(int i=0;i<m;i++){
    cin>>a.at(i);
    b+=a.at(i);
  }
  if(n-b>=0)
  cout<<n-b<<endl;
  else
    cout<<-1<<endl;
}

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

#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;

ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
ll mod(ll a, ll b) {return (a % b + b) % b;}

using namespace std;

bool ispalindrome(string s, ll l, ll r)
{
	for(ll i = l,j = r; i < j; i++,j--)
	{
		if(s[i] != s[j]) return false;
	}
	return true;
}
int main() 
{	
	fast;
	string s; cin>>s;
	ll n = s.size();
	bool a = ispalindrome(s,0,n-1);
	bool b = ispalindrome(s,0,(n-1/2) - 1);
	bool c = ispalindrome(s,((n+3)/2) - 1,n-1);
	if(a && b && c) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    int N;
    string A,B,C;
    cin >> N >> A >> B >> C;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] != B[i] && B[i] != C[i] && C[i] != A[i]) {
            ans += 2;
        } else if (A[i] == B[i] && B[i] == C[i] && C[i] == A[i]) {
            continue;
        } else {
            ans += 1;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<cstring>
using namespace std;
char s[100010],s1[100010],s2[100010];
int main()
{
	ios::sync_with_stdio(false);
	cin>>s+1;
	int l=strlen(s+1);
	for(int i=1;i<=l;i++)
	  s1[i]=s[l-i+1];
	for(int i=1;i<=l;i++)
	  {
	  	if(s1[i]=='b')
	  	  s2[i]='d';
	  	if(s1[i]=='d')
	  	  s2[i]='b';
	  	if(s1[i]=='p')
	  	  s2[i]='q';
	  	if(s1[i]=='q')
	  	  s2[i]='p';
	  }
	for(int i=1;i<=l;i++)
	  if(s2[i]!=s[i])
	    {
	    	cout<<"No";
	    	return 0;
		}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
	int N;

	cin >> N;

	int p[N];
	int q[N];

	for (int i = 0; i < N; i++)
	{
		cin >> p[i];
		q[i] = p[i];
	}

	sort(q, q + N);

	int count = 0;

	for (int i = 0; i < N; i++)
	{
		if (p[i] != q[i])
		{
			count++;
		}
	}

	if ((count == 2) || (count == 0))
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = {}
p = 0
for i in range(n, 0, -1):
    b = 0
    j = i
    while j < k:
        if j in a:
            b += a[j]
            break;
        else:
            j *= 2
            b += 1
    a[i] = b
c = [0]*20
for i in range(n):
    c[a[i+1]] += 1
for i in range(20):
    p += c[i]*(1/2)**i
print(p/n)

Measured memory_bytes: 19228
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

vector<vector<ll>> dp(410, vector<ll>(410, -1));
vector<ll> a(440);
ll dfs(ll l, ll r) {
	if(dp[l][r] != -1) return dp[l][r];
	if(l == r) return dp[l][r] = 0;
	ll ret = INF * INF;
	ll sum = 0; for(ll i = l; i <= r; i++) sum += a[i];
	for(ll i = l; i < r; i++) {
		ret = min(ret, dfs(l, i) + dfs(i + 1, r) + sum);
	}
	return dp[l][r] = ret;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	REP(i, n) cin >> a[i];
	cout << dfs(0, n - 1) << endl;
	return 0;
}

/* --------------------------------------- */


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

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  string s; cin >> s;
  int n = s.size();
  int res = 0;
  for (int i = 0; i < n - 1; i++) res += s[i] != s[i + 1];
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 512
import sys
S=input()
N = len(S)
S_re = S[::-1]
S_1 = S[0:(N-1)//2]
S_2 = S[(N+3)//2-1:N]
if S == S_re:
    if S_1 == S_1[::-1]:
        if S_2 == S_2[::-1]:
            print('Yes')
            sys.exit()

print('No')

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

int n,a,b,p[110];
string t;

int main() {
  cin >> n >> a >> b;
  rep(i,n)
  cin >> p[i];
  int c=0,d=0,e=0;
  rep(i,n){
    if(p[i]<=a) c++;
    else if(p[i]<=b) d++;
    else e++;
  }
  cout << min({c,d,e}) << endl;
}

Measured memory_bytes: 256