akhauriyash/Code-Regression huggingface dataset:
use std::collections::VecDeque;

fn main() {
    use proconio::input;
    use proconio::marker::Isize1;
    input!(h: usize, w: usize);
    let hi = h as isize;
    let wi = w as isize;
    input!(sx: Isize1, sy: Isize1);
    input!(gx: Isize1, gy: Isize1);
    input!(cells: [proconio::marker::Chars; h]);
    let index_of = |x: isize, y: isize| -> usize { (x + y * hi) as usize };
    let in_maze_p = |x: isize, y: isize| -> bool { 0 <= x && x < hi && 0 <= y && y < wi };
    let wall_p = |x: isize, y: isize| -> bool { cells[x as usize][y as usize] == '#' };

    let mut used = vec![false; h * w];
    let mut q: VecDeque<(isize, isize, u32)> = VecDeque::new();

    q.push_back((sx, sy, 0));
    while let Some((x, y, cnt)) = q.pop_front() {
        if used[index_of(x, y)] {
            continue;
        }
        if x == gx && y == gy {
            println!("{}", cnt);
            return;
        }
        used[index_of(x, y)] = true;

        for (xx, yy) in vec![(x - 1, y), (x + 1, y), (x, y - 1), (x, y + 1)] {
            if in_maze_p(xx, yy) {
                if !wall_p(xx, yy) {
                    if !used[index_of(xx, yy)] {
                        q.push_front((xx, yy, cnt));
                    }
                }
            }
        }

        for xd in -2..3 {
            for yd in -2..3 {
                let xx = x + xd;
                let yy = y + yd;
                if in_maze_p(xx, yy) {
                    if !wall_p(xx, yy) {
                        q.push_back((xx, yy, cnt + 1));
                    }
                }
            }
        }
    }
    println!("{}", -1);
}


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

int main(){
    int s = 0;
    string S,T;
    cin >> S >> T;
    s = S.size();
    bool flag = true;

    
    for(int i = 0;i < s;i++){
        if(S.at(i) != T.at(i))
            flag = false;
    }

    if(flag)
        cout << "Yes" << endl;
    else
    {
            cout << "No" << endl;
    }
    
} 

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

int N;
string S;

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

    cin >> S;

    int x = 0, y = 0;
    for (int i = 0; i < (int)S.size(); i++) {
        if (i % 2) {
            if (S[i] == '1') y++;
            else x++;
        } else {
            if (S[i] == '1') x++;
            else y++;
        }
    }

    cout << min(x, y);
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
map<int, ll> mp;
char s[200010];

int main()
{
    cin >> s;
    ll len = strlen(s);
    for (int i = 0; i < len; i++)
        mp[s[i] - 'a']++;
    ll ans = 1;
    ans += len*(len - 1) / 2;
    for (int i = 0; i < 26; i++)
        if (mp[i]) ans -= mp[i] * (mp[i] - 1) / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;


int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    for(int i = 0; i < s.length();i++){
        cout << "x";
    }
    cout << endl;

    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main (void) {
	string s; cin >> s;
	vector <bool> here(26, false);
	for (int i = 0; i < (int)s.size(); i++) {
		here[s[i]-'a'] = true;
	}
	for (int i = 0; i < 26; i++) {
		if (here[i] == false) {
			printf("%c\n", 'a'+i);
			return 0;
		}

	}
	cout << "None" << endl;


	return 0;
}

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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	long long N;
	scanf("%lld",&N);
	std::vector<long long> A(N, 0);
	for(ll i = 0 ; i < N - 2 + 1 ; i++){
		ll tmp;
		cin >> tmp;
		A[tmp - 1]++;
	}

	for (ll i = 0; i < N; ++i)
	{
		cout << A[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 4864
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a+b==c||a+c==b||b+c==a) cout << "Yes" << endl;
  else cout << "No" << endl;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
typedef long long ll;
ll solve( char a[][1000], int r, int c,int i,int j ,ll dp[][1000]) { 
  if(i==r-1&&j==c-1)
  return 1;
  if(dp[i][j]!=-1)
  return dp[i][j];
  ll ans=0;
  if(j+1<c&&a[i][j+1]=='.')
  ans=(ans+solve(a,r,c,i,j+1,dp))%mod;
  if(i+1<r&&a[i+1][j]=='.')
  ans=(ans+solve(a,r,c,i+1,j,dp))%mod;
  dp[i][j]=ans;
  return ans;
} 
  
   
int main(){
  int h,w;
  cin>>h>>w;
  char a[h][1000];
  for(int i=0;i<h;i++){
  	for(int j=0;j<w;j++)
  	cin>>a[i][j];
  }
  ll dp[h][1000];
  memset(dp,-1,sizeof(dp));
  cout<<solve(a,h,w,0,0,dp)<<endl;
  return 0;
}

Measured memory_bytes: 9216
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static boolean solve() {
		int n = in.nextInt();
		int s = in.nextInt();
		if (n + s == 0) return false;

		out.println(rec(n,-1,s));

		return true;
	}

	static long[][][] dp = new long[10][101][1001];

	static long rec(int n, int x, int s) {
		if (n == 0 && s == 0) return 1;
		if (n == 0) return 0;
		if (x != -1 && dp[n][x][s] != -1) return dp[n][x][s];
		long res = 0;
		for (int i=x+1; i<=100; i++) {
			if (s-i >= 0) {
				res += rec(n-1, i, s-i);
			}
		}

		if (x == -1) return res;
		return dp[n][x][s] = res;
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		for (int i=0; i<10; i++) {
			for (int j=0; j<101; j++) {
				Arrays.fill(dp[i][j],-1);
			}
		}

		while(solve());
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

Measured memory_bytes: 35264
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  map<string,int> mp;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    mp[s]++;
  }
  cout<<mp.size()<<endl;
  return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

ll lcm(ll a, ll b) {
    ll ao, bo;
    ao = a;
    bo = b;
    ll r = a % b;
    while (r) {
        a = b;
        b = r;
        r = a % b;
    }
    return ao / b * bo;
}

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    ll N;
    cin >> N;
    Vl T(N);
    for (ll i = 0; i < N; i++) {
        cin >> T[i];
    }

    ll ans = T[0];
    for (ll i = 1; i < N; i++) {
        ans = lcm(ans, T[i]);
    }
    cout << ans << endl;

    return 0;
}

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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        int N, X, T;
        cin >>N >>X >>T;
        cout <<((N+X-1)/X)*T <<endl;
        return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e9;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
string s;
vector<ll>v;
ll check(int n)
{
    map<int,int>mp;
    set<int>s;
    while(n)
    {
        s.insert(n%10);
        mp[n%10]++;
        n/=10;
    }
    if(mp[7] && mp[3] && mp[5] && s.size()==3)
        return 1;
    return 0;
}
void recur(ll n)
{
    if(n>MAX)
        return;
    if(check(n))
        v.push_back(n);
    recur(n*10+3);
    recur(n*10+5);
    recur(n*10+7);
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    ll n;
    cin>>n;
    recur(0);
    sort(all(v));
    int cnt=0;
    for(int i=0; i<v.size(); i++)
    {
        if(v[i]<=n){
            cnt++;
        }
    }
    cout<<cnt<<endl;




    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <vector>
using namespace std;
int main() {
  long long s;
  cin >> s;
  vector<long long> v(max(9ll, s+1), 0ll);
  if (s < 3) {
    cout << 0 << endl;
    return 0;
  }

  v.at(3) = 1;
  v.at(4) = 1;
  v.at(5) = 1;
  v.at(6) = 2;
  v.at(7) = 3;
  v.at(8) = 4;
  for (long long i = 9; i <= s; ++i) {
    v.at(i) += v.at(i-1);
    v.at(i) %= 1000000007ll;
    v.at(i) += v.at(i-3);
    v.at(i) %= 1000000007ll;
  }
  cout << v.at(s) << endl;

  return 0;
}


Measured memory_bytes: 3532
import java.util.Scanner;

public class Main {

	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int h=scan.nextInt();
		int w=scan.nextInt();
		long ar[][]=new long[h+2][w+2];
		
		for(int i=1;i<=h;i++) {
			String g=scan.next();
			for(int j=1;j<=w;j++)
			{
				if(g.charAt(j-1)=='.') {
					ar[i][j]=0;
				}else {
					ar[i][j]=-1;
				}
				
			}
		}
		ar[1][1]=1;
		for(int i=1;i<=h;i++)
		{
			for(int j=1;j<=w;j++)
			{
				if(i==1&& j==1)continue;
				if(ar[i][j]==-1)continue;
				long left=(ar[i][j-1]==-1)?0:ar[i][j-1];
//					left=left%1000000007;
				long right=(ar[i-1][j]==-1)?0:ar[i-1][j];
//					left=right%1000000007;
				ar[i][j]=(left+right)%1000000007;
//				System.out.println(ar[i][j]);
			}
		}
		System.out.println(ar[h][w]);
	}
}


Measured memory_bytes: 37660
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
int main(int argc, char const *argv[])
{
	vector<string> v;
	string s;
	int n,l;
	cin>>n>>l;
	for(int i=0;i<n;++i)
	{ cin>>s;
	  v.push_back(s);
	}
    sort(v.begin(),v.end());
    for(auto i:v)
    	cout<<i;
    cout<<endl;
	return 0;
}

Measured memory_bytes: 256
import collections

def main():
    n, m = map(int, input().split())
    g = [[] for i in range(n)]
    for i in range(m):
        a, b = map(int, input().split())
        a, b = a - 1, b - 1
        g[a].append(b)
        g[b].append(a)
    ans = solve(n, m, g)
    if -1 in ans:
        print('No')
    else:
        print('Yes')
        print(*ans, sep = '\n')


def solve(n, m, g):
    q = collections.deque()
    distances = [-1 for i in range(n)]
    ans  = [-1 for i in range(n)]
    distances[0] = 0
    q.append(0)
    while len(q):
        pos = q.popleft()
        for i in g[pos]:
            if distances[i] == -1:
                q.append(i)
                distances[i] = distances[pos] + 1
                ans[i] = pos + 1
    return ans[1:]


if __name__ == '__main__':
    main()

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

int main(){
  int64_t n, ans;

  cin >> n;

  ans = n * (n + 1) / 2;

  for(int i = 0; i < (n / 3); i++){
    ans = ans - (i + 1) * 3;
  }

  for(int i = 0; i < (n / 5); i++){
    ans = ans - (i + 1) * 5;
  }

  for(int i = 0; i < (n / 15); i++){
    ans = ans + (i + 1) * 15;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>
#define MAX(x,y) (((x)>(y))?(x):(y))

int x=0,i=0,j,d[500],m=0,l=0;
char s[500][36];

int main(){
	memset(d,0,sizeof(d));
	while(scanf("%s",s[x])!=EOF){
		x++;j=0;
		for(i=0;i<x-1;i++){
			if(strcmp(s[i],s[x-1])==0)d[i]++,j=1;
			m=MAX(m,d[i]);
			l=MAX(l,strlen(s[i]));
		}
		if(j==1)x--,j=0;
	}
	for(i=0;i<=x;i++)if(d[i]==m)printf("%s ",s[i]);
	for(i=0;i<=x;i++)if(strlen(s[i])==l)printf("%s\n",s[i]);
	
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<double> v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    for(int i=0;i<n-1;i++){
        sort(v.begin(), v.end());
        v[i+1]=(v[i]+v[i+1])/2;
        v[i]=0;
    }
    cout<<v[n-1];    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
//ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N = 3e5;
ll n, c[60];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    ll a;
    cin >> a;
    FOR(j, 0, 60) c[j]+=a&1, a>>=1;
  }
  ll ans = 0;
  FOR(i, 0, 60) ans += (1ll<<i)%MOD*c[i]%MOD*(n-c[i])%MOD;
  cout << ans%MOD << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    int x[5];
    cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];

    for(int i=0; i<5; i++){
        if(x[i] == 0) cout << i+1 << endl;
    }

    return 0;
    
}


Measured memory_bytes: 3584
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int a[101][101], b[101], c[101];
	int i, j;
	int n, m;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
	}
	for (j = 0; j < m; j++) scanf("%d", &b[j]);

	for (i = 0; i < n; i++) {
		c[i] = 0;
		for (j = 0; j < m; j++) c[i] += a[i][j] * b[j];
	}

	for (i = 0; i < n; i++) {
		printf("%d\n", c[i]);
	}
	return 0;
}



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

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define For(i, a) for (int i=0; i<(a); i++)
#define FORR(i,a,b) for (int i = (b)-1; i >= a; i--)
#define Forr(i,a) for (int i = (a)-1; i >= 0; i--)

#define deb(...) cerr << "[" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__) 
void DBG() { cerr << "]\n";}
template<typename T, typename ...Args> void DBG(T first, Args... args){
cerr << first; if(sizeof...(args))cerr<<", "; DBG(args...); }

#define int ll
#define pb(x) push_back(x)
#define INF (int)1e17
#define PI 3.14159265358979323846
 
int del_x[4] = {-1, 1, 0, 0};
int del_y[4] = {0, 0, 1, -1};
int XX[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int YY[8] = {-1, 0, 1, 1, 1, 0, -1, -1};


void solve(){
	string s;
	int cnt=0;
	cin >> s;
	for(char ch : s){
		int x = ch-'0';
		cnt += x;
		if(cnt>=9)cnt%=9;
	}
	cout << (cnt%9==0?"Yes\n":"No\n");
	
}

int32_t main(){ 
	#ifndef ONLINE_JUDGE
		clock_t tStart = clock();
		//freopen("in.txt", "r", stdin);
	#endif
	ios_base:: sync_with_stdio(false); 
	cin.tie(0); 
	int t=1;
	//cin >> t;
	for(int tt=1;tt<=t;tt++){
		//cout << "Case #"<<tt<<": ";
		solve();
	}
	#ifndef ONLINE_JUDGE
    cerr << "\nRun Time -> "<<(double)(clock()-tStart)/CLOCKS_PER_SEC <<" sec\n";
  #endif
}

Measured memory_bytes: 3740
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cstdio>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007
#define MAXS(x,y) (x = max(x,y))
#define MINS(x,y) (x = min(x,y))

using namespace std;

typedef long long int ll;

const ll INF=(ll)1e18;

vector<int> pre, in, post;

int N;

vector<ll> a;

int main(){
  cin >> N;

  a.resize(N+1);
  REP(i,N)cin >> a[i];
  a[N] = 0;

  ll ans = 0;

  REP(i,N){
    if(a[i] == 0)continue;

    if(a[i]%2==0){
      ans += a[i]/2;
    }else{
      ans += a[i]/2;
      if(a[i+1]>0){
        ans += 1;
        a[i+1] -= 1;
      }
    }
  }

  cout << ans << endl;

}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n, m;
  cin >> n >> m;
  long long int a[n], b[n], c[m], d[m];
  for(int i=0; i<n; i++) cin >> a[i] >> b[i];
  for(int i=0; i<m; i++) cin >> c[i] >> d[i];
  for(int i=0; i<n; i++){
    long long int dist;
    int ans=0;
    for(int j=0; j<m; j++){
      if(j==0) dist = abs(a[i]-c[j])+abs(b[i]-d[j]);
      else{
        if(dist>abs(a[i]-c[j])+abs(b[i]-d[j])){
          dist = abs(a[i]-c[j])+abs(b[i]-d[j]);
          ans=j;
        }
      }
    }
    ans++;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
H,W,M = map(int,input().split())
T = [0] * M
H_cnt = {}
W_cnt = {}
HW = {}
for i in range(M):
    h,w = map(int,input().split())
    if not h in H_cnt:
        H_cnt[h] = 0
    if not w in W_cnt:
        W_cnt[w] = 0
    H_cnt[h] += 1
    W_cnt[w] += 1
    HW[(h,w)] = 1

HL = [[h,cnt] for h,cnt in H_cnt.items()]
WL = [[w,cnt] for w,cnt in W_cnt.items()]

HL.sort(key=lambda x: x[1],reverse=True)
WL.sort(key=lambda x: x[1],reverse=True)

HS = {}
max_cnth = 0
for h,cnt in HL:
    if max_cnth<=cnt:
        HS[h] = cnt
        max_cnth = max(max_cnth,cnt)
        continue
    break

WS = {}
max_cntw = 0
for w,cnt in WL:
    if max_cntw<=cnt:
        WS[w] = cnt
        max_cntw = max(max_cntw,cnt)
        continue
    break

cnt = 0
ans = 0

# ここの判定を高速にする
cross_cnt = 0
for hw in HW.keys():
    h,w = hw
    if h in HS and w in WS:
        cross_cnt+=1
if len(WS) * len(HS)==cross_cnt:
    print(max_cnth+max_cntw-1)
    exit()
print(max_cnth+max_cntw)


#for h,hcnt in HS:
#    for w,wcnt in WS:
#        if (h,w) in HW:
#            cnt = hcnt+wcnt-1
#            ans = max(ans,cnt)
#            continue
#        cnt = hcnt+wcnt
#        ans = max(ans,cnt)


















Measured memory_bytes: 233256
import sys
from collections import deque

read = sys.stdin.buffer.read


def main():
    N, Q, *ABPX = map(int, read().split())
    G = [[] for _ in range(N)]
    for a, b in zip(ABPX[0 : 2 * N - 2 : 2], ABPX[1 : 2 * N - 2 : 2]):
        G[a - 1].append(b - 1)
        G[b - 1].append(a - 1)
    X = [0] * N
    for p, x in zip(ABPX[2 * N - 2 :: 2], ABPX[2 * N - 1 :: 2]):
        X[p - 1] += x

    C = [0] * N
    C[0] = X[0]
    seen = [False] * N
    stack = deque([0])

    while stack:
        v = stack.pop()
        seen[v] = True
        for nv in G[v]:
            if not seen[nv]:
                stack.append(nv)
                C[nv] = C[v] + X[nv]

    print(*C)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 95808
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        string a = Read.Str();
        Console.WriteLine(a.Substring(0,1)+(a.Length-2).ToString()+a.Substring(a.Length-1,1));
        Console.ReadLine();
    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b)
    {
        return a * b / gcd(a, b);
    }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;

        for (long i = 2; i < n; i++)
        {
            if (n % i == 0) return false;
        }
        return true;
    }

}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] longs()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
    public static int Int()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] ints()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

template<typename T> struct BIT {
	vector<T> bit;
	int n;
	
	BIT() {}
	BIT(int n) : bit(vector<T>(n + 2, 0)), n(n) {}
	
	T sum(int i) {
		i++;
		T s = 0;
		while (i > 0) {
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}
	
	void add(int i, T x) {
		i++;
		while (i <= n) {
			bit[i] += x;
			i += i & -i;
		}
	}
	
	T pquery(int i) {
		return sum(i) - sum(i - 1);
	}
	
	int lower_bound(T x) {
		int l = -1, r = bit.size();
		while (r - l > 1) {
			int m = (l + r) / 2;
			
			if (sum(m) >= x) r = m;
			else l = m;
		}
		if (r == bit.size()) r = -1;
		
		return r;
	}
};

int Q;
int query[212345];
int A[212345], B[212345];

int main() {
	int Q;
	cin >> Q;
	REP(i, Q) {
		scanf("%d", query + i);
		if (query[i] == 1) scanf("%d %d", A + i, B + i);
	}
	
	vector<int> cx;
	REP(i, Q) if (query[i] == 1) cx.push_back(A[i]);
	sort(ALL(cx));
	
	BIT<ll> popcnt(Q + 10), sum(Q + 10); // 1-indexed
	
	ll bsum = 0;
	REP(q, Q) {
		if (query[q] == 1) {
			int idx = lower_bound(ALL(cx), A[q]) - cx.begin() + 1;
			popcnt.add(idx, 1);
			sum.add(idx, A[q]);
			bsum += B[q];
		}
		else {
			int size = popcnt.sum(Q);
			if (size == 0) {
				puts("0 0");
				continue;
			}
			int idx = popcnt.lower_bound((size + 1) / 2); // 1-indexed
			
			ll x = cx[idx - 1];
			ll ans = -x * (popcnt.sum(Q) - popcnt.sum(idx)) + (sum.sum(Q) - sum.sum(idx));
			ans += x * popcnt.sum(idx) - sum.sum(idx);
			ans += bsum;
			
			printf("%lld %lld\n", x, ans);
		}
	}
	
	return 0;
}


Measured memory_bytes: 8824
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	int water=0, sugar=0;
	int ans_w=min(A,B), ans_s=0;
	for(int a=0; 100*a*A<=F; a++){
		for(int b=0; 100*b*B<=F; b++){
			for(int c=0; c*C<=F; c++){
				for(int d=0; d*D<=F; d++){
					water=a*A+b*B;
					sugar=c*C+d*D;
					if(water>0 && sugar<=E*water && 100*water+sugar<=F){
						if(sugar*(100*ans_w+ans_s)>ans_s*(100*water+sugar)){
							ans_w=water;
							ans_s=sugar;
						}
					}
				}
			}
		}
	}
	cout << 100*ans_w+ans_s << " " << ans_s << endl;
 	return 0;
}

Measured memory_bytes: 256
def chain(y, x):
	bomb[y][x] = "0"
	if bomb[y + 1][x] == "1" : chain(y + 1, x)
	if bomb[y + 2][x] == "1" : chain(y + 2, x)
	if bomb[y + 3][x] == "1" : chain(y + 3, x)
	if bomb[y - 1][x] == "1" : chain(y - 1, x)
	if bomb[y - 2][x] == "1" : chain(y - 2, x)
	if bomb[y - 3][x] == "1" : chain(y - 3, x)
	if bomb[y][x + 1] == "1" : chain(y, x + 1)
	if bomb[y][x + 2] == "1" : chain(y, x + 2)
	if bomb[y][x + 3] == "1" : chain(y, x + 3)
	if bomb[y][x - 1] == "1" : chain(y, x - 1)
	if bomb[y][x - 2] == "1" : chain(y, x - 2)
	if bomb[y][x - 3] == "1" : chain(y, x - 3)
	return

n = input()
for d in range(0, n):
	raw_input()
	bomb = []
	for _ in range(0, 3) : bomb.append(list("00000000000000"))
	for _ in range(0, 8) : bomb.append(list("000" + raw_input() + "000"))
	for _ in range(0, 3) : bomb.append(list("00000000000000"))
	
	x = input() + 2
	y = input() + 2
	
	chain(y, x)
	
	print "Data {}:".format(d + 1)
	for var in bomb[3:11]:
		print "".join(var[3:11])

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

const int MN = 100010;

int N, M;
vector<int> adj[MN];
int P[MN], vis[MN];
vector<int> A;
unordered_map<int, int> B;

void dfs(int u) {
    vis[u] = 1;
    A.push_back(u);
    B[ P[u] ] = 1;

    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];
        if(vis[v]) continue;
        dfs(v);
    }
}

int main() {
    scanf("%d %d", &N, &M);

    for(int i = 0; i < N; i++) {
        scanf("%d", &P[i]);
        P[i]--;
    }

    for(int i = 0; i < M; i++) {
        int u, v; scanf("%d %d", &u, &v);
        u--; v--;

        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    int ans = 0;
    for(int i = 0; i < N; i++) if(!vis[i]) {
        A.clear();
        B.clear();
        dfs(i);

        for(int j = 0; j < A.size(); j++) if(B[ A[j] ]) ans++;
    }
    printf("%d", ans);
}


Measured memory_bytes: 12956
import java.io.*;
class Main
{
    public static void main(String args[]) throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        int t=Integer.parseInt(bu.readLine());
        int c1=0,c2=0,c3=0,c4=0;
        while(t-->0)
        {
            String s=bu.readLine();
            if(s.equals("AC")) c1++;
            if(s.equals("WA")) c2++;
            if(s.equals("TLE")) c3++;
            if(s.equals("RE")) c4++;
        }
        sb.append("AC x "+c1+"\n");
        sb.append("WA x "+c2+"\n");
        sb.append("TLE x "+c3+"\n");
        sb.append("RE x "+c4+"\n");
        System.out.print(sb);
    }
}

Measured memory_bytes: 42756
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld long double
#define   pb push_back
#define  sz(x)  (int)x.size()
#define  ff first
#define  ss second
#define  pii  pair<int,int>
using namespace std; 

vector<int> allPrimes; 
 
void sieve(int n) 
{ 
    vector<bool> prime(n+1, true); 
    for (int p=2; p*p<=n; p++) { 
        if (prime[p] == true) { 
            for (int i=p*2; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for (int p=2; p<=n; p++) 
        if (prime[p]) 
            allPrimes.push_back(p); 
} 
int solve(int n) 
{ 
    sieve(n); 
    int result = 1;
    for (int  i=0; i < allPrimes.size(); i++) 
    { 
        int p = allPrimes[i]; 
        int exp = 0; 
        while (p <= n) 
        { 
            exp = exp + (n/p); 
            p = p*allPrimes[i]; 
        } 
        result = (result*(exp+1))%1000000007; 
    } 
    return result; 
}
 


signed main()
{
    int n=1; cin>>n;
    cout << solve(n) << endl ;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s, t;
	cin >> s;
	cin >> t;
	int i;
	for (i = 0; i < s.length(); i++) {
		if (!strcmp((s.substr(i, s.length() - i) + s.substr(0, i)).c_str(), t.c_str())) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

#include <math.h> 

bool IsPrime(long long int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
int main(void){
    long long int c=0,n,a[3],saisyo=1000000001900;
    {
        cin >> n;
    }
    if(IsPrime(n)==true)
    {
        cout << n-1 << endl;
        return 0;        
    }
    long long int i=2,j=2;
    for(i=2;i<n/2+1;i++)
    {
        if(n/i*i==n && saisyo>n/i+i-2)
        {
            saisyo=n/i+i-2;
            c++;
        }
        if(saisyo<i)
        {
            break;
        }
        if(i*i>n)
        {
            break;
        }
    }
    cout << saisyo << endl;
    return 0;
}


Measured memory_bytes: 3680
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  string s;
  ll K;
  cin >> s >> K;
  FOR(i,0,s.length()) {
    if(s[i] == 'a') continue;
    if(K >= 'z' - s[i] + 1) {
      K -= 'z' - s[i] + 1;
      s[i] = 'a';
    }
  }
  K %= 26;
  FOR(i,0,K) {
    if(s[s.length()-1]=='z') s[s.length()-1] = 'a';
    else s[s.length()-1] = char(s[s.length()-1] + 1);
  }

  cout << s << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111



	void solve(){


		ini(n);
		ins(morty);
		string morty1;
		int tmp = 0;
		FOR(i,0,morty.size()){
			if(morty[i] == '('){morty1+='(';tmp++;}
			else{
				if(tmp>0){morty1+=')';tmp--;}
				else{
					morty1 = '(' +morty1+ ')';
				}
			}
		}
		while(tmp--)morty1+=')';
		out(morty1);







	}	























int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  i64 n, a, b;
  cin >> n >> a >> b;

  u64 ans = 0;
  ans = n / (a + b) * a;

  i64 d = (n % (a + b));

  ans += min(a, d);

  cout << ans;

  return 0;
}


Measured memory_bytes: 3628
/***** author :  C0d1ngPhenomena *****/

#include <bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define TestCases int T; cin>>T; while(T--)
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define revrep(i,a,b) for(ll i = b-1; i >= a; i--)
#define vll vector<ll>
#define vvll vector < vll >
#define pll pair<ll, ll>
#define vpll vector <pll>
#define mp(x,y) make_pair(x,y)
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define alld(c) c.begin(),c.end(),greater<int>()
#define mem(a,val) memset(a,val,sizeof(a))
#define f first
#define s second
#define pb push_back
using namespace std;

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
	return (a.second < b.second);
}





int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	string S, T;
	cin >> S >> T;
	map<char, ll> mp;
	ll cnt = inf;

	rep(i, 0, S.length() - T.length()+1)
	{
		ll flag = 0;
		string str = S.substr(i, T.length());
		// cout << str << endl;
		rep(j, 0, T.length())
		{
			if(str[j] == T[j])
				flag++;
		}

		flag = T.length() - flag;

		cnt = min(cnt, flag);
	}

	cout << cnt;


	return 0;
}







Measured memory_bytes: 3648
package main

import (
    "fmt"
    "os"
    "bufio"
    "strconv"
    // "sort"
)
var sc = bufio.NewScanner(os.Stdin)


func dump(a []int){
    for i, v := range a {
        if i > 0{
            fmt.Print(" ")
        }
        fmt.Print(v)
    }
    fmt.Println("")
}

func isprime(x int) bool {
    if x <= 1 {
        return false
    }
    if x == 2 {
        return true
    }
    if x % 2 == 0 {
        return false
    }
    for d := 3; d*d <= x; d += 2 {
        if x%d == 0 {
            return false
        }
    }
    return true
}

func main() {
    sc.Split(bufio.ScanWords)
    // code goes here
    
    n := nextInt()
    cnt := 0
    for ;n > 0; n -=1 {
        if isprime(nextInt()) {
            cnt += 1
        }
    }
    fmt.Println(cnt)
    
}



func nextInt() int {
    sc.Scan()
    v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}
func nextInt64() int64 {
    sc.Scan()
    v, e := strconv.ParseInt(sc.Text(), 10, 64)
    if e != nil { panic(e) }
    return v
}
func nextString() string {
    sc.Scan()
    return sc.Text()
}
func nextFloat() float64 {
    sc.Scan()
    v, e := strconv.ParseFloat(sc.Text(), 64)
    if e != nil { panic(e) }
    return v
}
func Max(x, y int) int { if x > y { return x }; return y }
func Min(x, y int) int { if x < y { return x }; return y }
func Abs(x int) int { if x > 0 { return x }; return -x }




Measured memory_bytes: 1172
import math
mod=10**9+7
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
s=int(input())
if s<3:
    print(0)
else:
    x=1
    ans=1
    cnt=1
    for i in reversed(range((s-5)%2,s-4,2)):
        if i-cnt<0:
            break
        ans+=combinations_count(i,cnt)
        cnt+=1
    print(ans%mod)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K; cin >> K;
  string S; cin >> S;
  if(S.length() <= K) cout << S;
  else{
    for(int i = 0; i < K; i++) cout << S[i];
    cout << "...";
  }
  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    char a, b;
    cin >> a >> b;
    string ans = "=";
    if (a < b) {
        ans = "<";
    } else if (a > b) {
        ans = ">";
    }
    cout  << ans << endl;
    return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
	s = input().split()
	if s[0] < s[1]:
		tmp = s[0]
		s[0] = s[1]
		s[1] = tmp
	while True:
		x = int(s[0]) % int(s[1])
		if x==0:
			break
		s[0] = s[1]
		s[1] = x

	print (s[1])




Measured memory_bytes: 5596
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf
# @pysnooper.snoop()
#import pysnooper # debug

import math
from collections import defaultdict
#from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder
import bisect


# 50 まで
def survey():
    v = 1
    k = 2
    i = 0
    while not (v > 10 ** 12):
        v = k ** i
        print(i)
        i += 1

def survey2():
    v = 1
    s = 0
    while not (s > 50):
        #print('s', s) # debug
        s += v
        v += 1

def diff_selectable(v):
    l = [1, 3, 6, 10, 15, 21, 28, 36, 45, ]
    for i, t in enumerate(l):
        if v < t:
            return i
    raise ValueError

"""
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
"""

def prime_factorize(n):
    a = defaultdict(lambda: 0)
    while n % 2 == 0:
        a[2] += 1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a[f] += 1
            n //= f
        else:
            f += 2
    if n != 1:
        a[n] += 1
    return a

if __name__ == '__main__':
    ans = 0
    data = int(input())
    primes = prime_factorize(data)
    for pc in primes.values():
        ans  += diff_selectable(pc)
    #print('ans') # debug
    print(ans)

    #print('\33[32m' + 'end' + '\033[0m') # debug


Measured memory_bytes: 68576
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		int M = sc.nextInt();
		long[] A = new long[N + 2];
		long[] B = new long[M];
		for (int i = 0; i < N; i++) {
			A[i + 1] = Integer.parseInt(sc.next());
		}
		A[N + 1] = 1000000;
		for (int i = 0; i < M; i++) {
			B[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(A);
		long[] AS = new long[N + 2];
		for (int i = 0; i < N + 1; i++) {
			AS[i + 1] = AS[i] + A[i + 1];
		}
		long ans = 0;
		long[] cache = new long[501];
		Arrays.fill(cache, -1);
		for (int i = 0; i < M; i++) {
			int MOD = (int) B[i];
			if (MOD < cache.length) {
				if (cache[MOD] != -1) {
					ans += cache[MOD];
					continue;
				}
				long sum = 0;
				for (int j = 0; j < N; j++) {
					sum += A[j + 1] % MOD;
				}
				cache[MOD] = sum;
				ans += sum;
			} else {
				int left = 0;
				for (long j = 0; j <= A[N] + MOD;) {
					int prev = left;
					int right = N + 1;
					while (right - left > 1) {
						int mid = (left + right) >> 1;
						if (A[mid] >= j + MOD) {
							right = mid;
						} else {
							left = mid;
						}
					}
					long len = left - prev;
					ans += AS[left] - AS[prev] - len * j;
					j = A[right] / MOD * MOD;
				}
			}
		}
		System.out.println(ans);
	}


}



Measured memory_bytes: 106484
#include <cstdio>
#include <string>
 
class List
{
    int* data_;
    int begin_;
    int end_;
public:
    List()
    {
        data_  = new int[2000000];
        begin_ = 1999999;
        end_   = 1999999;
    }
    void Insert(int X)
    {
        --begin_;
        data_[begin_] = X;
    }
    void Delete(int X)
    {
        int Index = end_;
        for(int i = begin_; i < end_; ++i){
            if(X == data_[i]){
                Index = i;
                break;
            }
        }
        if(Index == end_) return;
        for(int i = Index; i < end_; ++i){
            data_[i] = data_[i+1];
        }
        end_--;
    }
    void DeleteFirst()
    {
        begin_++;
    }
    void DeleteLast()
    {
        end_--;
    }
    void Show()const
    {
        printf("%d", data_[begin_]);
        for(int i = begin_ + 1; i < end_; ++i){
            printf(" %d", data_[i]);
        }
        printf("\n");
    }
};
 
int main()
{
    List list;
    int n, X;
    std::scanf("%d\n", &n);
    char com[1024];
    for(int i = 0; i < n; ++i){
        std::fgets(com, 1024, stdin);
        if(com[6] == 'F'){
            list.DeleteFirst();
        }else
        if(com[6] == 'L'){
            list.DeleteLast();
        }else{
            int v = 0;
            for(int j = 7; com[j] >= '0' && com[j] <= '9'; ++j){
                v = v*10 + (com[j] - '0');
            }
            if(com[0] == 'i'){
                list.Insert(v);
            }else
            if(com[0] == 'd'){
                list.Delete(v);
            }
        }
    }
    list.Show();
    return 0;
}

Measured memory_bytes: 6508
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var imp = Console.ReadLine().Split(' ');
            int x = int.Parse(imp[0]);
            int a = int.Parse(imp[1]);
            int b = int.Parse(imp[2]);
            int absA = Math.Abs(x - a);
            int absB = Math.Abs(x - b);
            if (absA > absB)
            {
                Console.Write("B");
            }
            else
            {
                Console.Write("A");
            }
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int n, m, a[200010];
int rangetree[2000000];
int am[200010];
void update(int node, int val, int curr = 1, int cstart = 0, int cend = 2e5)
{
	if (cstart == cend)
	{
		rangetree[curr] = val;
		return;
	}
	int mid = (cstart+cend)/2;
	if (node <= mid) update(node, val, 2*curr, cstart, mid);
	else update(node, val, 2*curr+1, mid+1, cend);
	rangetree[curr] = min(rangetree[2*curr], rangetree[2*curr+1]);
}
int query(int s, int e, int curr = 1, int cstart = 0, int cend = 2e5)
{
	if (s <= cstart && cend <= e) return rangetree[curr];
	int mid = (cstart+cend)/2;
	if (e <= mid) return query(s, e, 2*curr, cstart, mid);
	else if (s > mid) return query(s, e, 2*curr+1, mid+1, cend);
	else return min(query(s, e, 2*curr, cstart, mid), query(s, e, 2*curr+1, mid+1, cend));
}
set<int> components; // marked by their greatest value
int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
		am[a[i]]++;
	}
	for (int i = 1; i <= n; i++)
	{	
		update(i, i-am[i]);
	}	
	components.insert(n);
	for (int i = n; i >= 1; i--)
	{
		if (query(i, n) == i) components.insert(i-1);
	}
	for (int i = 0; i < m; i++)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		x--;
		int b = a[x];
		am[b]--;
		a[x] = y;
		update(b, b-am[b]);
		if (query(b-am[b], n) == b-am[b] && b-am[b] > 0) components.insert(b-am[b]-1);
		if (query(y-am[y], n) == y-am[y] && y-am[y] > 0) components.erase(y-am[y]-1);
		am[y]++;
		update(y, y-am[y]);
		printf("%d\n", (int)components.size()-1);
	}
}

Measured memory_bytes: 14976
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    a, b, c, d = map(int, input().split())
    print(max(a*c, a*d, b*c, b*d))


if __name__ == '__main__':
    main()

Measured memory_bytes: 77620
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int f(int x) {
    int res = 1;
    while (x > 0) {
        ++res;
        x %= __builtin_popcount(x);
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string X;
    cin >> N >> X;
    int popcount = 0;
    for (auto& d : X) {
        if (d == '1') {
            ++popcount;
        }
    }
    // 2^i (0<=i<N)をpopcount(X)-1とpopcount(X)+1で割った時の値を求める
    vector<int> div_num = {popcount - 1, popcount + 1};
    vector<vector<int>> divided_pow(2, vector<int>(N, -1));
    rep(i, 0, 2) {
        if (!div_num[i]) {
            continue;
        }
        int pow_num = 1;
        rep(j, 0, N) {
            divided_pow[i][j] = pow_num % div_num[i];
            pow_num = (pow_num * 2) % div_num[i];
        }
    }
    // Xをpopcount(X)-1とpopcount(X)+1で割った時の値を求める
    vector<int> divided_x(2, -1);
    rep(i, 0, 2) {
        if (!div_num[i]) {
            continue;
        }
        divided_x[i] = 0;
        int pow_num = 1;
        rrep(j, N, 0) {
            if (X[j] == '1') {
                divided_x[i] = (divided_x[i] + pow_num) % div_num[i];
            }
            pow_num = (pow_num * 2) % div_num[i];
        }
    }
    rep(i, 0, N) {
        int selected = ((int)(X[i] - '0') + 1) % 2;
        if (!div_num[selected]) {
            cout << 0 << endl;
        } else {
            int val = (divided_x[selected] + (selected ? 1 : -1) * divided_pow[selected][N - 1 - i] + div_num[selected]) % div_num[selected];
            cout << f(val) << endl;
        }
    }
    return 0;
}

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

int main()
{
	string w, t;
	cin.tie(0);
	cin >> w;
	int c = 0;
	while (cin >> t && t != "END_OF_TEXT") {
		for (int i = 0; i < t.length(); i++) if (t[i] >= 'A' && t[i] <= 'Z') t[i] += 0x20;
		if (t == w) c++;
	}
	cout << c << "\n";
}



Measured memory_bytes: 3160