akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define MAX 510000
#define INF 1<<30
#define LINF (ll)1<<62
#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()
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(){
    ll n; cin >> n;
    string s,t; cin >> s >> t;
    ll ans = 2*n;
    ll mx = 0;
    rep(i,n){
        REP(j,1,n-i+1){
            if(s.substr(i,j) == t.substr(0,j)){
                mx = max(mx, j);
            }
        }
    }
    cout << ans - mx << endl;
}

Measured memory_bytes: 256
import sys
import numpy as np 

I = np.array(sys.stdin.read().split(), dtype=np.int32)
n, k, q = I[:3]; a = I[3:] - 1

def main():
    res = np.full(n, k, dtype=np.int32) - q
    res += np.bincount(a, minlength=n)
    ans = np.full(n, 'No', dtype='U3')
    ans[res > 0] = 'Yes'
    print(*ans, sep='\n')

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 30008
#include<stdio.h>
#include<string.h>

int main(){
    int i=0,j=0;
    char s[102];char ch[10];
    scanf(" %[^\n]",s);
    ch[j]='A'+(s[i]-'a');
    j++;
    for(;i<strlen(s);i++) {
        if (s[i] == ' ') {
            i++;
            ch[j] = 'A' + (s[i] - 'a');
            j++;
        }
    }
            ch[j]='\0';
            printf("%s",ch);
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
using namespace std;
#define MOD 1000000007

int N;
long long a[3333];
long long dp[3333][3333];

long long dfs(int l, int r){
    if(l == r) return 0;
    if(dp[l][r]!=1LL<<60) return dp[l][r];

    dp[l+1][r] = dfs(l+1,r);
    dp[l][r-1] = dfs(l,r-1);

    if((N-r-l)%2==0){
        dp[l][r] = max(dp[l+1][r]+a[l], dp[l][r-1]+a[r-1]);
    }else{
        dp[l][r] = min(dp[l+1][r]-a[l], dp[l][r-1]-a[r-1]);
    }
    return dp[l][r];
}

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

    for(int i=0; i<=N; i++)
        for(int j=0; j<=N; j++)
            dp[i][j] = 1LL<<60;

    cout << dfs(0, N) << endl;
    return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

const int INF = 1 << 29;
const ll MOD = 1e+9 + 7;

ll fact[200010];
ll inv[200010];
ll factInv[200010];

void init() {
    fact[0] = 1;
    REP (i, 1, 200010) fact[i] = fact[i - 1] * i % MOD;

    inv[1] = 1;
    REP (i, 2, 200010) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;

    factInv[0] = 1;
    REP (i, 1, 200010) factInv[i] = factInv[i - 1] * inv[i] % MOD;
}

ll modComb(int n, int r) {
    return fact[n] * factInv[n - r] % MOD * factInv[r] % MOD;
}

int main() {
    init();

    int H, W, A, B;
    cin >> H >> W >> A >> B;
    ll ans = 0;
    rep (i, H - A) {
        int h1 = i + 1;
        int w1 = B;
        int h2 = H - i;
        int w2 = W - B;
        ans = (ans + modComb(h1 + w1 - 2, w1 - 1) * modComb(h2 + w2 - 2, w2 - 1)) % MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(ll i = 0; i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,e) for (ll i = s; i < (ll)e; i++)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll n; cin >> n;
	vl a(n); REP(i, n) cin >> a[i];

	ll mi = TEN(15);
	FOR(i, -100, 101) {
		ll sum = 0;
		REP(j, n) sum += (i - a[j]) * (i - a[j]);
		mi = min(mi, sum);
	}
	cout << mi << endl;

	return 0;
}

Measured memory_bytes: 256
def g;gets.split.map &:to_i;end
while(x,y=g;x>0)
a,b=c=[g,g]
puts a==b ?0:(
h={c=>0}
q=[c+[0]]
m=(1..y).map{g<<1}<<[1]*x*2
d=[[0,1],[1,0],[0,-1],[-1,0]]
1 while(*c,e=q.shift;e&&(0..3).all?{|i|
  t,u=z=c.zip([d[i],d[i-2]]).map{|(j,k),(v,w)|m[k+w-1][j+v-1]==0?[j+v,k+w]:[j,k]}
  t!=u&&(h[z]||=(e<99&&q<<z+[e+1];0))
})
e ?e+1:"NA"
)
end

Measured memory_bytes: 61664
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Kenji
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();
            int K = in.nextInt();
            int k = K;
            int current = A;
            Set<Integer> set = new TreeSet<>();
            while (k > 0) {
                if (current > B) break;
                set.add(current);
                current++;
                k--;
            }

            for (int i = B - K + 1; i <= B; i++) {
                if (i < A) continue;
                set.add(i);
            }

            for (Integer i : set) {
                out.println(i);
            }
        }

    }
}



Measured memory_bytes: 22740
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
n,m = gets.chomp.split.map(&:to_i)
s=[]
m.times do
  tmp = gets.chomp.split.map(&:to_i)
  tmp.shift
  s.push tmp
end
q = gets.chomp.split.map(&:to_i)

ans = 0
d=n
(2**d).times do |i|
  bits = i.to_s(2).split(//)
  (d - bits.length).times{bits.unshift('0')}
  bits.map!(&:to_i)

  flg = true
  s.each_with_index do |sw, index|
    sum = sw.each.map{|e| bits[e-1]}.inject(&:+)
    if sum % 2 != q[index]
      flg = false
      break
    end
  end
  ans += 1 if flg
end

puts ans


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define AC ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
const int M = 1e9+7;
const int N = 2*1e5;

int n, k;

int main(){
    AC
    cin>>n;
    cout<<n+n*n+n*n*n<<endl;
}

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define Cin(x) cin >> x
#define Cin2(x,y) cin >> x >> y
#define Cin3(x,y,z) cin >> x >> y >> z
#define Cin4(w,x,y,z) cin >> w >> x >> y >> z
#define Cout(x) cout << x << "\n"
#define Cout2(x,y) cout << x << y << "\n"
#define Cout3(x,y,z) cout << x << y << z << "\n"
#define Cout4(w,x,y,z) cout << w << x << y << z << "\n"
#define Kaigyou cout << "\n"
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define Size(n) (n).size()
#define All(v) (v).begin(), (v).end()

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

    ll x; Cin(x);
    if(x<1200) Cout("ABC");
    else Cout("ARC");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
V<ll>fac,rfac;void setFac(int n, int mod){fac=rfac=V<ll>(++n);fac[0]=1;FOR(i,1,n)fac[i]=fac[i-1]*i%mod;rfac[n-1]=modInv(fac[n-1],mod);FORR(i,n-1,1)rfac[i-1]=rfac[i]*i%mod;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n, x, d;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> x;
  int ans = 1;
  FOR(i, 0, n){
    int l;
    cin >> l;
    d += l;
    if(d <= x) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define this-> tt
#define long long ll
using namespace std;
int main ()
{
 int k;
 string s;
 cin>>k>>s;
 if (k>=s.size())cout<<s<<endl;
 else
    for (int i=0;i<k;i++)
 {
     cout<<s[i];
     if (i==k-1)cout<<"..."<<endl;
 }




    return 0;
}

/*
▀█████████▄     ▄████████    ▄████████    ▄████████
  ███    ███   ███    ███   ███    ███   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
 ▄███▄▄▄██▀    ███    ███  ▄███▄▄▄▄██▀   ███    ███
▀▀███▀▀▀██▄  ▀███████████ ▀▀███▀▀▀▀▀   ▀███████████
  ███    ██▄   ███    ███ ▀███████████   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
▄█████████▀    ███    █▀    ███    ███   ███    █▀
                            ███    ███

*/


Measured memory_bytes: 3628
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	//iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
void solve() {
	while (true) {
		int n;
		cin >> n;
		if (n == 0) return;
		vector<string> inputs;
		REP(i, n) {
			string a;
			cin >> a;
			string b;
			b.push_back(a[0]);
			for (int i = 0; i < a.size(); ++i) {
				string c = "aiueo";
				int ok = 0;
				REP(j, c.size()) {
					if (a[i] == c[j])ok = 1;
				}
				if (ok == 1) {
					b.push_back(a[i + 1]);
				}
			}
			inputs.push_back(b);
		}
		int ans = -1;
		for (int i = 1; i < 100; ++i) {
			map<string, int> goo;
			REP(q, inputs.size()) {
				string b;
				REP(j, min((ll)inputs[q].length(), i)) {
					b.push_back(inputs[q][j]);
				}
				goo[b]++;
			}
			int ok = 1;
			for (auto x : goo) {
				if (x.second >= 2) ok = 0;
			}
			if (ok == 1) {
				ans = i;
				break;
			}
		}
		cout << ans << endl;
	}
}
#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3188
import Data.Char (toLower)

main :: IO ()
main = do
  (_ : k : _) <- map read . words <$> getLine :: IO [Int]
  s <- getLine :: IO String
  let
    (pr, (c : sf)) = splitAt (pred k) s
    s' = pr ++ (toLower c : sf)
  putStrLn s'


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double llf;
typedef pair<int, int> pii;
const int maxn = 4e4 + 5;
const int inf = 2e9 + 7;
int a[maxn], b[maxn];

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

	llf a, b;
	cin >> a >> b;

	for (llf i = 1; i < 2e4; ++i) {
		llf aa = i * 0.08, bb = i * 0.1;
		if (aa - a < 1.0 && aa >= a && bb - b < 1.0 && bb >= b) {
			cout << i << endl;
			return 0;
		}
	}
	cout << "-1\n";

	return 0;
}


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

int main() {
    int n, x, y; cin >> n >> x >> y;

    vector<int> answer(n, 0);
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            int dist = abs(i - j);
            dist = min(dist, abs(i - x) + 1 + abs(y - j));
            answer[dist]++;
        }
    }

    for (int i = 1; i <= n - 1; i++) {
        cout << answer[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		sc.close();

		int max = 0;
		for (int i = 0; i < N - 1; i++) {
			int ans = 0;
			String S1 = S.substring(0, i + 1);
			String S2 = S.substring(i + 1);
			char[] c1 = S1.toCharArray();
			char[] c2 = S2.toCharArray();
			for (char c = 'a'; c <= 'z'; c++) {
				boolean A = false, B = false;
				for (int j = 0; j < S1.length(); j++) {
					if (c1[j] == c) {
						A = true;
					}
				}
				for (int j = 0; j < S2.length(); j++) {
					if (c2[j] == c) {
						B = true;
					}
				}
				if (A && B)
					ans++;
			}
			if (max < ans) {
				max = ans;
			}
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 21716
#!/usr/bin/env ruby

n = STDIN.gets.chomp.to_i

def digits(int)
  int.to_s.length
end

def f(a, b)
  digits_a = digits(a)
  digits_b = digits(b)
  digits_a > digits_b ? digits_a : digits_b
end

def main(n)
  ans = digits(n)
  i = 2

  while i**2 <= n
    if n % i == 0
      f_a_b = f(i, n/i)
      ans = ans < f_a_b ? ans : f_a_b
    end
    i += 1
  end

  puts ans
end

main(n)


Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
using namespace std;
const int INF = 1000000000000;
const int mod = 1000000007;
int cnt[345678];
signed main() {
	int n, x, y; cin >> n >> x >> y;
	for (int h = 1; h <= n; h++) {
		for (int i = h + 1; i <= n; i++) {
			cnt[min(i - h, abs(x - h) + abs(i - y) + 1)]++;
			//cout << h << ' ' << i << ' ' << min(i - h, abs(x - h) + abs(i - y)) << endl;
		}
	}
	for (int h = 1; h < n; h++) {
		cout << cnt[h] << endl;
	}
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

std::vector<int> primes(int n) {
    std::vector<int> primes;
    std::vector<bool> isPrime(n+1, true);
    for (int i = 2; i <= n; i++) {
        if (!isPrime[i]) continue;
        primes.push_back(i);
        long long buf = i * 2;
        while (buf <= n) {
            isPrime[buf] = false;
            buf += i;
        }
    }

    return primes;
}

std::map<int, int> prime_fact(long long n) {
    std::map<int, int> cnt;

    long long m = n;
    for (int i: primes(int(sqrt(n))+1)) {
        if (m % i == 0) {
            cnt[i] = 1;
            m /= i;
        }
        while (m % i == 0) {
            cnt[i]++;
            m /= i;
        }
    }
    if (m != 1) {
        cnt[m] = 1;
    }

    return cnt;
}

int n, m;
string s;

int main() {
    cin >> n;

    Mii ps;
    REP2(i, 1, n+1) {
        Mii p = prime_fact(i);
        FOR(j, p) {
            int num = j->first, cnt = j->second;
            if (ps.count(num) == 1) {
                ps[num] += cnt;
            } else {
                ps[num] = cnt;
            }
        }
    }

    ll res = 1;
    FOR(i, ps) {
        res *= i->second + 1;
        res %= MOD;
    }
    std::cout << res << '\n';

    return 0;
}


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

for i in range(n):
    x[i]=list(map(int,input().split()))

a=0
for i in range(n):
    if x[i][0]**2+x[i][1]**2<=d**2:
        a+=1

print(a)

Measured memory_bytes: 93852
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
using namespace std;

typedef long long ll;
typedef short int sh;

const int inf=0x3f3f3f3f;
const int MAX=1e5+10;
const int mod=1e9+7;

vector<int>vec[26];
char str[MAX];

void Get_Pos()
{
    for(int i=0;str[i];i++)
    {
        int k=str[i]-'a';
        vec[k].push_back(i);
    }
}

void Solve()
{
    for(int i=0;i<26;i++)
    {
        int l=vec[i].size();
        for(int j=0;j<l;j++)
        {
            int t=vec[i].at(j);
            for(int k=j+1;k<l;k++)
            {
                int r=vec[i].at(k);
                if(((k-j+1)<<1)>r-t+1)
                {
                    printf("%d %d\n",t+1,r+1);
                    return;
                }
            }
        }
    }
    printf("-1 -1\n");
}

int main()
{
    int n;
    while(scanf("%s",str)!=EOF)
    {
        Get_Pos();
        Solve();
    }
    return 0;
}

Measured memory_bytes: 3760
#include <cstdio>
#include <algorithm>
#include <cstring>
#define C(n) ((n)*((n)-1)>>1)
using namespace std;
char s[200000+10];
long long ans, p,q,n,cnt[233];

int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for (long long i=1;i<=n;++i)
	  ++cnt[s[i]-'a'];
	ans=C(n);
	for (long long i=0;i<26;++i)
	  ans-=C(cnt[i]);
	printf("%lld",ans+1);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <thread>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)

using namespace std;

int main()
{
	int n, k; cin >> n >> k;
	string s; cin >> s;

	vector<int> segments(n + 1);
	int s_count = 0;
	segments[0] = 0;

	bool is_prev_zero = false;
	FOR_LT(i, 0, s.size()) {
		bool is_zero = s[i] == '0';

		if (is_prev_zero != is_zero) {
			s_count++;
		}
		segments[s_count]++;
		is_prev_zero = is_zero;
	}
	s_count++;

	int max_val = 0;
	int val = 0;
	queue<int> windows;
	FOR_LT(i, 0, s_count) {
		if (i & 1) {
			if (windows.size() == k) {
				max_val = max(max_val, val);

				val -= windows.front();
				windows.pop();
			}
			windows.push(segments[i] + segments[i - 1]);
		}
		val += segments[i];
	}

	max_val = max(max_val, val);

	cout << max_val << endl;

	return 0;
}

Measured memory_bytes: 896
#include<iostream>
using namespace std;
int n,i,t,s,x,y;
int main(){
	cin>>n;
	int p[n][3];
	for(;i<n;i++){cin>>p[i][0]>>p[i][1]>>p[i][2];t=p[i][2]?i:t;}
	for(;x<101;x++)for(y=0;y<101;y++){
		for(i=0;i<n;i++)if(p[i][2]!=max((s=p[t][2]+abs(x-p[t][0])+abs(y-p[t][1]))-abs(x-p[i][0])-abs(y-p[i][1]),0))break;
		if(i==n){cout<<x<<" "<<y<<" "<<s<<endl;return 0;}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>

using namespace std;

class Dice {
public:
    explicit Dice(int a[]) {
        for (int i = 0; i < 6; ++i) {
            face[i] = a[i];
        }
    }

    void rotate(char dir);
    void loop_swap(int a[]);

    static int rotate_itr[4][4];
    static map<char, int> c2i;
    int face[6];
};

/* ----- member funcs of Dice class ----- */

void Dice::rotate(char dir) {
    loop_swap(rotate_itr[c2i[dir]]);
}

int Dice::rotate_itr[4][4] = {
    {0, 1, 5, 4},  // N
    {0, 3, 5, 2},  // E
    {0, 2, 5, 3},  // W
    {0, 4, 5, 1},  // S
};

map<char, int> Dice::c2i = {{'N', 0}, {'E', 1}, {'W', 2}, {'S', 3}};

void Dice::loop_swap(int a[]) {
    int tmp = face[a[0]];
    for (int i = 0; i < 3; ++i) {
        face[a[i]] = face[a[i + 1]];
    }
    face[a[3]] = tmp;
}

/* ----- main func ----- */

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

    Dice dice(a);

    string S;
    cin >> S;
    for (char c : S) {
        dice.rotate(c);
    }

    cout << dice.face[0] << endl;
    return 0;
}



Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)


long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}


int main(){
    int A,B;
    cin >> A >> B;
    int i=0;
    
    while(1){
        if( int(i*0.08) > A && int(i * 0.1) > B){
            cout << -1 << endl;
            return 0;
        }
        if(int(i * 0.08) == A && int(i * 0.1) == B){
            break;
        }
        i++;
    }
    
    
    cout << i << endl;
    
    return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>
int main(void)
{
int a, b, c;

scanf("%d %d %d",&a,&b,&c);

if(a > b){
   if(b > c)
     printf("%d %d %d",c,b,a);
   else if(a > c)
     printf("%d %d %d",b,c,a);
   else
     printf("%d %d %d",b,a,c);
}

else{
   if(a > c)
     printf("%d %d %d",c,a,b);
   else if(b > c)
     printf("%d %d %d",a,c,b);
   else
     printf("%d %d %d",a,b,c);
}
printf("\n");

return 0;
}

Measured memory_bytes: 600
from heapq import heappop, heappush
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
p = [int(x) for x in input().split()]


class SegmentTree:  # 0-indexed
    def __init__(self, array, operation=min, identity=10**30):
        self.identity = identity
        self.n = len(array)
        self.N = 1 << (self.n - 1).bit_length()
        self.tree = [self.identity] * 2 * self.N
        self.opr = operation
        for i in range(self.n):
            self.tree[i+self.N-1] = array[i]
        for i in range(self.N-2, -1, -1):
            self.tree[i] = self.opr(self.tree[2*i+1], self.tree[2*i+2])

    def values(self):
        return self.tree[self.N-1:]

    def update(self, k, x):
        k += self.N-1
        self.tree[k] = x
        while k+1:
            k = (k-1)//2
            self.tree[k] = self.opr(self.tree[k*2+1], self.tree[k*2+2])

    def query(self, p, q):  # [p,q)
        if q <= p:
            print("Oops!  That was no valid number.  Try again...")
            exit()
        p += self.N-1
        q += self.N-2
        res = self.identity
        while q-p > 1:
            if p & 1 == 0:
                res = self.opr(res, self.tree[p])
            if q & 1 == 1:
                res = self.opr(res, self.tree[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.opr(res, self.tree[p])
        else:
            res = self.opr(self.opr(res, self.tree[p]), self.tree[q])
        return res


ind = [0]*(n+1)
Odd = SegmentTree([10**30]*n)
Even = SegmentTree([10**30]*n)

for i in range(n):
    ind[p[i]] = i
    if i % 2 == 0:
        Even.update(i, p[i])
    else:
        Odd.update(i, p[i])

cand = []
heappush(cand, (Even.query(0, n), 0, n, True))

q = []
while len(q) < n:
    first, l, r, is_even = heappop(cand)
    if is_even:
        second = Odd.query(ind[first]+1, r)
        q.extend([first, second])
        if l < ind[first]:
            heappush(cand, (Even.query(l, ind[first]), l, ind[first], True))
        if ind[first] + 1 < ind[second]:
            heappush(
                cand, (Odd.query(ind[first]+1, ind[second]), ind[first]+1, ind[second], False))
        if ind[second]+1 < r:
            heappush(
                cand, (Even.query(ind[second], r), ind[second]+1, r, True))
    else:
        second = Even.query(ind[first]+1, r)
        q.extend([first, second])
        if l < ind[first]:
            heappush(cand, (Odd.query(l, ind[first]), l, ind[first], False))
        if ind[first] + 1 < ind[second]:
            heappush(
                cand, (Even.query(ind[first]+1, ind[second]), ind[first]+1, ind[second], True))
        if ind[second]+1 < r:
            heappush(
                cand, (Odd.query(ind[second], r), ind[second]+1, r, False))

print(*q)


Measured memory_bytes: 151568
from sys import stdin,stdout

for _ in range(1):
	#n,shift,ch=stdin.readline().split()
	days,ass=map(int,stdin.readline().split())
	s=sum(map(int,stdin.readline().split()))
	ans=-1 if days-s<0 else days-s
	stdout.write(str(ans)+'\n')

Measured memory_bytes: 9548
// ABC157 B - Checkpoints
'use strict';

function Main(input) {
    const tmp = input.trim().split('\n');
    const NM = tmp[0].split(' ');
    const N = Number(NM[0]);
    const M = Number(NM[1]);
    let students = tmp
        .slice(1, N + 1)
        .map((v) => v.split(' ').map((v) => Number(v)));
    const checkpoints = tmp
        .slice(N + 1)
        .map((v) => v.split(' ').map((v) => Number(v)));
    // console.log(N, M, students, checkpoints);

    for (const student of students) {
        let point = -1
        let near = Number.MAX_VALUE;
        for (let i = 0; i < M; i++) {
            const d = distance(student, checkpoints[i]);
            if (d < near) {
                near = d;
                point = i + 1;
            }
        }
        console.log(point);
    }

    return;
}

function distance(a, b) {
    return Math.abs(a[0]- b[0]) + Math.abs(a[1] - b[1]);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21192
// E. Magical Permutation
// time limit per test1 second
// memory limit per test256 megabytes
// inputstandard input
// outputstandard output
// Kuro has just learned about permutations and he is really excited to create a
// new permutation type. He has chosen 𝑛 distinct positive integers and put all
// of them in a set 𝑆. Now he defines a magical permutation to be:

// A permutation of integers from 0 to 2𝑥−1, where 𝑥 is a non-negative integer.
// The bitwise xor of any two consecutive elements in the permutation is an
// element in 𝑆. Since Kuro is really excited about magical permutations, he
// wants to create the longest magical permutation possible. In other words, he
// wants to find the largest non-negative integer 𝑥 such that there is a magical
// permutation of integers from 0 to 2𝑥−1. Since he is a newbie in the subject,
// he wants you to help him find this value of 𝑥 and also the magical
// permutation for that 𝑥.

// Input
// The first line contains the integer 𝑛 (1≤𝑛≤2⋅105) — the number of elements in
// the set 𝑆.

// The next line contains 𝑛 distinct integers 𝑆1,𝑆2,…,𝑆𝑛 (1≤𝑆𝑖≤2⋅105) — the
// elements in the set 𝑆.

// Output
// In the first line print the largest non-negative integer 𝑥, such that there
// is a magical permutation of integers from 0 to 2𝑥−1.

// Then print 2𝑥 integers describing a magical permutation of integers from 0 to
// 2𝑥−1. If there are multiple such magical permutations, print any of them.

// Examples
// inputCopy
// 3
// 1 2 3
// outputCopy
// 2
// 0 1 3 2
// inputCopy
// 2
// 2 3
// outputCopy
// 2
// 0 2 1 3
// inputCopy
// 4
// 1 2 3 4
// outputCopy
// 3
// 0 1 3 2 6 7 5 4
// inputCopy
// 2
// 2 4
// outputCopy
// 0
// 0
// inputCopy
// 1
// 20
// outputCopy
// 0
// 0
// inputCopy
// 1
// 1
// outputCopy
// 1
// 0 1
// Note
// In the first example, 0,1,3,2 is a magical permutation since:

// 0⊕1=1∈𝑆
// 1⊕3=2∈𝑆
// 3⊕2=1∈𝑆
// Where ⊕ denotes bitwise xor operation.

#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

using namespace std;

int n, m, d;
int i, j, k;

void solve() {
  cin >> n;
  vector<int> a(n + 1);
  int res = 0;
  int count;
  for (i = 1; i <= n; ++i) cin >> a[i];
  vector<int> b(n + 1);
  for (j = n; j >= 1; --j) {
    count = 0;
    for (i = j; i <= n; i += j) {
      count += b[i];
    }
    if (count % 2 != a[j]) {
      b[j] = 1;
      res += 1;
    }
  }
  cout << res << endl;
  for (i = 1; i <= n; ++i) {
    if (b[i] == 1) cout << i << endl;
  }
  return;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}


Measured memory_bytes: 2560
// abc.cpp : Green Bin
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

	map<string,int> m;
	for(int i=0; i<n; i++){
		string s; cin>>s;
		sort(s.begin(), s.end());
		m[s]++;
	}

	ll ans=0;
	for(auto e: m) if(e.second>1) ans += (ll)e.second * (e.second-1) / 2;
	cout<< ans <<endl;
}

Measured memory_bytes: 11136
r,c = map(int,raw_input().split())
cels = []
for i in xrange(r):
    cols = map(int, raw_input().split())
    cels.append(cols)

for i in xrange(r):
    cels[i].append(sum([ j for j in cels[i]]))

sum_c=[]
for i in xrange(c):
    sum_c.append(sum([cels[n][i] for n in xrange(r)]))

cels.append(sum_c)
cels[r].append(sum(cels[r]))

for i in xrange(r+1):
    print " ".join(map(str,cels[i]))

Measured memory_bytes: 6464
#include<bits/stdc++.h>
using namespace std;
using namespace std::chrono; 
#define ll long long
#define fo(i,v,e) for(v=i;v<e;v++)
#define pb(x) push_back(x)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fi first 
#define se second
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vl vector<ll>
#define sz(x) (int)x.size()
#define ull unsigned long long
#define vvi vector<vi>
#define vvl vector<vl>
#define vpi vector<pii>
#define vpl vector<pll>
ll mod = 1000000007;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x);
#else
#define deb(x...)
#endif
vector<ll> sieveOfErthnosis(ll n)
{
    vector<bool>flag(n+5,false);
    vector<ll>primes;
    for(int i=2;i*i<=n;i++)
    {
        if(!flag[i])
        {
            for(int j=i*i;j<=n;j+=i)
            {flag[j]=true;}
        }
    }
    for (int  i = 2; i < n+1; i++)
    {
        if(!flag[i])primes.pb(i);
    }
    return primes;
}
void init()
{
    
}
void solve()
{
    ll a,b,c,d;cin>>a>>b>>c>>d;
    ll tt = ceil(double(a)/d);
    ll at = ceil(double(c)/b);
    // deb(tt,at)
    cout<<(tt>=at?"Yes":"No")<<endl;
}
int main()
{
    init();
    #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    #endif
    auto start = high_resolution_clock::now(); 
    int T = 1;
    // cin>>T;
    while(T--)
    {
        solve();
    }
    auto stop = high_resolution_clock::now(); 
    auto duration = duration_cast<milliseconds>(stop - start); 
    #ifndef ONLINE_JUDGE
    // cout << "time taken : "<<duration.count()<<" ms" << endl;
     #endif
}


Measured memory_bytes: 3672
H,N=map(int,input().split())
AB=[]
for i in range(N):
  AB.append(list(map(int,input().split())))
dp=[10**8]*(H+1)
dp[0]=0
i=0

for i in range(H+1):
  for A,B in AB:
    if i-A>=0:
      dp[i]=min(dp[i-A]+B,dp[i])
  for A,B in AB:
    if i+A>H:
      dp[-1]=min(dp[-1],dp[i]+B)
print(dp[-1])


Measured memory_bytes: 74440
import numpy as np

n, m, c = map(int, input().split())
B = np.array(list(map(int, input().split())))

ans = 0
for _ in range(n):
    A = np.array(list(map(int, input().split())))
    if np.dot(A, B) + c > 0:
        ans += 1
print(ans)

Measured memory_bytes: 13660
#include<bits/stdc++.h>
using namespace std;
#define vb __int128
#define ll long long
#define ld long double
#define full(a) a.begin(),a.end()
#define stoink stack<ll>
#define vec vector <ll>
#define vg vector<vector<ll> >
#define vgw vector<vector<pair<ll,ll> >
#define pa pair<ll,ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pre 0.00000000000000000001
#define inf 1000000000000
#define mod 1000000007
vector<vector<char>> arr;
vector<vector<ll>> dp;
ll x,y;
ll func(ll i,ll j) {
	if(dp[i][j] !=-1)
		return dp[i][j];
	ll res = 0;
	if(arr[i-1][j] != '#')
		res = (res + func(i-1,j)) % mod;
	if(arr[i][j-1] != '#')
		res = (res +  func(i,j-1)) % mod;
	return dp[i][j] = res;
}
int main()
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> x >> y;
	arr.resize(x+1,vector<char>(y+1,'#'));
	dp.resize(x+1,vector<ll>(y+1,-1));
	ll i,j;
	dp[1][1] = 1;
	for(i = 1; i <= x ; i++)
		for(j = 1; j <= y ; j++)
			cin >> arr[i][j];
	cout << func(x,y);
	return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  
  int count = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) != t.at(i)) count++;
  }
  cout << count;
}


Measured memory_bytes: 3824
import sys
import math

mod = 10**9 + 7
N, M = map(int, sys.stdin.readline().split())
diff = abs(N - M)
if diff > 1:
    print(0)
    sys.exit()

n_p = 1
for i in range(1, N+1):
    n_p *= i
    n_p %= mod
m_p = 1
for i in range(1, M+1):
    m_p *= i
    m_p %= mod

if diff == 0:
    print(2 * n_p * m_p % mod)
else:
    print(n_p * m_p % mod)

Measured memory_bytes: 9144
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a,b;
	int sum=0;
	cin>>a>>b;
	for(int i=0;i<a.size();i++)
	if(a[i]!=b[i])sum++;
	cout<<sum;
	return 0;
 } 

Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, x = 0;
  cin >> a;
  if (a / 100 == 1) {
    x++;
  }
  if (a / 10 % 10 == 1) {
    x++;
  }
  if (a % 10 == 1) {
    x++;
  }
  
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define inf 2000000000
#define infLL 2000000000000000000
#define MAX 300006
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d\n", a)
#define pfl(a) printf("%lld\n", a)
#define Case(t) printf("Case %d: ", t)
#define pii pair<int, int>
#define MOD 998244353
#define PI acos(-1.0)
#define eps 1e-9

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

clock_t t_Start;
void Start()
{
    t_Start = clock();
}
void End()
{
    double Time = (double)(clock()-t_Start)/CLOCKS_PER_SEC;
    error(Time);
}

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Start();

    string s, t;
    cin>>s>>t;
    cout<<t<<s<<endl;

    //End();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
 
int main()
{
   map<ll, ll> mp;
   mp[0]++;
   int N;
   cin >> N;
   ll a, sum = 0;
   ll ans = 0;
   for(int i = 0; i < N; i ++)
    {
          cin >> a;
         sum += a;
         ans += mp[sum];
        mp[sum] ++;
     }
    cout << ans << endl;
   return 0;
}

Measured memory_bytes: 12800
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
const int nMax=1e5+10;
int cnt=0;
char s[nMax];
int main()
{
	scanf("%s",s+1);
	int len=strlen(s+1);
	for(int i=2;i<=len;i++)
		if(s[i]!=s[i-1])
			cnt++;
	cnt++;
	printf("%d\n",cnt-1);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(ll i = a; i < b; i++)
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
ll fact(ll x){
    ll res = 1;
    REP(i,1,x+1) res = (res * i) % MOD;
    return res;
}
int main(){
    int n, m;
    cin >> n >> m;
    if(abs(n-m) > 1) cout<<0<<endl;
    else {
        ll val1 = fact(n);
        ll val2 = fact(m);
        ll res = (val1 * val2) % MOD;
        if(n == m) res = (res * 2) % MOD;
        cout<<res<<endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

char s[256] = {};
vl v;

int main(){
	ll k; scanf("%s%lld", s, &k);
	int n = strlen(s);
	// REP(i, n) s[n+i] = s[i];
	{
		int i = 0;
		while(i < n){
			int j = i;
			while(s[j] == s[i]) j++;
			DEBUG("[%d, %d)\n", i, j);
			v.EB(j-i);
			i = j;
		}
	}
	ll ans = 0;
	if(s[0] == s[n-1]){
		if((int)v.size() == 1){
			ans = n * k / 2;
		} else {
			FOR(i, 1, (int)v.size()-1){
			 	ans += v[i]/2;
			}
			ans *= k;
			ll a = *v.begin(), b = *v.rbegin();
			ans += a/2 + b/2 + (a+b)/2 * (k-1);
		}
	} else {
		for(ll &i : v) ans += i / 2;
		ans *= k;
	}
	printf("%lld\n", ans);
}


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

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

int main(){
int n;
cin>>n;
ll a[n];
vector<ll>b;
rep(i,n){
  cin>>a[i];
}
if(n%2==0){
for(int i=n;i>1;i-=2){
  cout<<a[i]<<" ";
}
for(int i=1;i<n;i+=2){
  cout<<a[i]<<" ";
}

}else
{
  for(int i=n;i>0;i-=2){
    cout<<a[i]<<" ";
  }
  for(int i=2;i<n;i+=2){
    cout<<a[i]<<" ";
  }
}


  return 0;
}


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

void solve()
{
    int n;
    cin>>n;
    vector<int> v, v1, v2;
    for(int i=1; i<=n; i++)
    {
        int x;
        cin>>x;
        v1.push_back(x);
    }
    for(int i=1; i<=n; i++)
    {
        int x;
        cin>>x;
        v2.push_back(x);
    }
    for(int i=1; i<=n; i++)
    {
        v.push_back(i);
    }
    int x=0; int a=-1;
    do
    {
        x++;
        if(v==v1)
        {
           a=x;
        }
    }
    while(next_permutation(v.begin(),v.end()));

    int y=0;
    do
    {
        y++;
        if(v==v2)
        {
            break;
        }

    }

    while(next_permutation(v.begin(),v.end()));

    cout<<abs(a-y)<<endl;


}
int main()
{
    int t;
    t=1;
    while(t--)
    {
        solve();

    }
    return 0;
}


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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	int ans = 0;
	if (N % 2 == 0){
		ans = N/2;
	} else {
		ans = N/2+1;
	}


	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
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 (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  ll N;
  cin >> N;
  bool flag = false;
  while(N>0){
    if(N%10 == 7) flag = true;
    N /= 10;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  }

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
int main()
{
    ll n, x, t;
    cin >> n >> x >> t;
    if (n - x * t <= 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define X first
#define Y second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int N = 100010;
int n,x,y,z;
vector<PII> v[N];
int sz[N];
ll f[N],ans;
void dfs(int x,int fa){
	int t;
	sz[x] = 1;
	for(int i =0;i<v[x].size();i++) if((t=v[x][i].X)!=fa){
		dfs(t,x);
		sz[x]+=sz[t];
		f[x]+=f[t]+1ll*v[x][i].Y*sz[t];
	}
}
void dfs2(int x,int fa,int s,ll sum){
	//cout<<x<<endl;
	int mx = s;
	int t;
	ll tmp = 0;
	for(int i =0;i<v[x].size();i++)if((t=v[x][i].X)!=fa){
		mx = max(mx,sz[t]);
		sum += f[t]+1ll*v[x][i].Y*sz[t];
	}
	int mi = 1e9;
	for(int i = 0;i<v[x].size();i++) mi = min(mi,v[x][i].Y);
	if(mx*2<=n){
		//cout<<x<<' '<<sum<<' '<<mi<<endl;
		
		if(mx*2==n){
			mi = -1;
			for(int i =0;i<v[x].size();i++) if((t=v[x][i].X)!=fa){
				if(sz[t]*2==n) mi = v[x][i].Y;
			}
		
			if(mi==-1){
				for(int i =0;i<v[x].size();i++) if((t=v[x][i].X)==fa){
					mi = v[x][i].Y;
				}
			}
		}
		ans = min(ans,2*sum-mi);
	}
	for(int i =0;i<v[x].size();i++)if((t=v[x][i].X)!=fa){
		//mx = max(mx,sz[t]);
		dfs2(t,x,n-sz[t],sum-f[t]-1ll*v[x][i].Y*sz[t]+1ll*(n-sz[t])*v[x][i].Y);
	}
}
int main(){
	scanf("%d",&n);
	for(int i = 1;i<n;i++){
		scanf("%d%d%d",&x,&y,&z);
		v[x].push_back(mp(y,z));
		v[y].push_back(mp(x,z));
	}
	dfs(1,0);
	ans = 1e18;
	dfs2(1,0,0,0);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 13568
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, K: int, R: int, S: int, P: int, T: str):
    score = [R, S, P]

    ans = 0
    past = []
    for i, t in enumerate(T):
        if t == "r":
            cand = 2
        elif t == "s":
            cand = 0
        else:
            cand = 1
        if i - K >= 0 and past[i-K] == cand:
            ans += 0
            past.append(-1)
        else:
            ans += score[cand]
            past.append(cand)
    print(ans)
    # print(past)

    return


def main():

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


if __name__ == '__main__':
    main()


Measured memory_bytes: 4212
def solve():
    h, w = map(int, input().split())
    a = [list(input()) for _ in range(h)]
    for i in range(h-1):
        for j in range(w-1):
            if a[i][j:j+2] == ["#","#"]:
                if a[i+1][j] == '#':
                    print("Impossible")
                    exit()
        for k in range(1,w):
            if a[i][k] == "#":
                if a[i+1][k-2:k] == ["#","#"]:
                    print("Impossible")
                    exit()
    if a[h-2][-1] == "#":
        if a[h-1][-2] == "#":
            print("Impossible")
            exit()
    print("Possible")
    return 0

if __name__ == "__main__":
    solve()


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  ll b=mod, u=1, v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a, b);
    u-=t*v; swap(u, v);
  }
  u%=mod;
  if(u<0)u+=mod;
  return u;
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}
/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin>>N;
  ll ans = modpow(10, N, MOD);
  ans = mod(ans - modpow(9, N, MOD), MOD);
  ans = mod(ans - modpow(9, N,MOD), MOD);
  ans = mod(ans + modpow(8, N,MOD), MOD);
  cout << ans << endl;
  return 0;
}


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

using namespace std;

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

	int N, H;
	cin >> N >> H;

	vector<pair<int, int>> katana(N);

	for (auto &k: katana) {
		cin >> k.first >> k.second;
	}

	sort(katana.begin(), katana.end(), [](const auto &l, const auto &r) {
		return l.second > r.second;
	});

	int best = 0;
	for (int i = 1; i < N; ++i) {
		if (katana[i].first >= katana[best].first) {
			best = i;
		}
	}

	int damage = 0;
	int attacks = 0;
	for (int i = 0; i < N; ++i) {
		if (i == best) continue;
		if (katana[i].second < katana[best].first) break;

		if (damage >= H) {
			cout << attacks;
			return 0;
		}

		damage += katana[i].second;
		attacks++;
	}

	if (damage >= H) {
		cout << attacks;
		return 0;
	}

	bool throwBest = (katana[best].first < katana[best].second);

	if (throwBest) {
		damage += katana[best].second;
		attacks++;
	}

	int numAttacks = (H - damage) / katana[best].first;
	attacks += numAttacks;
	damage += katana[best].first * numAttacks;
	if (damage < H) {
		++attacks;
	}

	cout << attacks;
}

Measured memory_bytes: 1024