akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
template<class T> istream& operator >> (istream & c, vector<T> & A) {rep(i, A.size()) c >> A[i];return c;}
template<class T> void vout(vector<T> A) {rep(i, A.size()) cout << A[i] << endl;}
template<class T> void vout_(vector<T> A) { rep(i, A.size()) cout << A[i] << (i == A.size() ? "\n" : " "); }
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<ll> a(n), b(n);
	cin >> a >> b;
	vector<ll> rec;
	int cnt1 = 0;
	rep(i, n) {
		if (a[i] > b[i]) {
			rec.push_back(a[i] - b[i]);
		}
	}
	sort(rec.rbegin(), rec.rend());
	ll sum = 0;
	rep(i, n) {
		if (a[i] >= b[i]) continue;
		sum += b[i] - a[i];
		cnt1++;
	}
	int cnt = 0;
	rep(i, rec.size()) {
		if (sum > 0) {
			sum -= rec[i];
			cnt++;
		}
	}
	if (sum > 0) {
		cout << -1 << endl;
		return 0;
	}
	cout << cnt + cnt1 << endl;
	return 0;
}

Measured memory_bytes: 5360
import java.util.*;

public class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        char b = sc.next().charAt(0);
        char arr[] = {'A','C','G','T'};
        char arr2[] = {'T','G','C','A'};
        for(int i=0;i<4;i++)if(b==arr[i]) System.out.println(arr2[i]);
    }
}


Measured memory_bytes: 21972
//                          VIVEK UPADHYAY
//                         MANIT, BHOPAL(M.P)
/**********************************************************************************************/
/**********************************************************************************************/
//                        $$ JAB-TAK TODEGA NHI,
//                           TAB -TAK CHODEGA NHI :D
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define LINE cout<<endl ;
#define ok cout<<"ok\n" ;
typedef long long ll;
const int MAXN = 1e5 + 10 ;
const int MAX = 1e6 ;
double pi = 3.1415926535897932384626433832795;
const ll inf=1e18 ;
ll mod = 1e9 + 7 ;
int main(){
    ll A , B ;
    cin >> A >> B ;
    int K ;
    cin >> K ;
    bool flag = true ;
    while(K > 0 && A >=0 && B >= 0){
       // cout<<A<<" "<<B<<endl;
        if(flag) {
            if(A%2) A--;
            B+=A/2 ;A-=A/2 ;
            flag=!flag ;
        }
        else {
            if(B%2) B--;
            A+=B/2 ;
            B-=B/2 ;
            flag=!flag ;
        }
        K-- ;
    }
    cout<<A<<" "<<B<<endl;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int n, m, c, s, g;
int cost[105][105];
int dist[25][105][105];
int p[20];
int r[25][52];
int q[25][52];

int h(int company, int from, int to) {
    //cerr << company << " " << from << " " << to << " " << dist[company][from][to] << endl;
    if(dist[company][from][to] == INF) return INF;
    int ret = 0;
    for(int i = 1; i <= p[company]; i++) {
        if(q[company][i] >= dist[company][from][to]) {
            ret += (dist[company][from][to] - q[company][i-1]) * r[company][i];
            return ret;
        }
        ret += (q[company][i] - q[company][i - 1]) * r[company][i];
    }
}

void f(int company) {
    for(int from = 1; from <= n; from++) {
        for(int to = 1; to <= n; to++) {
            int now = h(company, from, to);
            //cerr << now << endl;
            cost[from][to] = min(cost[from][to], now);
        }
    }
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        cin >> n >> m >> c >> s >> g;
        if(n == 0) break;
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= n; j++) {
                cost[i][j] = INF;
                for(int k = 1; k <= c; k++) {
                    dist[k][i][j] = INF;
                }
            }
            for(int k = 1; k <= c; k++) dist[k][i][i] = 0;
            cost[i][i] = 0;
        }
        for(int i = 1; i <= m; i++) {
            int x, y, d, c;
            cin >> x >> y >> d >> c;
            dist[c][x][y] = min(dist[c][x][y], d);
            dist[c][y][x] = min(dist[c][y][x], d);
        }
        for(int company = 1; company <= c; company++) {
            for(int from = 1; from <= n; from++) {
                for(int to = 1; to <= n; to++) {
                    //cerr << company << " " << from << " " << to << " " << dist[company][from][to] << endl;
                }
            }
        }
        for(int l = 1; l <= c; l++) {
            for(int i = 1; i <= n; i++) {
                for(int j = 1; j <= n; j++) {
                    for(int k = 1; k <= n; k++) {
                        dist[l][j][k] = min(dist[l][j][k], dist[l][j][i] + dist[l][i][k]);
                    }
                }
            }
        }
        for(int i = 1; i <= c; i++) cin >> p[i];
        for(int i = 1; i <= c; i++) {
            for(int j = 1; j < p[i]; j++) cin >> q[i][j];
            q[i][p[i]] = INF;
            q[i][0] = 0;
            for(int j = 1; j <= p[i]; j++) cin >> r[i][j];
        }
        for(int i = 1; i <= c; i++) f(i);
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= n; j++) {
                for(int k = 1; k <= n; k++) {
                    cost[j][k] = min(cost[j][k], cost[j][i] + cost[i][k]);
                }
            }
        }
        if(cost[s][g] == INF) cout << -1 << endl;
        else cout << cost[s][g] << endl;
    }
    return 0;
}


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

using ll = long long;
using P = pair<int, int>;
using PP = pair<int, P>;
#define rep1(i,n) for (int i=1; i<=n; i++)
#define rep0(i,n) for (int i=0; i<n; i++)
#define chmin(a,b) if ((a)>(b)) { a=(b); }
#define chmax(a,b) if ((a)<(b)) { a=(b); }
#ifdef _DEBUG
string _format(string args) { string r = "", t; istringstream s(args); while (getline(s, t, ',')) r += t+":%d "; return r + "\n"; }
#define debug(...) do{printf(_format(#__VA_ARGS__).c_str(), __VA_ARGS__);}while(0)
#else
#define debug(...) do{}while(0)
#endif

int main() {
    std::ios::sync_with_stdio(false); std::cin.tie(nullptr); // disable when using stdio
    int n;
    cin >> n;

    ll ans = 0;
    cout << 2 *  n * 3.141592 << endl;
}


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

#define mod 1000000007

typedef long long ll;

int N,M;
ll dp[3010][3010][2] = {0};

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

    for(int i = 1; i <= N; i++)dp[0][i][0] = 1LL;
    dp[0][0][1] = 1LL;

    for(int i = 0; i <= M; i++)
    {
        for(int j = 0; j <= N; j++)
        {
            for(int k = 0; k < 2; k++)
            {
                dp[i][j][k] %= mod;
                ll now = dp[i][j][k];
                if(j != N)
                {
                    dp[i + 1][j][k] += now;
                    dp[i + 1][j + 1][k] += now;
                }
                if(j != 0)
                {
                    if(j == 1)
                    {
                        dp[i + 1][j][1] += now;
                        dp[i + 1][j - 1][1] += now;
                    }
                    else
                    {
                        dp[i + 1][j][k] += now;
                        dp[i + 1][j - 1][k] += now;
                    }
                }
            }
        }
    }
    ll ans = 0;
    for(int i = 0; i <= N; i++)
    {
        ans += dp[M][i][1] % mod;
        ans %= mod;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 141568
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
	  result=(result*base)%modulus;
	  exponent=exponent>>1;
	  base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll a;
string s;
int main(){FAST;
	cin>>a>>s;
if(a>=3200)cout<<s;
else cout<<"red";
return 0;
}

Measured memory_bytes: 256
#include<bits//stdc++.h>
using namespace std;
int main(){
    int n,a[3];cin>>n;set<int> s;
    for(int i = 0;i <n;i++){
        cin >>a[0] >>a[1] >> a[2];
        sort(a,a+3);
        int sum = a[0]+ a[1]*1000+a[2]*1000000;
        s.insert(sum);
    }cout << n - s.size()<<endl;
}


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

// flagを用いたバブルソート
int bubbleSort(int A[], int N) {
    int sw = 0;
    bool flag = 1;

    for (int i = 0; flag; i++) {
        flag = 0;
        for (int j = N - 1; j >= i + 1; j--) {
            if (A[j] < A[j - 1]) {
                // 隣接要素を交換する
                swap(A[j], A[j - 1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main() {
    int A[100], N, sw;
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];

    sw = bubbleSort(A, N);

    for (int i = 0; i < N; i++) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;

    return 0;
}


Measured memory_bytes: 3084
attrs = Array.new
while line = $stdin.gets
    attrs << line.chomp.split.map{|v| v.to_i }
end

N = attrs.shift[0]
P = attrs.shift

result = 0

for i in 1..(N - 2) do
  s = [P[i - 1] , P[i] , P[i + 1]].sort
  if (s[0] < P[i]) && (s[1] == P[i])then
    result += 1 
  end
end

puts result

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

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

#define rep(a,n) for(int a = 0;a < n;a++)


	struct RollingHash {
		typedef long long int_type;
		typedef pair<int_type, int_type> hash_type;

		int_type base1;
		int_type base2;
		int_type mod1;
		int_type mod2;

		vector<int_type> hash1;
		vector<int_type> hash2;
		vector<int_type> pow1;
		vector<int_type> pow2;

		RollingHash() : base1(1009), base2(1007), mod1(1000000007), mod2(1000000009) {}

		void init(const string& s) {
			int n = s.size();
			hash1.assign(n + 1, 0);
			hash2.assign(n + 1, 0);
			pow1.assign(n + 1, 1);
			pow2.assign(n + 1, 1);
			for (int i = 0; i < n; i++) {
				hash1[i + 1] = (hash1[i] + s[i]) * base1 % mod1;
				hash2[i + 1] = (hash2[i] + s[i]) * base2 % mod2;
				pow1[i + 1] = pow1[i] * base1 % mod1;
				pow2[i + 1] = pow2[i] * base2 % mod2;
			}
		}

		hash_type get(int l, int r) {
			int_type t1 = ((hash1[r] - hash1[l] * pow1[r - l]) % mod1 + mod1) % mod1;
			int_type t2 = ((hash2[r] - hash2[l] * pow2[r - l]) % mod2 + mod2) % mod2;
			return make_pair(t1, t2);
		}

		RollingHash::hash_type concat(hash_type h1, hash_type h2, int h2_len) {
			return make_pair((h1.first * pow1[h2_len] + h2.first) % mod1,
				(h1.second * pow2[h2_len] + h2.second) % mod2);
		}
	};

	struct BSearch {
		static ll solve(ll left, ll right, function<ll(ll)> pred) {
			while (right - left > 1) {
				ll middle = left + right;
				middle /= 2;
				if (pred(middle)) {
					left = middle;
				}
				else {
					right = middle;
				}
			}
			return left;
		}
	};

int main(void)
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	RollingHash h;
	h.init(s);



	auto r = BSearch::solve(0, n + 1, [&](ll m) {
		set<P> memo;
		vector<P> values;
		for (int i = 0; i + m < n + 1; i++) {
			auto p = i - m;
			if (p >= 0) memo.insert(values[p]);
			auto t = h.get(i, i + m);
			if (memo.find(t) != memo.end()) {
				return true;
			}
			values.push_back(t);
		}
		return false;
	});
	if (r <= 0) {
		cout << 0 << endl;
		return 0;
	}
	cout << r << endl;
	return 0;
}

Measured memory_bytes: 936
mod=10**9+7
n,k=map(int,input().split())
coef=[]
for i in range(1,int(n**0.5)+1):
  coef.append((n//i)-(n//(i+1)))
coef+=[1]*(n-sum(coef))
coef=coef[::-1]
nn=len(coef)
dp=[[0]*nn for _ in range(k+1)]
dp[0][0]=1
for i in range(1,k+1):
  tmp=0
  for j in range(nn-1,-1,-1):
    tmp+=dp[i-1][(nn-1)-j]
    tmp%=mod
    dp[i][j]=coef[j]*tmp
    dp[i][j]%=mod
print(sum(dp[k])%mod)

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

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
    if (a > b) a = b;
}

template<class T, class U>
void ckmax(T &a, U b)
{
    if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define SZ(x) ((int) (x).size())
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

const int MAXN = 300013;
const int INF = 998244353;
const int BASE = 716070898;

int add(int a, int b)
{
    a += b; if (a >= INF) a -= INF; return a;
}
int mul(int a, int b)
{
    return (ll) a * b % INF;
}
int sub(int a, int b)
{
    a -= b; if (a < 0) a += INF; return a;
}
int pwr(int a, int b)
{
    int res = 1;
    while(b > 0)
    {
        if (b & 1) res = mul(res, a);
        b >>= 1;
        a = mul(a, a);
    }
    return res;
}
int inv(int a)
{
    return pwr(a, INF - 2);
}
int dvd(int a, int b)
{
    return mul(a, inv(b));
}

int N;
int M[3];
vi edge[3][MAXN];
int num[3][MAXN];
int sum[3][MAXN];
int pw[MAXN];
int ans;

int32_t main()
{
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(4);
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> N;
    FOR(i, 0, 3)
    {
        cin >> M[i];
        FOR(j, 0, M[i])
        {
            int u, v;
            cin >> u >> v; u--; v--;
            if (u > v) swap(u, v);
            edge[i][u].PB(v);
        }
        FORD(u, N, 0)
        {
            set<int> nums;
            for (int v : edge[i][u]) nums.insert(num[i][v]);
            num[i][u] = 0;
            while(nums.count(num[i][u])) num[i][u]++;
        }
        int pw = 1;
        FOR(j, 0, N)
        {
            pw = mul(pw, BASE);
            sum[i][num[i][j]] = add(sum[i][num[i][j]], pw);
            // cerr << "sum " << i << ' ' << num[i][j] << " peq " << pw << endl;
        }
        // cerr << "ok\n";
    }
    // cerr << "alive\n";
    FOR(i, 0, 512)
    {
        FOR(j, 0, 512)
        {
            ans = add(ans, mul(sum[2][i ^ j], mul(sum[0][i], sum[1][j])));
        }
    }
    cout << ans << '\n';
    return 0;
    //if an odd # say to include it then do it.
}


Measured memory_bytes: 32896
import sys
import math
def input(): return sys.stdin.readline().rstrip()

def main():
    A, B, H, M = map(int, input().split())
    hm = abs(H * 30 + H * (M / 360) - M)
    hm = abs(H * 30 + 0.5 * M - M * 6)
    if hm > 180:
        hm = 360 - hm
    cos_v = math.cos(math.radians(hm))
    print((A ** 2 + B ** 2 - 2 * A * B * cos_v) ** 0.5)

if __name__ == '__main__':
    main()


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

#define SIZE_OF_ARRAY(array) sizeof(array)/sizeof(array[0])
typedef long long ll;

int main() {
    ll A; double B;
    cin >> A >> B;
    if(A == 0){
        cout << 0 << endl;
    } else if(B == 0.00){
        cout << 0 << endl;
    } else {
        ll B2 = B * 1000;
        ll B3 = B2 / 10;
        ll ans = A * B3;
        ans = ans / 100;
        cout << ans << endl;
    }
}

Measured memory_bytes: 3696
#include<iostream>
using namespace std;
int main(){
	int n, m;
	int a[200005]={0};
	cin >> n;
	for(int i=2;i<=n;i++){
		cin >> m;
		a[m]++;
	}
	for(int i=1;i<=n;i++){
		cout << a[i] << endl;
	}
}

Measured memory_bytes: 4412
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
//printf("%.10f\n", n);
ll bit1[12345678], bit2[12345678], nn;//[1, nn]
ll sum1(ll i) {
	ll s = 0;
	while (i > 0) {
		s += bit1[i]; i -= i & -i;
	}
	return s;
}
void add1(ll i, ll x) {//iの値にxを加える
	while (i <= nn) {
		bit1[i] += x; i += i & -i;
	}
}
ll sum2(ll i) {
	ll s = 0;
	while (i > 0) {
		s += bit2[i]; i -= i & -i;
	}
	return s;
}
void add2(ll i, ll x) {//iの値にxを加える
	while (i <= nn) {
		bit2[i] += x; i += i & -i;
	}
}
ll test[12345678];
signed main() {
	ll n, k, a, cnt = 0, ans = 0; cin >> n >> k; nn = 10000 + 2;
	vector<ll> v; map<ll, ll> ma;
	for (int h = 0; h < n; h++) {
		cin >> a; test[h] = a; //cout << ' ' << sum(n + 2) << endl;
		ans += h - sum1(a); // cout << sum(a) << endl;
		add1(a, 1);
	}
	sort(test, test + n); reverse(test, test + n);
	for (int h = 0; h < n; h++) {
		cnt += h - sum2(test[h]); // cout << sum(a) << endl;
		add2(test[h], 1);
	}
	cout << (((ans % mod) * k % mod) + ((cnt % mod) * ((k * (k - 1) / 2) % mod)) % mod) % mod << endl;
	return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<15;
const ll MOD = 998244353;
const double EPS = 1e-9;

ll modpow(ll base, ll exp, ll mod){
  base %= mod;
  ll ret = 1;
  while(exp > 0){
    if (exp & 1) ret = (ret * base) % mod;
    exp /= 2;
    base = (base * base) % mod;
  }
  return ret;
}

int main(int argc, const char * argv[]) {
  int N; cin >> N;
  vector<int> a(N);
  for (int i=0; i<N; i++)
    cin >> a[i];

  int sum = accumulate(a.begin(), a.end(), 0);
  vector<vector<ll>> RGB(N+1, vector<ll>(sum+1, 0));
  RGB[0][0] = 1;
  for (int i=1; i<N+1; i++){
    for (int j=0; j<=sum; j++){
      if (j - a[i-1] < 0)
        RGB[i][j] = 2*RGB[i-1][j] % MOD;
      else
        RGB[i][j] = (2*RGB[i-1][j] % MOD + RGB[i-1][j-a[i-1]]) % MOD;
    }
  }

  ll ans = modpow(3, N, MOD);
  int half = (sum+2-1)/2;
  for (int i=sum; i>=half; i--)
    ans = (ans - 3 * RGB[N][i] % MOD) % MOD;

  if (sum % 2 == 0){
    vector<vector<ll>> GB(N+1, vector<ll>(sum+1, 0));
    GB[0][0] = 1;
    for (int i=1; i<N+1; i++){
      for (int j=0; j<=sum; j++){
        if (j - a[i-1] < 0)
          GB[i][j] = GB[i-1][j] % MOD;
        else
          GB[i][j] = GB[i-1][j] % MOD + GB[i-1][j-a[i-1]] % MOD;
      }
    }
    ans = (ans + 3 * GB[N][half] % MOD) % MOD;
  }

  cout << (ans + MOD) % MOD << endl;

  return 0;
}

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

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);cout<<"\n";};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts){   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }
template<typename T,typename U,typename... V> typename enable_if<is_same<T, U>::value!=0>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V> typename enable_if<is_same<T, U>::value==0>::type fill_v(U &u,const V... v){ for(auto &e:u) fill_v<T>(e,v...);}
//FUNCTION

int fn(int N,int K)
{
  if(N < K) return 0;
  // DEBUG("call");
  
  return N/K + fn(N,5*K);
}
//BELOW
void solve(void)
{ 
  int N;
  cin>>N;
  if(N%2 == 1)
  {
    cout<<0<<endl;
  }
  else
  {
    cout<<fn(N,10)<<endl;
  }
  

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

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

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
// #define DEBUGGING

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

namespace __init {

struct InitIO {
    InitIO() {
        cin.tie(0);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

V<ll> A;
VV<ll> edges;

ll dfs(ll now, ll pre) {
    ll ret = 0;
    V<ll> recs;
    ll sum = 0;
    for(ll nxt : edges[now]) {
        if(nxt == pre) continue;
        ll tmp = dfs(nxt, now);
        if(tmp == -1) return -1;
        recs.push_back(tmp);
        sum += tmp;
    }
    if(recs.empty()) return A[now];
    if(A[now] > sum) return -1;
    ll to_del = sum - A[now];
    DEBUG(now, A[now], sum, to_del);
    if(to_del > A[now]) return -1;
    if(sum - *max_element(ALL(recs)) < to_del) return -1;
    return A[now] - to_del;
}

bool solve() {
    ll N;
    cin >> N;
    A.resize(N);
    edges.resize(N);
    for(ll &e : A) cin >> e;
    for(ll i = 1; i < N; i++) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    if(N == 2) return A[0] == A[1];

    for(ll i = 0; i < N; i++) {
        if(edges[i].size() == 1) continue;
        return dfs(i, -1) == 0;
    }
    assert(false);
}

int main() {
    cout << (solve() ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 15872
#include<stdio.h>
int main()
{
char a[3];
  scanf("%3s",a);
if(a[0]=='a' && a[1]=='b' && a[2]=='c') printf("Yes");
else if(a[0]=='a' && a[1]=='c' && a[2]=='b') printf("Yes");
else if(a[0]=='b' && a[1]=='a' && a[2]=='c') printf("Yes");  
else if(a[0]=='b' && a[1]=='c' && a[2]=='a') printf("Yes");  
else if(a[0]=='c' && a[1]=='b' && a[2]=='a') printf("Yes");  
else if(a[0]=='c' && a[1]=='a' && a[2]=='b') printf("Yes");  
else printf("No");
  
return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;

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;
}
using namespace std;

void solve(){
	int n,a,b;
    cin>>n>>a>>b;
    int x=a+b;
    string s;
    cin>>s;
    rep(i,n){
        if(s[i]=='c')cout<<"No\n";
        else if(s[i]=='a'){
            if(x>0){
                cout<<"Yes\n";
                x--;
            }
            else cout<<"No\n";
        }
        else {
            if(x>0&&b>0){
                b--;x--;
                cout<<"Yes\n";
            }
            else cout<<"No\n";
        }
    }
}

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 848
N=int(input())
for h in range(1,3501):
	for n in range(1,3501):
		tmp=4*h*n-N*n-N*h
		if tmp==0:continue
		w=N*n*h/tmp
		if 1<=w<=3500 and w==int(w):
			print(h,n,int(w))
			exit()
		

Measured memory_bytes: 40924
n=int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
p=make_divisors(n)

l=len(p)
if l%2==1:
  ans=p[l-1]*2-2
  
else:
  ans=p[l-1]+p[l-2]-2
  
print(ans)

Measured memory_bytes: 3264
n=int(input())
s=input()
k=0
l=[]
for i in range(n):
    if s[i]=="W":
        k+=1
    l.append(k)
#print(l)
#既に追加されたものまで変更されはしなかった
w=n
for i in range(n):
    if i==0:
        #if s[i]=="W":
        #    v=n-l[n-1]+1
        #else:
        #    v=n-l[n-1]
        #下のようにすれば分ける必要はない
        v=n-1-l[n-1]+l[0]
    else:
        v=l[i-1]+n-1-i-(l[n-1]-l[i])


    if v<w:
        w=v
print(w)


Measured memory_bytes: 15392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;cin >> n >> k;
	if(n==1) cout << k << endl;
	else{
		int ans=k;
		rep(i,n-1) ans*=k-1;
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <unordered_map>
#include <unordered_set>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

using std::min;
using std::max;

//#define int long long

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
//typedef string S;

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

inline int nextInt()
{
    int x = 0;
    char c = getchar();
    int mi = (c == '-');
    if (c == '-') c = getchar();
    while ('0' <= c && c <= '9')
    {
        x = 10 * x + c - '0';
        c = getchar();
    }
    if (mi) return x * -1;
    return x;
}

int n, m;
int g[50][50];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a][b] = 1;
        g[b][a] = 1;
    }
    vector<int> p;
    for (int i = 0; i < n; i++) p.push_back(i);
    ll ans = 0;
    while (1)
    {
        int t = 1;
        for (int i = 0; i < n - 1; i++) if (!g[p[i]][p[i + 1]]) t = 0;
        if (p[0] == 0 && t) ans++;
        if (!next_permutation(all(p)))
        {
            cout << ans;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <sstream>
using namespace std;
inline int toInt(string x) {
    stringstream ss(x); int ret; ss>>ret; return ret;
}
int main() {
    stack<int> expr;
    string input;
    while (cin >> input) {
        if (input == "+") {
            int a = expr.top(); expr.pop();
            int b = expr.top(); expr.pop();
            expr.push(a + b);
        } else if (input == "-") {
            int a = expr.top(); expr.pop();
            int b = expr.top(); expr.pop();
            expr.push(b - a);
        } else if (input == "*") {
            int a = expr.top(); expr.pop();
            int b = expr.top(); expr.pop();
            expr.push(a * b);
        } else {
            expr.push(toInt(input));
        }
    }
    cout << expr.top() << "\n";
    return 0;
}

Measured memory_bytes: 1232
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const ll mod = 1e9+7;
long double PI = acosl(-1);
const ll infl = 1e18;
const int inf = 2e9;
const int nmax = 1e6+5;
const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;

int compos[nmax], divs[nmax];

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

    int n;
    cin>>n;
    for(int i=1; i<=n; i++){
        for(int j=i; j<=n; j+=i){
            divs[j]++;
        }
    }
    ll ans = 0;
    for(int i=1; i<n; i++) ans += divs[i];
    cout<<ans<<endl;

}
/*
*/


Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    string t;
    int ans = 999999;
    bool aaa = false;
    set<char>ss;
    for(int i=0;i<s.length();i++)ss.insert(s[i]);
    if(ss.size() == 1)cout << 0 << endl;
    else{
for(int i=0;i<26;i++){
        char c = (i+'a');
        bool chk = false;
        t = s;
        while(!chk){
            string u = "";
            chk = true;
            for(int j=0;j<t.length()-1;j++){
                if(t[j]==c || t[j+1]==c)u+=c;
                else {
                    u+='1';
                    chk = false;
                }
            }
            t = u;
        }
        if(ans > s.length()-t.length())ans = s.length()-t.length();
    }
    cout << ans << endl;
    }


    
}


Measured memory_bytes: 256
N, M = gets.chomp.split.map(&:to_i)
requests = ARGF.map {|l| l.chomp.split.map(&:to_i) }

ans = 0
x = -1
requests.sort_by {|a, b| b}.each do |a, b|
  next if a <= x
  x = b - 1
  ans += 1
end
puts ans

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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    
    rep(i,5) {
        int a;
        cin >> a;
        if (a==0) {
            cout << i+1 << endl;
        }
    }
}


Measured memory_bytes: 3592
N, A, B = map(int,input().split())

def ten_sumfunc(n):
    ans = 0
    while(n>0):
        ans += n%10
        n = n//10
    return ans

total = 0
for i in range(N+1):
    sum1 = ten_sumfunc(i)
    if A <= sum1 and sum1 <= B:
        total += i
        
print(total)


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

long long int x, y;

int main(){
  cin >> x >> y;
  int cnt = 1;
  while(true){
    cerr << x << endl;
    x *= 2LL;
    if(x > y){
      break;
    }
    cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define join(a, d) accumulate(a.begin() + 1, a.end(), a[0], [](string s, string t) {return s + d + t;})
#define all(a) a.begin(), a.end()
// #define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

vector<int> Eratosthenes(const int N) {
  vector<bool> is_prime(N + 1);
  for (int i = 0; i <= N; ++i) {
    is_prime[i] = true;
  }
  vector<int> P;
  for (int i = 2; i <= N; ++i) {
    if (is_prime[i]) {
      for (int j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      P.emplace_back(i);
    }
  }
  return P;
}

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  vector<int> p = Eratosthenes(100000);
  vector<int> n2017;
  for (int i : p) {
    int n = (i + 1) / 2;
    if (binary_search(all(p), n)) n2017.push_back(i);
  }

  int Q;
  cin >> Q;
  rep(_, 0, Q) {
    int l, r;
    cin >> l >> r;
    int left = lower_bound(all(n2017), l) - n2017.begin();
    int right = upper_bound(all(n2017), r) - n2017.begin();
    cout << right - left << endl;
  }
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld double
long double PI =3.14159265;
using ll = long long;

const ll modo=7;
const ll ms=2e6+5;
const ll inf=-1e17;

int ar[ms];
int tree[ms]={0};


int query(int l,int r,int a,int b,int ind)
{
    if(a>r||l>b)return 0;


    if(l>=a&&b>=r)return tree[ind];


    int mid=(l+r)>>1;


    return max(query(l,mid,a,b,2*ind),query(mid+1,r,a,b,2*ind+1));
}


void update(int a,int b,int i,int v,int ind)
{
    if(a==b)
    {
        tree[ind]=v;
        return;
    }
    int mid=(a+b)>>1;

    if(i<=mid)
    {
        update(a,mid,i,v,2*ind);
    }
    else update(mid+1,b,i,v,2*ind+1);

    tree[ind]=max(tree[2*ind],tree[2*ind+1]);
}

int main()
{
    idfc;

    int n;
    int k;
    cin>>n>>k;
    int mx=0;
    int i;
    for(i=0;i<n;i++)
    {
        cin>>ar[i];
        mx=max(mx,ar[i]);
    }
    int x,y;
    int r;
    int ans=0;
    for(i=0;i<n;i++)
    {
        x=max(0,ar[i]-k);
        y=min(mx,ar[i]+k);
        r=query(0,mx,x,y,1);
        ans=max(ans,r+1);
        update(0,mx,ar[i],r+1,1);
    }
    cout<<ans;


    return 0;
}

Measured memory_bytes: 8928
#include <stdio.h>

long long int a, b, n;
int l;

int main(void) {
    scanf("%lld%lld", &a, &b);
    n = a;
    while(n<=b) {
        n*=2;
        l++;
    }
    
    printf("%d", l);
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using Flag = std::pair<int, std::pair<int, int> >;

struct State
{ int mask[3], dist, prv; };

int n, m;
int cup[3];

int back( int mask )
{
  for( int i = n-1; i >= 0; --i ) if( mask >> i & 1 )
    return i;

  return -1;
}

void quePush( std::queue<State> &que, int cup[], int dist, int prv )
{
  int x = back( cup[0] ), y = back( cup[1] ), z = back( cup[2] );

  //printf( "(x,y,z)=(%d,%d,%d)\n", x, y, z );

  if( prv )
  {
    if( x > y )
      que.push( { { cup[0]^(1<<x), cup[1]|(1<<x), cup[2] }, dist+1, 0 } );
    else
      que.push( { { cup[0]|(1<<y), cup[1]^(1<<y), cup[2] }, dist+1, 0 } );
  }

  if( prv != 1 )
  {
    if( y > z )
      que.push( { { cup[0], cup[1]^(1<<y), cup[2]|(1<<y) }, dist+1, 1 } );
    else
      que.push( { { cup[0], cup[1]|(1<<z), cup[2]^(1<<z) }, dist+1, 1 } );
  }

  return;
}

int main()
{
  while( std::cin >> n >> m, n|m )
  {
    std::queue<State> que;

    rep( i, 3 ) 
      cup[i] = 0;

    rep( i, 3 )
    {
      int lc;
      std::cin >> lc;
      int x;
      rep( j, lc )
        std::cin >> x, cup[i] |= 1<<(x-1);
    }

    //printf( "(%d,%d,%d)\n", cup[0], cup[1], cup[2] );

    if( cup[0] == (1<<n)-1 || cup[2] == (1<<n)-1 )
    {
      printf( "%d\n", 0 );

      goto end;
    }

    quePush( que, cup, 0, -1 );

    while( !que.empty() )
    {
      State st = que.front(); que.pop();

      if( st.dist > m )
        continue;

      //printf( "(%d,%d,%d,%d)\n", st.mask[0], st.mask[1], st.mask[2], st.dist );

      if( st.mask[0] == (1<<n)-1 || st.mask[2] == (1<<n)-1 )
      {
        printf( "%d\n", st.dist );

        goto end;
      }

      quePush( que, st.mask, st.dist, st.prv );
    }

    puts("-1");

end:;
  }
  
  return 0;
}


Measured memory_bytes: 3168
def a2a(alpha,n):
    if ord(alpha)+n-ord("A")<26:
        return chr(ord(alpha)+n)
    else:
        return chr(ord(alpha)+n-26)
N=int(input())
S=input()
ans=""
for t in S:
    ans=ans+a2a(t,N)
print(ans)

Measured memory_bytes: 3060
n = int(input())
A = list(map(int, input().split()))

# sum_A[j] := A[0]～A[j-1]までの和
sum_A = [0 for _ in range(n)]
for j in range(1, n):
    sum_A[j] = sum_A[j - 1] + A[j - 1]

ans = 0
for j in range(1, n):
    ans += A[j] * sum_A[j]
    ans = ans % (10**9 + 7)
print(ans)

Measured memory_bytes: 31696
<?php
function init() {
  $A1 = $A2 = $A3 = $A4 = array();
  for ($i=1; $i <= 3; $i++) {
    for ($j=1; $j <= 10; $j++) {
      $A1[$i][$j] = $A2[$i][$j] = $A3[$i][$j] = $A4[$i][$j] = 0;
    }
  }
  $result = scan($A1, $A2, $A3, $A4);
  output($result);
}

function scan($A1, $A2, $A3, $A4) {
  $cnt = trim(fgets(STDIN));
  for ($i=0; $i < $cnt; $i++) {
    list($build, $floor, $room, $number) = explode(' ', trim(fgets(STDIN)));
    ${'A'.$build}[$floor][$room] += $number;
  }

  return array($A1, $A2, $A3, $A4);
}

function output($result) {
  foreach ($result as $key => $A) {
    foreach ($A as $floor) {
      echo ' '.implode(' ', $floor)."\n";
    }
    if($key < 3) {
      echo '####################'."\n";
    }
  }
}

init();

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 100001;


lli n;
lli v[e5];
lli m0[e5];
lli m1[e5];
lli sum0;
lli sum1;
lli cost0[e5];
lli cost1[e5];
lli ans = 0;

int main(){
	cin >> n;
	for(lli i = 0;i < n;i++) cin >> v[i];
	for(lli i = 0;i < n;i+=2) m0[v[i]]++;
	sum0 = accumulate(begin(m0),end(m0),0ll);
	for(lli i = 0;i < e5;i++) cost0[i] = sum0-m0[i];
	for(lli i = 1;i < n;i+=2) m1[v[i]]++;
	sum1 = accumulate(begin(m1),end(m1),0ll);
	for(lli i = 0;i < e5;i++) cost1[i] = sum1-m1[i];
	if(min_element(begin(cost0),end(cost0))-begin(cost0) == min_element(begin(cost1),end(cost1))-begin(cost1)){
		sort(begin(cost0),end(cost0));
		sort(begin(cost1),end(cost1));
		cout << min(cost0[0]+cost1[1], cost0[1]+cost1[0]) << endl;
	}else{
		cout << *min_element(begin(cost0),end(cost0))+*min_element(begin(cost1),end(cost1)) << endl;
	}


}


Measured memory_bytes: 4096
import math

k = int(input())
n = input()

r = n.count("R")
g = n.count("G")
b = n.count("B")

ans = r*g*b

for i in range(k):
    
    for j in range(i + 1, math.ceil((k + i)/2)):
        
        if (n[i] != n[j]) and (n[2*j - i] != n[i]) and (n[j] != n[2*j - i]):
            ans -= 1

print(ans)

Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
const int INF=1e9;
template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}
typedef pair<int,int> P;

signed main(){
  int n,m;cin>>n>>m;
  vector<int> d(n),u(m),v(m);
  for(int i=0;i<n;i++)cin>>d[i];
  for(int i=0;i<m;i++){
    cin>>u[i]>>v[i];
    u[i]--;v[i]--;
  }
  vector<int> edge[n];
  for(int i=0;i<m;i++){
    edge[u[i]].push_back(v[i]);
    edge[v[i]].push_back(u[i]);
  }
  for(int i=0;i<n;i++){
    int A=INF;
    for(int p:edge[i])chmin(A,d[p]);
    if(A>d[i])fin(-1);
  }
  set<P> s;
  vector<int> edge2[n];
  map<P,int> ma;
  for(int i=0;i<n;i++){
    int idx,D=INF+1;
    for(int p:edge[i])if(D>d[p])D=d[p],idx=p;
    int A=idx,B=i;
    if(A>B)swap(A,B);
    if(s.count(P(A,B)))continue;
    s.insert(P(A,B));
    edge2[A].push_back(B);
    edge2[B].push_back(A);
    ma[P(A,B)]=d[i];
  }
  vector<int> col(n,0);
  queue<int> que;
  for(int i=0;i<n;i++){
    if(col[i])continue;
    col[i]=1;
    que.push(i);
    while(que.size()){
      int p=que.front();que.pop();
      for(int q:edge2[p]){
        if(col[q])continue;
        col[q]=-col[p];
        que.push(q);
      }
    }
  }
  for(int i=0;i<n;i++)cout<<(~col[i]?'B':'W');cout<<endl;
  for(int i=0;i<m;i++){
    if(u[i]>v[i])swap(u[i],v[i]);
    cout<<(ma[P(u[i],v[i])]?ma[P(u[i],v[i])]:INF)<<endl;
  }
}


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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main() {
    int n, m;
    cin >> n >> m;
    V<int> a(n);
    rep(i, n) cin >> a[i], --a[i];
    V<int> prf(m + 1);
    rep(i, n - 1) {
        if (a[i] < a[i + 1]) {
            prf[a[i] + 1]++;
            prf[a[i + 1]]--;
        } else {
            prf[a[i] + 1]++;
            prf[m]--;
            prf[0]++;
            prf[a[i + 1]]--;
        }
    }

    rep(i, m) prf[i + 1] += prf[i];

    ll s = 0;

    {
        rep(i, n - 1) {
            ll c1 = (a[i + 1] - a[i] + m) % m;
            ll c2 = (a[i + 1] - 0 + m) % m + 1;
            s += min(c1, c2);
        }
    }

    VV<int> idx(m);
    for (int i = 1; i < n; ++i) {
        idx[a[i]].pb(i);
    }

    ll ans = s;

    for (int x = 0; x < m - 1; ++x) {  // x -> x+1
        s -= prf[x];
        for (int i : idx[x]) {
            s += (a[i] - a[i - 1] + m) % m - 1;
        }
        chmin(ans, s);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5760