akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    double n, m, d;
    cin >> n >> m >> d;
    if (d == 0){
        cout <<  ((m - 1) /n) << "\n";
    }else{
        double k = (2 * m / n - 2 /n);
        double l = (1 - d / n);
        cout << setprecision(10) << (l* k) << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string s;

    cin >> s;

    for (int i = 0; i < (int)s.size(); i++) {
        if (s[i] == '1') {
            s[i] = '9';
        }
        else {
            s[i] = '1';
        }
    }

    cout << s << endl;

    return (0);
}


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

typedef pair<int, int> Pii;

void readint(int N, vector<int> &a);
void readdouble(int N, vector<double> &a);
void readindex(int N, vector<int> &a);



signed main(){

    int A, B, C, K;
    cin >> A >> B >> C;
    cin >> K;

    vector<int> a(3);
    a[0] = A;
    a[1] = B;
    a[2] = C;
    sort(a.begin(), a.end());

    int ans = a[0] + a[1] + a[2] * pow(2, K);

    cout << ans;
    
    return 0;
}








void readint(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str());
}
void readdouble(int N, vector<double> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atof(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atof(s.c_str());
}
void readindex(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str()) - 1;
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str()) - 1;
}

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


using namespace std;
using ll = long long;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}



int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s=="ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
   

    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long
#define dbg1(x) cerr<<#x<<"="<<(x)<<" "
#define dbg2(x) cerr<<#x<<"="<<(x)<<"\n"
#define dbg3(x) cerr<<#x<<"\n"
using namespace std;
#define reg register
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
const int Mod=998244353,MN=4004;
int Mul(int x,int y){return (1ll*x*y)%Mod;}
int Add(int x,int y){return (x+y)%Mod;}
int fac[MN],inv[MN],p2[MN];
int C(int i,int j)
{
	if(i<0||j<0||i<j)return 0;
	return Mul(fac[i],Mul(inv[j],inv[i-j]));
}
int F(int i,int j){return C(i+j-1,j-1);}
int sol(int N,int pr,int nm)
{
	reg int i,j=min(N,pr);int r=0;
	for(i=0;i<=j;++i)r=Add(r,Mul(p2[i],Mul(C(pr,i),F(N-i,nm-pr+i))));
	return r;
}
int main()
{
	int N,K;reg int i,Ma;
	K=read();N=read();Ma=max(K,N);
	for(fac[0]=i=1;i<=Ma*2;++i)fac[i]=Mul(fac[i-1],i);
	for(inv[0]=inv[1]=1,i=2;i<=Ma*2;++i) inv[i]=Mul(inv[Mod%i],(Mod-Mod/i));
	for(i=2;i<=Ma*2;++i) inv[i]=Mul(inv[i-1],inv[i]);
	for(p2[0]=i=1;i<=Ma*2;++i) p2[i]=Mul(p2[i-1],2);
	for(i=2;i<=K*2;++i)
	{
		int ans=0,pr=i/2-max(i-K,1)+1;
		if(i%2==0) ans=Add(ans,sol(N-1,pr-1,K-pr));
		ans=Add(ans,sol(N,pr-(i%2==0),K-pr));
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 384
#include"bits/stdc++.h"

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int>T(N+1);
	int sum = 0;
	for (int i = 1; i <= N; i++) {
		cin >> T[i];
		sum += T[i];
	}
	int M;
	cin >> M;

	while(M--){
		int ans = sum;
		int P, M;
		cin >> P >> M;
		cout << sum - T[P] + M << endl;
	}
	return 0;
}

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

using namespace std;

const int INF = 1 << 29;

int N, Ma, Mb, A[40], B[40], C[40];

void dfs(int idx, int x, int y, int z, int end, vector< pair< pair< int, int >, int > > &odd)
{
  if(idx == end) {
    odd.emplace_back(make_pair(x, y), z);
  } else {
    dfs(idx + 1, x + A[idx], y + B[idx], z + C[idx], end, odd);
    dfs(idx + 1, x, y, z, end, odd);
  }
}

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

  vector< pair< int, int > > range;
  vector< pair< pair< int, int >, int > > a, b;
  for(int i = 1; i <= 400; i++) {
    int low = i * Mb;
    if(low % Ma != 0) continue;
    if(low / Ma > 400) continue;
    range.emplace_back(i, low / Ma);
  }
  for(int i = 0; i < N; i++) {
    cin >> A[i] >> B[i] >> C[i];
  }
  dfs(0, 0, 0, 0, N / 2, a);
  dfs(N / 2, 0, 0, 0, N, b);


  int call1[401][401], call2[401][401];
  fill_n(*call1, 401 * 401, INF);
  fill_n(*call2, 401 * 401, INF);
  call1[0][0] = 0;
  call2[0][0] = 0;
  for(auto &s : a) {
    auto &q = s.first;
    call1[q.first][q.second] = min(call1[q.first][q.second], s.second);
  }
  int ret = INF;
  for(auto &s : b) {
    auto &q = s.first;
    call2[q.first][q.second] = min(call2[q.first][q.second], s.second);
  }

  for(auto &s : range) {
    int sumA = s.first;
    int sumB = s.second;
    for(int j = 0; j <= sumA; j++) {
      for(int k = 0; k <= sumB; k++) {
        ret = min(ret, call1[j][k] + call2[sumA - j][sumB - k]);
      }
    }
  }
  if(ret == INF) cout << -1 << endl;
  else cout << ret << endl;
}

Measured memory_bytes: 32748
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using Graph=vector<vector<int>>;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
int roundup(int a,int b){return	(a-1)/b+1;}
void YN(bool flg){cout<<(flg?"YES":"NO")<<endl;}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<endl;}
void yn(bool flg){cout<<(flg?"yes":"no")<<endl;}


signed main(){
	int t;cin>>t;
	rep(i,t){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		bool ok=true;
		if(a<b){
			cout<<"No"<<endl;
			continue;
		}
		if(b>d){
		    cout<<"No"<<endl;
		    continue;
		}
		if(b<=c){
			cout<<"Yes"<<endl;
			continue;
		}
		int g=gcd(b,d);
		Yn(b-g+a%g<=c);
	}
}


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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	char ch;
	set<char> st;
	for (int i=0; i<n; i++) {
		cin>>ch;
		st.insert(ch);
	}
	cout << (st.size()==3 ? "Three" : "Four") << endl;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	
	long long int a, b, c, d;
	cin >> a >> b >> c >> d;
	long long int ans = 0;
	long long int h = 0;
	long long int p = c, g = d;

	while (1) {
		if (p > g)swap(p, g);
		if (!p)break;
		g %= p;
	}
	h = c*d / g;
	ans = b - b / c - b / d+b/h;
	a--;
	ans -= (a - a / c - a / d + a / h);
	cout << ans << endl;

	return 0;



}

Measured memory_bytes: 256
import math

N, M = [int(x) for x in input().split()]
edges = [[int(x) for x in input().split()] for _ in range(M)]

forward_edges = {n+1:[] for n in range(N)}
reverse_edges = {n+1:[] for n in range(N)}
for e in edges:
  forward_edges[e[0]].append(e[1])
  reverse_edges[e[1]].append(e[0])
# print(  forward_edges)
# print(  reverse_edges)
estimated_distance = {n+1:None for n in range(N)}
estimated_distance[N] = 0
probability = {n+1:None for n in range(N)}
probability[1] = 1
def get_probability(n):
  if probability[n] is not None:
    return probability[n]
  prob = 0
  for m in reverse_edges[n]:
    prob += get_probability(m) / len(forward_edges[m])
  probability[n] = prob
  return prob
  
def get_distance(n):
  if estimated_distance[n] is not None:
    return estimated_distance[n]
  total_distance = 0
  for m in forward_edges[n]:
    total_distance += get_distance(m)
  estimated_distance[n] = 1 + total_distance / len(forward_edges[n])
  return estimated_distance[n]


before_distance = get_distance(1)
max_decrease = 0
for n in range(1, N):
  if len(forward_edges[n]) == 1:
    continue
  distances = [get_distance(m) for m in forward_edges[n]]
  distance_diff = sum(distances) / len(distances) - (
    sum(distances)-max(distances))/(len(distances)-1)
  decrease = get_probability(n) * distance_diff
  max_decrease = max(max_decrease, decrease)

print(before_distance - max_decrease)
    


Measured memory_bytes: 34368
#include <iostream>
#include <algorithm>
#include <vector>

using lint = long long;

void solve() {
    int n;
    std::cin >> n;

    std::vector<lint> xs(n);
    for (auto& x : xs) std::cin >> x;
    std::sort(xs.rbegin(), xs.rend());

    lint sum = 0;
    for (int i = 0; i < n; ++i) sum += xs[i / 2];

    std::cout << sum - xs[0] << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 4764
#include <stdio.h>
#include <stdlib.h>

int max(int a, int b){
	return a > b ? a : b;
}

int main(void){
	int n, **happy, in;
	scanf("%d", &n);
	happy = malloc(sizeof(int*) * 3);
	for(int i = 0; i < 3; i++)happy[i] = malloc(sizeof(int) * n);
	for(int i = 0; i < 3; i++)
		scanf("%d", happy[i]);
	for(int i = 1; i < n; i++){
		for(int j = 0; j < 3; j++){
			scanf("%d", &in);
			happy[j][i] = 0;
			for(int k = 0; k < 3; k++){
				if(k == j)continue;
				happy[j][i] = max(happy[j][i], happy[k][i - 1] + in);
			}
		}
	}
	in = 0;
	for(int i = 0; i < 3; i++)in = max(in, happy[i][n - 1]);
	printf("%d\n", in);
	return 0;
}


Measured memory_bytes: 1280
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>

using namespace std;
const int64_t INF=10000000000000000;

int main(){
	int64_t n;
	cin>>n;
	vector<int64_t> a;
	a.reserve(n);
	for(int64_t i1=0;i1<n;i1++){
		int64_t temp;
		cin>>temp;
		a.push_back(temp);
	}
	vector<int64_t> sum;
	sum.reserve(n+1);
	sum.push_back(0);
	int64_t c_sum=0;
	for(int64_t i1=0;i1<n;i1++){
		c_sum+=a[i1];
		sum.push_back(c_sum);
	}
	sort(sum.begin(),sum.end());
	int64_t same_num=1;
	int64_t ans=0;
	for(int64_t i1=1;i1<=n;i1++){
		if(sum[i1-1]==sum[i1]){
			same_num++;
		}else{
			ans+=(same_num*(same_num-1))/2;
			same_num=1;
		}
	}
	ans+=(same_num*(same_num-1))/2;
	cout<<ans<<endl;




}

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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll n,i,a[200000];
	cin>>n;
	for (i=0;i<n;i++){
		cin>>a[i];
		a[i]-=(i+1);
	}
	sort(a,a+n);
	if (n%2==1){
		ll t=-a[(n-1)/2],s=0;
		for (i=0;i<n;i++){
			s+=abs(a[i]+t);
		}
		cout<<s;
	}
	else {
		ll t1=-a[n/2],t2=-a[n/2-1],s1=0,s2=0;
		for (i=0;i<n;i++){
			s1+=abs(a[i]+t1);
		}
		for (i=0;i<n;i++){
			s2+=abs(a[i]+t2);
		}
		cout<<min(s1,s2);
	}
	return 0;
}

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

using namespace std;
using ll = int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using tpi = tuple<int, int, int>;

using vqi = vector<queue<int>>;
using vpi = vector<pii>;
using bs = bitset<60>;
using vbi = vector<bs>;

ll gcd(ll a, ll b) {
  if (a < b) {
    swap(a, b);
  }

  /* ユークリッドの互除法 */
  ll r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

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

constexpr int64_t __pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
  if (p == 0) {
    return 1;
  }
  if (p % 2 == 0) {
    int64_t t = __pow_mod(n, p / 2, mod);
    return (t * t) % mod;
  }
  return (n * (__pow_mod(n, p - 1, mod) % mod)) % mod;
}

constexpr int64_t pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
  int64_t res = __pow_mod(n, p, mod);
  if (res == 0) {
    res = mod;
  }
  return res;
}

void solve(std::string S) {
    int l=S.size();

    for (int i=0;i<l;i++){
        cout<<'x';
    }
    cout<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

#define N 100016

int ans[N];
vpii adj[N];

void dfs(int u, int p = 0, int c = 0)
{
    ans[u] = c&1;
    for (const pii &e : adj[u]) {
        int v = e.fir, w = e.sec;
        ctif(v == p);
        dfs(v, u, c^w);
    }
}

int main()
{
    canhazfast();

    int n;

    cin >> n;
    for (int i = 1; i < n; ++i) {
        int u, v, w;
        cin >> u >> v >> w;
        adj[u].empb(v, w);
        adj[v].empb(u, w);
    }
    dfs(1);
    for (int i = 1; i <= n; ++i) cout << ans[i] << '\n';

    return 0;
}


Measured memory_bytes: 8448
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

int main() {
	int s[24 * 60 * 60];
	for (int n; cin >> n&&n;) {
		memset(s, 0, sizeof(s));

		for (int i = 0; i < n; i++) {
			char c;
			int shh, smm, sss, ghh, gmm, gss;
			cin >> shh >> c >> smm >> c >> sss;
			cin >> ghh >> c >> gmm >> c >> gss;

			int ss = shh * 60 * 60 + smm * 60 + sss;
			int gs = ghh * 60 * 60 + gmm * 60 + gss;

			for (int j = ss; j < gs; j++) {
				s[j]++;
			}
		}

		cout << *max_element(s, s + 24 * 60 * 60) << endl;

	}
	return 0;
}

Measured memory_bytes: 1504
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vii vector <int>::iterator 
#define vd vector <double>
#define vdd vector <double>::iterator
#define vs vector <string>
#define vss vector <string>::iterator
#define vc vector <char>
#define vcc vector <char>::iterator
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
#define SORT(x)     sort(x.begin(),x.end())
#define fill(x,y)   memset(x, y, sizeof(x))
#define PI 2*acos(0.0)
#define fio ios::sync_with_stdio(false);cin.tie(0)
using namespace std;
int main(){
   ll a;
   cin >> a;
   cout << a*(1+(a*(a+1))) << endl;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MIN(a,b) ((a)<(b)?(a):(b))

int count(int array[], int left, int right) {
   if (left > right) {
      return 0;
   }
   if (left == right) {
      return array[left];
   }
   for (int i = left; i <= right; i++) {
      if (array[i] == 0) {
         return count(array, left, i - 1) + count(array, i + 1, right);
      }
   }
   int minimum = 10000000;
   for (int i = left; i <= right ; i++) {
      minimum = MIN(minimum, array[i]);
   }
   for (int i = left; i <= right; i++) {
      array[i] -= minimum;
   }
   return count(array, left, right) + minimum;
}


int main(void) {
   int N;
   int L[101];
   scanf("%d", &N);
   for (int i = 0; i < N; i++) {
      scanf("%d", &L[i]);
   }
   int ans = count(L, 0, N - 1);
   printf("%d\n", ans);
   return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long n,m;
int main(){
	scanf("%lld%lld",&n,&m);
	if(n*2>m){
		printf("%lld\n",m/2);
		exit(0);
	}
	else{
		long long ans=n;
		m-=n*2;
		ans+=m/4;
		printf("%lld\n",ans);
	}
    return 0;
}

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

int n;
int dp[101][64];
constexpr int mod = 1e9+7;

// _AGC
// A_GC
// _GAC
// _ACG
// AG_C

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=0; i<4; ++i)
		dp[1][60+i] = 1;
	for(int i=2; i<=n; ++i){
		for(int j=0; j<4; ++j){
			for(int k=0; k<64; ++k){
				if(j == 1){
					if(k%16 == 2 || k%16 == 8) continue;
					if(k/4 == 2) continue;
					if(k/16 == 0 && k%4 == 2) continue;
				}else if(j == 2){
					if(k%16 == 1) continue;
				}
				dp[i][k%16*4+j] += dp[i-1][k];
				dp[i][k%16*4+j] %= mod;
			}
		}
	}
	int ans = 0;
	for(int i=0; i<64; ++i)
		ans = (ans + dp[n][i]) % mod;
	cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	while(1){
		int h,w,n,m;
		cin>>h>>w>>n>>m;
		if(h==0) break;
		vvi a(h,vi(w,1));
		for(int i=0;i<n;i++){
			int t,x;
			cin>>t>>x;
			vvi b;
			if(t==1){
				b=vvi(max(h-x,x),vi(w));
				for(int j=0;j<h;j++) for(int k=0;k<w;k++){
					if(j<x) b[x-j-1][k]+=a[j][k];
					else b[j-x][k]+=a[j][k];
				}
				h=max(h-x,x);
			}
			else{
				b=vvi(h,vi(max(w-x,x)));
				for(int j=0;j<h;j++) for(int k=0;k<w;k++){
					if(k<x) b[j][x-k-1]+=a[j][k];
					else b[j][k-x]+=a[j][k];
				}
				w=max(w-x,x);
			}
			a=b;
		}
/*		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++) cout<<a[i][j]<<' ';cout<<endl;
		}*/
		for(int i=0;i<m;i++){
			int x,y;
			cin>>x>>y;
			cout<<a[x][y]<<endl;
		}
	}
}


Measured memory_bytes: 3160
a,b,c,x,y = map(int,input().split(" "))
count = 0
if a + b <= c * 2:
    count += a * x
    count += b * y
else:
    count += (c * 2) * min(x,y)
    if min(x,y) == x:
        if b <= c * 2:
            count += (y - x) * b
        else:
            count += (y - x) * (c * 2)
    else:
        if a <= c * 2:
            count += (x - y) * a
        else:
            count += (x - y) * (c * 2)
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define ALL(v) v.begin(),v.end()
#define mod 1000000007

ll a[100100]={0};
map<ll,ll>mp;
//sum[i+1]は0番目からi番目までのi+1個の累積和

int main(){
  mp[0]=1;
  ll n,m;
  cin >> n >> m;
  ll res,sum=0;
  rep(i,n){
    cin >> a[i];
    sum+=a[i];
    res=sum%m;
    if(mp.find(res)==mp.end())mp[res]=1;
    else mp[res]++;
  }
  ll ans=0;
  for(auto itr=mp.begin();itr!=mp.end();itr++){
    ll tmp=itr->second;
    ans+=tmp*(tmp-1)/2;
  }
  cout << ans << endl;

}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, k, x; cin>>n>>k;
	priority_queue<int>pq;
	for(int i=0;i<n;i++){
		cin>>x;
		pq.push(-x);
	}
	int ret=0;
	while(k--){
		ret += -pq.top();
		pq.pop();
	}
	cout<<ret<<endl;

	return 0;
}

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;

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

int main() {
  int N,C;
  cin>>N>>C;
  vector<vector<int>> time(C,vector<int>(200100));
  for(int i = 0; i < N; i++){
    int s,t,c;
    cin>>s>>t>>c;
    time[c-1][2*s]++;
    time[c-1][2*t]--;
  }
  for(int i = 0; i < C;i++){
    for(int j = 1; j < 200100;j++){
      if(time[i][j]==1){
        time[i][j-1]=1;
        time[i][j]=0;
      }
    }
  }
  vector<int> all(200100,0);
  for(int i = 0; i < 200100; i++){
    for(int j = 0; j < C; j++){
      all[i]+=time[j][i];
    }
  }
  int ans = 0;
  for(int i = 1; i < 200100; i++){
    all[i]+=all[i-1];
    chmax(ans,all[i]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 24576
a = input()

answer = 'Good'
if a[0] == a[1] and a[2] != a[3]:
  answer = 'Bad'
  
if a[1] == a[2] and a[0] != a[3]:
  answer = 'Bad'
  
if a[2] == a[3] and a[0] != a[1]:
  answer = 'Bad'

if a[0] == a[1] and a[2] == a[3]:
  answer = 'Bad'
  
if a[0] == a[1] == a[2] != [3]:
  answer = 'Bad'
  
if a[1] == a[2] == a[3] != [0]:
  answer = 'Bad'

if a[0] == a[1] == a[2] == [3]:
  answer = 'Bad'

print(answer)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

int main()
{
	long long a,b,c;
	cin>>a>>b>>c;
	
	long long d = c-a-b;
	if(d<=0)
	{
		cout<<"No"<<endl;
		return 0;
	}

	if(4*a*b < d*d)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
from itertools import combinations_with_replacement

n, m, q = map(int,input().split())
conditions = []
for i in range(q): 
    conditions.append(list(map(int,input().split())))

cands = []
for i in combinations_with_replacement(list(range(1,m+1)),n):
    cands.append(i)

maxi = 0
for cand in cands:
    score = 0
    for condition in conditions:
        if cand[condition[1]-1] - cand[condition[0]-1]  == condition[2]:
            score += condition[3]
    if score > maxi:
        maxi = score
print(maxi)

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

int main() {
    int a, b, c, d;

    cin >> a >> b >> c >> d;

    if( a + b > c + d){
        cout << "Left" << endl;
    }
    else if ( a + b < c + d){
        cout << "Right" << endl;
    }
    else if ( a + b == c + d){
        cout << "Balanced" << endl;
    }
}

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

int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);

  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int ans = 0;
  for (int i = 0; i < n - 1; ++i)
    if (a[i] <= x)
      x -= a[i], ++ans;
    else
      break;
  cout << ans + (a[n - 1] == x) << "\n";
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ac = 0;
		int wa = 0;
		int tle = 0;
		int re = 0;
		for (int i = 0; i < N; i++) {
			String S = sc.next();
			if (S.equals("AC")) {
				ac++;
			} else if (S.equals("WA")) {
				wa++;
			} else if (S.equals("TLE")) {
				tle++;
			} else {
				re++;
			}
		}
		sc.close();
		System.out.println("AC x " + ac);
		System.out.println("WA x " + wa);
		System.out.println("TLE x " + tle);
		System.out.println("RE x " + re);
	}
}


Measured memory_bytes: 59556
//abc179_c.cpp
//Sat Sep 19 21:04:47 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

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

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

	ll ans = 0;
	for (int i=1;i<=n;i++){
		ll x = n/i;
		if(n%i==0)x--;
		ans += x;
	}


	cout << ans << endl;
//	printf("%.4f\n",ans);
}


Measured memory_bytes: 3632
#include <stdio.h>

int main(void)
{
    int i, j;
    int n;
    int a, sum;
    int min, max;
    
    while (1){
        scanf("%d", &n);
        
        if (n == 0){
            break;
        }
        
        for (i = 0; i < n; i++){
            sum = 0;
            for (j = 0; j < 5; j++){
                scanf("%d", &a);
                sum += a;
            }
            if (i == 0){
                min = max = sum;
            }
            if (min > sum){
                min = sum;
            }
            if (sum > max){
                max = sum;
            }
        }
        printf("%d %d\n", max, min);
    }
    
    return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e18;
string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    string S[N], five[5], a = ".";
    rep(i, N){
        S[i] = "";
        rep(j, N) S[i] += a;
    }
    if(N == 2){cout << -1 << endl; exit(0);}
    elif(N == 3){
        S[0] = "a..", S[1] = "a..", S[2] = ".bb";
        rep(i, N) cout << S[i] << endl;
        exit(0);
    }
    elif(N == 7){
        S[0] = ".aabbcc", S[1] = "adee...", S[2] = "ad.f...", S[3] = "bggf...",
        S[4] = "b...dee", S[5] = "c...d.f", S[6] = "c...ggf";
        rep(i, N) cout << S[i] << endl;
        exit(0);
    }
    five[0] = "abbcc", five[1] = "ad..b", five[2] = "bd..b", five[3] = "b.dda", five[4] = "ccbba"; 
    int m = N%2, n = (N-5*m)/2;
    rep(i, n){
        S[2*i][2*i] = alpha[0];
        S[2*i][2*i+1] = alpha[0];
        S[2*i+1][2*i] = alpha[1];
        S[2*i+1][2*i+1] = alpha[1];
        int j = (i+1)%n;
        S[2*j][2*i] = alpha[2];
        S[2*j+1][2*i] = alpha[2];
        S[2*j][2*i+1] = alpha[3];
        S[2*j+1][2*i+1] = alpha[3];
    }
    if(m == 1){
        rep(i, 5)rep(j, 5){
            S[2*n+i][2*n+j] = five[i][j];
        }
    }
    rep(i, N) cout << S[i] << endl;
}

Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

signed main(){
  int h;
  cin >> h;
  int cnt = 1;
  int ans = 0;
  while(h){
    h/=2;
    ans += cnt;
    cnt*=2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<bitset>
#include<queue>
#include<cmath>
#include<map>
#include<cstring>
#define rep(i,j,k) for(register int i = j; i <= k; i++)
#define dow(i,j,k) for(register int i = j; i >= k; i--)
#define ull unsigned long long
#define ll long long
#define eps 1e-9
using namespace std;

inline int read() {
	int s = 0, t = 1; char c = getchar();
	while( !isdigit(c) ) { if( c == '-' ) t = -1; c = getchar(); }
	while( isdigit(c) ) s = s * 10 + c - 48, c = getchar();
	return s * t;
}

const int N = 100005;
int t[N];

int main() {
	int n = read(), c = read(), k = read();
	rep(i,1,n) t[i] = read();
	sort(t+1,t+n+1);
	int now = t[1] + k, tot = 1, ans = 1;
	rep(i,2,n) {
		if( tot == c || t[i] > now ) now = t[i] + k, tot = 1, ans++;
		else tot++;
	}
	cout<<ans<<endl;
	return 0;   
}

Measured memory_bytes: 640
import math
a,b,h,m = map(int,input().split())
ax = a*math.sin((h/12+m/60/12)*2*math.pi)
ay = a*math.cos((h/12+m/60/12)*2*math.pi)
bx = b*math.sin((m/60)*2*math.pi)
by = b*math.cos((m/60)*2*math.pi)
print(math.sqrt((ax-bx)**2+(ay-by)**2))

Measured memory_bytes: 9576
import math


# def calc(n, c, d):
#     return n-(math.floor(n / c) +
#               math.floor(n / d) - math.floor(n / (c * d / math.gcd(c, d))))
def calc(n, c, d):
    return n-(n // c +
              n // d - n // (c * d // math.gcd(c, d)))


def main():
    a, b, c, d = map(int, input().split())

    print(calc(b, c, d)-calc(a-1, c, d))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9044
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        long n=sc.nextLong();
        long s=(long)sqrt(n)+1;
        int ans=100;
        for (long i = 1; i <= s; i++) {
            if(n%i==0)ans=min(F(i,n/i),ans);
        }
        out.println(ans);
    }
    static int F(long A,long B){
        return max(get(A),get(B));
    }
    static int get(long n){
        int c=1;
        while (n/10>0){
            c++;
            n/=10;
        }
        return c;
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll a, b;
    cin >> a >> b;
    cout << max({a+b, a-b, a*b}) << endl;
}


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

void solve (int n, int m) {
    vector<vector<int>> score(n, vector<int>(m));
    rep(i, m) rep(j, n) cin >> score[j][i];
    int ans = 0;
    rep(i, n) ans = max(ans, accumulate(score[i].begin(), score[i].end(), 0));
    cout << ans << '\n';
}

int main() {
    int n, m;
    while(cin >> n >> m) {
        if(!n) break;
        solve(n, m);
    }
    return 0;
}



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

int main() {
	
	string s; cin >> s;
	if (s.size() == 1) {
		cout << stoll(s) << endl;
		return 0;
	}
	ll n = s.size();
	ll ans = 0;
	for (ll bit = 0; bit < (1 << n - 1); ++bit) {
		ll tmpSum = 0;
		ll tmpS = (ll)(s[0] - '0');
		for (ll i = 0; i < n - 1; ++i) {
			if (bit & (1 << i)) {
				tmpSum += tmpS;
				tmpS = 0;
			}
			else{
				tmpS *= 10;				
			}
			tmpS += (ll)(s[i + 1] - '0');
			if (i == n - 2) {
				tmpSum += tmpS;
			}
		}
		ans += tmpSum;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long int ll;
int main()
{
	ll t;
	cin>>t;
	ll ac=0,wa=0,tle=0,re=0;
	while(t--)
	{
		string s;
		cin>>s;
		if(s=="AC")
		ac++;
		else if(s=="WA")
		wa++;
		else if(s=="TLE")
		tle++;
		else
		re++;
	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;
}

Measured memory_bytes: 3624
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] s = br.readLine().split(" ");
		int n = Integer.parseInt(s[0]);
		int k = Integer.parseInt(s[1]);
		s = br.readLine().split(" ");
		int[] h = new int[n];
		for (int i = 0; i < n; i++)
			h[i] = Integer.parseInt(s[i]);

		if (n == 2) {
			System.out.println(h[1] - h[0]);
			return;
		}

		int[] min = new int[n];

		for (int i = 1; i < n; i++) {
			int m = Integer.MAX_VALUE;
			for (int j = 1; j <= k; j++) {
				int x = Math.abs(h[i] - h[i - j]) + min[i-j];
				if (m > x) {
					m = x;
				}
				if (i - j == 0)
					break;
			}
			min[i] = m;
		}

		System.out.println(min[n-1]);
	}

}


Measured memory_bytes: 37092
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main(){
	long long int a,i;
	while(scanf("%lld",&a)!=EOF){
		for(i=1;i<=100000;i++){
			if(i*i<=a&&(i+1)*(i+1)>a){
				printf("%lld\n",i*i);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		
		int Capacity = A-B;
		System.out.println(Math.max(C-Capacity, 0));
		
		sc.close();	
	}

}

Measured memory_bytes: 23124
#include <stdio.h>

int main(void)
{
	int n, i;
	
	scanf("%d", &n);
	printf("%d:", n);
	
	i = 2;
	while (1){
		if (n == 1 || i * i > n){
			break;
		}
		else if (n % i == 0){
			printf(" %d", i);
			n /= i;
		}
		else if (i == 2){
			i++;
		}
		else {
			i += 2;
		}
	}
	
	if (n != 1){
		printf(" %d", n);
	}
	
	puts("");
	
	return (0);
}

Measured memory_bytes: 608
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string S, T;
	cin >> S >> T;
	int count = 0;

	for (int i = 0; i < S.size(); i++) {
		if (S.at(i) != T.at(i))
			count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3916
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int a = 0, b = 0;
		for(int i = 0; i < n; i++) {
			if(s.charAt(i) == '(') a++;
			else {
				if(a > 0) a--;
				else b++;
			}
		}
		for(int i = 0; i < a; i++) s += ")";
		for(int i = 0; i < b; i++) s = "(" + s;
		System.out.println(s);
	}
}


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

using namespace std;

int32_t main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    long long a;

    cin >> a;

    long long b;

    cin >> b;

    long long c;

    cin >> c;

    long long d;

    cin >> d;

    long long pos1 = a*c;

    long long pos2 = a*d;

    long long pos3 = b*c;

    long long pos4 = b*d;

    cout << max(pos1,max(pos2,max(pos3,pos4))) << '\n';

    return 0;

}



Measured memory_bytes: 3644
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long int lli;
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<pll> vop;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define REP(i,a,b) for( long long i=a;i<b;i++)
#define PB push_back
#define N 200007

vl g[N];
bool vis[N];
ll dis[N];
ll ans = 0;

void dfs(ll v)
{
    vis[v] = true;
    for (auto u : g[v])
    {
        if (!vis[u])
            dfs(u);
        dis[v] = max(dis[v], 1 + dis[u]);
    }
}

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

    fastIO;
    int test = 1, num = 1;
    //cin >> test;
    while (test--)
    {
        ll n, m;
        cin >> n >> m;
        REP(i, 0, m)
        {
            ll u, v;
            cin >> u >> v;
            g[u].PB(v);
        }
        REP(i, 1, n + 1)
        {
            if (!vis[i])
            {
                dfs(i);
            }
        }
        REP(i, 1, n + 1) ans = max(ans, dis[i]);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 14880
X=input()
Y=input()
dp=[[0 for y in range(1+len(Y))] for x in range(1+len(X))]
for x in range(len(X)):
    dp[x+1][0]=x+1
    for y in range(len(Y)):
        dp[0][y+1]=y+1
        if X[x]==Y[y]:cost=0
        elif X[x]!=Y[y]:cost=1
        dp[1+x][1+y]=min(dp[1+x][y]+1,dp[x][1+y]+1,dp[x][y]+cost)
print(dp[len(X)][len(Y)])


Measured memory_bytes: 44020
<?php
fscanf(STDIN, "%s", $strings);

fscanf(STDIN, "%d", $q);
$mae = [];
$ato = [];
$rev = 0;
while($q--){
    $query = explode(" ", trim(fgets(STDIN)));
    if($query[0] == 1){
        $rev = ($rev + 1) % 2;
    }else{
        if($query[1] == 1){
            if($rev == 0){
                $mae[] = $query[2];
            }else{
                $ato[] = $query[2];
            }
        }else{
            if($rev == 0){
                $ato[] = $query[2];
            }else{
                $mae[] = $query[2];
            }
        }
    }

}
if($rev == 0){
    $mae = array_reverse($mae);
    echo implode("",$mae).$strings.implode("",$ato);
}else{
    $ato = array_reverse($ato);
    echo implode("",$ato).strrev($strings).implode("",$mae);
}


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

#define endl '\n'

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

    long long n, c=10LL, ans = 0; cin >> n;
    if (n & 1LL){
        cout << "0\n";
        return 0;
    }
    long long x = n;
    while(c>0 && x/c > 0){
        ans += x/c;
        c *= 5LL;
    }
    cout << ans << endl;
    
    return 0;
    long long ans2=0;
    for (long long i = n; i>0; i-=2){
        long long y = i;
        while(y % 5 == 0){
            y /= 5;
            ans2++;
        }
    }
    cout << ans2 << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

int a[100000];
int b[100000];
vector<int> bb;
int main()
{
	int n,h;
	int min=0;
	int amax,amaxi; 
	amax=0;
	cin>>n>>h;
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
		if(amax<a[i])
		{
			amax=a[i];
			amaxi=i;
		}
	}
	for(int i=0;i<n;i++)
	{
		if(amax<=b[i])
		{
			bb.push_back(b[i]);
		}
	}
	sort(bb.begin(),bb.end());

	while(h>0 && !bb.empty())
	{
		h-=bb.back();
		bb.pop_back();
		min++;
	}
	if(h>0)
	{
		min += h/amax;
		if(h%amax!=0)
		{
			min++;
		}
	}
	cout<<min<<endl;
	return 0;
}

Measured memory_bytes: 1660
N = int(input())
x, y, h = [0]*N, [0]*N, [0]*N
for i in range(N):
    x[i], y[i], h[i] = map(int, input().split())

for cx in range(0, 101):
    for cy in range(0, 101):
        for i in range(N):
            if h[i] > 0:
                H = h[i] + abs(x[i]-cx)+abs(y[i]-cy)
        
        for i in range(N):
            if h[i] != max(0, H-abs(x[i]-cx)-abs(y[i]-cy)):
                break
        else:
            print(cx, cy, H)
            exit()

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

int main(){
    ll n;cin>>n;
    ll arr[3*n];
    for(int i=0;i<3*n;i++) cin>>arr[i];
    sort(arr,arr+3*n,greater<ll>());
    ll x=0,s=0,i=1;
    while(x<n && i<3*n){
        s+=arr[i];
        i+=2;
        x++;
    }
    cout<<s<<"\n";
}

Measured memory_bytes: 5980
#include <bits/stdc++.h>
#define N 3000
#define mod 1000000007
#define ll long long
#define ii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define prob "I"
#define fast ios_base:: sync_with_stdio(1); cin.tie(nullptr); cout.tie(nullptr);
#define io freopen(prob".inp","r",stdin); freopen(prob".out","w",stdout);
using namespace std;
int n;
double a[N],f[N][N];
void read()
{
    cin>>n;
    for(int i=1; i<=n; i++)
        cin>>a[i];
}
void solve()
{
    f[0][0]=1;
    for(int i=1; i<=n; i++)
        f[i][0]=f[i-1][0]*a[i];
    for(int j=1; j<=n/2; j++)
    {
        for(int i=1; i<=n; i++)
        {
          if(j>i) continue;
            f[i][j]=f[i-1][j]*a[i];
            f[i][j]+=f[i-1][j-1]*(1-a[i]);
         //   cout<<f[i][j]<<' ';
        }
     //   cout<<endl;
    }
    double ans=0;
    for(int j=0;j<=n/2;j++) ans+=f[n][j];
    cout<<fixed<<setprecision(10)<<ans;
}
int main()
{
    fast
   // io
    read();
    solve();
}


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

using namespace std;

int main()
{
	int N = 0;
	while (N < 1 || N>200000)
	{
//		cout << "Input the number of the numerical series :" << endl;
		cin >> N;
	}

	vector<int> a(N, 0);
	int remainder;
	int cnt;
//	cout << "Input the remainder of the every term devided by 2 and press enter key one by one :" << endl;

	for (cnt = 0; cnt < N; cnt++)
	{
		remainder = -1;
		while ((remainder != 0) && (remainder != 1))
		{
			cin >> remainder;
		}
		a[cnt] = remainder;
	}

//	printf("\n");

	vector<bool> b(N, 0);
	int prop;
	int sum;
	for (cnt = N - 1; cnt >= 0; cnt--)
	{
		sum = 0;
		sum = a[cnt];
		prop = 2;
		while (prop * (cnt + 1) <= N)
		{
			sum += b[prop * (cnt + 1) - 1];
			prop++;
		}
		b[cnt] = sum % 2;
	}

	int M = 0;
	for (cnt = 0; cnt < N; cnt++)
	{
		M += b[cnt];
	}
	printf("%d\n", M);

	for (cnt = 0; cnt < N; cnt++)
	{
		if (b[cnt])
			printf("%d ", cnt + 1);
	}
//	printf("\n");

	return 0;
}


Measured memory_bytes: 1792
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define F first
#define S second
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr> 
#define pr pair<int, int> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define vout(v) for (auto z: v) cout << z << " "; cout << endl;

#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {vector<string>v; stringstream ss(s); string x;
while (getline(ss, x, c))v.emplace_back(x); return move(v);} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {
cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}

const int M = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;
ll vis[N],res[N];

int solve() 
{
	//happy coding

	int n;
	cin>>n;
	int a[n+1];
	int b[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i];
		b[i] = 0;
	}

	for(int i = n;i>0;i--){
		int sum = 0;
		for(int j = 2*i;j<=n;j+=i){
			sum += b[j];
		}
		if(sum %2 ==a[i]){
			b[i] = 0;
		}else{
			b[i] = 1;
		}
	}
	vi v;

	for(int i=1;i<=n;i++){
		if(b[i]==1){
			v.pb(i);
		}
	}

	if(v.size()){
		cout<<v.size()<<endl;

		vout(v);
	}else{
		cout<<0<<endl;
	}


	
	return 0;
}
int main(){
	int test = 1;
  	//scanf("%d", &test);
  	while (test--)solve();return 0;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  if (s[n - 1] == 's') s += "es";
  else s += "s";
  cout << s << '\n';
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    s[3] = '8';
    print(s);

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int h, w, k;
	cin >> h >> w >> k;
	VE<string> s(h);
	rep(i, h) {
		cin >> s[i];
	}
	ll ans = 0;
	VE<string> t = s;
	rep(b1, 1 << h) rep(b2, 1 << w) {
		rep(i, h) {
			if (b1 & (1 << i)) {
				rep(j, w) s[i][j] = '?';
			}
		}
		rep(i, w) {
			if (b2 & (1 << i)) {
				rep(j, h) s[j][i] = '?';
			}
		}
		int cnt = 0;
		rep(i, h) rep(j, w) {
			if (s[i][j] == '#') cnt++;
		}
		// rep(i, h) cout << s[i] << endl;
		// cout << endl;
		ans += cnt == k;
		s = t;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define F first
#define S second
#define int long long
#define double long double
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,int> Pi;
typedef pair<P,P> PP;
double eps=1e-8;
int mod=1e9+7;
int inf=1LL<<55;

priority_queue<P,vector<P>,greater<P> > pq;

template <typename T>
int Count(const vector<T> &v, T l,T r){
  //counting [l,r]
  auto L = lower_bound(v.begin(), v.end(), l );
  auto R = upper_bound(v.begin(), v.end(), r );
  // [l,r) change upper -> lower
  return R-L;
}

signed main(){
  int n,ans=0;
  int c[10][10]={};
  cin>>n;
  for(int i=1;i<=n;i++){
    int s=i,t=i%10;
    while(s>9)s/=10;
    c[s][t]++;
  }
  for(int i=1;i<=n;i++){
    int s=i,t=i%10;
    while(s>9)s/=10;
    ans+=c[t][s];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
void main() {
    int[] tmp = readln.split.to!(int[]);
    int a = tmp[0] - 1, b = tmp[1] - 1;
    writeln(a * b);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;

Measured memory_bytes: 256