akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int n,i,a,r;
map<int,int> m;
int main() {
  scanf("%d",&n);
  for (i=0; i<n; i++) {
    scanf("%d",&a);
    m[a]=i;
  }
  auto it=m.begin();
  for (i=0; it!=m.end(); it++, i^=1) if (it->second%2!=i) r++;
  printf("%d\n",r/2);
  return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    rep(i, n) {
        int a;
        cin >> a;
        --a;
        g[a].push_back(i);
    }
    int ans = 0;
    map<pair<int, int>, bool> mp;
    rep(i, n) {
        for ( auto v : g[i] ) {
            for ( auto u : g[v] ) {
                if ( !mp[{v, u}] && !mp[{u, v}] && i == u ) {
                    ++ans;
                    mp[{v, u}] = true;
                    mp[{u, v}] = true;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 18176
N = int(input())

def F(a, b):
    return max( len(str(a)), len(str(b)) )

ans = float('inf')
n_iter = int(N**(1/2))+1

for i in range(1, n_iter):
    if N%i==0:
        ans = min( ans, F(i, N//i) )

print(ans)

Measured memory_bytes: 3060
N,K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
doko = 0
for i in range(N):
    if A[doko] <= 0:
        saishou = min(A)
        loop = A[doko] - saishou + 1
        hajimarimade = A[doko]
        K += hajimarimade
        print(A.index(-1*(K % loop)+hajimarimade)+1)
        exit()
    if i == K:
        print(doko+1)
        exit()
    hoji = doko
    doko = A[doko] - 1
    A[hoji] = (-1)*i

Measured memory_bytes: 32328
def f(s):
    return (s[0]*60+s[1])*60+s[2]
a=86401
while 1:
    t=[0]*a
    n=int(input())
    if n==0:break
    for _ in range(n):
        b,c=input().split()
        b,c=list(map(int,b.split(':'))),list(map(int,c.split(':')))
        t[f(b)]+=1;t[f(c)]-=1
    d=0
    for i in range(1,a):
        t[i]+=t[i-1]
        d=max(d,t[i])
    print(d)

Measured memory_bytes: 11652
#include <iostream>
using namespace std;
int main()
{
  int A, B;
  cin >> A >> B;
  int ans = 0;
  for (int i = A; i <= B; i++)
  {
    string s = to_string(i);
    if (s[0] == s[4] && s[1] == s[3])
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(X: int):
    current = 100
    count = 0
    while current < X:
        current = int(current*1.01)
        count += 1
    print(count)
    
    return


# 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)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


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

int main()
{
	int n;
	while(cin >> n){
		if(!n)
			break;
		int num = 0;
		int field[401][401];
		memset(field,-1,sizeof(field));
		field[200][200] = num++;
		for(int i=0;i<n-1;i++){
			int a,b;
			cin >> a >> b;
			for(int j=0;j<=400;j++){
				for(int k=0;k<=400;k++){
					if(field[j][k] == a){
						switch(b){
							case 0:
								field[j][k-1] = num++;
								break;
							case 1:
								field[j+1][k] = num++;
								break;
							case 2:
								field[j][k+1] = num++;
								break;
							case 3:
								field[j-1][k] = num++;
								break;
						}
					}
				}
			}
		}
		int sx=1000000,sy=1000000,gx=0,gy=0;
		for(int i=0;i<=400;i++){
			for(int j=0;j<=400;j++){
				if(field[i][j] != -1){
					sx = min(sx,j);
					sy = min(sy,i);
					gx = max(gx,j);
					gy = max(gy,i);
				}
			}
		}
		cout << gx-sx+1 << " " << gy-sy+1 << endl;
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int Sn = 0;
  int N1 = N;
 while (N1 != 0){
    Sn += N1%10;
    N1 /= 10;
  }
  if (N%Sn == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
typedef long long                   ll;
typedef long double                 ld;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<double,double>         pdd;
typedef pair<ld,ld>                 pld;
typedef pair<string , string>       pss;
#define ts(x)                       to_string(x)
#define ti(x)                       stoi(x)
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define tab                         '\t'
#define sep                         ' '
#define mine(v)                     *min_element(all(v))
#define maxe(v)                     *max_element(all(v))
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define endl                        "\n"
inline ll input(){ll n; cin >> n ; return n;}
ll pw(ll a , ll b)  { return (!b ? 1 : (b & 1 ? a * pw(a * a , b / 2) : pw(a * a , b / 2))); }

const int MAXN = 1e6 + 10;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;
const ll INF = 8e18;
bool mark[MAXN];
vector<int> g[MAXN], r[MAXN];
ll dp[MAXN], last[MAXN];

void DFS(int x,bool val, int X){
    mark[x] = 1;
    for(auto y:g[x]){
        if(!mark[y]){
            DFS(y, 1, x);
        }
        dp[x] = max(dp[x], dp[y] + 1);
    }
    return;
}

int main(){
    fast_io;
    //cout << fixed << setprecision(15);
    //scanf("%d %d %f %lld %s %c", &x);
    //printf("%d %d %f %lld %s %c", x);
    int n, m, a, b;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
    }
    for(int i = 0; i < n; i++){
        if(!mark[i]){
            DFS(i, 0, 0);
        }
    }
    ll ans = 0;
    //cout << endl;
    for(int i = 0; i < n; i++){
        //cout << dp[i] << " ";
        ans = max(ans, dp[i]);
    }
    cout << ans;
    return 0;
}




Measured memory_bytes: 58624
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll, ll>

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const int sz=2e5+100;
map<pii,int> mp;
vector<pii> edge;
vector<int> ad[sz];
int clr;
void DFS(int p,int parent,int last)
{
    int i=1;
    for(auto xx: ad[p])
    {
         if(xx != parent)
         {
             if(i==last) ++i;
             while(i>=clr) ++clr;
             int tempp=p,tempq=xx;
             if(tempp>tempq) swap(tempp,tempq);
             mp[{tempp,tempq}]=i;
             DFS(xx,p,i);
             ++i;
         }
    }
}
int main()
{
    Khela
    int a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    while(cin>>n)
    {
        for(i=0;i<=n;i++) ad[i].clear();
        mp.clear();
        edge.clear();
        for(i=1;i<n;i++)
        {
            cin>>p>>q;
            ad[p].pb(q);
            ad[q].pb(p);
            if(p>q) swap(p,q);
            edge.pb({p,q});
        }
        clr=0;
        DFS(1,-1,-1);
        cout<<clr-1<<endl;
        if(n==1) clr=0;
        for(auto xx: edge){
            cout<<mp[{xx.f,xx.s}]<<endl;
        }

    }

}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

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

  ll n;
  cin>>n;
  vector<ll> a(n+2,-INF),pre(n+2,-1),nxt(n+2,-1);
  repl(i,1,n+1)cin>>a[i];
  rep(i,n+2){
    pre[i]=i-1;
    nxt[i]=i+1;
  }

  set<P> st;
  rep(i,n+2){
    st.insert(P(a[i],i));
  }

  ll sum=0;
  rep(_,n/2){
    P p=*st.rbegin();
    sum+=p.fi;
    ll idx=p.se;

    st.erase(st.find(P(p.fi,p.se)));
    st.erase(st.find(P(a[pre[idx]],pre[idx])));
    st.erase(st.find(P(a[nxt[idx]],nxt[idx])));

    ll val=a[pre[idx]]+a[nxt[idx]]-a[idx];
    a[idx]=-INF; a[nxt[idx]]=-INF;
    ll nnxt=nxt[nxt[idx]];
    nxt[pre[idx]]=nnxt;
    if(nnxt<n+2)pre[nnxt]=pre[idx];
    a[pre[idx]]=val;

    st.insert(P(a[pre[idx]],pre[idx]));
  }
  cout<<sum<<endl;

  return 0;
}


Measured memory_bytes: 20340
// AtcoderTemplate.cpp : アプリケーションのエントリ ポイントを定義します。
//

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

int main()
{
	int n;
	cin >> n;
	if (n % 111 == 0) {
		cout << n << endl;
	}
	else {
		cout << (n / 111 + 1) * 111 << endl;
	}
    return 0;
}



Measured memory_bytes: 256
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    let mut iter = line.split_whitespace().map(|s| s.parse::<u32>().unwrap());
    let (a, b) = (iter.next().unwrap(), iter.next().unwrap());
    println!("{} {} {}", a/b, a%b, a as f64/b as f64);
}


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

#define inf 0x3f3f3f3f
#define INF 1000111000111000111LL
#define mod 1000000007
#define endl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fi first
#define se second
#define all(cc) (cc).begin(),(cc).end()
using lli = long long int ;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vb = vector<bool> ;
using vvi = vector<vector<int>> ;
using vlli = vector<long long int> ;
using vpii = vector<pair<int, int>> ;

int main()
  {
    ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
    lli n, x, two=0, four=0, ans ;
    cin>> n ;
    for(int i=0 ; i<n ; i++)
      {
        cin>> x ;
        if(x%4==0) four++ ;
        else if(x%2==0) two++ ;
      }
    two=max(two-1, (lli)0) ;
    ans=(four*2+1)+two ;
    if(ans>=n) cout<< "Yes" ;
    else cout<< "No" ;
  }


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdlib>
#include <cmath>
#define INF 100000000
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; }

using namespace std;

int main(){
  int i,j,k,a[100],max=-1*INF,n;
  cin >>n;
  for(i=0;i<n;i++)cin >> a[i];
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      chmax(max,abs(a[i]-a[j]));
    }
  }
  cout << max  << endl;;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <assert.h>
#include <fstream>

using namespace std;

const int MAXN = 100005;

struct Edge
{
	int to;
	int nxt;
}edge[MAXN << 1];

int n,m,id;
int fa[MAXN];
int first[MAXN];

void addE(int u,int v)
{
	edge[++id] = (Edge){v,first[u]};
	first[u] = id;
}

pair<int,int> dfs(int u)
{
	pair<int,int> ret;
	for (int i = first[u];i;i = edge[i].nxt)
	{
		pair<int,int> res = dfs(edge[i].to);
		ret.first += res.first;
		ret.second = max(ret.second,res.second + 1);
	}
	if (u == 1 || fa[u] == 1)
		return ret;
	if (ret.second >= m - 1)
	{
		ret.first++;
		ret.second = -1;
	}
	return ret;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for (int i = 1;i <= n;i++)
	{
		cin >> fa[i];
		if (i > 1)
			addE(fa[i],i);
	}
	cout << dfs(1).first + (fa[1] != 1) << endl;
	return 0;
}

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

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

int main(){
  ull a,b,c,d;cin >> a >> b >> c >> d;
  ull xy = b/lcm(c,d) - (a-1)/lcm(c,d);
  ull x = (b/c) - (a-1)/c;
  ull y = (b/d) - (a-1)/d;
  ull ans = (b-a+1) - (x+y-xy);
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <queue>
#include <sstream>
#include <climits>
#include <cmath>
#include <list>
#include <functional>
#include <map>
#include <stack>
using namespace std;
#define M_PI 3.141592
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define FORI(i,k,n) for(int i=k;i<(int)n;i++)
#define toRad 2.0*M_PI/360.0
#define inin(x) int x;cin>>x;
#define all(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define EPS 1e-12
#define pri_max 60000
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

/* 
bool memo[pri_max] = {};
vector<int> pri;
void calc()
{
	for (int i = 2; i < pri_max; i++)
	{
		if (memo[i] == false)
		{
			pri.push_back(i);
			for (int l = i; l < pri_max; l += i)
			{
				memo[l] = true;
			}
		}
	}
}*/
double len(pdd a, pdd b)
{
	return sqrt((b.first - a.first)*(b.first - a.first) + (b.second - a.second)*(b.second - a.second));
}

string en[] =
{
" 101",
"'000000",
",000011",
"-10010001",
".010001",
"?000001",
"A100101",
"B10011010",
"C0101",
"D0001",
"E110",
"F01001",
"G10011011",
"H010000",
"I0111",
"J10011000",
"K0110",
"L00100",
"M10011001",
"N10011110",
"O00101",
"P111",
"Q10011111",
"R1000",
"S00110",
"T00111",
"U10011100",
"V10011101",
"W000010",
"X10010010",
"Y10010011",
"Z10010000"
};
string de = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";
int todec(string x)
{
	reverse(all(x));
	int ans = 0;
	for (int i = 0; i < x.size(); i++)
	{
		ans += (x[i] - '0')*pow(2, i);
	}
	return ans;
}

int main()
{
	string s;
	while (getline(cin, s))
	{
		string a, b;
		for (int l = 0; l < s.size(); l++)
		{
			for (int i = 0; i < 32; i++)
			{
				if (s[l] == en[i][0])
				{
					a += en[i].substr(1, en[i].size() - 1);
				}
			}
		}
		FOR(i, a.size() % 5)a += "0";
		for (int i = 0; i < a.size() / 5; i++)
		{
			b+=de[todec(a.substr(i * 5, 5))];
		}
		cout << b << endl;
	}
}

Measured memory_bytes: 1232
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#define mod 1000000007
#define ten5 100000
using namespace std;



int main()
{
    int m,n,o=0,i,j,k,num[3];
    int sum=0,range=0;
    //long long int m,n,o,i,j,k=0;
    //vector <int> v;
    //float f,g,h;
    //char c,d;
    //string a;
    for(i=0;i<3;i++) cin>>num[i];
    sort(num,num+3);
    j=num[2]-num[0];
    k=num[2]-num[1];
    if(j%2==k%2)
    {
        sum=k/2+j/2;
        if(j%2==1) sum++;
    }
    else
    {
        sum=(k+1)/2+(j+1)/2+1;
    }
    cout<<sum;
    return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define pb push_back
#define pq priority_queue
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define elif else if

using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
using pll=pair<ll,ll>;
using pss=pair<string,string>;
using pdd=pair<ld,ld>;
using graph=vector<vector<int>>;
using wgraph=vector<vector<pll>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ex[8]={1,1,0,-1,-1,-1,0,1};
const int ey[8]={0,1,1,1,0,-1,-1,-1};
const ld E=1e-9;

template<class T> void chmin(T &a, T b){a=min(a, b);}
template<class T> void chmax(T &a, T b){a=max(a, b);}

ll abs1(ll a){if(a>=0)return a;else return -a;}
ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1)ret*=a;
    a*=a;
    if(a>=p)a%=p;if(ret>=p)ret%=p;
    b=b>>1;
  }
  return ret;
}
int digit(ll a,ll b=10){int i=0;while(a!=0){a/=b;i++;}return i;}
ll gcd1(ll a,ll b){
  if(a==0 || b==0)return 0;
  ll n;while(a%b!=0){n=a%b;a=b;b=n;}return b;
}
ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];a[0]=n;b[0]=m;int i=1;
  while(b[i-1]!=0){a[i]=b[i-1];b[i]=a[i-1]%b[i-1];i++;}
  n=i;if(c%a[n-1]!=0)return 0;
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){ll cnt=x;x=y;y=cnt-(a[n-i-1]/b[n-i-1])*y;}
  return x;
}
ll modRev(ll a,ll p=MOD){
  a%=p;ll n=solveLinear(a,p,1);
  n%=p;if(n<0)return n+p;
  return n;
}
ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  ll ret=1;
  for(int i=1;i<=n;i++){ret=ret*i;if(ret>=p)ret%=p;}
  return ret;
}
ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  ll ret=1;
  rep(i,k){ret=ret*(n-i);if(ret>=p)ret%=p;}
  return ret;
}
ll binom(ll n,ll k,ll p=MOD){
  return (perm(n,k,p)*modRev(fact(k)))%p;
}
int bis(vector<int> v,int key){
  int left=-1,right=v.size();
  while(abs1(right-left)>1){
    int mid=left+(right-left)/2;
    if(v[mid]<=key)left=mid;
    else right=mid;
  }
  return left;
}

int f(int p,int q){
  if(p>q)swap(p,q);
  int n=q/p+1,r=q%p;
  return n*p+r-1;
}

int main(){
  int i,j,k,cnt=0;
  int x;
  cin>>x;
  ll n=2;
  rep(i,x)n=2*n+2;
  cout<<n<<endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(100);
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int score;
  score = 0;
  for(int i = 0; i < N; i++){
    if(i % 2 == 0){
      score += vec.at(i);
    }
    else{
      score -= vec.at(i);
    }
  }
  cout << score <<endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const ll INF = ll(1e15)+10;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;

ll leg(ll n) {
	ll x = 5;
	ll res = 0;
	while (n >= x) {
		res += (n / x);
		x *= 5;
	}
	return res;
}

int main() {
	ll N; cin >> N;
	ll ans;
	if (N % 2 == 0) {
		ans = leg(N/2);
	}
	else {
		ans = 0;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int f=0;
    while(n!=0)
    {
        if(n%10==7)
        {
            f=1;
            cout<<"Yes"<<endl;
            break;
        }
        n=n/10;
    }
    if(!f)
    {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int N = 1e6;

int main() {
    ios_base::sync_with_stdio(0);
    ll a,b,n,x,T,cas=0;
    cin>>x;
    a=0, b=0;
    for(ll i=-1000;i<=1000;++i) {
        ll p = i*i*i*i*i;
        ll q = p-x;
        ll t=q;
        // cerr<<p<<" "<<q;
        int neg=0;
        if(q<0) {
        	neg=1;
        	q*=-1;
        }
        ll r = pow(q, 1.0/5);
        if(neg) r*=-1;
        // cerr<<r<<endl;
        if(r*r*r*r*r==t) {
            a = i, b=r;
            // if(neg) b*=-1;
            break;
        }
    }
    if(a==0 && b==0) assert(a!=0);
    cout<<a<<" "<<b<<endl;
    return 0;
}

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

#define cc(x) cout << (x) << endl
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); ++i)
typedef long long ll;

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }


int n,m;
int a, b, k;
string s;
const ll inf = 1LL<<58;
const int iinf = 1<<30;


int main(){
    cin >> s;
    int onecount=0;
    int zerocount=0;
    rep(i,s.size()){
        if(s[i]=='1'){
            onecount++;
        }else if(s[i]=='0'){
            zerocount++;
        }
    }
    if(onecount>zerocount){
        cc(zerocount*2);
    }else{
        cc(onecount*2);
    }
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define vsort(v) sort(v.begin(),v.end())
#define asort(a,n) sort(a, a + n)
#define vi vector<int>
#define vd vector<double>

//ここからAtCoder向けdefine
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;

using namespace std;

vi num(4);

bool zero(){
    int ans = 0;
    rep(i, 4){
        ans+= num[i];
    }
    if(ans == 7) return true;
    return false;
}

int ichi(){
    int ans = 0;
    REP(i, 1, 4){
        num[i] = -num[i];
        rep(j, 4){
            ans += num[j];
        }
        num[i] = -num[i];
        if(ans == 7) return i;
        ans = 0;
    }
    return -1;
}

int ni(){
    int ans = 0;
    /*rep(i, 4){
        cout << num[i] << ", ";
    }cout << endl;*/
    REP(i, 1, 4){
        REP(j, 1, 4){
            if(j != i){
                num[j] = -num[j];
                //cout << "rev" << j << '=' << num[j] << ',';
            }
        }
        //cout << endl;
        rep(j, 4){
            ans += num[j];
            //cout << num[j] << '>';
        }
        REP(j, 1, 4){
            if(i != j){
                num[j] = -num[j];
            }
        }
        //cout << endl << "ans = " << ans << endl;
        if(ans == 7) return i;
        ans = 0;
    }
    return -1;
}

bool san(){
    int ans = num[0];
    REP(i, 1, 4){
        num[i] = -num[i];
        ans += num[i];
    }
    REP(i, 1, 4){
        num[i] = -num[i];
    }
    if(ans == -7) return true;
    return false;
}

int main(){
    ios::sync_with_stdio(false);
    char n;
    rep(i, 4){
        cin >> n;
        num[i] = n - 48;
        //cout << num[i];
    }

    int a = ichi();
    /*
    rep(i, 4){
        cout << num[i];
    }
    cout << endl;*/
    
    if(zero()){
        cout << num[0] << '+' << num[1] << '+' << num[2] << '+' << num[3] << "=7" << endl;
    }/*else if(san()){
        cout << num[0] << '-' << num[1] << '-' << num[2] << '-' << num[3] << "=7" << endl;
    }*/else if(a != -1){
        cout << num[0];
        REP(i, 1, 4){
            if(i != a){
                cout << '+';
            }else{
                cout << '-';
            }
            cout << num[i];
        }
        cout << "=7" << endl;
    }else{
        int res = ni();
        cout << num[0];
        REP(i, 1, 4){
            if(i != res){
                cout << '-';
            }else{
                cout << '+';
            }
            cout << num[i];
        }
        cout << "=7" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// Problem : E - Dist Max
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

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

/* DEBUGGING */
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

/* MACROS */ 
typedef long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

typedef map<int,int> mii;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  all(x)      (x).begin(), (x).end()
#define  lcm(x, y)   ((x) * (y) / __gcd(x, y))
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcountll(x)
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b) for(int i=a ; i>=b ; --i)

/* CONSTANTS */ 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 2*10000000000000;
const ll MAX_N = 2e5 + 2;

// #define cerr if(false)cerr
/* CODE STARTS HERE */

void solve(){
    ll n; cin >> n;
    pll p1 = {-INF,INF},p2 = {-INF,INF},p3 = {-INF,INF};
    
    ll a,b;
    rep(i,0,n){
        cin >> a >> b;
        
        // a+b
        p1.ff = max(p1.ff , a+b);
        p1.ss = min(p1.ss , a+b);
        
        // a-b
        p2.ff = max(p2.ff , a-b);
        p2.ss = min(p2.ss , a-b);
        
        // b-a
        p3.ff = max(p3.ff , b-a);
        p3.ss = min(p3.ss , b-a);        
    }
    // deb(p1,p2,p3);
    
    ll ans = max({abs(p1.ff-p1.ss) , abs(p2.ff-p2.ss) , abs(p3.ff-p3.ss) , 0LL});    
    cout << ans;
}

int main(){
    IOS;
    solve();
}

Measured memory_bytes: 3640
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;

const int N=100005;
struct Seg
{
    int l,r;
    inline bool operator<(const Seg& o)const{return r<o.r;}
}s[N];
int n;

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i)
    {
        int x,l;
        scanf("%d%d",&x,&l);
        s[i]=(Seg){x-l,x+l};

    }
    int Pre=0x80000000,Cnt=0;
    std::sort(s+1,s+n+1);
    for(int i=1;i<=n;++i)
    {
        if(s[i].l>=Pre)
        {
            Pre=s[i].r;
            ++Cnt;
        }
    }
    printf("%d\n",Cnt);
    return 0;
}


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

typedef long long ll;
typedef unsigned long long int ull;
#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MOD 1000000007
#define PI 3.141592653589793238
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n)
    {
        if(n & 1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return result;
}



int32_t main()
{
    IOS

    int n;
    cin>>n;
    string k[4]={"AC","WA","TLE","RE"};
    unordered_map<string,int> mp;
    for(int i=0;i<n;i++)
    {
    	string s;
    	cin>>s;
    	mp[s]++;
    }

    for(int i=0;i<4;i++)
    	cout<<k[i]<<" x "<<mp[k[i]]<<endl;
    
    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>

int main(void){
    int x,y,z;
    scanf("%d %d %d", &x, &y, &z);
    int ans = 0;
    while(1){
        if(ans*(y+z)+z>x){
            ans--;
            break;
        } else if(ans*(y+z)+z==x){
            break;
        } else{
            ans++;
        }
    }
    printf("%d\n", ans);
}

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

using namespace std;

main() {
    //freopen("input.txt", "r", stdin):
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int k, x;
    cin >> k >> x;
    for (int i = max(-1000000, x - k + 1); i <= min(1000000, x + k - 1); ++i) cout << i << " ";
    return 0;
}



Measured memory_bytes: 256
a, b, k = map(int, input().split())

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

    # divisors.sort()
    return divisors

list_a = make_divisors(a)
list_b = make_divisors(b)
common = list(set(list_a) & set(list_b))
common.sort()
print(common[-k])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll MOD = 1000000007;

int main() {
    int K;
    cin >> K;
    string S;
    cin >> S;
    if(S.size() <= K){
        cout << S << endl;
    }else{
        cout << S.substr(0, K) << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
 
int main(void){
	
  int a,b,c;
  
  scanf("%d %d %d",&a,&b,&c);
  
  if(a+b+c == 17){
  printf("YES\n");
  } else {
  printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 128
'''二分探索'''
#import bisect
'''デック'''
#from collections import deque
'''順列,組み合わせ,累積和,直積・forネスト'''
#from itertools import permutations, combinations, accumulate, product
'''小数点以下切り捨て,小数点以下切り上げ,平方根,階乗,最大公約数'''
#from math import floor, ceil, sqrt, factorial, gcd
'''input 文字列は最後に\nを含む'''
#import sys
#input = sys.stdin.readline


def main():
    r = int(input())
    import math
    print(r*2*math.pi)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61984
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e3+4;


int32_t main(){
	cin.tie(0)->sync_with_stdio(0);
	#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	#endif
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<max({b*d,a*c,a*d,b*c});
} 



Measured memory_bytes: 3652
#include<iostream>
#include<cmath>
#include<iomanip>
int main(){
  int n;
  double D=0;
  std::cin >> n;
  int x[n], y[n];
  for(int i=0; i<n; i++) std::cin >> x[i];
  for(int i=0; i<n; i++) std::cin >> y[i];
  for(int p=1; p<=3; p++){
    for(int i=0; i<n; i++) D += pow(std::abs(x[i]-y[i]), p);
    std::cout << std::fixed << std::setprecision(8) << pow(D, (double)1/p) << std::endl;
    D = 0;
  }
  for(int i=0; i<n; i++) if(D < std::abs(x[i]-y[i])) D = std::abs(x[i]-y[i]);
  std::cout << std::fixed << std::setprecision(8) << D << std::endl;
  return 0;
}

Measured memory_bytes: 3444
h, w, n = gets.chomp!.split(" ").map!(&:to_i)
s_r, s_c = gets.chomp!.split(" ").map!(&:to_i)
s_r -= 1
s_c -= 1
s = gets.chomp!.chars
t = gets.chomp!.chars

#puts "h=#{h}"
#puts "w=#{w}"
#puts "Sr=#{s_r}"
#puts "Sc=#{s_c}"
# require 'pp'

memo = {
  'L' => Array.new(n * 2, s_c),
  'R' => Array.new(n * 2, s_c),
  'U' => Array.new(n * 2, s_r),
  'D' => Array.new(n * 2, s_r),
}

inverse = {
  'L' => 'R',
  'R' => 'L',
  'U' => 'D',
  'D' => 'U',
}

is_no = false

n.times do |i|
  my = i * 2
  you = i * 2 + 1
  memo['L'][my] = memo['L'][my - 1]
  memo['R'][my] = memo['R'][my - 1]
  memo['U'][my] = memo['U'][my - 1]
  memo['D'][my] = memo['D'][my - 1]

  case s[i]
  when 'R'
    memo[s[i]][my] = memo[s[i]][my - 1] + 1
    if memo[s[i]][my] >= w
      is_no = true
      break
    end
  when 'D'
    memo[s[i]][my] = memo[s[i]][my - 1] + 1
    if memo[s[i]][my] >= h
      is_no = true
      break
    end
  when 'L'
    memo[s[i]][my] = memo[s[i]][my - 1] - 1
    if memo[s[i]][my] < 0
      is_no = true
      break
    end
  when 'U'
    memo[s[i]][my] = memo[s[i]][my - 1] - 1
    if memo[s[i]][my] < 0
      is_no = true
      break
    end
  end

  memo['L'][you] = memo['L'][you - 1]
  memo['R'][you] = memo['R'][you - 1]
  memo['U'][you] = memo['U'][you - 1]
  memo['D'][you] = memo['D'][you - 1]

  case t[i]
  when 'L'
    memo[inverse[t[i]]][you] = memo[inverse[t[i]]][you - 1] > 0 ? memo[inverse[t[i]]][you - 1] - 1 : 0
  when 'R'
    memo[inverse[t[i]]][you] = memo[inverse[t[i]]][you - 1] + 1 < w ? memo[inverse[t[i]]][you - 1] + 1 : memo[inverse[t[i]]][you - 1]
  when 'U'
    memo[inverse[t[i]]][you] = memo[inverse[t[i]]][you - 1] > 0 ? memo[inverse[t[i]]][you - 1] - 1 : 0
  when 'D'
    memo[inverse[t[i]]][you] = memo[inverse[t[i]]][you - 1] + 1 < h ? memo[inverse[t[i]]][you - 1] + 1 : memo[inverse[t[i]]][you - 1]
  end
end

puts is_no ? "NO" : "YES"


Measured memory_bytes: 34940
#include <iostream>

using namespace std;

void toE(int a[])
{
    int tmp = a[0];
    a[0] = a[3];
    a[3] = a[5];
    a[5] = a[2];
    a[2] = tmp;
}

void toW(int a[])
{
    int tmp = a[0];
    a[0] = a[2];
    a[2] = a[5];
    a[5] = a[3];
    a[3] = tmp;
}

void toS(int a[])
{
    int tmp = a[0];
    a[0] = a[4];
    a[4] = a[5];
    a[5] = a[1];
    a[1] = tmp;
}

void toN(int a[])
{
    int tmp = a[0];
    a[0] = a[1];
    a[1] = a[5];
    a[5] = a[4];
    a[4] = tmp;
}

void spin(int a[])
{
    int tmp = a[1];
    a[1] = a[3];
    a[3] = a[4];
    a[4] = a[2];
    a[2] = tmp;
 }

bool judgeSame(int a[], int b[])
{
    int uNum[6] = {-1}, fNum[6] = {-1};
    bool ans = false;
    int last_U = 0, last_F = 0;

    for (int i = 0; i < 6; i++)
    {
        if (a[0] == b[i])
        {
            uNum[last_U] = i;
            last_U++;
        }
        if (i == 5 && uNum[0] == -1)
        {
            return ans;
        }
    }

    for (int j = 0; j < last_U; j++)
    {
        switch (uNum[j])
        {
            case 0:
                break;
            case 1:
                toN(b);
                break;
            case 2:
                toW(b);
                break;
            case 3:
                toE(b);
                break;
            case 4:
                toS(b);
                break;
            case 5:
                toN(b);
                toN(b);
                break;
        }

        for (int i = 1; i <= 4; i++)
        {
            if (a[1] == b[i])
            {
                fNum[last_F] = i;
                last_F++;
            }
        }
        if (fNum[0] == -1)
        {
            continue;
        }

        for (int k = 0; k < last_F; k++)
        {
            switch (fNum[k])
            {
                case 1:
                    break;
                case 2:
                    spin(b);
                    spin(b);
                    spin(b);
                    break;
                case 3:
                    spin(b);
                    break;
                case 4:
                    spin(b);
                    spin(b);
                    break;
            }

            int c = 0;
            while (a[c] == b[c])
            {
                c++;
                if (c == 6)
                {
                    ans = true;
                    return ans;
                }
            }
        }

    }
    return ans;
}

int main()
{
    int n;
    cin >> n;
    int a[n][6];

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

    for (int i = 0; i < n - 1; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            if (judgeSame(a[i], a[j]))
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}



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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int n, m; cin >> n >> m;
    V<int> b(n + 1);
    for(int i = 0; i < m; i++){
        int x; cin >> x;
        b[x] = 1;
    }

    // 前からdp
    V<int> dp(n + 10);
    dp[0] = 1;
    for(int i = 0; i <= n - 1; i++){
        if(b[i]) continue;
        if(!b[i + 1]) (dp[i + 1] += dp[i]) %= mod;
        if(!b[i + 2]) (dp[i + 2] += dp[i]) %= mod;
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 4040
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<(n);++i)
#define int long long
#define double long double
using namespace std;
signed main() {
  int D,L;
  cin>>D>>L;
  int ans = D/L + D-(D/L)*L;
  cout << ans << endl;
}



Measured memory_bytes: 3112
h1,h2 = [int(i) for i in input().split()]
k1,k2 = [int(i) for i in input().split()]
a,b,c,d = [int(i) for i in input().split()]

p1 = a*h1 + c*(h1 // 10) + b*h2 + d*(h2 // 20)
p2 = a*k1 + c*(k1 // 10) + b*k2 + d*(k2 // 20)
if p1 > p2:
    print("hiroshi")
elif p1 < p2:
    print("kenjiro")
else:
    print("even")
    


Measured memory_bytes: 5604
a, v = map(int, input().split())
b, w = map(int, input().split())

t = int(input())

def solve(a, v, b, w, t):
    if a == b:
        return 'YES'
    if v < w:
        return 'NO'
    if (v-w) * t >= abs(a-b):
        return 'YES'
    else:
        return 'NO'

print(solve(a, v, b, w, t))

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

const int MAX = 1000010;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> num(MAX);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        num[A[i]]++;
    }

    for (int i = 1; i < MAX; i++) {
        if (num[i] == 0) continue;
        for (int j = i + i; j < MAX; j += i) num[j]++;
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (num[A[i]] == 1) ans++;
    }

    cout << ans << endl;
}

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

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

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

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

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

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

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;
const int mod=1000000007;
template<class T,class U>
void add(T& a,U b){
	a=((ll)a+b)%mod;
}

template<class T,class U>
void sub(T& a,U b){
	a=((ll)a-b%mod+mod)%mod;
}

template<class T,class U>
void mult(T& a,U b){
	a=((ll)a*b)%mod;
}

ll modPow(ll a,ll p){
	ll s=1;
	REP(i,30){
		if((p>>i)&1)
			mult(s,a);
		mult(a,a);
	}
	return s;
}

ll modInv(ll a){
	return modPow(a,mod-2);
}

struct Takahashi{
	int x,v,l,r;
	void Input(){
		x=read(),v=read();
	}
};

signed main(){
	int n=read();
	vector<Takahashi> t(n);
	REP(i,n)t[i].Input();
	sort(ALL(t),[&](Takahashi a,Takahashi b){
		return a.v<b.v;
	});
	REP(i,n)t[i].v=i;
	sort(ALL(t),[&](Takahashi a,Takahashi b){
		return a.x<b.x;
	});
	int l=n,r=-1;
	for(int i=n-1;i>=0;i--){
		chmin(l,t[i].v);
		t[i].l=l;
	}
	REP(i,n){
		chmax(r,t[i].v);
		t[i].r=r;
	}
	t.PB(Takahashi{0,0,n,n});
	queue<pi> cnt;
	cnt.push(pi(-1,1));
	int sum=1;
	for(auto w:t){
		while(!cnt.empty())
			if(cnt.front().first<w.l-1){
				sub(sum,cnt.front().second);
				cnt.pop();
			}else break;
		cnt.push(pi(w.r,sum));
		add(sum,sum);
	}
	while(1<int(cnt.size()))cnt.pop();
	cout<<cnt.front().second<<endl;
}

Measured memory_bytes: 14720
#include <iostream>
#include <cctype>
#include <cstdio>
using namespace std;

int main(){
    string s;
    cin >> s;
    
    int cnt = 0;

    for (int i = 0; i < 3; i++) 
        if (s[i] == '1') ++cnt;

    cout << cnt << endl;

}

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

int main()
{
    int n, m; cin>>n>>m;
    if (max(n, m)>min(n, m)+1) return cout<<0<<endl, 0;

    const int mod=1e9+7;
    long res=1+(n==m);
    for(int i=1; i<=n; ++i) res=res*i%mod;
    for(int i=1; i<=m; ++i) res=res*i%mod;
    cout<<res<<endl;
}

Measured memory_bytes: 384
#include <iostream>

#include <map>
#include <unordered_map>
#include <algorithm>
#include <vector>

using namespace std;
//const char a[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
// input - given string
// You need to update in the given string itself i.e. in input. No need to return or print.


void solver() {
    // Write your code here
    int n;
    cin>>n;

    int l;
    cin>>l;
    vector<string > my;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        my.push_back(s);
    }
    sort(my.begin(),my.end());
    for(int i=0;i<n;i++)
    {
        cout<<my[i];
    }

















}


int main() {
    int n=1;
    //cin>>n;
    while(n--)
    {
        solver();
    }
}


Measured memory_bytes: 3024
main(){
	int a,b,c,d,e;
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
	a*=e;
	if(c<e)b+=d*(e-c);
	if(a>b)a=b;
	printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 596
# "()"となっている部分は全て削除できる
# "("だけで構成されているものは、ポイントuP
# ")"だけで構成されているものは、ポイントDOWN(最後に使う)
# ")("で構成されているものは、")"より"("の方が多いものと少ないものと同じものに分ける
# ・")"より"("のほうが多いものを、")"の数が少ない順に使っていく
# ・")"と"("の数が同じものを使う
# ・")"より"("のほうが少ないものを、")"の数が多い順に使っていく

import sys
readline = sys.stdin.readline

N = int(readline())
opencnt = 0
closecnt = 0
open_close_up = []
open_close_equal = []
open_close_down = []
for i in range(N):
  s = readline().rstrip()
  while "()" in s:
    s = s.replace("()","")
  opn = s.count("(")
  clo = s.count(")")
  if opn == 0 and clo == 0:
    # 空文字になったので無視してよい
    continue
  if opn == 0:
    # 全てクローズの場合
    closecnt += clo
  elif clo == 0:
    # 全てオープンの場合
    opencnt += opn
  elif opn > clo: # ")(("のようなケース
    open_close_up.append([clo,opn])
  elif opn == clo:
    open_close_equal.append([clo,opn])
  elif opn < clo:
    open_close_down.append([clo,opn])

open_close_up = sorted(open_close_up,key = lambda x:x[0]) # closeの数が少ない順
open_close_down = sorted(open_close_down,key = lambda x:x[0],reverse = True) # 多い順
  
# まずオープンを全て使う
cur = opencnt

# オープンの数が増えるものを全て使う
for i in range(len(open_close_up)):
  clo,opn = open_close_up[i][0],open_close_up[i][1]
  if clo > cur:
    print("No")
    exit(0)
  cur -= clo
  cur += opn

# オープンの数が変わらないものを全て使う
for i in range(len(open_close_equal)):
  clo,opn = open_close_equal[i][0],open_close_equal[i][1]
  if clo > cur:
    print("No")
    exit(0)
    
for i in range(len(open_close_down)):
  clo,opn = open_close_down[i][0],open_close_down[i][1]
  if clo > cur:
    print("No")
    exit(0)
  cur -= clo
  cur += opn
  
if cur - closecnt == 0:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 26768
n,kk=map(int,input().split())
ss=input().split()
a=[int(ss[i]) for i in range(n)]
s=[0]*(n+1)
for i in range(n):
    s[i+1]=s[i]+a[i]
b=[None for i in range(n*(n+1)//2)]
k=0
for i in range(n):
    for j in range(i+1,n+1):
        b[k]=s[j]-s[i]
        k+=1
res=0
for i in range(50,-1,-1):
    m=2**i
    cnt=0
    for j in b:
        if j&m>0:
            cnt+=1
    if cnt>=kk:
        bb=[0 for j in range(cnt)]
        k=0
        for j in b:
            if j&m>0:
                bb[k]=j
                k+=1
        b=list(bb)
        res+=m
print(res)

Measured memory_bytes: 75376
#include <stdio.h>

int main(){
    int a,b;

    scanf("%d%d",&a,&b);

    char c[a];
    int ac[a];  

    int d[b],e[b];
    int f, g, h, i, j, k, l, n;

    scanf("%s" ,c);

    for(f = 0; f < b; f++){
        scanf("%d%d",&d[f], &e[f]);
    }
   
    n = 0;
    ac[0] = 0;

    for(f = 0; f < a - 1; f++){
        if(c[f] == 'A' && c[f+1] == 'C'){
           n++;
        }
        ac[f+1] = n;
    }

    for(f = 0; f < b; f++){
        l = 0;
        i = e[f] - 1;
        j = d[f] - 1;
        l = ac[i] - ac[j];
        printf("%d\n", l);
    }
    return 0;  
}


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

int main(){
    vector<string> s(3);
    bool flag = true;
    char card,kachi;
    int a, b, c;
    a = 0; b = 0; c = 0;
    cin >> s.at(0) >> s.at(1) >> s.at(2);
    card = 'a';
    while(flag){
        if (card == 'a') {
            //a++;
            if (a+1 <= s.at(0).size()){
                card = s.at(0).at(a);
            }
            else{
                cout << 'A';
                break;
            }
            a++;
        }
        else if (card == 'b') {
            //b++;
            if (b+1 <= s.at(1).size()){
                card = s.at(1).at(b);
            }
            else{
                cout << 'B';
                break;
            }
            b++;
        }
        else {
            //c++;
            if (c+1 <= s.at(2).size()){
                card = s.at(2).at(c);
            }
            else{
                cout << 'C';
                break;
            }
            c++;
        }
    }

    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,n) for(int i=0;i<n;++i)
#define rep(j,n) for(int j=0;j<n;++j)
#define REP(i,n) for(int i=1;i<=n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define len(s)   ((int)s.size())
#define F first
#define S second
#define pb push_back
#define pf push_front
#define mp make_pair
typedef long long ll;
typedef double db;
typedef vector<int> ve;
typedef vector<pair<int ,int> >vepa;
typedef set<char>se;
typedef map<ll,ll> mpp;
const ll N=1e5,OO=1e14;
const int di[]={1,-1,0,0};
const int dj[]={0,0,1,-1};
ll TC,n,k,a,b,c,cnt,ans,sum,mx,mn,arr[N];
bool f,vis[N];
int main(){
     IOS;
     cin>>n;
     double m;
     cin>>m;
     rep(i,n)
     {
         cin>>a>>b;
         double d=sqrt( (a*a)+(b*b) );
         if(d<=m)cnt++;
     }
     cout<<cnt;
go;
}


Measured memory_bytes: 3764