akhauriyash/Code-Regression huggingface dataset:
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
using namespace std;
int main()
{
    int64_t N, D;
    int count = 0;
    cin >> N >> D;
    vector<int64_t> X(N), Y(N);
    for (int64_t i = 0; i < N; i++) {
        cin >> X.at(i) >> Y.at(i);
    }
    for (int64_t i = 0; i < N; i++) {
        if ((X.at(i) * X.at(i)) + (Y.at(i) * Y.at(i)) <= D * D) {
            count++;
        }
    }
    cout << count;
}

Measured memory_bytes: 6416
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n][2];
	for(int i=0; i<n; i++)
	cin>>a[i][0]>>a[i][1];
	for(int i=0; i<n-2; i++)
	{
		int c=0;
		for(int j=i; j<i+3; j++)
		{
			if(a[j][0]==a[j][1])
			c++;	
		}
		if(i!=(n-3))
		{
			if(c==3)
			{
				cout<<"Yes";
				break;	
			}
			else
			c=0;
		}	
		else
		{
			if(c==3)
			{
				cout<<"Yes";
				break;	
			}
			else
			cout<<"No";
		}
	}
	return 0;
}

Measured memory_bytes: 3536
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<long long> a(300000,0);
int n,si;
void update(int,int);
long long find(int,int,int,int,int);

int main(){
  int q,f;
  si=1;
  cin >> n >> q;
  for(int i=0;;i++){
    si*=2;
    if(si>=n+1)break;
  }

  for(int i=0;i<q;i++){
    cin >> f;
    if(f==0){
      int po,d;
      cin >> po >> d;
      update(po,d);
    }
    else{
      int st,go;
      long long sum;
      cin >> st >> go;
      sum=find(st,go+1,0,0,si);
      cout << sum << endl;
    }
  }
  return 0;
}
void update(int p,int d){
  int ko;
  ko=si-1+p;
  a[ko]+=d;
  while(ko>0){
    ko=(ko-1)/2;
    a[ko]+=d;
  }
}
long long find(int s,int t,int k,int l,int r){
  int m=(l+r)/2;
  if(s<=l&&r<=t){
    return a[k];
  }
  else if(r<=s||t<=l)return 0;
  
  return find(s,t,k*2+1,l,m)+find(s,t,k*2+2,m,r);
}

Measured memory_bytes: 5040
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int ss[26];
int main(){
  
    string s;
    cin>>s;
    rep(i,s.size()){
        int u=(s[i]-'a');
        if(ss[u]==0){
            ss[u]++;
        }else{
            puts("no");
            return 0;
        }
    }
    puts("yes");
    
    
    
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

int main(){
    ll n, l;
    cin >> n >> l;

    ll aji = 0;
    ll minval = 9999999;
    ll index = 0;
    for(int i = 0; i < n; i++){
        aji += l+i;
        if(minval > abs(l+i)){
            minval = abs(l+i);
            index = i;
        }
        minval = min(minval, abs(l+i));
    }

    ll ans = 0;
    for(int i = 0; i < n; i++){
        if(i==index){continue;}
        ans += l+i;
    }
    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

int main()
{
	LL n;int ans=0;bool o=false;
	cin>>n;
	while (n>=10)
		o|=n%10!=9,n/=10,ans+=9;
	cout<<ans+n-o<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
 
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int N;
vector <P> red, blue;

int main()
{
    cin >> N;
    int temp1, temp2;
    REP(i,N)
    {
        cin >> temp1 >> temp2;
        red.push_back(make_pair(temp1, temp2));
    }
    REP(i,N)
    {
        cin >> temp1 >> temp2;
        blue.push_back(make_pair(temp2, temp1));
    }

    sort(red.begin(), red.end(), greater<P>());
    sort(blue.begin(), blue.end());

    int ans = 0;
    bool check[100] = {};
    REP(i,N)
    {
        REP(j,N)
        {
            if(check[j]) continue;

            if(red[j].first < blue[i].second && red[j].second < blue[i].first)
            {
                ++ans;
                check[j] = true;
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

template<typename T, typename U> void cmax(T &a, U b) { if (a < b) a = b; }
template<typename T, typename U> void cmin(T &a, U b) { if (a > b) a = b; }

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  for (auto a : A) if (a % 2) return cout << "first" << "\n", 0;
  cout << "second" << "\n";
}

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

using namespace std;
long long a[10001];
long long x;
int main(){
    cin >> x;
    long long n = pow(1e16,1.0/5);
    for (long long i = 1; i <= n; i++) a[i] = i*i*i*i*i;
    for (long long i = n + 1; i <= 2*n; i++){
        long long temp = i - n;
        a[i] = - (temp*temp*temp*temp*temp);
    }
    long long p , q;
    for (int i = 0; i <= 2*n; i++)
        for (int j = 0; j <= 2*n; j++)
            if (a[i] - a[j] == x){
                p = ((i <= n) ? i : -(i - n)) , q = ((j <= n) ? j : -(j - n));
                //cout << p << " " << q << "\n";
            }
    cout << p << " " << q;
    return 0;
}

Measured memory_bytes: 3600
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi; 
typedef vector< vi > vvi; 
/////////////////////////
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define loop(i,a,b) for (int i = a; i < b; i++)
//////////////////////////
#define printvector(n) for(int i=0;i<n.size();i++){cout<<n[i]<<" ";}cout<<'\n'
#define printstack(n) for(int i=0;i<n.size();i++){cout<<n[i]<<" ";}cout<<'\n'
#define PI_val 3.14159265359
#define printpair(n) cout<<n.F<<" "<<n.S
#define printvop(n) loop(i,0,n.size()-1){printpair(n[i])<<endl;}
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
long long int mod=1000000007;
//////////////////////////
void constructXOR(int A[], int n) 
{ 
    // calculate xor of array 
    int XOR = 0; 
    for (int i = 0; i < n; i++) 
        XOR ^= A[i]; 
  
    // update array 
    for (int i = 0; i < n; i++) 
        A[i] = XOR ^ A[i]; 
} 

int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("E:/codes/testcases/input.in", "r", stdin);
    // for writing output to output.txt
    freopen("E:/codes/testcases/output.in", "w", stdout);
    #endif
    long long int a,b,x,n,m,k,sum=0,ans=0,res=0;
    cin >> n;
    int arr[n];
            loop(i,0,n)
            {
                cin>>arr[i];
            }
     constructXOR(arr,n);
for (int i = 0; i < n; ++i)
    {
    	/* code */
    	cout<<arr[i]<<" ";
    }    //       printvector(arr);
    //        sort(arr.begin(),arr.end());
    

    return 0;
}


Measured memory_bytes: 4364
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =9223372036854775807;//64bit 9*1e+17
const long MOD =1e+9+7;
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
  string S,T;
  cin>>S>>T;
 
  RREP(i,S.length()-T.length()+1){
    REP(j,(int)T.length()+1){
      if(j==T.length()){
	REP(r,S.length()){
	  if(r==i){
	    cout<<T;
	    r+=(T.length()-1);
	  }else if(S[r]=='?'){
	    cout<<'a';
	  }else{
	    cout<<S[r];
	  }
	}
	return 0;
      }else if(S[i+j]!=T[j]&&S[i+j]!='?'){
	break;
      }
    }
  } 
  print("UNRESTORABLE");
  return 0;
}

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

int main() {
    

    
    int N,A,B;
    cin>>N>>A>>B;
    string S;
    cin>>S;
    int count_a=0,count_b=0;
    for(int i=0;i<N;i++){
        if(S.at(i)=='a'){
            if(count_a+count_b<A+B){
                cout<<"Yes"<<endl;
                count_a++;
            }
            else cout<<"No"<<endl;
        }
        else if(S.at(i)=='b'){
            if(count_a+count_b<A+B&&count_b<B){
                cout<<"Yes"<<endl;
                count_b++;
            }
            else cout<<"No"<<endl;
            
            }
        else cout<<"No"<<endl;
        
            }
}


Measured memory_bytes: 896
#include <iostream>
#include <stdio.h>
#include<math.h>
#include<string.h>
using namespace std;

int main()
{
    long long A,B;
    cin>>A>>B;
    if((A+B)%2==1)
        cout<<"IMPOSSIBLE"<<endl;
    else
    {
        cout<<(A+B)/2<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int Judge(int x, int k, vector<int> d) {
	int i, sum = 0, a = 0;
	rep(i, d.size()) {
		d[i] %= x;
		sum += d[i];
	}
	sort(d.begin(), d.end(), greater<int>());
	rep(i, sum / x) {
		a += x - d[i];
	}
	return a <= k;
}

int main(void) {
	int num, i, k, sum = 0, ans;
	priority_queue<int> que;
	cin >> num >> k;
	vector<int> d(num);
	rep(i, num) {
		cin >> d[i];
		sum += d[i];
	}
	for (i = 1; i * i <= sum; i++) {
		if (sum % i == 0) {
			que.push(i);
			que.push(sum / i);
		}
	}
	while (!que.empty()) {
		ans = que.top();
		que.pop();
		if (Judge(ans, k, d))
			break;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3632
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

void main() {
    int n, k;
    readf("%s %s", &n, &k);
    readln;
    int[] p = readln.split.map!(to!int).array;
    p.sort;
    int ans = 0;
    foreach(i; 0..k)
        ans += p[i];
    ans.writeln;
}



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

using namespace std;

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

int main() {
	int x;
	while (cin >> x, x) {
		int ans = INF;
		REP(i, 5000/200 + 1) REP(j, 5000/300 + 1) REP(k, 5000/500 + 1) if (i*200+j*300+k*500 == x) {
			int tmp = int(i / 5 * (380 * 0.8) * 5 + i % 5 * 380
					+ j / 4 * (550 * 0.85) * 4 + j % 4 * 550
					+ k / 3 * (850 * 0.88) * 3 + k % 3 * 850);
			if (tmp == 0) continue;
			ans = min(ans, tmp);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <list>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
#include <cstdlib>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

#define xx first
#define yy second
#define $1 first
#define $2 second

void solveCase() {
	//ios::sync_with_stdio(false);
	//cin.tie(NULL); cout.tie(NULL);
	ll l; cin >> l;
	printf("%lf",pow((double)l / 3, 3));
}

int main() {

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	solveCase();
}

Measured memory_bytes: 512
a, b, n = gets.chomp.split(" ").map(&:to_i)
puts b > n ? ((a * n).to_f / b).to_i - a * (n.to_f / b).to_i : ((a * (b - 1)).to_f / b).to_i - a * ((b - 1).to_f / b).to_i

Measured memory_bytes: 14392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(int I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

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

	ll A,B,N;
	cin >> N >> A >> B;
	cout << min(A,B) << " " << max(0ll,A+B-N) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	ll l;cin>>l;
	double ans = double(pow(l,3))/double(27);
	cout<<fixed<<setprecision(10)<<ans<<endl;
	
} 

Measured memory_bytes: 640
num = int(input())

n_loop, reminder = divmod(num, 15)
total = 0
i = -1
for i in range(n_loop):
	total += i *15 *  8 + sum([1, 2, 4, 7, 8, 11, 13, 14])
remaining_nums = [num for num in range(1, reminder+1) if num % 3 and num % 5]
total += sum(remaining_nums) + (i + 1) * 15 * len(remaining_nums)

print(total)

Measured memory_bytes: 9200
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n,m,x,y;
  cin >> n >> m >> x >> y;
  vi xx(n),yy(m);
  rep(i,n) cin >> xx[i];
  rep(i,m) cin >> yy[i];

  vsort(xx);
  vsort(yy);

  bool b = false;
  for(int i = max(x,xx[sz(xx) - 1]); i <= min(yy[0],y);i++)
  {
    if(( x < i && i <= y)
      &&(xx[sz(xx) - 1] < i && i <= *yy.begin()))
    {
      b = true;
      break;
    }
  }

  if(!b) cout << "War" << endl;
  else cout << "No War" << endl;


  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


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

int main() {
  vector<long long int> v;
  int a, b, c;
  cin >> a >> b >> c;
  v.push_back(a);
  v.push_back(b);
  v.push_back(c);
  sort(v.begin(), v.end());
  if (v[0]%2 == 0 || v[1]%2 == 0 || v[2]%2 == 0) {
    cout << 0 << endl;
  }
  else {
    cout << v[0]*v[1] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
def can_win_without_repeated_move(health, special_moves_damages) -> str:
    """
    Given a monster's health and a number of special moves with differ damages,
    can we deplete the monster's health without repeating the same move twice?
    :param health: int
    :param special_moves_damages: list[int]
    :return: str
    """
    return 'Yes' if health <= sum(special_moves_damages) else 'No'


if __name__ == '__main__':
    print(can_win_without_repeated_move(list(map(int, input().split()))[0], list(map(int, input().split()))))


Measured memory_bytes: 13964
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T& a, T b) { if (a < b)a = b; }
template<class T>void chmin(T& a, T b) { if (a > b)a = b; }
constexpr int INF = 1000000000000000000;
constexpr int mod = 1000000007;
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
int kaijo[2000010];
int gcd(int a, int b) {
    if (b == 0)return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}
bool prime(int a) {
    if (a == 1)return false;
    for (int i = 2; i * i <= a; i++) {
        if (a % i == 0)return false;
    }
    return true;
}
void init_fact() {
    kaijo[0] = 1;
    for (int i = 1; i <= 2000000; i++) {
        kaijo[i] = kaijo[i - 1] * i;
        kaijo[i] %= mod;
    }
}
int modpow(int a, int b) {
    if (b == 0)return 1;
    if (b % 2)return modpow(a, b - 1) * a % mod;
    int memo = modpow(a, b / 2);
    return memo * memo % mod;
}
int comb(int a, int b) {
    if (!kaijo[0])init_fact();
    return kaijo[a] * modpow(kaijo[a - b], mod - 2) % mod * modpow(kaijo[b], mod - 2) % mod;
}
int inv(int x) {
    x = modpow(x, mod - 2);
    return x;
}
bool kosa(double ax, double ay, double bx, double by, double cx, double cy, double dx, double dy) {
    double ta = (cx - dx) * (ay - cy) + (cy - dy) * (cx - ax);
    double tb = (cx - dx) * (by - cy) + (cy - dy) * (cx - bx);
    double tc = (ax - bx) * (cy - ay) + (ay - by) * (ax - cx);
    double td = (ax - bx) * (dy - ay) + (ay - by) * (ax - dx);
    return tc * td < 0 && ta * tb < 0;
}
int n;
vector<int>v[100010];
int dp[100010][2];
bool used[100010];
void dfs(int x) {
    used[x] = true;
    dp[x][0] = dp[x][1] = 1;
    for (int i : v[x]) {
        if (!used[i]) {
            dfs(i);
            dp[x][0] *= (dp[i][0] + dp[i][1]);
            dp[x][0] %= mod;
            dp[x][1] *= (dp[i][0]);
            dp[x][1] %= mod;
        }
    }
}
signed main() {
    cin >> n;
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        v[a].pb(b);
        v[b].pb(a);
    }
    dfs(0);
    cout << (dp[0][0] + dp[0][1]) % mod << endl;
    return 0;
}


Measured memory_bytes: 11648
import math

while 1:
    n = int(raw_input())

    if n == 0:
        break

    nums = map(float, raw_input().split(" "))

    m = sum(nums) / float(n)
    std = 0

    for i in range(n):
        std += (nums[i] - m) ** 2

    print(math.sqrt(std / float(n)))

Measured memory_bytes: 6588
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main()
{
   int N,C;
   cin >> N >> C;
   vector<vector<ll>>D(C,vector<ll>(C));
   rep(i,C)rep(j,C)cin >> D[i][j];
   vector<vector<ll>>cos(3,vector<ll>(C,0));
   rep(i,N)rep(j,N){
       int c;cin >> c;c--;
       rep(k,C){
           cos[(i+j)%3][k]+=D[c][k];
       }
   }
   ll ans=(ll)(1e15);
   rep(i,C)rep(j,C)rep(k,C){
       if(i==j||j==k||k==i){continue;}
       ans=min(ans,cos[0][i]+cos[1][j]+cos[2][k]);
   }
   printf("%d\n",ans);
   return 0;
}

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 100010;
const double eps = 1e-6;

int n;
int a[N];

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;
        a[x - 1]++, a[x]++, a[x + 1]++;
    }

    int res = 0;
    for(int i = 0; i < N; i++)
        res = max(res, a[i]);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }




void solve(void)
{
  int N;
  cin>>N;
  cout<<N*(N-1)/2<<endl;
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
int main(){
    CIN(N);
    vector<P> hoge;
    for(int a = 0;a < N;a++){
        CIN(s);CIN(b);
        hoge.pb(make_pair(s,b));
    }
    P p = *max_element(ALL(hoge));
    COUT(p.first + p.second);
    return 0;
}


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

public class Main {
    public static void main(String args[]) throws IOException {

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	char s[] = br.readLine().toCharArray();
	char t[] = br.readLine().toCharArray();

	int err = 0;

	for (int i = 0; i < s.length; i++) {
	    if (s[i] != t[i]) {
		err++;
	    }
	}

	System.out.println(err);
    }

}

Measured memory_bytes: 37276
# ABC125D - Flipping Signs
def main():
    # neg % 2 == 0 -> all negatives disappear
    # 0 in A -> move all neg there
    # else -> move all neg to the smallest one (abs(i))
    N = int(input())
    A = tuple(map(int, input().split()))
    mi = min(abs(i) for i in A)
    abs_sum = sum(abs(i) for i in A)
    neg = sum(i < 0 for i in A)
    if 0 in A or neg % 2 == 0:
        print(abs_sum)
    else:
        print(abs_sum - mi * 2)


if __name__ == "__main__":
    main()

Measured memory_bytes: 14412
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
long long dp[10010];
  
int main()
{
  int K,T;
  cin >> K >> T;
  vector<int> A(T);
  REP(i, T) cin >> A[i];
  
  sort(ALL(A));
  int sum = 0;
  REP(i,T-1){
    sum+=A[i];
  }
  cout << max(0,A[T-1]-1-sum) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define mp make_pair 
#define f(i,n) for(int i=0;i<n;i++) 
#define F first 
#define S second 
#define pb push_back 

using namespace std;

ll a[300003],b[300003];
void test(){
	ll h,w,m;
	cin>>h>>w>>m;
	set<int> st[h+1];
	f(i,m){
		ll x,y;
		cin>>x>>y;
		st[x].insert(y);
		a[x]++;
		b[y]++;
	}
	
	set<int> x,y;
	ll mx = 0, my = 0;
	f(i,300003)mx = max(mx,a[i]), my = max(my,b[i]);
	
	f(i,300003){
		if(a[i]==mx)x.insert(i);
		if(b[i]==my)y.insert(i);
	}
	
	bool flag = false;
	for(auto i : x){
		for(auto j : y){
			if(st[i].find(j)==st[i].end()){
				flag = true;
				break;
			}
		}
		if(flag)break;
	}
	if(flag)cout<<mx+my<<"\n";
	else cout<<mx + my - 1<<"\n";
}

int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	// cin>>tests;
	while(tests--){
		test();
	}
}


Measured memory_bytes: 64528
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

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

    if (n % k == 0) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }


    return 0;
}


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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
    int n,d;
	cin >> n>>d;
    int x[10][10];
    fori(n){
        forj(d)
        cin>>x[i][j];
    }
    int counter=0;
    fori(n){
        for(int j=i+1;j<n;++j){
            int dis=0;
            for(int k=0;k<d;++k){
                dis+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            if(sqrt(dis)==(int)(sqrt(dis))){
                ++counter;
            }
        }
    }
    cout<<counter;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long

using namespace std;

int Mod = 1e9+7;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n; cin >> n;
	int sum_ = 0;
	vector<int> v(n);	
	vector<int> pref(n+1);

	for(int i = 0 ; i < n; i++){
		int t; cin >> t;
		v[i] = t; sum_ += t;
		pref[i+1] = pref[i] + t;
	}

	int ans = 0;

	for(int i = 0 ; i < n - 1; i++){
		ans += ((v[i] % Mod) * ((sum_  - pref[i + 1])%Mod))%Mod;
		ans %= Mod;
	}

	cout << ans;


  return 0;
}


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

int main() {
  string S;
  cin >> S;
  int L = S.size();
  int ans=0;
  for (int i=0;i <= (S.size() - 1) / 2;i++) {
    if (S.at(i) != S.at(L-1-i)){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int a[] = new int[N];
    int answer = 0;
    int tmpNumber=1;
    boolean isMinusOne = true;
    for(int i=0;i<N;i++){
      a[i]=sc.nextInt();
      if(a[i]==1){
        isMinusOne=false;
      }
    }
    if(isMinusOne){
      System.out.println(-1);
      return;
    }
    
    
    for(int i=0;i<N;i++){
      if(a[i]!=tmpNumber){
        answer=answer+1;
      }else{
        tmpNumber=tmpNumber+1;
      }
    }
    System.out.println(answer);
        
    
  }
  

  
}

Measured memory_bytes: 77340
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
void trace(int n, int arr[]){for(int i = 0; i < n; i++){cout << arr[i] << " ";} cout << endl << endl;}
const int N = 1e5 + 5;
ll n, height[N], k, dp[N];
ll solve(int idx){
    if(idx >= n)
        return 2e9;
    else if(idx == n - 1)
        return 0;
    if(dp[idx] != -1)
        return dp[idx];
    ll mn = 2e9;
    for(int i = 1; i <= k; i++){
        if(idx + i >= n)
            break;
        mn = min(mn, solve(idx + i) + abs(height[idx] - height[idx + i]));
    }
    dp[idx] = mn;
    return mn;
}
int main()
{
    Hello
    memset(dp, -1, sizeof dp);
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> height[i];
    cout << solve(0);
    return 0;
}

Measured memory_bytes: 12940
local n, m = io.read("*n", "*n")
local h = {}
local t = {}
for i = 1, n do
  h[i] = io.read("*n")
  t[i] = true
end
for i = 1, m do
  local a, b = io.read("*n", "*n")
  if h[a] < h[b] then
    t[a] = false
  elseif h[b] < h[a] then
    t[b] = false
  else
    t[a] = false
    t[b] = false
  end
end
c = 0
for i = 1, n do
  if t[i] then c = c + 1 end
end
print(c)


Measured memory_bytes: 4852
from math import gcd

N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7

lcm = 1
for a in A:
    lcm = lcm * a // gcd(lcm, a)


ans = 0
for a in A:
    ans += lcm // a


print(ans % MOD)

Measured memory_bytes: 70272
#include <bits/stdc++.h>
#include <unistd.h>
#include <random>
using namespace std;
 
typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;
 
int main() {
	// random_device rnd;
	// mt19937 mt(rnd());
    cin.tie(0);
    ios::sync_with_stdio(false);
	string s;
	cin >> s;
	if(s.size() < 7){
		cout << "NO" << endl;
		ED
	}
	if(s.substr(0,7) == "keyence" || s.substr(s.size()-7,7) == "keyence"){
		cout << "YES" << endl;
		ED
	}
	int check = 0;
	if(s[0] == 'k'){
		check++;
		if(s[1] == 'e'){
			check++;
			if(s[2] == 'y'){
			check++;
				if(s[3] == 'e'){
				check++;
					if(s[4] == 'n'){
					check++;
						if(s[5] == 'c'){
						check++;
							if(s[6] == 'e'){
							check++;
							}
						}
					}
				}
			}
		}
	}
	int z = s.size();
	if(s[z-1] == 'e'){
		check++;
		if(s[z-2] == 'c'){
			check++;
			if(s[z-3] == 'n'){
			check++;
				if(s[z-4] == 'e'){
				check++;
					if(s[z-5] == 'y'){
					check++;
						if(s[z-6] == 'e'){
						check++;
							if(s[z-7] == 'k'){
							check++;
							}
						}
					}
				}
			}
		}
	}
	if(check > 6){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
}

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





int main() {
	int N, A, B;
	cin >> N >> A >> B;
	string an = "Alice";
	if ((B - A) % 2 != 0) {
		an = "Borys";
	}
	


	cout << an << endl;


}


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

using namespace std;
#define set_precision(ans,l) cout << fixed << setprecision(l)<<ans;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repb(i, a, b) for (int i = a; i >= b; i--)
#define vi vector<int>
#define vl vector<long long int>
#define Vi vector<vector<int>>
#define vpi vector<pair<int,int>>
#define seti set<int>
#define setl set<ll>
#define dseti set<int, greater<int>>
#define dsetl set<ll, greater<ll>>
#define mseti multiset<int>
#define msetl multiset<ll>
#define dmseti multiset<int, greater<int>>
#define dmsetl multiset<ll, greater<ll>>
#define sortA(arr) sort(arr.begin(), arr.end())
#define dsortA(arr) sort(arr.begin(), arr.end(), greater<ll>())
#define ssort(arr) stable_sort(arr.begin(), arr.end())
#define nth(v,n) nth_element(v.begin,v.begin+n-1,v.end())
#define dnth(v,n) nth_element(v.begin,v.begin+n-1,v.end(), greater<ll>())
#define init(a)  memset((a),0,sizeof(a))
#define pi pair<int,int>
#define pb push_back
#define pl pair<ll,ll>
#define ll long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
long double EPS = 1e-9;

/*struct comp {
  bool operator() (const int& lhs, const int& rhs) const
  {return lhs<rhs;}
};*/

ll cel(ll a,ll b){return((a-1)/b+1);} 
ll gcd(ll a, ll b){
    if (a < b)swap(a, b);
    return (b == 0)? a: gcd(b, a % b);
}
ll MIN(ll a,int b){ll ans;(a>=b)?ans=b:ans=a;return ans;}
ll MAX(ll a,int b){ll ans;(a>=b)?ans=a:ans=b;return ans;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll po(ll x,ll y){
    ll ans=1;
    while(y){
        if(y&1){ans=(ans*x)%mod;}
        y>>=1;x=(x*x)%mod;
    }
    return ans;
}

int main()
{
    FIO;
    ll n,t,x,y,m,k;
    cin>>x;
    x?cout<<0:cout<<1;
    
    return 0;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
typedef long long int Int;
int main() {
	int N;
	Int ans=1;
	scanf("%d",&N);
	for(int i=1;i<=N;i++) {
		ans=(ans*i)%1000000007;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long X, Y;
    scan(X, Y);
    writeln(X % Y == 0 ? -1 : X);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
// #define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pi pair<int,int>
#define pii pair< int, pi >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
using namespace std::chrono;

string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
vector<vector<int>> vis;
int h,w,ch,cw,dh,dw;
int X[]={1,0,0,-1};
int Y[]={0,1,-1,0};
bool safe(int x,int y){
  return x>=0 && x<h && y>=0 && y<w;
}
void solve(){
  // auto start = high_resolution_clock::now();
  cin>>h>>w;
  cin>>ch>>cw;
  cin>>dh>>dw;
  ch--,cw--,dh--,dw--;
  char a[h][w];
  rep(i,0,h) {string s;cin>>s;rep(j,0,w) a[i][j]=s[j];}
  vis=vector<vector<int>> (h,vector<int>(w,0));
  // dfs(ch,cw);
  priority_queue<pii,vector<pii>,greater<pii>> pq;
  vector<vector<int>> dp(h,vector<int>(w,INT_MAX));
  pq.push({0,{ch,cw}});
  while(!pq.empty()){
    pii x=pq.top();
    pq.pop();
    if(x.s.f==dh && x.s.s==dw){
      cout<<x.f<<endl;
      return;
    }
    rep(i,0,4){
      int x1=X[i]+x.s.f,y1=Y[i]+x.s.s;

      if(safe(x1,y1) && dp[x1][y1]> x.f && a[x1][y1]=='.'){
        dp[x1][y1]=x.f;
        pq.push({x.f,{x1,y1}});
      }
    }

      rep(i,-2,3){
        rep(j,-2,3){
          if(safe(x.s.f+i,x.s.s+j) && !(i==0 && j==0) && dp[x.s.f+i][x.s.s+j]>x.f+1 && a[x.s.f+i][x.s.s+j]=='.'){
            dp[x.s.f+i][x.s.s+j]=x.f+1;
            pq.push({x.f+1,{x.s.f+i,x.s.s+j}});
          }
        }
      }
  }
  cout<<-1<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 12432
#include <iostream>

using namespace std;

long long g(long long a) {
	switch (a % 4)
	{
	case 0:
		return a * 1LL;
	case 1:
		return 1LL;
	case 2:
		return a * 1LL + 1LL;
	case 3:
		return 0LL;
	default:
		break;
	}
}

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

	long long a, b;
	cin >> a >> b;
	long long ans = 0;
	cout << (g(b) ^ g(a - 1)) << '\n';

	return 0;
}


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

using namespace std;

#define INF 1000
#define MOD 1000000007
#define maxn 1e5
#define PI 3.141592653589793
#define int long long int
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}
signed main()
{
    int N;
    cin >> N;
    int max1, max2 = 0;
    int j = 0;
    for (int i = 1; i <= N; i++)
    {
        max1 = ((i + 1) * i) / 2;
        j = i + 1;
        max2 = ((j + 1) * j) / 2;
        if ((max1 < N) && (max2 >= N))
        {
            break;
        }
    }
    max2 -= N;
    for (int i = 1; i <= j; i++)
    {
        if (i == max2)
        {
            continue;
        }
        cout << i << endl;
    }
}

Measured memory_bytes: 256
s=input()
n=int(input())
a,b=[],[]
p=0
for i in range(n):
    l=input().split()
    if len(l)==1:
        p+=1
    else:
        k=int(l[1])
        if k%2==p%2:
            b+=[l[2]]
        else:
            a+=[l[2]]
if p%2==1:
    s=s[::-1]
    a,b=b,a
print(("".join(a)[::-1])+s+"".join(b))

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	int ans=0;
	for(int i=0;i<n;++i){
		int a; cin>>a;
		bool yes=true;
		for(int j=2;j*j<=a;++j){
			if(a%j==0)yes=false;
		}
		if(yes)++ans;
	}
	cout<<ans<<"\n"s;
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

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

    vector<string> s(N);
    REP(i, N) cin >> s[i];

    auto g = make_vec<int>(N, N);
    REP(i, N) REP(j, N) {
        g[i][j] = (int)(s[i][j] - '0');
        if(g[i][j] == 0 && i != j) g[i][j] = inf;
    }


    vector<int> bg(N, -1);
    bg[0] = 0;
    bool chk = true;
    REP(k, N) REP(i, N) {
        if(bg[i] == -1) continue;
        REP(j, N){
            if(g[i][j] == 1){
                if(bg[j] == -1) bg[j] = 1 - bg[i];
                else chk &= (bg[j] == 1 - bg[i]);
            }
        }
    }
    
    int ans = -1;
    if(chk){
        REP(k, N) REP(i, N) REP(j, N) chmin(g[i][j], g[i][k] + g[k][j]);
        REP(i, N) REP(j, N) chmax(ans, g[i][j] + 1);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<math.h>
int main(){
	int N, M, i, l;
	if(scanf("%d%d", &N, &M));
	l=sqrt(M);
	for(i=N; i<=l; i++){
		if(M%i==0){
			printf("%d\n", M/i);
			return 0;
		}
	}
	for(i=(l<M/N?l:M/N);; i--){
		if(M%i==0){
			printf("%d\n", i);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<stdbool.h>
typedef long long ll;
using namespace std;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if (A >= B) {
		if (C >= D)cout << B + D << endl;
		else cout << B + C << endl;
	}
	else {
		if (C >= D)cout << A + D << endl;
		else cout << A + C << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  ll k,a,b;
  cin>>k>>a>>b;

  if(a+2>=b) {
    cout << k+1 << endl;
    return 0;
  }

  if(k<=a) {
    cout << k+1 << endl;
  }
  else  if((k-a-1)%2==0){
    cout << b+(b-a)*(k-a-1)/2 << endl;
  }
  else {
    cout << b+(b-a)*((k-a-1)/2)+1 << endl;
  }


}

Measured memory_bytes: 256
from collections import defaultdict

N = int(input())

def getPrimes(N):
    R = N + 10
    isPrime = [True] * (R + 2)
    primes = set()

    for p in range(2, R):
        if not isPrime[p]:
            continue
        primes.add(p)
        for q in range(p * 2, R, p):
            isPrime[q] = False

    return primes

primes = getPrimes(N)

def getFactors(N):
    facts = defaultdict(int)
    for p in primes:
        while N % p == 0:
            facts[p] += 1
            N //= p
    return facts

fracFacts = defaultdict(int)
for i in range(1, N + 1):
    for p, c in getFactors(i).items():
        fracFacts[p] += c

cnt = {
    2 : 0,
    4 : 0,
    14 : 0,
    24 : 0,
    74 : 0,
}

for c in fracFacts.values():
    for k in cnt.keys():
        if c >= k:
            cnt[k] += 1

ans = 0
ans += cnt[4] * (cnt[4] - 1) * (cnt[2] - 2) // 2
ans += cnt[14] * (cnt[4] - 1)
ans += cnt[24] * (cnt[2] - 1)
ans += cnt[74]
print(ans)

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

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

  if (s[0] == s[1] && s[1] == s[2]) {
    std::cout << "Yes" << std::endl;
  } else if (s[1] == s[2] && s[2] == s[3]) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main(){
    char str[1200];
    scanf("%[^\n]", str);
    for(int i = 0; str[i] != '\0'; i++){
        if ('a' <= str[i] && str[i] <= 'z'){
            str[i] += ('A' - 'a');
        }else if('A' <= str[i] && str[i] <= 'Z'){
            str[i] += ('a' - 'A');
        }
    }
    printf("%s\n", str);
    return 0;
}



Measured memory_bytes: 2568
#include<cstdio>
long long n,m,k;
signed main()
{
	return scanf("%lld%lld%lld",&n,&m,&k),m>=n?puts("1"):(k>=m?puts("-1"):printf("%lld\n",((n-m)/(m-k)+((n-m)%(m-k)>=1))<<1|1)),0;
}

Measured memory_bytes: 128