akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <list>
#include <cmath>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <vector>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
// const ll MOD = 1000000009;

#define M 1000000007


std::vector<ll> fac(2001); //n!(mod M)
std::vector<ll> ifac(2001); //k!^{M-2} (mod M)

//x^n(mod M)d
ll
mpow(ll x, ll n)
{
    ll ans = 1;
    while (n > 0){
        if (n & 1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

void
cominit()
{
    fac[0] = 1;
    ifac[0] = 1;
    for (ll i = 0; i < 2000; i++){
        fac[i+1] = fac[i] * (i+1) % M; // n! mod M
        ifac[i+1] = ifac[i] * mpow(i+1, M-2) % M; // k!^{M-2} mod M
    }
}


ll
comb(ll a, ll b)  // aCb mod M
{
    if (a == 0 && b == 0) return 1;
    if (a < b || a < 0) return 0;
    ll tmp = ifac[a-b] * ifac[b] % M;
    return tmp * fac[a] % M;
}

inline ll Mcomb(ll n, ll r){ return comb(n + r - 1, n - 1); } // r個をn部屋に分ける

int main() {
    cominit();
    ll n, k;
    cin >> n >> k;
    auto m = n - k;
    auto imax = min (k, n-k+1);
    auto prev = 0;
    for (ll i = 1; i <= k; ++i) {
        if (n-k <i-1) {
            cout << 0 << endl;
            continue;
        }
        auto res = comb(k-1, i-1);
        if (n-k == i-1) {
            cout << res << endl;
            continue;
        }
        res *= comb(n-k+1, i);
        res %= M;
        //cerr << i << ": ";
        cout << res << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
typedef long long ll;

using namespace std;
int a[100];
int main()
{
    int n;
    cin >> n;
    int ji = 0;
    int ou = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        if(a[i]%2 == 0)ou++;
        else ji++;
    }
    cout << (int)(pow(3, n))-(int)(pow(2, ou)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
using namespace std;

int main() {
	int n;
	cin >> n;
	if (n < 1200)
		cout << "ABC";
	else if (n < 2800)
		cout << "ARC";
	else
		cout << "AGC";
}



Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <vector>

int main()
{
  int n;
  scanf("%d", &n);

  std::vector<std::vector<int>> graph;
  graph.resize(n);
  for (int i = 0; i < n; ++i)
  {
    int u, k, v;
    scanf("%d%d", &u, &k);
    for (int j = 0; j < k; ++j)
    {
      scanf("%d", &v);
      graph[u - 1].push_back(v - 1);
    }
  }

  std::queue<int> vertex;
  vertex.push(0);
  int current_distance = 0;

  int distances[100];
  for (int i = 0; i < 100; ++i)
    distances[i] = -1;

  while (vertex.size() > 0)
  {
    int s = vertex.size();

    // Loop for current depth
    for (int i = 0; i < s; ++i)
    {
      int id = vertex.front();
      vertex.pop();

      if (distances[id] == -1)
        distances[id] = current_distance;

      std::vector<int>::const_iterator itr;
      for (itr = graph[id].begin(); itr != graph[id].end(); ++itr)
      {
        if (distances[*itr] == -1)
          vertex.push(*itr);
      }
    }

    ++current_distance;
  }

  for (int i = 0; i < n; ++i)
    printf("%d %d\n", i + 1, distances[i]);

  return 0;
}


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

#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N;
    cin>>N;
    vint ans;
    while(N){
        int n=1;
        while(n*(n+1)/2<N)n++;
        ans.pb(n);
        N-=n;
    }
    for(int i=ans.size()-1;i>=0;i--)cout<<ans[i]<<endl;
    return 0;
}


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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int N, C, s, t, c; cin >> N >> C;
	vector <vector <pair<int,int>>> v(C);
	for (int i = 0; i < N; ++i){
		cin >> s >> t >> c;
		s *= 2; t *= 2; --c;
		v[c].emplace_back(s,t);
	}
	vector <int> ava(2e5 + 2), ava2(2e5+2);
	for (int i = 0; i < C; ++i){
		if (!v[i].empty()){
		sort(v[i].begin(),v[i].end());
		++ava[v[i][0].first-1];
		for (int j = 1; j < v[i].size(); ++j){
			if (v[i][j-1].second != v[i][j].first){
				--ava[v[i][j-1].second];
				++ava[v[i][j].first-1];
			}
		}
		--ava[v[i][v[i].size()-1].second];
		for (int i = 1; i < ava.size(); ++i){
			ava[i] += ava[i-1];
		}	
		for (int i = 0; i < ava2.size(); ++i){
			if (ava[i] > 0) ++ava2[i];
		}
		ava.clear();
		ava.resize(2e5 + 2);
		}
	}
	cout << *max_element(ava2.begin(),ava2.end()) << "\n";
	/*
	vector <pair<int,int>> sor;
	for (int i = 0; i < C; ++i){
		sort(v[i].begin(),v[i].end());
		vector <pair<int,int>> tmp;
		if (!v[i].empty()){
//			pair<int,int> p;
			int x = v[i][0].first;
			for (int j = 1; j < v[i].size(); ++j){
				if (v[i][j-1].second != v[i][j].first){
					tmp.emplace_back(x, v[i][j-1].second);
					x = v[i][j].first;
				}
			}
			tmp.emplace_back(x, v[i][v[i].size()-1].second);	
		}
//		cout << "Test " << i  << " " << tmp.size()<< "\n";
		for (auto i : tmp){
			sor.push_back(i);
		}	
	}
	sort(sor.begin(),sor.end());
//	for (auto i : sor){
//		cout << i.first <<  " " << i.second << "\n";
//	}
	int req = 1;
	multiset <int> free;
	for (int i = 0; i < sor.size(); ++i){
		if (free.empty()){
			free.insert(sor[i].second);
		}else{
			if (*free.begin() < sor[i].first){
				free.erase(free.begin());
				free.insert(sor[i].second);
			}else{
				++req;
				free.insert(sor[i].second);
			}
		}
	}
	cout << req << "\n";
*/	
	return 0;
}


Measured memory_bytes: 5960
package main

import (
  "fmt"
)

func swapRunes(s string, a, b rune) string {
  runes := []rune(s)
  for i := 0; i < len(runes); i++ {
    if runes[i] == a {
      runes[i] = b
    } else {
      runes[i] = a
    }
  }
  return string(runes)
}

func main() {
  var n string
  fmt.Scan(&n)
  fmt.Println(swapRunes(n, '1', '9'))

}

Measured memory_bytes: 512
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  int A, B;
  cin >> A >> B;
  cout << A * B << endl;
}

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


Measured memory_bytes: 3144
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<cmath>
#include<limits>
#include <queue>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <memory>
#include <numeric>
#include <type_traits>
 
using namespace std;
 
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
typedef long long ll;

 
int main() {
    int s,w; cin >> s >> w;
    if(s<=w){
        cout << "unsafe";
    }
    else{
        cout << "safe";
    }
    

    return 0;
}

Measured memory_bytes: 3620
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        String[] s = new String[n];
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
        }

        if (Arrays.asList(s).contains("Y")) {
            System.out.println("Four");
        } else {
            System.out.println("Three");
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
int inf=1000001000;
ll INF=100000000000000000;

int main() {
    int n,m;
    cin >> n >> m;
    vector<vector<int>> e(n+1,vector<int>(0)),a(n+1,vector<int>(n+1,0));
    rep(i,m){
        int f,g;
        cin >> f >> g;
        e.at(f).push_back(g);
    }
    for (int i=1;i<n+1;i++){
        queue<int> q;
        q.push(i);
        a.at(i).at(i)=1;
        while(!q.empty()){
            int t=q.front();
            q.pop();
            rep(j,e.at(t).size()){
                int u=e.at(t).at(j);
                if (a.at(i).at(u)==0){
                    q.push(u);
                    a.at(i).at(u)=1;
                }
            }
        }
    }
    vector<vector<int>> w(n+1,vector<int>(0));
    rep(i,n){
        rep(j,n){
            if (a.at(i+1).at(j+1)==1 && a.at(j+1).at(i+1)==1) w.at(i+1).push_back(j+1);
        }
    }
    rep(i,n){
        rep(j,w.at(i+1).size()-1) cout << w.at(i+1).at(j) << " ";
        cout << w.at(i+1).at(w.at(i+1).size()-1) << endl;
    }
}



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

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

	int n,x,y; cin >> n >> x >> y;
	vector<ll> ans(10000,0);

	for(int i = 1; i < n; i++){
		for(int j = i+1; j < n+1; j++){
			int tmp = min(j-i,abs(i-x)+abs(j-y)+1);
			ans[tmp]++;
		}
	}

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


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    if((b-a-1)%2==0){
        cout<<"Borys"<<endl;
        return 0;
    }
    else if((b-a)%2==0){
        cout<<"Alice"<<endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 100006
using namespace std;
int n;
struct node
{
	int x,s;
}a[MAXN];
bool cmp(node a,node b)
{
	return a.x<b.x;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&a[i].x,&a[i].s);
	sort(a+1,a+1+n,cmp);
	printf("%d",a[n].x+a[n].s);
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
  Scanner sc;

  void run() {
    for ( ;; ) {
      char[] str = sc.nextLine().toCharArray();

      if ( str.length == 1 && str[ 0 ] == '.' ) {
        break;
      }

      LinkedList<Character> list = new LinkedList<Character>();
      HashMap<Character, Character> map = new HashMap<Character, Character>();
      map.put( '(', ')' );
      map.put( '[', ']' );
      list.add( ' ' );
      boolean f = true;
      for ( int i = 0; i < str.length; ++i ) {
        if ( !f ) {
          // debug(i);
          break;
        }
        switch ( str[ i ] ) {
        case '[':
        case '(':
          list.add( str[ i ] );
          break;
        case ']':
        case ')':
          char c = list.pollLast();
          if ( map.containsKey( c ) ) {
            // debug(c);
            f &= map.get( c ) == str[ i ];
          } else {
            f = false;
          }
          break;
        }
      }

      f &= list.size() == 1;

      System.out.println( f ? "yes" : "no" );
    }
  }

  Main() {
    sc = new Scanner( System.in );
  }

  int ni() {
    return sc.nextInt();
  }

  public static void main(String[] args) {
    new Main().run();
  }

  void debug(Object... os) {
    System.err.println( Arrays.deepToString( os ) );
  }
}

Measured memory_bytes: 36012
#include <stdio.h>

int main(void)
{
	int n, i;
	int a, b;
	int ap, bp;
	
	while (scanf("%d", &n), n){
		ap = bp = 0;
		for (i = 0; i < n; i++){
			scanf("%d %d", &a, &b);
			if (a > b) ap += a + b;
			else if (b > a) bp += a + b;
			else {
				ap += a;
				bp += b;
			}
		}
		printf("%d %d\n", ap, bp);
	}
	
	return (0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
const int INF = 1e18, MOD = 1e9 + 7;
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
signed main() {
    INCANT;
    int n, a[1111],res=0;
    cin>>n;
    rep(i, n){
        cin>>a[i];
    }
    rep(i, n){
        rep(j, i + 1, n){
            res += a[i] * a[j];
        }
    }
    cout<<res<<endl;
}


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


int main(void) {
	int n;
	cin >> n;
	vector<long long> luka(n+1);
	luka[0]=2;
	luka[1]=1;
	for(int i=2; i<=n; i++){
		luka[i]=luka[i-1]+luka[i-2];
	}
	cout << luka[n] << endl;
	return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <queue>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//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();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//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 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,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int gcd(int a, int b){
   int tmp;
   while(a%b==0){
      tmp=a%b;
      a=b;
      b=tmp;
   }
}

int lcm(int a,int b){
   return a*b/gcd(a,b);
}

bool prime_number(int n){
   vector<bool> i;
   if(n < 2){
      return false;
   }
   else if(n == 2){
      return true;
   }
   if(n % 2 == 0){
      return false;
   }
   for(int i=3;i<=n/i;i+=2){
      if(n % i == 0) return false;
      return true;
   }
}

int main(){
   int q,c,a,n,ans;
   
   cin >> q;
   while(cin >> c >> a >> n){
      ans=0;
      for(int i;c>0&&a>0&&n>0;i++){
         c--; a--; n--; ans++;
      }
      for(int i;c>1&&a>0;i++){
         c-=2; a--; ans++;
      }for(int i;c>2;i++){
         c-=3; ans++;
      }
      cout << ans << endl;
   }
   return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <time.h>
#include <cstdlib>
#include <cmath>
#include <fstream>
using namespace std;

int main() {
    string str, order, rep;
    int n, s, t;
    cin >> str >> n;
    for (int i = 0; i < n; i++) {
        cin >> order >> s >> t;
        if (order == "replace") {
            cin >> rep;
            str.replace(s,t-s+1, rep);
        } else if (order == "reverse") {
            reverse(str.begin() + s, str.begin() + t + 1);
        } else {
            cout << str.substr(s, t-s+1) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
ll n;
ll who(ll t){
  cout<<t<<endl;
  string S;cin>>S;
  if(S=="Male"){
    return 0;
  }
  if(S=="Female"){
    return 1;
  }
  if(S=="Vacant"){
    return 2;
  }  
}
void Main(){   
    cin>>n;
    vector<int> chair(n);
    chair.at(0)=who(0);
    if(chair.at(0)==2){
      return;
    }
    chair.at(n-1)=who(n-1);
    if(chair.at(n-1)==2){
      return;
    }
    ll left=0,right=n-1;
    ll center;
    For(i,2,20){
      center=(left+right)/2;
      chair.at(center)=who(center);
      if(chair.at(center)==2){
        return;
      }
      if((center+chair.at(center))%2==(left+chair.at(left))%2){
        left=center;
      }
      else{
        right=center;
      }      
    }
}
int main(){
    Main();
    return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  string s;
  int k;
  cin>>s>>k;
  for(int i=0;i<s.size();i++){
    if(s[i]=='a')continue;
    int tmp='z'-s[i]+1;
    if(tmp>k)continue;
    k-=tmp;
    s[i]='a';
  }
  s[s.size()-1]='a'+(k+s[s.size()-1]-'a')%26;
  cout<<s<<endl;;
  return 0;
}


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

void Slove(string str)	{
	string answer="";

	for (int i=0; i<str.length(); ++i)	{
		if (str[i] == '@')	{
			for (int j=0; j<str[i+1]-'0'; j++)
				answer+=str[i+2];
			i+=2;
		}
		else	answer+=str[i];
	}
	cout << answer << endl;
}

int main(void)	{
	string str;

	while (cin >> str)
		Slove(str);
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
 
void init();
void solve();
 
#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
 
#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
 
#define MOD 1000000007
 
signed main()
{
	init();
	solve();
}

string s;
int l;

void init()
{
  cin >> s;
  l = s.length();
}
 
void solve()
{
  rep(i, l-1) {
    if (s[i] != 'C') continue;
    reps(j, i+1, l) {
      if (s[j] == 'F') {
        cout << "Yes" << endl;
        return;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int N = 10050;
using namespace std;
int gi(){
  char ch=getchar(); int x=0,q=0;
  while(ch<'0' || ch>'9') (ch=='-'?q=1:0),ch=getchar();
  while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
  return q?(-x):x;
}
int st[N],top=1,p[N];
char s[10];
int main(){
  int a=gi(),b=gi(),n=a+b;
  if (a<=b){
    cout<<"Impossible"<<endl;
    return 0;
  }
  for (int i=1; i<n; ++i){
    if (!top){
      st[top=1]=i; continue;
    }
    printf("? %d %d\n",st[top],i);
    fflush(stdout);
    scanf("%s",s);
    if (s[0]=='Y')
      st[++top]=i;
    else
      --top;
  }
  for (int i=0; i<n; ++i){
    printf("? %d %d\n",st[top],i);
    fflush(stdout);
    scanf("%s",s);
    if (s[0]=='Y') p[i]=1;
  }
  printf("! ");
  for (int i=0; i<n; ++i)
    putchar(p[i]?'1':'0');
  putchar('\n');
  return 0;
}


Measured memory_bytes: 724
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;
    cin>>n;
    vector<int>v(200000,0);
    for(i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    int dp[200000];
    dp[1]=0;
    dp[2]=abs(v[2]-v[1]);
    for(i=3;i<=n;i++)
    {
        dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
    }
    cout<<dp[n];
}

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int  n;
    cin >> n;
    cout << (n-1)/2 << endl;
}


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

using namespace std;

using u32 = uint32_t;
using u64 = uint64_t;
using i64 = int64_t;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= a; i--)
#define RF0(i,b) RFO(i,0,b)

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

  int N, M;
  cin >> N >> M;

  int result = N * (N - 1) / 2 + M * (M - 1) / 2;
  cout << result;
}


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

using namespace std;

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

    vector<int> cnt(m, 0);
    for(int i=0; i<n; ++i){
        int k; cin >> k;
        for(int j=0; j<k; ++j){
            int A; cin >> A; --A;
            ++cnt[A];
        }
    }
    int res = 0;
    for(int i=0; i<m; i++){
        if(cnt[i] == n){
            res++;
        }
    }

    cout << res << endl;
    return 0;
}

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

template <class M, class E, class F = std::function<M(M, M)>, class A = std::function<M(M, E)>, class G = std::function<E(E, E)>>
class LazySegmentTree {
private:
  M* data;
  E* lazy;
  F op;
  G cp;
  A act;
  M e;
  E id;
  int sz;

  void propagate(int index) {
    if (lazy[index] == id) return;
    lazy[index << 1] = cp(lazy[index << 1], lazy[index]);
    lazy[(index << 1) | 1] = cp(lazy[(index << 1) | 1], lazy[index]);
    data[index] = act(data[index], lazy[index]);
    lazy[index] = id;
  }

  void propagate_topdown(int index) {
    int h = 0;
    for (int i = 1; i < index; i <<= 1) ++h;
    for (int i = h; i; i--) propagate(index >> i); 
  }

  void recalc(int index) { while (index >>= 1) data[index] = op(act(data[index << 1], lazy[index << 1]), act(data[(index << 1) | 1], lazy[(index << 1) | 1])); }

public:
  LazySegmentTree(int sz, const F& op, const A& act, const G& cp, const M& e, const E& id) : op(op), act(act), cp(cp), e(e), id(id), sz(sz) {
    data = new M[sz << 1];
    lazy = new E[sz << 1];
    for (int i = 0; i < (sz << 1); i++) data[i] = e;
    for (int i = 0; i < (sz << 1); i++) lazy[i] = id;
  }

  void update(int left, int right, const E& x) {
    if (left < 0) left = 0;
    if (right > sz) right = sz;
    left += sz; right += sz;

    propagate_topdown(left);
    propagate_topdown(right - 1);

    for (int l = left, r = right; l < r; l >>= 1, r >>= 1) {
      if (l & 1) {
        lazy[l] = cp(lazy[l], x);
        ++l;
      }
      if (r & 1) {
        --r;
        lazy[r] = cp(lazy[r], x);
      }
    }

    recalc(left);
    recalc(right - 1);
  }

  M query(int left, int right) {
    if (left < 0) left = 0;
    if (right > sz) right = sz;
    left += sz; right += sz;

    propagate_topdown(left);
    propagate_topdown(right - 1);

    M l = e, r = e;

    for (; left < right; left >>= 1, right >>= 1) {
      if (left & 1) {
        l = op(l, act(data[left], lazy[left]));
        ++left;
      }
      if (right & 1) {
        --right;
        r = op(act(data[right], lazy[right]), r);
      }
    }

    return op(l, r);
  }

  ~LazySegmentTree() {
    delete[] data;
    delete[] lazy;
  }
};

using namespace std;

int main() {
  int N, Q;
  cin >> N >> Q;
  
  auto f = [](int a, int b) {
    return min(a, b);
  };
  
  LazySegmentTree<int, int, decltype(f), decltype(f), decltype(f)> ho(N + 1, f, f, f, N - 2, N - 2), ve(N + 1, f, f, f, N - 2, N - 2);
  
  
  long long black = (long long)(N - 2) * (N - 2);
  
  while (Q--) {
    int t, x;
    cin >> t >> x;
    
    if (t == 1) {
      int rev = ho.query(x, x + 1);
      black -= rev;
      ve.update(1, rev + 2, x - 2);
    } else if (t == 2) {
      int rev = ve.query(x, x + 1);
      black -= rev;
      ho.update(1, rev + 2, x - 2);
    }
  }
  
  cout << black << endl;
  
  return 0;
}

Measured memory_bytes: 9584
#![allow(unused_imports)]
use petgraph::{graph::UnGraph, graphmap::UnGraphMap, Direction};
use proconio::{input, marker::Usize1};
use std::collections::HashSet;

fn main() {
    input! {
        n: usize,
        m: usize,
        hh: [usize; n],
        abs: [(Usize1, Usize1); m]
    };
    let mut count = 0;
    let g = UnGraphMap::<_, ()>::from_edges(abs);
    // dbg!(&g);
    for i in 0..n {
        let h = hh[i];
        let is_high = g
            .neighbors_directed(i, Direction::Incoming)
            .into_iter()
            .all(|j| h > hh[j]);
        if is_high {
            count += 1;
        }
        // println!("index: {}", i);
        // for n in g.neighbors_directed(i, Direction::Incoming) {
        //     dbg!(n);
        // }
        // println!("");
    }
    println!("{}", count);
}


Measured memory_bytes: 20596
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int N,M;
vector<int>G[1000];
int cnt[1000];
main()
{
	cin>>N>>M;
	for(int i=0;i<M;i++)
	{
		int u,v;cin>>u>>v;u--,v--;
		G[u].push_back(v);
		cnt[v]++;
	}
	queue<int>P;
	for(int i=0;i<N;i++)
	{
		if(cnt[i]==0)P.push(i);
	}
	int sz=0;
	while(!P.empty())
	{
		sz++;
		int u=P.front();P.pop();
		for(int v:G[u])
		{
			if(--cnt[v]==0)P.push(v);
		}
	}
	cout<<-(sz==N)<<endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

ll n, k;
vector<ll> a;
bool isCut(ll x) {
    //k回カットして，aの全ての要素をx以下にできるか？
    ll cnt = 0;
    for(int i = n - 1; i >= 0; --i) {
        if(a[i] <= x) continue;
        else if(a[i] % x == 0) cnt += a[i]/x - 1;
        else cnt += a[i] / x;
    }
    return (k >= cnt);
}

int main() {
    cin >> n >> k;
    a.resize(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    ll ng = 0, ok = a[n - 1] + 1;

    while(ng + 1 < ok) {
        ll mid = (ok + ng) / 2;
        if(isCut(mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << ok << endl;
}


Measured memory_bytes: 4720
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
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;}
int const INF = 1001001001;

vector<int> G[100050];

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

int n,m;
cin >> n >> m;
rep(i,m) {
    int a,b;
    cin >> a >> b;
    --a; --b;
    G[a].push_back(b);
    G[b].push_back(a);
}

vi dp(n,-1);
vi ans(n);
queue<int> que;

dp[0] = 0;
que.push(0);

while(!que.empty()) {
    int v = que.front(); que.pop();
    for(int nv : G[v]) {
        if(dp[nv] != -1) continue;
        dp[nv] = dp[v] + 1;
        ans[nv] = v + 1;
        que.push(nv);
    }
}

cout << "Yes" << endl;
rrep(i,n-1) {
    cout << ans[i] << endl;
}
return 0;
}

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

#define ll long long

int main()
{
    ll i, j, n, m, k, ans, x, y;

    cin >> n >> m >> k;

    vector <ll> a(n+1), b(m+1);

    a[0]=b[0]=0;
    for(i=1; i<=n; i+=1)
        cin >> a[i];
    for(i=1; i<=m; i+=1)
        cin >> b[i];

    for(i=1; i<=n; i+=1)
        a[i]+=a[i-1];
    for(i=1; i<=m; i+=1)
        b[i]+=b[i-1];


    ans=-1;
    for(i=0; i<=n; i+=1)
    {
        x=k-a[i];
        if(x>=0)
        {
            y=upper_bound(b.begin(), b.end(), x)-b.begin();
            ans=max(ans, i+y-1);
        }
    }

    cout << ans << endl;
}

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

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


int gcd(int a, int b){
  int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}

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

/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int n;
  scanf("%d",&n);

  int A[2000000];
  for(int i=0;i<2000000;i++){
    A[i]=0;
  }

  A[n]++;

  int ans=1;
  while(1){
    n=f(n);
    A[n]++;
    ans++;

    if(A[n]>1){
      printf("%d\n",ans);
      break;
    }
  }

  return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	int cur=0,ma=0;
	FOR(i,N) {
		cin>>x>>y;
		if(x==y) cur++;
		else cur=0;
		if(cur==3) return _P("Yes\n");
	}
	cout<<"No"<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char a[3][3];
  for(int i=0; i<3; i++){
  	for(int j=0; j<3; j++){
    	cin >> a[i][j];
    }
  }
  
  cout << a[0][0] << a[1][1] << a[2][2] << endl;
   
}

Measured memory_bytes: 256
def main():
    from collections import deque
    H, W = (int(i) for i in input().split())
    Ch, Cw = (int(i)-1 for i in input().split())
    Dh, Dw = (int(i)-1 for i in input().split())
    A = [input() for i in range(H)]
    V = [[-1]*W for i in range(H)]  # V[h][w]を頂点iとする
    d = ((1, 0), (0, 1), (-1, 0), (0, -1))

    def bfs_2d(sy, sx, v):
        que = deque()
        V[sy][sx] = v
        que.append((sy, sx))
        while que:
            uh, uw = que.popleft()
            for dy, dx in d:
                next_h = uh + dy
                next_w = uw + dx
                if not(0 <= next_h < H and 0 <= next_w < W):
                    continue
                if V[next_h][next_w] != -1:
                    continue
                if A[next_h][next_w] == '#':
                    continue
                V[next_h][next_w] = v
                que.append((next_h, next_w))

    # グループ分け
    vertex = 0
    for h in range(H):
        for w in range(W):
            if A[h][w] == "#" or V[h][w] != -1:
                continue
            bfs_2d(h, w, vertex)
            vertex += 1

    # グラフを作成、全てのマスで5*5の範囲を走査
    G = [[] for _ in range(vertex)]
    used = [set() for _ in range(vertex)]
    for h in range(H):
        for w in range(W):
            if A[h][w] == "#":
                continue
            for dh in range(-2, 3):
                for dw in range(-2, 3):
                    if h + dh < 0 or H <= h + dh or w + dw < 0 or W <= w + dw:
                        continue
                    if A[h+dh][w+dw] == "#":
                        continue
                    if V[h][w] == V[h+dh][w+dw]:
                        continue
                    if V[h+dh][w+dw] in used[V[h][w]]:
                        continue
                    G[V[h][w]].append((V[h+dh][w+dw]))
                    used[V[h][w]].add((V[h+dh][w+dw]))

    # for h in range(H):
    #     print(V[h])

    # for i in range(vertex):
    #     print(G[i])

    # スタートからゴールまでbfsして最短距離を求める
    s = V[Ch][Cw]
    g = V[Dh][Dw]
    que = deque([0])

    dist = [-1 for _ in range(vertex)]
    que = deque()
    dist[s] = 0
    que.append(s)
    while que:
        u = que.popleft()
        for v in G[u]:
            if dist[v] != -1:
                continue
            dist[v] = dist[u] + 1
            que.append(v)

    print(dist[g])


if __name__ == '__main__':
    main()


Measured memory_bytes: 162232
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  sort(v.begin(), v.end());
  int ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = i - 1; j >= 0; j--) {
      for (int k = j - 1; k >= 0; k--) {
        if (v[i] != v[j] && v[j] != v[k]) {
          int a = v[i] + v[j];
          int b = v[i] + v[k];
          int c = v[j] + v[k];
          if (a <= v[k] || b <= v[j] || c <= v[i]) {
            continue;
          } else {
            ans++;
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

struct point{
  double x,y;
};

double INF = 1e9;
double PI = acos(-1);
double EPS = (1e-10);
double dp[10001][20][20];
int n;
double Ti;
double r,ti;
point t[20];

double mem[20][20][20];
double check(int to,int from,int prev){
  if(mem[to][from][prev]!=-INF)return mem[to][from][prev];

  if(to==from||to==prev)return INF;
  double vax=t[to].x-t[from].x;
  double vay=t[to].y-t[from].y;
  double vbx=t[from].x-t[prev].x;
  double vby=t[from].y-t[prev].y;
  double ar=(vax*vbx+vay*vby)/(sqrt(vax*vax+vay*vay)*sqrt(vbx*vbx+vby*vby));
  ar=acos(ar);
  if(ar<ti+EPS){
    mem[to][from][prev]=sqrt(vax*vax+vay*vay);
  }else{
    mem[to][from][prev]=INF;
  }
  return mem[to][from][prev];
}

void solve(int i,int j,int k){
  for(int to=0;to<n;to++){
    dp[i+1][to][j]=min(dp[i+1][to][j],dp[i][j][k]+check(to,j,k));

    //dp[i][j][k]+sqrt(vax*vax+vay*vay));
    //    if(ar<ti+EPS){
    // dp[i+1][to][j]=min(dp[i+1][to][j],dp[i][j][k]+sqrt(vax*vax+vay*vay));
    //    }
  }
}

int main(){

  for(int i=0;i<10001;i++)
    for(int j=0;j<20;j++)
      for(int k=0;k<20;k++)
	dp[i][j][k]=INF;
  
  for(int i=0;i<20;i++)
    for(int j=0;j<20;j++)
      for(int k=0;k<20;k++)
	mem[i][j][k]=-INF;

  cin>>n>>r>>Ti;
  ti=Ti/360.0*2.0*PI;

  for(int i=0;i<n;i++)
    cin>>t[i].x>>t[i].y;
  
  for(int i=1;i<n;i++){
    double x=t[i].x-t[0].x;
    double y=t[i].y-t[0].y;
    dp[1][i][0]=sqrt(x*x+y*y);
  }

  int ans=0;
  for(int i=1;i<=10000;i++){
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
	if(dp[i][j][k]>r+EPS)continue;
	ans=max(ans,i);
	solve(i,j,k);
      }
    }
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 32616
s = int(input())

def collaz(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n +1

ans = [s]
flag = 0
while 1:
    s = collaz(s)
    if s not in ans:
        ans.append(s)
    else:
        ans.append(s)
        break
print(len(ans))

Measured memory_bytes: 38256
# coding: utf-8
s = int(input())
i = s
a = [s]
while True:
    if (i)%2 == 0:
        i = i//2
    else:
        i = 3*(i) + 1
    if i in a:
        print(len(a)+1)
        exit()
    a.append(i)

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int h,w,n;
    cin>>h>>w>>n;
    int m=max(h,w);
    cout<<(n+m-1)/m<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
using namespace std;

int N, A, B;
int x;
int x_sum;
int P[200000], Q[200000];
int max_num;
int diff[20], same[20];
int main(void) {
	scanf("%d %d %d", &N, &A, &B);
	x = A ^ B;
	x_sum = 0;
	for (int i = 0; i < N; i++) {
		x_sum += x % 2;
		x = x / 2;
	}
	if (x_sum % 2 == 0) {
		printf("NO\n");
		return 0;
	}
	else {
		printf("YES\n");
	}
	int p = 0; int q = 0;
	int A2 = A;
	int B2 = B;
	for (int i = 0; i < N; i++) {
		if (A2 % 2 != B2 % 2) {
			diff[p] = i;
			p += 1;
		}
		else {
			same[q] = i;
			q += 1;
		}
		A2 = A2 / 2;
		B2 = B2 / 2;
	}

	//printf("x_sum=%d\n", x_sum);

	/*x_sum桁が異なり、N-x_sum桁が共通 */
	max_num = 2;
	P[0] = 0;
	P[1] = 1;

	for (int i = 0; 2 * i + 1 < x_sum; i++) {
		max_num = max_num * 4;
		for (int j = 0; j < max_num / 2; j++) {
			if (j % 4 == 0 || j % 4 == 3) {
				Q[j] = 0;
			}
			else {
				Q[j] = 1;
			}
			Q[j] = Q[j] << (2 * i+1);
			Q[j] += P[j / 2];
		}
		for (int j = 0; j < max_num / 4; j++) {
			Q[max_num / 2 + j] = 2 << (2 * i+1);
			Q[max_num / 2 + j] += P[max_num / 4 - 1 - j];
		}
		for (int j = 0; j < max_num / 4; j++) {
			Q[max_num / 2 + max_num / 4 + j] = 3 << (2 * i+1);
			Q[max_num / 2 + max_num / 4 + j] += P[j];
		}
		for (int j = 0; j < max_num; j++) {
			P[j] = Q[j];
		}
	}

	for (int i = 0; i < N - x_sum; i++) {
		max_num = max_num * 2;
		for (int j = 0; j < max_num; j++) {
			if (j % 4 == 0 || j % 4 == 3) {
				Q[j] = 0;
			}
			else {
				Q[j] = 1;
			}
			Q[j] = Q[j] << (i + x_sum);
			Q[j] += P[j / 2];
		}
		for (int j = 0; j < max_num; j++) {
			P[j] = Q[j];
		}
	}
	for (int i = 0; i < max_num; i++) {
		Q[i] = 0;
		for (int j = 0; j < p; j++) {
			Q[i] += (P[i] % 2) << diff[j];
			P[i] = P[i] / 2;
		}
		for (int j = 0; j < q; j++) {
			Q[i] += (P[i] % 2) << same[j];
			P[i] = P[i] / 2;
		}
		printf("%d ", Q[i]^A);
	}
	printf("\n");
}

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

struct UnionFind {
  vi parent, count;
  UnionFind(const int nodeSize) : parent(nodeSize), count(nodeSize) {
    rep(i, nodeSize) parent[i] = i, count[i] = 1;
  }
  int root(int x) {
    if (parent[x] == x) return x;
    return parent[x] = root(parent[x]);
  }
  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    parent[ry] = rx;
    count[rx] += count[ry];
  }
  bool isSame(int x, int y) {
    return root(x) == root(y);
  }
  int countAffiliation(int x) {
    return count[root(x)];
  }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n, m, k; std::cin >> n >> m >> k;
  vector<vi> block(n);
  vi cnt(n);
  UnionFind uf(n);
  rep(i, m) {
    int a, b; std::cin >> a >> b; --a, --b;
    cnt[a]++, cnt[b]++;
    uf.unite(a, b);
  }
  rep(i, k) {
    int c, d; std::cin >> c >> d; --c, --d;
    block[c].pb(d), block[d].pb(c);
  }
  vi ans(n);
  rep(i, n) {
    ans[i] = uf.countAffiliation(i) - cnt[i] - 1;
    for (auto &v : block[i])
      if (uf.isSame(i, v)) --ans[i];
  }
  rep(i, n) {
    std::cout << ans[i] << (i+1 < n ? " " : "\n");
  }
}


Measured memory_bytes: 7936
from sys import stdin
input = stdin.readline


def main():
  X, N = list(map(int, input().split()))
  P = set(list(map(int, input().split())))

  min_ = float('inf')
  for i in range(102):
    if i not in P and abs(X - i) < min_:
      min_ = abs(X - i)

  cand = []

  for i in range(102):
    if i not in P and abs(X - i) == min_:
      cand.append(i)

  print(min(cand))


if(__name__ == '__main__'):
  main()


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

using namespace std;
typedef long long ll;
int main()
{
	ll a, b, m, n;
	cin >> a;
	ll x[200000];
	m = 1;
	n = 0;
	x[0] = 0;
	for(int i = 1; i <= a; i++){
		cin >> x[i];
		x[i] += x[i - 1];
	}
	sort(x, x + a + 1);
	for(int i = 0; i < a; i++){
		if(x[i] == x[i + 1])
		m++;
		else{
			n += m * (m - 1) / 2;
			m = 1;
		}
	}
	n += m * (m - 1) / 2;
	cout << n;
}


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

int n,a,b;

int quick_power(int a,int b)
{
	if (b==0)  return 1%mod;
	
	int res=a;
	b--;
	for (;b;b=b>>1,a=(1ll*a*a)%mod)
	{
		if (b&1ll)  res=(1ll*res*a)%mod;
	}
	return res%mod;
}

int ny(int n)
{
	return quick_power(n,mod-2ll);
}

int C(int n,int k)//C(5,3)
{
	if (k==0)  return 1;
	if (k>n-k)  k=n-k;
	
	int x=1ll,y=1ll;
	for (int i=1;i<=k;i++)
	{
		x=(1ll*x*(n-i+1))%mod;
		y=(1ll*y*i)%mod;
	}
	return (1ll*x*ny(y))%mod;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define INF_LL 1e18
#define INF 1e9

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()

#define fst first
#define snd second

using namespace std;

using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
using PLLL = pair<ll, PLL >;

ll MOD = 1e9+7;
int M, N, K;
vector<PII> X[100010], Y[100010];
PII pos[200010];
ll d[200010][2];
int g_n = -1;
int th_s_s = 0; // 0,0??????????????????????????????????????????

int main(void){
	cin >> M >> N >> K;
	REP(i, 200010){
		REP(j, 2){
			d[i][j] = INF_LL;
		}
	}
	REP(i, K){
		int x, y;
		cin >> x >> y; x--; y--;
		X[x].push_back({y, i+1});
		Y[y].push_back({x, i+1});
		pos[i+1] = {x, y};
		if(x == M-1 && y == N-1){
			g_n = i+1;
		}
		if(x == 0 && y == 0)
			th_s_s = 1;
	}
	if(g_n == -1){
		X[M-1].push_back({N-1, K+1});
		Y[N-1].push_back({M-1, K+1});
		g_n = K+1;
	}

	priority_queue<pair<ll, pair<int, int> >, vector<pair<ll, pair<int, int> > >, greater<pair<ll, pair<int, int> > > > pq;
	d[0][0] = 0;
	REP(i, X[0].size()){
		d[X[0][i].second][0] = X[0][i].first;
		d[X[0][i].second][1] = min(d[X[0][i].second][1], (ll)X[0][i].first+1);
		pq.push({X[0][i].first+1, {X[0][i].second, 1}});
	}
	if(th_s_s){
		REP(i, Y[0].size()){
			d[Y[0][i].second][1] = Y[0][i].first+1;
			d[Y[0][i].second][0] = min(d[Y[0][i].second][0], (ll)Y[0][i].first+2);
			pq.push({Y[0][i].first+1, {Y[0][i].second, 0}});
		}
	}
	while(pq.size()){
		pair<ll, pair<int, int> > p = pq.top(); pq.pop();
		int v = p.second.first, s = p.second.second;

		if(d[v][s] < p.first) continue;
		if(s == 0){
			int x_p = pos[v].first;
			REP(i, X[x_p].size()){
				int dis = abs(X[x_p][i].first-pos[v].second);
				if(d[X[x_p][i].second][s] > d[v][s] + dis){
					d[X[x_p][i].second][s] = d[v][s] + dis;
					d[X[x_p][i].second][(s+1)%2] = min(d[X[x_p][i].second][(s+1)%2], d[X[x_p][i].second][s]+1);
					pq.push({d[X[x_p][i].second][(s+1)%2], {X[x_p][i].second, (s+1)%2}});
				}
			}
		}else{
			int y_p = pos[v].second;
			REP(i, Y[y_p].size()){
				int dis = abs(Y[y_p][i].first-pos[v].first);
				if(d[Y[y_p][i].second][s] > d[v][s] + dis){
					d[Y[y_p][i].second][s] = d[v][s] + dis;
					d[Y[y_p][i].second][(s+1)%2] = min(d[Y[y_p][i].second][(s+1)%2], d[Y[y_p][i].second][s]+1);
					pq.push({d[Y[y_p][i].second][(s+1)%2], {Y[y_p][i].second, (s+1)%2}});
				}
			}
		}
	}
	if(d[g_n][0] == INF_LL && d[g_n][1] == INF_LL){
		cout << -1 << endl;
	}else{
		cout << min(d[g_n][0], d[g_n][1]) << endl;
	}
	return 0;
}

Measured memory_bytes: 22140