akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <random>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0)
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n, k;
lli a[100001], s[100001], t[100001];

template<class T>
lli subsum(const T& s, lli b, lli e) {
  return s[e] - s[b];
}

int main() {
  cin >> n >> k; read_n(a, n);
  lli sum = 0;
  for (lli i=1; i<=n; ++i) {
    s[i] = s[i-1] + min(0ll, a[i-1]);
    t[i] = t[i-1] + max(0ll, a[i-1]);
    sum += max(0ll, a[i-1]);
  }

  lli ans = 0;
  for (lli i=0; i<=n-k; ++i) {
    lli ss = subsum(s, i, i+k), ts = subsum(t, i, i+k);
    ans = max(ans, max(sum + ss, sum - ts));
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> qua;
typedef vector<qua> vec;
const double epx=1e-7;
namespace std
{
    bool operator < (const qua &a,const qua &b)
    {
        return (a.imag()==b.imag()?a.real()<b.real():a.imag()<b.imag());
    }
}
int ccw(qua a,qua b,qua c)
{
    b-=a,c-=a,a=c*conj(b);
    if(a.imag()>epx) return 1;
    if(a.imag()<-epx) return -1;
    if(a.real()<-epx) return 2;
    if(abs(b)+epx<abs(c)) return -2;
    return 0;
}
vec judge_convex(vec &v)
{
    int n=v.size(),c=0;
    vec r(n);
    for(int i=0; i<n; i++)
    {
        while(2<=c&&ccw(r[c-2],r[c-1],v[i])==-1) c--;
        r[c++] = v[i];
    }
    vec res(c);
    for(int i=0; i<c; i++) res[i]=r[i];
    return res;
}
vec calc_convex(vec &v)
{
    sort(v.begin(),v.end());
    vec u=judge_convex(v);
    reverse(v.begin(),v.end());
    vec l=judge_convex(v);
    for(int i=1; i+1<l.size(); i++) u.push_back(l[i]);
    return u;
}
int main()
{
//	freopen("in.txt","r",stdin);
//	freopen("out.txt","w",stdout);
    int n;
    double x,y;
    vec v;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%lf%lf",&x,&y);
        v.push_back(qua(x,y));
    }
    vec ans=calc_convex(v);
    printf("%d\n",ans.size());
    for(int i=0;i<ans.size();i++)
    {
        printf("%d %d\n",(int)ans[i].real(),(int)ans[i].imag());
    }
    return 0;
}



Measured memory_bytes: 7840
// @Author :- Gaurav Bharti
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define empb emplace_back
#define mp make_pair
#define F first
#define S second
#define vii vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define mapii map<int,int> 
#define mapll map<ll,ll>
#define lcm(a,b) a*b/(__gcd(a,b))
#define all(a) a.begin(),a.end()
#define test int t; cin>>t; while(t--)
#define prec(n) fixed<<setprecision(n)
#define ItsFUN ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007


 
int main() {
	ItsFUN;

	string s = "ACL";
	int k ; cin >> k;
	for(int i = 1; i <= k ;++i) cout << s ;
		cout << "\n";
	

	return 0 ;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef pair<int,int> P;

int main(){
	for(int i = 1; i < 10; i++){
		for(int j = 1; j < 10; j++){
			cout << i << "x" << j << "=" << i*j << endl;
		}
	}
}

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int i,n,k;
    LL x,ans=0;
    V<LL>v;
    cin >> n >> k;
    while(n--)
    {
        cin >> x;
        v.PSB(x);
        ans+=x;
    }
    sort(v.B,v.E);
    while(!v.EM  &&  k--)
    {
        ans-=v.back();
        v.PPB;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 2420
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        X: i32,
    }
    let mut ans = 0;
    for i in X..(10 as i32).pow(5)+5 {
        if is_prime(i) {
            ans = i;
            break;
        }
    }
    println!("{}", ans);
}

fn is_prime(x: i32) -> bool {
    for i in 2..((x as f64).sqrt() as i32) {
        if x % i == 0 {
            return false
        }
    }
    true
}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N;
    cin >> N;
    ll t,a;
    t = a = 0;
    rep(i,N) {
        ll T,A;
        cin >> T >> A;
        if (t<=T && a<=A) t=T, a=A;
        else {
            ll tt,at;
            tt = t/T;
            at = a/A;
            ll time = max(tt,at);
            ll tn = T*time;
            ll an = A*time;
            //cout << endl;
            //cout << tn << " " << an << endl;
            //cout << t << " " << a << endl;
            if (an<a || tn<t) an+=A, tn+=T;
            a = an, t = tn;
            //cout << endl;
            //cout << t << " " << a << " " << T << " " << A << " " << endl;
        }
        //cout << t << " " << a << endl;
    }
    ll ans = t + a;
    cout << ans << endl;
}


Measured memory_bytes: 3524
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>
   
using namespace std;

#define mod 1000000007

int main()
{
    int n, q;
    cin >> n >> q;
    long long int a[100001];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < q; i++){
        long long int x;
        cin >> x;
        int tail = 0;
        long long int nowsum = 0, ans = 0;
        for(int head = 0; head < n; head++){
            nowsum += a[head];
            while(nowsum > x && tail <= head){
                nowsum -= a[tail];
                tail++;
            }
            ans += head - tail + 1;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3872
# https://maspypy.com/atcoder-%E5%8F%82%E5%8A%A0%E6%84%9F%E6%83%B3-2019-02-16abc-155
import numpy as np

N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))
A.sort()
G = A[A > 0]
Z = A[A == 0]
L = A[A < 0]

ok = 10 ** 18 + 1
ng = -10 ** 18 - 1

# x以下がK個以上であるxの最小値

while ok - ng > 1:
    mid = (ng + ok) // 2
    # mid以下のペアの個数を数える

    # 正のもののうち、mid以下のペアの個数を数える
    cg = np.searchsorted(A, mid // G, side="right").sum()

    # 負のもののうちmid以下のペアの個数を数える
    cl = (N - np.searchsorted(A, (mid + 1) // L, side="right")).sum()

    # 同じ数字同士の積がmid以下のものを数える
    d = np.count_nonzero(A * A <= mid)

    # 0がmid以下なら、それもプラスするために必要
    z = 0
    if mid >= 0:
        z += len(Z) * N

    c = cg + cl + z - d

    # 二重になっているので、割る
    c //= 2

    # mid以下のペアの個数がK個以上のとき
    if c >= K:
        ok = mid
    else:
        ng = mid

print(ok)


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

const int MAX = 510000;
const long long MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long ruiseki[100005];
long long A[100005];

int main(void) {
    COMinit();
    int N; cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];
    
    long long ans = 0;
    for (int i = 1; i <= N; i++) {
        ruiseki[i] = (fac[N] * inv[i]) % MOD + ruiseki[i-1];
        ruiseki[i] %= MOD;
    }
    
    for (int i = 0; i < N; i++) {
        ans += A[i] * ruiseki[N - i] % MOD;
        ans %= MOD;
        ans += A[i] * (ruiseki[i+1] - ruiseki[1] + MOD) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 13824
package main

import (
        "fmt"
        "strings"
)

func solution(h, w int, s [][]string) string {
        for i := 0; i < h; i++ {
                for j := 0; j < w; j++ {
                        if s[i][j] == "#" {
                                if i > 0 && s[i-1][j] == "#" {
                                        continue
                                }
                                if i < h-1 && s[i+1][j] == "#" {
                                        continue
                                }
                                if j > 0 && s[i][j-1] == "#" {
                                        continue
                                }
                                if j < w-1 && s[i][j+1] == "#" {
                                        continue
                                }
                                return "No"
                        }
                }
        }
        return "Yes"
}

func main() {
        var h, w int
        fmt.Scan(&h, &w)
        s := make([][]string, h)
        for i := range s {
                var t string
                fmt.Scan(&t)
                s[i] = strings.Split(t, "")
        }
        fmt.Println(solution(h, w, s))
}

Measured memory_bytes: 1892
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define in2(N,s,t) rep(i,N){in(s[i] , t[i]);}
#define in3(N,s,t,u) rep(i,N){in(s[i] , t[i] , u[i]);}
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vs = V<string>;
using vd = V<double>; using vvi = V< V<int> >; using vvl = V< V<> >;
template<typename T>using heap = priority_queue< T , V<T> , greater<T> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

using P = pair<ll,ll>; using vp = V<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
//////////////////

ll dp[1024][20100];

void solve(){
  ini(H , N);
  vp v(N); in(v);
  rep(i,N + 1) rep(j , H + 1) dp[i][j] = infLL;
  dp[0][H] = 0;
  ll ans = infLL;
  rep(i , N) repr(j , H + 1){
    if(dp[i][j] == infLL) continue;
    amin(dp[i + 1][j] , dp[i][j]);
    if(j <= v[i].fi) amin(ans , v[i].se + dp[i][j]);
    else amin(dp[i][j - v[i].fi] , dp[i][j] + v[i].se);
  }
  out(ans);

}

Measured memory_bytes: 156928
using System;

class _0053 {
    public static void Main() {
        int k = 0, n, sum;
        bool[] e = new bool[104730];
        int[] p = new int[10000];
        e[0] = e[1] = false;
        for (int i = 2; i < 104730; i++) e[i] = true;
        for (int i = 2; i < 104730; i++)
            if (e[i])
                for (int j = 2; i * j < 104730; j++)
                    e[i * j] = false;
        for (int i = 0; i < 104730; i++)
            if (e[i]) p[k++] = i;
        while ((n = int.Parse(Console.ReadLine())) != 0) {
            sum = 0;
            for (int i = 0; i < n; i++)
                sum += p[i];
            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 9300
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
// define
#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()
// typedef
typedef long long lint;
typedef double Double;
typedef pair<int, int> pii;
//
typedef vector< int > Array;
typedef vector< Array > Matrix;
typedef vector< Double > DArray;
typedef vector< DArray > DMatrix;
typedef vector< string > SArray;
typedef vector< pii > PArray;
// popcount
inline int POPCNT(int _x) { return __builtin_popcount(_x); }
inline int POPCNT(lint _x) { return __builtin_popcountll(_x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
Double EPS = 1e-9;
// in range
inline bool in_range(int _v, int _mx, int _mi) { return _mi <= _v && _v < _mx; }
inline bool in_range(Double _v, Double _mi, Double _mx) { return -EPS < _v - _mi && _v - _mx < EPS; }
inline bool in_range(int _x, int _y, int _W, int _H) { return 0 <= _x && _x < _W && 0 <= _y && _y < _H; }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};

struct Edge {
	int t, cost, type;
	Edge(int _t, int _c, int _type) : t(_t), cost(_c), type(_type) {}
};

bool operator > (const Edge& a, const Edge& b) {
	return a.cost > b.cost;
}

int n, m, s, g1, g2;
int cost[110][110];

void solve() {
	for_(i,0,n) fill(cost[i], cost[i] + n, iINF / 2);
	
	for_(i,0,n) cost[i][i] = 0;
	
	for_(i,0,m) {
		int v, u, c; cin >> v >> u >> c;
		--v; --u;
		cost[v][u] = c;
	}
	
	for_(k,0,n) for_(i,0,n) for_(j,0,n) cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
	
	int ans = iINF;
	for_(k,0,n) ans = min(ans, cost[s][k] + cost[k][g1] + cost[k][g2]);
	cout << ans << endl;
}

int main() {
	while (cin >> n >> m >> s >> g1 >> g2, n) {
		--s; --g1; --g2;
		solve();
	}
	return 0;
}

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

int main()
{
  char ch;
  cin>>ch;
  
  if(ch >= 'A' && ch<= 'Z')
  {
    cout<<"A"<<endl;
  }
  else if(ch >= 'a' && ch <= 'z')
  {
    cout<<"a"<<endl;
  }
}

Measured memory_bytes: 3540
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define R register
using namespace std;
namespace chu_xuan{
    void swap(int &a,int &b){R int tmp=a;a=b,b=tmp;}
    void read(int &a) {a=0;int b=1,c=getchar(); while(c>'9'||c<'0'){if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();a*=b;}
    int In() {int a=0,b=1,c=getchar(); while(c>'9'||c<'0'){if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();return a*b;}
    int max(int a,int b){return a>b?a:b;}
    int min(int a,int b){return a>b?b:a;}
}using namespace chu_xuan;

int n,m,cnt[35],k,x,ans;

int main()
{
    read(n);read(m);
    for(int i=1;i<=n;i++)
    {
    	read(k);
    	while(k--)
    	{
    		read(x);
    		++cnt[x];
    	}
    }
    for(int i=1;i<=m;i++) if(cnt[i]==n) ans++;
    cout<<ans;
    return 0;
}

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

int main() {
  int N,K,A,B,C;
  cin>>N>>K;
  C=1;
  for (int i = 0; i < N; i++) {
    A=C*2;//Aはi=1の時1×2=2、i=2の時2×2=4
    B=C+K;
    if(A<B){
      C=A;
    }
    else if(A>=B){
      C=B;
    }
  }
cout<<C<<endl;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
    ll x, k, d;
    cin >> x >> k >> d;
    ll c = min(abs(x) / d, k-1);
    if(c % 2 != k % 2) c++;
    ll ans;
    if(x >= 0)
        ans = x - c*d;
    else
        ans = x + c*d;
    cout << abs(ans) << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=1e5+10;

ll n;
ll ar[N];
ll dp[N];

ll func(ll i)
{
    if(i==n){return(INT_MAX);}
    if(i==n-1){return(0);}
    if(dp[i]==-1)
    {
        dp[i]=min(func(i+1)+abs(ar[i]-ar[i+1]),func(i+2)+abs(ar[i]-ar[i+2]));
    }
    return(dp[i]);
}

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

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	cin>>n;
	for(ll i=0;i<n;++i)
    {
        cin>>ar[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<func(0);

	return(0);
}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {
	 public static void main(String[] args){
	        Scanner scan = new Scanner(System.in);
	        String s = scan.nextLine();
	        String t = scan.nextLine();
	        scan.close();

	        int count = 0;
	        int ans = 0;

	        for(int i=0;i<s.length()-t.length()+1;i++) {
	        	for(int j=0;j<t.length();j++) {
	        		if(s.charAt(i+j) == t.charAt(j)) {
	        			count++;
	        		}
	        	}
	        	ans = Math.max(ans,count);
        		count = 0;
	        }
	        System.out.println(t.length()-ans);
	    }
}



Measured memory_bytes: 35748
#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
double EPS=1e-10;
struct P{
	double x,y;
	P(){};
	P(double x,double y):x(x),y(y){};
	double add(double a,double b){if(abs(a+b)<EPS*(abs(a)+abs(b)))return 0;return a+b;}
	P operator +(P p){return P(add(x,p.x),add(y,p.y));}
	P operator -(P p){return P(add(x,-p.x),add(y,-p.y));}
	double dot(P p){return add(x*p.x,y*p.y);}
	double det(P p){return add(x*p.y,-y*p.x);}
};

P pos[105];

bool cmp_p(const P &p,const P&q)
{
	if(p.x!=q.x)return p.x<q.x;
	return p.y<q.y;
}

vector<P> convex_hull(P *ps,int n)
{
	sort(ps,ps+n,cmp_p);
	int k=0;
	vector<P> qs(n*n);
	for(int i=0;i<n;i++)
	{
		for(;k>1&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0;)k--;
		qs[k++]=ps[i];
	}
	for(int i=n-2,t=k;i>=0;i--)
	{
		for(;k>t&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0;)k--;
		qs[k++]=ps[i];
	}
	qs.resize(k-1);
	return qs;
}

int main()
{
	int N;
	for(;scanf("%d",&N),N;)
	{
		memset(pos,0,sizeof(pos));
		for(int i=0;i<N;i++)
			scanf("%lf,%lf",&pos[i].x,&pos[i].y);
		printf("%d\n",N-convex_hull(pos,N).size());
	}
}

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

void sort(int *,int *);

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a>b) sort(&a,&b);
	if(a>c) sort(&a,&c);
	if(b>c) sort(&b,&c);
	cout << a <<" " << b << " " << c << endl;
}

void sort(int *a,int *b){
	int w;
	w=*a;
	*a=*b;
	*b=w;
}

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

    using namespace std;
     
    int main() {
      
      int A, B, K;
      cin >> A >> B >> K;
      
      list<int> cd;
      list<int>::iterator itr;
      
      for (int i = 1; i < 101 ; i++){
        if ( A % i == 0 && B % i == 0){
          cd.push_front(i);
        }
      }
      
      itr = cd.begin();
      for (int i = 0; i < K-1 ; i++)
        itr++;
      cout << *itr << endl;
      
      
    }

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
//l={1,2,3,4}
//greater<int>()
//sort(l,l+n)

int main(void)
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ac = c - a;
	int ab = b - a;
	int bc = c - b;
	if (ac < 0)
		ac *= -1;
	if (ab < 0)
		ab *= -1;
	if (bc < 0)
		bc *= -1;

	if (ac <= d)
		cout << "Yes" << endl;
	else if (ab <= d&&bc <= d)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		int c = s.nextInt();
		
		if(a<b && b<c){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

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

int main() {
  int N,X;
  cin>>N>>X;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  int b=0;
  for(int i=0;i<N;i++){
    b=a.at(i)+b;
    if(b>X){
      cout<<i<< endl;
      return 0;
    }
  }
  if(b<X){
    cout<<N-1<< endl;
    return 0;
  }
  
  cout<<N<< endl;
}



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

int main() {
  int N ,A ,B;
  cin >> N >> A >> B;
  
  if ( N*A > B) {
    cout << B << endl;
  }
  else if ( N*A == B) {
    cout << B << endl;
  }
  else {
  cout << N*A << endl;
  }
}
 


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;

int main(void){
    Cin(string, a);
    Cout("ABC" + a);
}

Measured memory_bytes: 256
N, x = map(int, input().split())
A = [int(x) for x in input().split()]
cnt = 0
for i in range(N - 1):
  if A[i] + A[i + 1] > x:
    d = min(A[i] + A[i + 1] - x, A[i + 1])
    e = A[i] + A[i + 1] - x - d
    A[i + 1] -= d
    A[i] -= e
    cnt += d + e
print(cnt)

Measured memory_bytes: 14132
let
    const lines=readlines(open("/dev/fd/0"))
    const state=0
    global input,int,intSub,intLine
    input()=lines[state+=1]
    int(s::String)=parse(Int,s)
    intSub(s::SubString{String})=parse(Int,s)
    intLine(s::Array{SubString{String},1})=map(intSub,s)
end
function main()
    INF=2^60
    a,b,q=input()|>split|>intLine
    s=Array{Int}(a+2)
    s[1],s[a+2]=-INF,INF
    for i in 2:a+1
        s[i]=int(input())
    end
    t=Array{Int}(b+2)
    t[1],t[b+2]=-INF,INF
    for i in 2:b+1
        t[i]=int(input())
    end
    for _ in 1:q
        x=int(input())
        m=INF
        i=searchsortedlast(s,x)
        j=searchsortedlast(t,x)
        for v in view(s,i:i+1)
            for w in view(t,j:j+1)
                m=min(m,abs(x-v)+abs(v-w),abs(x-w)+abs(w-v))
            end
        end
        println(m)
    end
end
main()

Measured memory_bytes: 174556
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 200005
#define eps 1e-12
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        res = res * 10 + c - '0';
        c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
        out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int N,C[MAXN],sum[MAXN];
int dp[MAXN][2];
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void Solve() {
    read(N);
    for(int i = 1 ; i <= N ; ++i) {
        read(C[i]);
    }
    dp[0][0] = 1;
    for(int i = 1 ; i <= N ; ++i) {
        dp[i][0] = inc(dp[i - 1][1],dp[i - 1][0]);
        if(C[i] != C[i - 1]) {
            dp[i][1] = sum[C[i]];
            sum[C[i]] = inc(sum[C[i]],dp[i][0]);
        }
    }
    out(inc(dp[N][0],dp[N][1]));enter;
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
    Solve();
}


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

#define int long long

#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))
#define upp(a,b) upper_bound(all(a),(b))
#define fill(i,n) memset(i,n,sizeof(i)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int N,M;
int cnt[200020];

signed main() {
    IOS();
    /*シフト演算は(1ll<<x)*/
    cin>>N>>M;
    rep(i,0,M){
        int a,b;
        cin>>a>>b;
        if(a==1)cnt[b]++;
        if(b==N)cnt[a]++;
    }
    bool can=false;
    rep(i,1,N){
        if(cnt[i]==2)can=true;
    }
    can?puts("POSSIBLE"):puts("IMPOSSIBLE");
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int mod = 1000000007;
int dp[2001];

signed main() {
	int s;
	int i, j;
	
	cin >> s;
	dp[0] = 1;
	
	rep(i, s) {
		for (j = 3; i + j <= s; j++) {
			dp[i + j] += dp[i];
			dp[i + j] %= mod;
		}
	}
	
	cout << dp[s] << endl;
	return 0;
}

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

MOD = 1000000007  # type: int
from collections import Counter
from itertools import product
def solve(N: int, S: str):
    counter = dict(Counter(S))
    values = list(counter.values())
    LEN = len(values)
    answer = values[0]+1
    if LEN >= 2:
        for i in range(1,LEN):
            answer *= values[i]+1
            answer%=MOD
    print(answer-1)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3436
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
template<class T> inline istream& operator >> (istream & c, vector<T> & A) {rep(i, A.size()) c >> A[i];return c;}
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<ll> x(n), l(n);
	rep(i, n) cin >> x[i] >> l[i];
	vector<pair<ll, ll>> rec(n);
	rep(i, n) {
		rec[i].first = x[i] - l[i];
		rec[i].second = x[i] + l[i];
	}
	sort(rec.begin(), rec.end(), [&](const auto& x, const auto& y) {
		return x.second < y.second;
		});
	int cnt = 0;
	/*rep(i, n) cout << rec[i].first << ' ' << rec[i].second << endl;*/
	ll prev = -1e12;
	rep(i, n) {
		if (rec[i].first >= prev) {
			prev = rec[i].second;
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 6364
def binarySearch(n, S, search):
    low    = 1 - 1
    high   = n - 1
    middle = 0

    while low < high:
        middle = (high + low)/2
        if S[middle] == search or S[low] == search or S[high] == search:
            return 1
        elif search < S[middle]:
            high = middle - 1
        elif S[middle] < search:
            low = middle + 1
    return 0

n = input()
S = map(int, raw_input().split())
q = input()
T = map(int, raw_input().split())

count = 0

for j in range(q):
    search = T[j]
    count = count + binarySearch(n, S, search)

print count

Measured memory_bytes: 14732
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


int main() {
    ll n,q; cin >> n >> q;
    string s; cin >> s;
    ll l,r;

    char prev = 'b';
    vector<int> sum(n+1,0);
    vector<pair<ll,ll>> v(q);


    rep(i,n) {
        if(prev == 'A' && s[i] == 'C') {
            sum[i+1] = sum[i] + 1;
        }else{
            sum[i+1] = sum[i];
        }
        prev = s[i];
    }

    rep(i,q) {
        cin >> v[i].first >> v[i].second;
    }

    rep(i,q){
        cout << sum[v[i].second] - sum[v[i].first] << endl;
    }
    return 0;
}


Measured memory_bytes: 5368
#include <iostream>
using namespace std;
 
int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b){
		cout<<c<<endl;
	}
	if(b==c){
		cout<<a<<endl;
	}
	if(a==c){
		cout<<b<<endl;
	}
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std; 
#define endl "\n"
int main() 
{
//	ios::sync_with_stdio(0);
//	cin.tie(0);
    long long int i,j,l,inc,dec,t,r,mod=1000000007;
   	long long int c,d,q,e,ans=0,n,temp,m,p,w,h,k,x,y;
//	cin>>t;
	t=1;
	while(t--)
	{
		cin>>n>>m;
		long long int dp[n][m];
		char a[n][m];
		for(i=0;i<n;i++)
		{
			for(j=0;j<m;j++)
			{
				cin>>a[i][j];
				dp[i][j]=0;
			}
		}
		for(i=0;i<n;i++)
		{
			for(j=0;j<m;j++)
			{	
				if(i==0 && j==0)
				{
					dp[i][j]=0;
				}
				else if(a[i][j]=='#')
				{
					dp[i][j]=0;
				}
				else if(i==0 || j==0)
				{
					
					if(i==0)
					{
						if(j!=1)
						dp[i][j]=dp[i][j-1];
						else
						dp[i][j]=1;
					}
					else
					{
						if(i!=1)
						dp[i][j]=dp[i-1][j];
						else
						dp[i][j]=1;
					}
					
				}
				else
				{
					dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
				}
				//cout<<dp[i][j]<<" ";
			}
			//cout<<endl;
		}
		cout<<dp[i-1][j-1];
		
	}

   return 0;
}
/*
1
5
1 1 6 1 6

*/



Measured memory_bytes: 9088
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>

using namespace std;

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    for (int i = 100; i >= 1; i--) {
        if (a % i == 0 && b % i == 0) {
            k--;
            if (k == 0) {
                cout << i << endl;
                return 0;
            }
        }
    }
}



Measured memory_bytes: 256
N,K = map(int,input().split(' '))
MOD = 10**9 + 7

n = N-K+1
print(n)
for i in range(2,K+1):
	n = (n * (N-K+2-i) * (K-i+1) // (i * (i-1)))
	print(n % MOD)


Measured memory_bytes: 3316
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,k=map(int,input().split())
    A=list(map(int,input().split()))
    if A[0]==1:
        print(1)
        sys.exit()
    cur_a=1
    cunt=0
    visited=[False]*n
    visited[0]=True
    route=[1]
    for _ in range(k):
        next_a=A[cur_a-1]
        if visited[next_a-1]:
            loop=len(route)-route.index(next_a)
            cunt-=loop-1
            break
        cur_a=next_a
        cunt+=1
        route.append(cur_a)
        visited[cur_a-1]=True
    else:
        print(next_a)
        sys.exit()
    #print(route)
    #rint(cunt,loop)
    k-=cunt
    k=k%loop
    #print(k)
    print(route[cunt+k])
    

if __name__=='__main__':
    main()

Measured memory_bytes: 94948
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string c;
  	cin >> c;

  cout << (c.at(0) == 'a' || c.at(0) == 'i' || c.at(0) == 'u' || c.at(0) == 'e' || c.at(0) =='o' ? "vowel" : "consonant") << endl;
}

Measured memory_bytes: 256
S = input()

if len(S) == 1:
  print(int(S))
else:
  ans = 0
  for i in range(1<<(len(S)-1)):
    SP = []
    for j in range(len(S)-1):
      if (i>>j)&1 == 1:
        SP.append(j)
    SP += [len(S)-1]
    #print(SP)
    idx = 0
    for sp in SP:
      ans += int(S[idx:sp+1])
      idx = sp+1
  print(ans)

Measured memory_bytes: 39792
n, d = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(n)]
def f(a, b):
    num = (a**2 + b**2) ** (1/2)
    return num
ans = 0
for x, y in xy:
    if f(x, y) <= d:
        ans += 1
print(ans)

Measured memory_bytes: 103164
MAXVAL = 10000


def counting_sort(li):
    """Sort li by counting the number of occurrences of each
    element in li.
    All the elements in li are supposed to be 0..10000.

    >>> counting_sort([2, 5, 1, 3, 2, 3, 0])
    [0, 1, 2, 2, 3, 3, 5]
    """
    counter = [0] * (MAXVAL+1)

    for e in li:
        counter[e] += 1

    for i in range(1, MAXVAL+1):
        counter[i] += counter[i-1]

    result = [None] * len(li)
    for e in reversed(li):
        counter[e] -= 1
        result[counter[e]] = e

    return result


def run():
    _ = int(input())  # flake8: noqa
    xs = [int(i) for i in input().split()]

    print(" ".join([str(i) for i in counting_sort(xs)]))


if __name__ == '__main__':
    run()



Measured memory_bytes: 233480
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(INF)
#define INF 1e17
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

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

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int find(vector<int> &v,int t){
	int hi=sz(v),lo=-1;
	while(hi-lo>1){
		int m=(hi+lo)/2;
		if(v[m]>t) hi=m;
		else lo=m;
	}
	if(hi==sz(v)) return INF;
	return v[hi];
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s,t; cin>>s>>t;
	vector<vector<int>> cnt(26);
	For(i,0,sz(s)-1){
		cnt[s[i]-'a'].emplace_back(i);
	}
	for(auto &i:cnt) sort(all(i));
	if(sz(cnt[t[0]-'a'])==0){
		cout<<"-1\n";
		return 0;
	}
	int i=find(cnt[t[0]-'a'],-1),now=i;
	For(j,1,sz(t)-1){
		if(sz(cnt[t[j]-'a'])==0){
			cout<<"-1\n";
			return 0;
		}
		int pos=find(cnt[t[j]-'a'],i);
		if(pos==INF) pos=cnt[t[j]-'a'][0];
		if(pos<=i){
			now+=pos+(sz(s)-i);
			i=pos;
		}
		else{
			now+=pos-i;
			i=pos;
		}
	}
	cout<<now+1<<"\n";
	return 0;
}




























Measured memory_bytes: 1736
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>

using namespace std;

typedef long long ll;

ll x;

int main() {
	cin >> x;

	if (x >= 400 && x <= 599)
		cout << "8" << endl;
	else if (x >= 600 && x <= 799)
		cout << "7" << endl;
	else if (x >= 800 && x <= 999)
		cout << "6" << endl;
	else if (x >= 1000 && x <= 1199)
		cout << "5" << endl;
	else if (x >= 1200 && x <= 1399)
		cout << "4" << endl;
	else if (x >= 1400 && x <= 1599)
		cout << "3" << endl;
	else if (x >= 1600 && x <= 1799)
		cout << "2" << endl;
	else
		cout << "1" << endl;

	return 0;
}

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

int main(void){
    long long n,k,r,s,p;
    long long ans=0;
    string t;
    cin>>n>>k>>r>>s>>p>>t;
    bool R[100010]={},S[100010]={},P[100010]={};
    for(int i=0;i<n;i++){
        if(i-k<0){
            if(t[i]=='r'){
                ans+=p;
                P[i]=true;
            }
            else if(t[i]=='s'){
                ans+=r;
                R[i]=true;
            }
            else {
                ans+=s;
                S[i]=true;
            }
        }
        else{
             if(t[i]=='r'&&P[i-k]==false){
                 ans+=p;
                 P[i]=true;
            }
            else if(t[i]=='s'&&R[i-k]==false){
                ans+=r;
                R[i]=true;
            }
            else if(t[i]=='p'&&S[i-k]==false){
                ans+=s;
                S[i]=true;
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 768
n,m=map(int,input().split())

import sys
sys.setrecursionlimit(10**9) #再帰の上限をあげる

root=[-1 for i in range(n+1)] #自分が親ならグループの人数のマイナス倍を、そうでないなら（元）親の番号を示す
dep=[1]*(n+1)
def r(x):   #親は誰？
    if root[x]<0:
        return x
    else:
        root[x]=r(root[x])
        return root[x]

def unite(x,y):
    x=r(x)
    y=r(y)
    if x==y:
        return
    if dep[x]==dep[y]:
        dep[x]+=1
    if dep[x]<dep[y]:
        x,y=y,x
    root[x]+=root[y]
    root[y]=x

for i in range(m):
    x,y,z=map(int,input().split())
    unite(x,y)


g=[0]*(n+1)
for i in range(1,n+1):
    g[r(i)]+=1
ans=0
for i in range(n+1):
    if g[i]>0:
        ans+=1
print(ans)



Measured memory_bytes: 12692
import math

N = int(raw_input())
X = map(int, raw_input().split())

sx = 0
sx2 = 0
for i in range(N):
    sx += X[i]
    sx2 += X[i]*X[i]

#print sx, sx2, sx*sx-N*sx2

p = int(sx/N)

print min(N*p*p-2*p*sx+sx2,  N*(p+1)*(p+1)-2*(p+1)*sx+sx2)


Measured memory_bytes: 2568
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int N;
vector<int> v;

int main(){
    int t = 1;
    cin >> N;
    if(N == 0) cout << 0 << endl;
    while(N!=0){
        if(abs(N)%2 == 1){
            v.push_back(1);
            N -= t;
        }else{
            v.push_back(0);
        }
        t *= (-1);
        N /= 2;
    }
    for(int i=0;i<v.size();i++){
        cout << v[v.size()-i-1];
    }
    cout << endl;
    return 0;
}

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

int main() {
 string S,T;
  cin >> S >> T;
  int A, B;
  cin >> A >> B;
  string U;
  cin >> U;
  if(S == U){
    A--;
  }
  if(T == U){
    B--;
  }
  cout << A << " " <<  B << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
class Main{
  public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String line = br.readLine();
    int length = Integer.parseInt(line);
    int cubic = (int)Math.pow(length,3);
    System.out.println(cubic);
  }
}



Measured memory_bytes: 24200
#include<stdio.h>
#include<iostream>

using namespace std;

int main(void){
	
	int n, a[100000], k, x1, x2, x4;
	x1 = 0;
	x2 = 0;
	x4 = 0;

	cin >> n;

	for (k = 0; k < n; k++) {
		cin >> a[k];

		if (a[k] % 4 == 0) {
			x4++;
		}
		else if (a[k] % 2 == 0) {
			x2++;
		}
		else {
			x1++;
		}

	}

	if (x2 == 0) {
		if (x4 >= x1 - 1) {
			cout << "Yes\n";
		}
		else {
			cout << "No\n";
		}
	}
	else {
		if (x4 >= x1) {
			cout << "Yes\n";
		}
		else {
			cout << "No\n";
		}
	}



/*	for (k = 0; k < n; k++) {
		cout << a[k] << "\n";
	}*/

	return 0;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);//高速化、endlは使わない

  int N;
  bool can = false;

  cin >> N;

  for(int i=0; i <= N/7;i++){
    for(int j=0; j <= N/4;j++){
      if (4*j + 7*i == N) can = true;
    }
  }


  if (can) cout << "Yes" << "\n";
  else cout << "No" << "\n";
}


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

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

int main() {
    int N, i;
    cin >> N >> i;
    cout << N - i + 1 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long 
#define LLU long long unsigned
#define rarr(arr, n) for(int aab = 0; aab < n; aab++){cin >> arr[aab];}
#define parr(arr, n) for(int aab = 0; aab < n; aab++){cout << arr[aab] << " ";}
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n";
#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);ios_base::sync_with_stdio(0);cin.tie(0);

int main(){
	long long int n, m, a, b, counter = 0;
	cin >> n >> m;
	long long int arr[n + 1];
	for(int i = 1; i <= n; i++){
		cin >> arr[i];
	}

	vector<long long int> v1[n + 1];

	for(int i = 0; i < m; i++){
		cin >> a >> b;
		v1[a].pb(b);
		v1[b].pb(a);
	}

	for(int i = 1; i <= n; i++){
		bool flag = true;
		for(int j = 0; j < v1[i].size(); j++){
			if(arr[i] > arr[v1[i][j]]){
				continue;
			}
			else{
				flag = false;
				break;
			}
		}
		if(flag){
			counter++;
		}
	}

	cout << counter;
} 

Measured memory_bytes: 10236
from itertools import *
import fractions

N = int(input())
A = list(map(int, input().split()))

L = list(accumulate([0]+A, fractions.gcd))
R = list(accumulate([0]+A[::-1], fractions.gcd))

print(max(fractions.gcd(s, t) for s, t in zip(L, R[::-1][1:])))


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second
#define lwb lower_bound
#define upb upper_bound
#define all(x) (x).begin(),(x).end()

#define cbr(x) ((x)*(x)*(x))

signed main() {
#ifdef _DEBUG
  freopen("in", "r", stdin);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  double l;
  cin >> l;
  cout << fixed << setprecision(10) << cbr(l / 3.0) << '\n';
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;


int main(void){
    int a,b,c,x,y;
    cin >> a >> b>>c>>x>>y;
    int init=a*x+b*y;
    int s=0;
    while(true){
        s=0;
        if (x>0){
            s += a;
            x--;
        }
        if (y>0){
            s += b;
            y--;
        }
        int dif = s-2*c;
        // cout << init-dif << endl;
        if (dif>0)init-=dif;
        else break;
    }
    cout << init << endl;
    return 0;
}


Measured memory_bytes: 256
//       BAAP IZ HERE           //
#include<bits/stdc++.h>
using namespace std;
#define gcd __gcd
#define lli long long int
#define jmd ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int main()
{
    jmd;
    lli n;cin>>n;
    if(n%1000!=0)
        cout<<1000-(n%1000);
    else 
        cout<<"0";
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll h,w,one=1;
    cin >> h >> w;//h>=Wとしてよい
    if(w>h){
        swap(h,w);
    }//hが長辺

    if((h*w)%3 == 0){
        cout << 0 << endl;
    }else{
        ll ans1=10000000002,ans2=10000000002,ans3=10000000002,ans4=10000000002;
        
        for(ll i=max((h/3)-1,one);i <= (h+3)/3;i++){
            for(ll j=max((2*h/3)-1,one);j <= (2*h+3)/3;j++){
                ans1= min(ans1,max(w*i,max(w*(j-i),w*(h-j)))-min(w*i,min(w*(j-i),w*(h-j))));
            }
        }//長辺側から３分割する場合

        for(ll i=max((h/3)-1,one);i <= (h+3)/3;i++){
            for(ll j=max((w/2)-1,one);j <= (2+w)/2 ;j++){
                ans2=min(ans2,max(w*i,max((h-i)*(w-j),(h-i)*j))-min(w*i,min((h-i)*(w-j),(h-i)*j)));
            }   
        }//まず長辺側で切り、次に短辺側で切る

        swap(h,w); 

        for(ll i=max((h/3)-1,one);i <= (h+3)/3;i++){
            for(ll j=max((w/2)-1,one);j <= (w+2)/2;j++){
                ans3=min(ans3,max(w*i,max((h-i)*(w-j),(h-i)*j))-min(w*i,min((h-i)*(w-j),(h-i)*j)));
            }   
        }//まず短辺側で切り、次に長辺側で切る

        cout << min(ans4,min(ans1,min(ans2,ans3))) << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define F first
#define S second
//cout<<fixed<<setprecision(11);
const string nl="\n";
const ll MOD=1e9+7;
const ll ARR_MAX = 1e5+1;
const ll VAL_MAX = 1e5+1;
const ll INF=1e14;

void solve(){
    ll n;cin>>n;
    if(n%2){
    	cout<<0<<nl;
    	return;
    }
    ll k=10;
    ll ans=0;
    while(true){
    	if(n/k==0){
    		break;
    	}
    	ans+=n/k;
    	k*=5;    	
    }
    cout<<ans<<nl;
}

int main(){
    fastio();
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256