akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MAX_N = 1 << 17;
const int INF = 1 << 25;
const int def = INF;

struct MaxSegTree {
	int n;
	ll dat[2 * MAX_N - 1];
	void init(int n_) {
		n = 1;
		while(n < n_) n *= 2;
		for(int i = 0; i < 2 * n - 1; i++) dat[i] = 0;
	}

	void update(int k, ll a) {
		k += n - 1;
		dat[k] = a;
		while(k > 0) k = (k - 1) / 2, dat[k] = max(dat[k * 2 + 1], dat[k * 2 + 2]);
	}

	ll query(int a, int b) { return query(a, b, 0, 0, n); }

	ll query(int a, int b, int k, int l, int r) {
		if(r <= a || b <= l) return 0;
		if(a <= l && r <= b) return dat[k];
		ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return max(vl, vr);
	}

	void show() {
		for(int i = 0; i < n; i++) cout << dat[i + n - 1] << " ";
		cout << endl;
	}
};

struct MinSegTree {
	int n;
	ll dat[2 * MAX_N - 1];
	void init(int n_) {
		n = 1;
		while(n < n_) n *= 2;
		for(int i = 0; i < 2 * n - 1; i++) dat[i] = def;
	}

	void update(int k, ll a) {
		k += n - 1;
		dat[k] = a;
		while(k > 0) k = (k - 1) / 2, dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
	}

	ll query(int a, int b) { return query(a, b, 0, 0, n); }

	ll query(int a, int b, int k, int l, int r) {
		if(r <= a || b <= l) return def;
		if(a <= l && r <= b) return dat[k];
		ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return min(vl, vr);
	}

	void show() {
		for(int i = 0; i < n; i++) cout << dat[i + n - 1] << " ";
		cout << endl;
	}
};

MaxSegTree maxst;
MinSegTree minst;

int A[1000];
int check[1000];

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

	int N, M;
	cin >> N >> M;

	maxst.init(2 * N);
	minst.init(2 * N);
	for(int i = 0; i < N; i++) {
		cin >> A[i];
		maxst.update(i, A[i]);
		maxst.update(i + N, A[i]);
		minst.update(i, A[i]);
		minst.update(i + N, A[i]);
	}

	ll sum = 0;
	int idx = 0;
	for(int i = 0; i < N; i++) {
		if(check[idx]) break;
		ll s = maxst.query(idx, idx + M) - minst.query(idx, idx + M);
		sum += s;
		check[idx] = 1;
		idx = (idx + M) % N;
	}
	cout << sum << endl;
}

Measured memory_bytes: 3284
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
using LL = long long;
int gcd(int a, int b)
{
	return b ? gcd(b, a % b) : a;
}
int main()
{
	//freopen("..//data.in", "r", stdin);
	//freopen("..//data.out", "w", stdout);

	int k;
	scanf("%d", &k);

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

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

	return 0;
}

Measured memory_bytes: 3228
import java.io.PrintWriter

fun main(args: Array<String>) {

    // Sieve of Eratosthenes
    fun sieve(n: Int): Set<Int> {
        val primeNumbers = mutableSetOf<Int>()
        val sieved = mutableSetOf<Int>()

        for (i in 2..n) {
            if (sieved.contains(i)) continue
            primeNumbers.add(i)
            if (i * i <= n) {
                var j = 2
                while (i * j <= n) {
                    sieved.add(i * j)
                    j++
                }
            }
        }
        return primeNumbers
    }

    val primeNums = sieve(100000)
    val ans = IntArray(100001)
    for (i in 1..100000) {
        if (primeNums.contains(i) && primeNums.contains((i + 1) / 2)) {
            ans[i] = ans[i - 1] + 1
        } else {
            ans[i] = ans[i - 1]
        }
    }

    // main
    val pw = PrintWriter(System.out)

    val q = readLine()!!.toInt()
    repeat(q) {
        val (l, r) = readLine()!!.split(' ').map { it.toInt() }
        pw.println(ans[r] - ans[l - 1])
    }

    pw.flush()
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define All(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
template<class T> T gcd(T a,T b) {return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b) {return a/gcd(a,b)*b; }
template<class T> bool isPrime(T num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (T i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

using namespace std;

main()
{
    string s;
    cin>>s;
    if(s=="SUN")cout<<7<<endl;
    if(s=="MON")cout<<6<<endl;
    if(s=="TUE")cout<<5<<endl;
    if(s=="WED")cout<<4<<endl;
    if(s=="THU")cout<<3<<endl;
    if(s=="FRI")cout<<2<<endl;
    if(s=="SAT")cout<<1<<endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
list_ = [0]*(10**5+2)

for n in range(N):
  list_[A[n]] += 1

ans = 0
for n in range(0,len(list_)-2):
  _ = list_[n-1] + list_[n] + list_[n+1]
  ans = max(ans,_)

print(ans)

Measured memory_bytes: 14008
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1001001001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    string a, s, c;
    cin >> a >> s >> c;
    cout << 'A' << s[0] << 'C' << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

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

#define REP(i,n) for(ll i = 0;i < n;++i)
#define PB(s) push_back(s)
#define ST(n) sort(n.begin(),n.end())

using namespace std;
typedef long long ll;

int main(){
	ll N,M;//N 店数 M 本数
	cin >> N >> M;
	std::map<ll,ll> LIST;
	ll temp[N];
	REP(i,N){
		ll a,b;
		cin >> a >> b;
		LIST[a] += b;
		temp[i] = a;
	}
	sort(temp,temp+N);
	ll ANS=0;
	ll X =0;
	while(1){
		REP(i,LIST[temp[X]]){
			//cout << LIST[temp[X]] <<" " << temp[X] << endl;
			ANS += temp[X];
			M--;
			if(M==0){
				cout << ANS << endl;
				exit(0);
			}
		}
		X++;
		while(temp[X] == temp[X-1])X++;
	}
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
#include <math.h>
#include <limits.h>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}

int main(void){
  long long int k,i,j;
  long long int x,y,z;
  cin >> x >> y >> z;

  cout << (x-z)/(y+z) << endl;
  return 0;
}




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

using ll = long long int;
using P = pair<int, int>;
using P3 = pair<ll,P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9) + 7;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr double EPS = 1e-8;

bool solve(){
    int n;
    cin >> n;
    if(n==0) return true;
    int ans = -1;
    vector<int> cnt(26);
    for(int i=0;i<n;i++){
        char c;
        cin >> c;
        int id = c-'A';
        cnt[id]++;
        auto tmp = cnt;
        sort(tmp.rbegin(), tmp.rend());
        if(tmp[0] > tmp[1] + (n-i-1)){
            if(ans == -1) ans = i+1;
        }
    }
    if(ans != -1){
        char x;
        int maxi = 0;
        for(int i=0;i<26;i++){
            if(cnt[i] > maxi){
                maxi = cnt[i];
                x = char('A'+i);
            }
        }
        cout << x << " " << ans << endl;
    }else{
        cout << "TIE" << endl;
    }
    return false;
}

int main(){
    // solve();
    while(!solve());
    // int t; cin >> t; for(;t>0;t--) solve();
    return 0;
}


Measured memory_bytes: 3124
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll inf = 1000000000;
typedef pair<ll, ll> P;

int main() {
	int a[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int k;
	cin >> k;
	k--;
	cout << a[k] << endl;
	return 0;
}

Measured memory_bytes: 256
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST            ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll              long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define mii             map<int,int>
#define vi              vector<int>
#define vll             vector<long long>
#define all(a)          (a).begin(),(a).end()
#define clz(a)          __builtin_clz(a) // count leading zeroes
#define ctz(a)          __builtin_ctz(a) // count trailing zeroes
#define popc(a)         __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul             1000000007
#define rep(i,a,b)      for(int i=a;i<b;i++)
#define rfor(i,a,b)     for(int i=a; i>=b; i--)
#define debug(x)        cerr << #x << " = " << x << endl;
#define F               first
#define S               second
#define mod             998244353 
#define pll             pair<ll,ll>
#define endl            '\n'
#define deci(n)         cout<<fixed<<setprecision(n)
#define ordered_set     tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

ll binexpo(ll n, ll p)
{
    if(p == 0) return 1;
    ll x = binexpo(n,p/2)%mod;
    x = (x*x)%mod;
    if(p%2 == 0) return x;
    else return (x*n)%mod;
}
void solve()
{
    int n; cin>>n;
    vll d(n+1);
    vll tree(n+1,0), branch(n+1,0);
    tree[0]=1;
    rep(i,1,n+1) cin>>d[i], branch[d[i]]++;
    if(d[1]!=0 or branch[0]>1) {cout<<0; return;}
    sort(all(d));
    rep(i,1,d[n]+1)
    {
        tree[i] = (tree[i-1]*((binexpo(branch[i-1],branch[i])+mod)%mod))%mod;
    }
    cout<<tree[d[n]];
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;  //cin>>t;
    while(t--){
       solve();
    }
    return 0;
}

Measured memory_bytes: 2560
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stdio.h>
#define fo(i,a,b)for(int i(a);i<(b);i++)
#define rep(i,n)fo(i,0,n)
using namespace std;
#define pii pair<int,int>
#define ll long long
#define mp make_pair
#define pb push_back
typedef pair<pair<int,int>,int>tri;

char s[500005];
int cnt[500005];
int ans[500005];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    cin>>s[i];
    for(int i=1;i<=n;i++)
    if(s[i]=='0')cnt[i]=i;
    else cnt[i]=cnt[i-1];
    for(int i=1;i<=n;i++)
    {
        ans[i]=ans[i-1];
        if(s[i]=='1')
        {
            if(s[i-1]=='0' && s[i-2]=='1')
            {
                ans[i]=max(ans[i],ans[cnt[i-2]]+i-2-cnt[i-2]);
                ans[i]=max(ans[i],ans[cnt[i-2]+1]+i-2-cnt[i-2]-1);
            }
            if(s[cnt[i]-1]=='1')
            {
                ans[i]=max(ans[i],ans[cnt[i]-2]+i-cnt[i]);
            }
        }
    }
    cout<<ans[n];
    return 0;
}


Measured memory_bytes: 4608
def compare(s1, s2):
    if s1[1] > s2[1]:
        return 1
    elif s1[1] < s2[1]:
        return -1

    return 0

def bubbleSort(N, A):
    flag = True
    while flag:
        flag = False
        for i in xrange(N-1, 0, -1):
            if compare(A[i-1], A[i]) > 0:
                A[i-1], A[i] = A[i], A[i-1]
                flag = True

def selectSort(N, A):
    for i in xrange(N):
        minj = i
        for j in xrange(i, N):
            if compare(A[j], A[minj]) < 0:
                minj = j
        if minj != i:
            A[i], A[minj] = A[minj], A[i]

N = int(raw_input())
A = raw_input().split()
B = list(A)
bubbleSort(N, A)
print ' '.join(A)
print 'Stable'
selectSort(N, B)
print ' '.join(B)
if A == B:
    print 'Stable'
else:
    print 'Not stable'

Measured memory_bytes: 4272
#include "bits/stdc++.h"
using namespace std;

int main(){
	vector<int> a(10);
	for(int i=0;i<10;i++)cin>>a[i];
	sort(a.begin(),a.end());
	for(int i=9;i>6;i--)cout<<a[i]<<endl;
	return 0;
}

Measured memory_bytes: 3132
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>


using namespace std;

int main(){
  int N;
  cin>>N;
  int A[N];

  for(int i=0;i<N;i++)cin>>A[i];
  long sum=abs(A[0]);
  for(int i=1;i<N;i++)sum+=abs(A[i]-A[i-1]);
  sum+=abs(A[N-1]);
  int p;
  for(int i=0;i<N;i++){
    long a,b,c=0;
    if(i==0)a=0;
    else a=A[i-1];
    b=A[i];
    if(i==N-1)c=0;
    else c=A[i+1];
    if(((b-a)*(c-b))<0){
      p=min(abs(b-a),abs(c-b));
    }
    else p=0;
    cout<<sum-2*p<<endl;
  }
  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cstring>

using namespace std;

#pragma GCC oprimize("Ofast")
#define rep(i,a,b) for(__typeof(b)i=a;i<b;++i)

typedef long long ll;
typedef vector<ll> vl;

const ll inf = 100000000000;

ll n;
ll mem[100010];
vl l;


ll dp(ll at)
{
	if(at>n-1)return inf;
	if(at==n-1)return 0;
	if(mem[at]!=-1)return mem[at];
	ll ans = inf;
	ans = min(ans,abs(l[at]-l[at+1])+dp(at+1));
	ans = min(ans,abs(l[at]-l[at+2])+dp(at+2));
	return mem[at] = ans;
}


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

    memset(mem,-1,sizeof(mem));

	cin >> n;
	l.resize(n);
	rep(i,0,n)
	{
		cin >> l[i];
	}
	cout << dp(0);
	return 0;
}


Measured memory_bytes: 6528
#include<iostream>
using namespace std;
typedef long long LL;
const int N = 1e5;
int x[N+1];
int solve(int n, int k)
{
	if(x[1] >= 0)
		return x[k];
	if(x[n] <= 0)
		return abs(x[n-k+1]);
	// x[1] < 0 < x[n]
	int ans = 1e9;
	for(int i = 1; i+k-1 <= n; i++)
		if(x[i] <= 0 && x[i+k-1] >= 0)
			ans = min(ans,x[i+k-1]-x[i]+min(x[i+k-1],abs(x[i])));
	return ans;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, k; cin >> n >> k;
	for(int i = 1; i <= n; i++)
		cin >> x[i];
	cout<<solve(n,k)<<endl;
	
	cout<<flush;
	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

const int MAXN = 100100;
int memo[MAXN];

int rec(int n) {
    if (n == 0) return 0;
    if (memo[n] != -1) return memo[n];

    int res = n;
    for (int i = 1; i <= n; i *= 6) res = min(res, rec(n-i)+1);
    for (int i = 1; i <= n; i *= 9) res = min(res, rec(n-i)+1);

    return memo[n] = res;

}

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

    rep(i, MAXN) memo[i] = -1;    
    cout << rec(N) << endl;
    return 0;
}


Measured memory_bytes: 3712
from functools import reduce

MOD = 1000000007

def comb(n, r):
    if n < 0 or r < 0 or r > n:
        return 0
    r = min(r, n - r)
    if r == 0: return 1

    numer = [n - r + i + 1 for i in range(r)]
    denom = [i + 1 for i in range(r)]

    for i in range(1, r):
        divisor = denom[i]
        if divisor > 1:
            offset = (n - r) % (i + 1)
            for j in range(i, r, i+1):
                numer[j - offset] //= divisor
                denom[j] //= divisor

    res = 1
    for i in range(r):
        if numer[i] > 1:
            res *= numer[i]
    return res

    # return reduce(lambda x, y: x*y if y > 1 else x, numer)

def main():
    x, y = map(int, input().split())
    ans = 0
    if (x+y)%3==0 and x <= 2*y <= 4*x:
        n = (x + y) // 3
        r = y - n
        ans = comb(n, r) % MOD
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 65164
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long number=0;
	map<string,int>a;
	int t,b,c;
	cin>>t;
	string s;
	while(t>0){
		cin>>s;
		sort(s.begin(),s.end());
		number+=a[s];
		a[s]++;
		t--;
	}
	cout<<number;
}


Measured memory_bytes: 11136
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
int a[100000];
int W(int m,int b)
{
        return abs(a[m]-a[b]);
   
}

int F(int num)
{
    int dp[num+1];
    dp[0]=0;
    dp[1]=W(0,1);
     
   for(int i=2;i<=num;i++)
   {
       
    dp[i]=min((dp[i-1]+W(i,i-1)),(dp[i-2]+W(i,i-2)));

   }
   
    return dp[num];
}


int main() {
    int n;

cin>>n;

for(int i=0;i<n;i++)
   cin>>a[i];
   
int ans=F(n-1);
cout<<"\n"<<ans;
return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
//type
typedef long long ll;
#define pii pair<int, int>
#define vi vector<int>
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define all(v) v.begin(), v.end()
#define ios cin.tie(0); ios::sync_with_stdio(false)
#define FIX(a) cout << fixed << setprecision(a)
//manip
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power(T a, T b)
{return b ? power(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
#define LB(v, x) (int)(lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
template<typename T> T gcd(T a, T b) {if (b == 0) return a; return gcd(b, a % b);}
template<typename T> T lcm(T a, T b) {return a / gcd(max(a, b), min(a, b)) * b;} //先に割る!!
#define outa(a, n) rep(i, n) cout << a[i] << " "; cout << endl
#define out(a) cout << a << endl
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep3(i, st, n) for (int i = st; i < n; ++i)
//algorithm
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0
//bfs, not x, y, i, j
//not !(i % 2), i % 2 == 0
//minimal required terms
//cast caution
//look constraints always



int main() {
    int n; cin >> n;
    string s; cin >> s;
    int ans = 1;
    rep3(i, 1, SZ(s)) {
        if (s[i] == s[i - 1] && s[i] == 'x') {
            break;
        }
        ans++;
    }
    out(ans);
}



Measured memory_bytes: 3348
n = int(input())
h = list(map(int, input().split()))

x = -999
h.reverse()
for i in range(n):
    if i == 0:
        continue
    if h[i] > h[i-1]:
        if h[i]-h[i-1] == 1:
            h[i] -= 1
        else:
            print("No")
            quit()
print("Yes")

Measured memory_bytes: 14252
use proconio::input;

fn main() {
    input!(n: usize, k: usize, x: [i64; n]);
    println!(
        "{}",
        (0..=n - k)
            .map(|i| {
                let j = i + k - 1;
                x[j] - x[i] + x[i].abs().min(x[j].abs())
            })
            .min()
            .unwrap()
    );
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

string s;

map<pair<int, string>, int> memo;

int ans;

int solve(int pos, string last) {
  auto key = make_pair(pos, last);
  if (memo.find(key) != memo.end()) return memo[key];

  if (pos == s.size()) return memo[key] = 0;

  int ret = -1;

  for (int i = 1; (pos + i) <= min((int)(s.size()), pos + 2); ++i) {
    int next_pos = pos + i;

    if (last == s.substr(pos, i)) continue;

    ret = max(ret, solve(next_pos, s.substr(pos, i)));
  }

  ret += (ret == -1) ? 0 : 1;

  return memo[key] = ret;
}

int main(void) {
  // Here your code !
  cin >> s;

  // int pos = 0;

  // for (int i = 1; (pos + i) <= s.size(); ++i) {
  //   int next_pos = pos + i;

  //   printf("%d\n", next_pos);

  //   cout << s.substr(pos, i) << endl;
  // }

  set<string> occur;

  ans = solve(0, "");

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

  return 0;
}


Measured memory_bytes: 80388
n = int(input())
used = [[False for _ in range(13)] for _ in range(4)]

def suit2Num(suit):
  if suit == 'S':
    return 0
  elif suit == 'H':
    return 1
  elif suit == 'C':
    return 2
  elif suit == 'D':
    return 3

  return -1

def num2Suit(num):
  if num == 0:
    return 'S'
  elif num == 1:
    return 'H'
  elif num == 2:
    return 'C'
  elif num == 3:
    return 'D'

  return 'N'

for _ in range(n):
  suit, num = input().split()

  used[suit2Num(suit)][int(num)-1] = True

for i in range(4):
  for j in range(13):
    if not used[i][j]:
      print( num2Suit(i),j+1, sep =' ' )

Measured memory_bytes: 7776
class solve:
    def __init__(self, n):
        pass

    def insertionsort(self, A, n, g):
        for i in range(g, n):
            v = A[i]
            j = i - g
            while j >= 0 and A[j] > v:
                A[j + g] = A[j]
                j = j - g
                self.cnt += 1
            A[j + g] = v

    def shellsort(self, A, n):
        self.cnt = 0
        self.G = [1]
        f = 1
        while f * 3 + 1 <= n:
            f = f * 3 + 1
            self.G.append(f)
        self.G = list(reversed(self.G))
        self.m = len(self.G)
        for g in self.G:
            self.insertionsort(A, n, g)


n, *A = map(int, open(0).read().split())
solver = solve(n)
solver.shellsort(A, n)
print(solver.m)
print(' '.join(map(str, solver.G)))
print(solver.cnt)
print('\n'.join(map(str, A)))


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<string> w(n);
	rep(i, n) cin >> w[i];
	int res = 0;
	for (int i = 0; i < n - 1; ++i) {
		for (int j = i + 1; j < n; ++j) {
			if (w[i] == w[j]) res++;
		}
	}
	for (int i = 1; i < n; ++i) {
		if (w[i - 1].at(w[i - 1].size() - 1) != w[i].at(0)) res++;
	}
	if (res == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
n,m = map(int, input().split())
h = list(map(int, input().split()))

ab = [0]*n
for _ in range(m):
  a,b = map(int, input().split())
  ab[a-1] = max(ab[a-1], h[b-1])
  ab[b-1] = max(ab[b-1], h[a-1])

ans = 0 
for i in range(n):
  if ab[i] < h[i]:
    ans += 1
print(ans)


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int H, W, D;
int A[333][333];
map<int, pair<int, int>> m;
int a[111111];

int main() {
   cin >> H >> W >> D;
   rep (i, H) {
      rep (j, W) {
         cin >> A[i][j];
         m.insert({A[i][j], {i, j}});
      }
   }

   // for (int i = D+1; i <= H*W; i++) {
   //    a[i] = a[i-D] + abs(m[i-D].first - m[i].first) + abs(m[i-D].second - m[i].second);
   // }
   for (int i = 1; i <= H*W-D; i++) {
      a[i+D] = a[i] + abs(m[i+D].first - m[i].first) + abs(m[i+D].second - m[i].second);
   }

   int Q;
   cin >> Q;
   while (Q--) {
      int l, r;
      cin >> l >> r;
      cout << a[r] - a[l] << endl;
   }

   return 0;
}

Measured memory_bytes: 7552
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>; 
template<class T = int> using VV = V< V<T> >;

inline V<> divisor(lint n) {
    V<> res;
    lint i;
    for (i = 1; i * i < n; ++i) if (n % i == 0) res.push_back(i), res.push_back(n / i);
    if (i * i == n) res.push_back(i);
    return res;
}
inline lint tmod(lint a, lint p) { return (a %= p) < 0 ? a + p : a; }
inline int mod_pow(unsigned long long a, int n, unsigned long long p) {
    // a = tmod(a, p);
    unsigned long long res = 1;
    while (n > 0) {
        if (n & 1) {
            (res *= a) %= p;
        }
        (a *= a) %= p;
        n >>= 1;
    }
    return res;
}
lint mod_inv(lint a, lint p) {
    a = tmod(a, p);
    lint b = p, x = 1, u = 0;
    while (b) {
        lint q = a / b;
        swap(a -= q * b, b);
        swap(x -= q * u, u);
    }
    return a== 1 ? tmod(x, p) : -1;
}
int mod_log(lint g, lint x, int p) {
    g = tmod(g, p);
    x = tmod(x, p);
    int m = 1.4e6;
    static unordered_map<int, int> mp;
    lint a = 1;
    if (mp.empty()) for (int j = 0; j < m; ++j) {
        mp[a] = j;
        (a *= g) %= p;
    }
    g = mod_inv(mod_pow(g, m, p), p), a = 1;
    for (int i = 0; i < (p - 1 + m - 1) / m; ++i) {
        if (mp.count(a * x % p)) {
            return i * m + mp[a * x % p];
        }
        (a *= g) %= p;
    }
    return -1;
}
map<int, int> factorize(int n) {
    map<int, int> res;
    for (int i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            ++res[i];
            n /= i;
        }
    }
    if (n != 1) ++res[n];
    return res;
}
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int p, t; cin >> p >> t;
    auto mp = factorize(p - 1);
    auto ord = [&](int x) -> int {
        int res = p - 1;
        for (const auto& e : mp) {
            for (int i = 0; i < e.second; ++i) {
                if (mod_pow(x, res / e.first, p) == 1) {
                    res /= e.first;
                } else break;
            }
        }
        return res;
    };
    while (t--) {
        int n; cin >> n;
        V<> G(n);
        for (auto&& e : G) cin >> e;
        int a; cin >> a;
        int ea = (p - 1) / ord(a);
        int gcd = p - 1;
        for (int e : G) {
            gcd = __gcd(gcd, (p - 1) / ord(e));
            // if (ea % gcd == 0) {
            //     cout << "1\n";
            //     break;
            // }
        }
        // if (ea % gcd) cout << "0\n";
        cout << (ea % gcd == 0) << '\n';
    }
}


Measured memory_bytes: 3308
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static long lcm(long a, long b){
        long m = a;
		long n = b;   
        long t = m % n;
        while(t != 0){
            m = n;
            n = t;
            t = m % n;
        }                   
        long l = a * b / n;
        return l;
    }
    
    public static void main(String[] args) throws IOException {
    	BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
        String[]z=br.readLine().split(" ");
        long a = Integer.parseInt(z[0]);
        long b = Integer.parseInt(z[1]);
        long s = lcm(a , b);
        System.out.print(s);
    }
}



Measured memory_bytes: 32336
#include<iostream>
using namespace std;
int Min(int a,int b){
  if(a<b) return a;
  else return b;
}
int main(){
  int n,m,x;
  cin >> n >> m >> x;
  for(int i=0;i<m;i++){
    int a;
    cin >> a;
    if(x<a){
      cout << Min(i,m-i) << "\n";
      break;
    }
    if(i==m-1) cout << 0 << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
import numpy as np
def resolve():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    ans = ""

    for n in range(len(bin(max(A))) - 1, -1 ,-1 ):
        ans += str(np.count_nonzero((A >> n)&1) % 2)
    for i in range(N):
        print(int(ans,2) ^ A[i], end =" ")
resolve()

Measured memory_bytes: 49792
#include <cstdio>
#include <cstdlib>
#include <algorithm>

long long dp[100000];

int main()
{
  int n, k;
  scanf("%d%d", &n, &k);
  int h[100000];
  for (int i = 0; i < n; ++i)
  {
    scanf("%d", h + i);
  }
  for (int i = 2; i <= n; ++i)
  {
    long long min = 1e18;
    for (int j = 1; j <= k; ++j)
    {
      if (i - j < 1) continue;
      min = std::min(min, dp[i - j] + std::abs(h[i - 1] - h[i - 1 - j]));
    }
    dp[i] = min;
  }
  printf("%lld\n", dp[n]);
  return 0;
}


Measured memory_bytes: 1280
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	n <- readInt
	[ xs, ys ] <- map ( map fromIntegral ) . transpose <$> replicateM n readInts
	let
		ps = permutations [ 0 .. n - 1 ]
		m = fromIntegral $ length ps
		s = sum $ map ( solve xs ys ) ps
	printf "%12f\n" $ ( s / m :: Double )

solve _ _ [_] = 0
solve xs ys (i:j:ps) = d + solve xs ys (j:ps)
	where
		x1 = xs !! i
		y1 = ys !! i
		x2 = xs !! j
		y2 = ys !! j
		d = sqrt $ ( x1 - x2 ) ** 2 + ( y1 - y2 ) ** 2


Measured memory_bytes: 12796
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);
        int sub;
        int sum;
        int all;

        while(s.hasNext()){
            sub = s.nextInt();
            all = 0;
            if(sub == 0)
                break;
            int[][] table = new int[sub][sub];
            for(int i = 0; i < sub; i++){
                sum = 0;
                for(int j = 0; j < sub; j++){
                    table[i][j] = s.nextInt();
                    sum += table[i][j];
                    System.out.printf("%5d",table[i][j]);
                    if(j == sub - 1){
                        System.out.printf("%5d", sum);
                        System.out.println();
                    }
                }
            }

            for(int j = 0; j < sub; j++){
                sum = 0;
                for(int i = 0; i < sub; i++){
                    sum += table[i][j];
                }
                all += sum;
                System.out.printf("%5d", sum);
            }
            System.out.printf("%5d", all);
            System.out.println();
        }
        s.close();
    }

}

Measured memory_bytes: 31708
# 幅優先探索
from collections import deque

N, M = map(int, input().split())
AB = [map(int, input().split()) for _ in range(M)]

links = [[] for _ in range(N + 1)]
for a, b in AB:
    links[a].append(b)
    links[b].append(a)

result = [-1] * (N + 1)
q = deque([1])
while q:
    i = q.popleft()
    for j in links[i]:
        if result[j] == -1:
            result[j] = i
            q.append(j)
print('Yes')
print('\n'.join(str(i) for i in result[2:]))


Measured memory_bytes: 106232
N=input()
A=map(int,raw_input().split())
num=0
flag=1
while flag:
	flag=0
	for j in reversed(range(N-1)):
		if A[j+1]<A[j]:
			A[j+1],A[j]=A[j],A[j+1]
			flag=1
			num+=1

for m in range(N-1):
	print str(A[m]),
print A[N-1]
print num

Measured memory_bytes: 6424
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(){
  int n,w,h,x,y,Ma,sum;
  vector<vector<int>> g;
  int s,t;
  while(cin >> n){
    if(!n)break;
    cin >> w >> h;
    g.resize(h);
    REP(i,h){
      g[i].resize(w,0);
    }
    REP(i,n){
      cin >> x >> y;
      g[y-1][x-1]++;
    }
    cin >> s >> t;
    Ma=0;sum=0;
    /*    REP(i,h){
      REP(j,w)
	cout << g[i][j] << " ";
      cout << "\n";
      }*/
    REP(i,h-t+1){
      REP(j,w-s+1){
	REP(k,t){
	  REP(l,s){
	    sum += g[i+k][j+l];
	  }
	}
	Ma = max(sum,Ma);
	sum=0;
      }
    }
    cout << Ma << endl;
    g.clear();
  }
  return 0;
}

Measured memory_bytes: 3116
a=list(map(int,input().split()))
#print(a)
d=0
for i in range(a[0]+1):
    b=list(str(i))
    c=sum([(int(b[n])) for n in range(len(b))])
    #print(c)
    if a[1]<=c<=a[2]:
        d+=i
print(d)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using LL = int64_t;
const LL INF = 0x3f3f3f3f;
const LL mod = 1e9 + 7;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    LL W;
    while (cin >> n >> W) {
        map<LL, LL> a;
        a[0] = 0;
        for (int i = 0; i < n; i++) {
            LL v, w;
            cin >> w >> v;
            if (w > W || v <= 0) continue;
            vector<pair<LL, LL>> b;
            for (auto& i : a) {
                LL nw = w + i.first;
                if (nw > W) continue;
                LL nv = v + i.second;
                b.emplace_back(nw, nv);
            }
            auto s = a.begin();
            for (auto& i : b) {
                LL nw = i.first;
                LL nv = i.second;
                while (s != a.end() && s->first < nw) s++;
                if (s != a.end()) {
                    if (s->first == nw) {
                        if (s->second < nv) s->second = nv;
                        else continue;
                    } else {
                        if (prev(s)->second < nv) s = a.emplace(nw, nv).first;
                        else continue;
                    }
                } else {
                    s = a.emplace(nw, nv).first;
                }
                s++;
                while (s != a.end() && s->second <= nv) a.erase(s++);
            }
        }
        LL ans = 0;
        for (auto& i : a) ans = max(ans, i.second);
        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n, l;
    cin >> n >> l;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int idx = -1;
    rep(i, n-1) {
        if (a[i] + a[i+1] >= l) {
            idx = i;
            break;
        }
    }
    if (idx == -1) {
        cout << "Impossible" << endl;
        return 0;
    }
    cout << "Possible" << endl;
    vector<int> ans;
    for (int i = 0; i < n-1; ++i) {
        if (idx <= i) break;
        ans.push_back(i);
    }
    for (int i = n-2; i >= 0; --i) {
        if (i <= idx) break;
        ans.push_back(i);
    }
    ans.push_back(idx);
    rep(i, n-1) cout << ans[i] + 1 << endl;
}


Measured memory_bytes: 4320
# C - 755
import itertools

N = int(input())
ans = 0

for i in range(10):
    for j in itertools.product(['3','5','7'], repeat = i):
        if j.count('3') > 0 and j.count('5') and j.count('7'):
            if int(''.join(map(str,j))) <= N:
                ans += 1

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N;cin>>N;
	ll abs_nin = INF;
	ll sum = 0;
	int cnt_minus = 0;
	rep(i,N){
		ll t; cin>>t;
		if(t<0) ++cnt_minus;
		sum += abs(t);
		abs_nin = min(abs_nin, abs(t));
	}
	cout<<((cnt_minus%2)?sum-abs_nin*2:sum)<<endl;
	return 0;
}

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

using namespace std;
#define forn(i, n) for (ll i = 0; i < n; i++)
#define re return
#define fi first
#define mp make_pair
#define se second
#define sz(a) (int)a.size()
typedef long long ll;

const ll mod = 1e9 + 7, ma1 = 8, ma = 2 * 16 * 1024;
int n, nm, num[2 * ma];

vector<int> e[100000], reve[100000], use;
vector<int> nu, top, qq;
vector<pair<int, int> > a;

void dfs(int nu) {
	use[nu] = 1;
	for (int v : e[nu])
		if (!use[v])
			dfs(v);
	top.push_back(nu);
}

void dfs1(int nu) {
	use[nu] = 1;
	qq.push_back(nu);
	for (int v : reve[nu])
		if (!use[v])
			dfs1(v);
}

void add_edge(int l, int r, int nu) {
	if (l > r) re;
	if (l % 2) {
		e[nu].push_back(num[l]);
		reve[num[l]].push_back(nu);
		re add_edge(l + 1, r, nu);
	}
	if (r % 2 == 0) {
		e[nu].push_back(num[r]);
		reve[num[r]].push_back(nu);
		re add_edge(l, r - 1, nu);
	}
	add_edge(l / 2, r / 2, nu);
}

bool ok(int d) {
	//cout << d << "\n";
	forn (i, nm) {
		reve[i].resize(0);
		e[i].resize(0);
	}
	for (int j = ma - 1; j; j--) {
		reve[num[2 * j]].push_back(num[j]);
		reve[num[2 * j + 1]].push_back(num[j]);
		e[num[j]].push_back(num[2 * j]);
		e[num[j]].push_back(num[2 * j + 1]);
	}
	int j = 0;
	forn (i, 2 * n) {
		while (j < sz(a) && a[i].fi - a[j].fi > d)
			j++;
		//cout << j << " " << i << "\n";
		add_edge(j + ma, i + ma - 1, (a[i].se ^ 1));
	}
	j = 2 * n - 1;
	for (int i = 2 * n - 1; i >= 0; i--) {
		while (j >= 0 && a[j].fi - a[i].fi > d)
			j--;
		//cout << i << ", " << j << "\n";
		add_edge(i + ma + 1, j + ma, (a[i].se ^ 1));
	}
	// forn (i, nm) {
	// 	cout << i << ", ";
	// 	for (int v : e[i]) {
	// 		cout << v << " ";
	// 	}
	// 	cout << "\n";
	// }
	use.assign(nm, 0);
	top.resize(0);
	forn (i, nm) {
		if (!use[i])
			dfs(i);
	}
	use.assign(nm, 0);
	reverse(top.begin(), top.end());
	forn (nu, nm) {
		int i = top[nu];
		if (!use[i]) {
			qq.resize(0);
			dfs1(i);
			sort(qq.begin(), qq.end());
			/*forn (i, sz(qq)) {
				cout << qq[i] << " ";
			}
			cout << "\n";*/
			forn (i, sz(qq) - 1) {

				if (qq[i] == (qq[i + 1] ^ 1) && qq[i]+ 1 < 2 * n)
					re false;
			}
		}
	}
	re true;
}

int main() {
	iostream::sync_with_stdio(0);
	//freopen("a.in", "r", stdin);
	cin >> n;
	forn (i, n) {
		int x, y;
		cin >> x >> y;
		a.push_back(mp(x, 2 * i));
		a.push_back(mp(y, 2 * i + 1));
	}
	forn (i, 2 * ma) {
		num[i] = -1;
	}
	sort(a.begin(), a.end());
	forn (i, 2 * n) {
		num[i + ma] = a[i].se;
	}
	nm = 2 * n;
	for (int i = 1; i < 2 * ma; i++) {
		if (num[i] == -1) {
			num[i] = nm;
			nm++;
		}
		//cout << i << " k " << num[i] << "\n";
	}
	for (int j = ma - 1; j; j--) {
		e[num[j]].push_back(num[2 * j]);
		e[num[j]].push_back(num[2 * j + 1]);
	}
	// cout << ok(3);
	// re 0;
	int	l = -1, r = 1000* 1000 * 1001;
	while (r - l > 1) {
		int mid = (l + r) / 2;
		if (ok(mid))
			l = mid;
		else
			r = mid;
	}
	cout << r << "\n";
}

Measured memory_bytes: 21372
// Problem : A - Registration
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define itrep(at)	for(auto it=at.begin();it!=at.end();it++)
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
#define INF 1e18

#define MAX 200005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
void solve(lli the)
{
	char ch;
	db aa,bb,cc,dd,xx;
	string s1,s2,s3,str;
    lli i,j,k,a,b,c,d,n,m,l,r,x,y,z,low,high,mid,sum=0,ans=0,temp,t;
    cin >> s1 >> s2;
    s3="";
    a=s1.length();
    b=s2.length();
    if(a+1!=b){cout<<"No";return;}
    for(i=0;i<b-1;i++){
    	s3.pb(s2[i]);
    }
    if(s1==s3)	cout<<"Yes";
    else	cout<<"No";
    
    
}













int main()
{
	long long int t=1,c=1;
	//scanf("%lld",&t);
	while(t--){
		solve(c);
		c++;
	}
	return 0;
}
/* UJJWAL KESHRI */

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

#include <iostream>
#include <fstream>

//code by lynmisakura.wish to be accepted!
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

/***************************/
using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<long long> vl;
typedef pair<ll, ll> pi;
typedef vector<pair<ll, ll>> vpi;

//const long long INF = 1LL << 55;

#define itn ll
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(ll i = 0;i < n;i++)
#define rep(i,n) for(ll i = 0;i < n;i++)
#define flush fflush(stdout)
#define rrep(i,n) for(ll i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, ll mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

class BPalindromePhilia {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        string s;
        cin >> s;
        int ans = 0;
        int n = s.size();
        rep(i,s.size() / 2){
            if(s[i] != s[n-1-i])ans++;
        }
        cout << ans << endl;

    }
};

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


Measured memory_bytes: 256
n = int(input())
d, x = list(map(int, input().split()))
a = [0] * n
for _ in range(n):
    a[_] = int(input())

eat = 0
for _ in range(n):
    check = 1
    while check <= d:
        eat += 1
        check += a[_]
        # print(check,d,a[_])

print(x+eat)

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

int main() {
  int N, x, y;
  cin >> N;
  y = N;
  x = 0;
  // ここにプログラムを追記
  for(int i = 100000000; i >= 1; i /= 10) {
  	x += N / i;
    N %= i;
  }
  if(y % x == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {

	static BufferedReader reader;
	final static boolean MODE_DEBUG = false;
	//static field here
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		//code here
		int[] NM = readLineInt();
		int N = NM[0];
		int M = NM[1];
		int[] a = readLineInt();
		int ans = 0;
		for(int i=0;i<M;i++) {
			ans+=a[i];
		}
		
		if(ans<=N) {
			print(N-ans);
		}else {
			print("-1");
		}
		
	}
	
	//functions here
	//note that all methods should be STATIC


	private static <T> int arraySearch(T needle, T[] heystack) {
		for(int i=0;i<heystack.length;i++) {
			if(needle.equals(heystack[i])) {
				return i;
			}
		}
		return -1;
	}
	private static int[] sort(int[] base) {
		int[] copy = array_copy(base);
		Arrays.sort(copy);
		return copy;
	}
	private static int[] array_copy(int[] base) {
		int[] copy = new int[base.length];
		for(int i=0;i<base.length;i++) {
			copy[i] = base[i];
		}
		return copy;
	}
	private static int[] asArray(ArrayList<Integer> ints) {
		int[] intlist = new int[ints.size()];
		for(int i=0;i<intlist.length;i++) {
			intlist[i] = ints.get(i);
		}
		return intlist;
	}
	private static String[] readLine(){
		try{
			return reader.readLine().split(" ");
		}catch(Exception e){
			e.printStackTrace();
			return new String[]{e.getMessage()};
		}
	}
	private static int[] readLineInt(){
		try{
			String[] s = readLine();
			int[] ints = new int[s.length];
			for(int i=0;i<ints.length;i++) {
				ints[i] = Integer.parseInt(s[i]);
			}
			return ints;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static byte[] readLineByte(){
		try{
			String[] s = readLine();
			byte[] bytes = new byte[s.length];
			for(int i=0;i<bytes.length;i++) {
				bytes[i] = Byte.parseByte(s[i]);
			}
			return bytes;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static char[] readLineChar(){
		try{
			String[] s = readLine();
			char[] chars = new char[s.length];
			for(int i=0;i<chars.length;i++) {
				chars[i] = (char)Integer.parseInt(s[i]);
			}
			return chars;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static void print(Object o){
		System.out.println(o);
	}
	private static void print(){
		System.out.println();
	}
	private static void printd(Object o){
		if(MODE_DEBUG)System.err.println(o);
	}
	private static void printd(){
		if(MODE_DEBUG)System.err.println();
	}
}


Measured memory_bytes: 34468