akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N,M;
  cin >> N >> M;
  vector<int> X(M);
  rep(i,M)
  {
    cin >> X[i];
  }
  sort(ALL(X)); 
  vector<int> dist(M-1);
  int sum = 0;
  if(N>=M)
  {
    cout << 0 << endl;
    return 0;
  }
  else
  {
    rep(i,M-1)
    {
      dist[i] = X[i+1] -X[i];
    }
    sort(ALL(dist));
    rep(i,M-N)
    {
      sum += dist[i];
    }
  }
  
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 4044
#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
using namespace std;


int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n; cin >> n; 
    vector<long long int> vec(n);
    for(int i=0;i<n;++i) cin >> vec[i];
    vector<long long int> pre(n);
    pre[0] = vec[0];
    for(int i=1;i<n;++i) pre[i] = (pre[i-1] + vec[i])%1000000007;
    long long int res = 0;
    for(int i=1;i<n;++i){
        res = ( res%1000000007 + ((long long int)vec[i]*pre[i-1])%1000000007 ) % 1000000007;
    }
    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 6372
#include <iostream>
#include <set>
#include<string>
#include<algorithm>
#define ll long long
using namespace std;

int main(){
    string a,b;
    cin>>a>>b;
    ll cnt=0;
    for(int i = 0;i<a.length();i++){
        if(a[i]!=b[i]) cnt++;
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 3916
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

template<typename T1, typename T2>
bool maximize(T1 &a, const T2 &b) {
    if (b > a) {
        a = b;
        return true;
    }

    return false;
}

struct prefix_max_fenwick_tree {
    int tree_n;
    vector<long long> tree;

    prefix_max_fenwick_tree(int n = 0) {
        if (n > 0)
            init(n);
    }

    void init(int n) {
        tree_n = n;
        tree.assign(tree_n + 1, 0);
    }

    // index is in [0, tree_n).
    void update(int index, long long value) {
        for (int i = index + 1; i <= tree_n; i += i & -i)
            maximize(tree[i], value);
    }

    // Returns the max of the range [0, count).
    long long query(int count) const {
        long long result = 0;

        for (int i = count; i > 0; i -= i & -i)
            maximize(result, tree[i]);

        return result;
    }
};


int N;
vector<int> H, A;

int main() {
    scanf("%d", &N);
    H.resize(N);
    A.resize(N);

    for (int &h : H)
        scanf("%d", &h);

    for (int &a : A)
        scanf("%d", &a);

    prefix_max_fenwick_tree tree(N);
    long long answer = 0;

    for (int i = 0; i < N; i++) {
        long long value = tree.query(H[i]) + A[i];
        maximize(answer, value);
        tree.update(H[i], value);
    }

    printf("%lld\n", answer);
}


Measured memory_bytes: 3328
using System;
using System.Linq;
using System.Collections.Generic;

namespace program
{
    class Program
    {
        static void Main()
        {
          int[] num = Input.ScanIntArray();
          int N=num[0],M=num[1];
          string[] A = new string[num[0]];
          string[] B = new string[num[1]];
          for(int i=0;i<num[0];i++)
            A[i] = Input.ScanStr();
          for(int i=0;i<num[1];i++)
            B[i] = Input.ScanStr();
          
          
          
          for(int i=0;i<=N-M;i++){
            for(int j=0;j<=N-M;j++){
              bool isSub = true;
              for(int k=0;k<M;k++){
                isSub &= A[k+j].Substring(i,num[1]) == B[k];
              }
              if(isSub){ Console.WriteLine("Yes"); return; }
            }
          }
            
          Console.WriteLine("No");
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n;
    map<int,int> mp;
    int a[n+1];
    int b[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i];
        b[i]=a[i]-i;
        mp[a[i]-i]++;
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        m=b[i]-(2*a[i]);
        if(mp.find(m)!=mp.end()){
            ans+=mp[m];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 13824
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

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

a = list(map(int, sys.stdin.readline().rstrip().split()))
b = list(map(int, sys.stdin.readline().rstrip().split()))
c = list(map(int, sys.stdin.readline().rstrip().split()))

# print(N)
# print(a)

manzoku = 0
prev = -1

for i in a:
  manzoku += b[i-1]
  if i == prev + 1:
    manzoku += c[prev-1]
  prev = i


print(manzoku)

Measured memory_bytes: 3064
n, m = [int(i) for i in input().split()]
g = [[] for i in range(n)]
for i in range(m):
    a, b = [int(_) for _ in input().split()]
    g[a-1].append(b-1)
    g[b-1].append(a-1)

u = 0
s = []
non_bridge = []
while True:
    if u in s:
        tmp = s[s.index(u):]
        tmp.append(u)

        if len(tmp)>=4:
            for i in range(len(tmp)-1):
                if sorted(tmp[i:i+2]) not in non_bridge:
                    non_bridge.append(sorted(tmp[i:i+2]))
        u = s.pop()
    elif len(g[u]) > 0:
        s.append(u)
        j = -1
        for i in range(len(g[u])):
            if g[u][i] not in s:
                j = i
        u = g[u].pop(j)
    else:
        if len(s) == 0:
            break
        u = s.pop()

print(m-len(non_bridge))


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-


def main():
    from collections import Counter
    ab = list()

    for i in range(3):
        ai, bi = map(int, input().split())
        ab.append(ai)
        ab.append(bi)

    ab_count = Counter(ab)

    for ab_val in ab_count.values():
        if ab_val == 3:
            print('NO')
            exit()

    print('YES')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
import java.util.Scanner;

//Spellcasters
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt(), S = sc.nextInt();
			if((n|S)==0)break;
			int[] r = new int[101];
			while(n--!=0)r[sc.nextInt()]++;
			int res = 0;
			for(int i=1;i<101;i++)for(int j=i;j<101;j++){
				if(S<i+j){
					if(i==j)res+=r[i]*(r[i]-1)/2;
					else res+=r[i]*r[j];
				}
			}
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int a;
	cin>>a;
	cout<<48-a<<endl;
}











Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define PI 3.14159265359
int main(){
    double  a,b,x;cin>>a>>b>>x;
    double y=0;
    double ans=0;
    if(x>(a*a*b)/2){
        y=(2/(a*a))*(a*a*b-x);
        ans=atan2((double)(y),( double)(a));
    }
    else{
        ans=atan2(( double)(a*b*b),( double)(2*x));
    }
    ans=ans*(360/(2*PI));
    (double)ans;
    printf("%.7lf",ans);
    return 0;
}

Measured memory_bytes: 256
import math

q=int(input())
N=[0]*(10**5+1)
N[3]=1
N[2]=1
S=[]

for i in range(5,10**5+1,2):
    flag=True
    for j in range(3,int(math.sqrt(i))+1,2):
        if i%j==0:
            flag=False
            break
    if flag:
        N[i]=1

X=[0]*(10**5+1)
X[2]=1
cnt=0
for i in range(3,10**5+1,2):
    if N[i]==1 and N[(i+1)//2]==1:
        cnt+=1
    X[i]=cnt
Q=[]
for i in range(q):
    l,r=map(int,input().split())
    print(X[r]-X[l-2])

Measured memory_bytes: 4980
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>

using namespace std;

int dp[16][2048] = {{-1}};		//	dp[ジャンル][売却総数]

int main (void){
	int have;		//持ってる数
	int sell;		//売る数
	int value[16][2048] = {0};
	int kindnum[16] = {0};

	int ValBuffer,KindBuffer;

	int SoldField[16][2048];	//SoldField[ジャンル][売却数]

	scanf("%d%d",&have,&sell);
	for(int i=0;i<have;i++){
		scanf("%d%d",&ValBuffer,&KindBuffer);
		value[KindBuffer][kindnum[KindBuffer]] = ValBuffer;
		kindnum[KindBuffer]++;
	}
	for(int i=1;i<=10;i++){
		sort(value[i],value[i]+kindnum[i]);
	}

	for(int i=1;i<=10;i++){
		SoldField[i][0] = 0;
		for(int j=1;j<=sell;j++){
			if(j<=kindnum[i]){
				SoldField[i][j] = SoldField[i][j-1] + value[i][kindnum[i]-j] + (j-1)*2;
			}else break;
		}
	}
	for(int i=0;i<=sell;i++){
		dp[1][i] = SoldField[1][i];
	}
	//puts("###DBG0");

	for(int i=1;i<=10;i++){		//ジャンル十種
		for(int j=0;j<=sell;j++){		//次の種類を売る冊数
			if(j>kindnum[i+1])break;
			for(int k=0;k<=sell;k++){		//売られた冊数<=sell
				if(k+j>sell)break;
				if(dp[i][k]!=-1){
					//printf("kind:%d all:%d next:%d\n",i,k,j);
					dp[i+1][k+j] = max(dp[i][k]+SoldField[i+1][j] , dp[i+1][k+j]);
				}
			}
		}
		//printf("kind = %d\n",i);
	}

	int ans = dp[10][sell];

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

	return 0;
}

Measured memory_bytes: 1484
#include<stdio.h>

int main()
{
  int s[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  
  scanf("%d",&k);
  
  printf("%d\n",s[k-1]);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    long long a,b;
    cin>>a>>b;
    cin>>s;
    for(int i=0;i<a;i++){
        if(s[i]=='-'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    if(s[a]!='-'){
        cout<<"No"<<endl;
        return 0;
    }
    for(int i=a+1;i<a+b+1;i++){
        if(s[i]=='-'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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



int main(){
	long long n;
	cin>>n;
	
	long long res=n-1;
	
	for (long long i=1; i<=sqrt(n); i++){
		if(n%i==0){
			res=min(res,(i-1)+(n/i-1));
		}
	}
	
	cout<<res<<endl;
	
}


Measured memory_bytes: 256
import itertools
N=int(input())
P=tuple([int(i)-1 for i in input().split()])
Q=tuple([int(i)-1 for i in input().split()])
SEQ=sorted(list(itertools.permutations(range(N),N)))
#print(SEQ)

a=-1
b=-1
for i in range(len(SEQ)):
    if SEQ[i]==P:
        a=i
    if SEQ[i]==Q:
        b=i
print(abs(a-b))

Measured memory_bytes: 45936
#define NDEBUG
NDEBUG


#include <algorithm>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <random>

#define FOR(i, n) for (int i = 0; i < (n); ++i)


using namespace std;

// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END


//TODO migrate iterators into iterator_utils


#include <deque>


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    /// caide keep
    template<int N>
    struct bytetype {
        
    };

    /// caide keep
    template<>
    struct bytetype<4> {
        
    };

    /// caide keep
    template<>
    struct bytetype<3> {
        
    };

    /// caide keep
    template<>
    struct bytetype<2> {
        
    };

    /// caide keep
    template<>
    struct bytetype<1> {
        
    };

    /// caide keep
    template<>
    struct bytetype<0> {
        
    };

    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}


vector<vector<int>> g;
int n;
vector<int> deg;

void solve(istream& in, ostream& out) {
    n = next<int>(in);
    int m = next<int>(in);
    deg.clear();
    deg.resize(n);
    g.clear();
    g.resize(n);
    while (m--) {
        int a = next<int>(in) - 1;
        int b = next<int>(in) - 1;
        g[a].push_back(b);
        g[b].push_back(a);
        ++deg[a];
        ++deg[b];
    }
    vector<int> v1;
    FOR(i, n) {
        if (deg[i] == 1) {
            v1.push_back(i);
        }
    }
    vector<int> u(n);
    deque<int> vs;
    if (v1.size() >= 1) {
        vs.push_back(v1[0]);
        u[v1[0]] = 1;
    } else {
        u[0] = 1;
        vs.push_back(0);
    }

    while (true) {
        bool done = true;
        int v = vs.front();
        for (int to : g[v]) if (!u[to]) {
            vs.push_front(to);
            u[to] = 1;
            done = false;
            break;
        }
        if (!done) continue;

        v = vs.back();
        for (int to : g[v]) if (!u[to]) {
            vs.push_back(to);
            u[to] = 1;
            done = false;
            break;
        }

        if (done) break;
    }

    vector<int> res;
    while (!vs.empty()) {
        res.push_back(vs.front());
        vs.pop_front();
    }
    out << res.size() << endl;
    for (int x : res) {
        out << x + 1 << ' ';
    }
    out << endl;
}


int main() {
    solve(cin, cout);
    return 0;
}



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

using Bigint = __int128;


Bigint Calc(long long n, long long a, long long b, long long c, long long d, map<long long, Bigint>& memoization) {
  if (n == 0) return 0;
  if (memoization.count(n)) return memoization[n];
  Bigint result = (Bigint) d * n;
  for (int i = -4; i <= 4; ++i) {
    if (n + i < 0) continue;
    if ((n + i) % 2 == 0 && (n + i) / 2 < n) result = min(result, Calc((n + i) / 2, a, b, c, d, memoization) + d * abs(i) + a);
    if ((n + i) % 3 == 0 && (n + i) / 3 < n) result = min(result, Calc((n + i) / 3, a, b, c, d, memoization) + d * abs(i) + b);
    if ((n + i) % 5 == 0 && (n + i) / 5 < n) result = min(result, Calc((n + i) / 5, a, b, c, d, memoization) + d * abs(i) + c);
  }

  return memoization[n] = result;
}

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

  int t;
  cin >> t;

  while (t--) {
    long long n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    map<long long, Bigint> memoization;
    cout << ((long long) Calc(n, a, b, c, d, memoization)) << '\n';
  }
}

Measured memory_bytes: 7204
import sys
import collections
# input処理を高速化する
input = sys.stdin.readline
def main():
    # 入力
    N, M = map(int, input().split())
    # 隣接関係は隣接リストで管理する
    lst_edge = [[] for _ in range(N)]
    # 各頂点の入力辺の本数
    deg = [0] * N
    for _ in range(M):
        x, y = map(int, input().split())
        # 最初のindexをゼロにする
        lst_edge[x-1].append(y-1)
        deg[y-1] += 1
    # 入力辺を持たない頂点をqueueに入れる
    que = collections.deque()
    for v in range(N):
        if deg[v] == 0:
            que.append(v)
    # 各頂点の最初に入力辺を持たなかった点からの距離
    dp = [0] * N
    # For sequences, (strings, lists, tuples), use the fact that empty sequences are false.
    # https://www.python.org/dev/peps/pep-0008/#programming-recommendations
    while que:
        v = que.popleft()
        lst_nv = lst_edge[v]
        for nv in lst_nv:
            # エッジ(v, nv)をグラフから削除する
            deg[nv] -= 1
            if deg[nv] == 0:
                # エッジがなくなったことで、入力辺がなくなったらqueueに入れる
                que.append(nv)
                # 最初に入力辺を持たなかった点からの距離
                dp[nv] = max(dp[nv], dp[v] + 1)
    print(max(dp))
main()

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

//#################################################################
//ユークリッドの互除法 O(log max(a, b))

namespace gcd{

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

lli extgcd(lli a, lli b, lli &x, lli &y){
	lli d = a;
	if(b != 0){
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}else{
		x = 1;
		y = 0;
	}
	return d;
}

}

lli mod_inverse(lli a, lli m){
	lli x, y;
	gcd::extgcd(a, m, x, y);
	return (m + x % m) % m;
}

//a_i * x = b_i (mod m_i) (1 <= i <= n)を解く
pair<lli, lli> linear_congruence(const vector<lli> &A, const vector<lli> &B, const vector<lli> &M){
	lli x = 0, m = 1;
	for(lli i=0;i<A.size();i++){
		lli a = A[i] * m, b = B[i] - A[i] * x, d = gcd::gcd(M[i], a);
		if(b % d != 0) return make_pair(0, -1); //解がない
		lli t = b / d * mod_inverse(a / d, M[i] / d) % (M[i] / d);
		x = x + m * t;
		m *= M[i] / d;
	}
	return make_pair(x % m, m);
}

int main() {
  lli N, M, D;
  cin >> N >> M >> D;
  vector<lli> A(M);
  for(lli j = 0; j < M; ++j) {
    cin >> A[j];
  }
  bool flag = false;
  for(lli i = 0; i < D; ++i) {
    vector<lli> R(M);
    vector<lli> b, m;
    for(lli j = 0; j < M; ++j) {
      cin >> R[j];
      if(R[j] != -1) {
	b.push_back(R[j]);
	m.push_back(A[j]);
      }
    }
    if(flag) continue;
    pair<lli,lli> p = linear_congruence(vector<lli>(b.size(), 1), b, m);
    if(p.second == -1) {
      flag = true;
      continue;
    }
    lli k = (N - p.first) / p.second;
    while(p.first + p.second * k <= N) ++k;
    --k;
    N = p.first + p.second * k;
  }
  if(flag) N = -1;
  cout << N << endl;
  return 0;
}

Measured memory_bytes: 1216
def main():
    N = int(input())
    A = [0] + list(map(int, input().split()))

    for i in range(N//2, 0, -1):
        sum_m = sum([A[i*j] for j in range(2, N//i+1)])
        if A[i] == 0:
            if sum_m % 2 == 1:
                A[i] = 1
        else:
            if sum_m % 2 == 1:
                A[i] = 0

    sum_b = sum(A)
    print(sum_b)
    if sum_b:
        ans = [i for i, v in enumerate(A) if v == 1]
        print(*ans, sep='\n')


if __name__ == "__main__":
    main()

Measured memory_bytes: 90972
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long N = in.nextLong();
		long ans = 0;
		long num = 5;
		if (N % 2 == 1) {
			System.out.println(0);
			return;
		}
		while (num <= 1844674407370955161l && (num * 2) <= N) {
			long d = num * 2;
			ans += N / d;
			num *= 5;
		}
		System.out.println(ans);
		in.close();
	}
}

Measured memory_bytes: 22612
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include<string>
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl
typedef long long ll;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
 
using namespace std;

int main(){
    int n, x, t, ans;    cin >> n >> x >> t;
    ans = ((n-1)/x+1)*t;
    print(ans);
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int N; 
string S;
int ans = 0;
void dfs(vector<int> &A) {
  // 終了条件
  if(A.size() == 3) {
    int flag = 0;
    REP(i, N) {
      if(char_to_int(S[i]) == A[flag]) flag++;
      if(flag == 3) {
        ans++;
        break;
      }
    }
    return;
  }

  // 再帰処理
  for(int i = 0; i <= 9; ++i) {
    A.push_back(i);
    dfs(A);
    A.pop_back();
  }
}

int main() {
  cin >> N >> S;
  vector<int> A;
  dfs(A);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>



int main()
{
	int a, b, d, r;
	double f;
	scanf("%d %d", &a, &b);
	d = a / b;
	r = a % b;
	f = (double) a / b;
	printf("%d %d %.5lf", d, r, f);
	return 0;
}



Measured memory_bytes: 2104
#include<stdio.h>
int main(){
  int n,k,i;
  scanf("%d%d",&n,&k);
  char s[n+1];
  scanf("%s",s);
  for(i=0;i<n;i++)
    if(i+1==k)
      printf("%c",s[i]+32);
    else
      printf("%c",s[i]);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define speed ios::sync_with_stdio(false)
#define pb push_back
#define mp make_pair
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define all(x) (x).begin(), (x).end()
#define uint usigned int
typedef vector <pair<char , ll>> vi;
ll MOD = 1e9+7;
//vi v1[200005],v2;
//bool visit[200005]={false};
/*void bfs(ll n){
    queue<ll> q;
    q.push(n);
    visit[n]=true;
    while(!q.empty()){
        ll t=q.front();
        q.pop();
        v2.pb(t);
        for(ll i=0;i<v1[t].size();i++){
            if(visit[v1[t][i]]==false){
                q.push(v1[t][i]);
                visit[v1[t][i]]=true;
            }
        }
    }
}*/
/*void dfs(ll n){
    for(ll i=0;i<v1[n].size();i++)
    {
        ll y=v1[n][i];
        if(visit[y]==0)
        {
            v2.pb(y);
            visit[y]=1;
            dfs(y);
        }
    }
}*/

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
    ll n,i,g,b,r,j,k,ans=0,c=0,error=0;
    cin>>r>>g>>b>>n;
    if(r==1 && g==1 && b==1){
        cout<<((n+2)*(n+1))/2;
        return 0;
    }
    if(r==1 && g==1 && b!=1){
        j=1;c=0;
        for(i=0;i<=n;i++){
            ans+=j;
            c++;
            if(c==b){
                c=0;
                j++;
            }
        }
        cout<<ans;
        return 0;
    }
    if(r!=1 && g==1 && b==1){
         j=1;c=0;
        for(i=0;i<=n;i++){
            ans+=j;
            c++;
            if(c==r){
                c=0;
                j++;
            }
        }
        cout<<ans;
        return 0;
    }
    if(r==1 && g!=1 && b==1){
         j=1;c=0;
        for(i=0;i<=n;i++){
            ans+=j;
            c++;
            if(c==g){
                c=0;
                j++;
            }
        }
        cout<<ans;
        return 0;
    }
    for(i=0;i<=n;i++){
        for(j=0;j<=n;j++){
            for(k=0;k<=n;k++){
            if(r*i+g*j+b*k==n) ans++;
            if(r*i+g*j+b*k>n) break;}
            if(r*i+g*j>n) break;
        }
        if(r*i>n) break;
    }
    cout<<ans;
    return 0; 
}



Measured memory_bytes: 256
from collections import deque

s = input()
q = int(input())
Q = [input() for _ in range(q)]

s = deque(list(s))
insert = s.appendleft
append = s.append
flag = True

for query in Q:
    if query[0] == '1':
        flag = not flag
    else:
        if (query[2] == '1' and flag) or (query[2] == '2' and not flag):
            insert(query[4])
        else:
            append(query[4])

if not flag:
    s.reverse()

print(*s, sep='')


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

#define pb push_back
#define F first
#define S second
#define int long long
#define lint long long
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define SET(x, val) memset(x, val, sizeof(x))
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 2e5 + 5, MOD1 = 1e9 + 7, MOD2 = 998244353;
const lint INF = 1e18;

string s;
signed main()
{
    cin >> s;
    cout << s.substr(0, 3LL);
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define maxn 100005
int a[maxn];char s[10];
int main(){
	int n,m,x,ans1=0,ans2=0;scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d%s",&x,s);
		if(a[x]==-1)continue;
		if(s[0]=='A')ans1++,ans2+=a[x],a[x]=-1;
		else a[x]++;
	}
	printf("%d %d\n",ans1,ans2);
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace AtCoder.ABC170
{
    public class Problem3
    {
        public static void Main(string[] args)
        {
            var a = Console.ReadLine().Split(" ");

            var X = int.Parse(a[0]);

            var N = int.Parse(a[1]);

            if (N == 0)
            {
                Console.WriteLine(X.ToString());
                return;
            }

            if (N == 100)
            {
                if (X <= 50)
                {
                    Console.WriteLine("0");
                }
                else
                {
                    Console.WriteLine("101");
                }
                return;
            }

            var bs = Console.ReadLine().Split(" ");

            var ps = new List<int>();

            foreach(var b in bs)
            {
                ps.Add(int.Parse(b));
            }

            var os = new List<int>();
            
            for(var i = 0; i < 102; i++)
            {
                if (!ps.Contains(i))
                {
                    os.Add(i) ;
                }
            }

            var diffs = new List<List<int>>();

            foreach (var o in os.OrderBy(x => x))
            {
                var diff = Math.Abs(X - o);
                var index = os.IndexOf(o);
                var d = new List<int> { diff, index };
                diffs.Add(d);
            }

            var idx = diffs.OrderBy(x => x[0]).ThenBy(x => x[1]).FirstOrDefault()[1];

            var answer = os[idx];

            Console.WriteLine(answer.ToString());
        }
    }
}


Measured memory_bytes: 28356
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long d,ans=1,bin=1;
  cin>>d;
  if(d==1){
    cout<<1<<"\n";
  }else{
    while(ans<d){
      ans+=bin*2;
      bin*=2;
    }
    cout<<ans<<"\n";
  }
  return 0;
}


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

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  for (auto &h : H) {
    cin >> h;
  }
  sort(H.begin(), H.end());
  long long ans = 0;
  for (int i = 0; i < N - K; i++) {
    ans += H[i];
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


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

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

  sort(a,a+n);

  cout << a[n-1] - a[0] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
int main(){
    ll n,k;cin >> n >> k;
    map<ll,ll> mp;
    for(int i=0; i<n; i++){
        int a,b;cin >> a >> b;
        mp[a]+=b;
    }
    vector<l_l> ans;
    for(auto p: mp){
        ans.push_back({p.first,p.second});
    }
    sort(ans.begin(),ans.end());
    for(int i=0; i<n; i++){
        k-=ans[i].second;
        if(k<=0){
            cout << ans[i].first << endl;
            return 0;
        }
    }
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  int ans=INT_MAX;
  for(int i=-100;i<=100;i++){
    int res=0;
    for(int j=0;j<N;j++){
      res+=(i-A[j])*(i-A[j]);
    }
    ans=min(ans,res);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 810114514
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define int long long 

signed main(){
    int a,b;
    cin >> a >> b;
    cout << a-1 + (b>=a) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














string T;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> T;
	fore(c, T) if (c == '?') c = 'D';
	cout << T << endl;
}







Measured memory_bytes: 3740
d = {}
m = [[False]*3 for _ in range(3)]
for i in range(3):
  for j, val in enumerate(list(map(int,input().split()))):
    d[val] = (i,j)
    
N = int(input())

for _ in range(N):
  key = int(input())
  if key in d:
    i,j = d[key]
    m[i][j] = True
  
def main():
  if m[0][0] and m[1][1] and m[2][2]:
    return True
  if m[0][2] and m[1][1] and m[2][0]:
    return True
  for i in range(3):
    if m[i][0] and m[i][1] and m[i][2]:
      return True
    if m[0][i] and m[1][i] and m[2][i]:
      return True
      
  return False

ans = main()
if ans:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9256
//ll f(ll n, ll k){
//    while(n%k != 0){
//        ll take = n/k+1;
//        ll can_take = max(1ll,n%k/take);
//        n -= can_take*take;
//    }
//    return n/k;
//}
//void __(){
//    _(int,n);
//    _(vpii,a,n);
//    ll ans = 0;
//    rep(i,n)
//        ans ^= f(a[i].X,a[i].Y);
//    if(ans == 0)
//        print "Aoki";
//    else
//        print "Takahashi";
//}
//
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define REP_ZERO_INT(i,r) for(int i = 0; i < r; ++i)
#define GET_REP_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define rep(...) GET_REP_MACRO(__VA_ARGS__,REP_ANY,REP_INT,REP_ZERO_INT)(__VA_ARGS__)
#define all(v) (v).begin(), (v).end()
#define sz(v) ll(v.size())
#define X first
#define Y second
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
template <typename F, typename S> static
istream& operator>>(istream& stream, pair<F, S>& t){
    return stream >> t.first >> t.second;
}
T1 istream& read(T, T, istream& = cin);
T1 istream& operator>>(istream& stream, vector<T>& t){
    return read(all(t), stream);
}
T1 istream& read(T b, T e, istream& stream){
    for(T it = b; it != e; ++it)
        stream >> *it;
    return stream;
}
struct _print {
    string sep,end;
    bool space;
    ostream &stream;
    _print(string _sep=" ",string _end="\n",
            ostream &_stream = cout)
        : sep(_sep),end(_end),space(false),
            stream(_stream) {}
    ~_print() { stream << end; }
    template <typename T>
        _print &operator , (const T &t) {
            if (space) stream << sep;
            space = true;
            stream << t;
            return *this;
        }
};
#define print _print(),
#define INPUT_WITHOUT_INIT(type,name) type name; cin >> name
#define _IWI(type,name,...) type name(__VA_ARGS__); cin >> name
#define GET_INPUT_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define _(...) GET_INPUT_MACRO(__VA_ARGS__,_IWI,_IWI,_IWI,_IWI,_IWI,_IWI,INPUT_WITHOUT_INIT)(__VA_ARGS__)
ll f(ll n, ll k){
    while(n%k != 0){
        ll take = n/k+1;
        ll can_take = max(1ll,n%k/take);
        n -= can_take*take;
    }
    return n/k;
}
void __(){
    _(int,n);
    _(vpii,a,n);
    ll ans = 0;
    rep(i,n)
        ans ^= f(a[i].X,a[i].Y);
    if(ans == 0)
        print "Aoki";
    else
        print "Takahashi";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        __();
}


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

int main(){
  string ans = "No";
  int a, b, c, k;  cin >> a >> b >> c >> k;

  for(int i=0; i<=k; i++){
    int cc = c;
    for(int j=0; j<i; j++)
      cc *= 2;
    int bb = b;
    for(int j=0; j<k-i; j++)
      bb *= 2;
    if(cc > bb && bb > a)  ans = "Yes";
  }



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


Measured memory_bytes: 3620
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n=r(1);r(2)(n.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var n=r(3),i=r(5);t.exports=function(t){var e=new n(t);i(e)}},function(t,e,r){"use strict";var n=r(4);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new n(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,r){"use strict";t.exports=function(t){var e=t.inr().split("/"),r=Number(e[0]),n=Number(e[1]);Number(e[2]),r<2019||2019==r&&n<=4?console.log("Heisei"):console.log("TBD")}}]);


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

int main(){
    int n;
    cin >> n;
    vector<vector<int>> a(2, vector<int>(n));
    rep(i,2) {
       rep(j,n) {
            cin >> a[i][j];
        }
    }

    int ans = 0;
    rep(i,n){
        int pick = 0;
        rep(j,i+1) {
            pick += a[0][j];
        }
        for (int j = i; j < n; ++j) {
            pick += a[1][j];
        }
        if (ans < pick) ans = pick;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

int main() {
    int n, p;
    cin >> n >> p;
    int x, y;
    x = y = 0;
    rep (i, n) {
        int tmp;
        cin >> tmp;
        if (tmp % 2 == 0) {
            x++;
        }
        else {
            y++;
        }
    }
    ll res = 0;
    if (p == 1) {
        if (y == 0) {
            cout << 0 << endl;
            exit(0);
        }
        ll prev = y;
        res = y;
        int idx = 3;
        while (idx <= y) {
            prev *= 1ll * (y - idx + 2) * (y - idx + 1);
            prev /= 1ll * (idx - 1) * idx;
            res += prev;
            idx += 2;
        }
    }
    else {
        ll prev = 1;
        int idx = 2;
        res = 1;
        while (idx <= y) {
            prev *= 1ll * (y - idx + 2) * (y - idx + 1);
            prev /= 1ll * (idx - 1) * idx;
            res += prev;
            idx += 2;
        }
    }
    cout << res * (1ll << x) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int INF = 1e9;

int main(){
  int N, M;
  cin >> M >> N;
  vector<int> P(M), C(N), E(N);
  for(int i = 0; i < M; ++i){
    cin >> P[i];
  }
  int C_sum = 0;
  for(int i = 0; i < N; ++i){
    cin >> C[i] >> E[i];
    C_sum += C[i];
  }
  vector<int> DP(C_sum + 1, INF);
  DP[0] = 0;
  for(int i = 0; i < N; ++i){
    vector<int> DP_ = DP;
    for(int j = 0; j <= C_sum - C[i]; ++j){
      if(DP[j] >= INF) continue;
      DP_[j + C[i]] = min(DP_[j + C[i]], DP[j] + E[i]);
    }
    DP = DP_;
  }
  for(int i = C_sum-1; i >= 0; --i) DP[i] = min(DP[i], DP[i+1]);
  sort(P.begin(), P.end(), greater<int>());
  int s = 0, ans = 0;
  for(int i = 0; i < min(M, C_sum); ++i){
    s += P[i];
    ans = max(ans, s - DP[i+1]);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 42072
/************************Code by Hardik Aggarwal!!!!***********************************/

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
ll dp[100001][2];
vl g[100001];
bool visited[100001];
void dfs(ll u)
{
    visited[u]=true;
    dp[u][0]=dp[u][1]=1;
    for(auto v:g[u])
    {
        if(!visited[v])
        {
            dfs(v);
            dp[u][0]*=dp[v][1];
            dp[u][1]*=(dp[v][1]+dp[v][0]);
            dp[u][0]%=mod;
            dp[u][1]%=mod;
        }
    }
}
int main()
{
       

    IOS
    ll n;
    cin>>n;

    memset(visited,0,sizeof(visited));
    for(ll i=0;i<n-1;i++)
    {
        ll u,v;
        cin>>u>>v;
        u--;v--;
        g[u].pb(v);
        g[v].pb(u);
    }  

    dfs(0);

    ll ans=(dp[0][0]+dp[0][1])%mod;
    cout<<ans<<endl;

    

    
}
    
 
    
    



Measured memory_bytes: 11520
#include <stdio.h>
int main(void){
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++){
    if(i%3==0||i%10==3){
    printf(" %d",i);
    }
    else{
       for(int x=i/10;x;x/=10){
           if(x%10==3){
               printf(" %d",i);
               break;
           }
       } 
    
    }
}
printf("\n");
return 0;
}

Measured memory_bytes: 2752
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	m = 0
	while m*(m+1)>>1<n
		m += 1
	end
	for i in 1:m
		if i!=m*(m+1)>>1-n
			println(i)
		end
	end
end

main()

Measured memory_bytes: 109508
#include<stdio.h>

int main()
{
    int N,L[100];
    int max = 0;
    int sum = 0;

    scanf("%d", &N);

    for(int i = 0; i < N; i++)
    {
        scanf("%d ", &L[i]);

        sum += L[i];

        if(max < L[i])
        {
            max = L[i];
        }
    }

    if(max < (sum-max))
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");        
    }
    
    return 0;
}


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }

// DEGUG
template <class T>
void _dump(const char *s, T&& x) {
    clog << '{';
    while(*s != '\0') clog << *(s++);
    clog << ": " << x << '}' << "\n";
}
 
template <class Head, class... Tail>
void _dump(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  _dump(s, forward<Tail>(tail)...);
}
// }}} End

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

  VAR(int, N);

  vector<int> cnt(int(1e5)+10);
  rep(i, N) {
    VAR(int, a);
    cnt[a]++;
  }

  i64 maxv = 0;
  reps(i, 1, int(1e5)) {
    chmax(maxv, cnt[i-1] + cnt[i] + cnt[i+1]);
  }

  OUTL(maxv);

  return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
const int MaxN = 100;
char s[MaxN + 5];
char t[MaxN + 5];

int main()
{
	int flag;
	scanf("%s", s);
	scanf("%s", t);
	int lens = strlen(s);
	int lent = strlen(t);
	if(lens > lent) flag = 1;
	else if(lens < lent) flag = 0;
	else if(strcmp(s, t) > 0) flag = 1;
	else if(strcmp(s, t) < 0) flag = 0;
	else flag = -1;
	if(flag == 1) printf("GREATER\n");
	if(flag == 0) printf("LESS\n");
	if(flag == -1) printf("EQUAL\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD =  1000000007;

     signed main(){
       int n;
       cin>>n;
       int ans[n]={},a;
       for(int i=0;i<n-1;i++){
            cin>>a;a--;
            ans[a]++;
       }
       for(int i=0;i<n;i++)cout<<ans[i]<<endl;



      }

        


Measured memory_bytes: 5200
def nlog(n):
    for i in range(200):
        if n<10**i:
            return i-1
n=int(input())
k=int(input())

ns=nlog(n)
n1=n//10**int(ns)
#print(ns,n1,n1*10**ns)

if k==1:
    icnt=0
    for i in range(0,ns+1):
        for i1 in range(1,10):
            x=i1*10**i
            if x<=n:
                icnt=icnt+1
    print(icnt)
elif k==2:
    icnt=0
    for i in range(0,ns):
        for j in range(i+1,ns+1):
            for i1 in range(1,10):
                for j1 in range(1,10):
                    x=i1*10**i+j1*10**j
                    if x<=n:
                        icnt=icnt+1
    print(icnt)
elif k==3 and n<=122:
    icnt=0
    print(icnt)
elif k==3 and n>=123:
    icnt=0
    for i in range(0,ns):
        for j in range(i+1,ns+1):
            for i1 in range(1,10):
                for j1 in range(1,10):
                    x=n1*10**ns+i1*10**i+j1*10**j
                    if x<=n:
                        icnt=icnt+1

    icnt=icnt+int((n1-1)*ns*(ns-1)/2*9*9)
    icnt=icnt+int(ns*(ns-1)*(ns-2)/6*9*9*9)

    print(icnt)

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    string s;
    cin >> s;
    int n = s.length();
    if (n&1) {
        cout << "No" << endl;
        return 0;
    }
    bool ans = true;
    for (int i = 0; i < n-1; i += 2) {
        ans &= (s[i] == 'h' && s[i+1] == 'i');
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256