akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
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; }

int main(){
  int n,m,x; cin >> n >> m >> x;
  vi c(n);
  vector<vi> a(n,vi(m));
  rep(i,n){
    cin >> c[i];
    rep(j,m) cin >> a[i][j];
  }
  ll ans = INF;
  rep(bit,1<<n){
    vi sum(m);
    ll res = 0;
    rep(i,n){
      if(bit>>i & 1){
        res += c[i];
        rep(j,m) sum[j] += a[i][j];
      }
    }
    rep(i,m) if(sum[i] < x) res = INF;
    chmin(ans,res);
  }
  if(ans == INF) cout << -1;
  else cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3576
//in the name of god
//if you read this code please search about imam hussain
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pb push_back
#define endl "\n"
#define X first
#define Y second
#define pii pair<int,int>
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define read freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout)

const int maxn=1e5+5;
const int mod=1e9+7;
const int inf=1e9;
const int del=728729;

ll poww(ll a, ll b, ll md) {return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));}

int main(){
	migmig;
	string s , ss , sss;
  cin >> s >> ss;
  ll a , b ;
  cin >> a >> b;
  cin >> sss;
  if(sss==s){
    cout<<a-1<<" "<<b;
  }else cout<<a << " " << b-1;
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int k = sc.nextInt();
	int[] x = new int[n];
	for(int i = 0; i < n; i++) {
		x[i] = sc.nextInt();
	}
	
	sc.close();
	
	int sum = 0;
	
	for(int i = 0; i < n; i++) {
		if(x[i] * 2 > (k - x[i]) * 2) {
			sum += (k - x[i]) * 2;
		}else {
			sum += x[i] * 2;
		}
	}
	
	System.out.println(sum);
}
}


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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

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

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n,x,y;
    cin>>n>>x>>y;
    --x;--y;

    map<int,int> dcnt;

    rep1(i,1,n)dcnt[i]=0;

    rep(i,n){
        rep(j,n){
            d[i][j] = abs(i-j);
        }
    }

    d[x][y]=1;
    d[y][x]=1;

    rep(i,n)rep(j,n){
    
        chmin(d[i][j],d[i][x]+1+d[y][j]);
        chmin(d[i][j],d[i][y]+1+d[x][j]);
    
        if(i!=j)dcnt[d[i][j]]++;
    }

    for(auto p:dcnt)cout<<p.se/2<<endl;

    //cout <<fixed<<setprecision(16)<< << endl;

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

    return 0;
}


Measured memory_bytes: 16128
#include <iostream>
#include <algorithm>
typedef long long LL;
using namespace std;
const int N=2010;
int a[N];
int n;
LL ans;

int main(){
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	
	sort(a,a+n);
	
	for(int i=0;i<n-1;i++)
		for(int j=i+1;j<n;j++){
			int x=a[i];
			int y=a[j];
			
			int minv=abs(x-y), maxv=x+y;
			int min_idx, max_idx;

			int l=0,r=n-1;
			while(l<r){
				int mid=l+r>>1;
				if(a[mid]>minv) r=mid;
				else l=mid+1;
			}
			min_idx=l;
			
			l=0,r=n-1;
			while(l<r){
				int mid=l+r+1>>1;
				if(a[mid]<maxv) l=mid;
				else r=mid-1;
			}
			max_idx=l;
			
			int k;
			if(max_idx<=min_idx || a[max_idx]>=maxv || a[min_idx]<=minv) k=0;
			else{
				k=max_idx-min_idx+1;
				if(i>=min_idx && i<=max_idx) k--;
				if(j>=min_idx && j<=max_idx) k--;
			}
			
			ans+=(LL)k;
		}
		
	cout<<ans/3;
	return 0;
}


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

 ll dp[55][55][3000];

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

    ll n,a;
    cin>>n>>a;
    ll x[n];
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    
    dp[0][0][0] = 1;
    for(int i=0;i<n;i++){
        for(int k=0;k<=n;k++){
            for(int j=0;j<3000;j++){
                dp[i+1][k][j] += dp[i][k][j];
                if(k-1>=0 && j-x[i] >=0){
                    dp[i+1][k][j] += dp[i][k-1][j-x[i]];
                }
            }
        }
    }

    ll ans = 0;
    for(int i=1;i<=n;i++){
        ans += dp[n][i][i*a];
    }
    cout<< ans << endl;
    

    
  

}

Measured memory_bytes: 66560
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
using namespace std;

typedef pair<int,int> pii;

struct edge{
	int a, b, c;
	
	bool operator< (const edge &e) const{
		return c > e.c;
	}
};

struct UF{
	vector<int> par;

	explicit UF(int n): par(n + 1){
		for(int i = 1; i <= n; ++i){
			par[i] = i;
		}
	}
	
	int find(int x){
		return x != par[x] ? par[x] = find(par[x]) : x;
	}
	
	bool unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y){ return false; }
		par[x] = y;
		return true;
	}
	
	int count(const vector<char> msk){
		int r = 0;
		for(int i = 1; i < par.size(); ++i){
			if(msk[i] && find(i) == i){ ++r; }
		}
		return r;
	}
};

int main(){
	int n, m, a, b, c;
	while(scanf("%d%d", &n, &m), n){
		vector<pii> f(n);
		for(int i = 0; i < n; ++i){
			scanf("%d", &f[i].first);
			f[i].second = i + 1;
		}
		sort(f.begin(), f.end());

		vector<vector<int> > G(n + 1, vector<int>(n + 1, -1));
		UF uf(n);
		for(int i = 0; i < m; ++i){
			scanf("%d%d%d", &a, &b, &c);
			G[a][b] = G[b][a] = c;
			uf.unite(a, b);
		}

		int ans = 0;
		vector<char> alive(n + 1, 1);
		if(uf.count(alive) < 2){
			int k = 0;
			while(k < n){
				int ktmp = k;
				int tm = f[k].first;
				while(k < n && f[k].first == tm){
					int v = f[k].second;
					alive[v] = 0;
					++k;
				}

				UF uf1(n);
				for(int i = 1; i <= n; ++i)
				for(int j = 1; j < i; ++j){
					if(alive[i] && alive[j] && G[i][j] >= 0){
						uf1.unite(i, j);
					}
				}
				if(uf1.count(alive) > 1){
					k = ktmp;
					break;
				}
			}

			for(int i = k; i < n; ++i){
				f[i].first = f.back().first;
			}
			fill(alive.begin(), alive.end(), 0);
				//同一時刻で沈むとみなす
			
			uf = UF(n);
			k = n - 1;
			priority_queue<edge> pq;
			while(k >= 0){
				int tm = f[k].first;
				while(k >= 0 && f[k].first == tm){
					int v = f[k].second;
					alive[v] = 1;
					for(int u = 1; u <= n; ++u){
						if(alive[u] && G[v][u] >= 0){
							pq.push((edge){v, u, G[v][u]});
						}
					}
					--k;
				}
				
				while(!pq.empty()){
					edge e = pq.top();
					pq.pop();
					if(uf.unite(e.a, e.b)){
						ans += e.c;
					}
				}
			}
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1704
// Problem : C - Green Bin
// Contest : AtCoder - AtCoder Beginner Contest 137
// URL : https://atcoder.jp/contests/abc137/tasks/abc137_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int n; 
	cin>>n;
	vector<string> v(n);
	unordered_map<string,int> map;
	ll ans=0;
	loop(i,n)
	{
		cin>>v[i];
		sort(all(v[i]));
		ans+=map[v[i]];
		map[v[i]]++;
	}
	cout<<ans;
}
// read the question correctly (ll vs int)
// template by bqi343

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

#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()

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

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

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main(){
    int a, b, c; cin >> a >> b >> c;
    int ans = max( { a, b, c } ) * 10 + a + b + c - max( { a, b, c } );
    cout << ans << endl;

}


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

int main() {
	int sum = 0;
	string s;
	cin>>s;
	for(int i = 0; i<s.length();i++) {
		sum = (sum + (s[i] - '0')) % 9;
	}
	if(sum > 0) cout<<"No\n";
	else cout<<"Yes\n"; 
	return 0;
}

Measured memory_bytes: 3772
#include<cstdio>
#include<algorithm>
using namespace std;

int main() {
	int n, k, result = 0;
	int fruit[1000];
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d", &fruit[i]);
	}

	sort(fruit, fruit + n);

	for (int i = 0; i < k; i++) {
		result += fruit[i];
	}
	printf("%d\n", result);

	return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h> 
using namespace std;
const int N = 1000+5; 
int main(){
	int n;
	cin>>n;
	double t,a;
	cin>>t>>a;
//	double h[N]={0};
	double minn=0x3f3f3f;
	int maxidx=0;
	for(int i=1;i<=n;i++){
		double x;
		scanf("%lf",&x);
		x=t-x*0.006;
		x=fabs(a-x);
		if(x<minn){
			minn=x;
			maxidx=i;
		}
	} 
	printf("%d\n",maxidx);
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int main()
{
	int n,m;
	int d[110][110], M[110][110];
	while (cin >> n >> m, n) 
	{
		rep(i, n)rep(j, n) { d[i][j] = INF; M[i][j] = 0; };
		rep(i, n)d[i][i] = 0;
		rep(i, m) {
			int a, b, c;
			cin >> a >> b >> c;
			a--, b--;
			d[a][b] = d[b][a] = c;
			M[a][b] = M[b][a] = 1;
		}

		rep(k, n)rep(i, n)rep(j, n)
			d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

		int ans = d[0][n - 1];
		rep(k, n)rep(i, n)rep(j, n)
			if (M[i][k] && M[k][j])ans = min(ans, d[0][i] + d[j][n - 1]);

		cout << ans << endl;
	} 
	return 0;
}

Measured memory_bytes: 3172
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    int n; cin >>n;
    int mx = 0;
    int ans = 1;
    for (int i = 1; i <= n; i++) {
        int j = i;
        int count = 0;
        while (j % 2 == 0) {
            j =  j/2;
            count++;
        }
        if (count > mx) {
            mx = count;
            ans = i;
        }
    }

    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) (flag)?1:0
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

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

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ================================================

// Template End ======================================================

constexpr int MOD=1e9+7;

int main(void){
  int a,b; cin>>a>>b;
  if(a+b>=10) cout<<"error"<<endl;
  else cout<<a+b<<endl;
}













Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main() {
	int N;
	cin >> N;
	vi h(N);
	REP(i, N) {
		cin >> h[i];
	}

	vi t(N, 0);
	int ans = 0, p = 0;
	while (p < N) {
		if (t[p] == h[p]) {
			p++;
		}
		else {
			FOR(i, p, N - 1) {
				if (t[i] < h[i]) {
					t[i]++;
				}
				else {
					break;
				}
			}
			ans++;
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	vector<int> problems(3, 0);
	for (int i = 0; i < n; i++) {
		cin >> p;

		if (p <= a) {
			problems[0]++;
		} else if (p <= b) {
			problems[1]++;
		} else {
			problems[2]++;
		}
	}

	int ans = *min_element(problems.begin(), problems.end());
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 100;

void doc() {
    freopen("OB.inp","r",stdin);
    freopen("OB.out","w",stdout);
    ///cerr << "OK" << '\n';
}

void solve() {
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++)
        cin >> a[i];
    long long f[n][n][2];
    memset(f, 0, sizeof(f));
    for(int i = 0; i < n - 1; i++){
        f[i][i + 1][0] = - abs(a[i] - a[i + 1]);
        f[i][i + 1][1] = -f[i][i + 1][0];

        f[i][i][0] = -a[i];
        f[i][i][1] = a[i];
    }
    f[n - 1][n - 1][0] = -a[n - 1];
    f[n - 1][n - 1][1] = a[n - 1];
    for(int k = 2; k < n; k++)
    for(int i = 0; i + k < n; i++){
        int j = i + k;
        f[i][j][1] = max(f[i + 1][j][0] + a[i], f[i][j - 1][0] + a[j]);
        f[i][j][0] = min(f[i + 1][j][1] - a[i], f[i][j - 1][1] - a[j]);
        //cout << i << " " << j << " " << f[i][i + 1][0] << " " << f[i][i + 1][1] << '\n';
    }
    cout << f[0][n - 1][1];
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
   /// doc();
    solve();
}



Measured memory_bytes: 140928
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <algorithm>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

void Search(int n, vector<list<int>> &d, vector<int> &p, vector<int> &s) {
	for (auto itr = d[n].begin(); itr != d[n].end(); itr++) {
		if (*itr != p[n]) {
			p[*itr] = n;
			Search(*itr, d, p, s);
			s[n] += s[*itr];
		}
	}
	return;
}

int main(void) {
	int num, i, a, b, len = 0;
	cin >> num;
	vector<list<int>> d(num + 1);
	vector<int> p(num + 1, 0), s(num + 1, 1);
	for (i = 0; i < num - 1; i++) {
		scanf("%d%d", &a, &b);
		d[a].push_back(b);
		d[b].push_back(a);
	}
	Search(1, d, p, s);
	for (i = num; i != 1; len++)
		i = p[i];
	for (a = num, i = 0; i < (len - 1) / 2; i++)
		a = p[a];
	if (s[1] > (s[a] << 1))
		printf("Fennec\n");
	else
		printf("Snuke\n");
	return 0;
}

Measured memory_bytes: 16640
import java.util.Scanner;

public class Main {

    public static void main(final String[] args) {
        try (final Scanner sc = new Scanner(System.in)) {
            final int n = sc.nextInt();
            final int[] h = new int[n];
            int result = 0;
            int max = 0;
            for (int i = 0; i < n; i++) {
                h[i] = sc.nextInt();
                if (i == 0 || max <= (h[i])) {
                    result += 1;
                }
                max = Math.max(max, h[i]);
            }
            System.out.println(result);
        }
    }
}


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

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

  int ind_A, ind_Z;
  int N = s.size();
  for (int i=0;i<N;i++){
    if(s.at(i)=='A') {
      ind_A = i;
      break;
    }
  }
  
  for (int i=N-1;i>=0;i--){
    if(s.at(i)=='Z') {
      ind_Z = i;
      break;
    }
  }

  cout << ind_Z - ind_A +1 << endl;
}

  
  

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
class Point{
	public:
	double x,y;
	void input(){
		cin>>x>>y;
	}
};
double dist(Point a,Point b){
	return sqrt(pow(a.x-b.x,2.0)+pow(a.y-b.y,2.0));
}
class Line{
	public:
	double a,b,c;//ax+by=c
	Line(Point s,Point t){
		//x=(x1+x2)/2 , y=(y1+y2)/2を通り、
		//傾きa=-(x1-x2)/(y1-y2)の直線
		//(y1-y2)(y-(y1+y2)/2) = -(x1-x2)(x-(x1+x2)/2)
		//(x1-x2)x + (y1-y2)y = (x1^2-x2^2)/2 + (y1^2-y2^2)/2
		a=s.x-t.x;	b=s.y-t.y;
		c=((s.x+t.x)*(s.x-t.x)+(s.y+t.y)*(s.y-t.y))/2.0;
	}
	void multi(double x){
		a*=x;	b*=x;	c*=x;
	}
};
double searchx(Line s,Line t){
	double tmp=s.b;
	s.multi(t.b);	t.multi(tmp);
	return (s.c-t.c)/(s.a-t.a);
}
double searchy(Line s,Line t){
	double tmp=s.a;
	s.multi(t.a);	t.multi(tmp);
	return (s.c-t.c)/(s.b-t.b);
}
int main(){
	int n;	cin>>n;
	while(n--){
		Point a,b,c;
		a.input();	b.input();	c.input();
		Line l(a,b),m(b,c);
		Point center;
		center.x=searchx(l,m);	center.y=searchy(l,m);
		double dis=dist(center,a);
		printf("%.3lf %.3lf %.3lf\n",center.x,center.y,dis);
	}
	return 0;
}

Measured memory_bytes: 3056
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a + b) % 24 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int numCount[] = new int[101];
		String inputData = br.readLine();
		int value = 0;

		while (inputData != null) {
			numCount[Integer.parseInt(inputData)] += 1;
			inputData = br.readLine();
		}

		for (int i = 1; i <= 100; i++) {
			if (numCount[i] > value) {
				value = numCount[i];
			}
		}

		for (int i = 1; i <= 100; i++) {
			if (numCount[i] == value) {
				System.out.println(i);
			}
		}

	}

}

Measured memory_bytes: 24184
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<iostream> 
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#define ll long long
#define ull unsigned long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define lowbit(x) (x& -x)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define eps 1e-18
#define maxn 100010
inline ll read(){ll tmp=0; char c=getchar(),f=1; for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1; for(;'0'<=c&&c<='9';c=getchar())tmp=(tmp<<3)+(tmp<<1)+c-'0'; return tmp*f;}
inline ll power(ll a,ll b){ll ans=1; for(;b;b>>=1){if(b&1)ans=ans*a%mod; a=a*a%mod;} return ans;}
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline void swap(int &a,int &b){int tmp=a; a=b; b=tmp;}
using namespace std;
int n,k;
int main()
{
	n=read(); k=read();
	if(k&1){
		printf("%lld\n",1ll*(n/k)*(n/k)*(n/k));
	}
	else{
		int tmp=n/(k/2);
		if(tmp&1)printf("%lld\n",1ll*(tmp/2+1)*(tmp/2+1)*(tmp/2+1)+1ll*(tmp/2)*(tmp/2)*(tmp/2));
		else printf("%lld\n",2ll*(tmp/2)*(tmp/2)*(tmp/2)); 
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    int N; cin >> N;
    vector<string> S(N);
    for(string &s:S){
        cin >> s;
    }
    
    int ca = 0;
    int cb = 0;
    int cab = 0;
    int sp = 0;
    for(int i=0; i<N; i++){
        int L = (int)S[i].size();
        if(S[i][0]=='B' && S[i][L-1]=='A') sp++;
        else if(S[i][0]=='B') cb++;
        else if(S[i][L-1]=='A') ca++;
        for(int j=0; j<L-1; j++){
            if(S[i][j]=='A' && S[i][j+1]=='B') cab++;
        }
    }
    
    int ans = cab;
    if(sp > 0){
        ans += sp - 1;
        if(ca>0 && cb>0){
            ans += 2;
            ca--;
            cb--;
        }else if(ca>0 || cb>0){
            ans += 1;
        }
    }
    ans += min(ca, cb);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 768
import numpy as np

n,t = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(n)]
ab.sort()
dp = np.array([0]*t)
ans = 0
for a,b in ab:
    ans = max(ans,dp[-1]+b)
    dp[a:] = np.maximum(dp[:-a]+b,dp[a:])
# print(dp,ans)
print(max(ans,dp[-1]))

Measured memory_bytes: 12776
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	int p[n], q[n];
	rep(i, n) cin >> p[i];
	rep(i, n) cin >> q[i];
	int a[n];
	rep(i, n) a[i] = i + 1;
	int P, Q, cnt = 0;
	do {
		cnt++;
		bool ch = 1;
		rep(i, n) {
			if (a[i] != p[i]) {
				ch = 0;
				break;
			}
		}
		if (ch) P = cnt;
		ch = 1;
		rep(i, n) {
			if (a[i] != q[i]) {
				ch = 0;
				break;
			}
		}
		if (ch) Q = cnt;
	} while (next_permutation(a, a + n));
	cout << abs(P - Q) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int i,j,k;
    long long num;
    int a[10];
    while(scanf("%lld",&num)!=EOF){
        for(i=9;i>=0;i--){
            a[i]=num%10;
            num/=10;
        }

        for(i=10;i>1;i--){
      /*~~途中経過を出力する~~*/      
            /*for(k=0;k<i;k++){
                printf("%d",a[k]);
            }
             puts("");
            */
            for(j=0;j<i-1;j++){
                a[j]=(a[j]+a[j+1])%10;
            }
        }

        printf("%d\n",a[0]);
    }
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#define int long long
using namespace std;

signed main() {
    int n;
    int x;
    int a[101];
    int ans = 0;

    cin >> n;
    cin >> x;

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

    for(int i = 0; i < n; i ++){
        if(a[i] <= x){
            x -= a[i];
            ans ++;
        } else break;
    }
    if(x != 0 && ans == n) ans --;
    cout << ans;


    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n;
    cin >> n;
    vector<int> l;
    rep(i, n){ int tmp; cin >> tmp; l.push_back(tmp);}

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

    int sum = 0;
    for (int a = 0; a < n; a++)
    {
        for (int b = a+1; b < n-1; b++)
        {

            vector<int> tmp_l;
            int r_ = lower_bound(l.begin(), l.end(), l[a]+l[b]) - l.begin();  //含まれないギリギリ
            int l_ = upper_bound(l.begin(), l.end(), abs(l[a]-l[b])) - l.begin(); //含まれるギリギリ
            l_ = (b >= l_) ? b+1 : l_;
            //cout << a << ":" << b << ":" << r_ - l_ << endl;
            sum += r_-l_;
        }
    }
    cout << sum << endl;


}



Measured memory_bytes: 256
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
#print(l) 
for j in range(0,101):
    for k in range(0,101):
        for i in range(n):
            if l[i][2]>0:
                h=(l[i][2]+abs(j-l[i][0])+abs(k-l[i][1]))
                #print(j,k,h)
                break
        for i in range(n):
            h_r=max((h-abs(j-l[i][0])-abs(k-l[i][1])),0)
            if l[i][2] !=h_r:
                #print(True)
                break
        else:
            print(j,k,h)

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<cmath>
#include<set>
#include<list>
#include<stack>
#include<vector>
#include<cstdlib>
#include<iterator>
#include<deque>
#include<ctime>
#include<iomanip>
using namespace std;
int main()
{
	int a,b,c,i;
	cin>>a>>b>>c;
	for(i=1;i<=10000;i++)
		if((a*i)%b==c){cout<<"YES"<<endl;return 0;}
	cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std ;
#define int                 long long
#define ull                 unsigned long long int
#define ld                  long double
#define vi                  vector<int>
#define vii                 vector<pair<int,int>>
#define vvi                 vector<vector<int>>
#define pii                 pair<int,int>
#define prec(x)             fixed<<setprecision(15)<<x
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define rev(x)              reverse(x.begin(),x.end())
#define mset(a,b)           memset(a,b,sizeof(a))
#define mcpy(a,b)           memcpy(a,b,sizeof(a))
#define fo0(i,n)            for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n)            for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b)           for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)            for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)            for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define mk(arr,n,type)  	type *arr=new type[n];
#define dbg(x) cerr << #x << " is " << x << endl;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
clock_t beg = clock();
const int inf=1e18;const int mod=1e9+7;const int N=2e5+9;
const double pi = 3.1415926535897932384626433;
void FILE_IO(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}

void JH(){
    int d=0,e=0,f=0,g=0,p=0,w=0,flag=0,ans=0,res=0,cnt=0,sum=0;double f1=0.0,f2=0.0,f3=0.0;
    ld a,b;cin>>a>>b;
    int c=a*b;
    cout<<c<<endl;
}

int32_t main()
{
    FILE_IO();FAST_IO;int t=1;
    // cin>>t;
    while(t--){JH();}cerr<<"Execution time: "<<(double)(clock()-beg)/1000<<"s ";
}	

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

int main(){
  vector<int> B(9);
  for(int i=0;i<9;i++){
    cin >> B[i];
  }
  int N; cin >> N;
  for(int i=0;i<N;i++){
    int k;
    cin >> k;
    for(int j=0;j<9;j++){
      if(B[j]==k){
        B[j]=0;
      }
    }
  }
  if(B[0]==0 && B[1]==0 && B[2]==0){
    cout << "Yes" << endl;
    return 0;
  }
  if(B[3]==0 && B[4]==0 && B[5]==0){
    cout << "Yes" << endl;
    return 0;
  }
  if(B[6]==0 && B[7]==0 && B[8]==0){
    cout << "Yes" << endl;
    return 0;
  }
  if(B[0]==0 && B[3]==0 && B[6]==0){
    cout << "Yes" << endl;
    return 0;
  }
  if(B[1]==0 && B[4]==0 && B[7]==0){
    cout << "Yes" << endl;
    return 0;
  }
  if(B[2]==0 && B[5]==0 && B[8]==0){
    cout << "Yes" << endl;
    return 0;
  }
  if(B[0]==0 && B[4]==0 && B[8]==0){
    cout << "Yes" << endl;
    return 0;
  }
  if(B[6]==0 && B[4]==0 && B[2]==0){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}
      

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <memory.h>
#include <functional>
#include <string.h>
#include <iomanip>
#include <complex>
#include <unordered_set>
#include <unordered_map>
using namespace std;

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl; 
typedef double db;

const int mod=1e9+7;
ll qpow(ll x,ll k){return k==0?1:1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
#define MP make_pair
#define FF first
#define SS second
#define LB lower_bound
#define UB upper_bound
#define PB push_back
#define lc ((p<<1)+1)
#define rc ((p<<1)+2)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define all(v) (v).begin(),(v).end()
#define clean(v,a) memset(v,a,sizeof(v))
#define PQ priority_queue

/*
 * high precision: printf("%.12lf",(db)ans);
 *
 * clear output buffer: fflush(stdout);
 *
 * sync off: ios::sync_with_stdio(false);
 *
 */

const int Maxn=1e5+5;

int n,k;
vector<int> x[2];
int sum[2][Maxn];

int main()
{
	scanf("%d%d",&n,&k);
	x[1].PB(0);x[0].PB(0);
	for(int i=1;i<=n;i++)
	{
		int a;
		scanf("%d",&a);
		if(a>=0) x[1].PB(a);
		else x[0].PB(a);
	}
	reverse(x[0].begin()+1,x[0].end());
	for(int i=0;i<x[0].size();i++)
	{
		sum[0][i]=-x[0][i];
	}
	for(int i=0;i<x[1].size();i++)
	{
		sum[1][i]=x[1][i];
	}
	int ans=0x3f3f3f3f;
	for(int i=0;i<x[1].size();i++)
	{
		if(k-i>=x[0].size()) continue;
		ans=min(ans,sum[1][i]*2+sum[0][k-i]);
		ans=min(ans,sum[1][i]+sum[0][k-i]*2);
	}
	printf("%d\n",ans);
	return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] c = sc.next().toCharArray();
		Arrays.sort(c);
		if (c[0] == c[1] && c[2] == c[3] && c[0] != c[2]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
#define for_(i,a,b) for(int i=(a);i<(b);++i)
template< typename T > using Vec = vector< T >;
typedef long long lint;
template< typename T > void modAdd(T& a, T b, T mod) { (a += b) %= mod; }//a = (a + b) % mod; }
 
struct Edge {
	int v;
	lint d;
	bool operator > (const Edge& e) const { return d > e.d; }
};
 
int N, M, S, T, U[200005], V[200005];
lint D[200005];
Vec< Vec< Edge > > edge;
 
lint dst[2][100005];
lint numpath[2][100010];
const lint MOD = (lint)1e9 + 7;
 
void calcDist(int piv, int start) {
	priority_queue< Edge, Vec< Edge >, greater< Edge > > que;
	que.push(Edge{start, 0});
	dst[piv][start] = 0;
	numpath[piv][start] = 1;
	while (!que.empty()) {
		Edge e = que.top(); que.pop();
		//if (dst[piv][e.v] < e.d) continue;
		for (const Edge& ei : edge[e.v]) {
			if (dst[piv][ei.v] == -1 || dst[piv][ei.v] > e.d + ei.d) {
				dst[piv][ei.v] = e.d + ei.d;
				numpath[piv][ei.v] = numpath[piv][e.v];
				que.push(Edge{ei.v, dst[piv][ei.v]});
			} else if (dst[piv][ei.v] == e.d + ei.d) {
				modAdd(numpath[piv][ei.v], numpath[piv][e.v], MOD);
			}
		}
	}
}
 
void solve() {
	memset(dst, -1, sizeof(dst));
	calcDist(0, S);
	calcDist(1, T);
  
  assert(numpath[0][S] == numpath[1][T]);
	
	lint collision = 0;	
	
	for_(v,0,N) {
		if (dst[0][v] == dst[1][v] && dst[0][v] + dst[1][v] == dst[0][T]) {
			lint num = (numpath[0][v] * numpath[1][v]) % MOD;
			modAdd(collision, num * num, MOD);
		}
	}
	
	double thr = (double)dst[0][T] / 2.;
	for_(i,0,M) {
		int u = U[i], v = V[i], d = D[i];
		if (abs(dst[0][v] - dst[0][u]) == d) {
			if (dst[0][v] + d == dst[0][u]) swap(u, v);
			if (dst[0][u] + dst[1][v] + d == dst[0][T] && (double)dst[0][u] < thr && (double)(dst[0][u] + d) > thr) {
				lint num = (numpath[0][u] * numpath[1][v]) % MOD;
				modAdd(collision, num * num, MOD);
			}
		}
	}
	
	cout << ((numpath[0][T] * numpath[1][S] - collision + MOD) % MOD) << endl;
}
 
int main() {
	cin >> N >> M;
	cin >> S >> T;
	--S; --T;
	
	edge.assign(N, Vec< Edge >());
	for_(i,0,M) {
		cin >> U[i] >> V[i] >> D[i];
		--U[i]; --V[i];
		edge[U[i]].push_back(Edge{V[i], D[i]});
		edge[V[i]].push_back(Edge{U[i], D[i]});
	}
	
	solve();
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

void leave(string message) {
    cout << message << endl;
    exit(0);
}

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

    if(n%2)  leave("0");

    // 素因数5の個数を数える
    map<lint, lint> mp;  // 5^iで割れる数が何個あるか

    lint ans = 0;
    for(lint i=1; i<=27; i++) {
        lint key = pow(5, i);
        ans += n/(key*2);
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
using System;
using System.Linq;

class C
{
	static void Main()
	{
		var n = long.Parse(Console.ReadLine());
		Console.WriteLine(Enumerable.Range(1, (int)Math.Sqrt(n)).Where(x => n % x == 0).Min(x => x + n / x - 2));
	}
}


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

///for ordered set///
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/trie_policy.hpp>
///for ordered set///

using namespace std;

///for ordered set///
//using namespace __gnu_pbds;
//typedef tree< long long int , null_type, less_equal<long long int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
///for ordered set///

///Compiler Optimizer///
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
///Compiler Optimizer///

typedef long long           ll;
typedef unsigned long long  ull;

#define sf                  scanf
#define pf                  printf
#define pb                  push_back
#define ppb                 pop_back
#define MP                  make_pair
#define PF                  first
#define PS                  second
#define si(n)               scanf("%d",&n)
#define sii(x,y)            scanf("%d %d",&x,&y)
#define siii(x,y,z)         scanf("%d %d %d",&x,&y,&z)
#define sl(n)               scanf("%lld",&n)
#define sll(x,y)            scanf("%lld %lld",&x,&y)
#define slll(x,y,z)         scanf("%lld %lld %lld",&x,&y,&z)
#define FOR(i,x,y)          for(int i=x;i<y;i++)
#define RFOR(i,x,y)         for(int i=x;i>=y;i--)
#define CLR(arr,val)        memset(arr,val,sizeof arr);
#define vout(v)             for(int ind=0;ind<v.size();ind++){ cout<<v[ind]; if(ind<v.size()-1) cout<<' '; else cout<<endl;}
#define TCL(test,t)         for(test=1;test<=t;test++)
#define READ()              freopen("input.txt", "r", stdin)
#define WRITE()             freopen("output.txt", "w", stdout)
#define fastIO()            {ios_base::sync_with_stdio(false); cin.tie(NULL);}
#define MAXN                1000006
#define MAXP                1000006
#define MOD                 1000000007
#define PI                  acos(-1)

vector<int>adj[MAXN],ans;
int save[MAXN];

void bfs(int node,int n){
    queue<int>que;
    que.push(node);
    int mark[n+5]; CLR(mark,false);
    mark[node]=1;
    while(que.size()){
        node=que.front();
        que.pop();
        for(auto x:adj[node]){
            if(mark[x])continue;
            mark[x]=mark[node]+1;
            save[mark[node]]++;
            que.push(x);
        }
    }
}

int main(){
    #ifdef ELDUIVEL
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int n,x,y;
    cin>>n>>x>>y;
    for(int i=1;i<n;i++){
        adj[i].pb(i+1);
        adj[i+1].pb(i);
    }
    adj[x].pb(y);
    adj[y].pb(x);
    for(int i=1;i<=n;i++){
        bfs(i,n);
    }
    for(int i=1;i<n;i++){
        ans.pb(save[i]/2);
    }
    for(auto it:ans)cout<<it<<endl;
    #ifdef ELDUIVEL
        fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
    return 0;
}


Measured memory_bytes: 25600
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cassert>
#define ll long long
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(ch>'9'||ch<'0'){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
int n,m,first[100010],cnte,col[100010];
ll single,binary,linked;
struct edge{
	int to,next;
}a[400010];
inline void add(int u,int v){
	a[++cnte]=(edge){v,first[u]};first[u]=cnte;
	a[++cnte]=(edge){u,first[v]};first[v]=cnte;
}
int dfs(int u,int c){
	if(~col[u]&&c!=col[u]) return 0;
	if(~col[u]&&c==col[u]) return 1;
	col[u]=c;
	int i,v,re=1;
	for(i=first[u];~i;i=a[i].next){
		v=a[i].to;
		re&=dfs(v,c^1);
	}
	return re;
}
int main(){
	memset(first,-1,sizeof(first));memset(col,-1,sizeof(col));
	n=read();m=read();int i,t1,t2,tmp;
	for(i=1;i<=m;i++){
		t1=read();t2=read();
		add(t1,t2);
	}
	for(i=1;i<=n;i++) if(col[i]==-1){
//		cout<<"find empty "<<i<<' '<<first[i]<<'\n';
		if(first[i]==-1){single++;continue;}
		tmp=dfs(i,0);
		if(tmp) binary++;
		else linked++;
	}
//	cout<<single<<' '<<binary<<' '<<linked<<'\n';
	printf("%lld\n",single*single+2*single*(n-single)+binary*binary*2+linked*(binary*2+linked));
}

Measured memory_bytes: 6016
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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


int main() {
	int n;
	cin >> n;
	int a[100];
	rep(i, n) cin >> a[i];
	int res = 0,tmp = 1;
	
	for (int i = 0; i < n - 1; i++) {
		if (a[i] == a[i + 1]) {
			//res++;
			tmp++;
		}
		else {
			
			res += tmp / 2;
			tmp = 1;
		}
	}
	cout << res + tmp / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
    
#define all(a) a.begin(), a.end()
#define forn(l, r) for(int i = l; i < (r); ++i)
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
//#define int long long int
    
using namespace std;
using namespace __gnu_pbds;
using ll = long long int;
using ii = pair<int, int>;
using vi = vector<int>;
using graph = vector<vi>;
using ordered_mset = tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update>;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
    
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    
const ll mod = 998244353;
const int INF = 0x3f3f3f3f;
//const ll INFLL = (ll)1e17;
const int MAXN = 112345;
const double pi = 3.14159265359;
const double eps = 0.00000001;

graph g;
int dp[MAXN];
bool seen[MAXN];

int sol(int u) {
    if (seen[u]) {
        return dp[u];
    }
    seen[u] = 1;
    for (auto v : g[u]) {
        dp[u] = max(dp[u], sol(v) + 1);
    }
    return dp[u];
}

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    g.resize(n + 1);
    for (int i = 0; i < m; ++i) {
        int u, v;
        scanf("%d %d", &u, &v);
        g[u].push_back(v);
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans = max(ans, sol(i));
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 7552
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define EQ(a,b) (abs((a)-(b))<EPS)
int main()
{
	ll u[4010];
	bool flag;
	vector<int> v;
	while(1)
	{
		for(int i=0;i<4010;i++)
		{
			u[i]=0;
		}
		flag=true;
		int n;
		cin >> n;
		if(n==0)break;
		v.clear();
		for(int i=0;i<n;i++)
		{
			int x;
			ll y,z;
			cin >> x >> y >> z;
			if(!(u[x]))
			{
				v.pb(x);
			}
			u[x]+=y*z;
		}
		for(int i=0;i<v.size();i++)
		{
			if(u[v[i]]>=1000000)
			{
				flag=false;
				cout << v[i] << endl;
			}
		}
		if(flag)
		{
			cout << "NA" << endl;
		}
	}
	return 0;
}

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

using namespace std;

const int INF = 1e5 + 7;
int a[INF];
int dp[INF];

int main() {
  int N;
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &a[i]);
  }
  dp[1] = 0;
  dp[2] = abs(a[1] - a[2]);
  for (int i = 3; i <= N; i++) {
    dp[i] = min(abs(a[i] - a[i-2]) + dp[i-2], abs(a[i] - a[i-1]) + dp[i-1]);
  }
  printf("%d\n", dp[N]);
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long ll;

const int INF = 1e9;
ll n;
unordered_map<string, ll> mp;

int main() {
  cin >> n;
  string s;
  ll ans = 0;
  rep(i, n) {
    cin >> s;
    sort(s.begin(), s.end());
    ans += mp[s];
    mp[s]++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 10660
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.stream.Collectors;

public class Main {
    static int cnt = 0;

    static void merge(int[] A, int left, int mid, int right) {
        int n1 = mid - left;
        int n2 = right - mid;

        int[] L = new int[n1 + 1];
        int[] R = new int[n2 + 1];
        System.arraycopy(A, left, L, 0, n1);
        System.arraycopy(A, mid, R, 0, n2);
        L[n1] = Integer.MAX_VALUE;
        R[n2] = Integer.MAX_VALUE;

        int i = 0;
        int j = 0;
        for (int k = left; k < right; k++) {
            if (L[i] <= R[j]) {
                A[k] = L[i];
                i++;
            } else {
                A[k] = R[j];
                j++;
            }
            cnt++;
        }
    }

    static void mergeSort(int[] A, int left, int right) {
        if (left + 1 < right) {
            int mid = (left + right) / 2;
            mergeSort(A, left, mid);
            mergeSort(A, mid, right);
            merge(A, left, mid, right);
        }
    }

    public static void main(String[] args) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {
            cnt = 0;
            int n = Integer.parseInt(in.readLine());
            int[] A = Arrays.stream(in.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
            mergeSort(A, 0, n);

            System.out.println(Arrays.stream(A).mapToObj(String::valueOf).collect(Collectors.joining(" ")));
            System.out.println(cnt);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}



Measured memory_bytes: 169684