akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll mod = 998244353;
const int MAX = 510000;

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N), B(N);
  for (ll i=0; i<N; i++) cin >> A[i];
  for (ll i=0; i<N; i++) cin >> B[i];
  // A[i]<B[i]なるiが存在するかどうか
  bool exist = false;
  for (ll i=0; i<N; i++) {
    if (A[i]<B[i]) {
      exist = true;
      break;
    }
  }
  if (!exist) cout << 0 << endl;
  else {
    ll S = 0, res = 0;
    vector<ll> C(N); // A[i]-B[i]を格納
    for (ll i=0; i<N; i++) {
      if (A[i]<B[i]) {
        S += B[i]-A[i];
        res++;
      }
      else C.push_back(A[i]-B[i]);
    }
    sort(C.begin(), C.end());
    reverse(C.begin(), C.end());
    ll sum = 0;
    for (ll i=0; i<C.size(); i++) {
      sum += C[i];
      if (sum<S&&i==C.size()-1) {
        cout << -1 << endl;
        break;
      }
      else if (sum>=S) {
        cout << res+i+1 << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 3328
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,h,w=parseMap(split(readline()))
    ans=0
    for i in 1:n
        a,b=parseMap(split(readline()))
        if h<=a && w<=b
            ans+=1
        end
    end
    println(ans)
end
main()

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

#ifdef LOCAL
	#define D(a) cerr << #a << " = " << a << endl
#else
	#define D(a)
	#define cerr false && cerr
#endif
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define forn(i,n) forsn(i,0,n)
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first
using pii = pair<int,int>;
using vi = vector<int>;
using ll = long long;

vi node;
vector<vi> g;
vector<bool> v;

int sum(int n){
    v[n] = true;
    int s = node[n];
    for(int i : g[n]) if(!v[i]) s += sum(i);
    return s;
}

int main() {
	fastio;
	
    string s; cin >> s;
    int n = si(s), sd = n+1, sn = (sd+1)/2;
    vi d(sd);
    s = 'a'+s+'a';
    node = vi(sn), g.resize(sn), v.resize(sn);

    forn(i,sd) d[i] = (26+s[i]-s[i+1]) % 26;
    forn(i,sd/2) node[i] = (52-d[i]-d[sd-i-1]) % 26; 
    if(sd & 1) node[sd/2] = (26-d[sd/2]) % 26;

    int m; cin >> m;
    forn(i,m){
        int x,y; cin >> x >> y; x--;
        if(x >= sd/2) x = sd-x-1;
        if(y >= sd/2) y = sd-y-1;
        g[x].pb(y), g[y].pb(x);
    }
    bool ok = true;
    forn(i,sn) if(!v[i] && sum(i) % 26 != 0) ok = false;
    cout << (ok ? "YES" : "NO") << endl;  
	return 0;
}

Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
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; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    long long N;
    cin >> N;
    const auto &res = prime_factorize(N);
    ll ans = 0;
    for (auto p : res) {
        ll i = p.second;
        ll cnt = 0, cur = 1;
        while (i >= cur)
        {
            i -= cur;
            cur++;
            cnt++;
        }
        ans += cnt;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#pragma GCC optimize("Ofast")
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

const long long INF = 1e17+7;
const long long MOD = 1e9+7;
const int SIZE=1e6+10;
const double PI=acos(-1);

using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	long long n;
	cin >> n;
	string ans="";
	while(1){
		n--;
		ans+=(char)(n%26+'a');
		n/=26;
		if(n<=0)break;
	}
	reverse(ans.begin(),ans.end());
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template
struct node {
    int to; ll cost;
};

struct edge {
    int from, to; ll cost;
};

vector<int> vis;
vector<pair<int, ll>> val; // sgn, num
vector<vector<node>> G;
void dfs(int cur = 0, int pre = -1) {
    if(vis[cur]) return;
    vis[cur] = 1;
    for(node b: G[cur]){
        if(vis[b.to] == 0) {
            val[b.to].first = val[cur].first * (-1);
            val[b.to].second = b.cost - val[cur].second;
            dfs(b.to, cur);
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int n, m;
    cin >> n >> m;
    G.resize(n);
    vector<edge> A(m);
    rep(i, m) {
        int u, v;
        ll s;
        cin >> u >> v >> s;
        u--; v--;
        G[u].pb({v, s});
        G[v].pb({u, s});
        A[i] = {u, v, s};
    }
    
    vis.assign(n, 0);
    val.assign(n, {0, 0});
//    vis[0] = 1;
    val[0] = {1, 0};
    dfs(0);
    
    ll a = 1LL << 62;
    for(edge e: A) {
        if(val[e.from].first * val[e.to].first == -1) {
            if(val[e.from].second + val[e.to].second != e.cost) {
                output(0);
                return 0;
            }
        }
        else {
            ll tmp = val[e.from].first * (e.cost - val[e.from].second - val[e.to].second);
            if(tmp % 2 != 0) {
                output(0);
                return 0;
            }
            if(a == 1LL << 62) {
                a = tmp / 2;
            }
            else {
                if(a != tmp / 2) {
                    output(0);
                    return 0;
                }
            }
        }
    }
    if(a != 1LL << 62) {
        bool ok = true;
        rep(i, n) {
            if(val[i].first * a + val[i].second <= 0) ok = false;
        }
        if(ok) {
            output(1);
        }
        else {
            output(0);
        }
    }
    else {
        ll mi = -1LL << 62, ma = 1LL << 62;
        rep(i, n) {
            if(val[i].first > 0) {
                mi = max(-val[i].second + 1, mi);
            }
            else{
                ma = min(val[i].second - 1, ma);
            }
        }
//        output(ma);
//        output(mi);
        output(max(0LL, ma - mi + 1));
    }
    
    return 0;
}


Measured memory_bytes: 16000
#include <iostream>
#include <cassert>
//#define NDEBUG
int main(void){
    using namespace std;
 
    static const int NUM_MIN = 0;
    static const int NUM_MAX =  100;
    int input_num1 = 0;
    int input_num2 = 0;
    int input_num3 = 0;
    cin >> input_num1;
    cin >> input_num2;
    cin >> input_num3;
    
    assert(NUM_MIN <= input_num1 && input_num1 <= NUM_MAX); /* Precondition */
    assert(NUM_MIN <= input_num2 && input_num2 <= NUM_MAX); /* Precondition */
    assert(NUM_MIN <= input_num3 && input_num3 <= NUM_MAX); /* Precondition */

    /* Comparison */
    if(input_num1 < input_num2 && input_num2 < input_num3){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

int main(){
    int n;
    cin >> n;

    while(sqrt(n) - (int)(sqrt(n)) != 0) n--;

    cout << n << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		char[] list = s.toCharArray();

		if (list[0] == list[1] || list[1] == list[2] || list[2] == list[3]) {
			System.out.println("Bad");
		} else {
			System.out.println("Good");
		}

		sc.close();
	}
}

Measured memory_bytes: 26908
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
    char s[3];
    scanf("%s", s);
    int k = 0;
    for (int i = 0; i < 3 ; i++)
    {
        if (s[i] == '1')
        {
            k++;
        }
    }
    printf("%d\n", k);
    return 0;
}

Measured memory_bytes: 128
//Registration

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define fi first
#define se second
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<int,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18
int a,b,ans=0;string s,ss;

int main (){
    cin>>s>>ss;
    bool flag = true;
    if(s.size()+1!=ss.size())flag=false;
    rep(i,0,s.size()){
        if(s[i]!=ss[i])flag=false;
    }
    cout << (flag ? "Yes" :"No")<<nnn;
    return 0;
}

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

#define FOR(i, j, n) for (int i(j); i < n; ++i)
#define FORR(v, c) for (auto &v : c)
#define F first
#define S second
#define SQ(x) (x)*(x)
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define dbg(x) cerr<<#x<<" = " << (x) << endl
#define pnl(x) cout << x << '\n'
#define pns(x) cout << x << ' '
#define read(x) cin >> x
#define read2(x,y) cin >> x >> y
#define read3(x, y, z) cin >> x >> y >> z
#define read4(a, b, c, d) cin >> a >> b >> c >> d
#define readv(v) FORR(c,v) read(c)

struct Arrete { int v, c;};
struct Point {int x, y; double distance(Point other) const {return sqrt(SQ(x-other.x)+SQ(y-other.y));}};

typedef	vector<int>	vi;
typedef pair<int,int>	ii;
typedef vector<string>	vs;
typedef vector<ii>	vii;
typedef vector<Arrete>	vg;
typedef vector<long long>	vl;
typedef	long long ll;

const int MAXN = 1e3;
const int MOD = 1e9+7;

bool is_free[MAXN][MAXN];
ll dp[MAXN][MAXN];
int H, W;

int		main(void)
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	read2(H, W);
	FOR(i,0, H) FOR(j,0, W)
	{
		char c;
		read(c);
		is_free[i][j] = (c == '.');
	}
	dp[0][0] = 1;
	FOR(i, 0, H) FOR(j, 0, W)
	{
		if (!is_free[i][j]) continue;
		if (i)
			dp[i][j] = (dp[i][j] + dp[i-1][j])%MOD;
		if (j)
			dp[i][j] = (dp[i][j] + dp[i][j-1])%MOD;
	}

	cout << dp[H-1][W-1] << endl;

}



Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define endl '\n'
#define SORT(c) sort((c).begin(), (c).end())
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>())
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    if (N >= 64) {
        cout << "64" << endl;
    } else if (N >= 32) {
        cout << "32" << endl;
    } else if (N >= 16) {
        cout << "16" << endl;
    } else if (N >= 8) {
        cout << "8" << endl;
    } else if (N >= 4) {
        cout << "4" << endl;
    } else if (N >= 2) {
        cout << "2" << endl;
    } else {
        cout << "1" << endl;
    }
}


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

using namespace std;


typedef long long ll;
ll mod=1e9+0LL;
ll MOD=1e18+0LL;
ll md=1000000007;

const double PI=acos(-1);

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

#define     sz(v)       ((int)((v).size()))
#define     all(v)      ((v).begin()),((v).end())
#define     pb           push_back
#define     ff           first
#define     ss           second
#define     line         printf("\n")
#define     gap          ' '
#define     ctn          continue;
#define     linebreak    printf("******************************\n")
ll poW(ll a ,ll n)
{
    if(n==0) return 1;
    if(n%2==0)
    {
        ll b=poW(a,n/2);
        return (b*b)%md;
    }
    return (poW(a,n-1)*a)%md;
}
bool cmp(const pii &a,const pii &b)     { return (a.ff*b.ss) < (a.ss*b.ff);}
bool isOdd(int n)       { return (n%2)!=0; }
template <class T>
void printVector(vector <T> &v,string s="")
{
    cout<<s;
    for(int i=0;i<sz(v);i++)
    {
        cout<<v[i]<<gap;
    }
    line;
}

int toInt(string str) {
	int num;
	istringstream iss(str);
	iss>>num; return num;
}

template <class T> string toStr(T par) {
	ostringstream oss;
	oss<<par;
	return oss.str();
}

void sieve(vector<int>&v)
{
    int i,j;
    v.pb(1);
    bool visit[1002];
    memset(visit,0,sizeof(visit));
    for(i=2;i<=1001;i++)
    {
        if(!visit[i])
        {
            for(j=i*i;j<=1001;j+=i)
            {
                visit[j]=1;
            }
            v.pb(i);
            //cout<<i<<gap<<v.back();line;
        }
    }
}
bool isPrime(int x) {
	if (x < 2) return false;
	for (int y = 2; y * y <= x; y++)
		if (x % y == 0)
			return false;
	return true;
}
bool trip(pair<int,pair<int,int> >p,pair<int,pair<int,int> >q)
{
    int id1=p.ff;
    int id2=q.ff;

    int val1=p.ss.ff;
    int val2=q.ss.ff;

    int sid1=p.ss.ss;
    int sid2=q.ss.ss;

    if(id1==id2)
    {
            return sid1<sid2;
    }
    return val1<val2;
}

ll maxSubArraySum(vector<int>&v)
{
    ll sum=0,mx=0;
    for(int i=0;i<sz(v);i++)
    {
        sum=max((ll)v[i],sum+v[i]);
        mx=max(mx,sum);
    }
    return mx;
}

int main()
{
    int cs=1;
    //scanf("%d",&cs);
    while(cs--)
    {
        ll n,m,k;
        cin>>n>>m>>k;
        ll i,j,ans=0;
        ll a[n+1]={0},b[m+1]={0};
        for(i=1;i<=n;i++)
        {
            cin>>a[i];
             a[i]+=a[i-1];
        }
        for(j=1;j<=m;j++)
        {
            cin>>b[j];
             b[j]+=b[j-1];
        }
        j=m;
        for(i=0;i<=n;i++)
        {//cout<<i<<" I"<<endl;
            if(a[i]>k) break;
            while(b[j]>(k-a[i]))
            {
                j--;
            }
            ans=max(ans,i+j);
        }
        cout<<ans;
    }
}


Measured memory_bytes: 6744
import sys
from collections import deque
input = sys.stdin.readline

n = int(input())

ab = []
adj = [[] * (n+1) for _ in range(n+1)]

for i in range(n-1):
    a, b = list(map(int, input().split()))
    ab.append([a, b])
    adj[a].append(b)
    adj[b].append(a)

m = [0] * (n+1)
for a, b in ab:
    m[a] += 1
    m[b] += 1

k = max(m)
print(k)

visited = [False] * (n+1)
label = [(0, 0)] * (n+1)

j = m.index(k)

q = deque([j])
visited[j] = True
while len(q) > 0:
    v = q.popleft()
    l = 0
    for w in adj[v]:
        if not visited[w]:
            l += 1
            if label[v][1] == l:
                l += 1
            label[w] = (v, l)
            visited[w] = True
            q.append(w)

#print(adj)

for a, b in ab:
    if label[a][0] == b:
        print(label[a][1])
    else:
        print(label[b][1])

Measured memory_bytes: 105796
n = gets.to_i
a = (1..n).map { gets.to_i }.sort
divs = (1..a[-1]).select {|x| a[-1] % x == 0}
s = 0
i = 0
until a.empty?
    x = a.shift
    i += 1 until i == divs.size - 1 or divs[i] >= x
    s += divs[i] - x
end
p s


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n,k; cin>>n>>k;
    int cnt[(ll)1e6]={};
    rep(i,n){
        ll a; cin>>a;
        cnt[a-1]++;
    }
    sort(cnt,cnt+n);
    ll ans=0;
    rep(i,n-k) ans+=cnt[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 7536
#include<bits/stdc++.h>
using namespace std;
#define maxn 100005
char s[maxn];
int f[maxn][2];
int main(){
	scanf("%s",s+1);
	int i;
	for(i=1;s[i];i++){
		f[i][0]=1;
		if(s[i-1]=='R'&&s[i]=='R'){
			f[i][0]+=f[i-1][1],f[i][1]+=f[i-1][0];
		}
	}
	for(i=i-1;s[i];i--){
		if(s[i+1]=='L'&&s[i]=='L'){
			f[i][0]+=f[i+1][1],f[i][1]+=f[i+1][0];
		}
	}
	for(int i=1;s[i];i++){
		if(s[i]=='R'&&s[i+1]=='L'){
			printf("%d %d ",f[i][0]+f[i+1][1],f[i][1]+f[i+1][0]);i++;
		}
		else printf("0 ");
	}
	return 0;
}

Measured memory_bytes: 1280
def primelist(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
  
x = int(input())

list = primelist(x*2)
print(min([i for i in list if i>=x]))


Measured memory_bytes: 40688
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n, k;
    cin >> n >> k;
    int sum = ((n-2) * (n-1)) / 2;
    if (k > sum){
        cout << -1 << endl;
        return 0;
    }

    vector<P> g;
    for(int i = 1; i < n; i++){
        g.push_back(make_pair(i, n));
    }
    for(int i = 1; i < n; i++){
        for(int j = i+1; j < n; j++){
            g.push_back(make_pair(i, j));
        }
    }
    cout << sum-k+(n-1) << endl;
    for(int i = 0; i < sum-k+n-1; i++){
        printf("%d %d\n", g[i].first, g[i].second);
    }
    return 0;
}

Measured memory_bytes: 3844
/// --- In the name of ALLAH --- ///


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


typedef long long              ll;
typedef vector<int>            vi;
typedef vector<ll>             vl;
typedef vector<vi>             vvi;
typedef vector<vl>             vvl;
typedef pair<int,int>          pii;
typedef pair<double, double>   pdd;
typedef pair<ll, ll>           pll;
typedef vector<pii>            vii;
typedef vector<pll>            vll;
typedef double                 dl;

#define endl                   '\n'
#define PB                     push_back
#define F                      first
#define S                      second
#define all(a)                 (a).begin(),(a).end()
#define rall(a)                (a).rbegin(),(a).rend()
#define sz(x)                  (ll)x.size()
#define wt                     ll t; cin>>t; while(t--)
#define input(a,n)             for(int i=0;i<n;i++) cin>>a[i];

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;


#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))
#define mod 10000007
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }


const ll mx=1e9;



//q=51;

//ll b[q+1][q+1];


 main()
{
    optimize();
    ll n,i;
    cin>>n;
    ll a[n+1];
    for(i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    cout<<a[n]-a[1]<<endl;









    return 0;
}






























































































Measured memory_bytes: 3648
//
// Created by 和田邦彦 on 2020/02/16.
//

#include <iostream>
#include <string>

using namespace std;

int main() {
    string s, t;
    int ns, nt;
    string dec;

    cin >> s >> t;
    cin >> ns >> nt;
    cin >> dec;
    if (dec == s) {
        ns--;
    } else {
        nt--;
    }

    cout << ns << " " << nt << endl;

    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

bool dp[80][80][159 * 80];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int h, w;
    cin >> h >> w;

    vector< vector<int> > a(h, vector<int>(w));
    rep(i, h){
        rep(j, w){
            cin >> a[i][j];
        }
    }

    vector< vector<int> > v(h, vector<int>(w));
    rep(i, h){
        rep(j, w){
            int b;
            cin >> b;
            v[i][j] = abs(a[i][j] - b);
        }
    }

    dp[0][0][v[0][0]] = true;

    rep(i, h){
        rep(j, w){
            rep(k, 159 * 80){
                if(i + 1 < h){
                    if(k + v[i + 1][j] < 159 * 80) dp[i + 1][j][k + v[i + 1][j]] |= dp[i][j][k];
                    dp[i + 1][j][abs(k - v[i + 1][j])] |= dp[i][j][k];
                }
                if(j + 1 < w){
                    if(k + v[i][j + 1] < 159 * 80) dp[i][j + 1][k + v[i][j + 1]] |= dp[i][j][k];
                    dp[i][j + 1][abs(k - v[i][j + 1])] |= dp[i][j][k];
                }
            }
        }
    }

    int ans = IINF;
    rep(k, 159 * 80){
        if(dp[h - 1][w - 1][k]){
            chmin(ans, k);
        }
    }

    cout << ans << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 79872
/*

This Submission is to determine how many 120/240 min const. delivery point there are.

//info
120 req. steps <= 5
*/
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 1000000007
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)

unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(min((double)1.0, max((double)-1.0, cosine)));
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		double now_length = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa - now_min >= eps||(abs(goa - now_min) <= eps&&(abs(a[i] - a[starter]) - now_length) >= eps)) {
					now_min = goa;
					now_go = i;
					now_length = abs(a[i] - a[starter]);
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
int main() {
	int a, b;
	cin >> a >> b;
	int now = 1;
	REP(i, 10000) {
		if (now >= b) {
			cout << i << endl;
			return 0;
		}
		now += a - 1;
	}
}

Measured memory_bytes: 764
import java.util.HashMap;
import java.util.Scanner;

/**
 * Course ITP1 # 6 B
 *
 * Finding Missing Cards
 *
 * @author misago_jp
 */
public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = Integer.parseInt(s.next());
		boolean[][] cards = new boolean[4][13];
		Character[] its = new Character[]{'S', 'H', 'C', 'D'};
		HashMap<String, Integer> sti = new HashMap<String, Integer>();
		sti.put("S", 0);
		sti.put("H", 1);
		sti.put("C", 2);
		sti.put("D", 3);

		for (int i = 0; i < n; ++i) {
			cards[sti.get(s.next())][Integer.parseInt(s.next()) - 1] = true;
		}
		for (int i = 0; i < 4; ++i) {
			for (int j = 0; j < 13; ++j) {
				if (!cards[i][j]) {
					System.out.println(its[i] + " " + (j + 1));
				}
			}
		}
	}
}

Measured memory_bytes: 17368
#include<iostream> 
#include<stdio.h>
#include<string>
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (int i = 0; i < (n); ++i)	
//setprecision(16)

void outi(int x) { cout << x << endl; }
void outl(ll x) { cout << x << endl; }
void outs(string x) { cout << x << endl; }
ll max(ll a, ll b) {
	ll max;
	if (a > b) max = a;
	else max = b;
	return max;
}
ll min(ll a, ll b) {
	ll min;
	if (a < b) min = a;
	else min = b;
	return min;
}
int gcd(int x, int y) {
	/*最大公約数 O(log MAX_X)*/
	if (y == 0) return x;
	return gcd(y, x % y);
}
//---------------------------------------------------------------

int main() {
	int a;
	cin >> a;
	cout << a + a * a + a * a * a << endl;

}

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

int main(){
    int N,R;
    cin >> N >> R;
    if (N < 10){
        cout << 100 * (10 - N) + R << endl;
    }
    else {
        cout << R << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair < int , int > pii;
#define mpr make_pair
#define FS first
#define SC second
#define PB push_back
template < typename T > void UMAX(T &a,T b){a=(a>b?a:b);}
template < typename T > void UMIN(T &a,T b){a=(a<b?a:b);}
LL readint(){
	char c=getchar();
	LL ret=0ll;
	bool neg=0;
	while(!(c>='0' && c<='9')){
		if(c=='-') neg=1;
		c=getchar();
	}
	while(c>='0' && c<='9'){
		ret=ret*10ll+(LL)(c-'0');
		c=getchar();
	}
	return neg?-ret:ret;
}
void putint(LL v){
	if(v<0){
		putchar('-');
		v=-v;
	}
	if(!v){
		putchar('0');
		return;
	}
	if(v>=10ll) putint(v/10ll);
	putchar('0'+(v%10ll));
}
LL N;
LL gcd(LL A,LL B){
	if(!B) return A;
	return gcd(B,A%B);
}
void exgcd(LL A,LL B,LL &X,LL &Y){// AX-BY=1
	if(!B){
		X=1;Y=0;
		return;
	}
	exgcd(B,A%B,X,Y);
	LL nX=-Y,nY=-X-(A/B)*Y;
	if(nX<0){
		LL mtp=(-nX+B-1)/B;
		nX+=B*mtp;
		nY+=A*mtp;
	}
	if(nY<0){
		LL mtp=(-nY+A-1)/A;
		nX+=B*mtp;
		nY+=A*mtp;
	}
	LL mtp=min(nX/B,nY/A);
	nX-=B*mtp;
	nY-=A*mtp;
	X=nX;Y=nY;
}
void exgcd2(LL A,LL B,LL &X,LL &Y){
	if(A==1){
		X=B+1;
		Y=1;
		return;
	}
	if(B==1){
		X=1;
		Y=A-1;
		return;
	}
	exgcd(A,B,X,Y);
}
int main(){
	int i,j,k;
	N=readint()*2;
	LL res=(LL)8e18;
	for(i=1;(LL)i*i<=N;++i){
		if(N%i) continue;
		if(gcd(i,N/i)>1) continue;
		LL x,y;
		exgcd2(i,N/i,x,y);
		UMIN(res,x*i-1);
		exgcd2(N/i,i,x,y);
		UMIN(res,y*i);
	}
	printf("%lld\n",res);
	return 0;
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
#define N 100005
using namespace std;
char str[N];
int main(void)
{   int n,m;
    cin>>str;
    int l = strlen(str);
    for(int i = 0;i < l;i++)
    {
        if(i%2==0)
            cout<<str[i];
    }
    return 0;
}


Measured memory_bytes: 384
n = int(input())
a = list(map(int, input().split()))

b = []
for i in a:
    c = 0
    count = 0
    while c == 0:
        c = i % 2
        i = i //2
        if c == 0:
            count += 1
    b.append(count)

print(sum(b))

Measured memory_bytes: 4148
#include <iostream>
#include <algorithm>

using namespace std;

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

    long long in_k, i, j, k, sum = 0;


    cin >> in_k;
    //in_k = l;

    for(i = 1; i <= in_k; i++)
        for(j = 1; j <= in_k; j++)
            for(k = 1; k<= in_k; k++)
                sum+=__gcd(i,__gcd(j,k));

    cout << sum << "\n";

    return 0;
}


Measured memory_bytes: 3640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a % 500 <= b) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
//const ll MOD=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(0);
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

void solve(int ca){
    int N,M; cin>>N>>M;
    vector<int> to[100010];
    int cnt[100010]={0};
    int ans[100010]={0};
    for (int i = 0; i < N + M - 1; ++i) {
        int a,b; cin>>a>>b;
        to[a].push_back(b);
        to[b].push_back(a);
        cnt[b]++;
    }
    int root=0;
    for (int i = 1; i <= N; ++i) {
        if(cnt[i]==0) {
            root=i;
            break;
        }
    }
    queue<int> q;
    q.push(root);
    while(!q.empty()){
        int node =q.front();
        q.pop();
        //cout<<node<<endl;
        for(auto i:to[node]){
            --cnt[i];
            if(cnt[i]!=0){
                continue;
            }
            ans[i]=node;
            q.push(i);
        }
    }
    for(int i=1;i<=N;++i){
        cout<<ans[i]<<endl;
    }

}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  int MOD = 1e9+7;

  vector<vector<int>> DP(N + 1, vector<int> (13));
  DP.at(0).at(0) = 1;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 13; j++) {
      if (S.at(i) == '?') {
        for (int k = 0; k < 10; k++) {
          (DP.at(i + 1).at((j * 10 + k) % 13) += DP.at(i).at(j)) %= MOD;
        }
      } else {
        int s = S.at(i) - '0';
        (DP.at(i + 1).at((j * 10 + s) % 13) += DP.at(i).at(j)) %= MOD;
      }
    }
  }

  cout << DP.at(N).at(5) << "\n";
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n+2);
    a[0] = 0; a[n+1] = 0;
    int sum = 0;
    rep(i,n) {
        int ai;
        cin >> ai;
        a[i+1] = ai;
        sum += abs(a[i+1] - a[i]);
    }
    sum += abs(a[n+1] - a[n]);
    for (int i=1; i<=n; i++) {
        cout << sum - abs(a[i-1] - a[i]) - abs(a[i] - a[i+1]) + abs(a[i-1] - a[i+1]) << endl;
    }
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ll n;cin >> n;
  ll good = 1;
  for(ll i=1; i*i<=n; i++){
    if(n%i==0)good = i;
  }
  
  cout << good + n/good -2 << endl;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define en '\n'
#define fs first
#define sd second

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s1, s2;
    cin >> s1 >> s2;
    bool res = true;
    if(s1.size() == int(s2.size())-1){
        s2.pop_back();
        res = s1 == s2;
    }else{
        res = false;
    }
    cout << (res ? "Yes" : "No") << en;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main()
{
int A;
int B;
int C;
cin>>A;
cin>>B;
cin>>C;

if( A==B+C || B==A+C || C==A+B){
cout<<"Yes";
}
else{
cout<<"No";
}

return 0;
}



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

    long long int a,b,k;
    cin >> a >> b >> k;

    if(k >= a){
        k -= a;
        a = 0;
    }else{
        a -= k;
        k = 0;
    }

    if(k >= b){
        k -= b;
        b = 0;
    }else{
        b -= k;
        k = 0;
    }  

    cout << a << " " << b << endl;

}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto s = sort(readln.chomp.to!(char[]).array).to!string;
  auto t = sort(readln.chomp.to!(char[]).array);
  t.reverse;
  auto td = t.to!string;
  if (s < td) {
    writeln("Yes");
  } else {
    writeln("No");
  }
}


Measured memory_bytes: 256
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
typedef long long ll;
const int Imx=2147483647;
const int mod=1000000007;
const ll Lbig=2e18;
//My own input/output stream
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putsp()
#define putii(x,y) puti(x),putnum(y),putsp()
#define putiii(x,y,z) putii(x,y),putnum(z),putsp()
#define putsi(x) putnum(x),putendl()
#define putsii(x,y) puti(x),putnum(y),putendl()
#define putsiii(x,y,z) putii(x,y),putnum(z),putendl()
inline ll getnum()
{
	register ll r=0;register bool ng=0;register char c;c=getchar();
	while(c!='-'&&(c<'0'||c>'9'))c=getchar();
	if(c=='-')ng=1,c=getchar();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=getchar();
	if(ng)r=-r;return r;
}
template <class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline void putsp(){putchar(' ');}
inline void putendl(){putchar('\n');}
inline char mygetchar(){register char c=getchar();while(c==' '||c=='\n')c=getchar();return c;}
int n;
int main()
{
	int p;
	cin>>n>>p;
	ll dp[2]={1,0};
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		if(x&1)
		{
			ll tmp=dp[0];
			dp[0]+=dp[1];
			dp[1]+=tmp;
		}
		else dp[0]+=dp[0],dp[1]+=dp[1];
	}
	cout<<dp[p]<<endl;
	return 0;
}

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

int main(){
    int n,k;string ss;cin>>n>>k>>ss;
    vector<ll> a,s(1,0);

    int count=1;
    for(int i=1;i<n;i++){
        if(ss.at(i-1)!=ss.at(i)){
            a.push_back(count);
            count=1;
        }else count++;
    }
    a.push_back(count);

    int na=a.size();
    REP(i,na) s.push_back(s.at(i)+a.at(i));

    ll ans=0;
    for(int i=ss.at(0)-'0'-1;i<na;i+=2){
        int l=max(0,i),r=min(i+2*k+1,na);
        ans=max(ans,s.at(r)-s.at(l));
    }
    cout<<ans;
}

Measured memory_bytes: 2676
N,K=map(int, input().split())
ans = 0.0
for i in range(1,N+1):
  Z = 0
  S = i
  while True:
    if K <= S:
      break
    Z += 1
    S = S * 2
  ans += (1.0 / N) * pow(0.5, Z)
print(ans)

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

int main(){
  int n;
  cin >> n;
  if(n>=400 && n<=599)
    cout << "8\n";
  else if(n>=600 && n<=799)
    cout << "7\n";
  else if(n>=800 && n<=999)
    cout << "6\n";
  else if(n>=1000 && n<=1199)
    cout << "5\n";
  else if(n>=1200 && n<=1399)
    cout << "4\n";
  else if(n>=1400 && n<=1599)
    cout << "3\n";
  else if(n>=1600 && n<=1799)
    cout << "2\n";
  else if(n>=1800 && n<=1999)
    cout << "1\n";
  else {}
	return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define ll long long 
#define inf 0x7fffffff
#define clr(c) memset(c,0,sizeof(c))
using namespace std;
int mod=998244353;
const int M=1e6+10;
const int N=2e5+10;
inline ll read(){
    ll b=1,sum=0; char c=getchar();
    while(!isdigit(c)){if(c=='-') b=-1; c=getchar();}
    while(isdigit(c)){sum=sum*10+c-'0'; c=getchar();}
    return b*sum;
}
int n,m,k,T;
int len,ans;
char s[M]; 
int a[M],vis[3]; 
int C(int y,int x) {
	if(x>y) return 0;
	return 1;
}
int lucas(int y,int x) {
	if(x==0) return 1;
	return C(y%mod,x%mod)*lucas(y/mod,x/mod);
}
int main() 
{
    int i,j;
    n=read();
	scanf("%s",s+1);
	mod=2;
	bool f=0;
	for(i=1;i<=n-1;i++) {
		a[i]=abs(s[i+1]-s[i]);
		if(a[i]==1) f=1;
	}
	if(f==0) {
		for(i=1;i<=n;i++) a[i]/=2;
	}
	for(i=1;i<=n-1;i++) {
		ans+=lucas(n-2,i-1)*a[i];
		ans%=2;
	}


	if(f==0) ans*=2;
	printf("%d",ans);
    return 0;
}


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

int main() {
  int A, B;
  string S;
  
  cin >> A >> B;
  cin >> S;
  if (S.size() == A + B + 1 && S.at(A) == '-'){
    for(int i = 0; i < S.size(); i++){
        if (i != A && S.at(i) == '-'){
          cout << "No" << endl;
          exit(0);
        }
    }
  }
  else {
    cout << "No" << endl;
    exit(0);
  }
  
  cout << "Yes" << endl;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  long long A, B;
  cin >> A >> B;
  long long gcd = __gcd(A, B);
  int ans = 1;
  long long t = gcd;
  for (long long i = 2; i * i <= gcd; i++) {
    ans += !(t % i);
    for (; t % i == 0;) t /= i;
  }
  ans += (t > 1);
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * C - Sum of gcd of Tuples (Easy)
 * K∑a=1  K∑b=1  K∑c=1 gcd(a,b,c) を求めてください。
 * ただし、gcd(a,b,c) は a,b,c の最大公約数を表します。
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        // 入力値
        long n = sc.nextLong();

        long sum = 0;
        for( int i = 1; i <= n; i++ ) {
            long gcd1 = 0;
            for( int j = 1; j <= n; j++ ) {
                gcd1 = gcd( i, j );
                for( int k = 1; k <= n; k++ ) {
                    sum += gcd( gcd1, k );
                }
            }
        }

        System.out.println( sum );

        sc.close();
    }

    /*
     * 最大公約数を求める
     */
    private static long gcd( long m, long n ) {
        if( m < n ) return gcd(n, m);
        if( n == 0 ) return m;
        return gcd( n, m % n );
    }
}


Measured memory_bytes: 36256
#include<iostream>
#include<string>
using namespace std;
#define LL long long

LL a,b;
LL n;
LL ans,bns;

int main()
{
	
	cin>>a>>b;
	b++;
	n=1;
	while(n<=a)
	{
		LL p=a/(n*2)*n;
		if(a%(n<<1)-n>0) p+=a%(n<<1)-n;
		if(p&1) ans+=n;
		n<<=1;
	}
	n=1;
	while(n<=b)
	{
		LL p=b/(n<<1)*n;
		if(b%(n<<1)-n>0) p+=b%(n<<1)-n;
		if(p&1) bns+=n;
		n<<=1;
	}
	cout<<(ans^bns)<<'\n';
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX_N 200000
#define sum(l,r) (s[r]-s[l])
using namespace std;
typedef unsigned long long lnt;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n; lnt m, s[MAX_N+5];
int main() {
	read(n), read(m);
	for (int i = 1; i <= n; i++)
		read(s[i]), s[i] += s[i-1];
	lnt mi = s[n]*5+m*n*2, tot;
	for (int i = 1; i <= (n+1)/2; mi = min(mi, tot), i++) {
		tot = m*(n+i)+sum(max(0, n-2*i), n)*5; lnt c = 7;
		for (int j = n-2*i; tot < mi && j > 0; j -= i, c += 2)
			tot += sum(max(0, j-i), j)*c;
	}
	return printf("%llu\n", mi), 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
const int MAX = 510000;
const int 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 COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
	ll n,k;
	cin>>n>>k;
	ll ans=0;
    COMinit();
    // 計算例
    //cout << COM(100000, 50000) << endl;	
	for(ll i=0;i<=min(n,k);i++){
		ll cnt=0;
		cnt+=COM(n,i);
		cnt*=COM(n-1,i);
		ans+=cnt;
		ans%=inf;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

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

using namespace std;

#define MXN 100005

typedef pair<int,int> PII;

int a[MXN], b[MXN];
vector<PII> v;

int main() { 
    long long int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
        v.push_back(make_pair(a[i], b[i]));
    }
    sort(v.begin(), v.end());
    long long int cur = 0;
    for (int i = 0; i < v.size(); ++i) {
        cur += v[i].second;
        if (cur >= k) {
            cout << v[i].first << "\n";
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 1912
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String[] sArray = s.split("");
		String end = getEnd(sArray);
		if(s.endsWith(end)) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}

	private static String getEnd(String[] sArray) {
		String end = "keyence";
		if(!sArray[0].equals("k")) {
			return end;
		}
		end = end.substring(1);
		if(!sArray[1].equals("e")) {
			return end;
		}
		end = end.substring(1);
		if(!sArray[2].equals("y")) {
			return end;
		}
		end = end.substring(1);
		if(!sArray[3].equals("e")) {
			return end;
		}
		end = end.substring(1);
		if(!sArray[4].equals("n")) {
			return end;
		}
		end = end.substring(1);
		if(!sArray[5].equals("c")) {
			return end;
		}
		end = end.substring(1);
		if(!sArray[6].equals("e")) {
			return end;
		}
		end = end.substring(1);
		return end;
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template< typename T, typename V > typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) { t = v; }
template< typename T, typename V > typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e, v); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

string S;
int dp[100010][13];

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> S;
  dp[0][0] = 1;
  for (int i = 0; i < S.size(); i++) {
    for (int j = 0; j < 13; j++) {
      if (dp[i][j] == 0) continue;
      if (S[i] != '?') {
        (dp[i+1][(j*10+(S[i]-'0'))%13] += dp[i][j]) %= MOD;
      } else {
        for (int d = 0; d < 10; d++) {
          (dp[i+1][(j*10+d)%13] += dp[i][j]) %= MOD;
        }
      }
    }
  }
  cout << dp[S.size()][5] << endl;

  return 0;
}

Measured memory_bytes: 10704