akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-15
inline int read(){
    res s=0;
    bool w=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return w?-s:s;
}
inline void _swap(res &x,res &y){
    x^=y^=x^=y;
}
inline int _abs(const res &x){
    return x>0?x:-x;
}
inline int _max(const res &x,const res &y){
    return x>y?x:y;
}
inline int _min(const res &x,const res &y){
    return x<y?x:y;
}
const int N=1e6+10;
namespace MAIN{
    int a[N],n,k;
    namespace Segtree{
        int mn[N<<2];
        inline void pushup(const res &rt){
            mn[rt]=_min(mn[rt<<1],mn[rt<<1|1]);
        }
        void build(const res &rt,const res &l,const res &r){
            mn[rt]=inf;
            if(l==r)return;
            res mid=(l+r)>>1;
            build(rt<<1,l,mid),build(rt<<1|1,mid+1,r);
        }
        void update(const res &rt,const res &l,const res &r,const res &p,const res &va){
            if(l==r){mn[rt]=va;return;}
            res mid=(l+r)>>1;
            if(p<=mid)update(rt<<1,l,mid,p,va);
            else update(rt<<1|1,mid+1,r,p,va);
            pushup(rt);
        }
        int query(const res &rt,const res &l,const res &r,const res &L,const res &R){
            if(L>R)return 0;
            if(L<=l&&r<=R)return mn[rt];
            res mid=(l+r)>>1,ans=inf;
            if(L<=mid)ans=_min(ans,query(rt<<1,l,mid,L,R));
            if(R>mid)ans=_min(ans,query(rt<<1|1,mid+1,r,L,R));
            return ans;
        }
    }
    struct E{
        int next,to;
        E() {}
        E(res next,res to):next(next),to(to) {}
    }edge[N];
    int head[N],cnt,du[N];
    inline void addedge(const res &u,const res &v){
        edge[++cnt]=E(head[u],v),head[u]=cnt,du[v]++;
    }
    int x;
    priority_queue<int,vector<int>,greater<int> >Q;
    int id[N],idx;
    inline void topsort(){
        for(res i=1;i<=n;i++)if(!du[i])Q.push(i);
        while(!Q.empty()){
            res u=Q.top();
            Q.pop();
            id[u]=++idx;
            for(res i=head[u];~i;i=edge[i].next){
                res tox=edge[i].to;
                if(--du[tox]==0)Q.push(tox);
            }
        }
    }
    inline void MAIN(){
        memset(head,-1,sizeof(head));
        n=read(),k=read();
        for(res i=1;i<=n;i++)a[read()]=i;
        Segtree::build(1,1,n);
        for(res i=n;i;i--){
            x=Segtree::query(1,1,n,a[i]+1,_min(a[i]+k-1,n));
            if(x>=1&&x<=n)addedge(a[i],a[x]);
            x=Segtree::query(1,1,n,_max(1,a[i]-k+1),a[i]-1);
            if(x>=1&&x<=n)addedge(a[i],a[x]);
            Segtree::update(1,1,n,a[i],i);
        }
        topsort();
        for(res i=1;i<=n;i++)printf("%d\n",id[i]);
    }
}
int main(){
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 32632
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
     int a,b;
     cin>>a>>b;
     b*=2;
     b-=a;
     cout<<b<<endl;

    return 0;
}


Measured memory_bytes: 3692
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

long long gcd(long long p,long long q){
  if(p % q == 0) return q;
  else return gcd(q,p%q);
}

int main(){
  long long a,b,c,d;
  cin >> a >> b >> c >> d;
  long long g;
  g = gcd(c,d);
  long long nb;
  long long baisu;
  baisu = c*d/g;
  nb = b - (b/c + b/d - b/baisu);
  long long na;
  na = a - (a/c + a/d - a/baisu);
  long long ans = nb-na;
  if(a%c != 0){
    if(a%d != 0){
      ans += 1;
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main(){
  int s1 = 0 , s2 = 0 , s3 = 0 , i = 0 , a = 0;
  cin >> i;
  s1 = (i - i % 100) / 100;
  s2 = ((i - s1 * 100) - i % 10) / 10;
  s3 = i % 10;
  a = s1 % 2 + s2 % 2 + s3 % 2;
  cout << a << endl;
}

Measured memory_bytes: 256
n = int(input())
s = list(input())
ans = 0
c = 0
fh = []
lh = s
for i in range(n):
  tmp = lh.pop(0)
  if tmp not in fh:
    if tmp in lh:
      c += 1
  elif tmp not in lh:
    c -= 1
  fh.append(tmp)
  ans = max(ans, c)
print(ans)

Measured memory_bytes: 9128
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

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

    string ans = "";
    rep(i, s.size()){
        if(s[i] == '?')ans.push_back('D');
        else ans.push_back(s[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3900
import java.util.*

val sc = Scanner(System.`in`)
val N = sc.nextInt()
val M = sc.nextInt()
val X = sc.nextInt()
val A = Array(M) { sc.nextInt() }

fun main(args: Array<String>) {
    val l = A.filter { it < X }.count()
    val r = A.filter { it > X }.count()

    println(Math.min(l, r))
}


Measured memory_bytes: 29348
import java.util.Scanner;
import java.util.Arrays;
import java.util.Collections;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(); 
		int[]a = new int[n];
		int al=0, sw = 0;
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt(); 
		}
		Arrays.sort(a);
		for(int i = n-1; i >= 0; i--) {
			if(sw == 0) {
				al += a[i];
				sw = 1;
			} else {
				al -= a[i];
				sw = 0;
			}
		}
		System.out.println(al);
	}
}

Measured memory_bytes: 21844
#include <iostream>

using namespace std;

bool ballTest(int *balls, int *b, int numB, int *c, int numC, int num)
{
        if (num <= 0) {
                return true;
        }
        if (balls[0] > b[numB - 1]) {
                b[numB] = balls[0];
                if (ballTest(&balls[1], b, numB + 1, c, numC, num - 1)) {
                        return true;
                }
        }
        if (balls[0] > c[numC - 1]) {
                c[numC] = balls[0];
                if (ballTest(&balls[1], b, numB, c, numC + 1, num - 1)) {
                        return true;
                }
        }
        return false;
}


int main(int argc, char **argv)
{
        int num;

        cin >> num;

        for (int i = 0; i < num; i++) {
                int balls[11];
                int b[10], c[10];
                int numB, numC;

                b[0] = c[0] = 0;
                numB = numC = 1;
                cin >> balls[1] >> balls[2] >> balls[3] >> balls[4] >> balls[5] >> balls[6] >> balls[7] >> balls[8] >> balls[9] >> balls[10];
                if (ballTest(&balls[1], b, 1, c, 1, 10)) {
                        cout << "YES\n";
                } else {
                        cout << "NO\n";
                }
        }
        return 0;
}

Measured memory_bytes: 1116
import java.util.Scanner;
 
class Main {
  public static void main(String args[]) {
    Scanner scanner = new Scanner(System.in);
 
    int S = scanner.nextInt();
    int h, m, s;

    h = S / 3600;
    S %= 3600;

    m = S /60;
    S %= 60;

    s = S;
 
    System.out.println(h + ":" + m + ":" + s);
    scanner.close();
  }
}


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

using namespace std;

int main(void) {
  int n;
  long long a, b;
  cin >> n >> a >> b;

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

  long long ans = 0;
  for (int i = 1; i < n; i++) {
    ans += min((x[i] - x[i - 1]) * a, b);
  }

  cout << ans << endl;
  
  return 0;
}

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

void solve(long long N, std::vector<long long> a) {
  long long count = 0;
  for (long long i = 0; i < N; i++) {
    while (true) {
      if (a[i] % 2 == 0) {
        count++;
        a[i] /= 2;
      } else {
        break;
      }
    }
  }
  cout << count << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  solve(N, std::move(a));
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int n,m;
	while(1){
		cin>>n>>m;
		if(n+m==0) break;
		vi d(n+m+1,0);
		d[0]=0;
		rep(i,1,n+m+1) cin>>d[i];
		sort(all(d));
		int MAX=0;
		rep(i,0,n+m){
			MAX=max(MAX,d[i+1]-d[i]);
		}
		o(MAX);
	}
}

Measured memory_bytes: 1296
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int main()
{
	long long sum = 0;
	int N;
	cin >> N;

	vector<int> A(N + 2);

	A[0] = 0;
	for (int i = 1; i <= N; i++)
	{
		cin >> A[i];
	}
	A[N + 1] = 0;

	for (int i = 0; i < N + 1; i++)
	{
		sum += abs(A[i] - A[i + 1]);
	}
	
	for (int i = 0; i < N; i++)
	{
		cout << sum - abs(A[i] - A[i + 1]) - abs(A[i + 1] - A[i + 2]) + abs(A[i] - A[i + 2]) << endl;
	}

	return 0;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int main() {
    lint A, V, B, W, T;
    cin >> A >> V;
    cin >> B >> W;
    cin >> T;

    if (A < B) {
        lint X = A + V * T;
        lint Y = B + W * T;
        puts(X >= Y ? "YES" : "NO");
    }
    else {
        lint X = A - V * T;
        lint Y = B - W * T;
        puts(X <= Y ? "YES" : "NO");
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse
// struct Edge {
//   int to, id;
//   Edge(int a, int b): to(a), id(b) {}
// };

vector<ll> a[20];

int main(int argc, char const *argv[])
{
	int k;cin>>k;

	rep(i,10) {
		a[0].push_back(i);
	}

	int cnt=9;

	if (k<=9) {
		cout<<a[0][k]<<endl;
		return 0;
	}

	int dig=2;
	ll ten=10;
	while (1) {
		rep(i,10) {
			rep(j,a[dig-2].size()) {
				int x = a[dig-2][j]/(ten/10);
				if (x-1<=i&&i<=x+1) {
					a[dig-1].push_back(i*ten+a[dig-2][j]);
					// if (dig==2) cout<<i*ten+a[dig-2][j]<<endl;
					if (i!=0) cnt++;
					if (cnt==k) {
						cout<<i*ten+a[dig-2][j]<<endl;
						return 0;
					}
				}
			}
		}
		ten*=10;
		dig++;
	}



	return 0;
}

Measured memory_bytes: 1528
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL<<60;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  string S,T;
  cin >> S >> T;
  int N = S.size();
  for(int i=0; i<26; i++){
    int temp = -1;
    for(int j=0; j<N; j++){
      int nowS = S[j] - 'a';
      int nowT = T[j] - 'a';
      if(nowT == i){
        if(temp == -1){
          temp = nowS;
        }else{
          if(temp != nowS){
            cout << "No" << endl;
            return 0;
          }
        }
      }
    }
  }
  for(int i=0; i<26; i++){
    int temp = -1;
    for(int j=0; j<N; j++){
      int nowS = S[j] - 'a';
      int nowT = T[j] - 'a';
      if(nowS == i){
        if(temp == -1){
          temp = nowT;
        }else{
          if(temp != nowT){
            cout << "No" << endl;
            return 0;
          }
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 776
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>

using namespace std;

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

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

    int str_size;
    while(true) {
        str_size = s.length();

        if (str_size >= 5 && s.substr(str_size - 5) == "dream") {
            s.erase(s.begin() + str_size - 5, s.end());
        } else if (str_size >= 5 && s.substr(str_size - 5) == "erase") {
            s.erase(s.begin() + str_size - 5, s.end());
        } else if (str_size >= 6 && s.substr(str_size - 6) == "eraser") {
            s.erase(s.begin() + str_size - 6, s.end());
        } else if (str_size >= 7 && s.substr(str_size - 7) == "dreamer") {
            s.erase(s.begin() + str_size - 7, s.end());
        } else if (str_size == 0) {
            cout << "YES" << endl;
            return 0;
        } else {
            cout << "NO" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 512
import sys
readline = sys.stdin.readline

MOD = 10**9+7
N = int(readline())
C = list(map(int, readline().split()))
C.sort()

ans = 0
for i in range(N):
    ans = (ans + pow(2, 2*N-2, MOD)*C[i]*(N-i+1))%MOD
print(ans)


Measured memory_bytes: 78924
#include<bits/stdc++.h>
using namespace std;
#define N int(1e5)
int main(){
    int n, k, t, ans;
    int x[N], d[N];
    cin >> t;
    for(int i = 0; i < t; i++){
        cin >> n >> k;
       for(int j = 0; j < n; j++){
            cin >> x[j];
            if(j)
                d[j - 1] = x[j - 1] - x[j];
        }
        ans = x[n - 1] - x[0];
        sort(d, d + n - 1);
        for(int j = 0; j < min(k - 1, n - 1); j++){
            ans += d[j];
        }
        cout << ans << endl;
    }

}


Measured memory_bytes: 3928
#include <iostream>
using namespace std;
int main(){
  int n,a,b,c;
  cin>>n>>a>>b;
  c=(b/n)-((a-1)/n);
  if(c>=1){
    cout<<"OK"<<endl;
  }else{
    cout<<"NG"<<endl;
  }
  return 0;
}


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

int main(){
	int n,a,max=-1000000,min=1000000;
	long long sum=0;
	cin >> n;
	for(int i=0;i<n;++i){
		cin >> a;
		if(a > max)max=a;
		if(a < min)min=a;
		sum+=a;
	}
	cout << min << " " << max << " " << sum <<endl;

	return 0;
}

Measured memory_bytes: 1164
x1,y1,x2,y2,n,*a=`dd`.split.map &:to_i
xf=yf=1
x1>x2&&(x1,x2,xf=x2,x1,-1)
y1>y2&&(y1,y2,yf=y2,y1,-1)
v=a.each_slice(2).select{|x,y|x1<=x&&x<=x2&&y1<=y&&y<=y2}.map{|x,y|[x*xf,y*yf]}.sort
d=[F=1<<30]*s=v.size
v.each{|x,y|d[d.bsearch_index{|e|e>=y}]=y}
n=d.bsearch_index{|e|e>=F}||s
p 100.0*(x2-x1+y2-y1)-20*n+5*(n+(n>[x2-x1,y2-y1].min ? 1:0))*Math::PI

Measured memory_bytes: 42508
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;

template<int MOD> struct Fp {
	long long val;
	constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
		if (val < 0) val += MOD;
	}
	constexpr int getmod() { return MOD; }
	constexpr Fp operator - () const noexcept {
		return val ? MOD - val : 0;
	}
	constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
	constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
	constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
	constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
	constexpr Fp& operator += (const Fp& r) noexcept {
		val += r.val;
		if (val >= MOD) val -= MOD;
		return *this;
	}
	constexpr Fp& operator -= (const Fp& r) noexcept {
		val -= r.val;
		if (val < 0) val += MOD;
		return *this;
	}
	constexpr Fp& operator *= (const Fp& r) noexcept {
		val = val * r.val % MOD;
		return *this;
	}
	constexpr Fp& operator /= (const Fp& r) noexcept {
		long long a = r.val, b = MOD, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % MOD;
		if (val < 0) val += MOD;
		return *this;
	}
	constexpr bool operator == (const Fp& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Fp& r) const noexcept {
		return this->val != r.val;
	}
	friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
		return os << x.val;
	}
	friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
		if (n == 0) return 1;
		auto t = modpow(a, n / 2);
		t = t * t;
		if (n & 1) t = t * a;
		return t;
	}
};

// 二項係数ライブラリ
template<class T> struct BiCoef {
	vector<T> fact_, inv_, finv_;
	constexpr BiCoef() {}
	constexpr BiCoef(int n) noexcept : fact_(n, 1), inv_(n, 1), finv_(n, 1) {
		init(n);
	}
	constexpr void init(int n) noexcept {
		fact_.assign(n, 1), inv_.assign(n, 1), finv_.assign(n, 1);
		int MOD = fact_[0].getmod();
		for(int i = 2; i < n; i++){
			fact_[i] = fact_[i-1] * i;
			inv_[i] = -inv_[MOD%i] * (MOD/i);
			finv_[i] = finv_[i-1] * inv_[i];
		}
	}
	constexpr T com(int n, int k) const noexcept {
		if (n < k || n < 0 || k < 0) return 0;
		return fact_[n] * finv_[k] * finv_[n-k];
	}
	constexpr T fact(int n) const noexcept {
		if (n < 0) return 0;
		return fact_[n];
	}
	constexpr T inv(int n) const noexcept {
		if (n < 0) return 0;
		return inv_[n];
	}
	constexpr T finv(int n) const noexcept {
		if (n < 0) return 0;
		return finv_[n];
	}
};

int main() {
	BiCoef<Fp<MOD>> bc;
	bc.init(2100000);
	ll r1,c1,r2,c2;
	cin>>r1>>c1>>r2>>c2;

	auto g = [&](ll r, ll c){
		return bc.com(r+c+2,r+1)-1;
	};

	Fp<MOD> ans=g(r2,c2)-g(r1-1,c2)-g(r2,c1-1)+g(r1-1,c1-1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 49408
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <algorithm>  // std::unique
#include <cmath>
#include <limits.h>
#include <queue>
#include <unordered_map>
#include <sstream>      // std::ostringstream

#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

using ll = long long;
constexpr auto PrimeBigNum10_9_7 = 1000000007;

std::vector<std::string> split(const std::string &str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}


// 素数判定
template <typename T>
bool IsPrimeNumber(T value) {

	for (int i = 2; i * i <= value; ++i) {
		if ((value % i) == 0) {
			return true;
		}
	}
	return false;
}

// 桁数判定
template <typename T>
T GetFigureLength(T value) {
	T figure = 1;
	while (value >= 10) {
		value /= 10;
		++figure;
	}
	return figure;
}

// 素因数分解結果
template <typename T>
map<T, T> GetPrimeFactorize(T value) {

	map<T, T> res;

	for (T i = 2; i * i <= value; ++i) {
		if ((value%i) != 0)	continue;

		T count = 0;
		while ((value % i) == 0) {
			value /= i;
			++count;
		}

		res[i] = count;
	}

	if (value != 1) {
		res[value] = 1;
	}
	return res;
}

void DebugPrint(const vector<ll>& vec) {
	cout << "{";
	for (auto itr = vec.begin(); itr != vec.end(); ++itr) {
		cout << *itr << ",";
	}
	cout << "}" << endl;
}

// valueが2のx乗以下である計算
ll calc2x(ll value) {
	ll n = 0;
	while (value > 0) {
		value /= 2;
		++n;
	}
	return n;
}



struct Vec2 {
	double x;
	double y;

	void rotate(double rad) {
		double s = sin(rad);
		double c = cos(rad);
		double tmpX = this->x*c - this->y*s;
		double tmpY = this->x*s + this->y*c;
		this->x = tmpX;
		this->y = tmpY;
	}
};

int main(void) {

	vector<ll> sumCounterList;
	for (int i = 1; i <= 100; ++i) {
		sumCounterList.push_back(i * (i + 1) / 2);
	}



	ll a;
	cin >> a;

	auto answers = GetPrimeFactorize(a);

	ll ansCount = 0;
	for (auto n : answers) {
		if (n.second == 0)	continue;
		
		auto find = std::find_if(sumCounterList.rbegin(), sumCounterList.rend(), [n](ll v) { return n.second >= v; });
		auto v = sumCounterList.size()-std::distance(sumCounterList.rbegin(), find);
		//cout << n.first << ":" << n.second << "->" << v << endl;
		ansCount += v;
	}
	cout << ansCount << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979

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

int main(void){
	int N,like;
	set<P> pairs;
	ll result=0;

	cin>>N;
	FOR(i,1,N+1){
		cin>>like;
		P pair(min(i,like),max(i,like));		
		if(pairs.find(pair)!=pairs.end()) result++;
		else pairs.insert(pair);
	}
	cout<<result<<endl;

}



Measured memory_bytes: 4992
(* O(n) *)
let solve n a_s =
  let abs_s = List.map abs a_s in
  let mi = List.fold_left min max_int abs_s in
  let sum = List.fold_left (+) 0 abs_s in
  if mi = 0 then
    sum
  else
    let neg_count = List.fold_left (fun acc a -> if a < 0 then acc + 1 else acc) 0 a_s in
    if neg_count mod 2 = 0 then
      sum
    else
      sum - mi * 2

let read_ints () = read_line () |> Str.split (Str.regexp " ") |> List.map int_of_string
let _ =
  let n = read_int () in
  read_ints () |> solve n |> string_of_int |> print_endline

Measured memory_bytes: 18176
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

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

int main(){
  int a,b,c,k;
  string s;
  cin >> a >> b >> c >> k;
  rep(i,7){
    rep(j,7){
      rep(h,7){
        if (a*pow(i) < b*pow(j) && b*pow(j) < c*(pow(h))){
          if (i+j+h <= k){
            cout << "Yes" << endl;
            return 0;
          }
        }
      }
    }
  }
  cout << "No" << endl;
  
  

  return 0;
}


Measured memory_bytes: 3620
d,g = map(int,input().split())
p = d * [0]
c = d * [0]
for i in range(d):
    p[i], c[i] = map(int, input().split())

m = []

for i in range(2**d):
    sum = 0
    cnt = 0
    z = [i for i in range(d)]
    for j in range(d):
        if (i>>j)&1:
            sum += (j+1) * 100 * p[j] +c[j]
            cnt += p[j]
            z.remove(j)
    if sum < g:
        for i in range(p[max(z)]):
            sum += (max(z) + 1) *100
            cnt += 1
            if sum >= g:
                m.append(cnt)
                break

    else:
        m.append(cnt)

print(min(m))


Measured memory_bytes: 3064
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
#include <cstdlib>
//using
using namespace std;
using vl = vector <long long>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
using vvc = vector<vector<char> >;
//vector<vector<char> > hyou(N, vector<char>(N));
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//素数判定　O(√A) 
bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }
/*順列生成
do {
  // 順列に対する処理
} while (next_permutation(配列変数.begin(), 配列変数.end()));*/

//絶対値　abs()
//文字→数字　'0' アルファベット→数字　'a'　'A'が65番,'a'が97番だわ
//型キャスト　char('a'+1)
//reverse 回文

/*各位の和　
int sum = 0;
for(int i = 0; i <= 5; i++){
   sum += n%10;
   n /= 10;  
}
*/

//グローバル変数宣言
ll p=0,q=0,r=0;

int main()
{
  ll n,m;
  cin>>n>>m;
  vl a(m),b(m),c(n);
  rep(i,m){
    cin>>a[i]>>b[i];
    c[a[i]-1]++;
    c[b[i]-1]++;
  }
  rep(i,n)print(c[i])
}


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

// 1-A 標準出力にHelloWorldと出力する
class Main {

	// プログラムのエントリポイント
	public static void main(String[] args) {

		//階乗を宣言
		final int intFactorial = 3;

		//答えの格納場所
		int intAnswer = 1;

		try{
			//キーボードからの入力準備
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			//キーボードからの入力をString型で受け取る
			String strLine = br.readLine();

			//入力値をint型にする
			int intLine = Integer.parseInt(strLine);

			//階乗の回数だけ回す
			for(int i = 0; i < intFactorial; i++) {

				//入力値を掛ける
				intAnswer = intAnswer * intLine;
			}

			//結果を出力
			System.out.println(intAnswer);

		//例外処理
		}catch(IOException e) {

			//例外内容の表示
			System.out.println(e);
		}

	}

}

Measured memory_bytes: 17056
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cctype>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#define LL long long
#define MAXN 100010
#define debug(x) cerr << #x << " " << x << endl
using namespace std;

inline int read() { int x = 0, f = 1; char ch = getchar();
    for(; !isdigit(ch); ch = getchar()) f = ch == '-' ? -1 : 1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; return x * f;
}

const int inf = 1e9 + 7;

int n;
int T, A;
int h;

int main() {
    n = read();
    T = read(); A = read();
    double minn = inf, mini;
    for(int i = 1; i <= n; ++i) {
        h= read();
        double t = (double)T - (double)h * 0.006;
        if(fabs((double)A - t) < minn) {
            minn = fabs((double)A - t);
            mini = i;
        }
    }
    cout << mini << endl;
    return 0;
}

Measured memory_bytes: 256
use std::cmp;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };

    let s = sc
        .chars()
        .into_iter()
        .map(|c| c as usize - 'a' as usize)
        .collect::<Vec<_>>();
    let inf = s.len();
    let mut prefix_dp = vec![inf as u32; 1 << 26];

    let mut cur: usize = 0;
    for s in s.into_iter() {
        cur ^= 1 << s;
        if cur.count_ones() <= 1 {
            prefix_dp[cur] = 1;
        } else {
            let mut min = prefix_dp[cur];
            for i in 0..26 {
                let suffix = 1 << i;
                let prefix = cur ^ suffix;
                min = cmp::min(min, prefix_dp[prefix] + 1);
            }
            prefix_dp[cur] = min;
        }
    }

    println!("{}", prefix_dp[cur]);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 268668
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
int main(){
    int a,b;
    cin >> a >> b;
//    int ans[5];
    vector<int> ans(5); 
    int val;
    string str,rev;
    int count = 0;
    for(int i = a; i <= b; i++) {
        val = i;
        ans[0] = val % 10; val /= 10;
        ans[1] = val % 10; val /= 10;
        ans[2] = val % 10; val /= 10;
        ans[3] = val % 10; val /= 10;
        ans[4] = val % 10; val /= 10;
//        str = to_string(i);
        reverse(ans.begin(),ans.end());
/*
        rev = "";
        for(int i = 0; i <5; i++){
            rev += to_string(ans[i]);
        }
*/        
//        cout << "str :" << str << endl;
//        cout << "rev :" << rev << endl;
        if(ans[0] == ans[4] && ans[1] == ans[3]){
            count += 1;
        }
    }
    cout << count << endl;
 
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;

const int MAX_W = 55;
const int INF = 1<<29;
int H, W;

char board[MAX_W][MAX_W+1];
bool visited[MAX_W][MAX_W];
int memo[MAX_W][MAX_W];

int rec(int y, int x){

	//»
	if(visited[y][x]){
		return memo[y][x];
	}
	visited[y][x] = true;

	int &ret = memo[y][x];
	ret = INF;

	//îê
	if(y == 0 && x == 0){
		return ret = 0;
	}

	if( x > 0){
		ret = min(ret, rec(y, x-1) );
	}
	if( y > 0){
		ret = min(ret, rec(y-1, x) );
	}


	ret += board[y][x] - '0';
	return ret;

}

int main(){

	scanf("%d%d\n", &H, &W);
	for(int i=0; i<H; i++){
		scanf("%s\n", board[i]);
	}

	printf("%d\n", rec(H-1,W-1));

	return 0;
}

Measured memory_bytes: 0
/*
  AOJ 1019
  Title:Vampirish Night
  @kankichi573
*/
#include <stdio.h>
int N,K,S[100],B;

main()
{
  int i,j,flag;


  while(scanf("%d %d",&N,&K) && (N||K))
    {
      flag=0;
      for(j=0;j<K;j++)
	scanf("%d ",&S[j]);
      for(i=0;i<N;i++)
	for(j=0;j<K;j++)
	  {
	    scanf("%d ",&B);
	    S[j] -= B;
	    if(S[j]<0)
	      flag=-1;
	  }
      printf("%s\n",flag?"No":"Yes");

    }
  return(0);
}

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

vector<set<int>> Nu(200009);
vector<pair<int,int>> T(200009);
vector<int> ordl(200009);
vector<int> B(200009, -1);
ll tu = 1, N, K, a, ans;

void runner(int x) {
	//xは出発点
	//yは到着点
	int y = T[x].first;
	//cout << x << " " << y << endl;
	if (T[x].second)
		tu++;

	if (tu == K + 1) {
		tu--;
		return;
	}
	if (y == N - 1) {
		K %= tu;
		return;
	}
	B[tu] = y;
	runner(y + 1);
}

int main() {
	cin >> N >> K;
	vector<int> A(N);
	for (int i = 0;i < N;i++) {
		cin >> A[i];
		Nu[A[i]].insert(i);
	}
	for (int i = 0;i < N;i++) {
		auto it = Nu[A[i]].find(i);
		it++;
		if (it == Nu[A[i]].end()) {
			it = Nu[A[i]].begin();
			T[i] = { *it,1 };
		}
		else
			T[i] = { *it,0 };
	}
	B[0] = N;
	runner(0);
	//cout << tu << K << B[K] << endl;
	for (int i = B[K] + 1;i < N;i++) {
		if (T[i].second == 0) {
			i = T[i].first;
		}
		else {
			cout << A[i] << " ";
		}
	}
}

Measured memory_bytes: 24192
#!/usr/bin/env python3
import sys


def solve(N: int, K: int):
    ans = N
    N =  abs(N - K * (N // K))
    if ans > N:
        ans = N
    for i in range(3):
        N = abs(N - K)
        if ans > N:
            ans = N


    print(ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61952
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>

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

int main(){
    string str;
    cin >> str;
    int zero=0,one=0;
    rep(i,str.length()){
        if(str[i] == '0') zero++;
        else one++;
    }

    cout << 2 * min(zero,one) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {
    int a,b,k;
    cin >> a >> b >> k;
    int cnt = 0;
    int i;
    for (i = 100;; i--) {
        if (a%i==0 && b%i == 0) {
            //cout << i << endl;
            cnt++;
            if (cnt >= k) {break;}
        }
    }
    cout << i << endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, X) = listOfInt()
    if (X == 1 || X == 2 * N - 1) { println("No"); return }
    println("Yes")
    val A = IntArray(2 * N - 1)
    A[N - 2] = X - 1; A[N - 1] = X; A[N] = X + 1
    val B = (1..2 * N - 1).toMutableList()
    B.removeAll(listOf<Int>(X - 1, X, X + 1))
    var b = 0
    for (n in 0 until N - 2) A[n] = B[b++]
    for (n in N + 1 until 2 * N - 1) A[n] = B[b++]
    println(A.joinToString(separator = " "))
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }


Measured memory_bytes: 61060
import math

def main():
	n = int(input())
	cnt = 0
	for _ in range(n):
		a = int(input())
		if isPrime(a):
			cnt += 1
	print(cnt)


def isPrime(x):
	if x == 2:
		return True

	if x < 2 or (x%2) == 0:
		return False

	i = 3
	while i <= math.sqrt(x):
		if (x%i) == 0:
			return False
		i  += 2
	
	return True

main()


Measured memory_bytes: 5672
N, M = map(int, input().split())
x = [0] * N
y = [0] * N
z = [0] * N
result = []
sub_res = []

for i in range(N):
    x[i], y[i], z[i] = map(int, input().split())

for i in range(2 ** 3):
    for j in range(N):
        x_ = x[j] * (-1) ** int(bool(i & (1 << 0)))
        y_ = y[j] * (-1) ** int(bool(i & (1 << 1)))
        z_ = z[j] * (-1) ** int(bool(i & (1 << 2)))
        sum_ = x_ + y_ + z_
        sub_res.append(sum_)
    sub_res.sort()
    result.append(sum(sub_res[N - M:]))
    sub_res = []
print(max(result))

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

int main(void){
        string S,T;
        cin>>S>>T;
	S=S+S;
	if(S.find(T)==-1){
	cout<<"No"<<endl;
	}else{
	cout<<"Yes"<<endl;
	}

        return 0;
}



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

#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define endl '\n'
// #define int long long

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, k;
string s;
int32_t main()
{
	IOS
	//freopen("input.txt", "r", stdin);
	cin >> n >> k;
	cin >> s;
	s[k-1] += 32;
	cout << s << endl;
	return 0;
}


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

#define rep(i, a, b) for(int i=a; i<=b; i++)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MOD = 1e9+7;

ll n, x, m, lst, fst;
vector<ll> vec;
map<ll, int> ind;
ll sum, ans;

int main(){
  // freopen("input.txt", "r", stdin); 
  // freopen("output.txt", "w", stdout);
  cin.sync_with_stdio(0); cin.tie();
  cin.exceptions(cin.failbit);

  cin >> n >> x >> m;
  vec.pb(x);
  // cout << "k "<<x<<endl;
  rep(i, 1, m-1){
    ll k=(vec[i-1]*vec[i-1])%m;
    // cout << "k "<<k<<endl;
    if(k==x || ind[k]!=0){
      lst=i-1;
      fst=ind[k]; break;
    }
    vec.pb(k);
    ind[k]=i;
  }
  rep(i, fst, lst) sum+=vec[i];
  ans=((n-fst)/(lst-fst+1))*sum;
  rep(i, 0, fst-1) ans+=vec[i];
  int k=(n-fst)%(lst-fst+1);
  rep(i, 0, k-1) ans+=vec[fst+i];
  cout << ans;  
}

Measured memory_bytes: 6720
s=input()
leng=len(s)
a=0 #0101
b=0 #1010
for i in range(leng):
  if i%2==0:
    if s[i]=="1":
      a+=1
    if s[i]=="0":
      b+=1
  if i%2==1:
    if s[i]=="0":
      a+=1
    if s[i]=="1":
      b+=1
if a>=b:
  print(b)
else:
  print(a)

Measured memory_bytes: 9168
/*#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
typedef pair<ll , pair<ll, ll> > pi;
int pow(int x,int y){
    int res=1;
    while(y){
        if(y&1) res*=x;
        y>>=1;
        x*=x;
    }
    return res;
}   
struct Compare {
    constexpr bool operator()(pi const & a,
                              pi const & b) const noexcept
    { return a.first < b.first || (a.first == b.first && a.second.first > b.second.first); }
 
};
void prefix_function( string s,ll arr[] )
{
     long long border=0; arr[0]=0;
    for(long long i=1;i<s.size();i++)
    {
      while(border>0 && s[i]!=s[border])
        border=arr[border-1];
     
     if(s[i]==s[border])
         border++;
      else
       border=0;
      
      arr[i]=border;
    }
}//send mod-2 for a^-1 if mod is a prime number

ll mod=998244353;
ll add( ll a , ll b)
{
    return (((a%mod)+(b%mod))%mod);
}
ll mul(ll a,ll b)
{
  return (((a%mod)*(b%mod))%mod);
}
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b & 1) res = mul(res, a);
        a = mul(a, a);
        b >>= 1;
    }
    return res;
}
ll subs(ll a,ll b)
{
    return (((a%mod)-(b%mod)+mod)%mod);
}
ll dv(ll a,ll b)
{
    ll inv=binpow(b,mod-2);
    return mul(a,inv);
}

ll dsu_arr[100000];
ll dsu_sz[100000];
void dsu(ll n)
{
    for(ll i=0;i<=n;i++)
    {
        dsu_arr[i]=i;
        dsu_sz[i]=1;
    }
}
ll find(ll x)
{
     ll root=x;
    while (root!=dsu_arr[root])
    {
        root=dsu_arr[root];
    }
    while(x!=dsu_arr[x])
    {
        dsu_arr[x]=root;
        x=dsu_arr[x];
    }
    return root;
}
ll merge(ll x,ll y)
{
    ll root1=find(x);
    ll root2=find(y);
    
    if(root1==root2)
    return 0ll;
 
    if(dsu_sz[x]>dsu_sz[y]){
    dsu_arr[root2]=root1;
    dsu_sz[root1]+=dsu_sz[root2];
    }
    else
    {
         dsu_sz[root2]+=dsu_sz[root1];
        dsu_arr[root1]=root2;
    }
    return 1ll;
}
/*
vector<ll>adj[100005];
bool vis[100005];
ll dist[100005];
void bfs(ll c)
{
  vis[c]=true;
  dist[c]=0;
  q.push(c);
while(!q.empty())
{
    ll x=q.front();
    q.pop();
   
    for(ll i=0;i<adj[x].size();i++)
    {
        ll y=adj[x][i];
        if(!vis[y])
        {
            vis[y]=true;
            dist[y]=dist[x]+1;
            
            q.push(y);
        }
    }
 
}
}
*/

int main()
{
    Fast
 ll n;
 cin>>n;
 ll ans=0;
 for(ll i=1;i<n;i++)
 {
     if(n%i==0)
     {
         ll x=n/i-1;
         ans+=x;

     }
     else
     {
         ll x=n/i;
         ans+=x;
     }
     
 }
 cout<<ans<<endl;

}



   
      
    
        



Measured memory_bytes: 3632
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

n = inp()
x,y = [],[]
for i in range(n):
    a,b = ip()
    x.append(a+b)
    y.append(a-b)
print(max(max(x)-min(x),max(y)-min(y)))


Measured memory_bytes: 92980
#include<stdio.h>
int main(){
   char S[3];
   int i;
   int countA=0;
   int countB=0;
   for(i=0;i<3;i++){
      scanf("%c",&S[i]);
      if(S[i]=='A'){
         countA++;
      }else{
         countB++;
      }
   }
   if(countA==3 ||countB==3){
      printf("No\n");
   }else{
      printf("Yes\n");
   }
   

   return 0;

}


Measured memory_bytes: 1560
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin >> a >> b >>c;
	if(a+b==(a+b+c)/2||a+c==(a+b+c)/2||c+b==(a+b+c)/2){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(const auto& x : c )cout << x << " "; cout << "\n";
#define ol(c, s, e) for(int pos=s; pos<e; pos++)cout << c[pos] << " ";cout <<"\n";
#define PI acos(-1LL)

const int M = 1000000007;
const int N = 2e5 + 5;
const long long INF = 1e9 + 12;

int H, W;
int dp[1001][1001];
char s[1001][1001];
void solve(){
    cin >> H >> W;
    for(int i=1;i<=H; i++){
        for(int j=1; j<=W; j++){
            cin >> s[i][j];
            if(s[i][j]=='#') continue;
            if(i == 1 && j == 1) dp[i][j] = 1;
            else if(i == 1) dp[i][j] = dp[i][j-1];
            else if(j == 1) dp[i][j] = dp[i-1][j];
            else dp[i][j] = (dp[i-1][j] + dp[i][j-1])%M;
        }
    }
    cout << dp[H][W]%M;
}

signed main(){
    FAST
    int tc = 1;
//    TODO: check for tc
//    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        solve();
    }
}


Measured memory_bytes: 12376
#include <cstdio>
#include <cstdlib>

using namespace std;

char s[1000001];
int a[1000000];
int b[1000001];

int main() {
    int n, f1 = 0, c1 = 0, c2 = 0, ans = 0, i;
    
    scanf("%d", &n);
    scanf("%s", s);
    
    for (i = 0; i < n; i++) {
        a[i] = s[i] - '1';
        
        if (a[i] == 1) f1 = 1;
    }
    
    if (f1 == 0) {
        for (i = 0; i < n; i++) a[i] = a[i] / 2;
    } else {
        for (i = 0; i < n; i++) a[i] = a[i] % 2;
    }
    
    for (i = 0; i <= n; i++) {
        int x = i;
        
        while (x > 0 && x % 2 == 0) {
            b[i]++;
            x /= 2;
        }
    }
    
    for (i = 0; i < n; i++) {
        if (a[i] == 1 && c1 == c2) ans++;
        c1 += b[n - i - 1];
        c2 += b[i + 1];
    }
    ans %= 2;
    
    if (f1 == 0) ans *= 2;
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+5;
const ll mod=1e9+7;
ll fastpow(ll a,ll b){
    ll ans=1;
    for(;b;b>>=1,a=a*a%mod) if(b&1) ans=ans*a%mod;
    return ans;
}
ll fac[maxn];
ll C(ll n,ll m){
    return fac[n]*fastpow(fac[n-m],mod-2)%mod*fastpow(fac[m],mod-2)%mod;
}
int main(){
    fac[0]=1;
    for(int i=1;i<maxn;i++) fac[i]=fac[i-1]*i%mod;
    ll n,m,mod=1e9+7,ans=0;cin>>n>>m;
    if(m>1) ans=1;
    for(int i=1;i<=min(m,n-1);i++){
        ans=(ans+C(n,i)*C(n-1,n-i-1)%mod)%mod;
    }
    cout<<ans<<endl;
    return 0;
}

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

const int MAX = 200005;

int main() {
    long long N, a, A[MAX];
    scanf("%lld", &N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &a);
        A[i] = a - i - 1;
    }
    sort(A, A + N);
    long long b = A[N/2];
    long long ans = 0;
    for (int i = 0; i < N; i++) {
        ans += abs(A[i] - b);
    }
    printf("%lld", ans);
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    
    vi a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    vi sma(n+1, 0), smb(n+1, 0);
    rep(i, n) {
        sma[i+1] = sma[i] + a[i];
        smb[i+1] = smb[i] + b[i];
    }
    int ans = 0;
    rep(i, n) {
        chmax(ans, sma[i+1] + (smb[n] - smb[i]));
    }
    cout << ans << endl;
}

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

int main(){
  int n;
  cin>>n;
  int *a;
  a=new int[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n,greater<int>());
  int alice=0,bob=0;
  for(int i=0;i<n;i++){
    if(i%2==0){
      alice+=a[i];
    }else{
      bob+=a[i];
    }
  }
  cout<<(alice-bob);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int n;
    int a[100];
    int even = 0;
    int nyukoku = 0;

    scanf("%d",&n);

    for(int i = 0;i < n;i++){
        scanf("%d",&a[i]);
        if(a[i] % 2 == 0){
            ++even;
            if((a[i] % 3 == 0)||(a[i] % 5 == 0)){
                ++nyukoku;
            }
        }
    }

    if(even == nyukoku){
        printf("APPROVED");
    }else{
        printf("DENIED");
    }

}

Measured memory_bytes: 128
def chmin(a,b)
  (a>b)? b:a
end
def mhd(a,b)
  (a[0]-b[0]).abs+(a[1]-b[1]).abs
end

n,m=gets.split.map(&:to_i)
ab=n.times.map{gets.split.map(&:to_i)}
cd=m.times.map{gets.split.map(&:to_i)}
ab.each_with_index{|p1,i|
  minj=-1
  mind=10**9
  cd.each_with_index{|p2,j|
    tempd=chmin(mhd(p1,p2),mind)
    if mind>tempd
      minj=j
      mind=tempd
    end
    if p1.eql?(p2)
      break
    end
    }
  puts minj+1
  }

Measured memory_bytes: 1788
n = int(input())
A = list(map(int,input().split()))
q = int(input())
M = list(map(int,input().split()))
s = set()
for i in range(2**n):
    tmp = 0
    for j in range(n):
        if i >> j & 1:
            tmp += A[j]
    s.add(tmp)
for i in range(q):
    if M[i] in s:
        print('yes')
    else:
        print('no')
            


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

using namespace std;

int main()
{
    int N, K;

    cin >> N >> K;

    int ans = 0;
    int buf;
    for (int i = 0; i < N; i++)
    {
        cin >> buf;
        if (buf >= K)
        {
            ans ++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

struct ST {
  int i;
  string s;
  int p;
};
bool operator<(const ST& a, const ST& b){
  if(a.s == b.s) return a.p > b.p;
  return a.s < b.s;
}

int main(){
  int N;
  cin >> N;
  vector<ST> v;
  rep(i,N){
    ST st;
    st.i = i+1;
    cin >> st.s >> st.p;
    v.push_back(st);
  }

  sort(ALLOF(v));

  rep(i,v.size()){
    cout << v[i].i << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int a[3], b[3];
	int ans[5] = {0};
	for (int i = 0; i < 3; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = 0; i < 3; i++) {
		ans[a[i]]++;
		ans[b[i]]++;
	}
	for (int i = 1; i < 5; i++) {
		if (ans[i]>=3) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256