akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#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 fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;





int main(void) {

    int n;
    cin>>n;
    bool ch=false;
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            if(i*j==n)ch=true;
        }
    }
    if(ch)fin("Yes");
    else fin("No");

}



Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;
type I = usize;

fn main() {
    input!{
      a: usize,
      b: usize,
      t: usize,
    }
    let ans = t/a;
    println!("{}", ans*b);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

ll a[200010],sum[200010];

int main() {
    int n;cin>>n;
    rep(i,n) {
        cin>>a[i];
        sum[i+1] = (sum[i] + a[i])%MOD;
    }
    ll ans = 0;
    rep(i,n-1){
        ans = (ans + (a[i]*((sum[n]-sum[i+1]+MOD)%MOD))%MOD)%MOD;
    }
    if(ans < 0) ans = (ans + MOD) %MOD;
    cout<<ans<<endl;
}

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

int main(){
    int a, b;
    cin>>a>>b;
    
    if(a<1 or a>9 or b<1 or b>9){
        cout<<-1;
        return 0;
    }
    
    cout<<a*b;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> LLP;

const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;
// const double PI = M_PI;

int n, m;
vector<int> c;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  c.resize(m);
  rep(i, m) { cin >> c[i]; }
  int dp[n + 1];
  fill(dp, dp + n + 1, INF);
  dp[0] = 0;

  rep(i, m) {
    rep(j, n + 1) {
      if (dp[i] != INF && j + c[i] <= n) {
        dp[j + c[i]] = min(dp[j + c[i]], dp[j] + 1);
      }
    }
  }

  cout << dp[n] << endl;
  return 0;
}



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

int main()
{
	int H,W;
	cin >> H >> W;
	string data[H];
	for (int i = 0;i < H; i++){
		cin >> data[i];
	}
	for (int i = -1;i < H+1; i++){
		for (int j = -1;j < W+1; j++){
			if(j == W )
			{
				cout << "#" << endl;
			}
			else if((i == -1 || i == H) || j==-1)
			{
				cout << "#";
			}
			else
			{
				cout << data[i][j];
			}
		}
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,d;
long long a;
pair<int,long long> mon[200100];//(x,h)
long long de[200100];
int main(){
	cin>>n>>d>>a;
	for(int i=1;i<=n;i++){
		cin>>mon[i].first>>mon[i].second;
	}
	sort(mon+1,mon+n+1);
	long long ch=0LL;
	long long blows=0LL;
	long long res=0;
	memset(de,0,sizeof(de));
	int it=1;
	int ccc;
	for(int i=1;i<=n;i++){
		//possible:i,......,it
		//cur_hp:HP(i)
		ch=mon[i].second;//blood
		ch-=blows*a;
		ccc=0;
		if(ch>0){
			blows+=(ch+a-1)/a;//KO!
			res+=(ch+a-1)/a;
			ccc=(ch+a-1)/a;
		}
		while(it<=n&&mon[it].first-mon[i].first<=2*d)
			it++;
		it--;
		de[it]+=ccc;
		blows-=de[i];
	}
	cout<<res<<endl;
	return 0;
} 

Measured memory_bytes: 4992
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str):
    ans = YES

    for i, s in enumerate(S):
        if i%2==0:
            if s != "h":
                ans = NO
                break
        else:
            if s != "i":
                ans = NO
                break
    if len(S) % 2 == 1:
        ans = NO
    print(ans)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
a[99][999],c;f(d,s,b,i){for(++a[d++][s];i--;)b>>i&1||f(d,s+i*d,b|1<<i,10);}main(){for(f(0,0,0,10);scanf("%d%d",a,&c)/2;)printf("%d\n",a[**a][c]);}

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

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

    vector<pair<int, int>> ab;
    rep(i, 0, n)
    {
        int a, b;
        cin >> a >> b;
        ab.emplace_back(a, b);
        // cout << ab[i].first << ab[i].second << endl;
    }
    sort(ab.begin(), ab.end());

    ll cost = 0;
    rep(i, 0, n)
    {
        int num = min(m, ab[i].second);
        // cout << num << m << ab[i].second<<endl;
        cost += (ll)ab[i].first * num;
        m -= num;
        if (m == 0) break;
    }
    cout << cost << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  int min=105;
  ll ans=0;
  for(int i=0;i<N;i++) {
    cin >> h[i];
    if(min>h[i]) {
      min=h[i];
    }
  }
  ans += min;
  for(int i=0;i<N;i++) {
    h[i] -= min;
  }
  int num=0;
  while(1) {
    bool flag=true;
    for(int i=0;i<N;i++) {
      int bmin=h[i];
      if(h[i]!=0) {
        flag=false;
        //部分最小値
        int k=i+1;
        while(1) {
          if(h[k]==0) {
            for(int s=i;s<k;s++) {
              h[s] -= bmin;
            }
            i=k;
            ans += bmin;
            break;
          }
          if(bmin>h[k]) {
            bmin=h[k];
          }
          k++;
        }
      }
    }
    if(flag) {
      cout << ans << endl;
      return 0;
    }
    num++;
  }
}

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

int main(){
    int N;
    cin >> N ;
    int counter = 0;
    vector<int> v(N), c(N);
    for(int i = 0;i<N;i++) cin >> v[i];
    for(int i = 0;i<N;i++) cin >> c[i];
    for(int i = 0;i<N; i++) {
        if (v[i] > c[i]) counter += (v[i] - c[i]);
    }
    cout << counter << endl;
}


Measured memory_bytes: 256
use proconio::{fastout, input};
use std::iter::repeat;

#[fastout]
fn main() {
    input! {
        n: u64,
        a_i: [u64; n],
    }

    let mut h: Vec<u64> = repeat(0).take(a_i.len()).collect();

    for (i, val) in a_i.iter().enumerate() {
        if i == 0 {
            continue;
        }

        let prev_index = i - 1;
        let prev = a_i[prev_index];
        let prev_h = h[prev_index];

        if prev + prev_h > *val {
            h[i] = prev + prev_h - val;
        }
    }

    println!("{}", h.iter().sum::<u64>());
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll gcd(ll a, ll b){
  if(a<b)
    return gcd(b,a);

  if(b==0)
    return a;

  return gcd(b, a%b);
}

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

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

  ll n,m;
  cin >> n >> m;
  vll a(n);
  REP(i, n)
    cin >> a[i];

  SORT_UNIQUE(a);
  n = a.size();

  ll now;
  if(n!=1){
    now = lcm(a[0]/2, a[1]/2);
    for(ll i = 1; i+1<n; i++){
      now = lcm(now, a[i+1]/2);
      if(now>m){
        cout << 0 << endl;
        return 0;
      }
    }
  }
  else
    now = a[0]/2;


  bool flag = true;
  REP(i, n){
    if(now%a[i] != a[i]/2)
      flag = false;
  }

  ll ans = 0;
  if(flag){
    ans = m/now;
    ans = ans/2+ans%2;
  }
  cout << ans << endl;

}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;


void disp(vector<vector <int> > table)
{
	cout << "\n";
	for (int ri = 0; ri < table.size(); ri++) {
		for (int ci = 0; ci < table[0].size(); ci++) {
			cout << table[ri][ci] << " ";
		}
		cout << "\n";
	}
}

int main()
{
	int H, W;

	cin >> H >> W;

	vector<vector <int> > table;

	for (int hi = 0; hi < H; hi++) {
		int a;
		vector<int> line;
		for (int wi = 0; wi < W; wi++) {
			cin >> a;
			line.push_back(a);
		}
		table.push_back(line);
	}

	int cnt = 0;
	vector<string> ans;
	for (int ri = 0; ri < H; ri++) {
		for (int ci = 0; ci < W -1; ci++) {
			if (table[ri][ci] % 2 == 1) {
				table[ri][ci]--;
				table[ri][ci+1]++;
				cnt++;
				string line = to_string(ri + 1) + " " + to_string(ci + 1) + " " + to_string(ri + 1) + " " + to_string(ci + 2);
				ans.push_back(line);
				//disp(table);
			}
		}
	}

	int ci = W - 1;
	for (int ri = 0; ri < H-1; ri++) {
		if (table[ri][ci] % 2 == 1) {
			table[ri][ci]--;
			table[ri+1][ci]++;
			cnt++;
			string line = to_string(ri + 1) + " " + to_string(ci + 1) + " " + to_string(ri + 2) + " " + to_string(ci + 1);
			ans.push_back(line);
			//disp(table);
		}
	}


	printf("%d\n", cnt);
	for (auto s : ans) {
		printf("%s\n", s.c_str());
	}


	return 0;
}



Measured memory_bytes: 11892
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    int64_t N, W;
    cin >> N >> W;
    vector<int64_t>waits(110);
    vector<int64_t>values(110);
    int64_t max_v = 100100;
    int64_t max_n = 110;
    for (int64_t i=0; i<N; i++) {
        int64_t w, v;
        cin >> w >> v;
        waits[i] = w;
        values[i] = v;
    }

    vector<vector<int64_t>> dp(max_n, vector<int64_t>(max_v, 1000000001));
    dp[0][0] = 0;
    for (int i=0; i<N; i++) {
        for (int sum_v=0; sum_v<max_v; sum_v++) {
            if (sum_v - values[i] >= 0) {
                chmin(dp[i+1][sum_v], dp[i][sum_v-values[i]] + waits[i]);
            }

            chmin(dp[i+1][sum_v], dp[i][sum_v]);
        }
    }

    int64_t ans = 0;
    for (int sum_v=0; sum_v<max_v; sum_v++) {
        if (dp[N][sum_v] <= W) {
            ans = sum_v;
        }
    }

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

Measured memory_bytes: 90388
#include<iostream>

using namespace std;

int main() {
	int n;
	int A[100000];
	int ki = 0;

	//input
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		if (A[i] % 2 == 1) ki++;
	}

	if (ki % 2 == 0)cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}



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

long long number[11];
struct BOL{
	bool bol[11];
};
vector <BOL> kumi;
BOL Plus;
long long answer=0;
void operate();

void kumiawase(int i){
	if(i == input.size()-1){
		kumi.push_back(Plus);
	}else{
		Plus.bol[i] = true;
		kumiawase(i+1);
		Plus.bol[i] = false;
		kumiawase(i+1);
	}
}
int main(){
	cin >> input;
	
	for(int i=0;i<input.size();i++){
		number[i] = input[i] - '0';
	}
	
	kumiawase(0);
	long long answer=0;
	for(int i=0;i<kumi.size();i++){
		long long HOGE = 0;
		for(int j=0;j<input.size();j++){
			HOGE += number[j];
			if(!kumi[i].bol[j]){
				answer += HOGE;
				HOGE = 0;
			}else{
				HOGE *= 10;
			}
		}
		answer += HOGE;
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>;

using namespace std;

int main()
{
	int m, f, b;
	cin >> m >> f >> b;
	if (b <= m)
		cout << 0 <<endl;
	else {
		if (b > f + m)
			cout << "NA"<< endl;
		else
			cout << b - m<< endl;
	}
	return 0;
}


Measured memory_bytes: 3112
/**
     **author : _KMS_
     **created : 01-04-2020
**/
#include<bits/stdc++.h>
using namespace std;
const long long M =3e5+10,MOD=1e9+7;
typedef long long ll;
vector<int>v[M];
bool vis[M];
int dp[M][7];
int arr[10];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t,n;
    cin>>n;
    for(int i=1;i<=n;++i)
    {
      for(int j=1;j<=3;j++)
      {
        cin>>arr[j];
       for(int k=1;k<=3;k++)if(j!=k)dp[i][j]=max(dp[i][j],dp[i-1][k]+arr[j]);
      }
    }

  cout<<max(dp[n][1],max(dp[n][2],dp[n][3]))<<"\n";
    return 0;
}

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


int main() {
    long long a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;
    if(w>=v){//逃げる方が速いとき(同速度含む)
        cout<<"NO"<<endl;
        return 0;
    }
    if(a>b){//A(鬼)の方が右にいるとき
        ll sa=a-b;
        if(sa>t*(v-w)){
            cout<<"NO"<<endl;
        }
        else{
            cout<<"YES"<<endl;
        }
    }
    if(a<b){//B(逃げる方)が右にいるとき
        ll sa=b-a;
        if(sa>t*(v-w)){
            cout<<"NO"<<endl;
        }
        else{
            cout<<"YES"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3676
#define _USE_NATH_DEFINES
#include <iostream>
#include<algorithm>
using namespace std;

int main() {
	int a[3];
	for(int i = 0; i < 3; i++){
		cin >> a[i];
	}
	sort(a, a + 3);
	cout << a[0] + a[1] << endl;
}

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

int main() {
	int n;
	cin >> n;
	int mn = n;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		mn = min(mn, tmp);
		if (tmp == mn)
			ans++;
	}
	cout << ans;
}


Measured memory_bytes: 256
#![allow(dead_code)]

use std::cmp::{max, min};
fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let n: usize = sc.read();
    let s = sc.chars();

    let mut ans = 0;
    for i in 0..n - 1 {
        let z = longest_common_prefixes(&s[i..n]);
        let m = z
            .iter()
            .enumerate()
            .fold(0, |a, (i, &x)| max(a, min(i, x)));
        ans = max(ans, m);
    }

    format!("{}\n", ans)
}
#[test]
fn test_solve() {
    assert_eq!(solve("5\nababa\n"), "2\n");
    assert_eq!(solve("2\nxy\n"), "0\n");
    assert_eq!(solve("13\nstrangeorange\n"), "5\n");
}
fn longest_common_prefixes<T: PartialEq>(s: &[T]) -> Vec<usize> {
    let mut a = vec![0; s.len()];
    let mut i = 1;
    let mut j = 0;
    while i < s.len() {
        while i + j < s.len() && s[j] == s[i + j] {
            j += 1;
        }
        a[i] = j;
        if j == 0 {
            i += 1;
            continue;
        }
        let mut k = 1;
        while i + k < s.len() && k + a[k] < j {
            a[i + k] = a[k];
            k += 1
        }
        i += k;
        j -= k;
    }
    a
}
fn main() {
    let mut buf = String::new();
    use std::io::Read;
    std::io::stdin().read_to_string(&mut buf).unwrap();
    use std::io::Write;
    std::io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}
struct Scanner<I> {
    src: I,
}
impl<'a> Scanner<std::str::SplitWhitespace<'a>> {
    fn from_str(src: &'a str) -> Self {
        Scanner {
            src: src.split_whitespace(),
        }
    }
}
impl<'a, I> Scanner<I>
where
    I: std::iter::Iterator<Item = &'a str>,
{
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.src.next().unwrap().parse().ok().expect("Parse error")
    }
    fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    fn chars(&mut self) -> Vec<char> {
        self.src.next().unwrap().chars().collect()
    }
}

Measured memory_bytes: 4476
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

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

    int t[N];
    int x[N];
    int y[N];

    for (int i = 1; i <= N; i++)
        cin >> t[i] >> x[i] >> y[i];

    bool can = true;
    for (int i = 1; i <= N; i++)
    {
        if (t[i] < x[i] + y[i])
        {
            can = false;
        }
        if ((t[i] - x[i] - y[i])%2 != 0){
            can = false;
        }
    }
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 1408
# 32
import math
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n, d = LI()
x = LIR(n)
ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        dis = 0
        for k in range(d):
            dis += (x[i][k] - x[j][k]) ** 2
        dis = math.sqrt(dis)
        if float(dis).is_integer():
            ans += 1
print(ans)


Measured memory_bytes: 9204
<?php
$n   = trim(fgets(STDIN));
$a   = explode(' ', trim(fgets(STDIN)));
$min = 100;
for ($i = 0; $i < $n; $i++) {
    for ($j = 0; $a[$i] % 2 === 0; $j++) {
        $a[$i] = $a[$i] / 2;
    }
    if ($j < $min) {
        $min = $j;
    }
}
print $min;

Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

template<typename T>
class CumulativeSum{
public:
  Int n;
  vector<T> sum;
  vector<T> A;
  Int added;
  CumulativeSum():n(-1),added(0){}
  CumulativeSum(Int n):n(n), sum(n+1), A(n+1),added(0){}
  CumulativeSum(const vector<T> &B):n(B.size()), sum(n+1), A(n+1),added(0){
    for(Int i=1;i<=n;i++) sum[i] = sum[i-1] + B[i-1];
  }

  void apply(){
    for(Int i=1;i<=n;i++) A[i] = A[i] + A[i-1];
    for(Int i=1;i<=n;i++) A[i] = A[i] + A[i-1];
    for(Int i=1;i<=n;i++) sum[i] = sum[i] + A[i-1];
    added = 0; A.clear(); A.resize(n+1);
  }

  //[l, r)にxを加算
  void add(Int l, Int r, T x){
    added = 1;
    assert(l <= r && 0 <= l && r <= n);
    A[l] = A[l] + x;
    A[r] = A[r] - x;
  }

  //[l, r)の和を得る
  T get(Int l,Int r){
    assert(l<=r && 0<=l && r<=n);
    if(added) apply();
    return sum[r] - sum[l];
  }
};


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N;
  cin>>N;
  vector<Int> A(N);
  cin>>A;

  CumulativeSum<Int> sum(A);

  Int ans = INF;
  for(Int i=1;i<N;i++){
    Int l = sum.get(0, i);
    Int r = sum.get(i, N);
    Min(ans, abs(l - r));
  }
  cout<<ans<<endl;
  

  return 0;
}


Measured memory_bytes: 256
/*

#      #      #####   ##   ##  #####      ##     #  #      #   #  #####
#      #      #   #  #  ###  # #          # ##   #  #      #   #  #   #
#      #      #   #  #   #   # #          #  ##  #  #      #   #  #   #
#      #      #   #   #     #  #####      #   #  #  #       ###   #####
#      #      #   #    #   #   #          #  ##  #  #        #    #   #
#      #      #   #     ###    #          # ##   #  #        #    #   #
#      #####  #####      #     #####      ##     #  #####    #    #   #

*/

#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define pb push_back
#define np next_permutation
#define bs binary_search
#define mp make_pair
#define all(x) x.begin(), x.end()
#define bp __builtin_popcountll
#define sqr(x) ((llong)sqrt (x))
#define b_ctz __builtin_ctzll
#define b_clz __builtin_clzll

#define y1 road_to_respa_top_6
#define prev road_to_respa_top_6
#define Abdrakhman abcdefghijklmnopqrstuvwxyzRakhman
#define left kotoriy_levee_chem_right
#define right kotoriy_pravee_chem_left

#define android ios_base::sync_with_stdio(0), cin.tie (0), cout.tie (0)
#define fn ""

typedef long long llong;
typedef long double ldouble;
typedef unsigned long long ullong;

typedef vector <llong> vl;
typedef vector <string> vs;
typedef vector <vector <llong>> matrix;

typedef pair <llong, llong> pll;

typedef map <llong, llong> mll;

typedef set <llong> sl;

const llong MXN = 1e6 + 1;
const llong MNN = 1e3 + 1;
const llong MOD = 1e9 + 7;
const llong INF = 1e18;
const llong MAGIC = 1000;
const ldouble EPS = 1e-9;
const ldouble PI = 3.1415926536;
const string TIME = "rovno_ushten_push_ketti";

inline llong log2 (llong x) {return 64 - b_clz (x) - 1;};
inline llong __lcm (llong a, llong b) {return a / __gcd (a, b) * b;};

llong n, k, now;
llong cnt[MXN];

int main () {
    android;
    random_device rand;
    #ifdef I_LOVE_DILYA
        freopen ("input.txt", "r", stdin);
    #endif
    cin >> n >> k;
    for (llong i = 1; i <= n; ++ i) {
        llong x;
        cin >> x;
        if (!cnt[x]) ++ now;
        ++ cnt[x];
    }
    sort (cnt + 1, cnt + n + 1);
    llong ans = 0;
    for (llong i = 1; i <= n; ++ i) {
        if (!cnt[i]) continue;
        if (now <= k) break;
        ans += cnt[i];
        -- now;
    }
    cout << ans;
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  bool f = true;
  string a = "", b = "";
  int q;
  cin >> q;
  rep(i,q) {
    int c;
    cin >> c;
    if(c == 1) f = !f;
    else {
      int x; char y;
      cin >> x >> y;
      if(x == 1) {
        if(f) a = y + a;
        else b += y;
      } else {
        if(f) b += y;
        else a = y + a;
      }
    }
  }
  string ans;
  ans = a + s + b;
  if(!f) reverse(ans.begin(),ans.end());
  cout << ans << endl;
  return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif


void solve() {
    ll X;
    cin >> X;
    rep2(a, -140, 140) {
        rep2(b, -140, 140) {
            ll A = a * a * a * a * a;
            ll B = b * b * b * b * b;
            if (A - B == X) {
                cout << a << " " << b << '\n';
                return;
            }
        }
    }
}

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


Measured memory_bytes: 3612
import math
import bisect
def binary_search(a,n):
    low = 0
    high = len(a) - 1
    while low <= high:
        mid = (low + high) // 2
        index = a[mid]
        if index == n:
            return True
        elif index < n:
            low = mid+1
        else:
            high = mid -1
    return False

def get_sieve_oof_eratosthenes(n):
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1,n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
data = get_sieve_oof_eratosthenes(10**5 + 1)
count = [0 for i in range(10**5+1)]
for i in range(3,10**5,2):
    if binary_search(data,i) and binary_search(data,(i+1)//2):
            count[i] += count[i-1] + 1
            count[i+1] = count[i]
    else:
        count[i] += count[i-1]
        count[i+1] = count[i]
q = int(input())
for i in range(q):
    l,r = map(int,input().split())
    print(count[r]-count[l-1])


Measured memory_bytes: 7476
#include<stdio.h>
#include<math.h>
using namespace std;

int main(){
    double a, b, C, S, L, h;
    
    scanf("%lf %lf %lf", &a, &b, &C);
    
    S = a * b * sin(C * M_PI/180) / 2;
    L = a + b + sqrt(a*a + b*b - 2*a*b*cos(C * M_PI/180));
    h = S * 2 / a;
    
    printf("%lf\n%lf\n%lf\n", S, L, h);
    
    return 0;
}


Measured memory_bytes: 2960
#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 argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll N; cin >> N;
    map<ll,ll> mp_l;
    map<ll,ll> mp_r;
    REP(i, N) {
        ll tmp; cin >> tmp;
        if (i-tmp >= 0) mp_l[i-tmp]++;
        mp_r[i+tmp]++;//はみ出てるけどまあ使わない
    }
    ll res = 0;
    REP(i, N) {
        res += mp_l[i]*mp_r[i];
    }
    cout << res << endl;
    return 0;
}


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

int main() {
  int n; cin >> n;
  vector<pair<string, int>> p(n);
  vector<pair<string, int>> p0(n);
  for (int i=0; i<n; i++){
    cin >> p.at(i).first >> p.at(i).second;
    p.at(i).second *= -1;
    p0.at(i).first = p.at(i).first;
    p0.at(i).second = p.at(i).second;
  } // pairの列をpに格納。初期値をp0にコピー
  
  sort(p.begin(), p.end());
  // 辞書順早い順、点数低い順

  
  for (int i=0; i<n; i++){
    for (int j=0; j<n; j++){
      if (p.at(i) == p0.at(j)){
        cout << j+1 <<endl;
      }
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int N;
	cin>>N;
	vector<ll> A(N);
	rep(i,N)cin>>A[i];
	vector<ll> sum(N+1),xorsum(N+1);
	sum[0] = xorsum[0] = 0;
	rep(i,N){
		sum[i+1] = sum[i] + A[i];
		xorsum[i+1] = xorsum[i] ^ A[i];
	}
	ll ans = 0;
	for (int l = 1; l < N+1; ++l){
		ll ok  = l, ng = N+1;
		// (l,ok)は条件を満たし、(l,ng)は条件を満たさない。
		// okとngの距離を縮めていくことで境界値r0を求める
		while(ng - ok > 1){
			ll mid = (ok + ng) / 2;
			if(sum[mid] - sum[l - 1] == (xorsum[mid] ^ xorsum[l-1])){
				ok = mid;
			}
			else{
				ng = mid;
			}
		}

		//最終的なokが境界値r0になる
		ans += ok - l + 1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4992
from collections import defaultdict

N=int(input())
M=defaultdict(list)

for i in range(N-1):
  a,b=map(int,input().split())
  M[a-1].append(b-1)
  M[b-1].append(a-1)

def bfs(s):
  res=[-1 for x in range(N)]
  res[s]=0
  queue=[s]
  while queue:
    np=queue.pop()
    for nx in M[np]:
      if res[nx]<0:
        res[nx]=res[np]+1
        queue.append(nx)
  return res

ans0=bfs(0)
ansN=bfs(N-1)
cnt=0
for i in range(N):
  if ans0[i]<=ansN[i]:
    cnt+=1
if cnt > N/2:
  print("Fennec")
else:
  print("Snuke")

Measured memory_bytes: 37956
// https://atcoder.jp/contests/arc061/tasks/arc061_a

#include <iostream>
#include <vector>
#include <tuple>
#include <bitset>
#include <string>

using namespace std;
using ll = long long;
using ull = unsigned long long;

struct C {
    string s_{};
    explicit C(string s) : s_(move(s)){}
    ll resolve() {
        auto len = s_.size();
        ll ret = 0;
        ll count = 1;
        ll n = (1 << (len-1));
        for(ull i=0; i < n; ++i) {
            bitset<10> b{i};
            auto start = s_.data();
            ll count = 1;
            for(ll j=0; j < len-1; ++j) {
                if(b[j]) {
                    ret += stoll(string(start, count));
                    start += count;
                    count = 1;
                } else {
                    ++count;
                }
            }
            ret += stoll(string(start, count));
        }
        return ret;
    }
};

int main() {
    string s;
    cin >> s;
    C c{move(s)};
    cout << c.resolve() << endl;
    return 0;
}


Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())

ans = ''

ans += 'R' * (tx - sx)
ans += 'U' * (ty - sy)

ans += 'L' * (tx - sx)
ans += 'D' * (ty - sy)

ans += 'L'
ans += 'U' * (ty - sy + 1)
ans += 'R' * (tx - sx + 1)
ans += 'D'

ans += 'R'
ans += 'D' * (ty - sy + 1)
ans += 'L' * (tx - sx + 1)
ans += 'U'

print(ans)

Measured memory_bytes: 9164
char W[9],V[9];Z[7*24*60],S,N,T,P,M;main(){
	int i,j,k,l,r;
	for(;scanf("%d%d%d%s%s%d%d",&S,&N,&T,W,V,&P,&M),S;printf("%.9f\n",1-pow(1-1.0/P,N*r))){
		memset(Z,0,sizeof(Z));
		l=*W=='A'?7:1;
		if(*V=='A')for(i=0;i<l;i++)for(j=0;j<24*60;j++)Z[i*24*60+j]=1;
		if(*V=='D')for(i=0;i<l;i++)for(j=0;j<12*60;j++)Z[(i*24+12)*60+j]=1;
		if(*V=='N')for(i=0;i<l;i++)for(j=0;j<6*60;j++)Z[i*24*60+j]=Z[(i*24+18)*60+j]=1;
		for(r=j=0;j<24*60;r=r>l?r:l,j++)for(k=j,l=i=0;i<M;i++)l+=Z[(k+S)%(7*24*60)]&Z[k],k=(k+T)%(7*24*60);
}exit(0);}

Measured memory_bytes: 736
N = int(input())
A = [[0 for _ in range(2)] for _ in range(N)]
tmp = input().split()
for n in range(N):
    A[n][0] = int(tmp[n])
    A[n][1] = n

A.sort()
T =[]
for n in range(N):
    T.append(A[n][1]+1)

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



Measured memory_bytes: 38368
#define _GLIBCXX_DEBUG
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
void solve(){
    int n;
    cin >> n;
    vi b(n-1);
    for(int i = 0; i < n-1; i++) cin >> b[i];
    int sum = b[n-2];
    for(int i = n - 2; i > 0; i--){
        if(b[i] <= b[i-1]) sum += b[i];
        else sum += b[i-1];
    }
    cout << sum + b[0];
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    while(t--) solve();
}

Measured memory_bytes: 384
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int Q = sc.nextInt();
    String S = sc.next();
    int[] numArray = new int[N];
    int count = 0;
    numArray[0] = 0;
    for (int i = 0; i < N-1; i++) {
        if (S.substring(i,i+1).equals("A")){
            if (i < N-1 && S.substring(i+1,i+2).equals("C")){
                count++;
            }
        }
        numArray[i+1] = count;
    }
    for (int j = 0; j < Q; j++) {
        int start = sc.nextInt();
        int end = sc.nextInt();
        int answer = numArray[end-1] - numArray[start-1];
        System.out.println(answer);
    }
  }
  
}


Measured memory_bytes: 81932
// Iroha and a Grid	
// * frank_c1
// * 2017 / 09 / 30
 
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
 
LL pow_mod(LL b, LL p, LL k) {
	LL ret = 1;
	for (; p; p >>= 1) {
		if (p & 1) ret = ret * b % k;
		b = b * b % k;
	} return ret; 
}
 
const int maxn = (int)(4e5) + 5;
const int mo = (int)(1e9) + 7;
LL fac[maxn], ivf[maxn];
 
inline LL C(int n, int m) {
	if (m < 0 || n - m < 0) return 0;
	return (fac[n] * ivf[m] % mo) * ivf[n - m] % mo;
}
 
int main() {
	int h, w, a, b; LL ret = 0;
	scanf("%d%d%d%d", &h, &w, &a, &b);
	int mx = 2 * max(h, w); fac[0] = ivf[0] = 1;
	for (int i = 1; i <= mx; ++i) fac[i] = fac[i - 1] * i % mo;
	ivf[mx] = pow_mod(fac[mx], mo - 2, mo);
	for (int i = mx - 1; i >= 1; --i) ivf[i] = ivf[i + 1] * (i + 1) % mo;
	for (int i = b + 1; i <= w; ++i) (ret += C(h - a - 1 + i - 1, i - 1) * C(a - 1 + w - i, a - 1)) %= mo; 
	return printf("%lld\n", ret), 0;
}

Measured memory_bytes: 5888
n=int(input())
#a,b,x=map(int,input().split())
#hl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

mn=min(a,b,c,d,e)
print((n+mn-1)//mn +4)


Measured memory_bytes: 3064
//bismillahir rahmanir rahim            //Author:Fayed Anik

#include <bits/stdc++.h> 

using namespace std;


#define         ll                         long  long
#define         lf                         double 
#define         pb(x)                      push_back(x)
#define         ull                        unsigned long long
#define         sfl(a)                     scanf("%lld",&a)
#define         sf(a)                      scanf("%d",&a)
#define         pf(a)                      printf("%d\n",a)
#define         pfl(a)                     printf("%lld\n",a)
#define         pdl(a)                     printf("%llf\n",a)
#define         FOR(x,n)                   for(ll x=1;x<=n;++x)
#define         vii                        vector< ll > v
#define         pi                         3.14159265359
#define         mex                        10000000
#define         pii                        pair< ll , ll >
#define         mem(m,a)                   memset( m, a,sizeof m)
#define         mp(a,b)                    make_pair(a,b)
#define         maxn                       100000
#define         mod                        1000000007
#define         INF                        1e17
#define         f1                         first
#define         f2                         second
#define         all(v)                     v.begin(),v.end()
#define         PI                         acos(-1)
#define         printminusone              printf("-1\n")
#define         bug                        printf("bug")

int main(){
	ll a,b,x;
	sfl(a),sfl(b);
	ll ans=0;
	if(a==b){
		cout << a << endl;
		return 0;
	}

	x=b-a;
	x=x>>1;
	if(a&1){
		if(b&1){
			if(x&1){
				ans= a xor 1;
				cout << ans << endl;
			}	
			else{
				cout << a << endl;
			}
		}
		else{
			if(x&1){
				ans = a xor 1;
				ans = ans xor b;
				cout << ans << endl;
				
			}
			else{
				ans = a xor b;
				cout << ans << endl;
			}
		}
	}
	else{
		if(b&1){
			if(x&1){
				cout << 0 << endl;
			}
			else{
				cout << 1 << endl;
			}
		}

		else{
			if(x&1){
				ans=1 xor b;
				cout << ans << endl;

			}
			else{
				cout << b << endl;
			}	
		}
	}
}



Measured memory_bytes: 256
def solve():
    n, m, c = map(int, input().split())
    b = list(map(int, input().split()))
    a = [list(map(int, input().split())) for _ in range(n)]
    s = 0
    ans = 0
    for i in range(n):
        s = 0
        for j in range(m):
            s += a[i][j] * b[j]
        if s + c > 0:
            ans += 1
    print(ans)


if __name__ == '__main__':
    solve()


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

const int MOD = 1000000007;

vector<long long> kosu;//ありえる素因数のmaxを入れる

void divisor(long long n) {
  for (long long i = 2; i * i <= n; i++) {
    if(n % i == 0){  
      kosu.push_back(0); 
    }
    while(n % i == 0){
      kosu[kosu.size()-1]++;
      n /= i;
    }
  }
  if(n != 1){
    kosu.push_back(1);
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  long long N, M;
  cin >> N >> M;
  if(M == 1){  
    cout << 1 <<endl;
    return 0;
  } else{  
    divisor(M);
  }
  long long maxKosu = *max_element(kosu.begin(), kosu.end());
  vector<vector<long long>> dp(N, vector<long long>(maxKosu+1));
  for(int i = 0; i <= maxKosu; i++) dp[0][i] = 1;
  for(int i = 1; i < N; i++){  
    for(int j = 0; j <= maxKosu; j++){  
      dp[i][j] = dp[i-1][j];
      if(j > 0){  
        dp[i][j] += dp[i][j-1];
        dp[i][j] %= MOD;
      }
    }
  }
  long long ans = 1;
  for(int i = 0; i < kosu.size(); i++){  
    ans *= dp[N-1][kosu[i]];
    ans %= MOD;
  }
  cout << ans <<endl;
}


Measured memory_bytes: 30540
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define LOG(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

/*
x y
10^18
 */

ll x,y;

int main(){
  cin >> x >> y;
  cout << (int)floor(logl((long double)y/(long double)x)/logl(2.0)) + 1 << endl;

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<set>
#include<queue>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define INFECTED true
#define UNINFECTED false

int _n;
class state{
public:
  bool m[5][5];
  int x,y;
  int cnt;
  bool operator<(const state & a)const{
    if (x != a.x)return x < a.x;
    else if ( y !=a.y)return y<a.y;
    rep(i,_n)
      rep(j,_n)if( m[i][j]!=a.m[i][j]==INFECTED)return INFECTED;
    return false;
  }
};


int dx[]={ 1,1,1,0,-1,-1,-1, 0};
int dy[]={-1,0,1,1, 1, 0,-1,-1};
char m[5][5];

bool sparse(int x,int y,state &now){
  int cnt=0;
  rep(i,8){
    int nex=x+dx[i],ney=y+dy[i];
    if (nex<0||ney<0||nex>=_n||ney>=_n)continue;
    else if ( now.m[ney][nex]==INFECTED)cnt++;
  }
  if ( now.m[y][x]==INFECTED && (cnt==2||cnt==3))return INFECTED;
  else if (now.m[y][x]==UNINFECTED && cnt == 3)return INFECTED;
  return UNINFECTED;
}

bool  solved(state & now,int n){
  rep(i,n)
    rep(j,n)
    if ( now.m[i][j]==INFECTED)return INFECTED;
  return UNINFECTED;
}


int bfs(int n,state &ini){
  set<state>  S;
  queue<state> Q;
  Q.push(ini);
  S.insert(ini);
  
  while(!Q.empty()){
    state now =Q.front();
    Q.pop();
    if ( solved(now,n)==UNINFECTED){
      return now.cnt;
    }
  /*
    rep(i,n){
      rep(j,n)cout<< (now.m[i][j]==INFECTED?'#':'.');
      cout << endl;
    }
    */

    rep(i,8){
      int nex=now.x+dx[i],ney=now.y+dy[i];
      if (nex>=n||ney>=n||nex<0||ney<0||now.m[ney][nex]==INFECTED)continue;
      state next=now;
      next.x=nex;
      next.y=ney;
      next.cnt++;
      now.m[ney][nex]=true;
      rep(k,n){
	rep(j,n){
	  next.m[k][j]=sparse(j,k,now);
	}
      }
      now.m[ney][nex]=false;
      next.m[next.y][next.x]=UNINFECTED;
      if (S.find(next)==S.end()){
	Q.push(next);
	S.insert(next);
      }
    }
  }
  return -1;
}


main(){
  int n;
  state ini;
  while(cin>>n && n){
    _n=n;
    ini.cnt=0;
    rep(i,n){
      cin>>m[i];
      rep(j,n){
	if (m[i][j]=='@')ini.x=j,ini.y=i,m[i][j]='.';
	if ( m[i][j]=='#')ini.m[i][j]=INFECTED;
	else ini.m[i][j]=UNINFECTED;
      }
    }
    cout << bfs(n,ini)<<endl;
  }
  return false;
}

Measured memory_bytes: 3248
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>
#include<iomanip>

#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define MOD 1000000007

using namespace std;
using ll=long long int;

ll gcd(ll a, ll b) {
    if(a*b == 0)return max(a, b);
    if (a < b) {
        ll tmp = a;
        a = b;
        b = tmp;
    }
    if (a%b == 0)return b;
    return gcd(b, a%b);
}


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


int main(){
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    ll ans;
    ll cd = lcm(C,D);
    ll C_n,D_n,cd_n;
    C_n=(B-(B/C))-(A-1-((A-1)/C));
    D_n=(B-(B/D))-(A-1-((A-1)/D));
    cd_n=(B-(B/cd))-(A-1-((A-1)/cd));
    ans= C_n+D_n-cd_n;
    cout << ans << endl;
    return 0;
}


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

bool exist_isolate (vector<string> &s, int x, int y, int h, int w);

int main () {

    int H, W;
    cin >> H >> W;

    vector<string> s(H);
    for (int i = 0; i < H; i++) {
        cin >> s[i];
    }

    bool isolate;
    string ans = "Yes";

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (s[i][j] == '#') {
                isolate = exist_isolate(s, i, j, H, W);
            }
            if (isolate) {
                ans = "No";
            }
        }
    }

    cout << ans << endl;

    return 0;
}

bool exist_isolate (vector<string> &s, int x, int y, int h, int w) {

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

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            for (int k = 0; k < 4; k++) {

                int nx = x + dx[k], ny = y + dy[k];

                if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
                if (s[nx][ny] == '#') return false;
            }
        }
    }

    return true;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{min,max};
use std::collections::BinaryHeap;

fn main() {
    let xs = read_vec_i64();
    let (v,e,r) = (xs[0] as usize, xs[1] as usize, xs[2] as usize);
    let mut adj = vec![vec![]; v];
    for _ in 0..e {
        let ys = read_vec_i64();
        let (s,t,d) = (ys[0] as usize, ys[1] as usize, ys[2]);
        adj[s].push((t,d));
    }
    let mut dists = vec![None; v];
    dists[r] = Some(0);
    let mut heap = BinaryHeap::new();
    heap.push((0,r));
    while let Some((md,s)) = heap.pop() {
        let d = -md;
        for &(t,dd) in &adj[s] {
            let nd = d + dd;
            if dists[t].is_none() || nd < dists[t].unwrap() {
                dists[t] = Some(nd);
                heap.push((-nd,t));
            }
        }
    }
    for d in dists {
        match d {
            Some(x) => println!("{}", x),
            None => println!("INF"),
        }
    }
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}



Measured memory_bytes: 23344
def main():
    n, a, b = map(int, input().split())
    s = input()
    foreign, passed = 0, 0

    for i in range(len(s)):
        if s[i] == "a":
            if passed < a + b:
                print("Yes")
                passed += 1
            else:
                print("No")
        elif s[i] == "b":
            if passed < a + b and foreign < b:
                print("Yes")
                passed += 1
                foreign += 1
            else:
                print("No")
        else:
            print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 75584