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

vector<int> solve(int n) {
    vector<int> pf;
    vector<bool> flag(n + 1, true);
    for (int i = 6; i <= n; i++) {
        if (flag[i]) {
            if (i % 7 != 1 && i % 7 != 6) {
                flag[i] = false;
                continue;
            } else {
                if (n % i == 0) pf.push_back(i);
            }
            for (int j = i + i; j <= n; j += i) {
                flag[j] = false;
            }
        }
    }

    return pf;
}

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

    while (1) {
        int N;
        cin >> N;
        if (N == 1) break;
        vector<int> ans = solve(N);
        cout << N << ": ";
        for (int i = 0; i < ans.size(); i++) {
            cout << ans[i];
            if (i != ans.size() - 1) cout << " ";
            else cout << endl;
        }
    }
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;
typedef vector<str> ves;
typedef vector<char> vech;

int main(){
    ll N,D,ans=0;cin>>N>>D;
    vel2d X(N,vel(D));
    rep0(i,N){rep0(j,D){cin>>X[i][j];}}
    rep0(i,N){
        rep0(j,N){
            ll d2=0;
            rep0(k,D){
                d2+=(X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
            }
            rep1(k,d2){
                if(k*k>d2){break;}
                if(k*k==d2){ans++;
                //cout<<k<<endl;
                }
            }
        }
    }
    cout<<ans/2<<endl;
}
      

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 998244353
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
long long powmod(long long a,long long b){
	if(b==0)return 1;
	long long c=powmod(a,b/2ll);
	c=((c*c)%mod*((b&1ll)?a:1ll))%mod;
	return c;
}
void solve(){
	ll n,m,k;
	cin>>n>>m>>k;
	ll ans=0;
	ll pro[n+5];
	pro[1]=1;
	ll fact[n+5];
	fact[1]=1;
	fact[0]=1;
	for(ll i=2;i<=n+1;i++){
		pro[i]=(pro[i-1]*(n-i+1))%mod;
		fact[i]=(fact[i-1]*i)%mod;
	}
	//cout<<pro[2];
	for(ll i=1;i<=k+1;i++){
		ll a=m-1,b=n-i;//c=n-i+1,d=i-1;
		ll cnt=(m*powmod(a,b)%mod*pro[i]%mod*powmod(fact[i-1],mod-2)%mod);
		//cout<<cnt<<"\n";
		mad(ans,cnt);
	}
	cout<<ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 6732
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <string>
#include <cmath>

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

ll gcd(ll x,ll y)
{
	if(x==0) return y;
	return gcd(y%x,x);
}
int main()
{
	int T;
	scanf("%d",&T);
	while(T--)
	{
		ll A,B,C,D;
		scanf("%lld %lld %lld %lld",&A,&B,&C,&D);
		if(A<B) puts("No");
		else
		{
			A%=B;
			ll g=gcd(B,D);
			if(A%g+D<B) puts("No");
			else
			{
				if(A%g==0)
				{
					if(C<B-g) puts("No");
					else puts("Yes");
				}
				else
				{
					ll lim=A+(B-A)/g*g;
					if(C<lim) puts("No");
					else puts("Yes");
				}
			}
		}
	}
	return 0;
}


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

typedef long long int ll;
#define loop(i,s,e) for(ll i=s;i<e;i++)
#define test ll x;cin>>x;while(x--)
#define pb push_back
#define vec vector<ll>
#define sortvec(x) sort(x.begin(),x.end())
#define sz(x) x.size()

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

    ll a,b,k;
    cin>>a>>b>>k;
    if (k>=a+b)
    	cout<<"0 0\n";
    else
    {
    	if (k>=a)
    	{
    		k-=a;
    		a=0;
    		b-=k;
    		cout<<a<<" "<<b<<"\n";
    	}
    	else
    	{
    		a-=k;
    		cout<<a<<" "<<b<<"\n";
    	}
    }
}


Measured memory_bytes: 3632
import itertools
import numpy as np
data_num = int(input()) 
data = [int(input()) for i in range(data_num)] 
#data_num=5
#data=[6,8,1,2,3]

data.sort()
npdata=np.array(data)

parts1=[1]
parts2=[2 for i in range(data_num-2)]
parts1.extend(parts2)
parts1.append(1)
npparts1=np.array(parts1)

parts0=[(-1)**(i+1) for i in range(data_num)]
npparts0=np.array(parts0)

y=npparts1*npparts0

y=y.tolist()
y.sort()

y=np.array(y)
z1=sum(data*y)

parts01=[(-1)**i for i in range(data_num)]
npparts0=np.array(parts01)

y=npparts1*npparts0

y=y.tolist()
y.sort()
y=np.array(y)
z2=sum(data*y)

print(max(z1,z2))


Measured memory_bytes: 29892
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=1;(i)<=(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main() {
	int N;
	cin >> N;
	int ans = 0;
	rep(i, N) {
		if (i < 10)
			ans++;
		else if (i >= 100 && i < 1000)
			ans++;
		else if (i >= 10000 && i < 100000)
			ans++;
		else if (i >= 1000000 && i < 10000000)
			ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
def resolve():
    N, M = map(int, input().split())
    ans = 0
    if N == 1 and M == 1:
        pass
    else:
        if N != 0:
            ans += N*(N-1)/2
        if M != 0:
            ans += M*(M-1)/2
    print(int(ans))
resolve()

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll a,b,c,x,y;cin>>a>>b>>c>>x>>y;

  ll result = a*x + b*y;

  ll cxy = min(x,y);
  result = min(result, cxy*2*c + (x-cxy)*a + (y-cxy)*b);

  ll ac = max(x,y);
  result = min(result, (ac*2*c));

  cout<<result;

  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);

		//入力 A: Alice、B:Bob
		int A_min = sc.nextInt();
		int A_max = sc.nextInt();
		int B_min = sc.nextInt();
		int B_max = sc.nextInt();
		int answer = 0;

		//Aの最小値よりBの最大値が小さい、もしくは、Aの最大値よりBの最小値が大きい場合：区間の重複はないため答えは0
		if (A_min > B_max || A_max < B_min) {
			answer = 0;
		}

		//Aの最小値よりBの最小値が小さく、Aの最大値よりBの最大値が小さい場合：Aの最小値～Bの最大値まで重複
		else if (A_min >= B_min && A_max >= B_max) {
			answer = B_max - A_min;
		}

		//Aの最小値よりBの最小値が小さく、Aの最大値よりBの最大値が大きい場合：Aの最小値～Aの最大値まで重複
		else if (A_min >= B_min && A_max <= B_max) {
			answer = A_max - A_min;
		}

		//Aの最小値よりBの最小値が大きく、Aの最大値よりBの最大値が小さい場合：Bの最小値～Bの最大値まで重複
		else if (A_min <= B_min && A_max >= B_max) {
			answer = B_max - B_min;
		}

		//Aの最小値よりBの最小値が大きく、Aの最大値よりBの最大値が大きい場合：Bの最小値～Aの最大値まで重複
		else {
			answer = A_max - B_min;
		}
//		else if (A_min <= B_min && A_max >= B_max) {
//			answer = A_max - B_min;
//		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 23252
s = gets.chomp.split('').map(&:to_i)
n = s.size

sum = 0
['-','+'].repeated_permutation(n-1) do |a|
  k = 1
  (n-1).downto(0) do |d|
    sum += s[d]*k
    next if d == 0
    if a[d-1] == '+'
      k = 1
    else
      k *= 10
    end
  end
end
print sum.to_s

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;


int main(){
    LL K;
    cin >> K;
    puts("50");
    LL t=K/50+49;
    for(int i=0;i<50;i++){
        if(i>=50-K%50) cout << t+1 << (i==49?"\n":" ");
        else cout << t-K%50 <<" ";
    }
    return 0;
}

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

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

    int a, b;
    cin >> a >> b;
    if (a % 2 == 0 || b % 2 == 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
var a,b,i:longint;
    s:char;
begin
  readln(a,b);
  for i:=1 to a do
  begin
    read(s);
    if not(s in ['0'..'9']) then
    begin
      writeln('No');
      halt;
    end;
  end;
  read(s);
  if s<>'-' then
  begin
    writeln('No');
    halt;
  end;
  for i:=1 to b do
  begin
    read(s);
    if not(s in ['0'..'9']) then
    begin
      writeln('No');
      halt;
    end;
  end;
  writeln('Yes');
end.

Measured memory_bytes: 128
n,l = map(int,input().split())
apple = [l + i -1 for i in range(1, n+1)]
org = sum(apple)

for i in range(n):
    if i == 0:
        dif = abs(sum(apple[:i]+apple[i+1:]) - org)
        ans = sum(apple[i+1:])
    elif abs(sum(apple[:i]+apple[i+1:]) - org) < dif:
        dif = abs(sum(apple[:i]+apple[i+1:]) - org)
        ans = sum(apple[:i]+apple[i+1:])
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

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

int32_t main()
{
	FIO;
	int x; cin >> x;

	for (int a = 0; a <= 6000; ++a)
	{
		int a5 = a * a * a * a * a;
		int b5 = a5 - x;

		if (b5 == 0)
		{
			cout << a << ' ' << 0 << '\n';
			return 0;
		}

		int b = 1;

		for (b = 1; b * b * b * b * b < abs(b5); ++b);

		if (b * b * b * b * b == abs(b5))
		{
			if (b * b5 < 0)
				b = -b;

			cout << a << ' ' << b << '\n';
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::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 == 0>::type
fill_v(U& u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vi A(N, INF);
	vi B(N - 1);
	REP(i, N-1)cin >> B[i];
	REP(i, N-1) {
		chmin(A[i], B[i]);
		chmin(A[i + 1], B[i]);
	}
	int ans = 0;
	REP(i, N) {
		ans += A[i];
	}
	cout << ans << endl;
	return 0;
}


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

#define endl '\n'

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

    int a[3][3], m[3][3], n;
    memset(m, 0, sizeof m);
    for (int i=0; i<3; i++){
        for (int j=0; j<3; j++){
            cin >> a[i][j];
        }
    }

    cin >> n;
    while(n--){
        int b; cin >> b;
        for (int i=0; i<3; i++){
            for (int j=0; j<3; j++){
                if (a[i][j] == b){
                    m[i][j] = 1;
                }
            }
        }
    }
    bool ok3 = true;
    for (int i=0; i<3; i++){
        if (!m[i][i]){
            ok3 = false;
        }
        bool ok = true, ok2 = true;
        for (int j=0; j<3; j++){
            if (!m[i][j]) ok = false;
            if (!m[j][i]) ok2 = false;
        }
        if (ok || ok2){
            cout << "Yes\n";
            return 0;
        }
    }
    if (ok3) cout << "Yes\n";
    else{
        if (m[2][0] && m[1][1] && m[2][0]) cout << "Yes\n";
        else cout << "No\n";
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
	//here
	NodePointer cur = nil->next;
	while(cur != nil && cur->key != key){
		cur = cur->next;
	}
	return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
	//here
	if(t == nil) return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
	//here
	deleteNode(nil->prev);
}

void delete(int key){
	//here
	deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
	//here
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++;
      }
      size--;
    }
  }

  printList();
  return 0;
}


Measured memory_bytes: 33024
#include <bits/stdc++.h>
using namespace std;
inline void chmin (int& a, int b) {
  if (a > b) a = b;
}
int main() {
  int n;
  string s, t;
  cin >> n >> s >> t;
  vector<int> a, b;
  int pty;
  for (int i = 1; i < n; i++) {
    if (s[i] != s[i - 1]) a.emplace_back(i);
    if (t[i] != t[i - 1]) b.emplace_back(i);
  }
  if (a.empty() || b.empty()) {
    int ret = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] != t[i]) ret++;
    }
    cout << ret << endl;
    return 0;
  } else {
    int pty = s[a[0]] != t[b[0]];
    int sz = a.size();
    int tz = b.size();
    int ret = 1e9;
    for (int d = -(sz + ((sz & 1) != pty)); d <= (tz + ((tz & 1) != pty)); d += 2) {
      int tmp = 0;
      for (int i = min(0, -d); i < max(sz, tz - d); i++) {
        int x;
        if (i < 0) {
          x = 0;
        } else if (i < sz) {
          x = a[i];
        } else {
          x = n;
        }
        int j = i + d;
        int y;
        if (j < 0) {
          y = 0;
        } else if (j < tz) {
          y = b[j];
        } else {
          y = n;
        }
        tmp += abs(x - y);
      }
      chmin(ret, tmp);
    }
    cout << ret << '\n';
  }
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>

#include <sstream>
#include <fstream>
#include <cmath>
#include <vector>


using namespace std;


void check( int val ){
	
	cout << val << endl;
}

int main( int argc , char ** argv ){
	
	string s;
	cin >> s;

	long long K = 0;
	cin >> K;


	long long count = 0;
	while(1){

		if(K <= 0 || count >= s.length()) break;

		if(s[count] == 'a'){
			count ++;
			continue;
		}

		if(K >= ( 'z' - s[count] + 1) ){

			K -= ('z' - s[count]) + 1;
			s[count] = 'a';
		}

		count ++;
	}

	s[s.length()-1] += (K%26);

	cout << s << endl;
}



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

int main(void) {
    
   int n,a;
   cin >> n >> a;
   n = n%500;
   if(n<=a)cout << "Yes" << endl;
   else cout << "No" << endl;


    return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v)                                                            \
  do {                                                                         \
    x = max(x, v);                                                             \
  } while (0)
#define chmin(x, v)                                                            \
  do {                                                                         \
    x = min(x, v);                                                             \
  } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll N, len=0;
  cin>>N;
  map<string,ll> m;

  rep(i, N) {
    string s;
    cin>>s;
    m[s]++;
    chmax(len, m[s]);
  }

  vector<string> v;
  for (auto e: m) {
    if (e.second == len) {
      v.push_back(e.first);
    }
  }
  sort(begin(v),end(v));
  for(auto s: v) {
    cout<<s<<endl;
  }
  return 0;
}


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

using namespace std;

#define rep(i , l , r) for(int i = (l) , ___ = (r) ; i <= ___ ; ++i)
#define per(i , r , l) for(int i = (r) , ___ = (l) ; i >= ___ ; --i)

#define DEBUG(...) fprintf(stderr , __VA_ARGS__)

template<typename T>inline int chkmin(T &x , const T &y){ return x > y ? x = y , 1 : 0; }
template<typename T>inline int chkmax(T &x , const T &y){ return x < y ? x = y , 1 : 0; }

template<typename T>inline T read(T &f)
{
	f = 0 ; int x = 1 ; char c = getchar();
	while(!isdigit(c)) x = c == '-' ? -1 : 1 , c = getchar();
	while(isdigit(c)) (f *= 10) += c & 15 , c = getchar();
	return f *= x;
}

using int64 = long long;
using uint64 = unsigned long long;

int n , m;

int main()
{
	read(n) , read(m);
	int64 ret = 1 , d = 0;
	if(m == 1)
	{
		puts("0");
		return 0;
	}
	while(ret < m)
	{
		ret += (n - 1) , d++;
	}
	cout << d << endl;
	return 0;
}


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

int main() {
    //ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int k, s;
    cin >> k >> s;
    int ans = 0;
    for(int a = 0; a <= k; a++) {
        for(int b = 0; b <= k; b++) {
            int c = s - a - b;
            if(0 <= c && c <= k) {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  char x ; 
  cin >> x ;
  
  if((int)x < 95 ) cout << 'A' ;
  else              cout << 'a' ;
  
}


Measured memory_bytes: 3636
import sys
while True:
	y,x = map(int,input().split())
	if x==y==0:
		break
	for i in range(y):
		for j in range(x):
			if (i+j)%2==0:
				sys.stdout.write("#")
			else:
				sys.stdout.write(".")
		print()
	print()
	

Measured memory_bytes: 8300
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  string a,b;
  cin >> a >> b;
  if(a > b)cout << ">" << endl;
  else if(a < b)cout << "<" << endl;
  else cout << "=" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<list>
#include<queue>
using namespace std;

void probC(){
  string s;
  long long sum=0;
  cin >> s;
  int len = s.length();
  for(int p=0; p<len; p++){
    for(int q=p+1; q<len+1; q++){
      long long t = stoll(s.substr(p,q-p));
      int c;
      if(p==0 && q==len) c = 1;
      else if(p==0) c = 1<<(len-q-1);
      else if(q==len) c = 1<<(p-1);
      else c = (1<<(len-q-1)) * (1<<(p-1));
      //cout << t << " " << c << endl;
      sum += t*c;
    }
  }
  cout << sum << endl;
}

int main(){
  probC();
  return 0;
}


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

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

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

int main(){
    ll n, k;
    cin >> n >> k;
    ll ans = min(n % k, k - n % k);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
x,y=map(int,input().split())
ans=0
if x==1:
    ans+=300000
elif x==2:
    ans+=200000
elif x==3:
    ans+=100000
if y==1:
    ans+=300000
elif y==2:
    ans+=200000
elif y==3:
    ans+=100000
if x==1 and y==1:
    ans+=400000
print(ans)

Measured memory_bytes: 3060
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
B = [list(map(int, input().split())) for _ in range(H)]


def reverse_binary(n, width):
    return int("{:0{width}b}".format(n, width=width)[::-1], 2)


dp = [[0 for _ in range(W)] for _ in range(H)]
dp[0][0] = 1 << abs(A[0][0] - B[0][0])

for h in range(H):
    for w in range(W):
        diff = abs(A[h][w] - B[h][w])
        if w:
            dp[h][w] |= (reverse_binary(dp[h][w - 1] & ((1 << diff) - 1), diff)) << 1
            dp[h][w] |= dp[h][w - 1] >> diff
            dp[h][w] |= dp[h][w - 1] << diff
        if h:
            dp[h][w] |= (reverse_binary(dp[h - 1][w] & ((1 << diff) - 1), diff)) << 1
            dp[h][w] |= dp[h - 1][w] >> diff
            dp[h][w] |= dp[h - 1][w] << diff

tmp = dp[-1][-1]
ans = 0
while tmp & 1 == 0:
    tmp >>= 1
    ans += 1
print(ans)


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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

inline void Main() {
  // code
  int r;
  cin>>r;
  cout<<3*r*r<<endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */

using i64=std::int_fast64_t;
using u64=std::uint_fast64_t;
 
#define rep(i, a, b) for (i64 i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, u64 b,Num id=1) {
  if(b==0)return id;
  Num x = id;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

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

  i64 n;
  std::cin>>n;

  std::vector<i64> a(n);
  for(auto&& e:a)std::cin>>e;

  i64 ans=0;
  i64 prev=0;
  rep(i,0,n){
    if(prev>a[i]){
      ans+=prev-a[i];
    }else{
      prev=a[i];
    }
  }

  std::cout<<ans<<"\n";
  
  return 0;
}

Measured memory_bytes: 4712
package main

import (
	"fmt"
)

func main() {
	var a, b, c, k int
	fmt.Scanf("%d %d %d %d", &a, &b, &c, &k)
	fmt.Println(checker(a, b, c, k))
}

func checker(a int, b int, c int, k int) int {
	if a > k {
		return k
	} else if a+b > k {
		return a
	} else if c > 0 {
		return a + (k-(a+b))*(-1)
	}

	max := a*1 + (k-a-b)*(-1)
	return max
}


Measured memory_bytes: 1820
from heapq import heapify, heappush, heappop


N, M = map(int, input().split())

items = [-int(x) for x in input().split()]
heapify(items)

for _ in range(M):
  a = heappop(items)
  heappush(items, -(-a // 2))
  
print(-sum(items))  



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

int main() {
  int A,B;
  cin >> A >> B;
  
  int count = 0;
  
  for (int i = A; i <=B; i++) {
    string str;
    str = to_string(i);
    
    if (str.at(0) == str.at(4) and str.at(1) == str.at(3))
      count++;
  }
  cout << count << endl;
}

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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
const long long INF = 1e18;
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << ((a * 100 + b * 10 + c) % 4 == 0 ? "YES" : "NO") << endl;
}


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

using namespace std;

int main()
{
	set<string> s;

	int t = 0;

	cin >> t;

	while (t != 0)
	{
		string str;
		cin >> str;
		
		s.insert(str);

		t--;
	}

	cout << s.size() << endl;
}

Measured memory_bytes: 19168
function main(input) {
    var line = input.split(/\r?\n/g);
    var arr = line[0].split(" ");
    const H = arr[0], N = arr[1];
    var A = line[1].split(" ");
    var accum = 0;
    for (var i = 0; i < A.length; i++)
        accum += parseInt(A[i]);
    console.log(accum < H ? "No" : "Yes");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 16716
import sys
import string


def main():
    tmp = ''

    try:
        while True:
            tmp += input()
    except EOFError:
        pass

    tmp = list(filter(lambda x: x in string.ascii_lowercase, tmp.lower()))

    for c in string.ascii_lowercase:
        print('{} : {}'.format(c, tmp.count(c)))

    return 0


if __name__ == '__main__':
    sys.exit(main())



Measured memory_bytes: 6688
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


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


int main() {

	ll N;
	cin >> N;

	vector<ll> t(N + 1, 0), x(N + 1, 0), y(N + 1, 0);

	repn(i, N) cin >> t[i] >> x[i] >> y[i];

	string ans = "Yes";

	repn(i, N) {
		ll dis = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]);
		ll time = t[i] - t[i - 1];

		if (time < dis || (dis - time) % 2 != 0) { ans = "No"; }
	}

	cout <<ans;
	system("PAUSE");

	

}


Measured memory_bytes: 2808
#include<bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef unsigned long long ULL;
 
template<class T>
inline bool read(T &num) {
    char in;
    bool IsN = false;
    while(in = getchar(), in != '-' && (in < '0' || in > '9'))if(in == EOF)return false;
    in == '-' ? (IsN = true, num = 0) : num = in - '0';
    while(in = getchar(), in >= '0' && in <= '9')num = num * 10 + in - '0';
    return IsN ? num = -num : num, true;
}
 
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define debug(m) cout<<"nico "<<m<<endl
#define __m  int mid=l+(r-l)/2
 
const int maxn   = 1e5 + 7;
const int inf    = 2e9 + 7;
const int mod    = 1e9 + 7;
 
map<int,int>have;
int main() {
#ifdef LOCAL
    freopen("sample.in", "r", stdin);
#endif
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int k;
        cin>>k;
        have[k]++;
    }
    cin>>n;
    while(n--)
    {
        int k;
        cin>>k;
        if(have[k])
            have[k]--;
        else 
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 9728
#include <bits/stdc++.h>
#include <numeric>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    long long n,m;
    long long sum=0;
    cin>> n >> m;
    vector<long long> a(n),b(n);
    vector<pair<long long,long long>> c(n);
    for(int i=0;i<n;i++){
        cin >> a.at(i) >> b.at(i);
        c.at(i)=make_pair(a.at(i),b.at(i));
    }
    sort(c.begin(),c.end());
    for(int i=0;i<n;i++){
        long long k,l;
        k=min(c.at(i).second,m);
        l=c.at(i).first*k;
        sum+=l;
        m-=k;
        if(m<=0){
            break;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int dp[1000005][2];
int main(){
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    s += "0";
    for(int i = 0; i < s.size(); i++){
        int a = s[i] - '0';
        dp[i][0] = dp[i][1] = 1<<30;
        show(i, a);
        if(i == 0){
            dp[i][0] = a;
            dp[i][1] = 10-a;
        }else{
            if(a < 9){
                dp[i][0] = min(dp[i-1][0]+a,dp[i-1][1]+a+1);
                dp[i][1] = min(dp[i-1][0]+10-a, dp[i-1][1]+10-a-1);
            }else{
                dp[i][0] = dp[i-1][0] + a;
                dp[i][1] = min(dp[i-1][0]+10-a,dp[i-1][1]+10-a-1);
            }
        }
        show(dp[i][0], dp[i][1]);
    }
    cout << dp[s.size()-1][0] << endl;
}


Measured memory_bytes: 9220
#include<stdio.h>
#include<string.h>
 
#define LEN 100005
 
typedef struct pp {
    char name[100];
    int t;
} P;
 
P Q[LEN];
int head, tail, n;
 
void enqueue(P x){
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}
 
P dequeue(){
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}
 
int min(int a, int b){
    return a < b ? a : b;
}
 
int main(){
    int elaps = 0, c;
    int i, q;
    P u;
     
    scanf("%d%d", &n, &q);
 
    for(i=1; i<=n; i++){
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
 
    head = 1;
    tail = n + 1;
 
    while( head != tail ){
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if( u.t > 0 ) enqueue(u);
        else {
            printf("%s %d\n", u.name, elaps);
        }
    }
 
    return 0;
}


Measured memory_bytes: 11996
#include <bits/stdc++.h>
#define rep(i,s,t) for(int i = s;i <= t;i ++)
#define dow(i,t,s) for(int i = t;i >= s;i --)
#define REP(i,x) for(int i = 0;i < x.size();i ++)
#define DOW(i,x) for(int i = (int)s.size();i >= 0;i --)

#define fi first
#define se second

#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound


#define eps 1e-6
#define N
#define INF

#define SZ(x) ((int)(x).size())


using namespace std;

typedef vector<int> VI;
typedef long long LL;
typedef double db;
typedef pair<int,int> PII;


int n , num[100] , a[100] , v[100];
char ct[100];

void DFS(int x)
{
    if(x == 4)
    {
        int sum = a[1];
        rep(i,2,4)sum += v[i - 1] * a[i];
        if(sum == 7)
        {
            rep(i,1,3)ct[i] = (v[i] == 1) ? '+' : '-';
            ct[4] = '=';
            rep(i,1,4)printf("%d%c",a[i],ct[i]);
            printf("7");
            exit(0);
        }
        return ;
    }
    v[x] = -1;
    DFS(x + 1);
    v[x] = 1;
    DFS(x + 1);
}
int main ()
{
    char ch;
    //freopen("in.in","r",stdin);
    //freopen("out.out","w",stdout);
    rep(i,1,4)scanf("%c",&ch) , a[i] = ch - '0';
    DFS(1);
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException{
		ArrayList<Integer> list =new ArrayList<>(); 
		Scanner sc = new Scanner(new InputStreamReader(System.in));
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		list.add(a);
		list.add(b);
		list.add(c);
		
		Collections.sort(list);
		
		System.out.println(list.get(0)+list.get(1));
	}
}


Measured memory_bytes: 23764
n = int(input())
lst1 = list(map(int,input().split()))

dp = [0]*n

dp[1] = abs(lst1[1]-lst1[0])

for i in range(2,n):
    dp[i] = min(dp[i-1]+abs(lst1[i]-lst1[i-1]),dp[i-2]+abs(lst1[i]-lst1[i-2]))

print(dp[-1])

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


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


    int n;
    cin >> n;


    cout << (-n % 1000 + 1000) % 1000 << endl;


    return 0;
}



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

int main () {
    
    std::vector<int> x;
    while(true) {
        int n;
        std::cin >> n;
        if(n == 0) break;
        x.emplace_back(n);
    }
    
    for (int i = 1; i <= x.size(); i++) std::cout << "Case " << i << ": " << x.at(i - 1) << std::endl;
    
    return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,a,b;
    string s;
    cin >> n >> a >> b;
    cin >> s;
    int currentPassed = 0;
    int overseaRank = 0;
    vector <string> ans(n,"");
    for(int i = 0; i < n; i++){
        switch(s[i]){
            case 'a':
                if(currentPassed<(a+b)){
                    ans[i]="Yes";
                    currentPassed++;
                }else{
                    ans[i]="No";
                }
                break;
            case 'b':
                overseaRank++;
                if( (currentPassed<(a+b)) &&
                    (overseaRank <= b )){
                        currentPassed++;
                        ans[i]="Yes";
                }else{
                    ans[i]="No";
                }
                break;
            case 'c':
                ans[i]="No";
                break;
            default :
                break;
        }
    }
    for(int i = 0; i < n; i++){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 6684
import sys
import bisect
from functools import lru_cache

input = sys.stdin.readline


@lru_cache(maxsize=None)
def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    return True


def main():
    Q = int(input())
    lr = [[int(x) for x in input().split()] for _ in range(Q)]

    sosu = []
    for i in range(1, 10 ** 5 + 1):
        if is_prime(i) and is_prime((i + 1) // 2):
            sosu.append(i)

    for l, r in lr:
        li = bisect.bisect_left(sosu, l)
        ri = bisect.bisect_right(sosu, r)
        print(ri - li)









if __name__ == '__main__':
    main()


Measured memory_bytes: 34108
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstddef>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

#define int long long
#define YES "Yes"
#define NO  "No"

using namespace std;

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

  int num;
  int tmp;

  int n; cin >> n;
  string s; cin >> s;

  map<int, int> mem; // iまでの#ではない数.

  tmp = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] != '#') tmp++;
    mem.insert(make_pair(i + 1, tmp));
  }

  num = n;

  for (int i = 0; i <= n; ++i) {
    int tmp = 0;

    if (i == 0) { // bbbbbb
      tmp = mem.at(n);
    } else if (i == n) { // wwwwww
      tmp = n - mem.at(n);
    } else { // wwwbbb
      tmp += i - mem.at(i);
      tmp += mem.at(n) - mem.at(i);
    }
    num = min(num, tmp);
  }
  
  cout << num << endl;
  
  return 0;
}


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

int main(){
	int a, b, c;
	int i;
	int count = 0;
	cin >> a >> b >> c;

	for(i = a; i <= b; i++){
		if(c % i == 0){
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3092
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


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

    ans = ""
    if D == 25:
        ans = "Christmas"
    elif D == 24:
        ans = "Christmas Eve"
    elif D == 23:
        ans = "Christmas Eve Eve"
    elif D == 22:
        ans = "Christmas Eve Eve Eve"

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3944
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,x=0;
  string s;
  cin>>n>>s;
  rep(i,n) if(s[i]=='R') x++;
  if(x>n/2) cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 256
var
n,m,i,j,ans,t,id:longint;
c,u:array[1..500] of longint;
a:array[1..500,1..500] of longint;
function fun(x:longint):longint;
var
i:longint;
begin
for i:=1 to m do
begin
if u[a[x,i]]<>0 then continue;
exit(a[x,i]);
end;
exit;
end;

begin
ans:=1000;
readln(n,m);
for i:=1 to n do
begin
for j:=1 to m do
begin
read(a[i,j]);
end;
readln;
end;

for i:=1 to m do
begin
fillchar(c,sizeof(c),0);
for j:=1 to n do
inc(c[fun(j)]);
t:=0;
id:=0;
for j:=1 to m do
if t<c[j] then begin t:=c[j]; id:=j; end;

if t<ans then ans:=t;
u[id]:=1;
end;
write(ans);
end.



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

#define ll long long int
#define mp make_pair 
#define pb push_back
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);
#define ff first
#define ss second
#define MOD  1000000007
#define ll_MAX 922337203685477999
#define endl "\n"
inline ll absdiff(ll a,ll b) {return (a>b)?a-b:b-a;}
ll fast_expo(ll x,ll p){if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
ll gcd(ll a,ll b){if(a==0||b==0) return a+b;  else return gcd(b%a,a); }

int main()
{
    // fast
    ll t_c;t_c = 1;
    // cin>>t_c;
    for (ll ti = 0; ti < t_c; ++ti)
    {   
        ll n,k;cin>>n>>k;
        ll arr[n];
        for(ll i=0;i<n;++i) cin>>arr[i];
        sort(arr,arr+n);
        ll ans=0;
        for(ll i=0;i<max(0ll,n-k);++i) ans+=arr[i];
        cout<<ans;
    }
    return 0;
}   

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
    ll n,k=2;
    cin>>n;
    ll arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    ll dp[n+1];
    for(int i=0;i<=n;i++){
        dp[i]=INT_MAX;
    }
    dp[0]=0;
    dp[1]=0;
    for(int i=2;i<=n;i++){
        for(int j=i-1;j>i-k-1 && j>=0; j--){
          dp[i]= min(dp[i], abs(arr[i-1]-arr[j-1]) + dp[j]);
        }
        }

    cout<<dp[n];
return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <utility>
#include <vector>

struct sch {
    int t;
    int x;
    int y;
};

int main() {
    unsigned int n;
    std::cin >> n;
    std::vector<sch> plan;
    plan.resize(++n);
    plan.front() = sch{ 0, 0 ,0 };
    for (unsigned int i = 1; i < n; ++i) { std::cin >> plan[i].t >> plan[i].x >> plan[i].y; }
    bool yes = true;
    for (unsigned int i = 1; yes && i < n; ++i) {
        auto d = std::abs(plan[i-1].x - plan[i].x) + std::abs(plan[i-1].y - plan[i].y);
        auto dt = plan[i].t - plan[i-1].t;
        yes = yes && ((d - dt) % 2 == 0) && d <= dt;
    }
    std::cout << (yes ? "Yes" : "No");
}


Measured memory_bytes: 1408
# -*- coding: utf-8 -*-       

n = input()
a = map(int, raw_input().split())
alen = len(a)
b = [0]*alen
if(alen%2 == 0):
    for i,j in enumerate(range(0,alen,2)):
        b[i] = a[alen-1-j]
    for i,j in enumerate(range(0,alen,2)):
        b[alen/2+i] = a[j]
else:
    for i in range(0,alen/2+1):
        b[i] = a[alen-1-2*i]
    for i in range(0,alen/2):
        b[alen/2+1+i] = a[2*i+1]

print(' '.join(map(str,b)))
    


Measured memory_bytes: 26736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()

vll v;

//N!の素因数分解
vll prime_fact(int N){
  vll v(N+1,0);
  for(int i=2;i<=N;++i){
    int tmp = i;
    for(int j=2;j<=i;++j){
      while(tmp%j==0){
        tmp/=j;
        v[j]++;
      }
    }
  }
  return v;
}

ll num(ll a){
  ll tmp=0;
  rep(i,v.size()){
    if(v[i]>=a-1) tmp++;
  }
  return tmp;
}

int main(){
  ll N;cin>>N;
  v = prime_fact(N);
  
  cout << (num(75) + num(25) * (num(3) - 1) + \
  num(15) * (num(5) - 1) + num(5) * (num(5) - 1) * (num(3) - 2) / 2) << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,m,k;
  cin>>n>>m>>k;
  Int a,b,c;
  cin>>a>>b>>c;
  Int t;
  cin>>t;
  vector<Int> s(m);
  for(Int i=0;i<m;i++) cin>>s[i],s[i]--;

  k-=m;
  using P = pair<Int, Int>;
  priority_queue<P> pq;
  Int ans=0;
  if((n-1)*b<=t) ans++;
  
  vector<Int> lst(s);
  for(Int i=0;i+1<m;i++){    
    Int x=s[i]*b;
    if(x>t) continue;

    Int d=(t-x)/a+1;
    if(s[i]+d>=s[i+1]){
      ans+=s[i+1]-s[i];
      continue;
    }
    ans+=d;
    
    Int z=x+d*c;
    if(z>t) continue;
    Int e=d+(t-z)/a+1;
    
    //cout<<i<<" "<<d<<" "<<e<<endl;
    if(s[i]+e>=s[i+1]){
      pq.emplace(s[i+1]-(s[i]+d),-1);
      continue;
    }
    lst[i]=e;
    pq.emplace(e-d,i);
  }

  while(!pq.empty()&&k){
    --k;
    P p=pq.top();pq.pop();
    ans+=p.first;
    Int i=p.second;
    if(i<0) continue;
    Int x=s[i]*b;
    Int d=lst[i];
    Int z=x+d*c;
    if(z>t) continue;
    Int e=d+(t-z)/a+1;
    if(s[i]+e>=s[i+1]){
      pq.emplace(s[i+1]-(s[i]+d),-1);
      continue;
    }
    lst[i]=e;
    pq.emplace(e-d,i);
  }
  
  cout<<ans-1<<endl;
  return 0;
}



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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll x;cin>>x;
	for(ll i=0;i<=300;i++){
		for(ll j=-300;j<=i;j++){
			if(i*i*i*i*i-j*j*j*j*j==x){cout<<i<<" "<<j<<'\n';return 0;}
		}
	}
	return 0;
}

Measured memory_bytes: 3648