akhauriyash/Code-Regression huggingface dataset:
#https://tjkendev.github.io/procon-library/python/string/rolling_hash.html
class RollingHash():
    def __init__(self, s, base, mod):
        self.mod = mod
        self.pw = pw = [1]*(len(s)+1)

        l = len(s)
        self.h = h = [0]*(l+1)

        v = 0
        for i in range(l):
            h[i+1] = v = (v * base + s[i]) % mod
        v = 1
        for i in range(l):
            pw[i+1] = v = v * base % mod
    def get(self, l, r):
        return (self.h[r] - self.h[l] * self.pw[r-l]) % self.mod
N=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[a[i%N]^a[(i+1)%N] for i in range(2*N)]
d=[b[i]^b[(i+1)%N] for i in range(N)]
P=RollingHash(c,96,10**9+7)
Q=RollingHash(d,96,10**9+7)

for k in range(N):
    if P.get(k,k+N)==Q.get(0,N):
        x=b[0]^a[k]
        print(k,x)


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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;


ll MX = 1000'000'000'000'000'000LL;


int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	int N;

	cin >> N;

	V<ll> A(N + 1);

	int mn = 1;

	for (int i = 1; i <= N; ++i) {
		cin >> A[i];
		if (!A[i])
			mn = 0;
	}

	if (!mn) {
		cout << "0\n";
	} else {
		ll curr = 1;
		for (int i = 1; i <= N; ++i) {
			if (curr > MX / A[i]) {
				cout << "-1\n";
				return 0;
			}
			curr *= A[i];
			db(curr);
		}
		cout << curr << '\n';
	}



	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
	return 0;
}


Measured memory_bytes: 3920
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
int main(){
    cin>>N;
    ll ans=1;
    for(ll i=1800;i>=400;i-=200){
        if(N>=i){
            cout<<ans;
            return 0;
        }
        ans++;
    }
    return 0;
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
//template <typename... T> void read(T& ... t){ ((cin >> t), ...); }
//template <typename... T> void write(T ... t){ ((cout << t), ...); }
//#define int long long
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define size(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define ln '\n'
#define space ' '
using LL = long long;
using pii = pair<int,int>;
const int INF = 2e9;
const int NN = 2e3;
const int MOD = 998244353;
namespace Mm{
	inline int _chk(const int &x){ return (x < MOD) ? x : (x-MOD < MOD) ? x-MOD : x%MOD; }
	inline int mul(const int &x, const int &y) { return ((LL)_chk(x)*_chk(y))%MOD; }
	inline int add(const int &x, const int &y) { return (_chk(x)+_chk(y))%MOD; }
	inline int power(const int &x, const int &n){ if(n == 0) return 1; int y=power(x, n>>1); y=mul(y,y); return (n&1)?mul(y,x):y; }
	inline int inv(const int &x){ return power(x, MOD-2); }
	int _fact[2*NN] = {0};
	inline int fact(const int &x){ return (x == 0 ? 1 : (_fact[x] != 0 ? _fact[x] : _fact[x]=mul(x, fact(x-1)))); }
	int _cnk[2*NN+1][2*NN+1] = {0};
	inline int cnk(const int &n, const int &k){ return (n<k) ? 0 : _cnk[n][k]; }
} using namespace Mm;
int n,k;
int dp[NN+1][NN+1];
int nbPairs[2*NN+1];

#define read(a,b) cin>>a>>b
#define write(a,b) cout<<a<<b

int32_t main(){ FAST;
	for(int a=0; a<=2*NN; ++a) for(int b=0; b<=2*NN; ++b){
		if(b > a) _cnk[a][b] = 0;
		else if(b == 0) _cnk[a][b] = 1;
		else _cnk[a][b] = add(_cnk[a-1][b], _cnk[a-1][b-1]);
	}
	
	read(k,n);
	dp[0][0] = 1;
	for(int i=1; i<=k; ++i){ // #pairs
		int prefSum = 0;
		for(int j=0; j<=n; ++j){ // #items to distribute on pairs
			dp[i][j] = add(dp[i-1][j], add(prefSum, prefSum)); // k € [1;j]
			prefSum = add(prefSum, dp[i-1][j]);
		}
	}

	for(int i=1; i<=k; ++i) for(int j=i+1; j<=k; ++j) ++nbPairs[i+j];

	for(int i=2; i<=2*k; ++i){
		int ans = 0;
		int others = k - 2*nbPairs[i];

		if(i&1){
			if(others == 0){
				ans = dp[nbPairs[i]][n];
				write(ans, ln);
				continue;
			}

			for(int giveOthers=0; giveOthers<=n; ++giveOthers){
				int givePairs = n-giveOthers;
				ans = add(ans, mul(dp[nbPairs[i]][givePairs], cnk(others+giveOthers-1, giveOthers)));
			}
		}
		else{
			--others;
			if(others == 0){
				ans = add(dp[nbPairs[i]][n], dp[nbPairs[i]][n-1]);
				write(ans, ln);
				continue;
			}
			
			for(int giveOthers=0; giveOthers<=n; ++giveOthers){
				int givePairs = n-giveOthers;
				ans = add(ans, mul(dp[nbPairs[i]][givePairs], cnk(others+giveOthers-1, giveOthers)));
			}
			for(int giveOthers=0; giveOthers<=n-1; ++giveOthers){
				int givePairs = n-1-giveOthers;
				ans = add(ans, mul(dp[nbPairs[i]][givePairs], cnk(others+giveOthers-1, giveOthers)));
			}
		}

		write(ans, ln);
	}
}

Measured memory_bytes: 78464
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
typedef pair<int,int> P;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<(a-b)%c<<endl;
}



Measured memory_bytes: 256
#!/usr/bin/python3

def main():
    N = int(input())

    dp = [[0 for _ in range(N+ 1)] for _ in range(3)]

    for i in range(0, N):
        todo = tuple(map(int, input().split()))

        for k in range(3):
            dp[k][i+1] = max(dp[j][i] for j in range(3) if j != k) + todo[k]

    print(max(dp[k][N] for k in range(3)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 15168
// C.

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

typedef long long LL;

LL calc(LL a, LL b) {
	LL r = 1LL << 32;
	for (LL i = a; i < b; ++i) {
		for (LL j = a + 1; j <= b; ++j) {
			r = min(r, (i * j) % 2019);
			if (!r) {
				return r;
			}
		}
	}
	return r;
}

int main(int argc, char *argv[]) {
	LL l, r;
	cin >> l >> r;
	LL ans = calc(l, r);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<ll> > mat;

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

  int m = (n + 1) / 2;
  int b[50100], c[50100];
  for (int i = 0; i < m; i++)
  {
    b[i] = a[2 * i];
  }
  sort(b, b + m);

  sort(a, a + n);
  for (int i = 0; i < m; i++)
  {
    c[i] = a[2 * i];
  }

  int ans = 0;
  int ib = 0;
  int ic = 0;
	//bに出てきてcに出てこない数を数えているわけだが、もっといい方法がある気がする
  while (ib < m)
  {
    if (b[ib] < c[ic] || ic == m)
    {
      ans++;
      ib++;
    }
    if (b[ib] == c[ic])
    {
      ib++;
      ic++;
    }
    else
    {
      ic++;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 1024
X, N = map(int,input().split())
if N == 0:
    print(X)
    exit()

# titleの通り、使用を禁止された数字のリストが与えられる。
flist = list(map(int,input().split()))

if flist.count(X) == 0:
    print(X)
    exit()

# 使用禁止の数字を除いたリストを作るために、リストの素を作る。
l = list(range(0,102)) # ここの範囲設定が一番難しい部分だと思う。

# 使用を許可された数字のリストを作成する。
plist = []
for i in range(len(l)):
    if flist.count(l[i]) == 0:
        plist.append(l[i])

# Xを投入して、前後の数字との距離を計測していく。
plist.append(X)
anslist = sorted(plist)
t = anslist.index(X)

dist1 = anslist[t] - anslist[t-1] # Xと1つ前の数字との距離
dist2 = anslist[t+1] - anslist[t] # Xと1つ後ろの数字との距離
if dist1 <= dist2:
    print(anslist[t-1])
else:
    print(anslist[t+1])

Measured memory_bytes: 9184
import sys
def main():
    input = sys.stdin.readline
    N = int(input())
    G=[[] for _ in range(N)]
    for _ in range(N-1):
        a,b,c=map(int, input().split())
        a,b=a-1,b-1
        G[a].append((b,c))
        G[b].append((a,c))
    Q,K=map(int, input().split())
    K-=1

    dfromK = [-1] * N
    dfromK[K] = 0
    stk = [(K,0)]
    while stk:
        v,d=stk.pop()
        for to,c in G[v]:
            if dfromK[to] >= 0: continue
            dfromK[to] = d+c
            stk.append((to,d+c))

    for _ in range(Q):
        x,y=map(int, input().split())
        x,y=x-1,y-1
        print(dfromK[x] + dfromK[y])

if __name__ == '__main__':
    main()


Measured memory_bytes: 72660
#include <bits/stdc++.h>
//#include <boost/array.hpp>
//#include <boost/range/numeric.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/multiprecision/cpp_int.hpp>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.14159265;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define CALL(x) x.cbegin(),x.cend()
#define RALL(x) x.rbegin(),x.rend()
#define CRALL(x) x.crbegin(),x.crend()

#define cout cout << fixed << setprecision(12)
#define accm(arr) accumulate(ALL(arr),0LL)

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template<typename T>
inline void dbg(T a) { cout << a << ' '; } 

ll n, m, k;
ll ans = 0, sum = 0, cnt = 0;
//long double d;
string s;
char c;

/*--------------------template--------------------*/

int main() {
    cin >> n;
  	vi a(n), answ(n), cnt(n), sub(n);
	fill(ALL(cnt), 0);
	REP(i,n) {
      cin >> a[i];
      cnt[a[i]-1]++;
    }
  	REP(i,n) {
    	answ[i] = cnt[i] * (cnt[i]-1) / 2;
    	sub[i] = (cnt[i]-1) * (cnt[i]-2) / 2;
    }
	k = accm(answ);
    REP(i,n) {
    	cout << k - answ[a[i]-1] + sub[a[i]-1] << endl;
    }
}


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

public class P
{
    public string s { get; set; }
    public int c { get; set; }
}

public class Hello
{
    public static void Main()
    {
        string s;
        for (; (s = Console.ReadLine()) != null;)
        {
            var a = new int[9];
            for (int i = 0; i < 13; i++) a[int.Parse(s[i].ToString()) - 1]++;
            var ret = new List<int>();
            for (int i = 0; i < 9; i++)
            {
                a[i]++;
                if (a[i] >= 5) { a[i]--; continue; }
                for (int j = 0; j < 9; j++)
                {
                    if (a[j] >= 2)
                    {
                        var b = new int[9];
                        Array.Copy(a, b, 9);
                        b[j] -= 2;
                        if (goBfs(putA(b), 12)) { ret.Add(i); goto next; }
                    }
                }
                next:;
                a[i]--;
            }
            print(ret);
        }
    }
    public static void print(List<int> a)
    {
        var ac = a.Count();
        if (ac == 0) Console.WriteLine(0);
        for (int i = 0; i < ac; i++)
            if (i == ac - 1) Console.WriteLine(a[i] + 1);
            else Console.Write("{0} ", a[i] + 1);
    }
    public static bool goBfs(string s, int c)
    {
        var st = new Stack<P>();
        st.Push(new P { s = s, c = c });
        while (st.Count() > 0)
        {
            var x = st.Pop();
            if (x.c == 0) return true;
            var a = getA(x.s);
            for (int i = 0; i <= 6; i++)
            {
                if (a[i] >= 1 && a[i + 1] >= 1 && a[i + 2] >= 1)
                {
                    a[i]--; a[i + 1]--; a[i + 2]--;
                    var ww = putA(a);
                    st.Push(new P { s = ww, c = x.c - 3 });
                    a[i]++; a[i + 1]++; a[i + 2]++;
                }
            }
            for (int i = 0; i <= 8; i++)
                if (a[i] >= 3)
                {
                    a[i] -= 3;
                    var ww = putA(a);
                    st.Push(new P { s = ww, c = x.c - 3 });
                    a[i] += 3;
                }
        }
        return false;
    }
    public static int[] getA(string s)
    {
        var ret = new int[9];
        for (int i = 0; i < 9; i++) ret[i] = int.Parse(s[i].ToString());
        return ret;
    }
    public static string putA(int[] a)
    {
        var ret = "";
        for (int i = 0; i < 9; i++) ret += a[i].ToString();
        return ret;
    }
}



Measured memory_bytes: 10580
#include <bits/stdc++.h>
#define ll long long int
#define INF 1000000000000
#define MOD 1000000007
#define DEBUG(x) cerr<<'>'<<#x<<':'<<x<< endl
using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, k;
    cin >> n >> k;
    n = n % k;
    n = min(n, abs((n % k) - k));
    cout << n << endl;    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int64 n,a,b;
    cin >> n >> a >> b;
    vector<int> x(n);
    for (int i=0; i<n; i++) cin >> x[i];

    vector<int> diff;
    for (int i=0; i<n-1; i++) diff.push_back(x[i+1] - x[i]);

    auto cal = [&](int64 acc, int64 x){return acc + min(a*x,b);};
    int64 ans = accumulate(diff.begin(), diff.end(), 0LL,  cal);
    cout << ans << endl;
}

Measured memory_bytes: 1276
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

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

	ll N, M, L;
	cin >> N >> M >> L;
	
	vector<ll> counts(N);
	vector<vector<ll>> dists(N, vector<ll>(N, 1LL << 60));
	ll a, b, c;
	for (ll i = 0; i < M; ++i) {
		cin >> a >> b >> c;
		--a, --b;
		dists[a][b] = c;
		dists[b][a] = c;
	}
	for (ll i = 0; i < N; ++i) {
		dists[i][i] = 0;
	}

	for (ll k = 0; k < N; ++k) {
		for (ll i = 0; i < N; ++i) {
			for (ll j = 0; j < N; ++j) {
				dists[i][j] = min(dists[i][j], dists[i][k] + dists[k][j]);
			}
		}
	}

	vector<vector<ll>> results(N, vector<ll>(N));
	for (ll i = 0; i < N; ++i) {
		for (ll j = 0; j < N; ++j) {
			results[i][j] = (dists[i][j] <= L ? 1 : (1LL << 60));
		}
	}
	for (ll i = 0; i < N; ++i) {
		results[i][i] = 0;
	}

	for (ll k = 0; k < N; ++k) {
		for (ll i = 0; i < N; ++i) {
			for (ll j = 0; j < N; ++j) {
				results[i][j] = min(results[i][j], results[i][k] + results[k][j]);
			}
		}
	}

	ll Q;
	cin >> Q;
	ll s, t;
	for (ll i = 0; i < Q; ++i) {
		cin >> s >> t;
		--s, --t;
		if (results[s][t] < (1LL << 58)) {
			cout << (results[s][t] - 1LL) << endl;
		}
		else {
			cout << -1 << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 2048
#include<stdio.h>
int main(void)
{
    int x,y,w,c,i;
	scanf("%d %d",&x,&y);
	while(x!=0&&y!=0){
	    c=0;
		if(x<y){
            w=x;
            x=y;
            y=w;
        }
	    while(y!=0){
			    x=x%y;
				w=x;
				x=y;
				y=w;
				c++;
		}
	printf("%d %d\n",x,c);
	scanf("%d %d",&x,&y);
	}
	return 0;
}

Measured memory_bytes: 1028
import unittest


class TestD(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think([2, 1, 2]), 1)

    def test_2(self):
        self.assertEqual(think([2, 2, 2]), -1)

    def test_3(self):
        self.assertEqual(think([3, 1, 4, 1, 5, 9, 2, 6, 5, 3]), 7)


def solve():
    a = read()
    result = think(a)
    write(result)


def read():
    n = read_int(1)[0]
    return read_int(n)


def read_int(n):
    return read_type(int, n)


def read_float(n):
    return read_type(float, n)


def read_type(t, n):
    return list(map(lambda x: t(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a):
    if 1 not in a:
        return -1
    next_index = 1
    count = 0

    for i in a:
        if next_index == i:
            next_index += 1
        else:
            count += 1
    return count


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 28920
#include<bits/stdc++.h>
#define endl "\n"
#define ll long long
#define eb emplace_back
#define sz(x) ((int)(x).size())
using namespace std;
ll getmul(ll n){ll int k{0};while(n>0){k+=n%10;n=n/10;}return k;}
int main(){
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     int x,y;
     cin>>x>>y;
     if(y>=2*x&&y<=4*x&&y%2==0)
         cout<<"Yes"<<endl;
     else
         cout<<"No"<<endl;
 return 0;    
}

Measured memory_bytes: 3648
N = int(input())
A = list(map(int, input().split()))
ans = pow(2, N // 2)
# 0*1 2*2 4*2 2^N/2*2
check = [0 for p in range(0, N // 2 + N % 2)]
for o in A:
    check[o // 2] += 1

for q in range(0, N // 2 + N % 2):
    if q == 0 and N % 2 == 1:
        if check[q] != 1:
            ans = 0
            break
    else:
        if check[q] != 2:
            ans = 0
            break
print(ans % (pow(10, 9) + 7))

Measured memory_bytes: 14008
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <deque>
using namespace std;

int main(){
	int n;
	map<string,int> mp;

	cin >> n;
	cin.get();
	vector<string> s(n);

	for(int i = 0; i < n; ++i){
		getline(cin, s[i]);
		if(*s[i].rbegin() == ':'){
			mp[s[i].substr(0, s[i].size() - 1)] = i;
		}
	}

	vector<int> to(n);
	for(int i = 0; i < n; ++i){
		if(*s[i].rbegin() == ':'){
			to[i] = i + 1;
		}
		else{
			to[i] = mp[s[i].substr(5, s[i].size() - 6)];
		}
	}

	vector<int> d(n + 1, 1e9);
	d[0] = 0;
	deque<int> dq;
	dq.push_back(0);
	dq.push_back(-1);
	int ans = 0;
	while(1){
		int a = dq.front();
		dq.pop_front();

		if(a == n){
			cout << ans << endl;
			return 0;
		}
		if(a == -1){
			dq.push_back(a);
			++ans;
		}
		else{
			if(d[a] != ans){ continue; }
			if(d[to[a]] > ans){
				d[to[a]] = ans;
				dq.push_front(to[a]);
			}
			if(d[a + 1] > ans + 1){
				d[a + 1] = ans + 1;
				dq.push_back(a + 1);
			}
		}
	}
}

Measured memory_bytes: 1232
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


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

class BTrickOrTreat {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n,k;
        in >> n >> k;
        set<int> s;
        rep(i,k){
            int d;
            in >> d;
            rep(j,d) {
                int t;
                in >> t;
                s.insert(t);
            }
        }
        out << n-s.size() <<endl;
	}
};


int main() {
	BTrickOrTreat solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, x;
  cin >> n >> x;

  if(x == 1 || x == 2*n - 1){
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;

  ll cur = 1, cnt = 0;
  while(cnt < n - 1){
    cur++;    
    if(cur == x) continue;
    cout << cur << endl;
    cnt++;
  }

  ll lv = 1, rv = 2*n-1;
  if(x > n) swap(lv, rv);
  cout << lv << endl;
  cout << x << endl;
  if(n != 2) cout << rv << endl;

  cnt = 0;
  while(cnt < n - 3){
    cur++;    
    if(cur == x) continue;
    cout << cur << endl;
    cnt++;
  }

  return 0;
}


Measured memory_bytes: 3600
N, M = map(int, input().split())

# Mを i*j jがN以上なら i は a の 公約数である
# 最大値を記録しながら、公約数を全て探索
max_num = 1
for i in range(1, int(M**(1/2))+2):
    if M%i:
        continue
    j = M // i
    if j >= N:
        max_num = max(max_num, i)
    if i >= N:
        max_num = max(max_num, j)

print(max_num)

Measured memory_bytes: 3060
import java.io.IOException;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
			Scanner sc = new Scanner(System.in);
			int a = sc.nextInt();
			double s = 0;
			double d = 0;
			while(a != 0){
				int c[] = new int[a];
				for(int b=0;b<a;++b){
					c[b]=sc.nextInt();
					s += c[b];
				}
				s = s/a;
				for(int b=0;b<a;++b){
					d += Math.pow(s-c[b], 2);
				}
				d=Math.sqrt(d/a);
				System.out.println(d);
				d=0;
				s=0;
				a = sc.nextInt();
			}
	}

}

Measured memory_bytes: 31352
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int a[100009];
int main(){
    int n;
    cin>>n;
    for (int i=1;i<=n;i++)
        cin>>a[i];
    int ct=0;
    int sp=0;
    for (int i=1;i<=n;i++) 
           {
               ct+=abs(a[i]-sp);
               sp=a[i];
           }
    ct+=abs(sp-0);
    int aa;
    int bb;
    int cc;
    int dd;
    for (int i=1;i<=n;i++)
        {
           aa=abs(a[i]-a[i+1]);
           bb=abs(a[i-1]-a[i]);
           cc=abs(a[i-1]-a[i+1]);
           if (i!=n && i!=1) cout<<ct-aa-bb+cc<<endl;
           else if (i==1) {dd=ct-abs(a[1]-0)+abs(a[2]-0);cout<<dd-aa<<endl;}
                else {ct-=abs(sp-0);ct+=abs(a[i-1]-0);cout<<ct-bb<<endl;}
        }
    return 0;
} 

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <cassert>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using ld = long double;

#define st first
#define nd second

const int MAXN = 1e6 + 5, inf = 1e5;
const ll INF = 1e18;
const ld PI = 3.1415926535897932384626433832795;

struct Item {
    ll w, v;
};

Item item[MAXN];

ll dp[MAXN];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << setprecision(13) << fixed;

    //////////////////////////////////////////
    //////////////////////////////////////////

    int n, m;
    cin >> n >> m;

    for (int i = 1; i <= inf; i++) {
        dp[i] = m + 1;
    }

    for (int i = 0; i < n; i++) {
        cin >> item[i].w >> item[i].v;
    }

    sort(item, item + n, [](Item a, Item b) {
        if (a.v == b.v) {
            return a.w > b.w;
        }
        return a.w > b.w;
    });

    for (int i = 0; i < n; i++) {
        for (int j = inf; j >= 0; j--) {
            if ((dp[j] > 0 and dp[j] < m )or j == 0) {
                dp[j + item[i].v] = min(dp[j + item[i].v], dp[j] + item[i].w);
            }
        }
    }

    ll res = 0;
    for (int i = 1; i <= inf; i++) {
        if (dp[i] > 0 and dp[i] <= m) {
            res = i;
        }
    }
    cout << res << "\n";
}


Measured memory_bytes: 3072
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

int main()
{
	char a, b;
	cin >> a >> b;

	if (a > b)
	{
		cout << ">" << endl;
	}
	else if (a < b)
	{
		cout << "<" << endl;
	}
	else
	{
		cout << "=" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef vector<int> vi;
typedef vector<vi> vvi;

bool visit(const vector<vi>& g, int v, vector<int>& order, vector<int>& color) {
	color[v] = 1;
	for (int u : g[v]) {
		if (color[u] == 2) continue;
		if (color[u] == 1) return false;
		if (!visit(g, u, order, color)) return false;
	}
	order.push_back(v); color[v] = 2;
	return true;
}

// ?????????????????????????????????
// ???????????? true ???????????????????????????(false ?????´????????????)
bool TopologicalSort(const vector<vi>& g, vector<int>& order) {
	int n = g.size();
	vector<int> color(n);
	for (int u = 0; u < n; u++) if (!color[u] && !visit(g, u, order, color)) return false;
	reverse(order.begin(), order.end());
	return true;
}

int main()
{
	int V, E;
	cin >> V >> E;

	vvi edge(V);
	rep(i, 0, E)
	{
		int s, t;
		cin >> s >> t;
		edge[s].push_back(t);
	}

	vi order;
	if(!TopologicalSort(edge, order)) return 0;
	rep(i, 0, V) cout << order[i] << endl;
}

Measured memory_bytes: 3784
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    static Scanner input = new Scanner(System.in);
    private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);   

    public static void main(String[] args) {
        solve();
        out.flush();
    }    
    private static void solve() {
        ArrayList<Integer> point=new ArrayList<>();
        int n = input.nextInt();
        while (n != 0) {
            ArrayList<Integer> a = arrayInput(n);
            Collections.sort(a);
            a.remove(0);
            a.remove(a.size()-1);
            point.add((int)calculateAverage(a));
            n = input.nextInt();
        }
        for (int m: point
             ) {
            out.println(m);
        }
    }    

    private static ArrayList<Integer> arrayInput(int n) {
        ArrayList<Integer> a = new ArrayList<>();
        for (int i = 0; i < n; i++)
        a.add(input.nextInt());
        return a;
    }

    private static double calculateAverage(ArrayList<Integer> marks) {
        Integer sum = 0;
        if(!marks.isEmpty()) {
            for (Integer mark : marks) {
                sum += mark;
            }
            return sum.doubleValue() / marks.size();
        }
        return sum;
    }
}


Measured memory_bytes: 29292
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

	int n = nextInt();
    long[] a = new long[n];
    for(int i=0;i<n;i++){
      a[i] = nextLong();
      if(a[i]==0){
        System.out.println("0");
        System.exit(0);
      }
    }
    
    double ans = 0;
    
    for(int i=0;i<n;i++){
      ans += Math.log10(a[i]);
    }
    
    //System.out.println("ans="+ans);
    
    long limit = (long)Math.pow(10,18);
    
    if(ans>18.0){
      System.out.println("-1");
    }
    else{
      long cnt = 1;
      for(int i=0;i<n;i++){
        cnt *= a[i];
      }
      if(cnt>limit){
        System.out.println("-1");
      }
      else{
        System.out.println(cnt);
      }
      
    }                   
    

  }

  static int lcm(int a,int b){
    return a*b*gcd(a,b);
  }

  static int gcd(int a,int b){
    if(a%b!=0){
      return gcd(b,a%b);
    }
    else{
      return b;
    }
  }

  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

  static int nextInt(){
    return Integer.parseInt(sc.next());
  }

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


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

int main(){
  int A,B;
  cin >> A >> B;
  int ans = 0;
  int A5,A4,A2,A1;
  for(int i=A; i<B+1;i++){
    A5 = i/10000;
    A4 = (i/1000)%10;
    A1 = i%10;
    A2 = (i/10)%10;
    if(A5==A1 && A4==A2)ans++;
  }
  
  cout << ans << endl;
}

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

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, q;
    cin >> n >> q;
    vector<vector<ll>> graph(n);
    for (ll i = 0; i < n - 1; i++)
    {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].push_back(b);
    }
    vector<ll> cost(n, 0);
    for (ll i = 0; i < q; i++)
    {
        ll p, x;
        cin >> p >> x;
        p--;
        cost[p] += x;
    }
    vector<bool> seen(n, false);
    vector<ll> d(n, 0);
    stack<ll> st;
    st.push(0);
    d[0] = cost[0];
    while (!st.empty())
    {
        ll now = st.top();
        seen[now] = true;
        st.pop();
        for (auto v : graph[now])
        {
            if (!seen[v])
            {
                st.push(v);
                d[v] += d[now] + cost[v];
            }
        }
        seen[now] = false;
    }
    for (auto ans : d)
    {
        cout << ans << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > using vec = std::vector< T >;
template < class T > void print(T &x) { cout << x << "\n"; }
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  string S;
  int K;
  cin >> S >> K;
  int N = S.size();
  int nonOne = 0;
  char ans = '1';
  REP(i, N) {
    if (S[i] != '1') {
      nonOne = i;
      ans = S[i];
      break;
    }
  }
  if (K <= nonOne) {
    print("1");
  } else {
    print(ans);
  }
  // print();
}

Measured memory_bytes: 256
#include <stdio.h>
#define SIZE 100011

int main(void) {
  int num, tmp = 0;
  int l;
  int r;
  scanf("%d", &num);
  for (int i = 0; i < num; i++) {
    scanf("%d %d", &l, &r);
    tmp += r - l + 1;
  }

  printf("%d", tmp);

  return 0;
}


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

using namespace std;

int main() {
    char s[201], t[101], p[101];

    scanf("%s %s", s, p);
    strcpy(t, s);
    strcat(s, t);

    if (strstr(s, p) == NULL) {
        printf("No\n");
    } else {
        printf("Yes\n");
    }

}

Measured memory_bytes: 3160
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

long[2][] primeFact(long x)
{
	long[2][] ans;
	for (long i = 2; i*i <= x; ++i)
	{
		if (x % i != 0) continue;

		long r;
		while (x % i == 0)
		{
			++r;
			x /= i;
		}
		ans ~= [i, r];
	}
	if (x != 1)
		ans ~= [x, 1];
	return ans;
}

void main()
{
	auto A = RD;
	auto B = RD;

	auto aa = primeFact(gcd(A, B));
	debug writeln(aa);

	writeln(aa.length+1);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, b[109];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i < n; i++) {
		cin >> b[i];
	}
	b[0] = 1e9; b[n] = 1e9;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += min(b[i - 1], b[i]);
	}
	cout << ans << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) (v).begin(), (v).end()



int main() {

	ll N;
	cin >> N;
	if (N % 2 == 0) cout << N << endl;
	else cout << 2 * N << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/
ll N,C,K;
vector<ll> T;

int main(){
    cin >> N >> C >> K;
    T.resize(N);
    rep(i,N){
        cin>>T[i];
    }
    sort(all(T));

    //vector<ll> bus;

    ll ans=0;

    int idx=0;
    while(1){
        ll st = T[idx];
        ll et = st + K;
        int si = idx;
        int ei = lower_bound(T.begin(),T.end(),et+1) - T.begin();   // not closed )
        int num = ei - si;
        if(num<=C){
            idx = ei;
            ans++;
        }else{
            ans++;
            idx = si + C;
        }

        if(idx >= N) break;
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
S = input()

harf_n = len(S)//2
befor_str = S[:harf_n]
after_str = reversed(S[harf_n:])

hug_count = 0
for b_str, a_str in zip(befor_str, after_str):
    if b_str != a_str:
        hug_count += 1
print(hug_count)

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

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define R 1
#define L -1


int main(){
	int n;
	cin>>n;
	rep(loop,n){
		string s;
		cin>>s;
		int now = 0;
		string ans = string(1,s[0]);

		for(int i=1;i<s.size();i+=3){
			int alph = s[i+2];
			int dir = s[i+1]=='>'?R:L;

			now+=dir;
			if(dir == R){
				if(now == ans.size()){
					ans = ans+string(1,alph);
				}
			}else{
				if(now == -1){
					ans = string(1,alph)+ans;
					now = 0;
				}
			}
		}
		cout<<ans<<endl;
	}
}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> v(n);
    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> v[i];
        sum += v[i];
    }
    int t;
    cin >> t;
    vector<int> p(t), x(t);
    for(int i = 0; i < t; i++){
        cin >> p[i] >> x[i];
        cout << sum - v[p[i]-1] + x[i] << endl;
    }

    return 0;
}



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

//+=と=+に注意
//バケツは{0}で初期化しないと不具合を生じる
const int INF = 1001000000;

int main(){
  int n,k;
  int a[300000],b[300000]={0};
  cin >> n >> k;
  for(int i=0;i<n;++i){
    cin >> a[i];
  }
  for(int i=0;i<n;++i){
    b[a[i]]++;
  }
  //cout << b[0] <<" "<<b[1] << " " << b[2] << " " << b[3] << " " << b[4] << " " << b[5] << endl;
  sort(b,b+n+1,greater<int>());
  //cout << b[0] <<" "<<b[1] << " " << b[2] << " " << b[3] << " " << b[4] << " " << b[5] << endl;
  int res=0;
  for(int i=k;i<n;i++){
    res+=b[i];
  }
  cout << res << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

constexpr double eps = 1e-9;

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

    int n, d;
    cin >> n >> d;
    int ans = 0;
    for(int i = 0; i < n; ++i){
        int x, y;
        cin >> x >> y;
        if(hypot(x, y) <= d + eps){
            ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3696
use std::io::*;
use std::str::FromStr;
use  std::collections::BTreeSet;
use std::cmp::min;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    println!("{}", count(read()));
}

fn count(h: u64) -> u64 {
    if h == 0 {
        0
    } else if h == 1 {
        1
    } else {
        count(h / 2) * 2 + 1
    }
}


Measured memory_bytes: 4352
l = [int(i) for i in input().split(" ")]
n = l[0]
t = l[1]
c_list = []
flag = False
for i in range(n):
    l = [int(i) for i in input().split(" ")]
    if l[1] <= t:
        c_list.append(l[0])
        flag = True
if flag:
    print(min(c_list))
else:
    print("TLE")


Measured memory_bytes: 3060
import sys

n, m, *xy = map(int, sys.stdin.buffer.read().split())
xy = list(zip(xy[0::2], xy[1::2]))
counts = [1] * n
can = [False] * n
can[0] = True

for x, y in xy:
    x -= 1
    y -= 1
    counts[x] -= 1
    counts[y] += 1
    if can[x]:
        can[y] = True
        if counts[x] == 0:
            can[x] = False

print(sum(can))


Measured memory_bytes: 20388
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2);
        if(y%2==0)
         return (p*p)%hell;
        else
        return (x*((p*p)%hell))%hell;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
  ll a,b,t;
  cin>>a>>b>>t;
  cout<<(t/a)*b;}

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

using namespace std;

int dfs(list<int>graph[],int node,int visited[],set<int>&s)
{
    if(visited[node]!=-1)
    return 0;
    
    visited[node]=1;
    s.erase(node);
    
    for(auto i:graph[node])
    {
        dfs(graph,i,visited,s);
    }
    
    return 1;
}


int main()
{
    int n,m;cin>>n>>m;
    list<int>graph[n];
    
    for(int i=0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        u--;v--;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    
    int visited[n];
    
  for(int i=0;i<n;i++)
  visited[i]=-1;
    
    set<int>s;
    for(int i=0;i<n;i++)
    s.insert(i);
    
    int count=-1;
    
    while(!s.empty())
    {
        count++;
        auto ptrele=s.begin();
        auto ele=*ptrele;
        
        dfs(graph,ele,visited,s);
        
    }
   
    
    
    cout<<count;
    

    return 0;
}


Measured memory_bytes: 18924