akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef std::pair<int, int> ipair;
#define pb push_back
#define ff first
#define ss second
#define fr(i, j, k) for (int i = j; i < k; i++)
#define rf(i, j, k) for (int i = j; i >= k;i--)
#define int long long
#define ld long double
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define mp make_pair

const int mod = 1000000007;
const ld pi = acos(-1);
const int maxn = 2001;

template<class T> ostream& operator <<(ostream &out,vector<T> &A){for(auto x:A) out<<x<<" ";return out;}
template <class T1,class T2>T1 powr(T1 a,T2 b){T1 res = 1;fr(i,1,b+1)res = res*a;return res;}
#define IOS  std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int32_t main(){
  int n;  cin>>n;
  bool flag = true;
  vector<int>A(n);  fr(i,0,n) cin>>A[i];
  rf(i,n-2,0){
    if(A[i] <= A[i+1])  continue;
    if(A[i] - A[i+1] == 1)  A[i]--;
    else{
      flag = false;
      break;
    }
  }
  puts(flag ? "Yes" : "No");
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    vector<int>a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int tmp=k, cnt=1;
    if(n<=tmp){
        cout << cnt << endl;
        return 0;
    }
    while(true){
        tmp = tmp+k-1;
        cnt++;
        if(n<=tmp) break;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3732
#include<iostream>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//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 debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n,m;
   cin>>n>>m;
   vector<pii>v;
   rep(i,0,n)
   {
       int x,y;
       cin>>x>>y;
       v.pb({x,y});
   }
   sort(all(v));
   priority_queue<int>pq;
   int ans=0;int j=0;
   for(int i=1;i<=m;i++)
   {
       while(j<n && v[j].F<=i)
       {
           pq.push(v[j].S);
           j++;
       }
       if(!pq.empty())
       {ans+=pq.top();
       pq.pop();}
   }
   cout<<ans<<endl;
}



Measured memory_bytes: 3568
// ARC087
// E - Prefix-free Game

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 100000;

struct node {
    int child[2] = {-1, -1};
};

int N;
ll L;
vector<node> tree;

void add(string &s, int k = 0, int v = 0) {
    if (k >= (int)s.size()) {
        return;
    }
    node &nd = tree[v];
    int next_i = s[k] == '0' ? 0 : 1;
    int next_v = nd.child[next_i];
    if (next_v == -1) {
        next_v = nd.child[next_i] = tree.size();
        tree.push_back(node());
    }
    add(s, k + 1, next_v);
    return;
}

ll grundy(ll a) { return a & (-a); }

ll dfs(int v = 0, ll d = 0) {
    if (v == -1) {
        return 0;
    }
    ll ret = 0;
    if ((tree[v].child[0] == -1) != (tree[v].child[1] == -1)) {
        ret = grundy(L - d);
    }
    for (int i = 0; i < 2; i++) {
        ret ^= dfs(tree[v].child[i], d + 1);
    }
    return ret;
}

int main() {
    cin >> N >> L;
    tree.push_back(node());
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        add(s);
    }

    cout << (dfs() != 0 ? "Alice" : "Bob") << endl;

    return 0;
}


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

int main(){
    int N,X,Y;
    cin>>N>>X>>Y;
    Y--,X--;

    vector<int> dis(2*1000,0);

    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            int tmp = min(j-i,abs(i-X)+abs(j-Y)+1);
            dis[tmp]++;
        }
    }

    for(int i=1; i<N; i++){
        cout<<dis[i]<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 7;
const int mod = 1e9 + 7;
int a[5][5];
int vis[5][5];
int main(){
	for(int i = 1;i <= 3;i++){
		for(int j = 1;j <= 3;j++){
			scanf("%d",&a[i][j]);
		}
	}
	memset(vis,0,sizeof(vis));
	int b;
	scanf("%d",&b);
	while(b--){
		int x;
		scanf("%d",&x);
		for(int i = 1;i <= 3;i++){
			for(int j = 1;j <= 3;j++){
				if(x == a[i][j]) vis[i][j] = 1;
			}
		}
	}
	int fl = 0;
	int cnt1 = 0,cnt2 = 0,cnt3 = 0;
	for(int i = 1;i <= 3;i++){
		if(vis[1][i] == 1) cnt1++;
		if(vis[2][i] == 1) cnt2++;
		if(vis[3][i] == 1) cnt3++;
	}
	if(cnt1 == 3 || cnt2 == 3 || cnt3 == 3) fl = 1;
	cnt1 = 0,cnt2 = 0,cnt3 = 0;
	for(int i = 1;i <= 3;i++){
		if(vis[i][1] == 1) cnt1++;
		if(vis[i][2] == 1) cnt2++;
		if(vis[i][3] == 1) cnt3++;
	}
	if(cnt1 == 3 || cnt2 == 3 || cnt3 == 3) fl = 1;
	if(vis[1][1] && vis[2][2] &&vis[3][3] ) fl = 1;
	if(vis[1][3] && vis[2][2] &&vis[3][1] ) fl = 1;
	if(fl) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, X;
    cin >> A >> B >> X;
    if (X > A) {
        X -= A;
        A = 0;
        B = max(B - X, 0ll);
    } else {
        A -= X;
    }
    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
int main(){
	ll a,b,c;
	cin>>a>>b>>c;
	cout<<c<<' '<<a<<' '<<b<<endl;
	return 0;
}

Measured memory_bytes: 256
use std::collections::HashMap;

#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn calc(n: u64, dp: &mut HashMap<u64, u64>) -> u64 {
    if let Some(&v) = dp.get(&n) {
        return v;
    }

    let mut m = calc((n - 1) / 2, dp);
    m += calc(n / 2, dp);
    m %= 1_000_000_007;
    if n > 1 {
        m += calc(n / 2 - 1, dp);
        m %= 1_000_000_007
    }

    let v = dp.entry(n).or_insert(0);
    *v = m % 1_000_000_007;
    m
}

fn main() {
    let n = scan!(u64);

    let mut dp: HashMap<u64, u64> = HashMap::new();
    dp.entry(0).or_insert(1);
    println!("{}", calc(n, &mut dp))
}


Measured memory_bytes: 4352
#include<stdio.h>

int main(void){
  int n,d,x,i,j,ans=0;
  scanf("%d",&n);
  scanf("%d %d",&d,&x);
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
    for(j=0;(j*a[i]+1)<=d;j++){
      //printf("%d\n",j*a[i]+1);
      ans++;
    }
  }
  printf("%d\n",ans+x);
  
  return 0;
}

Measured memory_bytes: 128
def dfs(v):
    stack = [v]
    vis = []
    while len(stack)!=0:
        x = stack.pop()
        vis.append(x)
        for i in range(n):
            if graph[x][i]==False:
                continue
            if i in vis:
                continue
            if i in stack:
                continue
            stack.append(i)
    return len(vis)
 
n,m = map(int,input().split())
graph = []
for i in range(n):
    graph.append([False]*n)
a=[]
b=[]
for i in range(m):
    aa,bb = map(int,input().split())
    a.append(aa-1)
    b.append(bb-1)
for i in range(m):
    graph[a[i]][b[i]] = True
    graph[b[i]][a[i]] = True
ans=0
for i in range(m):
    graph[a[i]][b[i]]=False
    graph[b[i]][a[i]]=False
    len_vis = dfs(0)
    bridge=False
    if len_vis < n:
        bridge=True
    if bridge:
        ans+=1
    graph[a[i]][b[i]] = True
    graph[b[i]][a[i]] = True
print(ans)


Measured memory_bytes: 3064
def main():
    import copy
    s, t = input(), input()
    a = [[] for _ in range(26)]
    b = copy.deepcopy(a)
    for i, j in zip(s, t):
        x, y = map(lambda x: ord(x) - 97, [i, j])
        a[x].append(y)
        b[y].append(x)

    f = all(len(set(i)) <= 1 for i in a)
    g = all(len(set(i)) <= 1 for i in b)
    print("Yes" if f and g else "No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 8624
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
long long  gcd(long long  a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long  a, long long  b){return a/gcd(a, b)*b;}

long long N,M;
string S,T;


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

	cin >> N >> M >> S >> T;

	if(gcd(N,M) == max(N,M)){
		cout << "-1" << endl;
		return 0;
	}

	long long i = 0;
	for (int i = 0, j = 0; i < N && j < M; i += N / gcd(N,M), j += M / gcd(N,M)) {
		if(S[i] != T[j]){
      cout << "-1" << endl;
      return 0;
    }
	}
	cout << lcm(N,M) << endl;
}


Measured memory_bytes: 640
c = False
while(1):
    try:
        n = raw_input().zfill(5)
        if c: print
        c = True
        for i in xrange(2):
            print "".join(["*" if int(n[j])-5*i in range(5) else " " for j in xrange(5)])
        print "="*5
        for i in xrange(5):
            print "".join([" " if (int(n[j])%5)==i else "*" for j in xrange(5)])
    except EOFError:
        break

Measured memory_bytes: 4228
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }

vector<ll> num;

void make(ll ma, ll now){
    if(now <= ma){
        num.push_back(now);
        make(ma,now*10 + 3);
        make(ma,now*10 + 5);
        make(ma,now*10 + 7);
    }
}

int main() {
    ll n;
    cin >> n;
    make(n,0);
    ll ans = 0;
    for(ll a : num){
        string s = to_string(a);
        unordered_map<char,int> um;
        for(char c : s)um[c]++;
        if(um.size() == 3)ans++;
    }
    cout << ans << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 640
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int myPower(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}


const int maxn = 510;
char s[maxn][maxn];
int n;

int read() {
  if (scanf("%d", &n) < 1) {
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%s", s[i]);
  }
  return 1;
}

int used[maxn];

void solve() {
  for (int i = 0; i < n; ++i) {
    used[i] = 0;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      used[j] += (s[i][j] == '#');
    }
  }
  if (count(used, used + n, 0) == n) {
    printf("-1\n");
    return;
  }
  int res = inf;
  for (int i = 0; i < n; ++i) {
    res = min(res, (int) count(s[i], s[i] + n, '.') + !used[i]);
  }
  res += n - count(used, used + n, n);
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


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

const int MAX_N = 10005;
const int INF = 1<<29;
int N;
int Cost[MAX_N];
int T[2][2][MAX_N];

int solve() {
  fill(T[0][0],T[2][0],INF);
  T[1][0][0] = T[1][1][1] = 0;
  for(int i = 2; i <= N; ++i) {
    fill(T[i%2][0],T[i%2][2], INF);
    for(int j = 0; j < 2; ++j) {
      for(int k = 0; k <= N; ++k) {
	for(int l = 0; l < 2; ++l) {
	  int cost = (j == l ? 0 : Cost[i-2]);
	  if(k-j < 0) continue;
	  T[i%2][j][k] = min(T[i%2][j][k], T[(i-1)%2][l][k-j]+cost);
	}
      }
    }
  }
  return min(T[0][0][N/2], T[0][1][N/2]);
}

int main() {
  cin >> N;
  for(int i = 0; i < N-1; ++i) cin >> Cost[i];
  cout << solve() << endl;
  return 0;
}

Measured memory_bytes: 1024
n = int(input())
key = 0
for i in range(1, 10):
    for j in range(1, 10):
        if n/(i*j) == 1 and n%(i*j) == 0:
            key = 1
            break
    if key == 1:
        break

if key == 1:
    print("Yes")
else:
    print("No")

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

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

  bool flag = false;
  for (int i = 0; i < 3; i++){
    if (s.at(i) == s.at(i+1))
    flag = true;
  }

  if (flag)
    cout << "Bad" <<endl;
  else
    cout << "Good" <<endl;

}


Measured memory_bytes: 256
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! {
        n: usize
    }
    let mut exist: bool = false;
    for i in 1..10 {
        for j in 1..10 {
            if n == i * j {
                exist = true;
            }
        }
    }
    if exist {
        println!("Yes");
    } else {
        println!("No");
    }
}

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

typedef long long ll;
typedef vector<int> VI;

string s, t;

int cycle(int x){
    if (s.size() <= x){
        return x - s.size();
    } else {
        return x;
    }
}

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

    for (int i = 0; i < s.size(); i++){
        bool flag = false;
        for (int j = 0; j < s.size(); j++){
            if (s[cycle(i+j)] != t[j]){
                flag = true;
            }
        }
        if (!flag){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}


Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; 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){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


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

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  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));
      }
    }
  }
  return p;
}


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







/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  vector<ll> v(n);
  rep(i,n) cin>>v[i];
  sort(ALL(v));
  vector<ll> sum(n,0);
  sum[0]=v[0];
  rep(i,n-1) sum[i+1]=sum[i]+v[i+1];
  ll ans=1,tmp=sum[0];
  rep(i,n-1){
    if(tmp*2>=v[i+1]){
      tmp=sum[i+1];
      ans++;
    }else{
      tmp=sum[i+1];
      ans=1;
    }
  }
  cout<<ans<<endl;
  
}

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

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

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

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

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

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

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

// ---- ----

int n, a, b;
string s;

int main() {
	cin >> n >> a >> b >> s;
	
	int pa = 0, pb = 0;
	inc(i, n) {
		bool ans = false;
		if(s[i] == 'a' && pa < a + b          ) { ans = true; pa++; }
		if(s[i] == 'b' && pa < a + b && pb < b) { ans = true; pa++; pb++; }
		
		cout << (ans ? "Yes" : "No") << "\n";
	}
	
	return 0;
}


Measured memory_bytes: 896
#include <iostream>

int main(void){
		int a,b,c,n,i;
		std::cin>>n;
		for(i=0;i<n;i++){
		std::cin>>a;
		std::cin>>b;
		std::cin>>c;
		if(a*a==b*b+c*c)std::cout<<"YES"<<std::endl;
		else if(b*b==a*a+c*c)std::cout<<"YES"<<std::endl;
		else if(c*c==a*a+b*b)std::cout<<"YES"<<std::endl;
		else std::cout<<"NO"<<std::endl;
		}
		return 0;
		}

Measured memory_bytes: 1156
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define F first
#define S second
#define ll long long
#define pb push_back
#define mp make_pair
#define Fr(i,a,b) for(int i=a;i<=b;i++)
#define RF(i,a,b) for(int i=a;i>=b;i--)
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair< int, int>
#define vpii vector<pii>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   
    int t=1;
    //cin>>t;
    while(t--){
    	int n,k;
    	cin>>n>>k;
    	int x;vi a;
    	Fr(i,0,n-1){
    		cin>>x;
    		a.pb(x);
    	}
        vector<bool>dp(k+1,false);
        Fr(i,1,k){
        	Fr(j,0,n-1){
        		if(i-a[j]>=0&&dp[i-a[j]]==false){
        			dp[i]=true;
        		}
        	}
        }
        if(dp[k]==false){
        	cout<<"Second"<<endl;
        }
        else{
        	cout<<"First"<<endl;
        }
    }
    return 0;
}


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

int main() {
    ll n;
    std::cin >> n;
    
    ll sum = 0;
    ll minb=1e10;
    for (int i = 0; i < n; i++) {
        ll a,b;
        std::cin >> a>>b;
        sum += a;
        if(a-b>0){
            minb=min(minb,b);
        }
    }
    if(minb==1e10){
        std::cout << 0 << std::endl;
        return 0;
    }
    std::cout << sum-minb << std::endl;
}


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

int main()
{
  int i;
  char j;
  string s, ans;
  cin >> s;
  set<char> mozi;
  for(i=0; i<s.size(); i++)
  {
    mozi.insert(s[i]);
  }
  ans = "None";
  for(j='a'; j <= 'z'; j++)
  {
    if(!(mozi.count(j)))
    {
      ans = j;
      break;
    }
    
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
// 問題の URL を書いておく
// https://atcoder.jp/contests/dp/tasks/dp_c

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

using ll = int64_t;

ll dp[100005][3] = {};

int main(int, const char**)
{
    int n;
    cin >> n;
    rep(i, n)
    {
        ll a, b, c;
        cin >> a >> b >> c;
        dp[i + 1][0] = max(dp[i][1] + a, dp[i][2] + a);
        dp[i + 1][1] = max(dp[i][0] + b, dp[i][2] + b);
        dp[i + 1][2] = max(dp[i][0] + c, dp[i][1] + c);
    }
    cout << max(dp[n][2], max(dp[n][0], dp[n][1])) << endl;
    return 0;
}


Measured memory_bytes: 5916
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
  
n = I()

print(n // 2 + n % 2)

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

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    for (int i = 0; i < n; i++)
        cin >> l[i];
    
    int ans = 0;
    for (int i = 0; i < n-2; i++) {
        for (int j = i; j < n-1; j++) {
            for (int k = j; k < n; k++) {
                if ((l[i] == l[j]) || (l[j] == l[k]) || (l[k] == l[i]))
                    continue;
                if (l[i] + l[j] + l[k] - max(l[i], max(l[j], l[k])) * 2 > 0)
                    ans++;
            }
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3632
/*

Author: Ganesh Bhandarkar
							#   RUN   #
		<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>
*/

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

/* KEYWORDS */
#define FASTIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define sq(a) (a)*(a)
#define rep(i,a,b) for(int i=a;i<b;++i)

/*DATATYPES */
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef pair<int , int > pi;
typedef pair<int , char > pic;
typedef pair<char , char > pc;
typedef pair<char , int > pci;

/*Constants */
const ll mod = 10000000007;

/* Booleans */
// bool OE(int n)  if(n & 1){ return true; } else false;

int main(){

	
	
	FASTIO

	long long c=0;
	long long x;
	cin>>x;
	long long a[x];
	for(int i=1;i<=x;i++){
		cin>>a[i];

	}

	long long m = x+1;

	for(int i=1;i<=x;i++){
		if(m > a[i]) c++, m=a[i];
		
	}

	cout<<c;

	return 0;
}



// #include <iostream>
// #define llint long long
 
// using namespace std;
 
// llint n;
// llint a[200005];
 
// int main(void)
// {
// 	ios::sync_with_stdio(0);
// 	cin.tie(0);
	
// 	cin >> n;
// 	for(int i = 1; i <= n; i++) cin >> a[i];
	
// 	llint mn = n+1, ans = 0;
// 	for(int i = 1; i <= n; i++){
// 		if(mn > a[i]) ans++, mn = a[i];
// 	}
// 	cout << ans << endl;
	
// 	return 0;
// }

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

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

    int wcount = 0;
    int ecount = 0;
    vector<int> wc(N+1);
    wc.at(0) = 0;
    vector<int> ec(N+1);
    ec.at(0) = 0;

    for(int i = 0; i < N; i++)
    {
        if(s.at(i) == 'W')wcount++;
        if(s.at(i) == 'E')ecount++;
        wc.at(i+1) = wcount;
        ec.at(i+1) = ecount;
    }

    int count = 0;
    int countMin = pow(10,5)*4;

    for(int i = 0; i < N; i++)
    {
        count = wc.at(i) + ecount - ec.at(i+1);
        countMin = min(count,countMin);
    }

    cout << countMin << endl;
    return 0;
}

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

int main()
{
	int n;
	bool ok = 1;
	string s[100];
	map<string, int> used;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> s[i];
		if (used[s[i]])
		{
			ok = 0;
		}
		++used[s[i]];
	}
	for (int i = 1; i < n; ++i)
	{
		if (s[i-1][s[i-1].size()-1] != s[i][0])
		{
			ok = 0;
		}
	}
	cout << (ok?"Yes":"No") << endl;
	return 0;
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    for(int i=0; i<n-k; i++){
        if(a[i] < a[k+i]) cout << "Yes" << endl;
        else cout << "No" << endl;
        }

    return 0;
}

Measured memory_bytes: 4048
#include<stdio.h>
int main(void)
{
	int a, b;
	scanf("%d %d" , &a, &b);
	if(a < b)
 	{
 		printf("a < b\n");
 	}
	else if(a > b)
	{
		printf("a > b\n");
	}
	else
	{
		printf("a == b\n");
	}
	return 0;
	
}



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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
result = 0

for i in range(1,n+1,2):
    if i > 200:
        break
    #print(i)
    if len(make_divisors(i)) == 8:
        result += 1
    

print(result)


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

#define inf 2000000000
#define INF 1e18

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vl;
typedef vector<ii> vii;

#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define togglebit(n,i) ((n)^(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 500005
#define lb lower_bound
#define ub upper_bound
#define sz(x) (ll)x.size()
#define all(x) begin(x), end(x)
#define f0r(i, a) for (ll i=0; i<a; i++)
#define FOR(i, a) for (ll i=1; i<=a; i++)
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front

void solve()
{
    ll n,m,i,j,k,x;
    ll cnt=0,sum=0;
    string s,s1,s2,s3;

    cin>>x;
    if(x==0) cout<<"1\n";
    else if(x==1) cout<<"0\n";
}

int main()
{
    fastread;
    ll t=1;
    //cin>>t;
    while(t--){
            solve();
    }
    return 0;
}


Measured memory_bytes: 3596
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <cassert>
#include <cstdlib>
#include <cstring>

using namespace std;
const int MOD = 1e9 + 7;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define irep(i, a, b) for (int i = a; i <= b; i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)

long long power(long long a, long long p) {
    if (p == 0)
        return 1;
    if (p == 1)
        return a;

    long long half = power(a, p / 2) % MOD;
    if (p % 2 == 0) {
        return (half * half) % MOD;
    } else {
        return ((half * half) % MOD * a) % MOD;
    }
}

long long inv(long long x) {
    return power(x, MOD - 2);
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n + 1);
    rep(i, 0, n + 1) {
        cin >> a[i];
    }

    vector<int> pos(n + 1, -1);
    int dbl = -1;
    int posa = 0, posb = 0;
    rep(i, 0, n + 1) {
        if (pos[a[i]] >= 0) {
            dbl = a[i];
            posa = pos[a[i]];
            posb = i;
            break;
        }
        pos[a[i]] = i;
    }
    long long l = posa;
    long long r = n - posb;

    long long my_comb = 1;
    long long my_comb2 = 1;
    irep(i, 1, n + 1) {
        my_comb = (my_comb * (n - i + 2)) % MOD * inv(i) % MOD;
        long long res = my_comb;
        long long tosub = (l + r < i - 1 ? 0 : my_comb2);
        res = (res + MOD - tosub) % MOD;

        cout << res << endl;
        my_comb2 = (my_comb2 * (l + r - i + 1)) % MOD * inv(i) % MOD;
    }

    return 0;
}

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

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

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

    ans[a - 1] = i + 1;
  }

  for (int i = 0; i < N - 1; i++) {
    cout << ans[i] << " ";
  }
  cout << ans[N - 1] << endl;
}


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

#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout if (false) cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vec(v, n) vector<int> v(n, 0);
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力

#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define next asdnext
#define prev asdprev
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"



void Main()
{
	int X;
	cin>>X;
	int num=0;
	int cnt=0;
	do
	{
		num+=X;
		cnt++;
		dout<<num<<_n;
	} while ((num%360)!=0);
	cout<<cnt<<_n;
}



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


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

int main(int argc, char const *argv[])
{
	//freopen("input.txt" , "r" , stdin) ;

	char S[1000000] ;

	scanf("%s" , S) ;

	int z , o ;
	z = o = 0 ;

	for(int i = 0; S[i] != 0 ; i++){
		if(S[i] == '0')z++ ;
		else o++ ;
	}

	int ans = 2*min(z , o) ;

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  string s;
  cin >> s;

  if(s[K - 1] == 'A') s[K - 1] = 'a';
  if(s[K - 1] == 'B') s[K - 1] = 'b';
  if(s[K - 1] == 'C') s[K - 1] = 'c';

  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl

int main(){
    ll a,b,c,d;
    while(cin >> a >> b >> c >> d){
        ll h = abs(a - c);
        ll w = abs(b - d);
        ll x = h*w;
        ll ans = (h == 0 || w == 0) ? 0 : x/h + x/w - __gcd(h,w);
        cout << ans << endl;
    }
}


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

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 998244353
#define P pair<ll, ll>

int main() {
    ll a, b, c, k, now = 0;
    cin >> a >> b >> c >> k;
    now += min(k, a);
    k -= min(k, a);
    k -= min(k, b);
    now -= min(k, c);
    cout << now << endl;
}


Measured memory_bytes: 3644
import math

a, b = map(int, input().split())

if a % 2 == 0 and b % 2 == 0:
    if (b - a) % 4 == 0:
        ans = b
    else:
        ans = b + 1
elif a % 2 == 0 and b % 2 == 1:
    if (b - a) % 4 == 3:
        ans = 0
    else:
        ans = 1
elif a % 2 == 1 and b % 2 == 1:
    if (b - a) % 4 == 0:
        ans = a
    else:
        ans = a - 1
else:
    r = int(math.log2(b))
    A = []
    B = []
    for i in reversed(range(r + 1)):
        if a >= 2 ** i:
            a -= 2 ** i
            A.append(1)
        else:
            A.append(0)
        if b >= 2 ** i:
            b -= 2 ** i
            B.append(1)
        else:
            B.append(0)
    ans = 0
    for i in range(r + 1):
        if A[i] != B[i]:
            ans += 2 ** (r - i)
    if A[r - 1] == B[r - 1]:
        ans -= 1

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n,a[60],i,j;
int main()
{
	cin>>n;
	int flag=1;
	for(i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]<=a[i-1]){
			flag=0;
		}
	}
	if(flag){
		cout<<"YES"<<endl;
		return 0;
	}
	for(i=1;i<=n;i++){
		for(j=i+1;j<=n;j++){
			flag=1;
			int t;
			t=a[i];a[i]=a[j];a[j]=t;
			for(int i=1;i<n;i++)
				if(a[i]>=a[i+1])flag=0;
			if(flag){
				cout<<"YES"<<endl;
				return 0;
			}
			t=a[j];a[j]=a[i];a[i]=t;
		}
	}
	cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int x,points=0;
    cin>>x;
    while (x>=5) {
        if (x - 500 >= 0) {
            x -= 500;
            points += 1000;
        }
        else if (x-5>=0){
            x-=5;
            points+=5;
        }
    }
    cout<<points<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//typedef
//------------------------------------------
template<class T> using v=vector<T>;
using VI = v<int>;
using VVI = v<v<int>>;
using VS = v<string>;
using PII = pair<int, int>;
using LL = long long;
using ULL = unsigned long long;
using VLL = v<LL>;
using VVLL = v<VLL>;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

//update
//------------------------------------------
template<class T>inline T updmax(T& target, T val) { return target = max(target, val); }
template<class T>inline T updmin(T& target, T val) { return target = min(target, val); }

char s[1000005];

int main() {
	int n,  qq;
	scanf("%d%s%d", &n, s, &qq);
	REP(q, qq) {
		int k;
		scanf("%d", &k);
		LL d = 0, m = 0, c = 0, dm = 0, ans = 0;
		REP(i, n) {
			if (i >= k) {
				if (s[i - k] == 'D') {
					dm -= m;
					d--;
				}
				else if (s[i - k] == 'M') m--;
			}
			if (s[i] == 'D') d++;
			else if (s[i] == 'M') {
				dm += d;
				m++;
			}
			else if (s[i] == 'C') {
				ans += dm;
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1784
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef pair<int,int> P;

int main() {
    int i,j,n,p,q,temp;
    int a,b;
    int t=0;
    int flag=0;
    string s;
    cin>>a>>b;
    cin>>s;
    if(s[a]!='-'){flag=1;}
    for(i=0; i<a; ++i){
        p=s[i]-'0';
        if(p>=0&&p<=9){continue;}
        else{flag=1;break;}
    }
    if(b!=0) {
        for (i = a + 1; i < a+b+1; ++i) {
            p = s[i] - '0';
            if (p >= 0 && p <= 9) { continue; }
            else {
                flag = 1;
                break;
            }
        }
    }
    if(flag==0){cout<<"Yes";}
    else{cout<<"No";}
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a[3];
    int k;
    while (cin>>a[0]>>a[1]>>a[2]>>k)
    {
        int sum,m=0;
        for (int i=0;i<2;i++)
        {
            for (int j=0;j<2-i;j++)
            {
                if (a[j]<a[j+1])
                {
                    sum=a[j];
                    a[j]=a[j+1];
                    a[j+1]=sum;
                }
            }
        }
        for (int i=0;i<k;i++)
        {
            a[0]=a[0]*2;
        }
        m=a[0]+a[1]+a[2];
        cout<<m<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int K=stdIn.nextInt();
		int ans=0;
		for(int i=0;i<N;i++){
			int a=stdIn.nextInt();
			if(a>=K)
				ans++;
		}
		System.out.println(ans);
	}
}


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

int main() {
  int H,W;
  cin >>H>>W;
  char a='#';
  string str(W+2,'#');
  
  for(int i=0;i<H+2;i++){
    for(int j=0;j<W+2;j++){
      if(i!=0&&i!=H+1){
        if(j==0||j==W+1){
          str.at(j)=a;
        }
        else{
          cin >> str.at(j);
        }
      }
      else{
        str.at(j)='#';
      }
      cout <<str.at(j);
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {

	ll N,K;
	cin >> N>>K;

	cout << N-K+1 << endl;


}

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

int main(int argc, char const *argv[]) {

    std::string O,E;
    std::cin >> O >> E;

    std::string answer = "";
    for(int word_index = 0 ; word_index < O.length() ; word_index++ )
    {
        if(word_index < O.length())
            answer += O.substr(word_index,1);
        if(word_index < E.length())
            answer += E.substr(word_index,1);
    }
    std::cout << answer << '\n';
    return 0;
}


Measured memory_bytes: 256