akhauriyash/Code-Regression huggingface dataset:
from itertools import zip_longest
S = input()
T = input()
NT = len(T)

candidate = []
for i in range(len(S)):
    for target, t in zip_longest(S[i:i+NT], T):
        if target != "?" and target != t:
            break
    else:
        candidate.append(S[:i] + T + S[i+NT:])

ans_candidate = []
for c in candidate:
    c = c.replace("?", "a")
    ans_candidate.append(c)

ans_candidate.sort()
print(ans_candidate[0] if ans_candidate else "UNRESTORABLE")


Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>

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

using namespace std;

int main(){
	for(int n;scanf("%d",&n),n;){
		int a[101]={},r;
		rep(i,n)	scanf("%d",a+i+1);
		double b,v,e,f;	scanf("%lf%d%lf%lf%lf",&b,&r,&v,&e,&f);
		n++;

		static double t[10001];
		rep(x,a[n-1]){
			if(x<r)	t[x+1]=t[x]+1/(v-f*(r-x));
			else	t[x+1]=t[x]+1/(v-e*(x-r));
		}

		static double dp[101][101];
		rep(i,n)rep(j,n)	dp[i][j]=1e60;
		dp[0][0]=0;
		for(int i=1;i<n;i++){
			rep(j,i){
				int dis=a[i]-a[j];
				dp[i][j]=min(dp[i][j],dp[j][j]+t[dis]);
				dp[i][i]=min(dp[i][i],dp[i][j]+b);
			}
		}

		printf("%.9f\n",*min_element(dp[n-1],dp[n-1]+n));
	}

	return 0;
}

Measured memory_bytes: 0
s = list(input())

if len(s) == 2:
    if s[0] == s[1]:
        print(1,2)
    else:
        print(-1,-1)
    exit()


for i, (s1,s2,s3) in enumerate(zip(s[:-2], s[1:-1], s[2:])):
    same_cnt = 0
    if s1 == s2 or s2 == s3 or s3 == s1:
        print(i+1, i+3)
        break

else:
    print(-1,-1)


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

vector<ll> fct, invfct;

ll mod_pow(ll n, ll p, ll mod){
    // return (n^p) % mod
    if(p==0) return 1;
    ll res = mod_pow(n*n%mod, p/2, mod);
    if(p%2==1) res = res * n % mod;
    return res;
}

int main(){
    ll N, A, B, C;
    cin >> N >> A >> B >> C;
    ll mod = 1e9+7;

    fct = vector<ll>(2*N+1,1);
    for(ll i=1; i<=2*N; i++){
        fct[i] = i * fct[i-1] % mod;
    }
    invfct = vector<ll>(2*N+1,1);
    invfct[2*N] = mod_pow(fct[2*N], mod-2, mod) % mod;
    for(ll i=2*N-1; i>=1; i--){
        invfct[i] = (i+1)*invfct[i+1] % mod;
    }
    vector<ll> invAB(2*N+1,1);
    invAB[1] = mod_pow(A+B, mod-2, mod);
    for(int i=1; i<=2*N; i++){
        invAB[i] = invAB[i-1]*invAB[1] % mod;
    }
    vector<ll> powA(2*N+1,1), powB(2*N+1,1);
    powA[1] = A, powB[1] = B;
    for(int i=1; i<=2*N; i++){
        powA[i] = powA[i-1] * A % mod;
        powB[i] = powB[i-1] * B % mod;
    }

    ll ans = 0;
    for(int M=N; M<=2*N-1; M++){
        ll tmp = fct[M-1]*invfct[N-1] % mod;
        tmp = tmp * invfct[M-N] % mod;
        tmp = tmp * M % mod;
        tmp = tmp * (powA[N]*powB[M-N]%mod + powA[M-N]*powB[N]%mod) % mod;
        tmp = tmp * invAB[M] % mod;
        ans = (ans + tmp)%mod;
    }
    ans = ans * 100 % mod;
    ans = ans * mod_pow(100-C, mod-2, mod) % mod;
    cout << ans << endl;
}


Measured memory_bytes: 8064
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
s=list(input())
k=int(input())
a=s[k-1]
for i in range(n):
    if s[i]!=a:
        s[i]="*"
print(*s,sep="")

Measured memory_bytes: 77372
function Main(input) {
  var inputs = input.split("\n").map(num => parseInt(num, 10));
  var n = inputs[0];
  var a = inputs[1];

  if (n % 500 <= a) {
    console.log("Yes");
  } else {
    console.log("No");
  }
}

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

Measured memory_bytes: 7372
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
s = [0]
for ai in a:
    s.append(ai + s[-1])

def count(x, accum=False):
    ret = 0
    for ai in a:
        lo, hi = -1, n
        while hi - lo > 1:
            mid = (lo + hi) // 2
            if ai + a[mid] >= x:
                lo = mid
            else:
                hi = mid
        ret += ai * hi + s[hi] if accum else hi
    return ret

lo, hi = 0, 1000000000
while hi - lo > 1:
    mid = (lo + hi) // 2
    if count(mid) >= m:
        lo = mid
    else:
        hi = mid

print(count(lo, accum=True) - (count(lo) - m) * lo)


Measured memory_bytes: 92240
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define int long long
using namespace std;
typedef pair<int,int> pii;
static const int inf = 1ll<<60;
static const int MAX_N = 100000;

int N,T,Q;
vector<pii> A;
int flg[MAX_N+5];
int table[MAX_N+5];
int next[MAX_N+5];

signed main(){
    for(int i=0;i<100000;++i){
        next[i]=inf;
    }
    cin>>N>>T>>Q;
    for(int i=0;i<N;++i){
        int a,d;
        cin>>a>>d;
        if(d!=1)d=-1;
        A.PB(pii(a,d));
    }
    sort(A.begin(),A.end());
    int maxd=0;
    int t=0;
    for(int i=0;i<N;++i){
        if(flg[i]==1)continue;
        if(A[i].SE!=1||A[i+1].SE!=-1){
            if(A[i].SE==1)table[i]=t;
            else table[i]=t-1;
            continue;
        }
        int D=abs(A[i].FI-A[i+1].FI)/2;
        if(D<=T){
            maxd=max(D,maxd);
            A[i].FI+=A[i].SE*D;
            A[i+1].FI=A[i].FI;
            flg[i]=1;
            flg[i+1]=1;
            next[t]=A[i].FI;
            t++;
        }
    }
    for(int i=0;i<N;++i){
        if(flg[i]==1)continue;
        if(A[i].SE==1){
            int k=table[i];
            int d=abs(A[i].FI-next[k]);
            if(d>=maxd)A[i].FI+=maxd;
            else {
                A[i].FI=next[k];
                flg[i]=1;
            }
        }
        else {
            int k=table[i];
            int d=abs(A[i].FI-next[k]);
            if(d>=maxd)A[i].FI-=maxd;
            else {
                A[i].FI=next[k];
                flg[i]=1;
            }
        }
    }
    T-=maxd;
    for(int i=0;i<N;++i){
        if(flg[i]==1)continue;
        if(A[i].SE==1&&A[i+1].SE==-1){
            A[i].FI+=T;
            A[i+1].FI-=T;
            flg[i]=1;
            flg[i+1]=1;
            continue;
        }
        if(A[i].SE==1){
            int k=table[i];
            if(next[k]==inf){
                A[i].FI+=T;
            }
            else{
                int d=abs(A[i].FI-next[k]);
                if(d<=T)A[i].FI=next[k];
                else A[i].FI+=T;
            }
        }
        else{
            int k=table[i];
            if(next[k]==inf)A[i].FI-=T;
            else{
                int d=abs(A[i].FI-next[k]);
                if(d<=T)A[i].FI=next[k];
                else A[i].FI-=T;
            }
        }
    }
    for(int i=0;i<Q;++i){
        int q;
        cin>>q;
        q--;
        cout<<A[q].FI<<endl;
    }
}

Measured memory_bytes: 5136
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = SR(3)
    for i in range(3):
        print(s[i][i], end="")
    print()
    return

#B
def B():
    a, b = LI()
    ans = 0
    for i in range(a, b + 1):
        x = str(i)
        for k in range(len(x)//2):
            if x[k] != x[-k - 1]:
                break
        else:
            ans += 1
    print(ans)
    return

#C
def C():
    n, m = LI()
    if n == m == 1:
        print(1)
        return
    if n == 1 or m == 1:
        print(max(n - 2, m - 2))
        return
    if n == 2 or m == 2:
        print(0)
        return
    print(n * m - n * 2 - (m - 2) * 2)
    return

#D
def D():
    n, k = LI()
    ans = 0
    if k == 0:
        print(n * n)
        return
    for b in range(k + 1, n + 1):
        tmp1, tmp2 = n // b, n % b
        ans += tmp1 * (b - k) + max(tmp2 - k + 1, 0)
    print(ans)
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 39280
#include <cstdio>

const int MAXN = 3000;

int pow_mod(int b, int p, int m) {
	int ret = 1;
	while( p ) {
		if( p & 1 ) ret = 1LL*ret*b%m;
		b = 1LL*b*b%m;
		p >>= 1;
	}
	return ret;
}

int N, M;

int c[MAXN + 5][MAXN + 5], s[MAXN + 5][MAXN + 5], f[MAXN + 5][MAXN + 5];
void init() {
	for(int i=0;i<=MAXN;i++) {
		c[i][0] = 1;
		for(int j=1;j<=i;j++)
			c[i][j] = (c[i-1][j] + c[i-1][j-1]) % M;
	}
	s[0][0] = 1;
	for(int i=1;i<=MAXN;i++)
		for(int j=1;j<=i;j++)
			s[i][j] = (1LL*j*s[i-1][j]%M + s[i-1][j-1]) % M;
	for(int i=0;i<=MAXN;i++) {
		for(int j=1;j<=i;j++)
			f[i][j] = (1LL*(j + 1)*f[i-1][j]%M + f[i-1][j-1]) % M;
		f[i][0] = 1;
	}
}

int main() {
	scanf("%d%d", &N, &M); init();
	int ans = 0;
	
	for(int p=0;p<=N;p++) {
		int d = 1LL*pow_mod(M-1, p, M)*c[N][p]%M;
		d = 1LL*d*pow_mod(2, pow_mod(2, N-p, M-1), M)%M;
/*
		for(int j=0;j<=p;j++) {
			for(int k=0;k<=j;k++) {
				ans = (ans + 1LL*d*s[j][k]%M*c[p][j]%M*pow_mod(2, 1LL*k*(N-p)%(M-1), M)%M)%M;
			}
		}
*/
		int t = 1, q = pow_mod(2, N-p, M);
		for(int k=0;k<=p;k++,t=1LL*t*q%M)
			ans = (ans + 1LL*d*f[p][k]%M*t%M)%M;
	}
	
	printf("%d\n", ans);
}

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

int main(){
  int n;
  int64_t sum=0LL;
  scanf("%d",&n);
  vector<int64_t> a(n+1),b(n);
  rep(i,n+1)scanf("%ld",&a[i]);
  rep(i,n)scanf("%ld",&b.at(i));
  rep(i,n){
    if((a[i+1]+a[i])>=b[i]){
      sum += b[i];
      int c = b[i]-a[i];
      a[i+1] -= max(0,c);
    }
    else {
      sum += a[i+1]+a[i];
      a[i+1] = 0;
    }
  }
  printf("%ld",sum);
}


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define chmax(s, t) s=max(s,t);
#define chmin(s, t) s=min(s,t); 

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

/*組み合わせ(Combination)*/
const ll CMAX = 1010000;
const ll CMOD = 1e9+7;
ll fac[CMAX], finv[CMAX], inv[CMAX];
// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < CMAX; i++) {
		fac[i] = fac[i - 1] * i % CMOD;
		inv[i] = CMOD - inv[CMOD%i] * (CMOD / i) % CMOD;
		finv[i] = finv[i - 1] * inv[i] % CMOD;
	}
}
// 二項係数計算
ll comb(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % CMOD) % CMOD;
}

/*階乗*/
ll factorial(ll n){
    const ll FMOD = 1e9+7;
    ll ret = n;
    for(ll i=n-1;i>0;i--){
        ret*=i;
        ret%=FMOD;
    }
    return (ret?ret:1);
}


int main(){

    ll n; cin >> n;
    vll a(n); rep(i, n) cin >> a[i];

    ll sum = 0;
    ll ans = 0;
    ll mod = (ll)(1e9+7);
    rep(i, n){
        sum += a[i];
        sum %= mod;
    }

    rep(i, n){
        sum -= a[i];
        if(sum < 0) sum += mod;
        ans += a[i]*sum;
        ans %= mod;
    }

    cout << ans << endl;

    return 0;
}

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

int gcd(int a, int b){
    return (b==0)? a :gcd(b, a%b);
}

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << (a/gcd(a,b) * b/gcd(a,b))*c << endl;
    return 0;
}



Measured memory_bytes: 3112
#include <iostream> 
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

int main() {
    string S, T;
    cin >> S >> T;
    int Counter = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] != T[i]) {
            Counter += 1;
        }
    }
    cout << Counter << endl;
}

Measured memory_bytes: 3848
a = gets().chomp!

if(a.size < 1025)
	a = a.gsub(/[., ]/," ").split().find_all{|x| x.size>2&&x.size<7}
	a.size.times{|i|
		print a[i]
		print " " if(i != a.size-1)
	}
end
print "\n"

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

int main() {
    int n;
    cin >> n;
    vector<int> t(n+1),x(n+1),y(n+1);
    t[0] = x[0] = y[0] = 0;  // 初期状態
    rep(i,n) cin >> t[i+1] >> x[i+1] >> y[i+1];  // 1-index にしておく

    bool can = true;
    rep(i,n) {
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if (dt < dist) can = false;
        if (dist % 2 != dt % 2) can = false;  // dist と dt の偶奇は一致する必要あり！
    }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 1408
H,N=map(int, input().split())
A=[]
B=[]
for n in range(N):
  a,b=map(int, input().split())
  A.append(a)
  B.append(b)

dp=[float('inf')]*(H+1)
dp[0]=0
for h in range(1,H+1):
  for i in range(N):
    if h-A[i]>=0:
      dp[h]=min(dp[h-A[i]]+B[i],dp[h])
    else:
      dp[h]=min(dp[h],B[i])
print(dp[H])

Measured memory_bytes: 42732
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a.begin(),a.end());
  cout << a[n/2]-a[n/2-1]<<endl;
}

Measured memory_bytes: 640
# include <bits/stdc++.h>
# define ll long long 
using namespace std;
const ll N = 55, mod = 1e9 + 7;
bool a[N][N];
int n;
ll k, ans, dp[N];
struct matrix{
    ll d[N][N];
    inline matrix operator*(matrix other){
        matrix ans;
        memset(ans.d, 0, sizeof ans.d);
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                for(int k = 0; k < n; k++){
                    ans.d[i][j] += d[i][k] * other.d[k][j] % mod;
                    if(ans.d[i][j] >= mod)ans.d[i][j] -= mod; 
                }
            }
        }
        return ans;
    }
    inline matrix operator^(ll p){
        matrix cur, ans; 
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                cur.d[i][j] = ans.d[i][j] = d[i][j];
            }
        }
        p --; 
        while(p){
            if(p & 1){
                ans = ans * cur;
            }
            cur = cur * cur;
            p >>= 1;
        }
        return ans;
    }
}m;
int main(){
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> m.d[j][i];
        }
    }
    m = m ^ k; 
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            ans = (ans + m.d[i][j]);
            if(ans >= mod)ans -= mod;
        } 
    } 
    cout << ans << endl;
}

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

int main()
{
	int n,d,x,i,ans;
	int a[101];

	cin >> n >> d >> x;
	for(i=0;i<n;i++){
		cin >> a[i];
	}

	ans = x;

	for(i=0;i<n;i++){
		ans += d/a[i];
		if(d%a[i]!=0){
			ans++;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.txt"

vector<string> split(const string &s, char delim) {
	vector<string> elems;
	stringstream ss(s);
	string item;
	while (getline(ss, item, delim)) {
		if (!item.empty()) {
			elems.push_back(item);
		}
	}
	return elems;
}

int main() {
	string st;
	while (getline(cin,st)) {
		vector<string>sts = split(st, ' ');
		stack<ld>sta;
		for (auto st : sts) {
			
			if (st == "-") {
				ld b = sta.top();
				sta.pop();
				ld a = sta.top();
				sta.pop();
				sta.push(a - b);
			}
			else if (st == "+") {
				ld b = sta.top();
				sta.pop();
				ld a = sta.top();
				sta.pop();
				sta.push(a + b);
			}
			else if (st == "/") {
				ld b = sta.top();
				sta.pop();
				ld a = sta.top();
				sta.pop(); 
				sta.push(a / b);
			}
			else if (st == "*") {
				ld b = sta.top();
				sta.pop();
				ld a = sta.top();
				sta.pop();
				sta.push(a * b);
			}
			else {
				sta.push(stold(st));
			}
		}
		cout <<setprecision(12)<<fixed<< sta.top() << endl;
	}
	return 0;
}

Measured memory_bytes: 3260
#include <bits/stdc++.h>
#define S second
#define F first
#define pb push_back

using namespace std;

typedef long long llong;

const int MXN = (int)2e5 + 7;
const int MOD = (int)1e9 + 7;
const llong INF = 2e18 + 7;

int h, n, a[MXN], b[MXN];
bool dp[MXN];
llong cost[MXN];

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
  cin >> h >> n;
  for(int i = 1; i <= n; i++){
    cin >> a[i] >> b[i];
  }
  for(int j = 0; j < h; j++){
    cost[j] = MOD;
  }
  dp[h] = true;
  for(int i = 1; i <= n; i++){
    for(int j = h; j >= 0; j--){
      if(dp[j]){
        if(j - a[i] >= 0){
          dp[j - a[i]] = true;
          cost[j - a[i]] = min(cost[j] + b[i], cost[j - a[i]]);
        }else if(j - a[i] < 0){
          dp[0] = true;
          cost[0] = min(cost[j] + b[i], cost[0]);
        }
      }
    }
  }
  cout << cost[0];
  /*for(int j = h; j >= 0; j--){
    cout << j << ' ';
  }
  cout << endl;
  for(int j = h; j >= 0; j--){
    if(dp[j]){
      cout << cost[j] << ' ';
    }else
    cout << 0 << ' ';
  }*/
  /// a[i] -> damage
  /// b[i] -> point
  return 0;
}


Measured memory_bytes: 384
//
// Created by yamunaku on 2019/12/29.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    // CFS;
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int ans = 0;
    rep(i, n-1) if(a[i] < a[i + 1]) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <unordered_map>


int main() {
  int n, m, i;
  char l, r, temp;
  std::unordered_map<char, char> trans_map; 
  while (std::cin >> n) {
    if (n == 0) break;

    for (i = 0; i < n; i ++) {
      std::cin >> l >> r;
      trans_map[l] = r;
    }

    std::cin >> m;
    for (i = 0; i < m; i ++) {
      std::cin >> temp;
      std::unordered_map<char, char>::iterator it = trans_map.find(temp);
      if (it != trans_map.end()) std::cout << it->second;
      else std::cout << temp;
    }
    std::cout << std::endl;
    trans_map.clear();
  }
  return 0;
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
#define MAXN 100010
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x<n and y >=0 and y<n)
using namespace std;
const ll mod = 1e18 + 7;


int main (){
    string s;
    ll ans = 0;

    cin >> s;

    int n = s.size();

    for (int i=0; i<n; i++){
        for (int j=0; j+i < n; j++){
            ll power = n-2-i;
            if (j !=0 and j+i!=n-1) power--;
            power = max(power, 0LL);
            ans += (1 << (power))*(stoll(s.substr(j, i+1)));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
const MOD: u64 = 1000000007;


fn main() {
    input!{
        N: isize,
        A: [isize; N]
    }
    let ans = (-100..101).map(|i| (&A).into_iter().fold(0, |acc, a| acc + (a - i)*(a - i))).min().unwrap();
    println!("{:?}", ans);
}

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int main(){
    int n, ans = 0;
    cin >> n;
    ans = !n;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

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

		int multi_num = sc.nextInt();
		int low_lim = sc.nextInt();
		int high_lim = sc.nextInt();

		for (int i = low_lim; i <= high_lim; i++) {
			if (i % multi_num ==0) {
				System.out.println("OK");
				break;
			}
			if (i == high_lim) {
				System.out.println("NG");
			}
		}
	}
}

Measured memory_bytes: 35692
n,m,x = gets.chomp.split.map(&:to_i)

ca = []

ans = 10**9

n.times do |i|
  ca << gets.chomp.split.map(&:to_i)
end

def min(a,b)
  a < b ? a : b
end


[0,1].repeated_permutation(n) do |bits|

  tmp = Array.new(m,0)
  c_tmp = 0
  n.times do |i|
    next if bits[i] == 0

    1.upto(m) do |j|
      tmp[j-1] += ca[i][j]

    end
    c_tmp += ca[i][0]
  end

  # p bits
  #
  # p tmp
  #
  # p c_tmp

  flag = true

  m.times do |k|
    flag = false if tmp[k] < x
  end

  next if flag == false

  ans = min(c_tmp,ans)

  # p bits
  # p tmp
  # p c_tmp
end





if ans == 10**9
  puts -1
else
  puts ans
end


Measured memory_bytes: 14600
from itertools import groupby

def cbn(n):
    if n == 1:
        return 0
    else:
        return n * (n - 1) // 2

N = int(input())
S = [sorted(input()) for _ in range(N)]
S.sort()
print(sum(cbn(len(list(l))) for s, l in groupby(S)))

Measured memory_bytes: 25084
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }


int main() {
    ll t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    ll p = (a1-b1)*t1, q = (a2-b2)*t2;
    if(p > 0) {
        p *= -1; q *= -1;
    }

    if(p+q < 0) cout << 0 << endl;
    else if(p+q == 0) cout << "infinity" << endl;
    else {
        if(-p%(p+q) == 0) cout << -p/(p+q)*2 << endl;
        else cout << -p/(p+q)*2 + 1 << endl;
    }
}

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

int main(){
  string S;
  cin >>S;
  if((S.at(2)==S.at(3))&&(S.at(4)==S.at(5))){
    cout <<"Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))

using namespace std;
using LL=long long;

int A[1005];
int main(){
    int n,m,maxn;
    while(1){
        cin>>n>>m;
        if(n==0) break;
        maxn=0;
        for(int i=0;i<n;i++) cin>>A[i];
        for(int i=0;i<n-1;i++){
            for(int j=i+1;j<n;j++){
                if(A[i]+A[j]<=m) maxn=max(maxn,A[i]+A[j]);
            }
        }
        if(!maxn) cout<<"NONE"<<endl;
        else cout<<maxn<<endl;
    }
    return 0;
}



Measured memory_bytes: 3084
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    a = int(input())
    print(a + a * a + a * a * a)

if __name__ == '__main__':
    main()

Measured memory_bytes: 65212
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;
#include <queue>
#include <stack>
#include <stdlib.h>


int main(){
    
    
   int N;
   int M;
   cin >> N >> M;
   vector<int> L(M),R(M),table(N + 2,0);
   for(int i = 0;i < M;i++) {
       cin >> L[i] >> R[i];
       R[i]++;
       }

   for(int i=0;i < M;i++){
       table[L[i]]++,table[R[i]]--;//カードが有効な区間の始まりを終わりを記録
   }
    //[0,N]
    int max = -1;
    int cnt =0;
   for(int i =0;i < N + 1;i++){
       table[i + 1] += table[i];
       if(table[i + 1] == M) cnt++;
   }
   
   cout << cnt << endl;

   //インデックスの数を知りたい
   //

   

}

Measured memory_bytes: 1408
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
template<class T> void _out(const T &x) { cout << x; }
void _out(const int &x) { printf("%d", x); }
void _out(const ll &x) { printf("%lld", x); }
void _out(const double &x) { printf("%.16f", x); }
void _out(const char &x) { putchar(x); }
void _out(const char *x) { printf("%s", x); }
template<class T,class U> void _out(const pair<T,U> &x) {_out(x.F); putchar(' '); _out(x.S);}
template<class T> void _out(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _out(*i++)) if (i != x.cbegin()) putchar(' '); }
void out() {}
template<class T, class... U> void out(const T &head, const U &... tail) { _out(head); putchar(sizeof...(tail) ? ' ' : '\n'); out(tail...); }
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}
const int maxn = 2e5 + 5;
int a[maxn];

int main(){
    // #ifdef LOCAL
    //     freopen("in.txt", "r", stdin);
    //     freopen("out.txt", "w", stdout);
    // #endif
    ll n, k;
    sf(n, k);
    rep(i, 1, n) {
        sf(a[i]);
    }
    ll pre = 1;
    for (int i = k + 1; i <= n; ++i) {
        if (a[i] > a[i - k]) puts("Yes");
        else puts("No");
    }
    return 0;
}

Measured memory_bytes: 4548
n,a,b,c,d=map(int,input().split())
s=input()
f=0;F=0
for i in range(a,max(c,d)-1):
  if s[i]=='#' and s[i+1]=='#':
    f=1
if c>d:
  for i in range(b-2,d-1):
    if s[i]=='.' and s[i+1]=='.' and s[i+2]=='.':
      F=1
  if F==0:
    f=1
if f==1:print('No')
else:print('Yes')

Measured memory_bytes: 3572
#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()
#define Pb(i) push_back(i)

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

    ll n,k,a[200001],sum=0,ans; Cin2(n,k);
    vector<ll> cnt(n);
    rep(i,n) cnt[i] = 0;
    rep(i,n){
        Cin(a[i]);
        cnt[a[i]-1]++;
    }
    sort(All(cnt));
    reverse(All(cnt));
    rep(i,k) sum += cnt[i];
    ans = n - sum;
    Cout(ans);
    return 0;
}

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

int main() {
  vector<int> ABC(3, 0);
  for (int i = 0; i < 3; i++) {
    scanf("%d", &ABC.at(i));
  }
  int K;
  scanf("%d", &K);

  sort(ABC.begin(), ABC.end());

  int ans = ABC.at(0) + ABC.at(1);
  for (int i = 0; i < K; i++) {
    ABC.at(2) = 2 * ABC.at(2);
  }
  ans += ABC.at(2);

  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(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 (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n;
    cin >> n;
    ld ans = ((n+1)/2) / (ld)n;
    cout << fixed << setprecision(20) << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
typedef pair<int, int> PII;
typedef long long ll;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;



int n, x[105], ans = 100000000;

int main() {

	cin >> n;
	rep(i, n)cin >> x[i];

	sort(x, x + n);

	REP(i, 1, 100) {
		int tmp = 0;
		rep(j, n) {
			tmp += pow(i - x[j], 2);
		}
		ans = min(ans, tmp);
	}

	cout << ans << endl;

	return 0;
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,a[100005],b[100005],ans;
int v[100005];
void solve(){
    cin>>n;
    rep(i,0,n) cin>>a[i]>>b[i],v[i]=i;
    sort(v,v+n,[](int x,int y){
        return a[x]+b[x]>a[y]+b[y];
    });
    rep(i,0,n){
        if(i%2==0) ans+=a[v[i]];
        else ans-=b[v[i]];
    }
    cout<<ans<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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


main(){
  int n,i,k=0;
  cin >> n;
  vector<int> p(n);
  for(i=0;i<n;i++) cin >> p[i];
  
  for(i=0;i<n;i++){
    if(i+1!=p[i]){
      k++;
    }
  }
  
  if(k<=2){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
bool second_greater(const pii& left, const pii& right) {
    return left.second > right.second;
}
#endif


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

    int N;  cin >> N;
    vi A(N); REP(i, N) cin >> A[i];

    sort(A.begin(), A.end());

    deque<int> dq;
    dq.push_back(A[0]);
    int cnt = 0;
    int left = 1, right = N - 1;
    while(left <= right) {
        if (cnt%2==0) {
            dq.push_front(A[right]);
            right--;
            if (left <= right) {
                dq.push_back(A[right]);
                right--;
            }
        } else {
            dq.push_front(A[left]);
            left++;
            if (left <= right) {
                dq.push_back(A[left]);
                left++;
            }
        }
        cnt++;
    }

    ll ans = 0;
    ll sum = 0;
    int cur = dq.front(); dq.pop_front();
    while(!dq.empty()){
        int next = dq.front(); dq.pop_front();
        sum += abs(next - cur);
        cur = next;
    }
    ans = max(ans, sum);

    dq.clear();
    dq.push_back(A[N-1]);
    cnt = 0;
    left = 0, right = N - 2;
    while(left <= right) {
        if (cnt%2==1) {
            dq.push_front(A[right]);
            right--;
            if (left <= right) {
                dq.push_back(A[right]);
                right--;
            }
        } else {
            dq.push_front(A[left]);
            left++;
            if (left <= right) {
                dq.push_back(A[left]);
                left++;
            }
        }
        cnt++;
    }

    sum = 0;
    cur = dq.front(); dq.pop_front();
    while(!dq.empty()){
        int next = dq.front(); dq.pop_front();
        sum += abs(next - cur);
        cur = next;
    }
    ans = max(ans, sum);


    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    remarks = [[]] * n
    max_v = 0

    for i in range(n):
        a = int(input())
        remarks[i] = [tuple(map(int, input().split())) for _ in range(a)]

    for i in range(2 ** n):
        i_bin = format(i, 'b').zfill(n)
        if i_bin.count('1') <= max_v:
            continue

        is_true = True
        for j in range(n):
            if i_bin[j] == '1':
                for k in remarks[j]:
                    if int(i_bin[k[0]-1]) != k[1]:
                        is_true = False
                        break
                if is_true == False:
                    break
        if is_true:
            max_v = max(max_v, i_bin.count('1'))
    print(max_v)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
def cnt(N):
    res = 0
    for i in range(1,N+1):
        if N % i == 0:
            res += 1
    return res

N = int(input())

ans = 0
for i in range(1,N+1,2):
    if cnt(i) == 8:
        ans += 1

print(ans)


Measured memory_bytes: 9112
import sys
input = sys.stdin.readline

s = input().strip()
n = len(s)
ans = 1
cur = s[0]
i = 1
while (i < n):
	if s[i] != cur:
		ans += 1
		cur = s[i]
		i += 1
	else:
		if (i + 2) > n:
			break
		else:
			cur = s[i:i+2]
			ans += 1
			i += 2
print(ans)

	

Measured memory_bytes: 41308
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int ci = (int)'a';
vi flag(27, -1);
vi flag2(27, -1);
int main()
{
  string s, t;
  cin >> s;
  cin >> t;
  int l = s.length();
  rep(i, l)
  {
    int sn = s[i] - ci;
    int tn = t[i] - ci;
    
    if (flag[sn] != -1)
    {
      if (flag[sn] != tn)
      {
        cout << "No" << endl;
        return 0;
      }
    }
    else flag[sn] = tn;
    
    if (flag2[tn] != -1)
    {
      if (flag2[tn] != sn)
      {
        cout << "No" << endl;
        return 0;
      }
    }
    else flag2[tn] = sn;
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 776
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		for(int i=1;i<10;i++){
			for(int j=1;j<10;j++){
				int k = i*j;
				System.out.println(i+"x"+j+"="+k);
			}
		}

	}

}

Measured memory_bytes: 9340
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
typedef long long ll;
int main() {
  int A, B; cin >> A >> B;
  if(A<=5) cout << 0 << endl;
  else if ((A>=6) && (A<=12)) cout << B/2 << endl;
  else cout << B << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------


/*------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
------------------------------------------------------------------------------*/


//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


void _main()
{
    COMinit();

    int N, M;
    cin >> N >> M;
    int m = M;
    vector<int> exponents;
    for (int i = 2; i * 2 <= M; ++i)
    {
        int exponent = 0;
        while (m % i == 0)
        {
            ++exponent;
            m /= i;
        }
        if (exponent > 0)
        {
            exponents.push_back(exponent);
        }
    }
    ll ans = 1;
    for(const int exponent : exponents)
    {
        ans *= COM(exponent + N - 1, exponent);
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 12160
#include <bits/stdc++.h> 
        using namespace std;
        typedef long long ll;
        typedef pair<int,int> p;
        const int inf=(1<<30);
        #define rep(i,a,n)	for(int i=a;i<n;i++)
        #define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
        	
        int main(){
        	ll n,k;
        	cin>>n>>k;
        	ll a[100010];
        	rep(i,0,n)cin>>a[i];
        	ll dp[100010];
        	rep(i,0,n)dp[i]=inf;
        	dp[0]=0;
        	rep(i,0,n){
        		rep(j,1,k+1){
        			if(i+j<=n)
        			dp[i+j]=min(dp[i+j],dp[i]+abs(a[i]-a[i+j]));
        		}
        	}
        	cout<<dp[n-1]<<endl;
        }

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

using namespace std;

const int N = 2e5 + 5;

long long n , m;
long long a[N] , b[N] ;

int main()
{
    cin>>n>>m;
    for(int i =0;i<n;i++)cin>>a[i];
    for(int i =0;i<n;i++)cin>>b[i];
    sort(a , a+n) ;
    sort(b , b+n , greater<long long>()) ;
    long long l = 0 , r= 1e17 ,ans = 0;
    while(l<=r)
    {
        long long mid = (l+r) /2;
        long long mm = 0;
        for(int i = 0;i<n;i++)
        {
            long long k = mid / b[i];
            mm+= max(0ll ,a [i] - k);
        }
        if(mm<=m)
        {
            r = mid-1;
            ans = mid;
        }
        else l = mid+1;
    }

    cout<<ans;
    return 0;
}


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

int main(){
    char C;
    cin >> C;
    if(C == 'a'){
        cout << 'b' << endl;
    }
    else if(C == 'b'){
        cout << 'c' << endl;
    }
    else if(C == 'c'){
        cout << 'd' << endl;
    }
    else if(C == 'd'){
        cout << 'e' << endl;
    }
    else if(C == 'e'){
        cout << 'f' << endl;
    }
    else if(C == 'f'){
        cout << 'g' << endl;
    }
    else if(C == 'g'){
        cout << 'h' << endl;
    }
    else if(C == 'h'){
        cout << 'i' << endl;
    }
    else if(C == 'i'){
        cout << 'j' << endl;
    }
    else if(C == 'j'){
        cout << 'k' << endl;
    }
    else if(C == 'k'){
        cout << 'l' << endl;
    }
    else if(C == 'l'){
        cout << 'm' << endl;
    }
    else if(C == 'm'){
        cout << 'n' << endl;
    }
    else if(C == 'n'){
        cout << 'o' << endl;
    }
    else if(C == 'o'){
        cout << 'p' << endl;
    }
    else if(C == 'p'){
        cout << 'q' << endl;
    }
    else if(C == 'q'){
        cout << 'r' << endl;
    }
    else if(C == 'r'){
        cout << 's' << endl;
    }
    else if(C == 's'){
        cout << 't' << endl;
    }
    else if(C == 't'){
        cout << 'u' << endl;
    }
    else if(C == 'u'){
        cout << 'v' << endl;
    }
    else if(C == 'v'){
        cout << 'w' << endl;
    }
    else if(C == 'w'){
        cout << 'x' << endl;
    }
    else if(C == 'x'){
        cout << 'y' << endl;
    }
    else if(C == 'y'){
        cout << 'z' << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#import numpy as np
from sys import stdin
from copy import deepcopy
from functools import reduce
from fractions import gcd
import math
import itertools
from collections import Counter
from itertools import chain  ##list(chain.from_iterable(l)) ##flatten
from heapq import heappush, heappop

"""
N = int(input())
A, B = map(int,input().split())
A = list(map(int,input().split())) ## 横一列
A = [int(input()) for _ in range(N)] ## 縦一列
lst = [list(map(int,input().split())) for i in range(M)] ## 二次元
"""

# 最小公倍数
def lcm_base(x, y):
    return (x * y) // gcd(x, y)

A, B, C, D = map(int,input().split())

lcm = lcm_base(C, D)

n_c = (B // C) - ((A - 1) // C)
n_d = (B // D) - ((A - 1) // D)
n_cd = (B // lcm) - ((A - 1) // lcm)

ans = (B - A + 1) - n_c - n_d + n_cd
print(ans)

Measured memory_bytes: 5104