akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
        a: usize,
        b: usize,
    } 
    println!("{}", (b-1+a-2)/(a-1))
}


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

int main(){
  int N; cin >> N;
  string S; cin >> S;
  vector<int> a(N); rep(i, N) a[i] = S[i] - '0';
  vector<int> x(N - 1); rep(i, N - 1) x[i] = abs(a[i + 1] - a[i]);
  N--;
  bool check = true;
  rep(i, N) if (x[i] == 1) check = false;
  if (check) rep(i, N) x[i] /= 2;
  else rep(i, N) x[i] %= 2;
  int ans = 0;
  rep(i, N) {
    if (((N - 1) & i) == i) ans ^= x[i];
  }
  if (check) ans *= 2;
  cout << ans << endl;
}


Measured memory_bytes: 9220
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
char chbig(char c){return c-32;}
char chlit(char c){return c+32;}

int main(){
  double x1,y1,x2,y2;cin >> x1 >> y1 >> x2 >> y2;
  printf("%.10lf",sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)));
  return 0;
}




Measured memory_bytes: 3200
//四則演算 #pragma GCC target("avx")
//並列計算 #pragma GCC optimize("O3")
//条件分岐を減らす #pragma GCC optimize("unroll-loops")
//浮動小数点演算 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
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(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const 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& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; 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...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    int a; cin >> a;
    print(a + a * a + a * a * a);

    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <set>
using namespace std;
bool p[50000];
int main()
{
  int i,j;
  set<int> s;
  for(i=2;i<50000;i++){
    if(!p[i]){
      s.insert(i);
      for(j=i*2;j<50000;j+=i){
	p[j] = true;
      }
    }
  }
  while(cin >> i,i){
    int c = 0;
    set<int>::iterator it = s.begin();
    while(it != s.end() && (*it) <= i / 2){
      if(s.find(i - *it) != s.end()) {
	c++;
      }
      it++;
    }
    cout << c << endl;
  }
  return 0;
}

Measured memory_bytes: 1076
import sys
from collections import Counter

n = int(input())
s = [sys.stdin.readline().strip() for _ in range(n)]

c = Counter(s)
kaisuu = c.most_common(1)[0][1]
kosuu = Counter([x[1] for x in c.most_common()])[kaisuu]

for label in sorted([x[0] for x in c.most_common(kosuu)]):
  print(label)


Measured memory_bytes: 45076
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i=0; i< n; i++)
typedef long long ll;
using namespace std;


int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	vector<int> q(n);
	vector<int> v(n);
	rep(i, n) {
		cin >> p[i];
		v[i] = i + 1;
	}
	rep(i, n) {
		cin >> q[i];
	}
	int i = 1;
	int l = 0;
	int r = 0;
	
	do {
		for (int j = 0; j < n; j++) {
			if (v[j] != p[j]) break;
			if (j == n - 1) l = i;
		}
		for (int j = 0; j < n; j++) {
			if (v[j] != q[j]) break;
			if (j == n - 1) r = i;
		}
		//rep(i, n) {
		//	cout << v[i] << " ";
		//}
		//cout << endl;
		i++;
    } while (next_permutation(v.begin(), v.end()));
	cout << abs(r - l) << endl;
	//cout << r << " " << l << endl;
	return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val n = io.StdIn.readLine().toInt
  var seq = Seq[(String, Int, Int)]()
  for {i <- 1.to(n)} {
    val Array(s, p) = io.StdIn.readLine().split(" ")
    seq :+= (s, p.toInt, i)
  }
  seq.sortWith((i, j) => {
    if (i._1 != j._1) {
      i._1 < j._1
    } else {
      i._2 > j._2
    }
  }).foreach(i => println(i._3))
}

Measured memory_bytes: 25292
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
const int N = 3e5 + 5; 
typedef long long ll;
const ll INF = 1e16; 
using namespace std;

int n, m, stk[N], top; 
ll s[N], f[N], g[N], t[N], *dp; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

double X(int j) { return j; }
double Y(int j) { return dp[j] + ((ll)j * j - j) / 2 + s[j]; }
double slope(int i,int j) { return (Y(i) - Y(j)) / (X(i) - X(j)); }
ll calc(int i,int j) { return dp[j] + ((ll)(i - j + 1) * (i - j)) / 2 - (s[i] - s[j]); }
void DP()
{
	for(int i = 1;i <= n;i++) s[i] = s[i - 1] + t[i];
	stk[top = 1] = 0;
	for(int i = 1;i <= n;i++)
	{
		while(top > 1 && calc(i,stk[top]) <= calc(i,stk[top - 1])) top--; 
		dp[i] = max(calc(i,stk[top]),dp[i - 1]); 
		while(top > 1 && slope(stk[top - 1],i) >= slope(stk[top],stk[top - 1])) top--;
		stk[++top] = i;
	}
}

double X1(int j) { return j; }
double Y1(int j) { return f[j] + s[j] + ((ll)j * j - j) / 2; }
double slope1(int i,int j) { return (Y1(i) - Y1(j)) / (X1(i) - X1(j)); }
ll calc1(int i,int j)
{ return g[i + 1] + ((ll)(i - j) * (i - j + 1)) / 2 - (s[i] - s[j]) + f[j]; }

double X2(int j) { return j; }
double Y2(int j) { return g[j + 1] + ((ll)j * j + j) / 2 - s[j]; }
double slope2(int i,int j) { return (Y2(i) - Y2(j)) / (X2(i) - X2(j)); }
ll calc2(int i,int j)
{ return f[i] + ((ll)(j - i) * (j - i + 1)) / 2 - (s[j] - s[i]) + g[j + 1]; }

ll h[N];
void solve(int l,int r)
{
	if(l == r) { h[l] = 1 - t[l];return; }
	int mid = l + r >> 1;solve(l,mid),solve(mid + 1,r);
	top = 0;
	for(int i = l - 1;i < mid;i++)
	{
		while(top > 1 && slope1(i,stk[top - 1]) >= slope1(stk[top],stk[top - 1])) top--;
		stk[++top] = i;
	}int head = 1;ll maxx = -INF;
	for(int i = r;i > mid;i--)
	{
		while(head < top && calc1(i,stk[head]) <= calc1(i,stk[head + 1])) head++;
		maxx = max(maxx,calc1(i,stk[head]));
		h[i] = max(h[i],maxx);
	}top = 0;
	for(int i = mid + 1;i <= r;i++)
	{
		while(top > 1 && slope2(i,stk[top - 1]) >= slope2(stk[top],stk[top - 1])) top--;
		stk[++top] = i;
	}maxx = -INF;
	for(int i = l - 1;i < mid;i++)
	{
		while(top > 1 && calc2(i,stk[top]) <= calc2(i,stk[top - 1])) top--;
		maxx = max(maxx,calc2(i,stk[top]));
		h[i + 1] = max(h[i + 1],maxx);
	}
}

int main()
{
	n = read <int> (); 
	for(int i = 1; i <= n; i++) t[i] = read <int> (); 
	dp = f, DP(), reverse(t + 1, t + n + 1), dp = g, DP(); 
	reverse(t + 1, t + n + 1), reverse(g + 1, g + n + 1); 
	for(int i = 1; i <= n; i++) s[i] = s[i - 1] + t[i]; 
	solve(1, n), m = read <int> (); 
	for(int pos, v, i = 1; i <= m; i++)
	{
		pos = read <int> (), v = read <int> ();
		printf("%lld\n", max(f[pos - 1] + g[pos + 1], h[pos] + t[pos] - v)); 
	}
	return 0; 
}

Measured memory_bytes: 15460
#include <bits/stdc++.h>
 
#define int long long
#define MOD 1000000007
 
using namespace std;
 
template <class T> ostream &operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for (auto v : V)
        os << v << " ";
    os << "]";
    return os;
}
template <class T> ostream &operator<<(ostream &os, set<T> S) {
    os << "{ ";
    for (auto s : S)
        os << s << " ";
    return os << "}";
}
template <class L, class R> ostream &operator<<(ostream &os, map<L, R> M) {
    os << "{ ";
    for (auto m : M)
        os << "(" << m.first << ":" << m.second << ") ";
    return os << "}";
}
template <class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}

int getMax(int n) {
    int count = 0;
    while(n % 2 == 0) {
        count ++;
        n /= 2;
    }
    return count;
}
  
void solve() {
    int n, k;
    cin >> n;
    string res = "";
    n--;
    // char init = 'a';
    // init--;
    while(n >= 0) {
        res = (char)('a' + (n % 26)) + res;
        n /= 26;
        n--;
    }
    cout << res << endl;
}
 
int32_t main() {
    int t;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    // cin >> t;
    // while(t--) {
    //     solve();
    // }
    return 0;
}

Measured memory_bytes: 3652
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        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 Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  string s;
  cin>>s;
  ll dp[s.size()][13];
  rep(i,s.size()) rep(j,13) dp[i][j]=0;
  if(s[0]=='?') rep(i,10) dp[0][i]=1;
  else dp[0][s[0]-'0']=1;
  
  rep(i,s.size()-1){
    if(s[i+1]=='?'){
      rep(j,13){
        rep(k,10){
          dp[i+1][((10*j)%13+k)%13]+=dp[i][j];
          dp[i+1][((10*j)%13+k)%13]%=MOD;
        }
      }
      
      
    }else{
      rep(j,13){
        dp[i+1][((10*j)+(s[i+1]-'0'))%13]+=dp[i][j];
        dp[i+1][((10*j)+(s[i+1]-'0'))%13]%=MOD;
        
      }
      
      
    }
  }
  cout<<dp[s.size()-1][5]<<endl;
  
  
}

Measured memory_bytes: 10704
N=int(input())
D=[0]*N
A=list(map(int,input().split()))
for i in range(N):
    D[(i+1)*2%N] = D[i*2%N] + (A[(i*2+1)%N] - A[i*2%N])*2
r = (sum(A) - sum(D))//N
print(*list(map(lambda x: x+r, D)))


Measured memory_bytes: 70756
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

template<typename T>
struct SegmentTree{
private:
    int N;
    vector<T> node;
    function<T(T, T)> F;
    T DEFAULT;
public:
    void init(int n, function<T(T, T)> f, T def){
        F = f;
        DEFAULT = def;
        N = 1;
        while(N < n) N = (N<<1);
        node.assign(2*N-1, DEFAULT);
    }
    T& operator [](int a){
        return node[a+N-1];
    }
    void update(int a, T x){
        a += N-1;
        node[a] = x;
        while(a > 0){
            a = (a-1)>>1;
            node[a] = F(node[(a<<1)+1], node[(a<<1)+2]);
        }
    }
    T query(int a, int b, int k=0, int l=0, int r=-1){
        if(r == -1) r = N;
        if(b <= l || r <= a) return DEFAULT;
        if(a <= l && r <= b) return node[k];
        return F(query(a, b, (k<<1)+1, l, (l+r)>>1), query(a, b, (k<<1)+2, (l+r)>>1, r));
    }
};

int N, K, C;
string S;

int dpL[400000] ={}; // i 日目に働く場合，0～i 日目に最大で何回働ける？
int dpR[400000] ={};
int dpLm[400000] ={};
int dpRm[400000] ={};

int sum[400000] ={};

SegmentTree<int> rmq;

signed main(){
    cin >> N >> K >> C >> S;

    rep(i, N){
        if(S[i] == 'x') dpL[i] = 0;
        else dpL[i] = 1 + (i-C-1 >= 0 ? dpLm[i-C-1] : 0);

        if(i == 0) dpLm[i] = dpL[i];
        else dpLm[i] = max(dpLm[i-1], dpL[i]);
    }
    for(int i=N-1; i>=0; i--){
        if(S[i] == 'x') dpR[i] = 0;
        else dpR[i] = 1 + (i+C+1 < N ? dpRm[i+C+1] : 0);

        if(i == N-1) dpRm[i] = dpR[i];
        else dpRm[i] = max(dpRm[i+1], dpR[i]);
    }
    rmq.init(N, [](int a, int b){ return max(a, b); }, 0);
    rep(i, N){
        if(i+C+1 >= N) break;
        sum[i] = dpLm[i] + dpRm[i+C+1];
        rmq.update(i, sum[i]);
    }

    rep(i, N){ // i 日目は働かずに済むか
        if(S[i] == 'x') continue;
        // sum[j] がいけるのは j < i && i < j+C+1 の場合
        // i-C-1 < j < i
        // [i-C, i)
        int M = 0;
        if(i > 0) M = max(M, dpLm[i-1]);
        if(i+1 < N) M = max(M, dpRm[i+1]);
        if(i > 0 && C != 0) M = max(M, rmq.query(max(0, i-C), i));
        if(C == 0 && i > 0 && i+1 < N) M = max(M, dpLm[i-1]+dpRm[i+1]);
        if(M < K) cout << i+1 << endl;
    }
}

Measured memory_bytes: 9988
#a,b
a,b=(int(x) for x in input().split())
i = 1

if  a == b:
    while (i<=a):
        print(a, end="")
        i += 1
elif a>b:
    while (i<=a):
        print(b, end="")
        i += 1
elif a<b:
    while (i<=b):
        print(a, end="")
        i += 1

print()


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

int main() {
  string correct = "keyence";
  string key;
  cin >> key;

  if(key.size() == 7) {
    if(key == correct) {
      cout << "YES" << endl;
      return 0;
    }else {
      cout << "NO" << endl;
      return 0;
    }
  }else {
    int re = key.size() - 7;
    for(int i = 0; i < key.size(); i++) {
      if(key[i] != correct[i]) {
        key.erase(i, re);
        if(key == correct) {
          cout << "YES" << endl;
          return 0;
        }else {
          cout << "NO" << endl;
          return 0;
        }
      }
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
const int MOD = 1000000007;
;
long long kaijo(long long x){
    ll p=1;
    while(x!=0){
        p*= x;
        p%=MOD;
        x--;
    }
    return p;
}
signed main(void){
    int d,m; cin>>d>>m;
    if(abs(d-m)>1) {cout<<0<<endl; return 0;}
    else if(d==m){
        cout<< (2*kaijo(d)*kaijo(m)) % MOD <<endl;
    }else{
        cout<<(kaijo(d) * kaijo(m)) % MOD<<endl;
    } 
    
}


Measured memory_bytes: 256
def main():
    N = int(input())
    mod = 10**9 + 7
    C = list(map(int, input().split()))
    C.sort()
    r = 0
    for i, v in enumerate(C[:-1]):
        r += pow(2, N-i-2, mod) * (N- i + 1) * v * pow(2, i, mod)
        r %= mod
    r += C[-1] * pow(2, N-1, mod)
    r *= pow(2, N, mod)
    r %= mod
    return r
print(main())


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

int main() {
  int N; cin>>N;
  vector<int> d(N);
  rep(i,N) cin>>d[i];
  sort(d.begin(),d.end());
  cout<<d[N/2]-d[N/2-1]<<endl;
  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
long long power(int x)
{
	return x * x;
}
int main()
{
	int i = 0;
	long long N;
	scanf("%lld", &N);
	while (true) {
		if (power(i + 1) > N) {
			printf("%lld", power(i));
			return 0;
		}
		i++;
	}
	return 0;
}

Measured memory_bytes: 128
x = input().split()
total = int(x[0]) + int(x[1])
k = int(x[2])
if(total <= k):
  print('0 0')
else:
  if(k <= int(x[0])):
    print(str(int(x[0]) - k) + ' ' + x[1])
  else:
    print('0 ' + str(total - k))

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 200005
#define MOD 1000000007
#define LL long long
int H,W,A,B,N;
int a[MAXN];
LL s[MAXN],inv[MAXN];
LL Pow(LL a,int b)//快速幂
{
	LL ans=1;
	while(b)
	{
		if(b&1) ans=ans*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return ans;
}

void Pre()
{
	s[0]=1;
	for(int i=1;i<=N;i++)
		s[i]=s[i-1]*i%MOD;   //阶乘
	inv[0]=1;
	inv[N]=Pow(s[N],MOD-2);
	for(int i=N-1;i>0;i--)
		inv[i]=inv[i+1]*(i+1)%MOD;
}

LL C(int a,int b)
{
	if(a<0||b<0) return 1;
	return s[a]*inv[b]%MOD*inv[a-b]%MOD;
}
int main()
{
	scanf("%d %d %d %d",&H,&W,&A,&B);
	N=H+W-2;
	Pre();
	LL ans=C(H+W-2,H-1);
	for(int i=1;i<=B;i++)
	{
		ans-=C(H-A+i-2,H-A-1)*C(A-1+W-i,A-1)%MOD;
		ans=(ans%MOD+MOD)%MOD;
	}
	/*LL ans=0;
	for(int i=B+1;i<=W;i++)
	{
		ans+=C(H-A+i-2,i-1)*C(A+W-i,A)%MOD;
		ans=(ans%MOD+MOD)%MOD;
	}*/
	printf("%lld\n",ans);
	return 0;
}


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

int main(){
  long int n, m, l, A[100][100], B[100][100], C[100][100] = {};
  cin >> n >> m >> l;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      cin >> A[i][j];
    }
  }
  for(int i = 0; i < m; i++){
    for(int j = 0; j < l; j++){
      cin >> B[i][j];
    }
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      for(int k = 0; k < l; k++){
        C[i][k] += A[i][j] * B[j][k];
      }
    }
  }
  for(int i=0;i<n;i++){
				for(int j=0;j<l;j++){
					if(j!=l-1)cout<<C[i][j]<<" ";
					else cout<<C[i][j]<<endl;
				}
			}
			return 0;
}



Measured memory_bytes: 3324
from collections import deque

n, q = map(int, input().split())
rg = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    rg[a-1].append(b-1)
    rg[b-1].append(a-1)

deq = deque()
pnt = [0] * n

for _ in range(q):
    p, x = map(int, input().split())
    pnt[p-1] += x

visited = set()

deq.append(0)
visited.add(0)

while deq:
    ptr = deq.pop()
    for item in rg[ptr]:
        if item not in visited:
            visited.add(item)
            pnt[item] += pnt[ptr]
            deq.append(item)

print(' '.join(map(str, pnt)))


Measured memory_bytes: 141936
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
using ll = long long;
int main(){
  int n,k,a,cnt=0;
  cin >> n >> k;
  rep(i,n){
  	cin >> a;
    if(a >= k)cnt++;
  }
  cout << cnt <<endl;
  return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
    input! {
        k: usize,
        a: usize,
        b: usize,
    }
    let mut ans = "NG";

    for i in a..b+1 {
        if i % k == 0 {
            ans = "OK";
            break;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2172
# 制限時間以内でコストの最小のものを選ぶ
n, t = map(int, input().split())
v = [list(map(int, list(input().split()))) for i in range(n)]
list = []
for i in range(n):
    if v[i][1] <= t:
        list.append(v[i][0])
if list == []:
    print("TLE")
else:
    print(min(list))

Measured memory_bytes: 3064
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N, C = getNM()
query = [getList() for i in range(N)]
dp = [[0] * (C + 1) for i in range(10 ** 5 + 2)]
for i in range(N):
    s, t, c = query[i]
    dp[s][c] += 1
    dp[t + 1][c] -= 1

for i in range(1, 10 ** 5 + 2):
    for j in range(C + 1):
        dp[i][j] += dp[i - 1][j]

ans = 0
for i in range(10 ** 5 + 2):
    cnt = 0
    for j in dp[i]:
        if j > 0:
            cnt += 1
    ans = max(ans, cnt)
print(ans)

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

using i64 = int64_t;

int main(){
    i64 n, k;
    cin >> n >> k;
    map<i64, i64> mp;
    for(int i=0;i<n;++i){
        i64 a, b;
        cin >> a >> b;
        mp[a] += b;
    }

    i64 sum = 0, ans = -1;
    for(auto e: mp){
        sum += e.second;
        if(sum >= k){
            ans = e.first;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
    string s[3];
    int a=0,b=0,c=0;
    int turn=0;
    cin >> s[0] >> s[1] >> s[2];
    while(true){
        if(turn==0){
            if(a>=s[0].size()){
                cout << "A" << "\n";
                return 0;
            }
            turn=s[0][a]-'a';
            a++;
        }
        if(turn==1){
            if(b>=s[1].size()){
                cout << "B" << "\n";
                return 0;
            }
            turn=s[1][b]-'a';
            b++;
        }
        if(turn==2){
            if(c>=s[2].size()){
                cout << "C" << "\n";
                return 0;
            }
            turn=s[2][c]-'a';
            c++;
        }
    }
}

Measured memory_bytes: 256
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N;
    cin >> N;
    double ans = 0;
    REP(i,N) {
        double x;
        string S;
        cin >> x >> S;
        if(S == "JPY") ans += x;
        else ans += x * 380000.0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;
void solve()
{
	int n;
	cin>>n;
	vector<int> v(n);
	REP(i,n)
		cin>>v[i];
	sort(all(v));
	cout<<v[v.size()-1]-v[0]<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	private static final byte MASK_RIGHT = 0x0F;
	private static int[][] paper = new int[10][10];

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 128);
		String sLine;
		while ((sLine = reader.readLine()) != null) {
			droppingInk(sLine.charAt(0) & MASK_RIGHT, sLine.charAt(2) & MASK_RIGHT, sLine.charAt(4) & MASK_RIGHT);
		}
		calcResult();
	}

	private static void droppingInk(int x, int y, int size) {
		staining(x, y - 1);
		staining(x - 1, y);
		staining(x, y);
		staining(x + 1, y);
		staining(x, y + 1);
		if (size == 1) {
			return;
		}

		staining(x - 1, y - 1);
		staining(x + 1, y - 1);
		staining(x - 1, y + 1);
		staining(x + 1, y + 1);
		if (size == 2) {
			return;
		}

		staining(x, y - 2);
		staining(x - 2, y);
		staining(x + 2, y);
		staining(x, y + 2);
	}

	private static void staining(int x, int y) {
		if (x >= 0 && x < 10 && y >= 0 && y < 10) {
			paper[x][y]++;
		}
	}

	private static void calcResult() {
		int white = 0;
		int maxnoud = 0;
		for (int[] row : paper) {
			for (int colum : row) {
				if (colum == 0) {
					white++;
				} else if (colum > maxnoud) {
					maxnoud = colum;
				}
			}
		}
		System.out.println(white + System.getProperty("line.separator") + maxnoud);
	}
}

Measured memory_bytes: 16864
# PyPy3 (2.4.0)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------
from collections import defaultdict, deque
class DAG:
    def __init__(self, adjList, inDegreeArray):
        self.A = adjList
        self.In = inDegreeArray
        self.n = len(inDegreeArray)
        self.depth = [-1]*(self.n)
        self.nodes = []

    def sort(self):
        dq = deque()
        # 入次数が 0 の頂点を deque に入れる
        for i in range(self.n):
            if self.In[i] == 0:
                dq.append(i)
                self.depth[i] = 0
        while dq:
            v1 = dq.popleft()
            self.nodes.append(v1)
            for v2 in self.A[v1]:
                self.In[v2] -= 1
                self.depth[v2] = max(self.depth[v2], self.depth[v1] + 1)
                if In[v2] == 0:
                    dq.append(v2)
    
    def get_node_array(self):
        return self.nodes
    
    def get_depth(self):
        return self.depth

# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
A = [list(map(int,input().split())) for _ in range(N)]

# 試合と頂点の対応表
M = [[-1 for _ in range(N)] for _ in range(N)]
cnt = 0
for i in range(N):
    for j in range(i+1,N):
        M[i][j] = cnt
        M[j][i] = cnt
        cnt += 1

# 試合 j が 試合 i の翌日以降にしか行えない -> G[i][j]

G = [[] for _ in range((N*(N-1)//2))]
# 頂点(試合) の入次数
In = [0]*(N*(N-1)//2)
# 入力からグラフ, 配列を生成
for i in range(N):
    for j in range(N-2):
        gagem_id = M[i][ A[i][j] - 1 ]
        next_game_id = M[i][ A[i][j+1] - 1 ]
        G[gagem_id].append(next_game_id)
        In[next_game_id] += 1

dag = DAG(G, In)
dag.sort()
node = dag.get_node_array()
depth = dag.get_depth()

if len(node) != len(In):
    print(-1)
else:
    print(max(depth) + 1)


Measured memory_bytes: 142300
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1e9+1
#pragma GCC optimization ("O3")
using namespace std;
const long long int N = 6999999;
#define all(x) begin(x),end(x)
int main()
{
 
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  long long int n,c =0;
  cin >> n;
  vector <long long int> v(n+1),sv(n);
  for (int i = 0; i < n+1; ++i)
  {
    cin >> v[i];
  }
  for (int i = 0; i < n; ++i)
  {
    cin >> sv[i];
  }
  for (int i = 0; i < n; ++i)
  {
    long long int h = min(v[i],sv[i]);
    v[i] -= h;sv[i] -= h ;c += h;
    h = min(v[i+1],sv[i]);
    v[i+1] -= h;c+=h;
  }
  cout << c << endl;
  return 0;
} 


Measured memory_bytes: 1792
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define all(a) a.begin(),a.end()
#define endl '\n'
#define ull unsigned long long
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define iter vector<int>::iterator
#define iter1 vector<int>::iterator
#define int long long
using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

template<class T>
using ordered_multiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rnd1(chrono::steady_clock::now().time_since_epoch().count());

//find_by_order
//order_of_key

const int N=2e5+7;
const int inf=1e18+1e9;
const int mod=1e9+7;
const ld eps=1e-9;

int h[N];
int dp[N];

main ()
{
    ios;
    int n,k;
    cin>>n>>k;
    for (int i=1;i<=n;++i){
        cin>>h[i];
    }
    dp[1]=0;
    dp[0]=inf;
    for (int i=2;i<=n;++i){
        dp[i]=inf;
        for (int j=1;j<=min(i-1,k);++j){
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
 
int main(){
  int h, w, i, j;
  while(scanf("%d%d", &h, &w) && h && w){
    for(i = 0;i < h;i++){
      for(j = 0;j < w;j++) putchar((i + j) % 2 == 0 ? '#' : '.');
      puts("");
    }
    puts("");
  }
  return 0;
}


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

int main() {
  int x1,x2,x3,x4,x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;
  if (x1 == 0){
    cout << 1 << endl;
  }
  else if (x2 == 0){
    cout << 2 << endl;
  }
  else if (x3 == 0){
    cout << 3 << endl;
  }
  else if(x4 == 0){
cout << 4 << endl;
  }
  else if (x5 == 0){
    cout << 5 << endl;
  }
}


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

using namespace std;

int main()
{
    int n,k;
    cin >> n >> k;
    int h;
    int ans=0;
    for(int i=0;i<n;i++){
        cin >>h ;
        if(h>=k){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N,M = map(int,(input().split()))
A = [0]*M
B = [0]*M
for i in range(M):
    A[i],B[i] = map(int,(input().split()))
bridge = [[] for _ in range(N)]

# UnionFind
class UnionFind:

    def __init__(self, n):
        self.par =  [-1] * n
        self.rank = [0] * n
    
    def root(self,x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.root(x)
        y = self.root(y)

        if x == y:
            return
        else:
            if self.rank[x] <self.rank[y]:
                self.par[y] += self.par[x] # 負+負でsize管理 
                self.par[x] = y
            else:
                self.par[x] += self.par[y]
                self.par[y] = x
                if self.rank[x] == self.rank[y]: # 負+負でsize管理 
                    self.rank[x] += 1
    
    def is_same(self, x, y):
        return self.root(x) == self.root(y)

    def size(self, x):
        return -self.par[self.root(x)]

Tree = UnionFind(N)
isolated = N*(N-1)//2
ans = []
ans.append(isolated)
for i in range(1,M)[::-1]:
    if not Tree.is_same(A[i]-1,B[i]-1):
        isolated -= Tree.size(A[i]-1) * Tree.size(B[i]-1)
    Tree.union(A[i]-1,B[i]-1)
    ans.append(isolated)

ans.reverse()
for i in range(M):
    print(ans[i])

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	int l,r,d;
	scanf("%d %d %d",&l,&r,&d);
	int cnt = 0;
	for(int i=l;i<=r;i++){
		if(i % d == 0){cnt++;}
	}
	printf("%d\n",cnt);
	
	return 0;
};

Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std ;
const int maxn = 5e3 + 10 ;
#define ll long long
int p[maxn] , h[maxn] , n , ans = 0 ;
#define fi first 
#define se second
pair < int , ll > z[maxn] ;
ll dp[maxn][maxn] ;
int main()
{
	cin >> n ;
	for ( int i  = 1 ; i<= n ; i++)
	{
		cin >> h[i] >> p[i] ;
		z[i].fi = h[i]+p[i] , z[i].se = i ;
	}
	sort ( z + 1 , z+n+1 ) ;
	for ( int i =1 ; i<=n ; i++)
	{
		for ( int j = n ; j>=1 ; j-- ) 
		{
			if ( ( dp[i-1][j-1] ^ ( j==1 )) && dp[i-1][j-1] <= h[z[i].second] )
				dp[i][j] = ( dp[i][j] == 0 ? dp[i-1][j-1] + p[z[i].se] : min ( dp[i][j] , dp[i-1][j-1] + p[ z[i].second] )) , ans = max ( ans , ( (bool) dp[i][j] * j )) ;
			//cout << " ans " << ans << endl;
			if ( dp[i-1][j] ) 
				dp[i][j] = min ( dp[i][j] , dp[i-1][j] ) ;
			if ( !dp[i][j] ) 
				dp[i][j] = dp[i-1][j] ;
		}
	}
	cout << ans << endl;

	
}


Measured memory_bytes: 196096
n,l = map(int,input().split())
sum = 0.5 * n * (2 * l + n -1)

s = list(l+i-1 for i in range(n+1))
a = list(sum - int(abs(s[j])) for j in range(1,n+1))

if max(a) > 0:
        print(int(max(a)))
elif max(a)<0:
        print(int(sum - max(s)))
else:
        print(int(sum))

Measured memory_bytes: 3188
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans=0;
    char a;
    ll cnt=0;
    while(cin>>a){
        if (a=='A'||a=='C'||a=='G'||a=='T')cnt++;
        else {
            cnt=0;
        }
        ans=max(ans,cnt);
    }

    dbg{
        if(true)cout <<"YES"<<endl;
        else cout <<"NO"<<endl;
    }

    cout <<ans<<endl;

    return 0;

}

Measured memory_bytes: 256
//Link : https://codeforces.com/contest/1253

#include <bits/stdc++.h>
using namespace std;
#define ll long long
/*
#include <limits.h>
INT_MAX
LLONG_MAX
*/
#define B 18
#define BIT (1<<B)

int cc[BIT],parity[BIT];
#define N 105

ll combi[N][N], csum[N][N];
void solve() {
  int n,k,s,t;
  scanf("%d %d %d %d ", &n,&k,&s,&t);
  if((t&s)!=s) {
    printf("0\n");
    return;
  }
  for(int i=0;i<N;++i) {
    combi[i][0] = 1;
    for(int j=1;j<i;++j) {
      combi[i][j] = combi[i-1][j] + combi[i-1][j-1];
    }
    combi[i][i] = 1;
    for(int j=1;j<N;++j) {
      csum[i][j] = csum[i][j-1] + combi[i][j];
    }
  }
  vector<int> in;
  for(int i=0;i<n;++i) {
    int a;
    scanf("%d ", &a);
    if( ((a&s) ==s )&& ( (t&a) ==a) ) {
      in.push_back(a^s);
    }
  }
  t^=s;
  int tb = 0;
  for(int b=0;b<B;++b) {
    if(t&(1<<b)) {
      ++tb;
    }
  }
  for(int i=0;i<in.size();++i) {
    int sum = 0, cur = 1;
    for(int b=0;b<B;++b) {
      if(in[i]&(1<<b)) {
        sum += cur;
      }
      if(t&(1<<b)) {
        cur = cur*2;
      }
    }
    in[i] = sum;
  }
  ll ret = 0;
  for(int bit=0;bit<(1<<tb);++bit) {
    parity[bit] = parity[bit/2];
    if(bit&1) {
      parity[bit] ^= 1;
    }
    ll sum = 0;
    for(int a : in) {
      sum -= csum[cc[(bit&a)]][min(cc[(bit&a)],k)];
      ++cc[bit&a];
      sum += csum[cc[(bit&a)]][min(cc[(bit&a)],k)];
    }
    for(int a : in) {
      --cc[bit&a];
    }
    if(parity[bit]) {
      sum *= -1;
    }
    ret += sum;
  }
  printf("%lld\n", ret);
}

int main() {
  //freopen("input.txt","r",stdin);
  solve();
  return 0;
}


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

int main(){
    long long n, a, b;
    std::cin >> n >> a >> b;

    long long max = a + b * (n - 1), min = a * (n - 1) + b;

    std::cout << std::max(0ll, max - min + 1) << std::endl;

    return 0;
}

Measured memory_bytes: 256
/*Lucky_Glass*/
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e5;
vector<int> lnk[N+3];
int n,m,nidx;
int du[N+3],dep[N+5];
int idx[N+3];
vector<pair<int,int> >ans;
int DFS(int u,int depth,int pre){
	idx[u]=++nidx;
	dep[u]=depth;
	int ret=0;
	for(auto v : lnk[u]){
		if(v==pre) continue;
		if(dep[v]){
			if(dep[v]<dep[u]) ret++,ans.push_back(make_pair(u,v));
			continue;
		}
		int retv=DFS(v,depth+1,u);
		if(retv%2==0) ret++,ans.push_back(make_pair(u,v));
		else ans.push_back(make_pair(v,u));
	}
	return ret;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int u,v;scanf("%d%d",&u,&v);
		lnk[u].push_back(v);
		lnk[v].push_back(u);
		du[u]++;du[v]++;
	}
	int res=DFS(1,1,0);
	if(res%2) printf("-1\n");
	else{
		for(int i=0;i<ans.size();i++)
			printf("%d %d\n",ans[i].first,ans[i].second);
	}
	return 0;
}

Measured memory_bytes: 18292
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
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; }
signed main(void){
    int x; cin>>x;
    int k = x/100;
    double res = x - k*100;
    //cout<<res<<endl;
    double y = ceil(res/5.0);
    if(y > k) cout<<0<<endl;
    else cout<<1<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long int pow107 = (int)pow(10, 9) + 7;

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

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}


int main(){
    string s1,s2;
    cin >> s1 >> s2;
    for(int i = 0; i < s2.size(); ++i){
        cout << s1[i] << s2[i];
    }
    if(s1.size() > s2.size())
        cout << s1[s1.size()-1];
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include "bits/stdc++.h"
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define lpe(i, n) for (int i = 1; i <= (int)(n); ++i)
#define lpd(i, n) for (int i = (int)(n); i >= 1; --i)
#define ll long long
using namespace std;
typedef pair<ll, ll> pl;
typedef vector<ll> vl;
typedef map<ll, ll> ml;
int a[1000000];
int main()
{string s;
cin>>s;
if(s[2]==s[3] and s[4]==s[5])cout<<"Yes";
else cout<<"No";

    return 0;
}


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

int main(){
  string s;
  while (cin >> s) {
    string ans;
    for (int i = 0; i < s.size(); i++) {
      if (s.at(i) == '@') {
        int n = s.at(i + 1) - '0';
        for (int j = 0; j < n; j++) {
          ans += s.at(i + 2);
        }
        i += 2;
      } else {
        ans += s.at(i);
      }
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3140
d=input().split()
for o in input():
 s={'N':(0,1,5,4),'W':(0,2,5,3),'E':(0,3,5,2),'S':(0,4,5,1)}[o]
 for i in range(3):d[s[i+1]],d[s[i]]=d[s[i]],d[s[i+1]]
print(d[0])


Measured memory_bytes: 5564
<?php
$N=(int)trim(fgets(STDIN));
$A=explode(' ',trim(fgets(STDIN)));

$trade=0;
$flag=1;
while($flag){
  $flag=0;
  for($j=$N-1;0<$j;$j--){
    if($A[$j]<$A[$j-1]){
      list($A[$j],$A[$j-1])=[$A[$j-1],$A[$j]];
      $flag=1;
      ++$trade;
    }
  }
}
echo implode(' ',$A),PHP_EOL,$trade;
?>

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

typedef long long ll;

const ll MOD = 1e9 + 7;

int main() {
	int N; ll m; cin >> N >> m;
	vector<ll> A(N); for (auto&& x : A)cin >> x;
	
	vector<ll> sum(N + 1, 0);
	for (int i = 0; i < N; i++) { sum[i + 1] = (sum[i] + A[i]) % m; }

	map<ll, ll> mp; ll ans = 0;
	for (int i = 0; i <= N; i++) {
		ans += mp[sum[i]];
		mp[sum[i]]++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5760
#include <stdio.h>
#include <string.h>
char str1[1510];
char str2[1510];
char str3[1510];
int main(){
    int m;
    int a,b;
    int i,j;
    char p;
    scanf("%s",&str1);
    scanf("%d",&m);
    for(i=0;i<m;i++){
        scanf("%s",&str3);
        if(strcmp(str3,"replace")==0){
            scanf("%d %d %s",&a,&b,&str2);
            for(j=0;j<b-a+1;j++){
            str1[a+j]=str2[j];
            }
        }
        else if(strcmp(str3,"reverse")==0){
            scanf("%d %d",&a,&b);
            while(a<b){
                p=str1[a];
                str1[a]=str1[b];
                str1[b]=p;
                a++;
                b--;
            }
        }
        else if(strcmp(str3,"print")==0){
            scanf("%d %d",&a,&b);
            for(j=a;j<=b;j++){
                printf("%c",str1[j]);
            }
            puts("");
        }
    }
    return 0;
}



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

int main(){
  int N,M;
  cin >> N >> M;
  vector<vector<int>> blum(M);
  vector<int> p(M);
  rep(i,M){
    int k;
    cin >> k;
    rep(j,k){
      int sw;
      cin >> sw;
      sw--;
      blum[i].push_back(sw);
    }
  }
  rep(i,M){
    cin >> p.at(i);
  }
  int ans = 0;
  for(int i=0; i<(1<<N); i++){
    bool ok = true;
    for(int j=0; j<M; j++){
      int c = 0;
      for(int id : blum[j]){
        if(i & (1<<id)) c++;
      }
      c %= 2;
      if(p[j] != c) ok = false;
    }
    if(ok) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<int> v;
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
  }

  bool flg = true;
  rep(i,N){
    if(v[i]%2==0){
      if(v[i]%3!=0 && v[i]%5!=0) flg = false;
    }
  }

  if(flg) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
  
  return 0;
}



Measured memory_bytes: 256