akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8

LL powmod(LL x, LL y){
	LL a = 1;
	while(y){
		if(y & 1){ a = a * x % MOD; }
		x = x * x % MOD;
		y >>= 1;
	}
	return a;
}

int n;
VV(int) G;
LL tot;
vector<LL> p2;

int dfs(int u, int p){
	int ret = 1;
	vector<int> csz;
	for(int v : G[u]){
		if(v == p){ continue; }
		int s = dfs(v, u);
		csz.push_back(s);
		ret += s;
	}

	if(p != -1){ csz.push_back(n - ret); }
	if(csz.size() > 1){
		LL sum = 1;
		for(LL x : csz){
			sum += p2[x] - 1;
		}
		tot += p2[n - 1] - sum;
		tot %= MOD;
	}

	return ret;
}

void mainmain(){
	scanf("%d", &n);
	p2.resize(n + 4);
	p2[0] = 1;
	for(int i = 1; i < n + 4; ++i){
		p2[i] = p2[i - 1] * 2 % MOD;
	}

	G.resize(n);
	for(int i = 1; i < n; ++i){
		int a, b;
		scanf("%d%d", &a, &b);
		--a;
		--b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	dfs(0, -1);

	tot = (tot % MOD + MOD) % MOD;
	LL ans = tot * powmod(p2[n], MOD - 2) % MOD;
	printf("%lld\n", ans);
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){
	throw;
}


Measured memory_bytes: 26368
from sys import stdin
from itertools import accumulate
input = stdin.readline

n = int(input())
a = list(map(int,input().split()))
p = [0] + list(accumulate(a))
res = 0
for i in range(n-1,-1,-1):
    res += (a[i] * p[i])%(10**9 + 7)
print(res % (10**9 + 7))

Measured memory_bytes: 108728
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char* add(const char* a, const char* b)
{
    int sizeA, sizeB, sizeX;
    int A, B, C;
    char* x;
    char* t;
    int la, lb, lx;
    C = 0;
    sizeA = strlen(a);
    sizeB = strlen(b);
    sizeX = (sizeA > sizeB ? sizeA : sizeB)+1;
    x = (char*)calloc(sizeX, 1);
    la = sizeA - 1;
    lb = sizeB - 1;
    lx = sizeX - 1;
    
    while(lx >= 0){
        A = la >= 0 ? a[la] - '0' : 0;
        B = lb >= 0 ? b[lb] - '0' : 0;
        x[lx] = '0' + (A + B + C) % 10;
        C = (A + B + C) / 10;
        la--;
        lb--;
        lx--;
    }
    if (*x == '0'){
        t = (char*)calloc(sizeX - 1, 1);
        strcpy(t, x + 1);
        free(x);
        return t;
    }
    return x;
}
int main()
{
    int i;
    int N;
    char first[201];
    char second[201];
    char* result;
    scanf("%d", &N);
    for(i = 0; i < N; ++i){
        scanf("%s", first);
        scanf("%s", second);
        if(strlen(first) > 80
        || strlen(second) > 80){
            printf("overflow\n");
            continue;
        }
        result = add(first, second);
        if(strlen(result) <= 80){
            printf("%s\n", result);
        }else{
            printf("overflow\n");
        }
        free(result);
    }
    return 0;
}

Measured memory_bytes: 1748
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef long double ld;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll exp(ll x,ll y){if(y==0) return 1;if(y%2 == 1) return x*exp(x,y/2)*exp(x,y/2);return exp(x,y/2) * exp(x,y/2);}
ll exp(ll x,ll y,ll modd) {if(y==0) return 1;ll t=exp(x,y/2,modd);t = t%modd;t=t*t;t=t%modd;if(y % 2 == 1) return (x*t)%modd ;return t%modd;}
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC target ("sse4")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define emp empty()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0ll, so x)
#define all(x) (x).be , (x).en
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define revn(i,a,b) for(ll i=a;i>=b;--i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vs vector<string>
#define vsi vector<pair<string,int>>
#define vll vector<pair<ll,ll> >
#define vlll vector<pair<ll,pair<ll,ll>>>
#define vlvl vector<pair<pair<ll,ll>,ll>>>
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

vector<int> a;
int n;

ll dp[111000];

int solve(int k)
{
	if(dp[k]!=-1) return dp[k];
	if(k==0) return dp[k]=0;
	
	int ans = 0;
	for(int i=0;i<n;i++)
	{
		if(k<a[i])continue;
		if(solve(k-a[i])==0)
		{
			ans=1;
			break;
		}
	}
	return dp[k]=ans;
}


int main()
{
    ios;
    int k;
	cin>>n>>k;
    memset(dp, -1, sizeof(dp));
	a.resize(n);
	
	for(int i=0;i<n;i++)
		cin>>a[i];
	
	if(solve(k))
		cout<<"First\n";
	else
		cout<<"Second\n";
	
	return 0;
}

Measured memory_bytes: 4224
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

long long int w[107];
long long int v[107];
long long int dp[107][100007];
int main()
{
    int N,W;
    scanf("%d %d\n",&N,&W);
    for(int i=0; i<N; i++)
    {
        scanf("%lld %lld\n",&w[i],&v[i]);
    }

    if(w[0]<=W){ dp[0][w[0]]=v[0]; }
    for(int i=1;i<N;i++)
    {
        for(int k=0;k<=W;k++)
        {
            if(k+w[i]<=W)
            {
                dp[i][k+w[i]]=max(dp[i-1][k]+v[i], dp[i][k+w[i]]);
            }
            dp[i][k]=max(dp[i-1][k], dp[i][k]);
        }
    }

    long long int res=0;
    for(int k=0;k<=W;k++){ res=max(dp[N-1][k],res); }
    printf("%lld\n",res);
    //printf("%lld\n",dp[N-1][W]);
    return 0;
}

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



int main() {
    int n,k;
    cin>>n>>k;
    cout << (n%k==0? 0:1) <<endl;
}

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

int main(void){
    string a,b; cin >> a >> b;
    for(int i=0; i<3; i++){
        if(a[i]!=b[2-i]){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
}

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

#define ll long long
#define SZ(x) ((int) (x).size())
#define mk make_pair
#define pb push_back
#define debug(x) cerr << #x << " : " << x << endl;

using namespace std;

int main() {
       ios::sync_with_stdio(false); 
       cin.tie(0);
       ll x;
       cin >> x;
       ll cur = 100;
       ll ans = 0;
       while (cur < x) {
         ll res = cur / 100;
         cur += res;
         ++ans;
         //debug(cur);
       }
       cout << ans << '\n';
       return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
  
// #define int long long
#define pb push_back
#define print(Target) cout << Target << '\n'

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}

signed main()
{
  ios::sync_with_stdio(false);
  int v, n, sum = 0;
  double num = 0;
  char c;
  int i;
  for (i = 0; cin >> v >> c >> n; i++){
    sum += v * n;
    num += n;
  }
  print(sum);
  print(round(num / i));

  return (0);
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
const int MAXN = 1000005;
const ll MOD = 1e9 + 7;
ll fac[MAXN], add[MAXN];
int main() {
	fac[0] = 1;
	for (int i = 1; i < MAXN; ++i)
		fac[i] = fac[i - 1] * i % MOD;
	int n, h, d;
	scanf("%d%d%d", &n, &h, &d);
	ll mult = 0;
	for (int i = 1; i <= n; ++i) mult += fac[i];
	mult %= MOD;
	for (int i = 0; i <= h; ++i) {
		if (i) add[i] += add[i - 1];
		add[i] %= MOD;
		ll dp = i == 0 ? fac[n] : add[i] * mult % MOD;
		if (i + 1 <= h) {
			add[i + 1] += dp;
			add[i + 1] %= MOD;
		}
		if (i + d + 1 <= h) {
			add[i + d + 1] -= dp;
			add[i + d + 1] %= MOD;
		}
	}
	if (add[h] < 0) add[h] += MOD;
	printf("%lld\n", add[h]);
}


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

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    ll negs = 0;
    rep(i, N) if (A[i] < 0) negs++;
    ll ans = 0;
    rep(i, N) ans += abs(A[i]);
    if (negs % 2 == 1) {
        ll mn = 1e10;
        rep(i, N) mn = min(mn, abs(A[i]));
        ans -= 2 * mn;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const ll INF = 1001001001;
const ll MOD = 1e9 + 7;

//x * y = m (y >= n)となる最大のxが求める答え
int main(){
  int n, m;
  cin >> n >> m;
  if(m == 1){
    cout << 1 << endl;
    return 0;
  }
  vector<int> vec;
  for(int i = 1; i * i < m; i++){
    if(m % i == 0){
      if(m/i>=n) vec.push_back(i);
      if(i >= n) vec.push_back(m/i);
    }
  }
  sort(all(vec)); reverse(all(vec));
  cout << vec[0] <<endl;
}
    

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,x,y;
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	int ans=0;
	if(2*c>=(a+b)) ans=a*x+b*y;
	else
	{
		if(x<y) swap(a,b),swap(x,y);
		ans=y*c*2;
		ans+=(x-y)*min(a,2*c);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main()
{
  int i=0,j=0,s_max=0,t_max=0;
  int s_baketu[26]={0};
  int t_baketu[26]={0};
  char s[200]={0},t[200]={0};
/*
  for(i=0;i<100;i++)printf("%d ",s[i]);
  printf("\n");
  for(i=0;i<100;i++)printf("%d ",t[i]);
  printf("\n");
*/  
  scanf("%s",s);
  scanf("%s",t);
/*  
  for(i=0;i<100;i++)printf("%d ",s[i]);
  printf("\n");
  for(i=0;i<100;i++)printf("%d ",t[i]);
  printf("\n");
*/
  for(i=0;i<200;i++){
    if(s[i]!=0)s_baketu[s[i]-97]++;
  } 
  for(i=0;i<26;i++){
    while(s_baketu[i]>0){
      s[s_max]=i;
      s_baketu[i]--;
      s_max++;
    }      
  }
  
  for(i=0;i<200;i++){
    if(t[i]!=0)t_baketu[t[i]-97]++;
  }
    for(i=25;i>=0;i--){
    while(t_baketu[i]>0){
      t[t_max]=i;
      t_baketu[i]--;
      t_max++;
    }      
  }
/*  
  for(i=0;i<26;i++)printf("%d ",s[i]);
  printf("\n");
  for(i=0;i<26;i++)printf("%d ",t[i]);
  printf("\n");
*/ 
  for(i=0;i<200&&j==0;i++){
    if(s[i]<t[i])j=1;
    if(s[i]>t[i]&&j==0){
     printf("No");
     return 0;
   }
  }
  if (j==1)printf("Yes");
  else if(j==0)printf("No");
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>

using namespace std;

int main(){

	int n,kakeru;
	cin >> n;
	if( n%2 == 0){
		kakeru = n;
	}
	else{
		kakeru = n*2;
	}
	cout << kakeru <<endl;


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define N 200020
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
int n,m,p[N],b[N],tot,ans[N],an,vis[N];
int cnt,head[N];
bool ok;
struct Bomb{
	int pos,st;
}a[N];
bool cmp(Bomb x,Bomb y){
	return x.pos<y.pos;
}
struct Edge{
	int to,nxt,id;
}edge[N<<1];
void add(int a,int b,int c){
	cnt++;
	edge[cnt].to=b;
	edge[cnt].id=c;
	edge[cnt].nxt=head[a];
	head[a]=cnt;
}
int dfs(int u,int fa,int id){
	vis[u]=1;
	int tmp=0;
	for(int i=head[u];i;i=edge[i].nxt){
		int v=edge[i].to;
		if(vis[v])continue;
		tmp^=dfs(v,u,edge[i].id);
	}
	if(!fa)return tmp;
	if(tmp^b[u]){
		ans[++an]=id;
		return 1;
	}
	return 0;
}
int main(){
	n=read(),m=read();
	for(int i=1;i<=n;i++){
		a[i].pos=read(),a[i].st=read();
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++){
		p[i]=a[i].pos,b[i]=a[i].st^a[i-1].st;
	}
	for(int i=1;i<=m;i++){
		int l=read(),r=read();
		l=lower_bound(p+1,p+n+1,l)-p;
		r=upper_bound(p+1,p+n+1,r)-p-1;
		if(l>r)continue;
		add(l,r+1,i),add(r+1,l,i);
	}
	ok=true;
	dfs(n+1,0,0);
	for(int i=n;i>=1;i--){
		if(vis[i])continue;
		int tmp=dfs(i,0,0);
		if(tmp^b[i]){
			ok=false;
			break;
		}
	}
	if(!ok){
		puts("-1");
		return 0;
	}
	printf("%d\n",an);
	sort(ans+1,ans+an+1);
	for(int i=1;i<=an;++i){
		printf("%d ",ans[i]);
	}
	return 0;
}


Measured memory_bytes: 13312
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
using namespace std;
signed main(){
	int n,m,t=0;
	cin >> n >> m;
	vector<int> a;
	REP(i,m){
		int l,o;
		cin >> l >> o;
		if(l == 1){
			a.push_back(o);
		}
		else if(o == n){
			a.push_back(l);
		}

	}
	sort(a.begin(),a.end());
	FOR(i,1,a.size()){
		if(a[i] == a[i-1]){
			cout << "POSSIBLE" << endl;
			t=1;
			break;
		}
	}
	if(t == 0){
		cout << "IMPOSSIBLE" << endl;
	}

    return 0;
}


Measured memory_bytes: 2420
#include <algorithm>
#include <cmath>
#include <iostream>
#include <set>
#include <vector>
using namespace std;

// ans, max-sport
pair <int, int> count(int M, vector < vector <int> > a, set<int> ex) {
	vector <int> num(M, 0);
	for (int i=0; i<a.size(); i++) {
		for (int j=0; j<a[i].size(); j++) {
			if (ex.find(a[i][j]) == ex.end()) {
				num[a[i][j]-1]++;
				break;
			}
		}
	}

	int maxnum = 0, maxi = 0;
	for (int i=0; i<M; i++) {
		if (maxnum < num[i]) {
			maxnum = num[i];
			maxi = i+1;
		}
	}

	return make_pair(maxnum, maxi);
}

int main() {
	int N, M, Aij;
	vector < vector <int> > A;
	cin >> N >> M;
	for (int i=0; i<N; i++) {
		vector <int> v;
		for (int j=0; j<M; j++) {
			cin >> Aij;
			v.push_back(Aij);
		}
		A.push_back(v);
	}

	int ans = N;
	set<int> ex;
	for (int i=0; i<M; i++) {
		pair <int, int> p = count(M, A, ex);
		ans = min(ans, p.first);
		ex.insert(p.second);
	}

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


Measured memory_bytes: 1060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N; cin >> N;
    int cnt = 0;
    map<int, int> mp;
    for(int i=0; i<N; i++){
        int a; cin >> a;
        mp[a]++;
    }

    for(auto itr=mp.begin(); itr!=mp.end(); itr++){
        cnt += (itr->second)-1;
    }

    if(cnt%2 == 0) cout << N-cnt << endl;
    else cout << N-cnt-1 << endl;
}

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

int main(){
    int n,a,g=0;
    cin >> n;
    rep(i,n){
        cin >> a;
        if(a%2==0)g++;
    }
    cout << pow(3,n)-pow(2,g) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x=nxt();
    for(ll i=-1e3;i<=1e3;i++)
        for(ll j=-1e3;j<=1e3;j++)
        {
            ll temp=pow(i,5)-pow(j,5);
            if(temp==x)
            {
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    
    return 0;   
}




 
 


Measured memory_bytes: 4124
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

bool tasai(string t){
    set<char> st;
    REP(i,t.size()){
        if(st.count(t[i])) return false;
        st.insert(t[i]);
    }
    return true;
}

int main(){
    string s;cin>>s;
    if(s.size()==26){
        for(int i=s.size()-1;i>=0;--i){
            string tmp=s;
            for(int j=s.size()-1;j>=i+1;--j){
                    tmp.pop_back();
            }
            while(tmp[i]!='z'){
                tmp[i]++;
                
                if(tasai(tmp)){
                    cout<<tmp<<endl;
                    return 0;
                }
            }
        }
        cout<<-1<<endl;
    }
    else{
        REP(i,26){
            if(s.find('a'+i)==string::npos){
                cout<<s<<char('a'+i)<<endl;
                return 0;
            }
        }
    }
}


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

long long a,b,x;

long long f(long long n){
  if(n==-1){ return 0; }
  return n/x + 1;
}

int main() {
  cin >> a >> b >> x;
  cout << f(b) - f(a-1) << endl;
  return 0;
}

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

int main() {
  int K;
  int X;
  cin >> K >> X;
  int Y = 500 * K;
  cin >> Y;
  if (X <= Y) {
    cout << "Yes" <<endl;
  }
  else {
    cout << "No" << endl;
  } 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

map<ll, ll> pf;
void primeFac(ll n){
  if(n == 1){
    pf[1] = 1;
    return;
  }
  ll N = n;
  if(n % 2 == 0){
    ll cnt = 0;
    while(n % 2 == 0){
      cnt++;
      n /= 2;
    }
    pf[2] = cnt;
  }
  for(ll i = 3; i * i <= N; i += 2){
    if(n % i == 0){
      ll cnt = 0;
      while(n % i == 0){
        cnt++;
        n /= i;
      }
      pf[i] = cnt;
    }
  }
  if(n != 1){
    pf[n] = 1;
  }
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, P; cin >> N >> P;
  primeFac(P);
  ll ans = 1;
  for(auto &i : pf){
    if(i.second >= N){
      for(ll j = 0; j < i.second/N; j++){
        ans *= i.first;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
 
public class Main {
	static boolean debug = true;
	static Scanner sc = new Scanner(System.in);
 
	static long max = Long.MIN_VALUE;
 
	public static void main(String[] args) throws Exception {
 
		String[] str=sc.nextLine().split(" ");
		if(str[0].charAt(str[0].length()-1)==str[1].charAt(0)&&str[1].charAt(str[1].length()-1)==str[2].charAt(0))
			System.out.println("YES");
		else
			System.out.println("NO");
	
		 

	}
 
	private static void print(String string) {
		// TODO Auto-generated method stub
		if (debug)
			System.out.println(string);
	}
 
	private static void print(int[] data) {
		if (debug) {
			for (int i = 0; i < data.length; i++)
				System.out.println(i + ":" + data[i]);
		}
	}
 
	private static void print(String[] data) {
		if (debug) {
			for (int i = 0; i < data.length; i++)
				System.out.println(i + ":" + data[i]);
		}
	}
 
	private static void print(char[] data) {
		if (debug) {
			for (int i = 0; i < data.length; i++)
				System.out.println(i + ":" + data[i]);
		}
	}
 
	private static void print(double[] data) {
		if (debug) {
			for (int i = 0; i < data.length; i++)
				System.out.println(i + ":" + data[i]);
		}
	}
 
	private static void print(int[][] data) {
 
		if (debug) {
			for (int i = 0; i < data.length; i++) {
				for (int j = 0; j < data[0].length; j++) {
					System.out.print(data[i][j] + " ");
				}
				System.out.println();
			}
		}
	}
 
	private static void print(char[][] data) {
 
		if (debug) {
			for (int i = 0; i < data.length; i++) {
				for (int j = 0; j < data[0].length; j++) {
					System.out.print(i + " " + j + ":" + data[i][j] + " ");
				}
				System.out.println();
			}
		}
	}
 
	private static void print(String[][] data) {
 
		if (debug) {
			for (int i = 0; i < data.length; i++) {
				for (int j = 0; j < data[0].length; j++) {
					System.out.print(i + " " + j + ":" + data[i][j] + " ");
				}
				System.out.println();
			}
		}
	}
 
	private static void print(double[][] data) {
 
		if (debug) {
			for (int i = 0; i < data[0].length; i++) {
				for (int j = 0; j < data.length; j++) {
					System.out.print(i + " " + j + ":" + data[i][j] + " ");
				}
				System.out.println();
			}
		}
	}
 
	public static void inPutData(char[][] c) {
		for (int i = 0; i < c.length; i++) {
			c[i] = sc.nextLine().toCharArray();
		}
	}
 
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n);i>0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+5  
using ll = long long;
using P = pair<int, int>;
using lP = pair<ll, ll>;
using fP = pair<double, double>;
using PPI = pair<P, int>;
//ll const mod=998244353;
ll const mod = 1e9 + 7;
const ll MAX = 1000005;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vd = vector<double>;
using vs = vector<string>;
using vp = vector<P>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<double>>;
using vvc = vector<vector<char>>;
using vvp = vector<vector<P>>;
using vvb = vector<vector<bool>>;
template <typename T>
bool chmax(T& a, const T b) { if (a < b) { a = b; return true; } return false; }
template <typename T>
bool chmin(T& a, const T b) { if (a > b) { a = b; return true; } return false; }

ll gcd(ll a, ll b) {
    if (b == 0)return a;
    return gcd(b, a % b);
}
//////////////////////////////////////
int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vl a(n + 1), b(m + 1);
    rep(i, n)cin >> a[i + 1];
    rep(i, m)cin >> b[i + 1];
    rep(i, n)a[i + 1] += a[i];
    rep(i, m)b[i + 1] += b[i];
    int l = -1, r = 400001;
    auto check = [&](int s) {
        if (n + m < s)return false;
        ll res = 1e18+1;
        rep(i, n + 1) {
            if (s - i > m || s - i < 0)continue;
            chmin(res, a[i] + b[s - i]);
        }
        if (res > k)return false;
        else return true;
    };
    while (l + 1 < r) {
        int now = (l + r) / 2;
        if (check(now))l = now;
        else r = now;
    }
    cout << l << endl;
    return 0;
}

Measured memory_bytes: 6444
#include <bits/stdc++.h>
using namespace std;
#define int long long
using P = pair<int, int>;
constexpr array<int, 4> dx = {1, 0, -1, 0};
constexpr array<int, 4> dy = {0, 1, 0, -1};
constexpr int INF = 1234567890;
constexpr int MOD = 1000000000 + 7;
// constexpr int MOD = 998244353;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int fact(int n) { return n > 1 ? n * fact(n - 1) % MOD : 1; }
int modinv(int a)
{
    int b = MOD, u = 1, v = 0;
    while (b)
    {
        int t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= MOD;
    if (u < 0)
        u += MOD;
    return u;
}
constexpr int modpow(int a, int n)
{
    int rtn = 1;
    while (n > 0)
    {
        if (n & 1)
            rtn = rtn * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return rtn;
}

char change(char c, int n)
{
    return (c - 'A' + n) % ('Z' - 'A'+1) + 'A';
}

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    for (auto &&si : s)
    {
        si = change(si, n);
    }
    cout << s << endl;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000;
const double PI = acos(-1);
int num_edge = 0, head[100000];
struct Edge { int nxt, to; }edge[100000];
LL n, m, sum = 0, f[100000] = {}, W[1000][1000] = {}, now = 0;
string str;
void add_edge(int from, int to) {
	edge[++num_edge].nxt = from;
	edge[num_edge].to = to;
	head[from] = num_edge;
}

char p[1000][1000];
int main() {
	cin >> str;
	for (int i = 0; i < str.size() - 1; i++) {
		if (str[i] == 'A'&&str[i + 1] == 'C') {
			cout << "Yes" << endl;
			break;
		}
		if (i == str.size() - 2)
			cout << "No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define INF 0x3f3f3f3f3f3f3f3f
#define PI acos(-1.0)
#define MOD 1000000007
//#define eps 1e-10
#define R freopen("555input.txt","r",stdin);
#define W freopen("medical.out","w",stdout);
//
#define N 105
#define M 1000000005
LL n,i,j,a,b,c,d,ans,f[N],t;
LL gcd(LL a,LL b){return b==0?a:gcd(b,a%b);}
LL lcm(LL a,LL b){if(a%b==0)return a;if(b%a==0)return b;return max(a/gcd(a,b)*b,b/gcd(a,b)*a);}
int main ()
{
    
    scanf("%lld",&t);
    for(i=0;i<t;i++)
    {
        scanf("%lld",&f[i]);
        if(i)ans=lcm(f[i],ans);
        else ans=f[i];
    }
    cout<<ans;





    return 0;

}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

const int MX = 3010;
 
ll dp[MX][MX][4];
ll v[MX][MX];

int main(){
    int r,c,k;
    cin>>r>>c>>k;
    rep(i,k){
        ll a,b,d;
        cin>>a>>b>>d;
        a--;b--;
        v[a][b]=d;
    }
    rep(i,r)rep(j,c)rep(k,4)dp[i][j][k]=-1e18;
    dp[0][0][0]=0;
    rep(i,r){
        rep(j,c){
            for(int k=2;k>=0;--k){
                if(dp[i][j][k]>=0)dp[i][j][k+1]=max(dp[i][j][k+1],dp[i][j][k]+v[i][j]);
            }
            rep(k,4){
                if(dp[i][j][k]>=0){
                    if(i+1<r)dp[i+1][j][0]=max(dp[i][j][k],dp[i+1][j][0]);
                    if(j+1<c)dp[i][j+1][k]=max(dp[i][j+1][k],dp[i][j][k]);
                }
            }

        }
    }
    ll ans=0;
    rep(i,4){
        ans=max(ans,dp[r-1][c-1][i]);
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

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

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

llong GCD(llong a, llong b){
	a = abs(a), b = abs(b);
	if(a < b) swap(a, b);
	if(b == 0) return a;
	while(b){
		a %= b;
		swap(a,b);
	}

	return a;
}

llong LCM(llong a, llong b){
	return a / GCD(a, b) * b;
}

int main(){
	llong x, y;
	cin >> x >> y;

	cout << x + y - GCD(x,y) + 1 << endl;

	return 0;
}


Measured memory_bytes: 3096
#include <stdio.h>

#define N 10001
#define Q 501

int linearSearch(int *, int, int);

int main(){
  int i, n, q, S[N], T[Q], cnt=0;

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

  scanf("%d", &q);
  for(i = 1; i <= q; i++){
    scanf("%d", &T[i]);
  }

  for(i = 1; i <= q; i++){
    if(linearSearch(S, n, T[i])) cnt++;
  }

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

  return 0;
}

int linearSearch(int *S, int n, int key){
  int i = 1;
  S[n + 1] = key;
  while(S[i] != key) i++;
  if(i == n + 1) return 0;
  return i;
}

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

int main()
{
    long long int N, M;

    cin >> N >> M;

    long long int p[M];
    string S[M];

    for (long long int i = 0; i < M; i++)
    {
        cin >> p[i] >> S[i];
    }

    long long int pena[N] = {0};
    long long int correct = 0;
    bool ACflg[N] = {false};

    for (int i = 0; i < M; i++)
    {
        if (S[i] == "WA" && ACflg[p[i] - 1] == false)
        {
            pena[p[i]-1]++;
        }
        else if (S[i] == "AC" && ACflg[p[i] - 1] == false)
        {
            correct++;
            ACflg[p[i] - 1] =true;
        }
    }

    long long int pena_sum = 0;

    for (int i = 0; i < N; i++)
    {
        if (ACflg[i] == true)
        {
            pena_sum += pena[i];
        }
    }

    cout << correct << " " << pena_sum << endl;

    return 0;
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int n;
vector<int> G[100100];

int dfs(int v){

  int ret = 0;
  
  vector<int> vec_val;
  for(auto nv : G[v]){

    int tans = dfs(nv);

    vec_val.push_back(tans);    
  }

  sort(vec_val.rbegin(), vec_val.rend());

  rep(i, vec_val.size()){
    chmax(ret, vec_val[i] + i + 1);
  }

  return ret;

}

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

  cin >> n;

  rep(i, n-1){

    int a;
    cin >> a;
    a--;
    // a -> iへの辺
    G[a].push_back(i+1);

  }

  int ans = 0;
  ans = dfs(0);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 15104
import sys
input = sys.stdin.readline

n = int(input())
T = [[] for _ in range(n+1)]
for _ in range(n-1):
  a, b = map(int, input().split())
  T[a].append(b)
  T[b].append(a)
def dfs(v):
  dist = [-1]*(n+1)
  dist[v] = 0
  stack = [v]
  depth = 0
  while stack:
    nv = stack.pop()
    for i in T[nv]:
      if dist[i] != -1:
        continue
      dist[i] = dist[nv] + 1
      stack.append(i)
  return dist

D = dfs(1)
m = D.index(max(D))
dia = max(dfs(m))
if dia%3 == 1:
  print("Second")
else:
  print("First")

Measured memory_bytes: 55088
using System;
// using System.Collections.Generic;

class Program
{
    static bool checkPal(string s)
    {
        char[] arr = s.ToCharArray();
        Array.Reverse(arr);
        return s == new string(arr);
    }

    static void Main()
    {
        String S = Console.ReadLine();
        String str = S.Substring(0, S.Length / 2);
        Console.WriteLine(checkPal(S) && checkPal(str) ? "Yes" : "No");
    }
}

Measured memory_bytes: 13140
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 10000

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

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

int main(){
  int x, y, z;cin>>x>>y>>z;
  cout<<z<<" "<<x<<" "<<y<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vst;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;


const ll mod=1e9+7;
const ll inf=1e16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

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

  ll n,k,r,s,p;
  string t;
  cin >> n >> k >> r >> s >> p >> t;
  
  string mask="";
  rep(i,0,k) mask+='x';
  t=mask+t;
  

  
  ll res=0;
  rep(i,k,t.size()) {
    if(t[i]==t[i-k]) {
      t[i]='x'; 
      continue;
    }
     if(t[i]=='s') res+=r;
     else if(t[i]=='p') res+=s;
     else if(t[i]=='r') res+=p;
  }
  
 cout << res << endl;
  
}


Measured memory_bytes: 768
fun main (args : Array<String>) {
	val s = readLine()!!
	val S : String = s.toString()
	val list : List<String> = listOf("SUN","MON","TUE","WED","THU","FRI","SAT")
	val num = list.indexOfFirst{ it == S}
	println("${7 - num}")
}

Measured memory_bytes: 34212
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr int MOD_TYPE = 1;
constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

#pragma endregion

ll f(ll x)
{
  if (x < 0)
    return 0;
  ll res = 0;
  for (ll i = x / 4 * 4; i <= x; i++)
    res ^= i;
  return res;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  ll a, b;
  cin >> a >> b;
  cout << (f(b) ^ f(a - 1)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s, t;
  cin >> s >> t;
  
  int a, b;
  cin >> a >> b;
  
  string u;
  cin >> u;
  
  if(u==s){
    cout << a-1 << " " << b << endl;
  }
  else{
    cout << a << " " << b-1 << endl;
  }
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
import math
from itertools import chain

def input():
    return sys.stdin.readline().rstrip()

def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

Q = int(input())
a = [list(map(int, input().split())) for _ in range(Q)]
s = []
min_num = min(list(chain.from_iterable(a)))
max_num = max(list(chain.from_iterable(a)))
ctr = 0

for j in range(min_num, max_num + 1, 2):
    if is_prime(j) and is_prime((j + 1) // 2):
        s.append(j)

for i in range(Q):
    for k in s:
        if k >= a[i][0] and k <= a[i][1]:
            ctr += 1
    print(ctr)
    ctr = 0

Measured memory_bytes: 74892
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] line = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int L = line[0] + line[1];
            int R = line[2] + line[3];
            if (L == R)
            {
                Console.WriteLine("Balanced");
            }
            else if (L > R)
            {
                Console.WriteLine("Left");
            }
            else
            {
                Console.WriteLine("Right");
            }
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000001
#define MAXN        400005
#define mod         998244353
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,p;
    cin>>a>>p;
    a=a*3;
    a=a+p;
    a=a/2;
    cout<<a;
}

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

using namespace std;
typedef long long LL;

class UnionFind {
public:
    vector <LL> par;
    vector <LL> siz;

    UnionFind(LL sz_): par(sz_), siz(sz_, 1LL) {
        for (LL i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(LL sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (LL i = 0; i < sz_; ++i) par[i] = i;
    }

    LL root(LL x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }

    bool unite(LL x, LL y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool same(LL x, LL y) {
        return root(x) == root(y);
    }

    LL size(LL x) {
        return siz[root(x)];
    }
};

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> p(N);
  rep(i,N) cin >> p[i];
  rep(i,N) p[i]--;
  UnionFind tree(N);
  rep(i,M){
    int x, y;
    cin >> x >> y;
    x--; y--;
    tree.unite(x,y);
  }
  int ans=0;
  rep(i,N) if(tree.same(i,p[i])) ans++;
  cout << ans << endl;
  
	return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int N, p[30], min_times;

map<int,int> rot[4] = {
    { {1, 28}, {2, 29}, {3, 30}, {15, 16}, {19, 21}, },
    { {3, 22}, {6, 25}, {9, 28}, {12, 19}, {13, 15} },
    { {7, 22}, {8, 23}, {9, 24}, {13, 18}, {10, 12} },
    { {1, 24}, {4, 27}, {7, 30}, {10, 21}, {16, 18} }
};

vector<int> group_id = {
    0, 0, 0, 0, 0, 0, 0, 0, 0,
    9, 9, 9,
    12, 12, 12,
    15, 15, 15,
    18, 18, 18,
    21, 21, 21, 21, 21, 21, 21, 21, 21
};

void rotate(int i) {
    for (auto it=rot[i].begin(); it!=rot[i].end(); ++it) {
        swap(p[it->first - 1], p[it->second - 1]);
    }
}

bool isOK() {
    for (int i=0; i<(int)group_id.size(); ++i) {
        if (p[i] != p[group_id[i]]) return false;
    }
    return true;
}

int solve(int times, int &min_times) {
    if (min_times <= times || isOK()) {
        min_times = min(min_times, times);
        return times;
    } else if (times == 7) {
        return 8;
    }
    int ret = 8;
    for (int i=0; i<4; ++i) {
        rotate(i);
        ret = min(ret, solve(times + 1, min_times));
        rotate(i);
    }
    return ret;
}

int main() {
    ios::sync_with_stdio(false);
    cin >> N;
    for (int i=0; i<N; ++i) {
        for (int j=0; j<30; ++j) {
            cin >> p[j];
        }
        min_times = 8;
        cout << solve(0, min_times) << endl;
    }
    return 0;
}

Measured memory_bytes: 1200
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        int n = sc.nextInt();
        int[] cnts = new int[100001];
        long s = 0;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            cnts[a] += 1;
            s += a;
        }

        int q = sc.nextInt();
        for (int i = 0; i < q; i++) {
            int b = sc.nextInt(), c = sc.nextInt();
            s += 1L * c * cnts[b] - 1L * b * cnts[b];
            cnts[c] += cnts[b];
            cnts[b] = 0;
            out.println(s);
        }

        out.flush();
    }

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

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

Measured memory_bytes: 60828
n = input()
N = [int(i) for i in n]
for i in range(8):
  n = format(i, '03b')
  ans = N[0]
  msg = str(N[0])
  for j in range(3):
    if n[j] == '0':
      ans += N[j+1]
      msg += '+' + str(N[j+1])
    else:
      ans -= N[j+1]
      msg += '-' + str(N[j+1])
  if ans == 7:
    print(msg + "=7")
    break

Measured memory_bytes: 9140
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int prev = sc.nextInt() - 1;
		for (int i = 1; i < n; i++) {
		    int x = sc.nextInt();
		    if (prev < x) {
		        x--;
		    }
		    if (prev > x) {
		        System.out.println("No");
		        return;
		    }
		    prev = x;
		}
		System.out.println("Yes");
   }
}


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

const int MAXN = 1e5 + 10;
long long sum, t, cnt, n, a[MAXN], b[MAXN];
vector<long long> r;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		cin >> b[i];
	for (int i = 0; i < n; i++)
		if (a[i] - b[i] < 0)
			sum += b[i] - a[i], cnt++;
		else
			r.push_back(a[i] - b[i]);
	if (cnt == 0)
		return cout << 0, 0;
	sort(r.begin(), r.end());
	reverse(r.begin(), r.end());
	for (int i = 0; i < r.size(); i++) {
		t += r[i];
		if (t >= sum)
			return cout << i + 1 + cnt, 0;
	}
	cout << -1;
}

Measured memory_bytes: 2936
#include<iostream>
#include<cmath>
#include<iomanip>

int main(){
    int i,n;
    double sum,ave,dev,V;
    while(1){
        std::cin>>n;
        if(n==0){
            break;
        }else{
            sum=0;
            ave=0;
            dev=0;
            V=0;
            double num[1000];
        
            for(i=0;i<n;i++){
                std::cin>>num[i];
                sum+=num[i];
            }
            ave=sum/n;//平均値を算出

            for(i=0;i<n;i++){
                V+=pow(num[i]-ave,2);
            }
            dev=sqrt(V/n);

            std::cout<<std::fixed;
            std::cout<<std::setprecision(5)<<dev<<std::endl;
        }
    
    }
    return 0;
}



Measured memory_bytes: 3284
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const long long LINF = 1000000000000000018ll;
const int INF = 1000000009;
const int mod = 1000000007;

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

  int n; cin >> n;
  vector<int> a(n);
  map<int, long long> mp;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]]++;
  }

  long long ans = 0;
  for (auto it = mp.begin(); it != mp.end(); it++) {
    if ((it->second) > 1) {
      ans += (it->second) * ((it->second)-1) / 2;
    }
  }
  for (int i = 0; i < n; i++) {
    long long out = ans;
    long long tmp = mp[a[i]];
    if (tmp > 1) {
      out -= tmp*(tmp-1)/2;
      out += (tmp-1)*(tmp-2)/2;
    }
    cout << out << endl;
  }
  return 0;
}


Measured memory_bytes: 12160