akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LL long long
#define INF 0x3f3f3f3f
#define lc (x << 1)
#define rc (x << 1 | 1)
#define F0 q[top[0]][0]
#define F1 q[top[1]][1]
using namespace std;

template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

/*============ Header Template ============*/

const int N = 300000 + 5;

int W, H, n;
int mx[N << 2], tag[N << 2];
int top[2];

struct node {int x, y, w;} p[N], q[N][2];
int cmp(const node &a, const node &b) {return a.x < b.x;}

void upd(int x) {
	mx[x] = max(mx[lc], mx[rc]);
}

void build(int x, int l, int r) {
	mx[x] = tag[x] = 0;
	if (l == r) return;
	int m = (l + r) >> 1;
	build(lc, l, m);
	build(rc, m + 1, r);
}

void make_tag(int x, int val) {
	mx[x] += val;
	tag[x] += val;
}

void push_down(int x) {
	if (tag[x]) {
		make_tag(lc, tag[x]);
		make_tag(rc, tag[x]);
		tag[x] = 0;
	}
}

void modify(int x, int l, int r, int s, int t, int val) {
	if (s > t) return;
	// if (x == 1) printf("BOO %d %d %d\n", s, t, val);
	if (s <= l && r <= t) {make_tag(x, val); return;}
	push_down(x);
	int m = (l + r) >> 1;
	if (s <= m) modify(lc, l, m, s, t, val);
	if (m < t)  modify(rc, m + 1, r, s, t, val);
	upd(x);
}

int getmax(int x, int l, int r, int s, int t) {
	if (s <= l && r <= t) return mx[x];
	push_down(x);
	int m = (l + r) >> 1, ans = 0;
	if (s <= m) ans = max(ans, getmax(lc, l, m, s, t));
	if (m < t)  ans = max(ans, getmax(rc, m + 1, r, s, t));
	return ans;
}

int solve() {
	sort(p + 1, p + n + 1, cmp);
	top[0] = top[1] = 0;
	int ans = max(W, H), num = n;
	if (p[n].x != W) p[++num] = (node) {W, H};
	// printf("num = %d\n", num);
	// for (int i = 1; i <= num; i++) printf("%d %d\n", p[i].x, p[i].y);
	build(1, 1, num);
	for (int i = num; i; i--) {
		if (i < num) {
			// printf("x = %d ans = %d\n", i, getmax(1, 1, num, i + 1, num) - p[i].x);
			ans = max(ans, getmax(1, 1, num, i + 1, num) - p[i].x);
		}
		if (p[i].y <= H / 2) { // 1
			while (top[1] && F1.w < p[i].y) {
				modify(1, 1, num, F1.x, F1.y, F1.w);
				top[1]--;
			}
			q[top[1] + 1][1] = (node) {i + 1, top[1] ? F1.x - 1 : num, p[i].y}; top[1]++;
			modify(1, 1, num, F1.x, F1.y, -F1.w);
		} else { // 0
			while (top[0] && F0.w > p[i].y) {
				modify(1, 1, num, F0.x, F0.y, -F0.w);
				top[0]--;
			}
			q[top[0] + 1][0] = (node) {i + 1, top[0] ? F0.x - 1 : num, p[i].y}; top[0]++;
			modify(1, 1, num, F0.x, F0.y, F0.w);
		}
		q[++top[1]][1] = (node) {i, i, 0};
		q[++top[0]][0] = (node) {i, i, H};
		modify(1, 1, num, i, i, p[i].x + H);
	}
	if (p[1].x) ans = max(ans, getmax(1, 1, num, 1, num));
	return ans;
}

int main() {
	read(W), read(H), read(n);
	for (int i = 1; i <= n; i++) read(p[i].x), read(p[i].y);
	int ans = solve();
	for (int i = 1; i <= n; i++) swap(p[i].x, p[i].y); swap(W, H);
	ans = max(ans, solve());
	// ans = solve();
	printf("%d\n", ans * 2);
	return 0;
}

Measured memory_bytes: 17536
n = int(input()) - 1
i = 1
s = 26

while n >= s:
    n -= s
    s *= 26
    i += 1

lst = []
for j in range(i):
    lst.append(n % 26)
    n //= 26

for j in lst[::-1]:
    print(chr(j + ord('a')), end='')

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    ll l = 0, r = 1e10;
    while (r-l > 1) {
        ll c = (l+r)/2;
        ll cnt = 0;
        for (int i = 0; i < N; i++) {
            cnt += (A[i]+c-1)/c-1;
        }
        if (cnt <= K) r = c;
        else l = c;
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 4836
#include <iostream>
#include <fstream>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
#include <cassert>
#include <random>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back
#define FOR(i, n) for(int i = 0; i < (n); i++)
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

const int mod = 1e9 + 7;
const int mod2 = 998244353;

void fact_init(int n);
ll exp(ll taban, ll us, ll md);
ll ebob(ll a, ll b);
ll ekok(ll a, ll b);
ll komb(ll a, ll b);

vector<ll> fact;
vector<ll> inv_fact;
void fact_init(int n){
    fact.resize(n+5);
    inv_fact.resize(n+5);
    fact[0] = inv_fact[0] = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = (fact[i-1] * i) % mod;
        inv_fact[i] = exp(fact[i], mod-2, mod);
    }
}
ll exp(ll taban, ll us, ll md) {
    ll carpan = taban % md;
    if(carpan == 0) return 0;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % md;
        temp /= 2;
        carpan = (carpan*carpan) % md;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}

ll komb(ll a, ll b){
    if(a < b) return 0;
    return fact[a] * (inv_fact[a-b] * inv_fact[b] % mod) % mod;
}
const int N = 3e5 + 5;

int main(){
    ios::sync_with_stdio(false); cin.tie(NULL);
	#define int ll
	int n; cin>>n;
	vector<int> ar[2];
	/*
		0 -> /
		1 -> \
	*/
	vector<pii> vec(n);
	for(int i = 0; i < n; i++){
		int x, y; cin>>x>>y;
		ar[0].pb(y-x);
		ar[1].pb(y+x);
		vec[i] = {x, y};
	}
	SORT(ar[0]);
	SORT(ar[1]);
	
	cout<<max(ar[0][n-1] - ar[0][0], ar[1][n-1] - ar[1][0])<<"\n";
}

Measured memory_bytes: 8196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 998244353;
const ld PI = acosl(-1);

void merge(vector<pii> &v, pii &p, int &lim) {
    vector<pii> res;
    int nxt = 1, N = v.size();
    res.push_back({0, 0});
    for (int i = 0; i < N; ++i) {
        pii tmp = {v[i].first + p.first, v[i].second + p.second};
        while (nxt < N && v[nxt].first <= tmp.first)
            res.push_back(v[nxt++]);
        if (tmp.first <= lim)
            res.push_back(tmp);
    }
    swap(res, v);
}

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

    int N;
    cin >> N;
    vector<pii> A(N);
    for (int i = 0; i < N; ++i)
        cin >> A[i].second >> A[i].first;

    int Q;
    cin >> Q;
    for (int i = 0; i < Q; ++i) {
        int v, L;
        cin >> v >> L;

        vector<pii> sum1, sum2;
        sum1.push_back({0, 0});
        sum2.push_back({0, 0});
        for (int j = 0; v > 0; v >>= 1, ++j) {
            merge((j < 9 ? sum1 : sum2), A[v - 1], L);
        }

        int siz1 = sum1.size(), siz2 = sum2.size(), maxv = 0;
        for (int j = 0; j < siz1; ++j) {
            if (maxv < sum1[j].second)
                maxv = sum1[j].second;
            else
                sum1[j].second = maxv;
        }

        int idx = siz1 - 1, res = 0;
        for (int j = 0; j < siz2; ++j) {
            while (idx >= 0 && sum2[j].first + sum1[idx].first > L)
                idx--;
            if (idx >= 0)
                res = max(res, sum2[j].second + sum1[idx].second);
        }
        cout << res << '\n';
    }

    return 0;
}


Measured memory_bytes: 5264
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define int ll
#define ld double
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect

const int N = 4e5 + 7, MOD = 1e9 + 7;

int f[N] = {1}, rf[N] = {1};

int binpow(int x) {
    int ans = 1;
    int d = MOD - 2;
    while (d > 0) {
        if (d & 1)
            ans = ans * x % MOD;
        x = x * x % MOD;
        d >>= 1;
    }
    return ans;
}

int binom(int n, int k) {
    return f[n] * rf[k] % MOD * rf[n - k] % MOD;
}

void solve() {
    loop1(i, N - 1) {
        f[i] = f[i - 1] * i % MOD;
        rf[i] = binpow(f[i]);
    }
    int n, k;
    cin >> n >> k;
    int ans = 0;
    loop(i, min(k + 1, n))
        ans = (ans + binom(n, i) * binom(n - 1, i) % MOD) % MOD;
    cout << ans;
}
 
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

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

typedef long long int lli;

const int MOD = 1e9 + 7;
const int LIM = 1e5 + 5;
lli col[LIM];
lli fac[2*LIM];

int h, w, a, b;

lli powerr(int a, int b) {
	if(b == 0) {
		return 1;
	} else if(b == 1) {
		return a;
	} else {
		lli base = powerr(a, b/2);
		lli ans = base*base % MOD;
		if(b%2) {
			ans *= a;
			ans %= MOD;
		}
		return ans;
	}
}

void initFac() {
	fac[0] = fac[1] = 1;
	for(int i = 2; i < 2*LIM; i++) {
		fac[i] = i*fac[i-1];
		fac[i] %= MOD;
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> h >> w >> a >> b;

	initFac();

	for(int i = 0; i < h; i++) {
		if(i < h - a) {
			col[i] = fac[i + b];
			col[i] %= MOD;
			col[i] *= powerr(fac[i], MOD - 2);
			col[i] %= MOD;
			col[i] *= powerr(fac[b], MOD - 2);
			col[i] %= MOD;
		} else {
			col[i] = col[i-1];
		}
	}

	lli ans = 0;

	if(b + 1 != w) {
		for(int i = 0; i < h; i++) {
			lli term = col[i];
			term *= fac[h+w-i-b-3];
			term %= MOD;
			term *= powerr(fac[w-b-2], MOD-2);
			term %= MOD;
			term *= powerr(fac[h-i-1], MOD-2);
			term %= MOD;

			ans += term;
			ans %= MOD;
		}
	} else {
		ans = col[h-1];
	}

	cout << ans << endl;

	return 0;
}

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

int main()
{
	string S;
	cin >> S;
	const int target = 753;

	int mindif = INT_MAX;
	for (int i = 0; i <= S.length() - 3; i++) {
		int val = stoi(S.substr(i, 3));
		int dif =abs( val - target);
		if (dif < mindif) mindif = dif;
	}

	cout << mindif << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int R;
    cin >> R;
    if(R<1200){
        cout << "ABC" << endl;
    }else if(R<2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
}




Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main () {
  int a, b, c, d;
  a = b = c = d = 0;
  for (int i = 0; i < 3; i ++) {
    int p, q;
    cin >> p >> q;
    switch (p) {
      case 1: a ++;break;
      case 2: b ++;break;
      case 3: c ++;break;
      case 4: d ++;break;
    }
    switch (q) {
      case 1: a ++;break;
      case 2: b ++;break;
      case 3: c ++;break;
      case 4: d ++;break;
    }
  }
  if (a < 3 && b < 3 && c < 3 && d < 3) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

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

using namespace std;
using lint=long long;

const long long INF=1LL<<61;

lint a[6],d;
map<lint,lint> memo;

lint dfs(lint n){
	if(n==1) return d;

	if(memo.count(n)>0) return memo[n];

	lint res=INF;
	if(1.0*d*n<1e10) res=d*n;

	for(int x:{2,3,5}){
		lint next=n/x;
		if(1<=next && next<n) res=min(res,a[x]+d*(n-next*x)+dfs(next));
		next=(n+x-1)/x;
		if(1<=next && next<n) res=min(res,a[x]+d*(next*x-n)+dfs(next));
	}
	return memo[n]=res;
}

void solve(){
	lint n; cin>>n>>a[2]>>a[3]>>a[5]>>d;
	memo.clear();
	cout<<dfs(n)<<'\n';
}

int main(){
	int q; scanf("%d",&q); rep(_,q) solve();
	return 0;
}


Measured memory_bytes: 4492
#include <iostream>
#include <algorithm>
int main(){int n,k,l[51],a=0;std::cin>>n>>k;for(int i=0;i!=n;++i)std::cin>>l[i];std::sort(l,l+n,std::greater<int>());for(int i=0;i!=k;++i)a+=l[i];std::cout<<a<<"\n";}

Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double h = sc.nextDouble();
        double m = sc.nextDouble();
        double x = (m*11/360 - h/6) * Math.PI;
		System.out.println(Math.pow(a*a+b*b-2*a*b*Math.cos(x), 0.5));
    }
}

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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
map<string,int>mp;
vector<string>v;
int main()
{
    int n;
    cin>>n;
    while(n--)
    {
        string s;
        cin>>s;
        sort(all(s));
        mp[s]++;
        v.pb(s);
    }
    LL ans=0;
    Unique(v);
    for(int i=0; i<v.size(); i++)
    {
        LL cnt=mp[v[i]];
//        cout<<v[i]<<" "<<cnt<<endl;
        ans+=((cnt-1)*cnt)/2;

    }
    cout<<ans;

}


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

int main() {
    long long n; cin >> n;
    
    long long mn = 1000000;
    for(long long a = 1; a * a <= n; ++a) {
        if(n % a == 0 && mn > a) mn = n / a;
    }
    
    int res = 0;
    while(mn) {
        mn /= 10;
        ++res;
    }
    
    cout << res << endl;
}


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;

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

    vector<int>p(n);
    rep(i,n){
        cin>>p[i];
    }

    int ans=1,now=p[0];

    rep2(i,1,n){
        if(now>=p[i]){
            ans++;
            now=p[i];
        }
    }

    cout<<ans<<endl;
}


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

bool chk[333][333];
int A[333][333];

int main() {
    int N; scanf("%d",&N);
    for(int i=1; i<=N; i++) {
        for(int j=1; j<=N; j++) {
            scanf("%d",&A[i][j]);
        }
    }
    for(int k=1; k<=N; k++) {
        for(int i=1; i<=N; i++) {
            for(int j=1; j<=N; j++) {
                if(A[i][k] + A[k][j] < A[i][j]) return !printf("-1");
                if(i != k && k != j && A[i][k] + A[k][j] == A[i][j]) chk[i][j] = 1;
            }
        }
    }
    long long ans = 0;
    for(int i=1; i<=N; i++) {
        for(int j=i+1; j<=N; j++) {
            if(!chk[i][j]) ans += A[i][j];
        }
    }
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 768
h, w = map(int, input().split())
A = []

for i in range(h):
    tmp = input()
    if(tmp != w*"."):
        A.append(tmp)

D = []

for j in range(w):
    flag = True
    for B in A:
        if(B[j] == "#"):
            flag = False
    if(flag):
        D.append(j)

for B in A:
    for j in range(w):
        if(j not in D):
            print(B[j], end="")
    print()


Measured memory_bytes: 4468
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


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

  int n,a,b;
  cin>>n>>a>>b;
  int ans=0;
  rep(i,n){
    int t;
    cin>>t;
    ans+=!(a<=t&&t<b);
  }

  cout<<ans<<endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(){
    int n, m;
    cin >> n >> m;
    vi(s,m);
    vi(c,m);
    rep(i,m){
        cin >> s[i] >> c[i];
    }
    /*
    rep(i,m){
        cout << s[i] << " " << c[i] << endl;
    }
    */
   if(n!=1){
        rng(i,pow(10,n-1),pow(10,n)){
            //int i = 702;
            bool ch = true;
            string st = to_string(i);
            //cout << "st:" << st << endl;
            rep(j,m){
                char di = '0' + c[j];
                if(st.at(s[j] - 1) != di){
                    ch = false;
                    //cout << j << endl;
                }
            }
            if(ch){
                cout << i << endl;

                return 0;
            }
            /*
            if(!ch){
                //cout << i << " is unsuitable" << endl;
                continue;
            }
            else{
                cout << i << endl;
                return 0;
            }
            */
        }
   }
   else{
       rng(i,0,pow(10,n)){
            bool ch = true;
            string st = to_string(i);
            rep(j,m){
                char di = '0' + c[j];
                if(st.at(s[j] - 1) != di){
                    ch = false;
                }
            }
            if(ch){
                cout << i << endl;
                return 0;
            }
        }
   }
    cout << -1 << endl;
    return 0;
}

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

#define ll long long
#define int long long
#define MOD 1000000007
#define MAX 100001
#define debugStart cout << "\n[DEBUG START]\n"
#define debugStop cout << "\n[DEBUG STOP]\n"
#define KHATAM cout << std::endl;


auto solve ( int* arr, int size ) -> int {

        int DP[size];
        memset(DP,0, sizeof(DP));
        DP[0] = 0;
        DP[1] = abs( arr[0] - arr[1] );
        for ( int i = 2; i < size; ++i ) {
                DP[i] = std::min( DP[i-1] + abs(arr[i] - arr[i-1]) , DP[i-2] + abs(arr[i] - arr[i-2]) );
        }        
        return DP[size - 1];
}
signed
main() {

        ios_base::sync_with_stdio(0);
        cin.tie(0);
        int T = 1; 
        // cin >> T;
        for ( int testcase = 1; testcase <= T; ++testcase ) {
                
                int size;
                std::cin >> size; 
                int arr[size];
                for ( int i = 0; i < size; ++i ) {
                        std::cin >> arr[i];
                }
                std::cout << solve(arr, size); 
                std::cout << '\n';
        }
        return 0;
}

Measured memory_bytes: 1792
<?php

$args = [];
$input = explode(' ', trim(fgets(STDIN)));

$n = (int)$input[0];
$x = (int)$input[1];

while(true){
	$input = explode(' ', trim(fgets(STDIN)));
	foreach ($input as $value) {
		if ($value !== '') {
			$args[] = (int)$value;
			++$cnt;
		}
		if (count($args) >= $n) {
			break;
		}
	}
	if (count($args) >= $n) {
		break;
	}
}

$args[] = $x;
sort($args);
$diff_array = [];
$length = count($args);
for ($i=1; $i < $length; $i++) { 
	$diff_array[] = $args[$i] - $args[$i-1];
}
$diff_array = array_unique($diff_array, SORT_NUMERIC);
sort($diff_array);
$min = $diff_array[0];

for ($i=$min; $i > 0; $i--) { 
	$flg = true;
	foreach ($diff_array as $value) {
		if ($value % $i !== 0) {
			$flg = false;
			break;
		}
	}
	if ($flg) {
		echo $i;
		break;
	}
}

Measured memory_bytes: 29036
using System;
using System.Linq;

namespace _20200502_B
{
    class Program
    {
        static void Main(string[] args)
        {
            // 文字列の入力
            //string s = Console.ReadLine();

            // 整数の入力
            long n = long.Parse(Console.ReadLine());

            // 文字列配列の入力
            //string[] inputStrArray = Console.ReadLine().Split(' ');

            // 整数配列の入力
            //long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            long money = 100;
            int year = 0; 
            while (money < n) 
            {
                long tmp = (long)(money* 0.01);
                money += tmp;
                year++;

            }
            Console.WriteLine(year);

        }
    }
}


Measured memory_bytes: 27480
import math
N= int(input())
nums = set()
f = lambda x: x//2 if x % 2 == 0 else 3 * x + 1
nums.add(N)
before = N

for i in range(1,1000005):
    new_num = f(before)

    if new_num in nums:
        print(i + 1)
        exit(0)
    else:
        nums.add(new_num)
        before = new_num

Measured memory_bytes: 3060
n = int(input())

r = n

for i in range(n+1):
    cnt = 0
    nine = n - i
    while i > 0:
        cnt += i % 6
        i = i // 6
    while nine > 0:
        cnt += nine % 9
        nine = nine // 9
    if r > cnt: r = cnt

print(r)



Measured memory_bytes: 2940
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    long long N, A, B; cin >> N >> A >> B;
    long long ans;
    if (~(A-B)&1) ans = (B-A)/2;
    else ans = min(A-1, N-B) + 1 + (B-A-1)/2;
    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const ll inf = 1e18 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll n;
ll a[200100];

ll dp[200100][3];

ll solve() {
    dp[0][0] = 0;
    dp[0][1] = -1e18;
    dp[0][2] = -1e18;
    dp[1][0] = 0;
    dp[1][1] = a[0];
    dp[1][2] = -1e18;
    for (int i = 2; i <= n; i++) {
        for (int j = 0; j < 3; j++) {
            int k = i / 2 + (j < 2 ? j : -1);
            int idx = -1;
            for (int p = 0; p < 3; p++) {
                if ((i-1) / 2 + (p < 2 ? p : -1) == k) {
                    idx = p;
                    break;
                }
            }
            if (idx >= 0) {
                dp[i][j] = dp[i-1][idx];
            } else {
                dp[i][j] = -1e18;
            }

            idx = -1;
            for (int p = 0; p < 3; p++) {
                if ((i-2) / 2 + (p < 2 ? p : -1) == k-1) {
                    idx = p;
                    break;
                }
            }
            if (idx >= 0) {
                dp[i][j] = max(dp[i][j], dp[i-2][idx]+a[i-1]);
            } else {
                dp[i][j] = -1e18;
            }
        }
    }
    
    return dp[n][0];
}

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

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 9396
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    char a,b; cin >> a >> b;
    if(a=='H'){
        if(b=='H') puts("H");
        else puts("D");
    }else{
        if(b=='H') puts("D");
        else puts("H");
    }
}


Measured memory_bytes: 256
while true
    n = gets.to_i
    if n == 0
        break
    end
    a = Array.new(n).map{Array.new(2,0)}
    for i in 0..n-1 do
        t = gets.split.map(&:to_i)
        a[i][0] = t[0]
        a[i][1] = t[1]
    end
    a = a.sort {|a,b| a[1]<=>b[1]}
    sum = 0
    b = true
    for i in 0..n-1 do
        sum += a[i][0]
        if sum > a[i][1]
            puts "No"
            b = false
            break
        end
    end
    if b
        puts "Yes"
    end
end

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

int nC2(int n){
  if(n <= 1){
    return 0;
  }else{
    return n*(n-1)/2;
  }
}

int main(){
  int N, M;
  cin >> N >> M;
  cout << nC2(N)+nC2(M) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int xx = 0;
		int yy = 0;
		int time = 0;
		for (int i = 0; i < n; i++) {
		    int t = sc.nextInt();
		    int x = sc.nextInt();
		    int y = sc.nextInt();
		    int d = Math.abs(x - xx) + Math.abs(y - yy);
		    int spent = t - time;
		    if (d > spent || (spent - d) % 2 != 0) {
		        System.out.println("No");
		        return;
		    }
		    xx = x;
		    yy = y;
		    time = t;
		}
		System.out.println("Yes");
	}
}


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

using namespace std;

int N, ap[20], E[100009], d[1 << 16], frm[1 << 16];
vector < pair < int, int > > h[100009];
vector < pair < int, int > > v[1 << 16];

void dfs (int nod, int tata)
{
    for (auto it : h[nod])
        if (it.first != tata)
            E[it.first] = it.second, dfs (it.first, nod), E[nod] ^= it.second;
}

priority_queue < pair < int, int > > PQ;
int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N);
for (int i=1; i<N; i++)
{
    int x, y, z;
    scanf ("%d %d %d", &x, &y, &z), x ++, y ++;
    h[x].push_back ({y, z});
    h[y].push_back ({x, z});
}
dfs (1, -1);
for (int i=2; i<=N; i++)
    ap[E[i]] ++;
int ans = 0, msk = 0;
for (int i=1; i<16; i++)
{
    if (ap[i] & 1) msk |= 1 << i;
    ans += (ap[i] >> 1);
}
for (int msk = 0; msk < (1 << 16); msk +=2)
    for (int i=1; i<16; i++)
        if (msk & (1 << i))
        {
            v[msk].push_back ({msk ^ (1 << i), 1});
            int aux = msk ^ (1 << i);
            for (int j=1; j<16; j++)
                if (aux & (1 << j))
                {
                    if (aux & (1 << (j ^ i))) v[msk].push_back ({aux ^ (1 << j) ^ (1 << (j ^ i)), 2});
                    else v[msk].push_back ({aux ^ (1 << j) ^ (1 << (j ^ i)), 1});
                }
        }
for (int i=0; i<(1 << 16); i++)
    d[i] = -1;
PQ.push ({0, msk}), d[msk] = 0;
while (!PQ.empty ())
{
    auto curr = PQ.top ();
    PQ.pop ();
    if (d[curr.second] != -curr.first) continue;
    int nod = curr.second;
    for (auto it : v[nod])
        if (d[it.first] == -1 || (d[it.first] > d[nod] + it.second))
            d[it.first] = d[nod] + it.second, PQ.push ({-d[it.first], it.first}), frm[it.first] = nod;
}
printf ("%d\n", ans + d[0]);
return 0;
}


Measured memory_bytes: 35200
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define mem0(s) memset(s,0,sizeof(s))
#define meminf(s) memset(s,0x3f,sizeof(s))
#define mp_insert(a,b,c) mp.insert(map<pair<int,int>,int>::value_type(make_pair(a,b),c))
double pi=acos(-1);
typedef long long ll;
typedef unsigned long long ull;
inline ll lowbit(ll x){return x&(-x);}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll max(ll a,ll b){return a>b?a:b;}
const int INF=0x3f3f3f3f,max_n=200005,mod=19260817;
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
inline ll pow(ll a,ll b,ll mod){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int a[9];
int b[9];
int count1;
int x=1;
int n;
bool f()
{
	for(int i=0;i<n;i++)
	{
		if(a[i]>b[i])
		{
			return true;
		}
		else if(a[i]==b[i])
		{
			continue;
		}
		else
		{
			return false;
		}
	}
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		x*=i;
	}
	for(int i=1;i<=n;i++)
	{
		cin>>b[i];
	}
	if(f())
	{
		swap(a,b);
	}
	while(1)
	{
		int flag=0;
		
		for(int i=1;i<=n;i++)
		{
			if(a[i]!=b[i])
			{
				flag=1;
			}
		}
		if(!flag)
		{
			break;
		}
		count1++;
		next_permutation(a+1,a+1+n);
	}
	cout<<count1;
}

Measured memory_bytes: 256
#include<stdio.h>
int M[100][100];

int main(void){
        int n;
        int i,j,u,k,v;

        scanf("%d",&n);
        for(i=0;i<n;i++){
                scanf("%d%d",&u,&k);
                u--;
                for(j=0;j<k;j++){
                        scanf("%d",&v);
                        v--;
                        M[u][v]=1;
                }
        }

        for(i=0;i<n;i++){
                for(j=0;j<n;j++){
                        if(j) printf(" ");
                        printf("%d",M[i][j]);
                }
                printf("\n");
        }

        return 0;
}

Measured memory_bytes: 636
#include<cstdio>
#include<vector>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<map>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=3e3+3;
const int MOD=1e9+7;
const double EPS=1e-12;
template <class T>
bool sf(T &ret){ //Faster Input
    char c; int sgn; T bit=0.1;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&c!='.'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    if(c==' '||c=='\n'){ ret*=sgn; return 1; }
    while(c=getchar(),c>='0'&&c<='9') ret+=(c-'0')*bit,bit/=10;
    ret*=sgn;
    return 1;
}
int sign(double x){
    return fabs(x) < EPS ? 0 : x>0 ? 1 : -1 ;
}
char s[N];
int main(void){
    int k;
    cin >>s+1 >>k;
    int ed=-1;
    for(int i=1;i<=(int)strlen(s+1);++i){
        if(s[i]=='1')   continue;
        else{
            ed=i-1;
            break;
        }
    }
//    cout <<"ed="<<ed<<endl;
    if(ed<1)  cout << (char) s[1] << endl;
    else{
        if(k<=ed)   cout <<1<<endl;
        else    cout << s[ed+1]<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>
using namespace std; //
int main(){
	int x;
	cin>>x;
	cout<<x*x*x<<endl;
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X, Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%(m))
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

string S;
bool used[26];

int main() {
    cin >> S;

    if (S == "zyxwvutsrqponmlkjihgfedcba") {
        cout << -1 << endl;
        return 0;
    }

    if (len(S) < 26) {
        string ans = S;
        rep(i, len(S)) {
            used[S[i] - 'a'] = true;
        }
        rep(i, 26) {
            if (!used[i]) {
                char ch = i + 'a';
                ans += string{ch};
                break;
            }
        }
        cout << ans << endl;
        return 0;
    }

    rrep(i, 26) {
        used[S[i] - 'a'] = true;
        for (int j = S[i] - 'a' + 1; j < 26; ++j) {
            if (used[j]) {
                char ch = 'a' + j;
                string ans = S.substr(0, i) + string{ch};
                cout << ans << endl;
                return 0;
            }
        }
    }


    return 0;
}


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

using namespace std;

#define FOE(i, s, t) for (int i = s; i <= t; i++)
#define FOR(i, s, t) for (int i = s; i < t; i++)
#define FOD(i, s, t) for (int i = s; i >= t; i--)

#define LL long long
#define mp make_pair
#define pb push_back

LL a, v, b, w, t;

int main() {
	cin >> a >> v >> b >> w >> t;
	
	if (w >= v) {
		puts("NO");
		return 0;	
	}
	
	LL s = v - w;
	LL dist = abs(b - a);
	
	if (dist <= t * s) {
		puts("YES");	
	} else {
		puts("NO");	
	}
}	

Measured memory_bytes: 3556
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>

using namespace std;

#define ll long long int
#define pii pair<ll,ll>

int main()
{
    int n;
    cin >> n;
    vector<ll> v(n);
    ll sum = 0;
    ll ans = 0;
    for(int i = 0;i < n;i++)
    {
        cin >> v[i];
        sum += v[i];
        ans += abs(v[i]);
    }
    ll m = 0;
    for(int i = 0;i < n-1;i++)
    {
        m += 2 * v[i];
        ans = min(ans, abs(sum - m));
    }
    cout << ans << endl;
    return 0;
}


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

int k;
vector<int> ve = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(){
	cin >> k;
	cout << ve[k-1] << "\n";
}


Measured memory_bytes: 256
#ifdef LOCAL
#define debug(_) cerr << #_ << ": " << (_) << '\n'
#define _GLIBCXX_DEBUG
#else
#define debug(_) (void(0))
#endif  // LOCAL

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

int main(){
    string S;
    cin >> S;

    auto sa = suffix_array(S);
    auto lcp = lcp_array(S, sa);
    long long N = S.size();
    cout << ((N * (N + 1)) / 2 - (accumulate(lcp.begin(), lcp.end(), 0ll))) << '\n';

    return 0;
}

Measured memory_bytes: 15644
#include <iostream>
#include <vector>

using namespace std;

const int NO_OF_BITS = 21;
vector <int> sum(NO_OF_BITS, 0);

int is_bit_set(long long &n, int position)
{
    return ( (n&(1LL << position)) != 0);
}

int at_most_one_bit_set()
{
    for(int i = 0; i < NO_OF_BITS; i++)
        if(sum[i] > 1)
            return false;

    return true;
}

void add(long long n)
{
    for(int bit = 0; bit < NO_OF_BITS; bit++)
    {
        if(is_bit_set(n, bit))
            sum[bit]++;
    }
}

void take_out(long long n)
{
   for(int bit = 0; bit < NO_OF_BITS; bit++)
    {
        if(is_bit_set(n, bit))
            sum[bit]--;
    }
}

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

    vector <int> A(no_of_elements + 1);
    for(int i = 1; i <= no_of_elements; i++)
        cin >> A[i];

    int left = 0, right = 0;
    long long good_subarrays = 0;

    while(left < no_of_elements)
    {
        take_out(A[left]);
        left++;

        while(right < no_of_elements)
        {
            right++;
            add(A[right]);

            if(!at_most_one_bit_set())
            {
                take_out(A[right]);

                right--;

                break;
            }
        }

        good_subarrays += (right - (left - 1));
    }

    cout << good_subarrays;
    return 0;
}



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

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;

    vector<bool> ok(N, false);
    while (K--) {
        int d;
        cin >> d;
        while (d--) {
            int a;
            cin >> a;
            ok[a] = true;
        }
    }

    int res = 0;
    for (int i = 1; i <= N; i++) {
        if (!ok[i]) res += 1;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3640
N, X = map(int,input().split())
def rec(n,x):
    f = 2**(n+1)-3
    if n==0:
        return 1
    if x==1:
        return 0
    elif x<=f+1:
        return rec(n-1,x-1)
    elif x==f+2:
        return 2**n
    elif x<=2*f+2:
        return 2**n+rec(n-1,x-(2**(n+1)-1))
    else:
        return 2**(n+1)-1
print(rec(N,X))


Measured memory_bytes: 38256
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            char[][] grid = new char[3][];
            grid[0] = in.next().toCharArray();
            grid[1] = in.next().toCharArray();
            grid[2] = in.next().toCharArray();

            int cur = 0;
            int[] countArr = new int[] {grid[0].length, grid[1].length, grid[2].length};
            int[] indexArr = new int[3];

            while (indexArr[cur] < countArr[cur]) {
                char c = grid[cur][indexArr[cur]];
                indexArr[cur]++;
                cur = c - 'a';
            }

            out.println((char) (cur + 'A'));
        }
    }

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null, () -> solve(), "1", 1 << 26).start();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

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

    }

}

Measured memory_bytes: 29140
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll n, x;
  cin>>n;
  vector<ll>a(n), dp(n,0);
  for(ll i=0;i<n;i++) cin>>a[i];
  //dp[0]=a[0];
  dp[1]=abs(a[0]-a[1]);
  //cout<<dp[0]<<" "<<dp[1]<<" ";
  for(ll i=2;i<n;i++)
  {
    dp[i] = min((dp[i-1] + abs(a[i-1] - a[i])), (dp[i-2] + abs(a[i-2] - a[i])));
    //cout<<dp[i]<<" ";
  }
  cout<<dp[n-1];
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i = 0; i < n; ++i)
const ll mod = 1e9 + 7;
const ll N = 2e5 + 200;
const ll INF = 0x3f3f3f;



int main(){
    int n;
    cin>>n;
    map<ll,ll> mp;
    int flag = 0;
    rep(i,n){
        int x;
        cin>>x;
        if(!mp[x]){
            mp[x] = 1;
        }else{
            flag = 1;
        }
    }
    if(flag)    cout<<"NO"<<endl;
    else    cout<<"YES"<<endl;
    return 0;
}

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

using namespace std;
int i,j,n,m;
long double dp[3005][3005],a[3005],sol;

int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>a[i];
    dp[1][1]=a[1];
    dp[1][0]=1-a[1];
    for(i=2;i<=n;i++)
        dp[i][0]=dp[i-1][0]*(1-a[i]);
    for(i=2;i<=n;i++)
        for(j=1;j<=i;j++)
        dp[i][j]=dp[i-1][j]*(1-a[i])+dp[i-1][j-1]*a[i];
    for(i=n/2+n%2;i<=n;i++)
        sol+=dp[n][i];
    cout<<fixed<<setprecision(10)<<sol;
    return 0;
}


Measured memory_bytes: 139392
def l_in(type_): return list(map(type_, input().split()))
def i_in(): return int(input())
def m_in(type_): return map(type_, input().split())
def r_in(n, type_): return [type_(input()) for _ in range(n)]
ans = False
a, b, c = m_in(int)
k = i_in()
for _ in range(k):
    if c <= b or c <= a: c *= 2
    elif b <= a: b *= 2
    if c > b > a:
        ans = True
        break
print('Yes' if ans else 'No')

Measured memory_bytes: 9136
#include<bits/stdc++.h>
#include<stdio.h>
#include <iostream>
#include <cmath>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(b+c<a)	cout<<0<<endl;
	else	cout<<abs(a-(b+c))<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int arr[n];
    int flag=0;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
    }
    sort(arr,arr+n);
    for(int i=0;i<n;i++)
    {
        if(arr[i]==arr[i+1])
        {
            flag=1;
            break;
        }
    }
    if(flag==0)
    {
        cout<<"YES"<<endl;
    }
    else if(flag==1)
    {
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>

using namespace std;

int main(void){
  int N;
  cin >> N;

  int prime[15]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
  int num[15];
  for(int i=0;i<15;i++){
    num[i]=0;
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<15;j++){
      int val=i+1;
      while(val%prime[j] == 0){
        //cout << val << endl;
        num[j]++;
        val/=prime[j];
      }
    }
  }
  int judge[5]={2,4,14,24,74};
  int judge_num[5]={0,0,0,0,0};
  for(int i=0;i<15;i++){
    for(int j=0;j<5;j++){
      if( num[i] >= judge[j] ) judge_num[j]++;
    }
    //cout <<num[i] << " ";
  }
  for(int j=0;j<5;j++){
    //cout << judge_num[j] << " ";
  }
  int res = judge_num[1]*(judge_num[1]-1)*(judge_num[1]-2)/2 + (judge_num[0]-judge_num[1])*judge_num[1]*(judge_num[1]-1)/2
          + judge_num[2]*(judge_num[2]-1) + (judge_num[1]-judge_num[2])*judge_num[2]
          + judge_num[3]*(judge_num[3]-1) + (judge_num[0]-judge_num[3])*judge_num[3]
          + judge_num[4];
  cout << res << endl;



  return 0;
}


Measured memory_bytes: 256
L,R = map(int,input().split())
mod = 2019
k = 2018
limit = R-L
if limit >= 2019:
    k = 0
else:
    for i in range(limit):
        for j in range(limit-i):
            s = ((L+i)*(L+i+j+1)) % mod
            if s < k:
                k = s 
print(k)

Measured memory_bytes: 2940
icase=0
if icase==0:
    n=int(input())
    h=list(map(int,input().split()))
elif icase==1:
    n=5
    h=[3,1,2,3,1]
    ans=5
elif icase==2:
    n=4
    h=[1,2,2,1]
    ans=2
elif icase==3:
    n=8
    h=[4, 23, 75, 0, 23, 96, 50, 100]
    ans=221

hmin=10**6

def hct(hh,ll,rr,hcnt0):
#    print("0: ll:",ll,"rr:",rr,"hcnt0:",hcnt0,"h:",h)
    if ll>=rr:
        return hcnt0
    hcnt0+=1
    hmax=-1
    hhim=-1
    lll=ll
    for i in range(ll,rr):
        hh[i]-=1
        hmax=max(hh[i],hmax)
        if hh[i]>0 and hhim<=0:
            lll=i
            hhim=1
        if hh[i]<=0 and hhim>0:
            rrr=i
            hhim=-1
            hcnt0=hct(hh,lll,rrr,hcnt0)
    if hhim>0:
        hcnt0=hct(hh,lll,rr,hcnt0)
    return hcnt0
        
hcnt=0
ll=0        
hhim=-1
for i in range(n):
    if h[i]==0 and hhim>0:
        hcnt=hct(h,ll,i,hcnt)
        lll=i
        hhim=-1
    elif h[i]==0:
        hhim=-1
    elif h[i]>0 and hhim<0 :
        ll=i
        hhim=1
if hhim>0:
    hcnt=hct(h,ll,n,hcnt)
print(hcnt)
        

Measured memory_bytes: 3188
open Batteries
let () =
  let a,b,c = Scanf.scanf "%d %d %d " (fun a b c -> a,b,c) in

  let res = ref "NO" in
  for i=1 to b do
    if a*i mod b = c then res := "YES"
  done;

  Printf.printf "%s\n" !res


Measured memory_bytes: 3072