akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;

bool usedx[100009];
bool usedy[100009];

vector<int>v[100009];
bool used[100009];

int dfs(int now){
  if(used[now])return 0;
  used[now]=1;
  int res=1;
  r(i,v[now].size()){
    res += dfs(v[now][i]);
  }
  return res;
}

signed main(){
  int n,sum=0;
  cin>>n;
  int y[n],x[n];
  r(i,n){
    cin>>x[i]>>y[i];
    if(usedx[x[i]] || usedy[y[i]]){
      cout<<-1<<endl;
      return 0;
    }
    usedx[x[i]]=1;
    usedy[y[i]]=1;
    v[x[i]].push_back(y[i]);
    v[y[i]].push_back(x[i]);
    //if(x[i]==y[i])used[x]=1;
  }

  r(i,n){
    if(!used[i+1]){
      sum += dfs(i+1)-1;
    }
  }


  cout<<sum<<endl;
  
}



Measured memory_bytes: 14304
#include <bits/stdc++.h>
using namespace std;
 
int main() {

    int N;
    cin >> N;

    vector<pair<int, int>> A(N);

    for(int i = 0; i < N; i++){
        cin >> A.at(i).second >> A.at(i).first;
    }

    long long now = 0;

    sort(A.begin(), A.end());

    for(int i = 0; i < N; i++){
        now += A.at(i).second;
        if(now > A.at(i).first){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

}

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

ll n,c[51],d[51][21][2],v[51][21][2],a=1e18;
string s[51];

ll fnc(ll b,ll p,ll g){
	if(p == s[b].size()) return 0;
	ll &e = v[b][p][g];
	ll &m = d[b][p][g];
	if(e) return m;
	e = 1, m = 1e18;
	ll l = 1;
	if(!g) {
		for(int j=p, k=s[b].size()-1; j<k; j++, k--) {
			if(s[b][j] != s[b][k]) l = 0;
		}
	}
	else {
		for(int j=0, k=p; j<k; j++, k--) {
			if(s[b][j] != s[b][k]) l = 0;
		}
	}
	if(l) return m = 0;
	for(int i=0; i<n; i++) {
		ll y = 1;
		int j, k;
		if(!g) {
			for(j=p, k=s[i].size()-1; j<s[b].size() && k>=0 && y; j++, k--) {
				if(s[b][j] != s[i][k]) y = 0;
			}
			if(y) {
				if(k < 0) m = min(m, c[i] + fnc(b, j, 0));
				else m = min(m, c[i] + fnc(i, k, 1));
			}
		}
		else {
			for(j=p, k=0; k<s[i].size() && j>=0 && y; j--, k++) {
				if(s[b][j] != s[i][k]) y = 0;
			}
			if(y) {
				if(j < 0) m = min(m, c[i] + fnc(i, k, 0));
				else m = min(m, c[i] + fnc(b, j, 1));
			}
		}
	}
	return m;
}

int main() {
	cin >> n;
	for(int i=0; i<n; i++) cin >> s[i] >> c[i];
	for(int i=0; i<n; i++) a = min(a, c[i] + fnc(i, 0, 0));
	cout<<(a==1e18 ? -1 : a)<<endl;
}


Measured memory_bytes: 3676
n = int(input())
str = ""

if n%10 == 0:
	str = "pon"
elif n%10 == 1:
	str = "pon"
elif n%10 == 2:
	str = "hon"
elif n%10 == 3:
	str = "bon"
elif n%10 == 4:
	str = "hon"
elif n%10 == 5:
	str = "hon"
elif n%10 == 6:
	str = "pon"
elif n%10 == 7:
	str = "hon"
elif n%10 == 8:
	str = "pon"
elif n%10 == 9:
	str = "hon"

print(str)

Measured memory_bytes: 9152
#include <iostream>
#include <string>
#include <vector>
#include <math.h>

using namespace std;

double dist(vector<int> a, vector<int> b) {
    double sum = 0;
    for (int i = 0; i < a.size(); i++) {
        sum += pow(a[i] - b[i], 2);
    }

    return sqrt(sum);
}

int main() {
    int N, D = 0;

    cin >> N >> D;

    vector<vector<int>> points;
    for (int i = 0; i < N; ++i) {
        vector<int> point;
        for (int j = 0; j < D; j++) {
            int a = 0;
            cin >> a;
            point.push_back(a);
        }
        points.push_back(point);
    }

    int result = 0;

    for (int i = 0; i < points.size(); i++) {
       for (int j = i+1; j < points.size(); j++) {
           double dt = dist(points[i], points[j]);
           if (fmod(dt, 1) == 0) {
               result++;
           }
       }
    }
    
    cout << result << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
    
bool isBiggerthanN(int num,int n){
    if(num > n)return  true;
    else return  false;
}

int main(){
    int flag=1;
    int n,MAX=0;
    int ans=0;

    cin >>n;
    int h[n];
    for (int i = 0; i < n; i++){
        cin >>h[i];
        MAX=max(h[i],MAX);
    }

    for (int hei = 0; hei < MAX; hei++){
        int k=0;
        while (isBiggerthanN(h[k],hei)==false)k++;
        ans++;
        for (int i = k; i < n-1; i++){
            if((isBiggerthanN(h[i],hei)==false)&&(isBiggerthanN(h[i+1],hei)==true))ans++;
        }
    }
    cout << ans <<endl;
    //cout <<fixed<<setprecision(16)<< ans <<endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}




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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> mat;
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define mset(a,x) memset(a,x,sizeof(a))
#define FASTIO cin.tie(0),ios::sync_with_stdio(0)

int n, k;

int main() {
    cin >> n >> k;
    vector<ll> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];

    auto tx = x, ty = y;
    sort(ALL(x)); sort(ALL(y));

    ll res = 1LL << 62;
    rep(i, n) FOR(j, i + 1, n) rep(kk, n) FOR(l, kk + 1, n) {
        ll a = min(x[i], x[j]), b = max(x[i], x[j]);
        ll c = min(y[kk], y[l]), d = max(y[kk], y[l]);
        
        int cnt = 0;
        rep(p, n) {
            if (a <= tx[p] && tx[p] <= b
                && c <= ty[p] && ty[p] <= d) cnt++;
        }
        if (cnt < k) continue;
        ll s = 1LL * (b - a) * (d - c);
        res = min(res, s);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, s[10] = {0}, i, j, g;
	
	while (scanf("%d", &n) != EOF){
		i = 0;
		g = 512;
		for (j = 0; j < 10; j++){
			if (n >= g){
				s[i] = g;
				n -= g;
				i++;
			}
			g /= 2;
		}
		for (j = i - 1; j >= 0; j--){
			if (j == 0) printf("%d\n", s[j]);
			else printf("%d ", s[j]);
		}
	}
	return (0);
}

Measured memory_bytes: 596
inp = input()
inp = inp[::-1]
li = ['dream','dreamer','erase','eraser']
li = [k[::-1] for k in li]
m = 0
while True:
    for i in li:
        if inp.startswith(i):
    	    inp = inp.replace(i,'',1)
    	    m = 0
    else:
    	if m == 1:
    		break
    	else:
    		m = 1
    		continue
    break
if inp == '':
	print("YES")
else:
	print("NO")

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

int arr[1000001];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll N;
	cin >> N;
	int maxi = 0;
	vector<int> v;
	for(int i = 0; i<N;i++)
	{
		int temp;
		cin >>temp;
		v.push_back(temp);
		maxi = max(temp,maxi);
	}
	int ans = 0;
	sort(v.begin(),v.end());
	for(int i = 1;i<N;i++)
	{
		if(v[i] == v[i-1])
		{
			arr[v[i]]= 1;
		}
	}

	for(auto i :v)
	{
		if(arr[i] == 0)
		{
			ans ++;
		}
		for(int j = i; j<=maxi;j+=i)
		{
			arr[j] = 1;
		}
	}
	cout <<ans<<endl;
}


Measured memory_bytes: 7968
# 1回の操作ではK-1個の数を1にできる、変えなくてはいけない数はN-1個　その天井をとればok
import math
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
ans = math.ceil((N - 1) / (K - 1))
print(ans)


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

int main() {
	int a,b;
	cin>>a>>b;
	if(a>=13)
	cout<<b<<endl;
	else if(a>=6 && a<=12)
	cout<<b/2<<endl;
	else if(a<=5)
	cout<<0<<endl;
	return 0;
}

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

int main(){
  
  int N;
  cin >> N;
  
  vector<int> v(N);

  for(int i=0; i<N; ++i)
  {
    cin >> v[i];
  }
  
  int sum = 0;
  for (int i = 0; i < v.size(); ++i){  
    sum += (v[i]-1);
  }
  cout << sum << endl;


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;
char s[500005];
vector<int> init,used;
vector<int> addi(vector<int> a,vector<int> b)
{
	vector<int> ans;
	int carry=0,tempA,tempB;
	int len=max(a.size(),b.size());
	for(int i=0;i<len;++i){
		tempA=tempB=0;
		if(i<a.size()) tempA=a[i];
		if(i<b.size()) tempB=b[i];
		if(tempA+tempB+carry>=10){
			ans.push_back(tempA+tempB+carry-10);
			carry=1;
		}
		else{
			ans.push_back(tempA+tempB+carry);
			carry=0;
		}
	}
	if(carry==1) ans.push_back(1);
	return ans;
}
int count(vector<int> a)
{
	int result=0;
	for(int i=0;i<a.size();++i){
		result+=a[i];
	}
	return result;
}
int check(int m)
{
	vector<int> temp;
	int t=m*9;
	while(t>0){
		temp.push_back(t%10);
		t/=10;
	}
	if(m*9>=count(addi(used,temp))) return true;
	return false;
}
int main()
{
	scanf("%s",s);
	vector<int> temp;
//	cout<<123456789*9<<endl;
	temp.push_back(9);
	int l=strlen(s),k=0;
	for(int i=l-1;i>=0;--i){
		init.push_back(s[i]-'0');
	}
	for(int i=1;i<=9;++i){
		used=addi(used,init);
//		showHang();
	}
	int lo=1,hi=l;
	while(lo<=hi){
		int mi=(lo+hi)/2;
		if(check(mi))
		{
			k=mi;
			hi=mi-1;
		}
		else lo=mi+1;
	}
	cout<<k<<endl;
	return 0;
}

Measured memory_bytes: 12660
#include <iostream>
#include <vector>

using namespace std;

int N,M;
vector<int>som[100007];
int dp[100005];


void DFS(int a)
{
    dp[a]=1;
    for(int i=0; i<som[a].size(); i++)
    {
        if(dp[som[a][i]] == 0) DFS(som[a][i]);
        dp[a]=max(dp[a], dp[som[a][i]]+1);
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> N >> M;
    for(int i=0; i<M; i++)
    {
        int x,y;
        cin >> x >> y;
        som[x].push_back(y);
    }
    int wynik=0;
    for(int i=1; i<=N; i++) if(dp[i] == 0) DFS(i);
    for(int i=1; i<=N; i++) wynik=max(wynik, dp[i]);
    cout << wynik-1;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
// #define vec(v) vector<int>(v)
// #define be(v) (v).begin(), (v).end()
// #define pb(q) push_back(q)
// #define mapci(mp) map<char*,int>(mp)
// #define mapcc(mp) map<char*,char*>(mp)
// typedef long long ll;
using namespace std;

int main(){

    int r;
    cin>>r;
    cout<<3*r*r<<endl;

    return 0;
}

Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#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 <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 1001001001001001;
const long long MOD = 1000000007;
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

cpp_int gcd(cpp_int a, cpp_int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
 
cpp_int lcm(cpp_int a, cpp_int b) {
    return a  / gcd(a, b) * b;
}

int main() {
    int N;cin >> N;
  	vector<cpp_int> retu(N);
  	for(int i = 0;i<N;i++) cin >> retu.at(i);
  	sort(retu.begin(),retu.end());
  	cpp_int ans = retu.at(0);
  	for(int i = 1;i<N;i++){
      	ans *= retu.at(i);
      	if(ans > 1000000000000000000){
        	cout << -1 << endl;
          	return 0;
        }
    }
  	cout << ans << endl;
    // PLEASE GIVE ME THE "ACCEPTED" !
}


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

// 小数点以下桁数
// fixed << setprecision(i)

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

int main()
{
  int n, max_a, tmp;
  vector<bitset<30>> a(200000);
  vector<int> b(30, 0);
  
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> tmp;
    bitset<30> s(tmp);
    a[i] = s;
    for (int j = 0; j < 30; j++)
      b[j] += a[i][j];
  }
  for (int i = 0; i < n; i++)
  {
    bitset<30> s(0);
    for (int j = 0; j < 30; j++)
    {
      if (b[j] % 2 && !a[i][j])
        s[j] = 1;
      else if (!(b[j] % 2) && a[i][j])
        s[j] = 1;
    }
    cout << s.to_ullong() << endl;
  }
}

Measured memory_bytes: 4620
X=int(input())
C=-1
if (X<=1):
	print(1)
else:
	for J in range(1,X+1):
		for I in range(2,X+1):
			if pow(J,I)<=X:
				if pow(J,I)>C:
					C=pow(J,I)
			else:
				break
	print(C)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vl vector<ll>
#define pl pair<ll,ll>
#define rep(i,b) for(ll i=0;i<b;i++)
#define all(v) (v).begin(),(v).end()

ll G[100][100];

int main() {
    ll n,k,u;cin>>n;
    rep(i,n){
        cin>>k>>k;
        rep(j,k){
            cin>>u;
            u--;
            G[i][u]=1;
        }
    }
    rep(i,n){
        rep(j,n){
            cout<<G[i][j];
            if(j<n-1)cout<<" ";
        }
        cout<<endl;
    }
}


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

int main() {
   int n;
   cin >> n;
   int a[n], b[n];
   rep(i, n) {
       cin >> a[i];
       b[a[i] - 1] = i + 1;
   }

   rep(i, n) {
       cout << b[i] << " ";
   }
}

Measured memory_bytes: 1536
n = int(input())
h = list(map(int, input().split()))
answer = -1#これなに
m = 0#カウントするやつやね
for i in range(n-1):
    if h[i] >= h[i+1]:
        m += 1
    else:
        answer = max(answer,m)
        m = 0
answer = max(answer,m)
print(answer)


Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int N;
  	cin >> N;
  	vector<string> S(N);
  	for(int i=0;i<N;i++) cin >> S.at(i);
  	int a=0;
  	int w=0;
  	int t=0;
  	int r=0;
  	for(int i=0;i<N;i++){
    	if(S.at(i) == "AC") a++;
      	else if(S.at(i) == "WA") w++;
      	else if(S.at(i) == "TLE") t++;
      	else if(S.at(i) == "RE") r++;
    }
  cout << "AC" << " " << "x" <<" "<< a << endl;
  cout << "WA" << " " << "x" << " " << w << endl;
  cout << "TLE" << " " << "x" << " " <<t << endl;
  cout << "RE" << " " << "x" <<" "<< r << endl;
}

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

char hand[32] = "00000001111111110000100010";

int main(){
    string typ;
    while(cin >> typ){
        if(typ == "#") break;
        int ch = 0;
        for(int i = 1; i < typ.size(); i++){
            ch += abs(hand[typ[i] - 97] - hand[typ[i-1] - 97]);
        }
        printf("%d\n", ch);
    }    
    return 0;
}

Measured memory_bytes: 1188
#include "bits/stdc++.h" // {{{
using namespace std;
#define outl(x) cout << (x) << '\n'
#define rep(i,n) for(int i=0; i < (int)(n); ++i)
#define FILL(a,val) memset((a), (val), sizeof(a))
#define ten(n) ((int)(1e##n))
#define TMPLT(T,U) template<class T, class U>
using ll = long long;
constexpr int INF = 0x3f3f3f3f;

namespace ydk{ // }}}
constexpr int MXN = 5005;
constexpr int MOD = ten(9) + 7;

int N, L;
string s;
int dp[MXN][MXN];

constexpr int modPow(ll x, ll n)
{
    ll ret = 1;
    while(n > 0) {
        if(n&1) (ret *= x) %= MOD;
        (x *= x) %= MOD;
        n >>= 1;
    }
    return ret;
}

ll fn(int cnt, int len)
{
    if (~dp[cnt][len]) { return dp[cnt][len]; }
    if (cnt == N) { return (len == L)? 1 : 0; }

    return dp[cnt][len] =
        (fn(cnt+1, len+1)*2 + fn(cnt+1, max(0, len-1))) % MOD;
}

signed _vim_is_god_()
{
    ios::sync_with_stdio(false); cin.tie(nullptr);
    cin >> N >> s;
    L = s.length();

    FILL(dp, -1);
    ll ans = fn(0, 0);

    ans = ans * modPow(modPow(2, L), MOD-2) % MOD;
    outl(ans);

    return 0;
}

} // {{{
signed main(){ydk::_vim_is_god_(); return 0;} // }}}



Measured memory_bytes: 98304
#include <bits/stdc++.h>     // [PRIMES]               1777 ~2^10.80  
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

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

	vector<pll> weightValue;
	FOR(i, 0, n) {
		ll a, b; cin >> a >> b;
		weightValue.pb(mp(a, b));
	}

	ll dp[n][w + 1] = {{ 0 }};

	pll firstPair = weightValue[0];
	FOR(i, 0, w + 1) {
		if(firstPair.xx <= i) dp[0][i] = firstPair.yy;
		else dp[0][i] = 0;
	}

	FOR(i, 1, n) {
		pll nextPair = weightValue[i];
		FOR(j, 0, w + 1) {
			if(j - nextPair.xx >= 0) {
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - nextPair.xx] + nextPair.yy);
			} else {
				dp[i][j] = dp[i - 1][j];
			}
		}
	}

	cout << dp[n - 1][w] << endl;

	return 0;
}

Measured memory_bytes: 78336
#![allow(unused_imports)]
use std::io;
use std::cmp::*;
use std::collections::*;
#[allow(dead_code)]
const M: i64 = 1e9 as i64 + 7;

fn read_line() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}
#[allow(dead_code)]
fn read<T>() -> T where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().trim().parse().unwrap()
}
#[allow(dead_code)]
fn readv<T>() -> Vec<T> where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().split(' ').map(|a| a.trim().parse().unwrap()).collect()
}

fn main() {
    let _ = read::<i32>();
    let aa = readv::<i32>();
    let bb = readv::<i32>();
    let x = aa.iter().fold(0, |acc, &a| acc ^ a);
    let mut a2: HashMap<i32, i32> = HashMap::new();
    // let (aa, bb) = aa.iter().zip(bb.iter()).filter(|a, b| a != b).unzip();
    let (mut aa, bb): (Vec<i32>, Vec<i32>) = aa.iter().zip(bb.iter()).filter(|&(&a, &b)| a != b).unzip();
    let n = aa.len() as i32;
    aa.push(x);
    for &a in &aa {
        *a2.entry(a).or_insert(0) += 1;
    }
    for &b in &bb {
        match a2.get(&b) {
            Some(&rem) if rem > 0 => { a2.insert(b, rem - 1); },
            _ => {
                println!("{}", -1);
                return;
            }
        };
    }
    // #[cfg(local)] println!("{}: {:?}", "a2", a2);

    let mp = aa.iter().collect::<BTreeSet<&i32>>().into_iter().enumerate()
        .map(|(a, b)| (b, a as i32)).collect::<HashMap<&i32, i32>>();
    let a2 = aa.iter().map(|a| mp[a]).collect::<Vec<i32>>();
    let b2 = bb.iter().map(|b| mp[b]).collect::<Vec<i32>>();
    // let mut dests = b2.iter().collect::<HashSet<&i32>>().into_iter().enumerate()
    let mut dests = b2.iter().enumerate()
        .fold(HashMap::new(), |mut acc, (a, b)| { (*acc.entry(b).or_insert(Vec::new())).push(a as i32); acc });
    let mut q = std::iter::once(n).collect::<VecDeque<i32>>();
    let mut rems = (0..n + 1).collect::<HashSet<i32>>();
    let mut ans = 0;
    #[cfg(local)] println!("{}: {:?}", "(mp, dests)", (mp, &dests));
    #[cfg(local)] println!("{}: {:?}", "(a2, b2)", (&a2, &b2));
    while !rems.is_empty() {
        while let Some(s_idx) = q.pop_front() {
            if !rems.remove(&s_idx) {
                continue;
            }
            let s_num = a2[s_idx as usize];
            #[cfg(local)] println!("{}: {:?}", "s_num", s_num);
            if let Some(destv) = dests.remove(&s_num) {
                for dest in destv {
                    #[cfg(local)] println!("{}: {:?}", "(s_idx, s_num, dest)", (s_idx, s_num, dest));
                    if a2[dest as usize] != b2[dest as usize] {
                        q.push_back(dest);
                    }
                }
            }
        }
        if let Some(&rem) = rems.iter().next() {
            q.push_back(rem);
            ans += 1;
        }
        #[cfg(local)] println!("{}: {:?}", "rems", rems);
    }
    #[cfg(local)] println!("{}: {:?}", "(ans, n)", (ans, n));
    println!("{}", ans + n);
}


Measured memory_bytes: 26904
#!/usr/bin/env python3
import sys
 
 
def solve(N: int, H: "List[int]"):
    longest = 0
    current = 0
    for i in range(N-1):
        if H[i] >= H[i+1]:
            current += 1
        else:
            if current > longest:
                longest = current
            current = 0
    if current > longest:
        longest = current
    print(longest)
    return
 
 
# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, H)
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 15288
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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 (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
void printv(vector<T> v)
{
    for (T t : v)
    {
        cout << t << " ";
    }
    cout << '\n';
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int h, w, x, y;
    cin >> w >> h >> x >> y;
    
    double menseki = (double) w*(double)h/2.0;
    if(h%2==0 and w%2==0) if(h/2==y and w/2==x){
        cout  << setprecision(12)<<menseki<< " "<< 1<<endl;
        return 0;
    }
    
    
    cout <<  setprecision(12) <<menseki << " "<<0<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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 ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, T;
    cin >> N >> T;
    vector<P> AB(N);
    rep(i, N) {
        int A, B;
        cin >> A >> B;
        AB[i] = {A, B};
    }

    sort(all(AB));

    vector<vector<ll>> dp(N + 1, vector<ll>(T + 1));

    rep(i, N) {
        rep(j, T) {
            chmax(dp[i + 1][j], dp[i][j]);
            chmax(dp[i + 1][min(T, j + AB[i].first)], dp[i][j] + AB[i].second);
        }
    }

    ll ans = 0;
    rep(i, N) {
        chmax(ans, dp[i + 1][T]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 73688
#include <iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<string>
#include <queue>
#include <stack>
#include <set>
#include <cstring>
#include <map>
using namespace std;
typedef long long ll;
ll d[20001];
pair<ll, ll> a[1003];
int main() {
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
  
    // d[i] = 괴물 체력을 i남았을 때의 최소 비용
    ll h, n; cin >> h >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }
    ll ans = -1;
    for (int i = 1; i <= 20000; i++) {
        d[i] = 1e9;
        for (int j = 0; j < n; j++) {
            if (i - a[j].first >= 0) {
                d[i] = min(d[i], d[i - a[j].first] + a[j].second);
            }
        }
        if (i >= h) {
            if (ans == -1 || ans > d[i]) {
                ans = d[i];
            }
        }
    }

    cout << ans << '\n';
}

Measured memory_bytes: 384
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2);
        if(y%2==0)
         return (p*p)%hell;
        else
        return (x*((p*p)%hell))%hell;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    
    ll a[5];
    for(int i=0;i<5;i++)
    {
        cin>>a[i];
        if(a[i]==0)
        cout<<i+1;
    }}
    
    
    
    
    
    

Measured memory_bytes: 3504
#include <bits/stdc++.h>
using namespace std;
 
int main(){
   char S[4];
   cin>>S;
   if(S[2]==S[3] && S[4]==S[5]){
       cout<<"Yes"<<endl;
   }else{
       cout<<"No"<<endl;
   }
 
    return 0;
}

Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return [init]*size1
  else
    return [[init]*size2]*size1
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

x=get_i
puts x.index(0)+1

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i=a; i<b; i++)
int mod = 1e9 + 7;
typedef long long ll;
 
int main(){
    long long N;
    cin >> N;

    for (long long h=1; h<=3500; h++){
        for (long long w=1; w<=3500; w++){
			long long n = (N * h * w) / ((4 * h - N) * w - N * h);
          	if(((4 * h - N) * w - N * h) > 0 && (N * h * w) % ((4 * h - N) * w - N * h)==0){
            	printf("%ld %ld %ld\n", h, w, n);
              	return 0;
            }
        }
    }
}   

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val S = sc.next()
    println(solve(S))
  }

  def solve(S: String): String = {
    val arr = S.toArray
    val bl = arr.count(a => a == '1')
    val re = arr.count(a => a == '0')
    (S.length - Math.abs(bl - re)).toString
  }
}

Measured memory_bytes: 31736
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N ;
    cin >> N ;
    
    vector<ll> a(N);
    rep(i, N){
        cin >> a[i];
    }
    

    vector<bool> ans(N, false);
    
    for(ll i = N-1; i>=0; i--){
        ll idx = i+1;
        ll times = 2;
        ll cnt = 0;
        
        while(((idx * times) <= N)){
            if(ans[idx * times -1]) cnt++;
            times ++;
        }
        cnt += a[i];
        
        if(cnt%2 == 1) ans[i] = true;
    }
    
    ll cnt = 0;
    rep(i, N) if(ans[i]) cnt ++;
    cout << cnt << endl;
    
    rep(i, N){
        if(ans[i]) cout << (i+1) << " ";
    }

    cout << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <stdio.h>
#include <map>
#include <set>

using namespace std;

void Dump(char ch, set<int> &sset)
{
    set<int>::iterator sitr = sset.end();
    if (!sset.empty())
    {
        sitr = sset.begin();
    }
    for (int i = 1; i <= 13; i++)
    {
        if (sitr == sset.end())
        {
            printf("%c %d\n", ch, i);
        }
        else if (*sitr == i)
        {
            sitr++;
        }
        else
        {
            printf("%c %d\n", ch, i);
        }
    }
}

int main(int argc, char *argv[])
{
    int n, num;
    scanf("%d", &n);

    char suit;
    set<int> sset, hset, cset, dset;

    for (int i = 0; i < n; i++)
    {
        getchar();
        scanf("%c", &suit);
        switch (suit) {
        case 'S':
            scanf("%d", &num);
            sset.insert(num);
            break;
        case 'H':
            scanf("%d", &num);
            hset.insert(num);
            break;
        case 'C':
            scanf("%d", &num);
            cset.insert(num);
            break;
        case 'D':
            scanf("%d", &num);
            dset.insert(num);
            break;
        default:
            break;
        }
    }

//    set<int>::iterator sitr = sset.end();
//    if (!sset.empty())
//    {
//        sitr = sset.begin();
//    }
//    for (int i = 1; i <= 13; i++)
//    {
//        if (sitr == sset.end())
//        {
//            printf("%c %d\n", 'S', i);
//        }
//        else if (*sitr == i)
//        {
//            sitr++;
//        }
//        else
//        {
//            printf("%c %d\n", 'S', i);
//        }
//    }
    Dump('S', sset);
    Dump('H', hset);
    Dump('C', cset);
    Dump('D', dset);

    return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;


ll xs, ys, xt, yt;
ll N;
double x[1100], y[1100], r[1100];

const int MAX_N = 2000010;
vector<pair<int, double> > G[MAX_N];
vector<double> dijkstra(int start){
	vector<double> dist(MAX_N, INFF);
	dist[start] = 0;//dist[i] :=　start->iまでの最短距離
	priority_queue<pair<double, int>, vector<pair<double, int> >, greater<pair<double, int> > >  que;
	que.push(make_pair(0, start));
	while(!que.empty()){
		double cost; int u;//今までにかかった時間 現在の頂点
		cost = que.top().first, u = que.top().second;
		que.pop();
		if(dist[u] < cost) continue;
		for (auto tmp : G[u]){
			int v = tmp.first; double time = tmp.second;//隣接する頂点 その頂点まで行く時間
			if(dist[v] > dist[u] + time){//u->v
				dist[v] = dist[u] + time;
				que.push(make_pair(dist[v], v));
			}
		}
	}
	return dist;
}


int main(void) {
	cin >> xs >> ys >> xt >> yt;
	cin >> N;
	x[0] = xs, y[0] = ys, x[N + 1] = xt, y[N + 1] = yt;
	reps(i, 1, N + 1) cin >> x[i] >> y[i] >> r[i];
	rep(i, N + 2)reps(j, i + 1, N + 2){
		auto dist = [](int i, int j) {
			return max((double)0, sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2)) - (r[i] + r[j]));
		};
		G[i].pb(mp(j, dist(i, j))), G[j].pb(mp(i, dist(i, j)));
	}
	auto ret = dijkstra(0);
	printf("%.9f\n", ret[N + 1]);
	return 0;
}

Measured memory_bytes: 85012
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
#define ld long double
#define ft first
#define sd second
using namespace std;

const int N = 2e5 + 9;


ll tr[4 * N], lz[4 * N], f[N];
const ll inf = 1e18;

void upd(int x, int l, int r, int ul, int ur, ll diff) {
    if (lz[x] != 0) {
        tr[x] += lz[x];
        if (l != r) {
            lz[2 * x] += lz[x];
            lz[2 * x + 1] += lz[x];
        }
        lz[x] = 0;
    }
    if (l > r || l > ur || r < ul)
        return;
    if (l >= ul && r <= ur) {
        tr[x] += diff;
        if (l != r) {
            lz[2 * x] += diff;
            lz[2 * x + 1] += diff;
        }
        return;
    }
    int m = (l + r) / 2;
    upd(2 * x, l, m, ul, ur, diff);
    upd(2 * x + 1, m + 1, r, ul, ur, diff);
    tr[x] = max(tr[2 * x], tr[2 * x + 1]);
}


ll qry(int x, int l, int r, int ql, int qr) {
    if (lz[x] != 0) {
        tr[x] += lz[x];
        if (l != r) {
            lz[2 * x] += lz[x];
            lz[2 * x + 1] += lz[x];
        }
        lz[x] = 0;
    }
 
    if (l > r || l > qr || r < ql)
        return -inf;
    if (l >= ql && r <= qr)
        return tr[x];

    int m = (l + r) / 2;
    return max(qry(2 * x, l, m, ql, qr), qry(2 * x + 1, m + 1, r, ql, qr));
}


pair<pair<int, int>, ll> q[N];
vector<int> st[N], ed[N];
signed main() {

    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, m; cin >> n >> m;
    for(int i = 1; i <= m; i++) {
        cin >> q[i].ft.ft >> q[i].ft.sd >> q[i].sd;
        q[i].ft.ft++; q[i].ft.sd++;
        st[q[i].ft.ft].pb(i);
        ed[q[i].ft.sd].pb(i);
    }
    n++;
    for(int i = 2; i <= n; i++) {
        for(int j: st[i]) {
            upd(1, 1, n, 1, q[j].ft.ft-1, q[j].sd);
        }
        f[i] = qry(1,1,n,1, i-1);
        upd(1,1,n,i,i,f[i]);
        for(int j: ed[i]) {
            upd(1,1,n, 1, q[j].ft.ft-1, -q[j].sd);
        }
    }
    ll ans = 0;
    // cout << f[2] << endl;
    for(int i = 1; i <= n; i++) ans = max(ans, f[i]);
    cout << ans << "\n";
    
    return 0;
}

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a==b && b==c) cout << 1 << endl;
  else if(a!=b && b!=c && c!=a) cout << 3 << endl;
  else cout << 2 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		int a=scn.nextInt();
		int b=scn.nextInt();
		System.out.println(b%a==0?a+b:b-a);
	}

}


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

int main(){
  int N;
  cin >> N;
  int sum = 0;
  for(int i = 0; i<N; i++){
    int l,r;
    cin >> l >> r;
    sum += (r-l)+1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3608
using System;
using System.Collections.Generic;
using System.Linq;

namespace template
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // ここに処理を書く
            var alist = Enumerable.Range(0, cin.ReadInt + 1);
            var blist = Enumerable.Range(0, cin.ReadInt + 1);
            var clist = Enumerable.Range(0, cin.ReadInt + 1);
            var x = cin.ReadInt;

            var cnt = alist.SelectMany(a => 
                                blist.SelectMany(b => 
                                    clist.Select(c => 500*a + 100*b + 50*c)))
                           .Count(r => r == x);

            Console.WriteLine(cnt);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) 
                {
                    return inputStream.Dequeue();
                }

                string[] tmp = _stream.ReadLine().Split(_separator);
                
                for (int i = 0; i < tmp.Length; ++i)
                {
                    inputStream.Enqueue(tmp[i]);
                }
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


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

int main()
{
	int ans{-1}, N;
	scanf("%d", &N);
	for (int i{1}; i <= N; i++)
		if ((int)(i * 1.08) == N)
			ans = i;
	if (ans >= 0) printf("%d\n", ans);
	else puts(":(");

	return 0;
}

Measured memory_bytes: 256
import itertools

def fibonacci(n):
    if (n == 0):
        f_n = 1
    elif (n == 1):
        f_n = 1
    else:
        f_n = fibonacci(n-1) + fibonacci(n-2)

    return f_n

def X_amida_number(W, W_i):
    x_amida = "0" * (W - 1)
    left_x_amida = x_amida[:(W_i-2)] if(W_i-2 >= 0) else ""
    right_x_amida = x_amida[(W_i+1):]

    return fibonacci(len(left_x_amida) + 1) * fibonacci(len(right_x_amida) + 1)

def Y_amida_number(W, W_i):
    y_amida = "0" * (W - 1)
    left_y_amida = y_amida[:W_i-1] if(W_i-1 >= 0) else ""
    right_y_amida = y_amida[W_i+1:]

    return fibonacci(len(left_y_amida) + 1) * fibonacci(len(right_y_amida) + 1)

def Z_amida_number(W, W_i):
    z_amida = "0" * (W - 1)
    left_z_amida = z_amida[:W_i-1] if(W_i-1 >= 0) else ""
    right_z_amida = z_amida[W_i+2:]

    return fibonacci(len(left_z_amida) + 1) * fibonacci(len(right_z_amida) + 1)

def amida_all(amida_list, W):
    for i, j in itertools.product(range(W), range(3)):
        if(j == 0):
            amida_list[i][j] = X_amida_number(W, i)
        elif(j == 1):
            amida_list[i][j] = Y_amida_number(W, i)
        else:
            amida_list[i][j] = Z_amida_number(W, i)

    return amida_list

H, W, K = map(int, input().split())
amida_list = [[0]*3 for i in range(W)]
amida_list = amida_all(amida_list, W)

dp_array = [0 for i in range(W)]
dp_array[0] = 1

for H_i in range(1, H + 1):
    new_dp_array = [0 for i in range(W)]
    for W_i in  range(W):
        if (W_i == 0):
            if(W == 1):
                new_dp_array[0] = dp_array[0] * amida_list[0][1]
            else:
                new_dp_array[0] = dp_array[0] * amida_list[0][1] + dp_array[1] * amida_list[0][2]
        elif (W_i == (W - 1)):
            new_dp_array[W - 1] = dp_array[W_i - 1] * amida_list[W_i][0] + dp_array[W_i] * amida_list[W_i][1]
        else:
            new_dp_array[W_i] = dp_array[W_i - 1] * amida_list[W_i][0] + dp_array[W_i] * amida_list[W_i][1] + dp_array[W_i + 1] * amida_list[W_i][2]
    dp_array = list(new_dp_array)

print(dp_array[K - 1] % 1000000007)

Measured memory_bytes: 3192
import sys

N = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if N == 1:
    print(0)
    sys.exit()

f = factorization(N)

result = 0
for p, e in f:
    i = 1
    while True:
        e -= i
        if e < 0:
            break
        result += 1
        i += 1

print(result)

Measured memory_bytes: 9472
/*
ID: Aman Raj
LANG: C++
TASK: prefix
*/
#include<iostream>
#include <stdio.h>
//#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<math.h>
typedef  long long int ll;
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
//#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define flush fflush(stdout)
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <fstream>
// find_by_order()  // order_of_key
typedef tree<
	int,
	null_type,
	less<int>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;


   int main()
{

      ll n,m;cin>>n>>m;
        vector<ll> s(n),t(m);
        for(ll i=0;i<n;i++)cin>>s[i];
        for(ll i=0;i<m;i++)cin>>t[i];
        vector<vector<ll> > dp(n+1);
        dp[0].resize(m+1,1);
        for(ll i=1;i<=n;i++)
        {
            dp[i].resize(m+1);
             dp[i][0]=1;
             for(ll j=1;j<=m;j++)
             {
                 if(s[i-1]==t[j-1])
                     dp[i][j]=dp[i-1][j]+dp[i][j-1];
                 else dp[i][j]=dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1];
                 dp[i][j]+=mod;
                 (dp[i][j])%=mod;
             }
        }
        cout<<dp[n][m];



    return 0;
 }




Measured memory_bytes: 31616
import java.util.Scanner;

public class Main{
    public static void Compare(int x, int y){
        if(x > y){
            System.out.println("a > b");
        }else if(x < y){
            System.out.println("a < b");
        }else{
            System.out.println("a == b");
        }
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        Compare(a, b);
    }
}


Measured memory_bytes: 26136
import math
import copy

inputa = input().split()
# inputb = input().split()

# a = int(inputa[0])
# b = int(inputa[1])
# c = int(inputa[2])

a = inputa[0]
inputList = list(a)

# x = int(inputb[0])
# y = int(inputb[1])

# inputList=[]
# for i in range(a):
#     inputNum = input()
#     inputList.append(inputNum)

tmptop = [inputList[0], inputList[1]]
tmpjointop = "".join(tmptop)
top = int(tmpjointop)

tmpbottom = [inputList[2], inputList[3]]
tmpjoinbottom = "".join(tmpbottom)
bottom = int(tmpjoinbottom)

flgFrontMM = True
flgTermMM = True

if top > 12 or top == 0:
    flgFrontMM = False

if bottom > 12 or bottom == 0:
    flgTermMM = False

if flgFrontMM and flgTermMM:
    print("AMBIGUOUS")
elif flgFrontMM == False and flgTermMM == False:
    print("NA")
elif flgFrontMM:
    print("MMYY")
elif flgTermMM:
    print("YYMM")

Measured memory_bytes: 38256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <ctime>
#define ll long long
#define inf 0x3f3f3f3f
#define N 200010
#define mod 1000000007
#define int long long
//ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int a[N];

signed main(){
	int n,sum=0;
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
    {
        scanf("%lld",a+i);
        sum=(sum+a[i])%mod;
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        ans=(ans+a[i]*(sum+mod-a[i]))%mod;
    }
    ans=ans*500000004%mod;
    printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 5352