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

int main() {
  std::string str;
  std::cin >> str;
  int str_begin, str_end;
  for (int i=0; i<str.size(); i++) {
    if (str.at(i) == 'A') {
      str_begin = i;
      break;
    }
  }
  for (int i = str.size()-1; i > 0; i--) {
    if (str.at(i) == 'Z') {
      str_end = i;
      break;
    }
  }
  std::cout << str_end - str_begin + 1 << std::endl;
}


Measured memory_bytes: 640
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int[][] g    = new int[n+1][n+1];
        int[] find   = new int[n+1];
        int[] finish = new int[n+1];
        
        for (int i = 0; i < n; i++) {
            int u = sc.nextInt();
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int v = sc.nextInt();
                g[u][v] = 1;
            }
        }
        
        Deque<Integer> deq = new ArrayDeque<Integer>();
        int time = 0;
        for (int k = 1; k <= n; k++ ) {
            if (find[k] != 0) continue;
            
            deq.push(k);
            while(!deq.isEmpty()) {
                int top = deq.peek();
                if (find[top] == 0) find[top] = ++time;
                
                int j;
                for (j = 1; j <= n; j++) {
                    if (g[top][j] == 1 && find[j] == 0) {
                        deq.push(j);
                        find[j] = ++time;
                        break;
                    }
                }
                if (j == n + 1) {
                    deq.pop();
                    finish[top] = ++time;
                }
            }
        }
        
        for (int i = 1; i <= n; i++) {
            System.out.println(i + " " + find[i] + " " + finish[i]);
        }
    }
}




Measured memory_bytes: 28392
#include<iostream>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=50000005;
int s,len[N],p[N];
ll qpow(ll a,ll n)
{
//purvikaurraina
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
int main()
{
    p[0]=1;
    scanf("%d",&s);
    ll ans=0;
    int sum=0;
    for(int l=1,r=0;l<10000000;l++)
    {
        while(sum<s)
        {
            r++;
            p[r]=p[r-1];
            len[r]=len[r-1];
            if(r/p[r]!=0) p[r]*=10,len[r]++;
            sum+=len[r];
        }
        if(sum==s) ans++;
        sum-=len[l];
    }
//purvikaurraina
    for(int t=1;t<=s/8;t++)
    {
        if(s%t) ans=(ans+1)%mod;
        else ans=(ans+(qpow(10,s/t)-qpow(10,s/t-1)-t+1))%mod;
    }
    ans=(ans+mod)%mod;
    printf("%lld\n",ans);
}

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

int main() {
    int n,i,j,m,k;
    cin>>n>>k;
    int arr[n+1],dp[n+1];
    for(i=1;i<n+1;i++)
    {
    cin>>arr[i];
    dp[i]=INT_MAX;
    }
    dp[0]=dp[1]=0;
    for(i=2;i<n+1;i++)
    {
    	for(j=1;j<k+1;j++)
    	{
    		if(i-j>0)
    		{
    			dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
    		}
    	}
    
    }
    cout<<dp[n];
	return 0;
}

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

typedef long long ll;

const int MAXV = 1e5 + 10;
const int MAXN = 1e3 + 10;
const ll INF = 1e13;

ll dp[MAXV];
int N,W,V,wi[MAXN],vi[MAXN];

int main(){

	cin >> N >> W;
	for(int i = 1;i<=N;i++)
	{
		cin >> wi[i] >> vi[i];
		V += vi[i];
	}

	for(int i = 1;i<=V;i++) dp[i] = INF;
	dp[0] = 0;
	
	for(int item = 1;item<=N;item++)
	{
		int w = wi[item], v = vi[item];
		for(int i = V;i>=v;i--)
		{
			dp[i] = min(dp[i],dp[i - v] + w);
		}
	}

	for(int i = V;i>=0;i--)
	{
		if(dp[i] <= W)
		{
			cout << i << endl;
			break;
		}
	}

	return 0;

}

Measured memory_bytes: 1024
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<int,int>;
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((ll)x.size())
#define MOD (ll)(998244353)
#define INF (2e9)
#define EPS (1e-6)
#ifdef LOCAL_TEST
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<endl;}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
#else
#define debug(...)
#endif

void INIT(){
#ifdef LOCAL_TEST
	freopen("D:\\input.in","r",stdin);
	freopen("D:\\output.out","w",stdout);
	freopen("D:\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
}

ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll fpow(ll b,ll p){
	b%=MOD;
	ll ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int dp[10010];

int32_t main() {
	INIT();
	//code...
	int h,n; cin>>h>>n;
	vector<pii> v(n); //pair(weight,cost)
	for(auto &i:v) cin>>i.F>>i.S;
	For(i,1,h) dp[i]=INF;
	dp[0]=0;
	For(i,0,n-1) For(j,1,h){
		if(j<=v[i].F) dp[j]=min(dp[j],v[i].S);
		else dp[j]=min(dp[j],dp[j-v[i].F]+v[i].S);
	}
	cout<<dp[h]<<"\n";
	return 0;
}


Measured memory_bytes: 3600
#include <cassert>
#include <cctype>
#include <cerrno> 
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
int main() {
 vector<int> vec(5);
 int x,y;
 cin>>x>>y;
 if((y-2*x)%2==0&&y-2*x>=0&&4*x-y>=0)
 {
 	cout<<"Yes"<<endl;
 }
else
{
	cout<<"No"<<endl;
}
    
       }


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

int main(){
      int n,m;cin >> n >> m;
      map<int, int> mm;
      int ans = 0;
      for(int i = 0;i < n;i++){
            set<int> no;
            int k;cin >> k;
            for(int j = 0;j < k;j++){
                  int t;cin >> t;
                  if(no.count(t) == 0){
                        mm[t]++;
                        no.insert(t);
                        if(mm[t] == n)ans++;
                  }
            }
      }
      cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=998244353;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2LL*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
ll a, b, c;

int main(void)
{
	cin>>a>>b>>c;
	if(a+b==c || b+c==a || c+a==b) cout<<"Yes";
	else cout<<"No"; return 0;
}
// 제출하기 전에 생각햇나요?
// it may be easier/harder than you think
// ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define debug(x) cerr<<#x<<" -> "<<x<<'\n'
#define debug2(x,y) cerr<<#x<<" -> "<<x<<" "<<#y<<" -> "<<y<<'\n'
#define debug3(x,y,z) cerr<<#x<<" -> "<<x<<" "<<#y<<" -> "<<y<<" "<<#z<<" -> "<<z<<'\n'

 
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>

const ll N = 2e5+7;
const ll MOD = 1e9+7;


int main(){
	fast;
	int n, k;
	cin>>n>>k;
	if(k == 1){
		cout<<0<<'\n';
		return  0;
	}
	n = n - k + 1;
	cout<<n - 1<<'\n';
	
	
	return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        int x = int.Parse(Console.ReadLine());
        int ans = 1;
        int tmp;
        for (int i = 2; i * i < x; i++)
        {
            tmp = 1;
            while (tmp * i <= x)
            {
                tmp *= i;
            }
            ans = Math.Max(ans, tmp);
        }
        Console.WriteLine(ans);
    }
}

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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/e.in", "r", stdin);
//  freopen("../IO/f.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}




void solve(std::istream &in, std::ostream &out) {
  int n;
  in >> n;
  int64_t mn1 = numeric_limits<int64_t>::max();
  int64_t mx1 = numeric_limits<int64_t>::min();
  int64_t mn2 = numeric_limits<int64_t>::max();
  int64_t mx2 = numeric_limits<int64_t>::min();
  for (int i = 0, x, y; i < n; ++i) {
    in >> x >> y;
    mn1 = min(mn1, (int64_t)x + y);
    mx1 = max(mx1, (int64_t)x + y);
    mn2 = min(mn2, (int64_t)x - y);
    mx2 = max(mx2, (int64_t)x - y);
  }
  out << max(abs(mn1 - mx1), abs(mn2 - mx2)) << '\n';
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int n, d[N], cnt[N], L, hL;
void check() {
    for (int i = 1; i < hL; i++)
        if (cnt[i]) {
            puts("Impossible");
            return;
        }
    for (int i = hL + 1; i < L; i++)
        if (cnt[i] < 2) {
            puts("Impossible");
            return;
        }
    if (L & 1) {
        if (cnt[hL] != 2) {
            puts("Impossible");
            return;
        }
    } else {
        if (cnt[hL] != 1) {
            puts("Impossible");
            return;
        }
    }
    puts("Possible");
}
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &d[i]);
        cnt[d[i]]++;
        L = max(d[i], L);
    }
    hL = (L + 1) / 2;
    check();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    int n, m;
    cin >> n >> m;
    int ans;
    ans = n*(n-1)/2+m*(m-1)/2;
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    n,t=map(int,input().split())
    ct=[tuple(map(int,input().split())) for _ in range(n)]
    minc = 1001
    for c,tt in ct:
        if t >= tt and minc > c:
            minc = c
    print(minc if minc != 1001 else "TLE")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9032
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        double[] array = new double[n];
        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            array[i] = (double)(num + 1) / 2;
            
        }
        
        double nowsum = 0;
        for (int i = 0; i < k; i++) {
            nowsum += array[i];
        }
        
        double max = nowsum;
        for (int i = 1; i < n - k + 1; i++) {
            nowsum -= array[i - 1];
            nowsum += array[i - 1 + k];
            max = Math.max(max, nowsum);
        }
        
        
        System.out.println(max);
    }
}


Measured memory_bytes: 65448
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int n, m, x;
	cin >> n >> m >> x;
	int l = 0, r = 0, in;
	for (int i = 0; i < m; ++i)
	{
		cin >> in;
		l += (in < x);
		r += (in > x);
	}
	cout << min(l, r) << endl;
	return 0;
}

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string a, b, c;
  cin >> a >> b >> c;

  if (a.at(a.size() - 1) == b.at(0) && b.at(b.size() - 1) == c.at(0)) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF -1e18
#define INF 1e18
#define int ll int
#define OOK order_of_key  //no of elements less than
#define FBO find_by_order //iterator pointing kth element;indexing starts from 0
#define CK3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define CK4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef pair<int,pair<int,int>> PIPI;
typedef map<int,int>MII;
typedef vector<int> VI;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}
*/
//int modInverse(int a, int m) {return power(a, m-2);} //gcd(a,m)=1 


signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{
    int k;
    cin>>k;
    int dp[100][10];
    int len=1;
    dp[1][0]=1;for(int i=1;i<=9;i++)dp[1][i]=1;
    if(k<=9){cout<<k<<endl;return 0;}
    k-=9;
    while(true)
    {len++;
    int sum=0;
    dp[len][0]=dp[len-1][0]+dp[len-1][1];
    for(int i=1;i<9;i++)
    dp[len][i]=dp[len-1][i-1]+dp[len-1][i]+dp[len-1][i+1];
    dp[len][9]=dp[len-1][8]+dp[len-1][9];
    for(int i=1;i<=9;i++)sum+=dp[len][i];
    if(sum>k)break;
    k-=sum;
    }
    
    int ans=0;int j=1;
    for(int i=len;i>0;i--)
    {
        for(;j<=9;j++)
        {
            if(k-dp[i][j]>0)
            {
                k-=dp[i][j];
            }
            else
            {
                ans=ans*10+j;if(j>0)j--;break;
            }
        }
    }
    cout<<ans<<endl;
    
}


return 0;
}





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

#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int h, w;
LL ans[10];
	
inline bool ok(int x, int y)
{
	return x >= 1 && y >= 1 && x <= h - 2 && y <= w - 2;
}
	
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	
	cin >> h >> w;
	
	int n;
	cin >> n;
	vector<PII> cand;
	set<PII> S;
	while(n--)
	{
		int x, y;
		cin >> x >> y;
		S.insert({x, y});
		FOR(i, 0, 3) FOR(j, 0, 3)
			if (ok(x - i, y - j))
				cand.PB({x - i, y - j});
	}
	
	sort(ALL(cand));
	cand.resize(unique(ALL(cand)) - cand.begin());
	
	for(auto lol: cand)
	{
		int x = lol.X, y = lol.Y;
		int tut = 0;
		FOR(i, 0, 3) FOR(j, 0, 3)
			tut += S.count({x + i, y + j});
		ans[tut]++;
	}
	
	FOR(i, 1, 10) ans[0] += ans[i];
	ans[0] = (h - 2) * (LL) (w - 2) - ans[0];
	FOR(i, 0, 10) cout << ans[i] << endl;
		
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 13164
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

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

    ll n; cin >> n;
    priority_queue<P> que_greater;
    // priority_queue<P, vector<P>, greater<P>> que_smaller;
    ll a[n], b[n];
    rep(i, n){
        cin >> a[i] >> b[i];
        que_greater.push({a[i] + b[i], i});
        // que_smaller.push({a[i] + b[i], i});
    }
    bool used[n] = {};

    ll score_taka = 0;
    ll score_aoki = 0;

    rep(i, n){
        P p_taka, p_aoki;
        int i_taka = -1, i_aoki = -1;
        if(i % 2  == 0){
            while(!que_greater.empty()){
                p_taka = que_greater.top();
                que_greater.pop();
                if(!used[p_taka.second]) break;
            }
            i_taka = p_taka.second;
            score_taka += a[i_taka];
            used[i_taka] = true;
        }
        else{
            while(!que_greater.empty()){
                p_aoki = que_greater.top();
                que_greater.pop();
                if(!used[p_aoki.second]) break;
            }
            i_aoki = p_aoki.second;
            score_aoki += b[i_aoki];
            used[i_aoki] = true;
        }

        // cout << i_taka << " " << i_aoki << endl;
    }
    cout << score_taka - score_aoki << endl;


    return 0;
}

Measured memory_bytes: 3696
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    *S,=ST()
    for i,s in enumerate(S):
        S[i] = chr((ord(s)+N-ord("A"))%26+ord("A"))
    print(*S,sep="")
if __name__ == '__main__':
    main()

Measured memory_bytes: 5236
#define _DEBUG 1
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

void solve(ll n, std::vector<ll> a) {
  string result = "";
  rep(i, n) {
    ll idx;
    if (n - 1 - 2 * i >= 0) {
      idx = n - 1 - 2 * i;
    } else {
      idx = 2 * (i - (n / 2)) - (n % 2);
    }

    result += to_string(a.at(idx)) + " ";
  }
  result.erase(result.size() - 1);
  cout << result << 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() {
  ll n;
  scanf("%lld", &n);
  std::vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  solve(n, std::move(a));
  return 0;
}


Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		if (a > 9 || b > 9)
			System.out.println(-1);
		else {
			System.out.println(a * b);
		}

	}
}

Measured memory_bytes: 23764
/*
#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,n)
#define  red(i,n) for(li i=(n)-1;i>=0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
using li = long int;
using ull= unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
 
 
int main()
{
    li n;
    cin>>n;
    li a[n];
    rep(i,n)cin>>a[i];
    for(int i=n-1;i>=0;i-=2) cout<<a[i]<<" ";
    for(int i=n%2;i<n;i+=2) cout<<a[i]<<" ";
    cout<<endl; 
    
    return 0;
}
 

Measured memory_bytes: 3712
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <math.h>

int main(int argc, char *argv[])
{
    int n;
    long long k;
    long long a[100000];
    long long mask;
    long long x;
    int count;
    int i, maskbit;
    long long ans;

    scanf("%d %lld", &n, &k);

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

    x = 0;
    for (maskbit = 40; maskbit >= 0; maskbit--) {
        if (pow(2, maskbit) > k) {continue;}
        mask = (long long) 1 << maskbit;

        count = 0;
        for (i = 0; i < n; i++) {
            if (mask & a[i]) {count++;}
        }

        if (count <= n / 2 && (x | mask) <= k) { // maskbit目が0の方が多いなら，反転させる
            x |= mask;
            for (i = 0; i < n; i++) {
                a[i] ^= mask;
            }
        }
    }

    ans = 0;
    for (i = 0; i < n; i++) {
        ans += a[i];
    }

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main(void){
  int a[5], k;
  REP(i, 5) cin >> a[i];
  cin >> k;
  REP(i, 4){
    FOR(j, i+1, 5){
      if(a[j]-a[i] > k){
        cout << ":(" << endl;
        return 0;
      }
    }
  }
  cout << "Yay!" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#define mod (long long int)(1e9 + 7)
#define pb push_back
using namespace std;
typedef pair<int,int> pii;
 
long long int pow_mod(long long int a,long long int b){
  if(b==0) return 1;
  if(b%2==0){
    long long int c=pow_mod(a,b/2);
    return (c*c)%mod;
  }
  return (a*pow_mod(a,b-1))%mod;
}
 
long long int ncr(long long int n,long long int r){
  if(n<r) return 0;  
  long long int i,ans;
  ans=1;
  for(i=1;i<=(n-r);i++){
    ans*=(n-i+1);
    ans%=mod;
    ans*=pow_mod(i,mod-2);
    ans%=mod;
  }
  return ans;
}
int main(){
  long long int n,k;
 
  cin>>n>>k;
  
  for(int i=0;i<k;i++){
    cout<<ncr(k-1,i)*ncr(n-k+1,i+1)%mod<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include<iomanip>

using namespace std;
typedef long long ll;

int main() {
	int N;
	cin >> N;
	vector<pair<int, int>> ans(N);
	for (int i = 0; i < N; i++) {
		int a; cin >> a;
		ans[i] = make_pair(a, i + 1);
	}
	sort(ans.begin(), ans.end());
	for (int i = 0; i < N; i++) {
		cout << ans.at(i).second << " ";
	}
}


Measured memory_bytes: 3968
#118
n, m = (int(_) for _ in input().split())
ans = 0
food = [0 for i in range(m)]
for i in range(n):
    person = [int(_) for _ in input().split()]
    for j in range(1, person[0] + 1):
        food[person[j] - 1] += 1
for f in food:
    if f == n:
        ans += 1

print(ans)

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

int main() {
    char s[205];
    char nd[] = "-";
    int n, t1, cnt;
    while (1) {
        scanf("%s", s);
        if (strcmp(s, nd) == 0) break;
        scanf("%d", &n);
        cnt = 0;
        while (n--) {
            scanf("%d", &t1);
            cnt += t1;
        }
        // printf("%d\n", cnt);
        cnt %= strlen(s);
        // printf("%d\n", cnt);
        printf("%s", s + cnt);
        s[cnt] = '\0';
        printf("%s\n", s);
    }
}


Measured memory_bytes: 2112
#include<iostream>
#include<algorithm>
using namespace std;
int a[1000];
int main(){
	int n,k,sum=0;
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<k;i++)sum+=a[i];
	cout<<sum<<'\n';
} 

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  int n;
  cin >> n;
  vector<int>l(n);
  rep(i,n) cin >> l[i];
  sort(l.begin(), l.end());
  int ans=0;
  rep(b,n)rep(a,b){
    int ab = l[a]+l[b];
    int right = lower_bound(l.begin(), l.end(), ab)-l.begin();
    int left = b+1;
    ans += max(right-left, 0);
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int a,b;
    cin >> a >> b;
    if(abs(a-b) % 2 == 0) cout << abs((a < b ? a : b) + abs(a-b)/2) << endl;
    else cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
"""
n, k = [int(i) for i in input().split(' ')]

arr = [int(i) for i in input().split(' ')]

dp = [10**10]*n

k += 1
dp[0] = 0

for i in range(0, n):
    for j in range(1, k):
        if i+j < n:
            dp[i+j] = min(dp[i+j], dp[i] + abs(arr[i+j]-arr[i]))

print(dp[n-1])
"""

n = int(input())

a = [int(i) for i in input().split(' ')]

for i in range(1, n):
    new_a = [int(i) for i in input().split(' ')]
    new_a[0] = max(new_a[0]+a[1], new_a[0]+a[2])
    new_a[1] = max(new_a[1]+a[0], new_a[1]+a[2])
    new_a[2] = max(new_a[2]+a[1], new_a[2]+a[0])
    a, new_a = new_a, a

print(max(a))


Measured memory_bytes: 70156
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define Fast_cin ios::sync_with_stdio(false), cin.tie(0);
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
using namespace std;

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') fu = -1; c = getchar(); }
    while(c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}

template <typename T>
void print(T x) {
    if(x < 0) putchar('-'), x = -x;
    if(x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

const int N = 2e5 + 5, md = 998244353;

inline int add(int x, int y) {
    x += y;
    if(x >= md) x -= md;
    return x;
}

inline int sub(int x, int y) {
    x -= y;
    if(x < 0) x += md;
    return x;
}

inline int mul(int x, int y) { return 1ll * x * y % md; }

inline int fpow(int x, int y) {
    int ans = 1;
    while(y) {
        if(y & 1) ans = mul(ans, x);
        y >>= 1; x = mul(x, x);
    }
    return ans;
}

char c[N];
int len[N], f[N];
int n, m, ans;

int check(int l) {
    for(register int i = l + 1; i <= n; i++) {
        int val = (c[(i - 1) % l + 1] - '0') ^ (((i - 1) / l) & 1);
        if(val < c[i] - '0') return 1;
        if(val > c[i] - '0') return 0;
    }
    return 1;
}

int solve(int l) {
    int ans = 0;
    for(register int i = 1; i <= l; i++) ans = add(add(ans, ans), c[i] - '0');
    return ans + check(l);
}

int main() {
    read(n); scanf("%s", c + 1);
    for(register int i = 1; i <= n; i++) {
        if(n % i == 0 && ((n / i) & 1)) {
            len[++m] = i;
            f[m] = solve(i);
        }
    }
    // for(register int i = 1; i <= m; i++) {
    //     fprintf(stderr, "%d, %d\n", len[i], f[i]);
    // }
    for(register int i = 1; i <= m; i++) {
        for(register int j = 1; j < i; j++) {
            if(len[i] % len[j] == 0) {
                f[i] = sub(f[i], f[j]);
            }
        }
        ans = add(ans, mul(f[i], 2 * len[i]));
    }
    print(ans, '\n');
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<28)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n;
    if (2800 <= n) cout << "AGC" << endl;
    else if (1200 <= n) cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define debug(x) cout << #x << " = " << x << endl
#define print(x) cout << x << endl;
const ll MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    map<string, int> M;
    rep(i, N)
    {
        string res;
        cin >> res;
        if (!M.count(res))
        {
            M[res] = 0;
        }
        M[res]++;
    }

    cout << "AC"
         << " x " << M["AC"] << endl;
    cout << "WA"
         << " x " << M["WA"] << endl;
    cout << "TLE"
         << " x " << M["TLE"] << endl;
    cout << "RE"
         << " x " << M["RE"] << endl;
}


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

int main(){
  string s,t,u;
  int a,b;
  cin >> s >> t >> a >> b >> u;
  if(s==u) a--;
  else b--;
  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N,C = map(int,input().split())
XV = [tuple(map(int,input().split())) for i in range(N)]

rcum1 = [0]
rcum2 = [0]
rcummx = [0]
px = 0
for x,v in XV:
    d = x - px
    rcum1.append(rcum1[-1] + v - d)
    rcum2.append(rcum2[-1] + v - 2*d)
    rcummx.append(max(rcummx[-1], rcum1[-1]))
    px = x

lcum1 = [0]
lcum2 = [0]
lcummx = [0]
px = C
for x,v in reversed(XV):
    d = px - x
    lcum1.append(lcum1[-1] + v - d)
    lcum2.append(lcum2[-1] + v - 2*d)
    lcummx.append(max(lcummx[-1], lcum1[-1]))
    px = x
lcum1.reverse()
lcum2.reverse()
lcummx.reverse()

ans = max(rcummx[-1], lcummx[0])
for i in range(N+1):
    a = rcum2[i] + lcummx[i]
    b = lcum2[i] + rcummx[i]
    ans = max(ans, a, b)
print(ans)

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define fi first
#define se second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;
template <class T> using vec = vector<T>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  ll n;
  cin >> n;
  vec<ll> a(n);
  scan(a);

  multiset<ll> s;
  ll ans = 0;
  for (ll num : a) {
    auto it = s.lower_bound(num);
    if (it == begin(s)) {
      ans++;
      s.insert(num);
      continue;
    }

    it--;
    s.erase(it);
    s.insert(num);
  }

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

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


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

int main(){
    int N; cin >> N;
    vector<int> A(N);
    pair<int, int> maxpair = {-1, -1};
    for(int i=0; i < N; i++){
        int a; cin >> a;
        if(maxpair.first <= a && maxpair.second <= a){
            maxpair.second = maxpair.first;
            maxpair.first = a;
        } else if(maxpair.first >= a && maxpair.second <= a){
            maxpair.second = a;
        }
        A[i] = a;
    }
    for(int i=0; i < N; i++){
        if(A[i] == maxpair.first){
            cout << maxpair.second << endl;
        } else {
            cout << maxpair.first << endl;
        }
    }
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n,m;
    cin>>n>>m;
    cout<<n*(n-1)/2+m*(m-1)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N,M,X=get_i
a=get_i
a.push(X)
a.push(0)
a.sort!
x=a.index(X)
ans=0
if x<M+1-x
    ans=x-1
else
  x.upto(M+1) do|i|
    ans=M+1-x
  end
end
puts ans

Measured memory_bytes: 1788
#!/usr/bin/env python

import sys

N = int(sys.stdin.readline())

nfizz = N // 3
nbuzz = N // 5
nfizzbuzz = N // 15

tot = (1 + N) * N // 2
tot_fizz = 3 * (1 + nfizz) * nfizz // 2
tot_buzz = 5 * (1 + nbuzz) * nbuzz // 2
tot_fizzbuzz = 15 * (1 + nfizzbuzz) * nfizzbuzz // 2

tot = tot - (tot_fizz + tot_buzz - tot_fizzbuzz)

print(tot)




Measured memory_bytes: 9188
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // ABC148E - Double Factorial

        Scanner sc = new Scanner(System.in);

        long n = sc.nextLong();

        if (n % 2 == 1) {
            System.out.println(0);
            return;
        }

        long ans = 0;

        for (long i = 10; i <= n; i *= 5) {
            ans += n / i;
        }

        System.out.println(ans);
    }

}


Measured memory_bytes: 21588
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define rep(a,b) for(int a=0;a<b;++a)
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define fastio ios::sync_with_stdio(false)
#define R(a) cin>>a
#define R2(a,b) cin>>a>>b
#define int LL
#define auto QWQ
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
const int MAXN=5e5+20;
int T;
int k[MAXN],l[MAXN],r[MAXN];
vector<mp > v;
vector<int> used; 
set<int> unused;
set<int> :: IT ite;
void solve(){
	v.clear();
	unused.clear();
	used.clear();
	int n;
	R(n);
	rb(i,1,n){
		cin>>k[i]>>l[i]>>r[i];
	} 
	int res=0;
	rb(i,1,n){
		res+=r[i];
		if(r[i]!=l[i])
		v.PB(II(l[i]-r[i],k[i]));
	}
	sort(ALL(v));
	reverse(ALL(v));
	if(v.empty()){
		cout<<res<<endl;
		return;
	}
	rb(i,1,n) unused.insert(i);
	int notsure=n-v.size();
	n=v.size();
	rep(i,n){
		if(v[i].FIR>0){
			ite=unused.upper_bound(v[i].SEC);
			if(ite!=unused.begin())
			{
				ite--;
				used.PB(*ite);
				res+=v[i].FIR;
				unused.erase(ite);
			}
			else notsure++;
		}
		else{
			break;
		}
	}
	sort(ALL(used));
//	cout<<unused.size()<<endl;
	rep(i,used.size()){
		if(!unused.empty()) 
		if(used[i]>*(unused.begin())){
			unused.insert(used[i]);
			unused.erase(unused.begin());
		}
	}
	rb(i,1,notsure){
		unused.erase(unused.begin());
	}
//	cout<<unused.size()<<endl; 
	rl(i,n-1,0){
		if(v[i].FIR<0){
//			cout<<"!"<<endl;
			//want to be right
			ite=unused.upper_bound(v[i].SEC);
			if(ite!=unused.end()){
				unused.erase(ite);
			}
			else{
				unused.erase(unused.begin());
				res+=v[i].FIR;
			}
		}
	}
	cout<<res<<endl;
}
signed main(){
//	freopen("b.in","r",stdin);
//	freopen("b.out","w",stdout);
	fastio;
	cin>>T;
	while(T--) solve();
	return 0;
}
/*

4
3
2 1 9
2 6 6
3 7 4
4
4 7 8
4 7 9
4 1 5
1 10 10
8
5 1 5
1 4 5
1 8 7
5 8 3
1 1 2
8 8 2
1 3 7
5 9 8
5
1 2 1
2 2 1
3 2 1
4 2 1
5 2 1 

*/

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

int n;


int main(void){
    // Your code here!
    cin >> n;
    vector<int> x(n);
    // vector<int> origin(n);
    REP(i,0,n) {
        cin >> x[i];
        // origin[i] = x[i];
    }
    sort(x.begin(),x.end());
    
    int mx = x[n-1];
    if (mx % 2 == 1) mx += 1;
    int half = x[0];
    REP(i,0,n-1) {
        if (abs(mx/2 - x[i]) < abs(mx/2 - half)) {
            half = x[i];
        }
    }
    cout << x[n-1] << " " << half << endl;
    

    
}


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

int main() {
  string s;
  string p;
  cin>>s;
  stringstream komoji_s;
  stringstream komoji_p;
  for(int i=0;i<s.size();i++){
    if(isupper(s[i])){
      komoji_s<<tolower(s[i]);
    }else{
      komoji_s<<s[i];
    }
  }
  s=komoji_s.str();                    
  int count=0;
  while(cin>>p){
    if(p=="END_OF_TEXT")break;
    komoji_p.str("");
    for(int i=0;i<p.size();i++){
      if(isupper(p[i])){
        komoji_p<<(char)tolower(p[i]);
      }else{
        komoji_p<<p[i];
      }
    }
    p=komoji_p.str();
    //cout<<s<<" "<<p<<endl;
    if(s.compare(p)==0){
      count++;
    }
  }
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 3208
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#define rep(i,N) for(int i=0; i<N;i++)
using namespace std;

int main(){
    int X;
    cin >>X;
    if(X<30){
        cout <<"No";
    }else{
        cout <<"Yes";
    }
    return 0;
}



Measured memory_bytes: 3628
#include<stdio.h>

int solve(int,int);

int q,n,A[2000],M[2000];

int main(){
  int i,j;

  //in                                                                                                    
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &A[i]);
  }
  scanf("%d", &q);
  for(i=0; i<q; i++){
    scanf("%d", &M[i]);
  }

  //M[1~q]まで再帰にかける&out                                                                          
  for(i=0; i<q; i++){
    if( solve(0, M[i]) ){
      printf("yes\n");
    }
    else{
      printf("no\n");
    }
  }
  return 0;
}

int solve(int i,int m){
  //(M[]の内1項)−(分岐点の数値)=0ならその数値になり得る                                             
  if(m-A[i]==0) return 1;
  //A[]の要素数を超えるとmになりえない                                                          
  if(i >= n) return 0;
  //まだ判断ができない場合はsolveに再帰的に変数値を引き継ぐ                               
  if(solve(i+1,m-A[i]) || solve(i+1,m)) return 1;
  return 0;
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

int dp[110][10010];

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

    int n,w;
    cin>>n>>w;
    vector<pair<int,int>> v(n);
    for(int i=0;i<n;i++)cin>>v[i].first>>v[i].second;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=w;j++){
            if(j-v[i-1].second>=0)dp[i][j]=max(dp[i-1][j],dp[i][j-v[i-1].second]+v[i-1].first);
            else dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][w]<<endl;

}


Measured memory_bytes: 7140
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int h, w, K;
    cin>>h>>w>>K;
    vector<string> v(h);
    rep(i, h){
        cin>>v[i];
    }
    int all_k = 0;
    vector<int>horizontal(w);
    rep(i, h){
        rep(j, w){
            if(v[i][j] == '#') {
                horizontal[j]++;
                all_k++;
            }
        }
    }
    int ans = 0;
    for(int i = 0;i<(1<<h);i++){
        int now_vertical = 0;
        vector<int> check(w);
        rep(k_1, h){
            if((i>>k_1)&1){
                rep(j, w){
                    if(v[k_1][j] == '#') {
                        now_vertical++;
                        check[j]++;
                    }
                }
            }
        }
        for(int j = 0;j<(1<<w);j++){
            int now = now_vertical;
            rep(l, w){
                if((j>>l)&1){
                    now+=horizontal[l]-check[l];
                }
            }
            if(now==all_k-K) ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

#define IL __inline__ __attribute__((always_inline))

#define For(i, a, b) for (int i = a, i##end = b; i <= i##end; ++ i)
#define FOR(i, a, b) for (int i = a, i##end = b; i < i##end; ++ i)
#define Rep(i, a, b) for (int i = a, i##end = b; i >= i##end; -- i)
#define REP(i, a, b) for (int i = a, i##end = b; i > i##end; -- i)

template < class T >
IL T chkmax(T &a, const T b) {
    if (a < b)
        a = b;
    return a;
}

template < class T >
IL T chkmin(T &a, const T b) {
    if (a > b)
        a = b;
    return a;
}

template < class T >
IL T mymax(const T a, const T b) {
    return a > b ? a : b;
}

template < class T >
IL T mymin(const T a, const T b) {
    return a < b ? a : b;
}

template < class T >
IL T myabs(const T &a) {
    return a > 0 ? a : -a;
}

const int INF = 0X3F3F3F3F;
const double EPS = 1E-10, PI = acos(-1.0);

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define OK DEBUG("Passing [%s] in LINE %d...\n", __FUNCTION__, __LINE__)

typedef long long LL;
#define F first
#define S second
/*************************header*************************/

const int MAXN = 100000 + 5;

int r[MAXN], pos1[MAXN], pos2[MAXN], p[MAXN];

int main() {
	int x, n;
	scanf("%d%d", &x, &n);
	For(i, 1, n) {
		scanf("%d", &r[i]);
		p[i] = p[i - 1] + ((i & 1) ? r[i - 1] - r[i] : r[i] - r[i - 1]);
	}
	pos1[0] = 0;
	pos2[0] = x;
	For(i, 1, n) {
		pos1[i] = (i & 1) ? mymax(0, pos1[i - 1] - r[i] + r[i - 1]) : mymin(x, pos1[i - 1] + r[i] - r[i - 1]);
		pos2[i] = (i & 1) ? mymax(0, pos2[i - 1] - r[i] + r[i - 1]) : mymin(x, pos2[i - 1] + r[i] - r[i - 1]);
	}
	int q;
	scanf("%d", &q);
	int cur = 0;
	while (q --) {
		int t, a;
		scanf("%d%d", &t, &a);
		while (r[cur + 1] <= t && cur < n)
			++ cur;
		int L = (cur & 1) ? mymin(x, pos1[cur] + t - r[cur]) : mymax(0, pos1[cur] - t + r[cur]), 
			R = (cur & 1) ? mymin(x, pos2[cur] + t - r[cur]) : mymax(0, pos2[cur] - t + r[cur]),
			k = a + ((cur & 1) ? p[cur] + t - r[cur] : p[cur] - t + r[cur]);
		if (k <= L)
			printf("%d\n", L);
		else if (k >= R)
			printf("%d\n", R);
		else
			printf("%d\n", k);
	}
	return 0;
}


Measured memory_bytes: 2816