akhauriyash/Code-Regression huggingface dataset:
from math import gcd
def gc(a,b,c):
    return gcd(gcd(a,b),c)
k=int(input())
ans=0
for a in range(1,k+1):
    for b in range(1,a+1):
        for c in range(1,b+1):
            x=gc(a,b,c)
            if a!=b and b!=c and c!=a:
                ans+=6*x
            elif a==b and b==c:
                ans+=x
            else:
                ans+=3*x
print(ans)
                    
                    


Measured memory_bytes: 9132
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
  
int main()
{
  ll N;
  cin >> N;
  ll a = 1;
  REP(i,N){
    a=((i+1)*a)%MOD;
  }

  cout << a << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7,inv2=(mod+1)/2;
int n,q,a[4001],dp[4001][4001];
int main() {
	cin>>n>>q; for(int i=1;i<=n;i++)cin>>a[i]; for(int i=1;i<=n;i++) for(int j=1;j<=n;j++)dp[i][j]=(a[i]>a[j]);
	for(int k=1,x,y;k<=q;k++) {
		cin>>x>>y; dp[x][y]=dp[y][x]=1ll*inv2*(dp[x][y]+dp[y][x])%mod;
		for(int i=1;i<=n;i++) if(i!=x&&i!=y)dp[i][x]=dp[i][y]=1ll*inv2*(dp[i][x]+dp[i][y])%mod,dp[x][i]=dp[y][i]=1ll*inv2*(dp[x][i]+dp[y][i])%mod;
	}
	long long ans=0; for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++)ans+=dp[i][j]; while(q--)ans=ans*2%mod;
	cout<<ans<<'\n';
}

Measured memory_bytes: 47360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=55,INF=1<<30;
int H,W;
int cnt;
int state[MAX][MAX];
vector<int> dx={1,0,-1,0,1,1,-1,-1},dy={0,-1,0,1,1,-1,1,-1};

void DFS(int us,int ut){
    for(int i=0;i<8;i++){
        if(0<=us+dx[i]&&us+dx[i]<H&&0<=ut+dy[i]&&ut+dy[i]<W){
            if(state[us+dx[i]][ut+dy[i]]==0){
                state[us+dx[i]][ut+dy[i]]=1;
                DFS(us+dx[i],ut+dy[i]);
            }
        }
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        cin>>W>>H;
        if(H==0&&W==0) break;
        
        cnt=0;
        memset(state,0,sizeof(state));
        
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                int x;cin>>x;
                if(x==0) state[i][j]=1;
            }
        }
        
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(state[i][j]==0){
                    state[i][j]=1;
                    cnt++;
                    DFS(i,j);
                }
            }
        }
        
        cout<<cnt<<endl;
    }
}



Measured memory_bytes: 3120
#include <iostream>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int n,m;    cin >> n >> m;
    if(n == m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#pragma comment(linker, "/stack:640000000")
#include <bits/stdc++.h>
using namespace std;

const double EPS = 1e-9;
const int INF = 0x7f7f7f7f;
const double PI=acos(-1.0);

#define    READ(f) 	         freopen(f, "r", stdin)
#define    WRITE(f)   	     freopen(f, "w", stdout)
#define    MP(x, y) 	     make_pair(x, y)
#define    PB(x)             push_back(x)
#define    rep(i,n)          for(int i = 1 ; i<=(n) ; i++)
#define    repI(i,n)         for(int i = 0 ; i<(n) ; i++)
#define    FOR(i,L,R) 	     for (int i = L; i <= R; i++)
#define    ROF(i,L,R) 	     for (int i = L; i >= R; i--)
#define    FOREACH(i,t)      for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define    ALL(p) 	         p.begin(),p.end()
#define    ALLR(p) 	         p.rbegin(),p.rend()
#define    SET(p) 	         memset(p, -1, sizeof(p))
#define    CLR(p)            memset(p, 0, sizeof(p))
#define    MEM(p, v)         memset(p, v, sizeof(p))
#define    getI(a) 	         scanf("%d", &a)
#define    getII(a,b) 	     scanf("%d%d", &a, &b)
#define    getIII(a,b,c)     scanf("%d%d%d", &a, &b, &c)
#define    getL(a)           scanf("%lld",&a)
#define    getLL(a,b)        scanf("%lld%lld",&a,&b)
#define    getLLL(a,b,c)     scanf("%lld%lld%lld",&a,&b,&c)
#define    getC(n)           scanf("%c",&n)
#define    getF(n)           scanf("%lf",&n)
#define    getS(n)           scanf("%s",n)
#define    bitCheck(a,k)     ((bool)(a&(1<<(k))))
#define    bitOff(a,k)       (a&(~(1<<(k))))
#define    bitOn(a,k)        (a|(1<<(k)))
#define    bitFlip(a,k)      (a^(1<<(k)))
#define    iseq(a,b)         (fabs(a-b)<EPS)
#define    vi 	 vector < int >
#define    vii 	 vector < vector < int > >
#define    pii 	 pair< int, int >
#define    ff 	 first
#define    ss 	 second
#define    ll	 long long
#define    ull 	 unsigned long long
#define    POPCOUNT           __builtin_popcount
#define    POPCOUNTLL         __builtin_popcountll
#define    RIGHTMOST          __builtin_ctzll
#define    LEFTMOST(x)        (63-__builtin_clzll((x)))
#define    UNIQUE(V) (V).erase(unique((V).begin(),(V).end()),(V).end())

template< class T > inline T gcd(T a, T b) { return (b) == 0 ? (a) : gcd((b), ((a) % (b))); }
template< class T > inline T lcm(T a, T b) { return ((a) / gcd((a), (b)) * (b)); }
template <typename T> string NumberToString ( T Number ) { ostringstream ss; ss << Number; return ss.str(); }

#ifdef mamun
     #define debug(args...) {cerr<<"*: "; dbg,args; cerr<<endl;}
#else
    #define debug(args...)  // Just strip off all debug tokens
#endif

struct debugger{
    template<typename T> debugger& operator , (const T& v){
        cerr<<v<<" ";
        return *this;
    }
}dbg;
///****************** template ends here ****************
int t,n,m;


int main() {
    ///check for 0 or -1 if input not specified
    #ifdef mamun
//        READ("in.txt");
//        WRITE("out.txt");
    #endif // mamun
//    ios_base::sync_with_stdio(0);cin.tie(0);

    string s;
    while(cin >> s)
    {
        string tmp = s;
        reverse(ALL(tmp));
        if(s == tmp)puts("Yes");
        else puts("No");
    }

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
        int x,i,j,a;
        double rt;

        scanf("%d",&x);

        a=0;
        for(i=x;i>0;i++){
                rt=sqrt((double)x);
                j=2;
                while((i%j)!=0 && (j<=rt)) j++;

                if(j>rt){
                        printf("%d",i);
                        return 0;
                }
        }
}


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

class HashTable(list):
    def __init__(self, length):
        list.__init__(self)
        self.length = length
        self[:] = [None] * length

    def h(self, key, i):
        h1 = key % self.length
        h2 = 1 + (key % (self.length - 1))
        return (h1 + i*h2) % self.length

    def insert(self, key):
        i = 0
        while True:
            h1 = key % self.length
            h2 = 1 + (key % (self.length - 1))
            j = (h1 + i*h2) % self.length
            #j = self.h(key, i) # slow...
            if self[j] is None:
                self[j] = key
                return j
            else:
                i += 1
    
    def search(self, key):
        i = 0
        while True:
            h1 = key % self.length
            h2 = 1 + (key % (self.length - 1))
            j = (h1 + i*h2) % self.length
            #j = self.h(key, i) # slow...
            if self[j] == key:
                return j
            elif self[j] is None or i >= self.length:
                return None
            else:
                i += 1

def getNum(char):
    char2num = str.maketrans("ACGT", "1234")
    return int(char.translate(char2num), 5)

if __name__ == '__main__':

    n = int(input())
    T = HashTable(1046527)
    C = [input().split(" ") for i in range(n)]
    
    for command, char in C:
        num = getNum(char)
        if command[0] == "i":
            T.insert(num)
        else:
            if T.search(num) is None:
                print("no")
            else:
                print("yes")


Measured memory_bytes: 317140
#include<iostream>
using namespace std;

int main(void){
        int n, a, b;
        cin >> n >> a >> b;
        int max = a;
        if (max > b) max = b;
        int min = a + b - n;
        if (min < 0) min = 0;
        cout << max << " " << min << endl;
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int p[200];
int main(){
	int n;cin>>n;
	rep(i,n){
		cin>>p[i];p[i]--;
	}
	rep(i,n)rep(j,n){
		swap(p[i],p[j]);
		bool ok=true;
		rep(k,n){
			if(p[k]!=k){ok=false;}
		}
		if(ok){
			puts("YES");return 0;
		}
		swap(p[i],p[j]);
	}
	puts("NO");
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int dp[11][2][2][2][2];
int main()
{
	string a;
	cin >> a;
	int s = a.length();
	dp[0][0][0][0][0] = 1;
	for(int i = 0; i < s; ++i)
	{
		for(int j = 0; j < 2; ++j)
		{
			for(int k = 0; k < 2; ++k)
			{
				for(int l = 0; l < 2; ++l)
				{
					for(int m = 0, lim; m < 2; ++m)
					{
						lim = m ? 9 : a[i] - '0';
						if(3 <= lim)
						{
							dp[i + 1][1][k][l][m || 3 < lim] += dp[i][j][k][l][m];
						}
						if(5 <= lim)
						{
							dp[i + 1][j][1][l][m || 5 < lim] += dp[i][j][k][l][m];
						}
						if(7 <= lim)
						{
							dp[i + 1][j][k][1][m || 7 < lim] += dp[i][j][k][l][m];
						}
					}
				}
			}
		}
		dp[i + 1][0][0][0][1] += dp[i][0][0][0][0];
		dp[i + 1][0][0][0][1] += dp[i][0][0][0][1];
	}
	printf("%d\n", dp[s][1][1][1][0] + dp[s][1][1][1][1]);
}

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


int main() {
  ll H,W;
  cin>>H>>W;
  vector<string> vec(H);
  for(ll i=0;i<H;i++) {
cin>>vec[i];
  }
  
vector<vector<ll>> A(H,vector<ll> (W+2,0));
  for(ll i=0;i<H;i++) {
ll count=0;
    for(ll j=1;j<W+1;j++) {
if(vec[i][j-1]=='#') {
count++;
}
      A[i][j]=count;
    }
    A[i][W+1]=count+1;
  }
  
  
  vector<vector<ll>> B(W,vector<ll>(H+2,0));
  for(ll i=0;i<W;i++) {
    ll count=0;
    for(ll j=1;j<H+1;j++) {
      if(vec[j-1][i]=='#') {
count++;
      }
      B[i][j]=count;
    }
    B[i][H+1]=count+1;
  }
  
  ll ans=0;
  for(ll i=0;i<H;i++) {
for(ll j=0;j<W;j++) {
if(vec[i][j]=='#') {
continue;
}
  ll p=lower_bound(all(A[i]),A[i][j+1]+1)-lower_bound(all(A[i]),A[i][j+1])-1;
  ll q=lower_bound(all(B[j]),B[j][i+1]+1)-lower_bound(all(B[j]),B[j][i+1])-1;
  ans=max(ans,p+q-1);
}
  }
  
  cout<<ans<<endl;
}


  

Measured memory_bytes: 73460
#include <bits/stdc++.h>
using namespace std;
int a[100005];
vector<int> adjlist[100005];
int ans[100005];
bool cmp(int a, int b){
    return ans[a] > ans[b];
}
void dfs(int u){
    ans[u] = 0;
    for (auto v : adjlist[u]){
        dfs(v);
    }
    sort(adjlist[u].begin(),adjlist[u].end(),cmp);
    int ct = 1;
    for (auto v : adjlist[u]){
        //printf("%d -> %d: %d + %d\n",u,v,ans[v],ct);
        ans[u] = max(ans[u],ans[v]+ct++);
    }
}
int main(){
    int n;
    scanf("%d",&n);
    for (int i = 2; i <= n; i++){
        scanf("%d",&a[i]);
        adjlist[a[i]].push_back(i);
    }
    dfs(1);
    printf("%d",ans[1]);
}


Measured memory_bytes: 12800
#include <iostream>
#include <string>
#include<vector>
#include <algorithm>
using namespace std;
#define ll long long
const int INF = 1e9 + 5;

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    int n, k;
    cin >> n >> k;
    vector<int> v(n, 0);
    vector<int> dp(n, INF);
    
    for(int i=0; i<n; i++){
        cin >> v[i];
    } 
    dp[0] = 0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<= i+k; j++){
            if(j>=n) break;
            dp[j] = min(dp[j], dp[i] + abs(v[i]-v[j]));
            //cout << i << " " << j << " " <<  dp[j] << endl;
        }
    }
    //for(int i=0; i<n; i++) cout << dp[i] << endl;
    cout << dp[n-1];
   return 0;
}

Measured memory_bytes: 4048
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100005

struct LOC{
	void set(int arg_row,int arg_col){
		row = arg_row;
		col = arg_col;
	}
	int row,col;
};

int LENGTH;
int min_change;

int table_index;
int table[362880][9];
int tmp_array[9],phone[3][3],ans[3][3],adj[10][10];
bool used[10];
char buf[NUM];
LOC loc[10];

void recursive(int index){

	if(index == 9){

		for(int i = 0; i < 9; i++){
			table[table_index][i] = tmp_array[i];
		}
		table_index++;

		return;
	}

	for(int i = 1; i <= 9; i++){

		if(used[i])continue;
		tmp_array[index] = i;
		used[i] = true;
		recursive(index+1);
		used[i] = false;
	}
}

void calc(int num_index){

	int index = 0;

	//電話を作成
	for(int row = 0; row < 3; row++){
		for(int col = 0; col < 3; col++){
			phone[row][col] = table[num_index][index++];
			loc[phone[row][col]].set(row,col);
		}
	}

	int count = 0;
	//指は最初の数字に合わせておく

	for(int i = 1; i <= 9; i++){
		for(int k = 1; k <= 9; k++){
			count += (abs(loc[i].row-loc[k].row)+abs(loc[i].col-loc[k].col))*adj[i][k];
		}
	}

	if(count < min_change){
		for(int row = 0; row < 3; row++){
			for(int col = 0; col < 3; col++){
				ans[row][col] = phone[row][col];
			}
		}
		min_change = count;
	}
}



int main(){

	scanf("%d",&LENGTH);
	scanf("%s",buf);

	for(int i = 1; i <= 9; i++){
		for(int k = 1; k <= 9; k++){
			adj[i][k] = 0;
		}
	}

	//隣接回数を数える
	for(int i = 1; i < LENGTH; i++){

		adj[buf[i]-'0'][buf[i-1]-'0']++;
	}

	table_index = 0;

	for(int i = 1; i <= 9; i++)used[i] = false;

	//9!の数列を作る
	for(int i = 1; i <= 9; i++){

		tmp_array[0] = i;
		used[i] = true;
		recursive(1);

		used[i] = false;
	}

	min_change = BIG_NUM;

	for(int i = 0; i < table_index; i++){

		calc(i);
	}


	for(int row = 0; row < 3; row++){
		for(int col = 0; col < 3; col++){
			printf("%d",ans[row][col]);
		}
		printf("\n");
	}


	return 0;
}




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

template <class T>
inline void read(T &x)
{
    static char c;
    x=0;
    for(c=getchar();isspace(c);c=getchar());
    static bool sign;
    sign=0;
    if (c=='-') sign=!sign,c=getchar();
    for(;isdigit(c);x=x*10+c-'0',c=getchar());
    if (sign) x=-x;
    return;
}

#ifndef DEBUG//-DDEBUG
#define SHOW(x)
#else
#define SHOW(x) cout<<#x"="<<(x)<<endl
#endif

const int MAXN=2e3+5;
ll a[MAXN<<1];
ll best[MAXN];
const ll INF=1LL<<50;
int main()
{
	int n;
	ll x;
	scanf("%d%lld",&n,&x);
	for (int i=1;i<=n;i++)
	{
		read(a[i]);
		a[i+n]=a[i];
	}
	ll ans=INF;
	memset(best,15,sizeof(best));
	for (int ev=0;ev<n;ev++)
	{
		ll sum=ev*x;
		for (int i=1;i<=n;i++)
		{
			best[i]=min(best[i],a[i+ev]);
			sum+=best[i];
		}
		ans=min(ans,sum);
	}
	printf("%lld",ans);
    return 0;
}

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

using namespace std;
int main()
{
    while (true) {
        int N;
        cin >> N;
        if (N == 0) {
            break;
        }
        vector<int> x;
        vector<int> y;
        x.push_back(0);
        y.push_back(0);

        for (int i = 0; i < N - 1; i++) {
            int n, d;
            cin >> n >> d;
            const int sx = x[n];
            const int sy = y[n];
            if (d == 0) {
                x.push_back(sx - 1);
                y.push_back(sy);
            } else if (d == 1) {
                x.push_back(sx);
                y.push_back(sy - 1);
            } else if (d == 2) {
                x.push_back(sx + 1);
                y.push_back(sy);
            } else {
                x.push_back(sx);
                y.push_back(sy + 1);
            }
        }
        sort(x.begin(), x.end());
        sort(y.begin(), y.end());
        cout << x[N - 1] - x[0] + 1 << " " << y[N - 1] - y[0] + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3000
/*      ░░█ ▄▀█ █   █▀ █░█ █▀█ █▀▀ █▀▀   █▀█ ▄▀█ █▀▄▀█
        █▄█ █▀█ █   ▄█ █▀█ █▀▄ ██▄ ██▄   █▀▄ █▀█ █░▀░█     */

// Author : Udit "luctivud" Gupta @ (https://www.linkedin.com/in/udit-gupta-1b7863135/)


#include <bits/stdc++.h>
#pragma GCC optimize "trapv"

using namespace std;

typedef long long int lld;
typedef unsigned long long int llu;


#define       TESTCASES()  cin >> (T3X0); T353 = T3X0; while(T3X0--)
#define       _input(V3C)  for(auto &V3C_I7 : (V3C)) cin >> (V3C_I7)
#define mems(A77AY, V4LU)  memset((A77AY), (V4LU), sizeof((A77AY)))
#define  CH3K(I7, E4, S7)  (((S7)<0) ? (I7)>(E4) : (I7)<(E4))
#define for4(I7,S4,E4,S7)  for(auto I7=(S4); CH3K(I7,E4,S7); (I7)+=(S7))




void solveEachTest(lld T35TC453N = 1) {

    lld a, b, k; cin >> a >> b >> k;
    lld g = __gcd(a, b);

    for4(i, g, 0, -1) {
        if (g % i == 0 ) k--;
        if (k == 0) {
            cout  << i ;
            return;
        }
    }

    cout << "\n";

    return;
}


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

    lld T3X0 = 0, T353 = 1;

    // TESTCASES()
    solveEachTest(T353 - T3X0);
    return 0;
}
// Random Thought :  null

Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define endl "\n"
#define fcout cout<<fixed<<setprecision(15)
typedef pair<int, int> P;
//struct edge { int to, cost; };

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

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

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int modinv2(int a, int mod) {
    return mod_pow(a, mod - 2, mod);
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k, int mod) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= mod;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }
    return x * modinv(y, mod) % mod;
}

signed main() {
    //srand((unsigned)time(NULL));

    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n, ans = 0;
    cin >> n;
    map<int, int>mp = factaring(n);
    for (auto x : mp) {
        if (x.second > 0) {
            for (int i = 1;; i++) {
                if (x.second < i) break;
                ans++;
                x.second -= i;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3680
//
// Created by Tzyark on 2018/10/10.
//
#include <iostream>
#include <set>
using namespace std;
int main() {
    set<char> vowel;
    vowel.clear();
    vowel.insert('a');
    vowel.insert('e');
    vowel.insert('i');
    vowel.insert('o');
    vowel.insert('u');
    char c;
    cin >> c;
    cout << (vowel.count(c) > 0 ? "vowel" : "consonant");
    return 0;
}


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

void input()
{
}

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

    string a, b, c;
    for (int i = 0; i < (int)s.size(); i++)
    {
        a = b = c = "";
        a = s.substr(0, i);
        for (int j = i + 1; j < (int)s.size(); j++)
        {
            b = s.substr(i, j);
            c = s.substr(j + 1, s.size() - 1);
            if (a + b == "keyence" || b + c == "keyence" || a + c == "keyence")
            {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
}

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

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

  int a;
  cin >> a;
  cout << a + a * a + a * a * a << endl;

  return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=1000000000000001;
const double PI=3.141592653589;


int main(){
  string s,t; cin>>s>>t;

  // int r=s.size()-1;
  // string rs;
  // rep(i,s.size()){
  //   rs+=s[s.size()-1-i];
  // }
  // cout<<"rs "<<rs<<endl;

  rep(i,s.size()){
    string s1=s.substr(0,s.size()-i);
    string s2=s.substr(s.size()-i,i);
    // cout<<s2+s1<<endl;
    if(s2+s1==t){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;

  return 0;
}


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

#define ll long long
using namespace std;

int main() {
	ll a,b,c,d; cin >> a >> b >> c >> d;
  	
  	ll x = a*c, y = b*d, x1 = a*d, y1 = b*c;
  	cout << max(max(x,y), max(x1,y1));
  	return 0;
}

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


int main() {
    int N;
    int s;
    cin >> N;
    vector<string> W(N); cin >> W.at(0);
    s = W.at(0).size();
    for(int i=0;i<N-1;++i){
      cin >> W.at(i+1);
      if(W.at(i).at(s-1) != W.at(i+1).at(0)){
        cout << "No" << endl;
        return 0;
      }
      for(int j=0;j<i+1;++j){
        if(W.at(i+1) == W.at(j)){
          cout << "No" << endl;
          return 0;
        }
      }
      s = W.at(i+1).size();
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3584
a,b,c,x,y = map(int,input().split())
ans = 0
if 2*c<=min(a,b):
  ans = c*max(x,y)*2
elif 2*c<=max(a,b):
  if a>b and x>y:
    ans = c*x*2
  elif a<=b and x<=y:
    ans = c*y*2
  elif a>b and x<=y:
    ans = c*x*2+b*(y-x)
  elif a<=b and x>y:
    ans = c*y*2+a*(x-y)
  else:
    ans = c*y*2+a*(x-y)
elif 2*c<=a+b:
  if x>y:
    ans = c*y*2+a*(x-y)
  else:
    ans = c*x*2+b*(y-x)
else:
  ans = a*x+b*y
print(ans)

Measured memory_bytes: 3064
#!/usr/bin/env python3
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
import sys


def solve(S: str):
    if S == 'ABC':
        print('ARC')
        return
    print('ABC')


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


if __name__ == '__main__':
    main()


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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int K; cin >> K;
    int num = 7;
    rep(i, 1000000){
        if(num % K == 0){
            cout << i+1 << endl;
            return 0;
        }
        num = (num*10 + 7) % K;
    }
    cout << -1 << endl;
    return 0;
}

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

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

  vector<int> a(4);
  for (int i = 3; i >= 0; i--) {
    a[i] = N % 10;
    N /= 10;
  }

  for (int bit = 0; bit < (1<<3); bit++) {
    char op[3];
    int total = a[0];
    for (int i = 0; i < 3; i++) {
      if (bit & (1<<i)) {
        total += a[i+1];
        op[i] = '+';
      }
      else {
        total -= a[i+1];
        op[i] = '-';
      }
    }
    if (total == 7) {
      cout << a[0];
      for (int i = 0; i < 3; i++) {
        cout << op[i] << a[i+1];
      }
      cout << "=7" << endl;
      return 0;
    }
    else total = 0;
  }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


class UnionFind:
    def __init__(self, n):
        self._parents = list(range(n))
        self._ranks = [0] * n
        self._size = [1] * n

    def root(self, x):
        if self._parents[x] == x:
            return x
        self._parents[x] = self.root(self._parents[x])
        return self._parents[x]

    def size(self, x):
        return self._size[self.root(x)]

    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry:
            return

        if self._ranks[rx] < self._ranks[ry]:
            self._parents[rx] = ry
            self._size[ry] += self._size[rx]
        else:
            self._parents[ry] = rx
            self._size[rx] += self._size[ry]
            if self._ranks[rx] == self._ranks[ry]:
                self._ranks[rx] += 1

    def same(self, x, y):
        return self.root(x) == self.root(y)



def solve(N: int, M: int, X: "List[int]", Y: "List[int]", Z: "List[int]"):
    uf = UnionFind(N)
    qq = UnionFind(N)

    for x, y, z in zip(X, Y, Z):
        x -= 1
        y -= 1
        uf.unite(x, y)
        #if (z % 2) == 0:
        #    uf.unite(x, y)
        #else:
        #    qq.unite(x, y)

    return len(set([uf.root(i) for i in range(N)]))


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
    M = int(next(tokens))  # type: int
    X = [int()] * (M)  # type: "List[int]" 
    Y = [int()] * (M)  # type: "List[int]" 
    Z = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        X[i] = int(next(tokens))
        Y[i] = int(next(tokens))
        Z[i] = int(next(tokens))
    result = solve(N, M, X, Y, Z)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 35024
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// How to use 「map」
/*
  - 宣言
    map<{key_type}, {value_type}> salary;
  - 要素の挿入
    salary["Alice"] = 1000;
  - 要素の取得 O(logn)
    salary.at("Alice");
  - 要素の削除
    salary.erase("Alice");
  - キー検索
    salary.find("Alice"); -> true
    salary.find("Bob");   -> false
  - イテレーション
    for(auto& [key, value] : salary) {...}
 */
// -------------------------------------


// How to use 「lower_bound」, 「upper_bound」
/*
  vector<int> a = {1, 2, 3, 4, 5};
  auto iter1 = lower_bound(all(a), 3);  <- 第二引数「以上」の最小イテレータが返る
  auto iter2 = upper_bound(all(a), 3);  <- 第二引数「より大きい」最小のイテレータが返る
 */
// -------------------------------------


// How to use 「struct sort」
/*
  struct Person {
    string name;
    int age;

    Person(string _name, int _age) {
      name = _name;
      age = _age;
    }

    bool operator<(const Person &another) const {
      return age < another.age;
    }
  };

  vector<Person> people;
  people.pb(Person("Alice", 20));
  people.pb(Person("Bob", 19));
  people.pb(Person("John", 40));
  people.pb(Person("Chris", 30));
  sort(all(people));
 */
 // -------------------------------------

// -------------------------------------------------------------------------------------


int main() {
  map<string, int> dic;

  int n;
  cin >> n;

  int m = 0;
  rep(i, n) {
    string s;
    cin >> s;

    if (dic.find(s) == end(dic)) {
      dic[s] = 1;
    } else {
      dic[s]++;
    }
    m = max(m, dic[s]);
  }

  vector<string> v;
  for(auto itr = dic.begin(); itr != dic.end(); ++itr) {
    if (itr->second == m) {
      v.pb(itr->first);
    }
  }

  sort(all(v));

  rep(i, v.size()) {
    cout << v[i] << endl;
  }

  return 0;
}

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

template<typename T>
istream &operator>>(istream &is, vector<T> &v) {
	for (auto &x : v) is >> x;
	return is;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	vector<array<int, 3>> a(n + 1);
	a[0][0] = 0;
	a[0][1] = 0;
	a[0][2] = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}
	for (int i = 1; i <= n; i++) {
		int t = a[i][0] - a[i - 1][0];
		int d = abs(a[i][1] - a[i - 1][1]) + abs(a[i][2] - a[i - 1][2]);
		if (!(d <= t && t % 2 == d % 2)) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}



Measured memory_bytes: 4504
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <cmath>
#include <functional>
#include <memory.h>

// pi = atan(1)*4;

#define INTMAX 2100000000

using namespace std;

int main(void)
{
	long long int n;
	stringstream ss;
	string s;
	int res = 0;

	cin >> s;
	res = s.length();
	n = stoll(s);


	for (int a = sqrt(n); a > 0; a--)
	{
		if (n%a == 0)
		{
			int b = n / a;
			ss << b;
			res = ss.str().length();
			break;
		}
	}
	cout << res << '\n';
	return 0;
}

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/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; }



int main(){
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  ll money = 1000;
  ll kabu = 0;
  rep(i,n-1) {
    money += kabu * a[i];
    kabu = 0;
    if(a[i] < a[i+1]) {
      kabu = money / a[i];
      money %= a[i];
    }
  }
  money += kabu * a[n-1];
  cout << money << endl;
}

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

int main(){
	ll n,W;
	cin>>n>>W;
	ll w[n],v[n];
	for(ll i=0;i<n;i++){
		cin>>w[i]>>v[i];
	}
	ll dp[n+1][W+1];
	for(ll i=0;i<=n;i++){
		for(ll j=0;j<=W;j++){
			if(i==0 || j==0){
				dp[i][j]=0;
			}
			else if(w[i-1]<=j){
				dp[i][j]=max(dp[i-1][j],v[i-1]+dp[i-1][j-w[i-1]]);
			}
			else{
				dp[i][j]=dp[i-1][j];
			}
		}
	}
	cout<<dp[n][W]<<endl;
}

Measured memory_bytes: 79104
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int l;
    cin >> l;
    int r = (int)log2(l);
    int n = r + 1;
    vector<pair<pair<int, int>, int>> ans;
    FOR(i, 1, n - 1) {
        ans.push_back(make_pair(make_pair(i, i + 1), 0));
        ans.push_back(make_pair(make_pair(i, i + 1), (int)pow(2, i - 1)));
    }
    int x = (int)pow(2, r);
    FORR(t, n - 1, 1) {
        if(x + (int)pow(2, t - 1) <= l) {
            ans.push_back(make_pair(make_pair(t, n), x));
            x += (int)pow(2, t - 1);
        }
    }

    cout << n << " " << ans.size() << endl;
    REP(i, ans.size()) {
        cout << ans[i].first.first << " ";
        cout << ans[i].first.second << " ";
        cout << ans[i].second << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX;
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;



int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	long double x,y;
	cin>>x>>y;
	cout<<floor(log2(y)-log2(x))+1<<endl;
	
	
	
	
	
	
//////////////////////////////////////////////////////
	return 0;
}


Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	static char[] ch;
	static int id;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for(int T = sc.nextInt(); T-- > 0; ) {
			ch = sc.next().toCharArray();
			id = 0;
			
			System.out.println(exp());
		}

		sc.close();
	}

	static int exp() {
		id++;
		if(Character.isDigit(ch[id])) {
			int num = num();
			id++;
			return num;
		}
		
		List<Integer> list = new ArrayList<Integer>();

		for(;;) {
			if(ch[id] == '[') {
				list.add(exp());
			} else {
				break;
			}
		}

		id++;
		Collections.sort(list);
		int num = 0;
		for(int i = 0; i < (list.size() + 1) / 2; i++) {
			num += list.get(i);
		}
		
		return num;
	}

	static int num() {
		int x = 0;
		while(Character.isDigit(ch[id])) {
			x *= 10;
			x += ch[id++] - '0';
		}
		
		x++;
		return x / 2;
	}
}

Measured memory_bytes: 53692
def merge_sort(array, left, right)
	return 0 unless left + 1 < right
	mid = (left + right) / 2
	compared_count  = merge_sort(array, left, mid)
	compared_count += merge_sort(array, mid, right)
	compared_count += merge(array, left, mid, right)
	compared_count
end

def merge(array, left, mid, right)
	left_array_size  = mid - left
	right_array_size = right - mid

	left_array  = []
	left_array_size.times { |i| left_array << array[left + i] }

	right_array = []
	right_array_size.times { |i| right_array << array[mid + i] }

	# 下記のループでの番兵をセット(最後は必ず片方がnilになるため)
	left_array  << Float::INFINITY
	right_array << Float::INFINITY

	compared_count = 0
	i = j = 0
	(left...right).each do |k|
		if left_array[i] <= right_array[j]
			array[k] = left_array[i]
			i += 1
		else
			array[k] = right_array[j]
			j += 1
		end
		compared_count += 1
	end
	compared_count
end

array_size = STDIN.gets.to_i
array = STDIN.gets.split[0...array_size].map(&:to_i)
compared_count = merge_sort(array, 0, array_size)
puts array.join(" ")
puts compared_count

Measured memory_bytes: 171112
bingo = []
for _ in range(3):
    bingo.append(list(map(int, input().split(' '))))

n = int(input())
for _ in range(n):
    val = int(input())
    for i in range(3):
        try:
            index = bingo[i].index(val)
        except ValueError:
            pass
        else:
            bingo[i][index] = None
if bingo[0][0] == bingo[1][1] == bingo[2][2] == None:
    print("Yes")
elif bingo[0][2] == bingo[1][1] == bingo[2][0] == None:
    print("Yes")
else:
    tmp = True
    for i in range(3):
        if bingo[0][i] == bingo[1][i] == bingo[2][i] == None:
            print("Yes")
            tmp = False
            break
        if bingo[i][0] == bingo[i][1] == bingo[i][2] == None:
            print("Yes")
            tmp = False
            break

    if tmp:
        print("No")


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

signed main(){
  int a,b,c,d,p,q,r,s; cin>>a>>b>>c>>d;
  p=a*c;
  q=a*d;
  r=b*c;
  s=b*d;
  cout<<max(p,max(q,max(r,s)))<<endl;
}

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

int main(){
	vector<char> S(4);
	for(int i = 0; i < 4; i++) cin >> S[i];
	sort(S.begin(), S.end());
	if(S[0] == S[1] && S[1] != S[2] && S[2] == S[3]) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
const int maxn=1000010;
double f[maxn];
int main()
{
	double n,t,a;
	double ans,ansn=19260817;
	cin>>n>>t>>a;
	for(int i=1;i<=n;i++){
		cin>>f[i];
		if(abs(t-f[i]*0.006-a)<ansn){
			ansn=abs(t-f[i]*0.006-a);
			ans=i;
		}
	}
	printf("%d\n",(int)ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=998244353;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }
    long long mins(long long a, long long b){
        return mod(mod(a)-mod(b));
    }
 
    ll modPow(ll a, ll b){
        if(b==0)
            return 1LL;
        if(b==1)
            return a%M;
        ll res=1;
        while(b){
            if(b%2==1)
                res=mul(res,a);
            a=mul(a,a);
            b=b/2;
        }
        return res;
    }
    vector<ll>a(200005);
    vector<pair<ll,ll>>seg(12);
    void solve (){
        ll n,k;
        cin>>n>>k;
        for(int i=0;i<k;i++){
            cin>>seg[i].first>>seg[i].second;
        }
        vector<ll>dp(n+1) , psum(n+1);
        psum[1]=1;
        for(int i=1;i<=n;i++){
            if(i>2)
                psum[i]=add(psum[i],psum[i-1]);
            psum[i]=add(psum[i],dp[i]);
            for(int j=0;j<k;j++){
                if(i+seg[j].first <=n) dp[i+seg[j].first]=add(dp[i+seg[j].first],psum[i]);
                if(i+seg[j].second+1 <=n) dp[i+seg[j].second+1]=mins(dp[i+seg[j].second+1],psum[i]);
            }
        }
        cout<<psum[n];
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }

Measured memory_bytes: 7960
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static String arr ="abcdefghijklmnopqrstuvwxyz";
    static char alArr[] = arr.toCharArray();
    public static void main(String[] args) {
        String str = "";
        while (sc.hasNext()){
            String aa =  sc.next();
            str += aa;
        }
        str = str.toLowerCase();
        char strarr[] = str.toCharArray();
        for (int i = 0; i < arr.length(); i++){
            int count = 0;
            for (int j = 0; j < str.length(); j++){
                if(strarr[j]==alArr[i]){
                     count++;
                 }
            }
            System.out.println(alArr[i] + " : " + count);
        }
    }
}



Measured memory_bytes: 26728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    string s, t;
    cin >> s >> t;
    vector<vector<ll>> dp(s.size()+3, vector<ll>(t.size()+3, 0));
    dp.at(0).at(0) = 0;
    for(int i = 1; i <= s.size(); i++){
        for(int j = 1; j <= t.size(); j++){
            if (s.at(i-1) == t.at(j-1)){
                dp.at(i).at(j) = dp.at(i - 1).at(j - 1) + 1;
            }
            else{
                dp.at(i).at(j) = max(dp.at(i - 1).at(j), dp.at(i).at(j - 1));
            }
        }
    }
    int len = dp.at(s.size()).at(t.size());
    int i = s.size();
    int j = t.size();
    string ans = "";
    while(len > 0){
        if (s.at(i-1) == t.at(j-1)){
            ans = s.at(i-1) + ans;
            i--;
            j--;
            len--;
        }
        else if(dp.at(i).at(j) == dp.at(i-1).at(j)){
            i--;
        }
        else{
            j--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 74060
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define ll long long
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  in(a),in(b)
#define in3(a,b,c)  in2(a,b),in(c)
#define in4(a,b,c,d)  in2(a,b),in2(c,d)
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
ll read(){
    ll f=1,x=0;char c=getchar();
    while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    return x*f;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 300010
#define inf 0x7fffffff
/*------------------------------------------------------------*/
int n,m;
//char a[maxn];
//int f[maxn],g[maxn];
ll a[maxn];
int main(){
	int n;
	in(n);
	ll ans=0;
	ll sum=0;
	int l=1,r=1;
	FOR(i,1,n)in(a[i]);
//	int sum=0;
	FOR(i,1,n){
		while(r<=n&&(sum^a[r])==sum+a[r])r++,sum^=a[r-1];
		ans+=1ll*(r-i); 
		sum^=a[i];
	}
//	FOR(i,1,n){
//		ll c;
//		in(c);
//		if((sum^c)==sum+c)sum+=c;
//		 else sum=c,l=i;
//		ans+=1ll*(i-l+1);
//	}
//	ans+=1ll*(r-l+2)*(r-l+1)/2;
	outl(ans);
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>

int main(){
  char s[11];
  int first = 0;
  scanf("%s",&s);
  int len=strlen(s);
  if(s[0]=='A'){
    for(int i=2;i<len-1;i++){
      if(s[i]=='C'){
        first += 1;
        if(first>=2){
          printf("WA\n");
          return 0;
        }
      }
    }
  }
  if(first==0){
    printf("WA\n");
    return 0;
  } else {
    for(int i=0;i<len;i++){
      if(s[i]!='A'&&s[i]!='C'){
        if(s[i]>='a'&&s[i]<='z'){
        } else {
          printf("WA\n");
          return 0;
        }
      }
    }
  }
  printf("AC");
  return 0;
}

Measured memory_bytes: 128
def solve():
    S=input()
    T=input()
    i = -1
    for j in range(len(S)-len(T)+1):
        if all(a=="?" or a==b for a,b in zip(S[j:],T)):
            i = j
    if i == -1:
        print("UNRESTORABLE")
    else:
        ans = S[0:i] + T + S[i+len(T):]
        ans = ans.replace("?", "a")
        print(ans)

solve()

Measured memory_bytes: 3060
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <bitset>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

long long pow_mod(long long x, long long n, long long mod_num) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) { res = (res * x) % mod_num; }
        x = (x * x) % mod_num;
        n = (n >> 1);
    }
    return res;
}

const long long MOD = 1000000007;
const int MAX_N = 500050;
const int MAX_V = 1500000;
int a[MAX_N];
int N;

int ac[MAX_N];
int ac0ac[MAX_N];

std::vector<int> loc[MAX_V];

int main(int argc, char **argv) {
    std::cin >> N;

    for (int i = 1; i <= N; i++) {
        std::cin >> a[i];
    }

    for (int i = 1; i <= N; i++) {
        ac[i] = ac[i-1] ^ a[i];
    }


    for (int i = 1; i <= N; i++) {
        loc[ac[i]].push_back(i);
        ac0ac[i] = ac0ac[i-1];
        if (ac[i] == 0) {
            ac0ac[i]++;
        }
        //std::cout << ac[i] << " ";
    }
    //std::cout << std::endl;

    long long ret = 0;
    //std::cout << ac[N] << std::endl;
    if (ac[N] == 0) {
        ret += pow_mod(2, loc[0].size() - 1, MOD);
        for (int i = 1; i < MAX_V; i++) {
            if (0 < loc[i].size()) {
                long long dp[2] = {};
                dp[0] = 1;
                dp[1] = 0;
                int pl = 0;

                for (int l : loc[i]) {
                    long long p0 = dp[0] % MOD;
                    long long p1 = dp[1] % MOD;

                    dp[0] = p0 + p1 * (ac0ac[l] - ac0ac[pl]);
                    dp[1] = p0 + p1 + p1 * (ac0ac[l] - ac0ac[pl]);
                    pl = l;
                }
                //std::cout << i << " " << dp[1] << std::endl;
                ret = (ret + dp[1]) % MOD;
            }
        }
    } else {
        long long dp[2] = {};
        dp[0] = 1;
        dp[1] = 0;
        int pl = 0;
        for (int l : loc[ac[N]]) {
            long long p0 = dp[0] % MOD;
            long long p1 = dp[1] % MOD;

            dp[0] = p0 + p1 * (ac0ac[l] - ac0ac[pl]);
            dp[1] = p0 + p1 + p1 * (ac0ac[l] - ac0ac[pl]);
            pl = l;
        }
        ret = (ret + dp[0]) % MOD;
    }

    std::cout << ret << std::endl;


    return 0;
}



Measured memory_bytes: 50932