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

int main(){
  
 string S; cin >> S;
  
 int price = 700;
 
 for(int i = 0; i < 3; i++){
   if(S[i] == 'o'){
     price += 100;
   }
 }
 
 cout << price << endl;

 return 0;
     
}
    

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

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

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

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

const int mod = 1000000007;


struct UnionFind {
    vector<ll> par;

    UnionFind(ll N) : par(N) {
        for(int i = 0; i < N; i++) par[i] = i;
    }

    ll root(ll x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(ll x, ll y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

  int n, m;
  cin >> n >> m;

  set<int> all;
  UnionFind uf(m);

  int f;
  rep(i, n) {
    int k;
    cin >> k;
    int fst;
    cin >> fst;
    all.insert(fst);
    f = fst;
    rep(i, k-1) {
      int snd;
      cin >> snd;
      all.insert(snd);
      uf.unite(fst, snd);
    }
  }

  bool res = true;
  for(int x: all) {
    res = res && uf.same(f, x);
  }

  cout << (res ? "YES" : "NO") << endl;
}


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

const ll INF=1001001001;

int main(){
    int n,k; cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    vector<ll> dp(n,INF);
    dp[0]=0;
    rep2(i,n){
        rep2(j,min(i+1,k+1)){
            dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]),dp[i]);
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1408
def main():
    s = list(input())
    from collections import deque
    q = deque()
    for i in s:
        if i == 'B':
            if len(q) > 0:
                t = q.pop()
        else:
            q.append(i)
    print(*list(q), sep='')

if __name__ == '__main__':
    main()

155284

Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#define r(i,n) for(int i=0; i<n; i++)
typedef long long ll;
using namespace std;

int main(void){
  int n;
  cin >> n;
  char c;
  char a[4]={};
  r(i,n){
    cin >> c;
    if(c=='G')a[0]++;
    if(c=='W')a[1]++;
    if(c=='Y')a[2]++;
    if(c=='P')a[3]++;
  }
  int cnt=0;
  for(int i=0; i<4; i++){
    if(a[i]!=0){cnt++;}
  }
  if(cnt==3){cout << "Three" << endl;}
  else cout << "Four" << endl;

  return 0;
}


Measured memory_bytes: 256
/// Thank you tanakh!!!
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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")
    };
}

use std::cmp;
use std::collections::{BTreeMap, BTreeSet};

fn t(x: usize, y: usize) -> (usize, usize) {
    if x > y {
        (y, x)
    } else {
        (x, y)
    }
}

fn rec(x: usize, y: usize, map: &mut BTreeMap<(usize, usize), usize>) -> usize {
    let state = t(x, y);
    if x < 2 && y < 2 {
        0
    } else if map.contains_key(&state) {
        *map.get(&state).unwrap()
    } else {
        let (x, y) = state;
        let mut set = BTreeSet::new();
        let mut i = 1;
        while 2 * i <= y {
            if 2 * i <= x {
                let tmp = rec(x - 2 * i, y + i, map);
                set.insert(tmp);
            }
            let tmp = rec(x + i, y - 2 * i, map);
            set.insert(tmp);
            i += 1;
        }

        let mut grundy = 0;
        for i in 0..(set.len() + 1) {
            if !set.contains(&i) {
                grundy = i;
                break;
            }
        }
        map.insert(state, grundy);
        grundy
    }
}

fn main() {
    input!(x: usize, y: usize);

    // let mut map = BTreeMap::new();
    // for x in 0..100 {
    //     for y in x..100 {
    //         rec(x, y, &mut map);
    //     }
    // }
    // for (key, &value) in map.iter() {
    //     if value == 0 {
    //         println!("{:?} {}", key, value);
    //     }
    // }
    let (x, y) = t(x, y);
    if x == y || x + 1 == y {
        println!("Brown");
    } else {
        println!("Alice");
    }
}


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

int main(){
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(u == s){
        a--;
    }
    if(u == t){
        b--;
    }
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <bitset>
#define pb push_back
#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 mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define rng(x) x.begin(),x.end()
#define sz(x) int((x).size())
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<P> vp;
typedef vector<ll> vl;

const int MX = 3005;
const int INF = 1001001001;

int n, q;
int a[MX], b[MX];
ll c[MX];

int main() {
  scanf("%d%d",&n,&q);
  rep(i,n) {
    scanf("%d",&c[i]);
    scanf("%d%d",&a[i],&b[i]);
    // cout<<c[i]<<" "<<a[i]<<" "<<b[i]<<endl;
    // --a[i]; --b[i];
  }
  rep(ti,n) {
    vl x, nc;
    rep(i,n) nc.pb(c[i]*MX*MX+c[a[i]]*MX+c[b[i]]);
    x = nc;
    sort(rng(x));
    rep(i,n) c[i] = lower_bound(rng(x),nc[i])-x.begin();
    // rep(i,n) cout<<c[i]<<" "; cout<<""<<endl;
  }
  rep(i,q) {
    int v;
    scanf("%d",&v);
    // --v;
    int ans = 0;
    rep(j,n) if (c[v] == c[j]) ans++;
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 3352
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,i,j;
	cin>>n;

	int h[n];

	for(i = 0; i<n; i++){
		scanf("%d",&h[i]);
	}

	int arr[n];
	arr[0] = 0;
	int v1,v2= 1000000;
	for(i = 1; i<n ; i++){
		v1 = abs(h[i] - h[i-1]) + arr[i-1];
		if(i>1)
			v2 = abs(h[i] - h[i-2]) + arr[i-2];
		arr[i] = min(v1,v2);
	}

	cout<<arr[n-1];


}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=10000000000000000001;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};

int main() {

	string s;
	cin>>s;

	int k=0,g=0;
	rep(i,s.size()){
		if(i%2==0&&s[i]=='0')k++;
		if(i%2>0&&s[i]=='1')k++;
		if(i%2==0&&s[i]=='1')g++;
		if(i%2>0&&s[i]=='0')g++;

	}
	cout<<min(k,g)<<endl;

	return 0;
}


Measured memory_bytes: 512
import java.awt.*;
import java.io.*;
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new TestC().doIt();
//		new TestD().doIt();
//		new TestE().doIt();
	}
	class TestE{
		void doIt(){
			int N = sc.nextInt();
			int K = sc.nextInt();
			int A[] = new int[N];
			for(int i = 0;i < N;i++){
				A[i] = sc.nextInt();
			}
			System.out.println(maxGCD(N,K,A));
		}
		int maxGCD(int N,int K,int A[]){
			int result = 0;
			for(int i = 1;i < 100;i++){
				int sum = 0;
				for(int j = 0;j < N;j++){
					if((A[j] % i) < i/2){
						sum = sum + A[j] % i;
					}else{
						sum = sum - i + (A[j] % i);
					}
				}
				System.out.println(i+" "+sum);
			}
			return 0;
		}
	}
	class TestD{
		void doIt(){
			String S = sc.next();
			int length = S.length();
			char setRL[] = S.toCharArray();
			int children[][] = new int[2][length];
			int copyChildren[] = new int[length];
			for(int x = 0;x < length;x++){
				children[0][x] = 1;
				copyChildren[x] = children[0][x];
			}
			moveChildren(setRL,children,copyChildren,length);
			for(int x = 0;x < length-1;x++){
				System.out.print(copyChildren[x]+" ");
			}
			System.out.println(copyChildren[length - 1]);
		}
		void moveChildren(char RLSet[],int children[][],int copyChildren[],int length){
			while(true){
				boolean isTheSameSet = true;
				for(int y = 0;y < 2;y++){
					for(int x = 0;x < length;x++){
						if(RLSet[x] == 'R'){
							children[(y+1)%2][x+1] += children[y%2][x];
							children[y%2][x] = 0;
						}
						else{
							children[(y+1)%2][x-1] += children[y%2][x];
							children[y%2][x] = 0;
						}
					}
				}
				for(int x = 0;x < length;x++){
					if(children[0][x] != copyChildren[x])isTheSameSet = false;
					copyChildren[x] = children[0][x];
				}
				if(isTheSameSet)break;
			}
		}
	}
	class TestC{
		void doIt(){
			int N = sc.nextInt();
			int H[] = new int[N];
			for(int i = 0;i < N;i++){
				H[i] = Integer.parseInt(sc.next());
			}
			boolean result = canMonotonousDecrease(N,H);
			if(result){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
 		}
		boolean canMonotonousDecrease(int N,int H[]){
			for(int i = 1;i < N;i++){
				int diff = H[i] - H[i-1];
				if(diff > 0)H[i] = H[i] - 1;
				else if(diff < 0)return false;
			}
			return true;
		}
	}
}

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

int main() {
  
  bool hw_1 = false;
  int H = 0, W = 0;
  cin >> H >> W;
  
  int64_t even_line_counter = 0;
  int64_t odd_line_counter = 0;
  
  if (H != 1 || W != 1) {
    // 偶数行の計算    
    // 行の数が奇数のとき
    if (H % 2 == 1) {
      // 列の数が奇数のとき
  	  if (W % 2 == 1) {
        even_line_counter = (W + 1) / 2;
        even_line_counter *= (H + 1) / 2;
      }
      // 列の数が偶数のとき
      else {
        even_line_counter = W / 2;
        even_line_counter *= (H + 1) / 2;
      }
    }
    // 行の数が偶数のとき
    else {
      // 列の数が奇数のとき
  	  if (W % 2 == 1) {
        even_line_counter = (W + 1) / 2;
        even_line_counter *= H / 2;
      }
      // 列の数が偶数のとき
      else {
        even_line_counter = W / 2;
        even_line_counter *= H / 2;
      }
    }
  
    // 奇数行の計算    
    // 行の数が奇数のとき
    if (H % 2 == 1) {
      // 列の数が奇数のとき
  	  if (W % 2 == 1) {
        odd_line_counter = (W - 1) / 2;
        odd_line_counter *= (H - 1) / 2;
      }
      // 列の数が偶数のとき
      else {
        odd_line_counter = W / 2;
        odd_line_counter *= (H - 1) / 2;
      }
    }
    // 行の数が偶数のとき
    else {
      // 列の数が奇数のとき
  	  if (W % 2 == 1) {
        odd_line_counter = (W - 1) / 2;
        odd_line_counter *= H / 2;
      }
      // 列の数が偶数のとき
      else {
        odd_line_counter = W / 2;
        odd_line_counter *= H / 2;
      }
    }
  }
  
  if (H == 1 || W == 1) {
    hw_1 = true;
  }
  
  if (hw_1 == false) {
    cout << even_line_counter + odd_line_counter << endl;
  }
  else {
    cout << 1 << endl;
  }  
}

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

int main(){
  string S, T, U; int A, B;
  cin >> S >> T >> A >> B >> U;

  if(S == U){
    cout << A-1 << " " << B << endl; 
  } else {
    cout << A << " " << B-1 << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll x = min(b-1, n);
  ll ans = ((a*x) / b) - (a*(x/b));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3576
/* ***********************************************
Author        :yang12138
Created Time  :2017年05月18日 星期四 10时47分45秒
File Name     :A.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)



int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
 	int a,b,c;   
	while(cin>>a>>b>>c){
		if(c>=a && c<=b) printf("Yes\n");
		else printf("No\n");
	}
    return 0;
}


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

using namespace std;

int main () {
  int N;
  int A[100];
  double ans=0;

  cin >> N;
  for (int i=0; i<N; i++) {
    cin >> A[i];
    ans+=(double)1.0/A[i];
  }

  printf("%.10lf\n", 1.0/ans);
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N, M;
  cin >> N >> M;
  map<int, int> mp;
  REP(i, M) {
    int a, b;
    cin >> a >> b;
    mp[a]++;
    mp[b]++;
  }
  REP1(i, N) cout << mp[i] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


// void solve()
// {
//     string s;
//     cin>>s;
//     ll x1=s[0]-'a';
//     ll x2=s[1]-'a';
//     ll x3=s[2]-'a';
//     ll x4=s[3]-'a';
//     ll f1=0,f2=0;

     
    
    
// }
const int N=1e5+5;
vector<ll> v[N];
ll vis[N];
ll ans[N];
ll noc=0;


void dfs(ll x,ll s)
{
    vis[x]=1;

    for(auto it:v[x])
    {
        if(!vis[it])
        {
            dfs(it,x);
        }
    }
}



void solve()
{
    ll n;
    cin>>n;
    ll u,vv,dis;
    ll i,j;
    clr(ans);
    ll m;
    cin>>m;
    
    for(i=0;i<m;i++)
    {
        cin>>u>>vv>>dis;
        u--,vv--;
        v[u].pb(vv);
        v[vv].pb(u);
    }
    // ll lef=-1;

    for(i=0;i<n;i++)
    {
        if(!vis[i])
        {
            noc++;
            dfs(i,-1);
        }
    }
    cout<<noc<<"\n";

   
  
     
    
}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

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

int main(){

  int N; cin >> N;
  vector<int> a(N+1);
  for(int i=1; i<N+1; i++)
    cin >> a.at(i);
  
  int ball_count = 0;
  vector<bool> flag(N+1);
  
  for(int i=N; i>N/2; i--){
    //倍数がないので確定できる
    if(a.at(i) == 1){
      flag.at(i) = 1;
      ball_count++;
    }
  }
  
  for(int i=N/2; i>0; i--){
  
    int count = 0;
    for(int j=2; i*j<=N; j++){
      if(flag.at(i*j)==1)
        count++;
    }

    if(a.at(i) != count % 2){
      flag.at(i) = true;
      ball_count++;
    }
  
  }
  
  cout << ball_count << endl;
  
  for(int i=1; i<N+1; i++){
    if(flag.at(i) == true)
      cout << i << ' ';
  }
  
}

Measured memory_bytes: 1792
import os

import sys
import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N, K = list(map(int, sys.stdin.buffer.readline().split()))
A = list(map(int, sys.stdin.buffer.readline().split()))

A = np.array(A, dtype=int) - 1

dp = np.zeros((K.bit_length() + 1, N), dtype=int)
dp[0, :] = A
for h in range(1, len(dp)):
    dp[h] = dp[h - 1][dp[h - 1]]

ans = 0
for i in reversed(range(K.bit_length())):
    if K >> i & 1:
        ans = dp[i][ans]
print(ans + 1)


Measured memory_bytes: 127340
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn = 1e5 + 20;
bool check(string s)
{
    for(int i = 1; i < s.size(); i++)
        if(s[i] != s[i - 1])
            return 0;
    return 1;
}
int res = maxn;
int main()
{
    string s;
    cin >> s;
    for(int i = 'a'; i <= 'z'; i++)
    {
        string s1 = s;
        while(!check(s1))
        {
            string s2;
            for(int j = 0; j < s1.size() - 1; j++)
            {
                if(s1[j] == i || s1[j + 1] == i)
                    s2 += (char)i;
                else
                    s2 += s1[j];
            }
            s1 = s2;
        }
        res = min(res , (int)s.size() - (int)s1.size());
    }
    cout << res;
}


Measured memory_bytes: 768
# vim: fileencoding=utf-8


def main():
    a = int(input())
    if a <= 599:
        print(8)
    elif a <= 799:
        print(7)
    elif a <= 999:
        print(6)
    elif a <= 1199:
        print(5)
    elif a <= 1399:
        print(4)
    elif a <= 1599:
        print(3)
    elif a <= 1799:
        print(2)
    elif a <= 1999:
        print(1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61292
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			char[] s = in.nextString().toCharArray();
			int len = s.length;

			boolean isEven = len % 2 == 0;
			boolean isWinnerFirst;

			if (s[0] == s[len-1]) {
				if (isEven) {
					isWinnerFirst = true;
				} else {
					isWinnerFirst = false;
				}
			} else {
				if (isEven) {
					isWinnerFirst = false;
				} else {
					isWinnerFirst = true;
				}
			}

			out.println(isWinnerFirst ? "First" : "Second");

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 25044
#include <iostream>
using namespace std;
int gcd(int a,int b)
{
	return(b==0?a:gcd(b,a%b));
}

int main(void)
{
	int a,b;
	while(cin >> a >> b){
		if(a>b) cout << gcd(a,b) << endl;
		else cout << gcd(b,a) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import math
N=int(input())
d=int(math.sqrt(2*N)+1)
bucket=[0 for i in range(N)]
for i in range(0,d+1):
  for j in range(i,d+1):
    for k in range(j,d+1):
      if(i**2+j**2+k**2<=2*N and (i**2+j**2+k**2)%2==0 and i+j-k>=2 and j+k-i>=2 and k+i-j>=2):
        x=i+j-k
        y=j+k-i
        z=k+i-j
        if((x==z and z<y) or (x<z and z==y)):
          bucket[(i**2+j**2+k**2)//2-1]+=3
        elif(y==x and x==z):
          bucket[(i**2+j**2+k**2)//2-1]+=1
        else:
          #print(x,y,z)
          bucket[(i**2+j**2+k**2)//2-1]+=6
for i in range(N):
  print(bucket[i])

Measured memory_bytes: 9248
N = gets.to_i
A, B = gets.split.map(&:to_i)
P = gets.split.map(&:to_i)
Q1, Q2, Q3 = P.group_by{|i| i > B ? 2 : i > A ? 1 : 0}.map{|k,v| v.size}
p [Q1, Q2, Q3].map(&:to_i).min

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


int n,m,A[100001],B[100001], parent[100001];
long long f[100001],size[100001];

int find(int a){
	if(parent[a]==a){
		return a;
	}
	return find(parent[a]);
}
void uni(int a, int b){
	int ap=find(a);
	int bp=find(b);
	if(ap!=bp){
		if(size[ap]>size[bp]){
			parent[bp]=ap;
		}else{
			parent[ap]=bp;
		}
		size[ap]+=size[bp];
		size[bp]=size[ap];
	}
}

int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>A[i]>>B[i];
	}
	for(int i=1;i<=n;i++){
		parent[i]=i;
		size[i]=1;
	}
	long long ans=(long long)n*(n-1)/2;
	for(int i=m;i>=1;i--){
		f[i]=ans;
		if(find(A[i])!=find(B[i])){
			//cout<<size[find(A[i])]<<" "<<size[find(B[i])]<<endl;
			ans=ans-(long long)size[find(A[i])]*size[find(B[i])];
		}
		uni(A[i],B[i]);
	}
	
	for(int i=1;i<=m;i++){
		cout<<f[i]<<endl;
	}
}

Measured memory_bytes: 4096
import itertools
import math
import fractions
import functools
n = int(input())
b = list(map(int, input().split()))
a = [0]*n
a[0] = b[0]
for i in range(1,n-1):
    a[i] = min(b[i-1],b[i])

a[n-1]=b[n-2]
print(sum(a))

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

int main(void){
    vector<int> dish;
    rep(i,5){
        int x;
        cin >> x;
        dish.push_back(x);
    }
    int cal=10;
    int num = 6;
    rep(i,5){
        if(cal > dish[i]%10 && dish[i]%10 != 0){
            cal = dish[i]%10;
            num = i;
        }
    }
    int time = 0;
    rep(i,5){
        if(i!=num){
          	if(dish[i] %10 != 0){
            time += dish[i] + 10 - (dish[i] % 10);
            }
          	else{
             time += dish[i];
            }
        }
        else{
            time += dish[i];
        }
    }
    cout << time <<endl;
    
    
    return 0;
}




































Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def bisearch_min(mn, mx, func):
    """ 条件を満たす最小値を見つける二分探索 """

    ok = mx
    ng = mn
    while ng+1 < ok:
        mid = (ok+ng) // 2
        if func(mid):
            # 下を探しに行く
            ok = mid
        else:
            # 上を探しに行く
            ng = mid
    return ok

def check(m):
    b = B * m
    cnt = 0
    for h in H:
        # 全体攻撃
        h -= b
        if h > 0:
            # 単体攻撃
            cnt += ceil(h, A)
    # 必要な単体攻撃の回数がm以下ならOK
    return cnt <= m

N, A, B = MAP()
H = LIST(N)
# Aを単体攻撃、Bを全体攻撃とする
A -= B

# 二分探索
res = bisearch_min(0, 10**9, check)
print(res)


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

int main()
{
	string str;
	while (getline(cin, str), str != "."){
		stack<char> st;
		bool res = true;
		for (int p = 0; p < str.size(); p++){
			if (str[p] == '(' || str[p] == '['){
				st.push(str[p]);
			}
			else if (str[p] == ')' || str[p] == ']'){
				if (st.empty()){
					res = false;
					break;
				}
				char c = st.top(); st.pop();
				if ((c == '(' && str[p] == ']') || 
				    (c == '[' && str[p] == ')')){
					res = false;
					break;
				}
				
			}
		}
		printf(res && st.empty() ? "yes\n" : "no\n");
	}
	
	return 0;
}

Measured memory_bytes: 1180
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func getFloat() float64 {
	sc.Scan()
	n, _ := strconv.ParseFloat(sc.Text(), 64)
	return n
}

func sum(n []int) int {
	a := 0
	for _, v := range n {
		a += v
	}
	return a
}

func partseFloat(s string) (n float64) {
	n, _ = strconv.ParseFloat(s, 64)
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Scan()
	s := sc.Text()

	Rune := []rune(s)
	n := len(Rune)
	var min float64
	min = 753
	for i := 0; i < n-2; i++ {
		if math.Abs(753-partseFloat(s[i:i+3])) < min {
			min = math.Abs(753 - partseFloat(s[i:i+3]))
		}
	}
	fmt.Println(min)
}


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

using namespace std;

int main(){

  int n;

  cin >> n;

  vector<int> a(n);
  int total = 0;
  
  for(int i=0;i < n;++i){
	cin >> a[i];
	total += a[i];
  }

  if(total % 2 == 0)
	cout << total / 2 << endl;
  else{
	int min = 110;
	for(int i = 0;i < n;++i){
	  if(a[i] < min)
		min = a[i];
	}
	cout << (total - min)/2 << endl;
  }
  
}



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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

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

struct UnionFind{
    vector<int> par; // par[i]:iの親の番号
    vector<int> s; // s[i]:iの属する木のノード数
    int n_group; // 木の数
    
    UnionFind(int N) : par(N) {
        for(int i=0; i<N; i++) par[i] = i;
        s.assign(N, 1);
        n_group = N;
    }
    
    int root(int x){ // xが属する木の根
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    
    void unite(int x, int y){ // xとyの木を併合
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] = ry;
        s[ry] += s[rx];
        s[rx] = 0;
        n_group--;
    }
    
    bool same(int x, int y){ // xとyが同じ木に属するかどうか
        return root(x) == root(y);
    }

    int size(int x){ // xが属する木のノード数
        return s[root(x)];
    }
};

int main(void){
    int H,W; cin >> H >> W;
    VS S(H); REP(i,H) cin >> S[i];
    int n[H][W];
    int t = 0;
    REP(i,H)REP(j,W) n[i][j] = t++;
    UnionFind uf(H*W);
    REP(i,H)REP(j,W){
        if(S[i][j] == '.') continue;
        if(i && S[i-1][j] == '.') uf.unite(n[i][j], n[i-1][j]);
        if(j && S[i][j-1] == '.') uf.unite(n[i][j], n[i][j-1]);
        if(i<H-1 && S[i+1][j] == '.') uf.unite(n[i][j], n[i+1][j]);
        if(j<W-1 && S[i][j+1] == '.') uf.unite(n[i][j], n[i][j+1]);
    }

    VI g(H*W,0);
    REP(i,H)REP(j,W){
        if(S[i][j] == '#') continue;
        int r = uf.root(n[i][j]);
        g[r]++;
    }
    ll ans = 0;
    REP(i,H)REP(j,W){
        if(S[i][j] == '.') continue;
        int r = uf.root(n[i][j]);
        ans += g[r];
    }

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

Measured memory_bytes: 2944
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<functional>
using namespace std;
int main(void) {
    
    int n;
    cin>>n;
    int temp=n;

    int sum=0;

    while(1){
        sum+=n%10;
        n = n/10;
        if(n==0)break;
    }
   // cout<<sum<<" ";
    if(temp%sum==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
import itertools
from collections import Counter
D, G = map(int, input().split())
P = [list(map(int, input().split())) for i in range(D)]
min_num = 10**8

judge_list = list(itertools.product([0, 1, 2], repeat=D)) #0:中途半端に解く 1:一問も解かない 2: 全部解く


for judge in judge_list:
    score = 0
    num = 0
    d = Counter() #インスタンスを生成
    d.update(judge)
    if (d[0] <= 1):
        for i in range(1, len(judge) + 1):
            if score >= G:
                break

            if judge[-i] == 1:
                pass

            if judge[-i] == 2:
                score += P[-i][0] * (D - i + 1) * 100 + P[-i][1]
                num += P[-i][0]

            if (judge[-i] == 0):
                for j in range(P[-i][0]):
                    if score >= G:
                        break
                    score += 100 * (D - i + 1)
                    num += 1
                        
        if score >= G:
            min_num = min(num, min_num)

print(min_num)           

Measured memory_bytes: 11508
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF 2147483647//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
//5000000000000000


int main() {
    string s;
    ll k;
    cin >> s >> k;
    ll i = 0;
    while(k){
        if(s[i]-'0' == 1){
            k--;
        }else{
            k -= pow(s[i]-'0',5000000000000000);
        }
        if(k <= 0){
            cout << s[i]-'0' << endl;
            break;
        }
        i++;
    }
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<list>

using namespace std;

int main()
{
	int A, B;
	cin >> A >> B;
	int output = 0;
	output = max(A, B);
	if (A > B)
	{
		A--;

	}
	else
	{
		B--;
	}
	output += max(A, B);
	cout << output << endl;
	return 0;

}

Measured memory_bytes: 256
N,M,X=map(int,input().split())
A=list(map(int,input().split()))
money=[False]*N
leftcount=0
rightcount=0
for i in A:
    money[i]=True
for i in range(X,0,-1):
    if money[i]==True:
        leftcount+=1
for i in range(X,N):
    if money[i]==True:
        rightcount+=1
if leftcount>rightcount:
    print(rightcount)
else:
    print(leftcount)

Measured memory_bytes: 9208
#include<bits/stdc++.h>
#define N 100005
#define Ms(a,b) memset(a,b,sizeof a)
#define db(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
using namespace std;
int n,a[N],ans,now;
int main() {
	scanf("%d%d",&n,&a[1]);
	for(int i=2; i<=n; i++) {
		scanf("%d",&a[i]);
		if(a[i]<=a[i-1])now++;
		else ans=max(ans,now),now=0;
	}
	printf("%d\n",max(ans,now));
	return 0;
}


Measured memory_bytes: 640
//
// Created by yamunaku on 2020/06/13.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    //CFS;
    ll n, k, s, t;
    cin >> n >> k >> s >> t;
    if((s & t) != s){
        cout << 0 << endl;
        return 0;
    }
    vl a;
    rep(tt, n){
        ll x;
        cin >> x;
        if((x & s) == s && (x | t) == t){
            ll tmp = 0;
            int kk = 0;
            rep(i, 18){
                if(!((1 << i) & s))
                    if((1 << i) & t){
                        if(x & (1 << i)) tmp |= (1 << kk);
                        kk++;
                    }
            }
            a.push_back(tmp);
        }
    }

    int kk = 0;
    rep(i, 18){
        if(!((1 << i) & s))
            if((1 << i) & t) kk++;
    }
    n = a.size();
    mtl c(n + 1, vl(n + 1));
    c[0][0] = 1;
    rep(i, n + 1){
        c[i][0] = c[i][i] = 1;
        repl(j, 1, i) c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
    }
    vl b(1 << kk, 0);
    rep(i, 1 << kk){
        map<int, int> mp;
        rep(j, n){
            mp[a[j] & i]++;
        }
        for(auto &p:mp){
            repl(j, 1, k + 1){
                if(j > p.second) break;
                b[i] += c[p.second][j];
            }
        }
    }
    rep(i, kk){
        rep(j, 1 << kk){
            if(j & (1 << i)){
                b[j] -= b[j ^ (1 << i)];
            }
        }
    }
    cout << abs(b.back()) << endl;
    return 0;
}

Measured memory_bytes: 5360
#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<cstdlib>
#include<queue>
#include<utility> //pair
using namespace std;

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

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

int main() {
	//入力;
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	int b[3];
	b[0] = abs(a[0] - a[1]);
	b[1] = abs(a[2] - a[1]);
	b[2] = abs(a[0] - a[2]);

	cout << b[0] + b[1] + b[2] - max(b[0], max(b[1], b[2])) << endl;
	//小数点以下の桁数表示;
	//cout << fixed << setprecision(15);

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif
template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}
static const long long MOD_NUM = 1000000007LL;

static void D_task();

int main()
{
	D_task();
	fflush(stdout);
	return 0;
}

static void D_dfs(std::vector<std::vector<int>>& graph, LLONG* tree, std::map<int, std::pair<int, bool>>& que, int vtx, int x)
{
	LLONG val = x;
	if ((que.find(vtx) != que.end()) && (que[vtx].second == false)) {
		val += (LLONG)(que[vtx].first);
		que[vtx].second = true;
	}
	tree[vtx] += val;
	for (auto it = graph[vtx].begin(); it != graph[vtx].end(); it++) {
		D_dfs(graph, tree, que, *it, val);
	}
}


static void D_task()
{
	int N, Q;
	get2int(N, Q);

	std::vector<std::vector<int>> graph(N);
	int a, b;
	for (int i = 0; i < N - 1; i++) {
		get2int(a, b); a--; b--;
		graph[a].push_back(b);
	}
	auto tree = new LLONG[N];
	memset(tree, 0, sizeof(LLONG) * N);

	int p, x;
	std::map<int, std::pair<int, bool>> que;
	for (int i = 0; i < Q; i++) {
		get2int(p, x); p--;
		que[p].first += x;
	}

	for (auto it = que.begin(); it != que.end(); it++) {
		if (it->second.second != false) continue;
		it->second.second = true;
		D_dfs(graph, tree, que, it->first, it->second.first);
	}
	
	for (int i = 0; i < N; i++) {
		printf("%lld ", tree[i]);
	}

	delete[] tree;
}


Measured memory_bytes: 52224
#include<stdio.h>

int main(void) {
  int H,W,i,j;
  while(scanf("%d %d",&H,&W)){
    if(H==0&&W==0) break;
    for(i=1;i<=H;i++){
      for(j=1;j<=W;j++)
	if((i+j)%2==0)
	  printf("#");
	else
	  printf(".");
      printf("\n");
    }
    printf("\n");
  }
  return(0);
}

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

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

int main(){
  long long A,B;
  cin >> A >> B;

  vector<long long> a(50);
  vector<long long> b(50);
  long long base=1;
  for(int i=0;i<50;i++){
    a.at(i)=A/(base*2)*base;
    if((A%(base*2)-1)/base>0) a.at(i)+=A%(base*2)-base;
    b.at(i)=(B+1)/(base*2)*base;
    if(((B+1)%(base*2)-1)/base>0) b.at(i)+=(B+1)%(base*2)-base;
    base*=2;
  }
  
  long long ans=0;
  base=1;
  for(int i=0;i<50;i++){
    //cout << i << ":" << a.at(i) << "," << b.at(i) << endl;
    if((b.at(i)-a.at(i))%2==1)  ans+=base;
    base*=2;
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
    int n;
    cin >> n;
    int a = n%1000;
    int b = 0;
    if(a!=0) b = 1000-a;
    cout << b << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
const int mod = 1e9 + 7;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
int main(){
    int n, k; cin >> n >> k;
    vll sn(n,0);
    rep(i,k){
        int d; cin >> d;
        rep(j,d){
            int a; cin >> a;
            sn[a-1]++;
        }
    }
    ll cnt = 0;
    rep(i,n)if(sn[i] == 0)cnt++;
    cout << cnt << endl;
    return 0;
}  

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

const int MOD = 1e9 + 7;

class mint {
    long long x;
public:
    mint(long long x=0) : x((x % MOD + MOD) % MOD) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};


// 組み合わせ数を計算する
map<long long, vector<mint>> _combinations;
mint combination(long long n, long long r) {
    if(n < 1 || r < 1) return mint(0);
    if(n == r) return mint(1);
    if(r > n - r) r = n - r;
    if(!_combinations.count(n)) {
        vector<mint> vec = {0, n};
        _combinations.emplace_hint(_combinations.end(), n, vec);
    }
    auto&& vec = _combinations.find(n)->second;
    if(vec.size() <= r) {
        long long i = vec.size();
        vec.resize(r + 1);
        for(; i <= r; i++) {
            vec[i] = vec[i - 1];
            vec[i] *= (n - i + 1);
            vec[i] /= i;
        }
    }

    return vec[r];
}

int n,a,b;
mint result;
int main() {
    cin.tie(0); ios::sync_with_stdio(false); cout << fixed << std::setprecision(20);

    cin >> n >> a >> b;
    cout << mint(2).pow(n) - 1 - combination(n, a) - combination(n, b);
}

Measured memory_bytes: 1792
fun main(args:Array<String>):Unit {
    val vector = Vector()
    repeat(readLine()!!.toInt()){
        val arg = readLine()!!.split(' ').map(String::toInt)
        when(arg.first()){
            0 -> when(arg[1]){
                0 -> vector.pushFront(arg.last())
                else -> vector.pushBack(arg.last())
            }
            1 -> println(vector[arg.last()])
            else -> when(arg[1]){
                0 -> vector.popFront()
                else -> vector.popBack()
            }
        }
    }
}

class Vector {
    var capacity:Int = 10000
        private set
    private var mHead:Int = 0//[mHead, mEnd)
    private var mEnd:Int = 0
    private var size:Int = 0
    private var mArray:Array<Int> = Array(10000){0}
    private fun resize():Unit {
        val newArray = Array(capacity * 2){0}
        for (i in 0 until size){
            newArray[i] = mArray[(i + mHead) % capacity]
        }
        capacity *= 2
        mHead = 0
        mEnd = size
        mArray = newArray
    }
    fun pushBack(value:Int):Unit  {
        if (size == capacity) resize()
        mArray[mEnd] = value
        mEnd = (mEnd + 1) % capacity
        ++size
    }
    fun pushFront(value:Int):Unit {
        if (size == capacity) resize()
        mHead = (mHead + capacity - 1) % capacity
        mArray[mHead] = value
        ++size
    }
    fun popBack():Unit {
        mEnd = (mEnd + capacity - 1) % capacity
        --size
    }
    fun popFront():Unit {
        mHead = (mHead + 1) % capacity
        --size
    }
    operator fun get(index:Int):Int = mArray[(mHead + index) % capacity]
}


Measured memory_bytes: 141128
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<=n;i++)
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;


/// 各桁の和
int sumdigit(int x){
   int sum = 0;
    while(x != 0){
        sum += x % 10;
        x /= 10;    
    }
    return sum;
}
/// 最大公約数 
int gcd(int x, int y){
      if(x<y){
          int temp = x;
          x = y;
          y = temp;
      }
      int r = x % y;
       while(r!=0){
           x = y;
           y = r;
           r = x % y;
       }
      return y;
   }



int main(){
    int A ,B,C;
    cin >> A >> B >> C;
    if(A == B && B == C){
        cout << "Yes" << endl;

    }
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <functional>

int N, H;
int b[100000];

int main(){
        scanf("%d %d",&N,&H);
        int a;
        int maxa = 0;
        for(int i = 0; i < N; i++){
                scanf("%d %d",&a,b+i);
                if(maxa < a){ maxa = a;}
        }

        std::sort(b,b+N,std::greater<int>());
        int cnt=0;
        int bind = 0;
        while(H > 0 && b[bind] > maxa && bind != N){ // ここを>にするのか>=にするのかで結果が異なる
                cnt++; H -= b[bind++];
        }
        if(H > 0){
                cnt += H/maxa;
                cnt += (H%maxa==0)?0:1;
        }

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

}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <vector> 
#include <algorithm>
#include <limits>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

ll N,W;

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

int main(){
  cin >> N >> W;
  vector<pll> goods(N);
  vector<vector<ll>> dp(N+1, vector<ll>(W+1,0));
  
  for(ll i=0; i<N; i++){
    pll init; 
    cin >> init.first >> init.second;
    goods[i] = init;
  }
  
  for(ll i=0; i<N; i++){
    for(ll j=0; j<=W; j++){
      ll w = j-goods[i].first;
      if(w>=0) chmax(dp[i+1][j], dp[i][w]+goods[i].second);
      chmax(dp[i+1][j], dp[i][j]);
    }
  }
  
  cout << dp[N][W] << "\n";
}

Measured memory_bytes: 80256
x,n = map(int,input().split())
p = list(map(int,input().split()))
q = set(range(0,102))
q = q - set(p)
q_list = list(q)
ans = 100
d = 100
for i in range(102-n):
   if d != min(d,abs(x - q_list[i])):
       ans = q_list[i]
       d = abs(x - q_list[i])
print(ans)

Measured memory_bytes: 61880