akhauriyash/Code-Regression huggingface dataset:
import collections

n = int(input())
arr = list(map(int,input().split()))
cnt = collections.Counter(arr)
total = 0

for key in cnt.keys():
  total += cnt[key] * (cnt[key] - 1)//2
  
for i in range(n):
  tmp = total
  tmp -= cnt[arr[i]]*(cnt[arr[i]] - 1)//2
  tmp += (cnt[arr[i]] - 1)*(cnt[arr[i]] - 2)//2
  print(tmp)


Measured memory_bytes: 34076
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

double dp[110][210];

double f(int vs, int vf, int t, int maxi) {
    double ret = 0.0;
    if(abs(vs-vf) > t) return -INF;
    if(vs > maxi || vf > maxi) return -INF;
    if(vs > vf) swap(vs, vf);
    double x = (vf-vs+t)/2.0;
    double y = t - x;
    double z = max(0.0, double(vs + x - maxi));
    return (double)vs * t + (double)x * x / 2.0 + (double)y * y / 2.0 - z*z + y*(x-y);
}

int main(){
#ifdef LOCAL_TEST
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    rep(i, 110) rep(j, 210) dp[i][j] = -INF;
    int n;
    cin >> n;
    vi t(n), v(n);
    rep(i, n) cin >> t[i];
    rep(i, n) cin >> v[i];
    dp[0][0] = 0;
    rep(i, n) {
        rep(j, v[i]+1) {
            if(dp[i][j] == -INF) continue;
            rep(k, 210) {
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + f(j, k, t[i], v[i]));
            }
        }
    }
    printf("%.15lf\n", dp[n][0]);
    return 0;
}

Measured memory_bytes: 384
a,b = map(int,input().split())

def sum_xor(x):
  if x%2!=0:
    if (x+1)/2%2==0:
      return 0
    else:
      return 1
  else:
    a = 0
    if ((x)//2)%2==0:
      a = 0
    else:
      a = 1
    return a^x

c = sum_xor(b)
d = sum_xor(a-1)
print(c^d)

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



void print(vector<int> v){
	
	for(int i=0;i<v.size();i++){
		cout<<v[i];
	}
	//cout<<endl;
}
int jud(int x){
	
	if(x%2==0)return x/2;
	else return (3*x)+1;
}
double N,T,A,H;
double Ti;
double diffT=1000;
int ans=0;
int m[10000001]={0};
string S;
long long minS=100000000000;
void solve(){
	cin>>N>>T>>A;
	for(int i=1;i<=N;i++){
		
		cin>>H;
		Ti=T-(H*0.006);
		if(abs(A-Ti)<diffT){
			
			diffT=abs(A-Ti);
			ans=i;
		}
		
	}
	cout<<ans<<endl;


}


int main(){

    solve();
    return 0;
}




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

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

  ll N; cin >> N;
  vector<string> S(N);
  for (ll i = 0; i < N; i++) {
    cin >> S[i];
  }

  ll ans = 1;
  sort(S.begin(), S.end());
  string pre = S[0];
  for (ll i = 1; i < N; i++) {
    if (pre != S[i]) {
      ans++;
    }
    pre = S[i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9540
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
using namespace std;
int n,m,ans,f[10005];
int coun(int x,int y,int z)
{
	if (x==y && y==z) return 1;
	if (x==y || y==z) return 3;
	return 6;
}
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	scanf("%d",&n);
	m=sqrt(n);
	for (int i=1;i<=m;i++)
		for (int j=i;j<=m;j++)
			for (int k=j;k<=m;k++)
			{
				int p=i*i+j*j+k*k+i*j+i*k+j*k;
				if (p>n) continue;
				f[p]+=coun(i,j,k);
			}
	for (int i=1;i<=n;i++) printf("%d\n",f[i]);
	return 0;
}

Measured memory_bytes: 3808
#include<stdio.h>
int k[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main() {
    int n;
    scanf("%d", &n);
    printf("%d\n", k[n - 1]);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

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

    vector<vector<int>> S_list(n, vector<int>(26, 0));

    REP(i,n){
        string tmp;
        cin >> tmp;

        for(char c : tmp){
            int index = (int)(c - 'a');
            S_list[i][index]++;
        }
    }

    vector<int> ans(26,0);
    REP(i,26){
        int min_c = S_list[0][i];
        for(int j=0; j<n; j++){
            chmin(min_c, S_list[j][i]);
        }
        ans[i] = min_c;
    }

    string ans_S = "";
    REP(i, 26){
        for(int j=0; j<ans[i]; j++){
            ans_S += 'a' + i;
        }
    }

    cout << ans_S << endl;

    return 0;
}

Measured memory_bytes: 3604
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>

using namespace std;

int main() {
 int n,m,cx,cy;
  cin >> n >> m >> cx >>cy;
  vector<int> x(n);
  vector<int> y(m);
  for(int i=0;i<n;i++){
    cin >> x.at(i);
  }
  for(int i=0;i<m;i++){
    cin >> y.at(i);
  }
  sort(x.begin(), x.end());
  sort(y.begin(),y.end());
  if(x.at(n-1)<y.at(0)&&cx<x.at(n-1)&&cy>y.at(0)){
    cout << "No War" << endl;
  }
  else{
    cout << "War" << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#define max(a,b) (a>b?a:b)
#define reg register
typedef long long ll;
const int p=1e9+7;
const int maxn=5005;
int n,f[maxn][maxn]={1},i,j,len;
ll res;
char ch;
inline ll qpow(ll a,ll b){
	res=1;while(b){if(b&1)res=res*a%p;a=a*a%p;b>>=1;}return res;
}
int main(){
	scanf("%d\n",&n);while((ch=getchar())!='\n')len++;
	for(i=0;i<=n;++i)for(j=0;j<=i;++j){
            f[i+1][j+1]=(f[i+1][j+1]+(f[i][j]<<1)%p)%p;
            f[i+1][max(j-1,0)]=(f[i+1][max(j-1,0)]+f[i][j])%p;
		}
	printf("%d\n",f[n][len]*qpow(qpow(2,len),p-2)%p);
    return 0;
}

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

int main() {
    long N;
    cin >> N;
    
    long y_500, y_5;
    y_500 = N / 500;
    y_5 = (N - (y_500 * 500)) / 5;
    
    
    cout << y_500 * 1000 + y_5 * 5 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <cstring>
#include <string>
#include <cstdlib>
using namespace std;
const int INF=99999999;
#define MAX_V 100*2+2
struct edge{
	int to,cap,cost,rev;
	edge(int to,int cap=0,int cost=0,int rev=-1):
	to(to),cap(cap),cost(cost),rev(rev)
{}
};
int V;
vector<edge> G[MAX_V];
int dist[MAX_V];
int prevv[MAX_V], preve[MAX_V];

//to から dst へ向かう容量 cap,コストcost の辺をグラフに追加する
void add_edge(int from, int to, int cap, int cost){
	G[from].push_back( edge(to,cap,cost,G[to].size()) );
	G[to].push_back( edge(from,0,-cost,G[from].size()-1) );
}
// s から t への流量 f の最小費用流を求める
// 流せない場合は-1を返す
// 流量がdouble の場合は誤差死に注意
int n;
char c[100][100];

int min_cost_flow(int s,int t,int f){
	int res = 0;
	while(f>0){
		fill(dist, dist+V, INF);
		dist[s] = 0;
		bool update = true;
		while(update){
			update = false;
			for(int v=0;v<V;v++){
				if(dist[v] == INF) continue;
				for(int i=0;i<G[v].size(); i++){
					edge &e = G[v][i];
					if(e.cap > 0 && dist[e.to] > dist[v] + e.cost){
						dist[e.to] = dist[v] + e.cost;
						prevv[e.to] = v;
						preve[e.to] = i;
						update = true;
					}
				}
			}
		}
		if(dist[t] == INF) return -1;
		int d=f;
		for(int v=t;v!=s;v=prevv[v]) d=min(d, G[prevv[v]][preve[v]].cap);
		f -= d;
		res += d*dist[t];
		for(int v=t;v!=s;v=prevv[v]){
			edge &e = G[prevv[v]][preve[v]];
			e.cap -= d;
			G[v][e.rev].cap += d;
		//	if(n<=v && v<2*n){
		//		c[prevv[v]][v-n] = 'o';
		//	}
		}
	}
	return res;
}


string Map[100];
int E[100][100];
int W[100][100];
main(){
	int i,j,ans=0;
	cin >> n;
	V = 2*n+2;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			cin >> W[i][j];
			c[i][j] = '.';
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			cin >> E[i][j];
		}
	}
	for(i=0;i<n;i++){
		cin >> Map[i];
	}
	for(i=0;i<n;i++){
		add_edge(2*n, i, 1, 0);
		add_edge(i+n, 2*n+1, 1, 0);
		for(j=0;j<n;j++){
			if(Map[i][j] == 'o'){
				ans += E[i][j];
				add_edge(i, n+j, 1, 1000-E[i][j]);
			}else{
				add_edge(i, n+j, 1, 1000+W[i][j]);
			}
		}
	}
	cout << ans + min_cost_flow(2*n, 2*n+1, n) - 1000*n << endl;

	int cnt = 0;
	for(i=0;i<n;i++){
		for(j=0;j<G[i].size();j++){
			int to = G[i][j].to;
			if(G[i][j].cap || 2*n<=to) continue;
			c[i][to-n] = 'o';
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(Map[i][j] != c[i][j]) cnt++;
		}
	}
	cout << cnt << endl;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(c[i][j] != Map[i][j]){
				if(Map[i][j] == 'o') cout << i+1 << " " << j+1 << " erase" << endl;
				else cout << i+1 << " " << j+1 << " write" << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1740
#include<iostream>
using namespace std;
#include<algorithm>
#include<cstring>
#include<string>
#include<stdio.h>
#include<map>
#include<vector>
#include<cmath>
#include<iomanip>
#include<queue>
#include<stack>
#include<set>
#define maxn 1000005
#define INF 1e9
#define ll long long
ll a, b;
int main()
{
	cin >> a >> b;
	if (a == 0 || b == 0)cout << "Zero" << endl;
	else if (a > 0)cout << "Positive" << endl;
	else if (b < 0) {
		int x = b - a + 1;
		if (x % 2)cout << "Negative" << endl;
		else cout << "Positive" << endl;
	}
	else cout << "Zero" << endl;
	return 0;
}

Measured memory_bytes: 3020
#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> a;
	rep(i,n){
		int aa;
		cin >> aa;
		a.push_back(aa);
	}
	
	vector<int> sort_a = a;
	sort(sort_a.begin(), sort_a.end());
	
	int cnt = 0;
	rep(i,n){
		if(a[i] != sort_a[i]) cnt++;
	}

	if(cnt>2) cout << "NO" << endl;
	else cout << "YES" << endl;
	return 0;
}

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

int a[605][605],d1,d2,n;

void color(int d,int size){
	while (d%4==0){ d/=4; size++; }
	if (d&1){
		for (int i=0;i<2*n;i++)
			for (int j=0;j<2*n;j++)
				if ((i>>size)+(j>>size)&1)
					a[i][j]=1;
	}
	else{
		for (int i=0;i<2*n;i++)
			for (int j=0;j<2*n;j++)
				if ((i>>size)&1)
					a[i][j]=1;
	}
}

int main(){
	scanf("%d%d%d",&n,&d1,&d2);
	color(d1,0); color(d2,0);
	int k=0;
	for (int i=0;i<2*n;i++)
		for (int j=0;j<2*n;j++)
			if (k<n*n&&!a[i][j]){ printf("%d %d\n",i,j); k++; }
			else if (k==n*n) break;
	return 0;
}

Measured memory_bytes: 2304
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define IOS std::cin.tie(0),std::ios::sync_with_stdio(false)

namespace idaten {

	using namespace std;
	using ll = int_fast64_t;
	using ull = uint_fast64_t;
	using P = std::pair<int64_t, int64_t>;
	template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
	template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
	template<class Type>struct is_vector : std::false_type {};
	template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
	template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
		if (v.empty())return out;
		constexpr bool is_vector_v = is_vector<T>::value;
		if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
		else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
		return out;
	}
	inline void put() {}
	template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
	template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
	inline void putn() {}
	template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

	void solve() {
		IOS;
		int n,m;
		cin >> m >> n;
		vector<int> v(n), w(n);
		REP(i, n) {
			cin >> w[i];
		}
		vector<vector<int>> dp(n + 1, vector<int>(m + 1, INT_MAX / 2));
		dp[0][0] = 0;
		REP(i, n) {
			REP(j, m+1) {
				dp[i + 1][j] = dp[i][j];
				if (j - w[i] >= 0) {
					chmin(dp[i + 1][j], dp[i + 1][j - w[i]] + 1);
				}
			}
		}
		put(dp[n][m]);
	}
} // namespace idaten

int main() {
	idaten::solve();
	return 0;
}



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

const int M = 100000;

int main() {
  int n;
  while (cin >> n, n) {
    auto p = vector<int>(n);
    for (int i = 0; i < n; ++i) cin >> p[i];

    auto dp1 = vector<vector<int>>(n + 1, vector<int>(M, -1));
    auto dp2 = vector<vector<int>>(n + 1, vector<int>(M, 100 * 5000));
    dp1[0][0] = dp2[0][0] = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < M; ++j) {
        dp1[i + 1][j] = dp1[i][j];
        dp2[i + 1][j] = dp2[i][j];
      }
      int change = (1000 - p[i] % 1000) % 1000;
      for (int cur = 0; cur < M; ++cur) {
        if (dp1[i][cur] == -1) continue;
        int canGet = (cur + change >= 500);
        int nxt = cur + change - 500 * canGet;
        if (dp1[i + 1][nxt] < dp1[i][cur] + canGet) {
          dp1[i + 1][nxt] = dp1[i][cur] + canGet;
          dp2[i + 1][nxt] = dp2[i][cur] + p[i];
        } else if (dp1[i + 1][nxt] == dp1[i][cur] + canGet) {
          dp2[i + 1][nxt] = min(dp2[i + 1][nxt], dp2[i][cur] + p[i]);
        }
      }
    }
    int ans1 = -1, ans2 = 100 * 5000;
    for (int j = 0; j < M; ++j) ans1 = max(ans1, dp1[n][j]);
    for (int j = 0; j < M; ++j) if (dp1[n][j] == ans1) ans2 = min(ans2, dp2[n][j]);
    cout << ans1 << ' ' << ans2 << endl;
  }
  return 0;
}



Measured memory_bytes: 82160
#include <cstdio>
#define ri register int
namespace io {
    const int SIZE = (1 << 21) + 1;
    char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
    // getchar
    #define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
    // print the remaining part
    inline void flush () {
        fwrite (obuf, 1, oS - obuf, stdout);
        oS = obuf;
    }
    // putchar
    inline void putc (register char x) {
        *oS ++ = x;
        if (oS == oT) flush ();
    }
    // input a signed integer
    template <class I>
    inline void gi (I &x) {
        for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
        for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;
    }
    // print a signed integer
    template <class I>
    inline void print (I x) {
        if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
        while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
        while (qr) putc (qu[qr --]);
    }
    //no need to call flush at the end manually!
    struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: gi;
using io :: putc;
using io :: print;
const int N=205;
int a[N],b[N],pos[N],ta,tb,tot,head[N],nxt[N*N],adj[N*N],link[N],vis[N];
inline void addedge(ri x,ri y){
	nxt[++tot]=head[x];
	adj[head[x]=tot]=y;
}
inline void push(ri x){
	if(x&1)
		a[++ta]=x;
	else
		b[++tb]=x;
}
inline bool prime(ri n){ // n是否为级质数 
	if(n<=2) return false;
	for(ri i=2;i*i<=n;++i)
		if(n%i==0) return false;
	return true;
}
inline int abs(ri x){
	return x>0 ? x:-x;
}
inline int dfs(ri x){
	for(ri y,i=head[x];i;i=nxt[i])
		if(!vis[y=adj[i]]){
			vis[y]=1;
			if(!link[y]||dfs(link[y])){
				link[y]=x;
				return 1;
			}
		}
	return false;
}
int main(){
	ri n,i,j,x,last,ans;
	gi(n);
	for(i=1;i<=n;++i){
		gi(x);
		if(i==1) push(x);
		else if(last+1!=x) push(last+1),push(x); 
		last=x;
	}
	push(last+1);
//	printf("ta=%d\n",ta);
//	for(i=1;i<=ta;++i) printf("%d ",a[i]); puts("");
//	printf("tb=%d\n",tb);
//	for(i=1;i<=tb;++i) printf("%d ",b[i]); puts("");
	// ta + tb 为偶数 
	for(i=1;i<=ta;++i)
		for(j=1;j<=tb;++j)
			if(prime(abs(a[i]-b[j])))
				addedge(i,j);
	ans=0;
	for(i=1;i<=ta;++i){
		for(j=1;j<=tb;++j) vis[j]=0;
		ans+=dfs(i);
	}
	ans+=(ta-ans)/2*2+(tb-ans)/2*2+(ta-ans)%2*3;
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 2304
#include<iostream>
using namespace std;
#define lli long long 
int main(){
  lli n,u,sum=0;
  cin>>n;
  lli z=n;
  while(n>0){
    u=n%10;
    n/=10;
    sum++;
  }
  lli k=0;
  for(lli i=0;i<sum;i++){
    k=k*10+u;
  }
  if(k<z){
    for(lli i=0;i<sum;i++)
      cout<<u+1;
  }
  else{
    for(lli i=0;i<sum;i++)
      cout<<u;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int N,Q;
string s;
char t[200020],d[200020];

bool judge(int mid,int x){
  int now=mid-1;
  for(int i=0;i<Q;i++){
    if(s[now]==t[i]){
      if(d[i]=='L') now=now-1;
      else now=now+1;
    }
    if(now==x) return true;
    else if(x==N&&now==-1) return false;
    else if(x==-1&&now==N) return false;
  }
  return false;
}

int main(){
  cin>>N>>Q;
  cin>>s;
  for(int i=0;i<Q;i++){
    cin>>t[i]>>d[i];
  }

  int ok=0,ng=N+1;
  while(ng-ok>1){
    int mid=(ok+ng)/2;
    if(judge(mid,-1)) ok=mid;
    else ng=mid;
  }
  int ans=ok;

  ok=N+1;
  ng=0;
  while(ok-ng>1){
    int mid=(ok+ng)/2;
    if(judge(mid,N)) ok=mid;
    else ng=mid;
  }

  cout<<N-min(ans+N-ok+1,N)<<endl;

  return 0;
}


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

ll a[100001] = {};
ll b[100001] = {};
int main() {
	ll n, h; cin >> n >> h;
	ll maxA = 0;
	rep(i, 0, n) {
		cin >> a[i] >> b[i];
		maxA = max(maxA, a[i]);
	}

	sort(b, b + n);
	reverse(b, b + n);

	ll ans = 0;
	rep(i, 0, n) {
		if (b[i] >= maxA) {
			h -= b[i];
			ans++;
			if (h <= 0) {
				cout << ans << endl;
				return 0;
			}
		}
		else {
			break;
		}
	}

	ans += h / maxA + ((h % maxA == 0) ? 0 : 1);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#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(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#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 show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
inline ll lin() { ll x; scanf("%lld",&x); return x;}
inline char chin() { char x; scanf("%c",&x); return x;}
inline string stin() { string x; cin >> x; return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }
char itoa(int n) { return n + '0';}
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 () {
  int n = in();
  int taro = 0, hanako = 0;
  rep(i,n) {
    string s, t;
    cin >> s >> t;
    if (s > t) taro += 3;
    else if (s < t) hanako += 3;
    else {
      taro += 1;
      hanako += 1;
    }
  }
  printf("%d %d\n", taro, hanako);
  return 0;
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;

  int ret = 0, add = 0;
  for(int i = 1; i < N; i++) {
    if(S[i - 1] != S[i]) ++add;
    else ++ret;
  }
  while(add > 0 && K > 0) {
    int v = min(2, add);
    add -= v;
    ret += v;
    K--;
  }
  cout << ret << endl;
}






Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T, vec<T>, greater<T>>;
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
const i64 MOD = 1000000007;

i32 n;
i64 x[100000];

i32 main()
{
    cin >> n;
    times(n, i) {
        cin >> x[i];
    }
    i64 ans = 1; i32 p = 1; i32 cnt = 0;
    times(n, _) {
        upto(p, n, i) {
            if (x[i-1] >= 2*(i-cnt)-1) {
                p = i;
            } else {
                p++;
                break;
            }
        }
        ans = (ans * (p - cnt)) % MOD;
        cnt++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
  
using namespace std;
  
int main(){
 int a[3],i;
 for (i=0;i<3;i++) {
  cin >> a[i];
 }
 sort(a, a+3);
 cout << a[0] << " " <<a[1] << " "<<a[2] << endl;
 return 0;
}


Measured memory_bytes: 3156
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<long long> vll, vLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    if(n==1) cout << "Hello World\n";
    else{
        int a,b;
        cin >> a >> b;
        cout << a+b << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#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;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

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

using namespace::std;

int N, A[100000], B[100000],ans,Ex;

void m_sort(int a[], int tmp[], int left, int right);
void m_sort(int a[], int tmp[], int left, int right);
void sort(int a[], int total) {
	int tmp;
	for (int i = 0; i < total; i++) {
		for (int j = i + 1; j < total; j++) {
			if (a[i] < a[j]) {
				tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}

}

void mergeSort(int a[], int tmp[], int size)
{
	m_sort(a, tmp, 0, size - 1);
}
void merge(int a[], int tmp[], int left, int mid, int right)
{
	int i, left_end, num_elements, tmp_pos;

	left_end = mid - 1;
	tmp_pos = left;
	num_elements = right - left + 1; // 要素 

	while ((left <= left_end) && (mid <= right))
	{
		if (a[left] <= a[mid])
		{
			tmp[tmp_pos] = a[left];
			tmp_pos = tmp_pos + 1;
			left = left + 1;
		}
		else
		{
			tmp[tmp_pos] = a[mid];
			tmp_pos = tmp_pos + 1;
			mid = mid + 1;
		}
	}


	while (left <= left_end)
	{
		tmp[tmp_pos] = a[left];
		left = left + 1;
		tmp_pos = tmp_pos + 1;
	}

	while (mid <= right)
	{
		tmp[tmp_pos] = a[mid];
		mid = mid + 1;
		tmp_pos = tmp_pos + 1;
	}


	for (i = 0; i <= num_elements; i++)
	{
		a[right] = tmp[right];
		right = right - 1;
	}
}
void m_sort(int a[], int tmp[], int left, int right)
{
	int mid;

	if (right > left)
	{
		mid = (right + left) / 2;
		m_sort(a, tmp, left, mid);
		m_sort(a, tmp, mid + 1, right);

		merge(a, tmp, left, mid + 1, right);
	}
}



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

	mergeSort(A, B, N);
	Ex = 0;
	for (int i = 0; i < N; i++) {
		if (A[i] != Ex) {
			ans++;
			Ex = A[i];
		}
		else {
			ans--;
			Ex = 0;
		}

	}
	cout << ans << endl;

	return 0;
		}


	


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
     
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007  
#define mod2 998244353 
#define pi 3.14159265358979323846

int solve(){
    int n,m,t=0,w=0,b;
    string s;
    cin>>n>>m;
    int a[n]={0};
    rep(i,0,m){
        cin>>b>>s;
        if(s=="WA"&&a[b-1]>=0) a[b-1]++;
        if(s=="AC"&&a[b-1]>=0) {t++;w=w+a[b-1];a[b-1]=-1;}

    }
    cout<<t<<" "<<w;

    return 0;
}   
     
signed main(){      
    IOS;
    int t=1;
    //cin>>t;   
    while(t--){
        solve();
        //if(solve()) cout<<"YES";
        //else cout<<"NO";
        cout<<"\n";
    }
    return 0;
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

ll dp[100], dp2[100];

// |B|l-1|P|l-1|B|
ll dnc(int n, ll x)
{
    if (n == 0)
        return 1;
    if (x == 0)
        return 0;
    if (x == dp2[n] / 2)
        return 1 + dp[n - 1];
    if (x < dp2[n] / 2)
        return dnc(n - 1, x - 1);
    return dp[n - 1] + 1 + dnc(n - 1, x - dp2[n - 1] - 2);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    ll x;
    cin >> n >> x;
    dp[0] = 1;
    dp2[0] = 1;
    for (int i = 1; i <= n; ++i)
    {
        dp[i] = 2 * dp[i - 1] + 1;
        dp2[i] = 2 * dp2[i - 1] + 3;
    }
    cout << dnc(n, x - 1);
}


Measured memory_bytes: 256
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
#include<iostream>
#include<bits/stdc++.h>
#include<cstdio>
#include<string.h>
#include<map>
#include<cmath>
#include<stack>
#include<algorithm>
#include<assert.h>
using namespace std;
#define endl '\n'
#define pb push_back
//#define int long long
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define mem0(s) memset(s,0,sizeof(s))
#define meminf(s) memset(s,0x3f,sizeof(s))
#define mp_insert(a,b,c) mp.insert(map<pair<int,int>,int>::value_type(make_pair(a,b),c))
double pi=acos(-1);
typedef long long ll;
typedef unsigned long long ull;
inline ll lowbit(ll x){return x&(-x);}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll max(ll a,ll b){return a>b?a:b;}
const double Rad_to_deg=45.0/atan(1.0);
inline ll floor(const ll&a,const ll&b){return a/b;}
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
const ll INF=4223372036854775807,max_n=100010,mod=998244353;
inline int cal(int x){int res=0;while(x){x/=10;res++;}return res;}
inline ll ceil(const ll&a,const ll&b){if(a%b==0)return a/b;return a/b+1;};
inline ll pow(ll a,ll b,ll mod){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline int mul(int a,int b){return (ll)a*b%mod;}
int n,k;
char s[max_n];
ll ans;
int main()
{
	cin>>n>>k;
	scanf("%s",s+1);
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='L'&&s[i-1]=='L'&&i-1>=1)
		{
			ans++;
		}
		else if(s[i]=='R'&&s[i+1]=='R'&&i+1<=n)
		{
			ans++;
		}
	}
	cout<<min(ans+2*k,n-1);
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main(){
  ll n , a , b;
  cin >> n >> a >> b;
  ll c = n/(a+b);
  ll d = n%(a+b);
  ll sum;
  if (d >= a){
   sum = c*a + a;
  }
  else{
   sum = c*a + d;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
#define PB push_back
#define MP make_pair
#define st first
#define nd second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<long long>;
using ld = long double;

#define unordered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using unordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif


int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);

  int n;
  cin >> n;

  vi a(n), b(n);
  for (int &x : a) { cin >> x; }
  for (int &x : b) { cin >> x; }

  multiset<pii> b_set;
  for (int i = 0; i < n; ++i) {
    if (b[i] > a[i]) {
      b_set.emplace(b[i], i);
    }
  }

  ll num_ops = 0;
  while (!b_set.empty()) {
    int val, loc;
    tie(val, loc) = *b_set.rbegin();
    debug(val, loc, a, b);
    b_set.erase(prev(b_set.end()));
    assert(val > a[loc]);

    const ll x = b[(loc+n-1)%n];
    const ll y = b[(loc+1)%n];
    const ll diff = x + y;
    if (diff > b[loc] - a[loc]) {
      cout << "-1\n"; return 0;
    }
    
    const int bound = max<ll>({a[loc], x - diff, y - diff});
    const int max_steps = (b[loc] - bound) / diff;
    num_ops += max_steps;
    b[loc] -= max_steps * diff;
    if (b[loc] > a[loc]) {
      b_set.emplace(b[loc], loc);
    }
  }

  for (int i = 0; i < n; ++i) {
    if (a[i] != b[i]) {
      cout << "-1\n"; return 0;
    }
  }

  cout << num_ops << "\n";
}



Measured memory_bytes: 11264
def main():
    N = int(input())
    A = [int(v) for v in input().split()]
    C = [0] * (N + 1)

    for i in A:
        C[i] += 1

    b = 0
    
    for cnt in C:
        b += ((cnt * (cnt - 1)) // 2)

    for i in range(N):
        p = ((C[A[i]] - 1) * (C[A[i]] - 2)) >> 1
        m = (C[A[i]] * (C[A[i]] - 1)) >> 1
        print(b - m + p)


if __name__ == '__main__':
    main()

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

int main(){
  while(true){
    string s1;
    cin >> s1;
    if(s1==".")break;

    string s2;
    cin >> s2;
    if(s1==s2){
      cout << "IDENTICAL" << endl;
      continue;
    }

    string t1=s1;
    string t2=s2;

    while(true){
      size_t d1b = t1.find('\"');
      if(d1b==string::npos)break;
      t1.replace(d1b,1,"@");

      size_t d1e = t1.find('\"');
      t1.replace(d1e,1,"@");

      size_t d2b = t2.find('\"');
      if(d2b==string::npos)break;
      t2.replace(d2b,1,"@");

      size_t d2e = t2.find('\"');
      t2.replace(d2e,1,"@");

      string u1 = s1;
      u1.replace(d1b+1,d1e-d1b-1,"");
      string u2 = s2;
      u2.replace(d2b+1,d2e-d2b-1,"");

      if(u1==u2){
        t1=u1;
        t2=u2;
        break;
      }
    }

    if(t1==t2){
      cout << "CLOSE" << endl;
    }else{
      cout << "DIFFERENT" << endl;
    }
  }

  return 0;
}


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

#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")

#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()
#define MP make_pair

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn=2e3+10, maxm=5e4+10, lg=21, mod=1e9+7, inf=1e18;

string s,t;
ll n,L[3*maxn],R[3*maxn];

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	
	memset(L,69,sizeof(L)),memset(R,69,sizeof(R));
	cin>>s>>t; n=SZ(s);
	t=t+t+t;
	for(int i=0;i<3*n;i++) L[i]=(t[i]=='1' ? 0:L[i-1]+1);
	for(int i=3*n-1;i>=0;i--) R[i]=(t[i]=='1' ? 0:R[i+1]+1);
	if(R[0]>=inf){
		for(int i=0;i<n;i++)if(s[i]=='1') return cout<<-1,0;
		return cout<<0,0;
	}
	ll ans=inf;
	for(int d=-n;d<=n;d++){
		vector<pll> bb;
		ll ek=0; for(int i=n;i<2*n;i++)if(s[i-n]!=t[i+d]) bb.pb({max(L[i]+min(d,0),0ll),max(R[i]-max(d,0),0ll)}), ek++;
		sort(all(bb));
		ll mx=0; for(int i=SZ(bb)-1;i>=0;i--){
			ans=min(ans,ek+2*(bb[i].F+mx)+abs(d));
			mx=max(mx,bb[i].S);
		}
		ans=min(ans,ek+2*mx+abs(d));
	}
	cout<<ans;
	
	return 0;
}



 


Measured memory_bytes: 3800
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに実装したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			System.out.println(IntStream.range(1, n).mapToLong(i -> (n - 1) / i).sum());
		}
	}
}


Measured memory_bytes: 36676
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  vector<ll>vec(a);
  ll b;
  cin>>b;
  ll c=0;
  for(ll i=0;i<a;i++){
    vec.at(i)=i+b;
    c+=vec.at(i);
  }
  ll d=abs(vec.at(0));
  ll e=0;
  for(ll i=0;i<a;i++){
    d=min(d,abs(vec.at(i)));
    if(d==abs(vec.at(i))){
      e=i;
    }
  }
  cout<<c-vec.at(e)<<endl;
    
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include<vector>
#include<map>
#include<cmath>
#include<iomanip>
#define ll long long
using namespace std;
#define rep(n) for(int i=0;i<n;i++)
#define rep2(a,n) for(int i=a;i<=n;i++)
int main(void){
    // Your code here!
int n,k,q;
cin>>n>>k>>q;
map<int,int> mp;
rep(q){
    int a;
    cin>>a;
    mp[a]++;
}

rep2(1,n){
    if((k-(q-mp[i]))>0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

}


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

void solve(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // int t;
    // cin>>t;
    // while(t--){
    //     solve();
    // }
    float d,t,s;
    cin>>d>>t>>s;
    if(d/s<=t){
        cout<<"Yes\n";
    }
    else
        cout<<"No\n";
    return 0;
}

Measured memory_bytes: 3736
import sys
import math
if sys.version_info.minor >= 5:
    from math import gcd
else:
    from fractions import gcd


def miller_rabin(n):
    """ primality Test
        if n < 3,825,123,056,546,413,051, it is enough to test
        a = 2, 3, 5, 7, 11, 13, 17, 19, and 23.
        Complexity: O(log^3 n)
    """
    assert(n >= 1)
    if n == 2:
        return True
    if n <= 1 or not n & 1:
        return False

    primes = [2, 3, 5, 7, 11, 13, 17, 19, 23]

    d = n - 1
    s = 0
    while not d & 1:
        d >>= 1
        s += 1

    for prime in primes:
        if prime >= n:
            continue
        x = pow(prime, d, n)
        if x == 1:
            continue
        for r in range(s):
            if x == n - 1:
                break
            if r + 1 == s:
                return False
            x = x * x % n
    return True


A, B = map(int, input().split())
ab_gcd = gcd(A, B)

divisors = []
for i in range(1, int(pow(ab_gcd, 0.5) + 1e-6) + 1):
    if ab_gcd % i == 0:
        divisors.append(i)
        divisors.append(ab_gcd // i)

print(sum(miller_rabin(x) for x in divisors) + 1)


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

const int mod = 1000000007;

int main(){
    int n, w;
    cin >> n >> w;
    vector<int> v(n);
    for(int i = 0; i < n; i++)  cin >> v[i];
    sort(v.rbegin(), v.rend());
    vector<vector<int>> dp(n+1, vector<int>(w+1, 0));
    dp[0][0] = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= w; j++){
            dp[i+1][j] = dp[i][j];
            if(j >= v[i]){
                dp[i+1][j] += dp[i][j-v[i]];
                dp[i+1][j] %= mod;
            }
        }
    }
    int ans = 0, weight = 0;
    if(accumulate(v.begin(), v.end(), 0) <= w)  ans++;
    for(int i = n-1; i >= 0; i--){
        // v[i] を使わず、 v[i+1] ... v[n-1]を全部使う.その和はweight
        if(weight > w)  continue;
        for(int j = max(0, w-weight-v[i]+1); j <= w-weight; j++)    ans += dp[i][j], ans %= mod;
        weight += v[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10704
function main(input:string) {
  const i = input.split(" ");
  const a = parseInt(i[0], 10);
  const b = parseInt(i[1], 10);
  const c = parseInt(i[2], 10);
  let result = "NO";
 
  for (let i = 1; i <= 100; i++){
    if ((i*a) % b === c) {
      result = "YES";
      break;
    }
  }
  console.log(result);
 
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29580
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
using namespace std;
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;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main() {
    int k,x;
    cin >> k >> x;
    if (500*k >= x) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
	string Class[] = {"light fly", "fly", "bantam", "feather", "light", "light welter", "welter", "light middle", "middle", "light heavy", "heavy"};
	double Classnum[] = {0.00, 48.00, 51.00, 54.00, 57.00, 60.00, 64.00, 69.00, 75.00, 81.00, 91.00, 20000.00};
	const int NUM = 11;

	double n = 0.0;
	while(cin >> n){
		if(cin.eof()) break;
		for(int i = 1; i < NUM + 1; i++){
			if(Classnum[i] >= n){
				cout << Class[i - 1] << endl;
				break;
			}
		}
	}


	return 0;
}

Measured memory_bytes: 1228
K = int(input())

from collections import defaultdict

num = 0

dp = [[] for i in range(10)]

for i in range(1, 10):
    dp[0].append(i)

for k in range(9):
    for j in range(len(dp[k])):
        s = str(dp[k][j])
        n = int(s[-1])
        if 0 < n:
            dp[k + 1].append(int(s + str(n - 1)))
        dp[k + 1].append(int(s + str(n)))
        if n < 9:
            dp[k + 1].append(int(s + str(n + 1)))

for i in range(10):
    dp[i].sort()
    for j in range(len(dp[i])):
        num += 1
        if num == K:
            print(dp[i][j])

Measured memory_bytes: 11372
//compiledef
#include <bits/stdc++.h>
#define rep(i, n) for(i=0;i<(n);i++)
#define per(i, n) for(i=(n);i>0;i--)
#define repx(i, n, x) for(i=(x);i<(n);i++)
#define xper(i, n, x) for(i=(n);i>(x);i--)
#define pback push_back

//c++def
using namespace std;
typedef long long int ll;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
typedef struct{
	int parent;
	int left;
	int right;
	int depth;
}node;
const int DROOT = -1;
node u[100007];
int check(int nd, int dp){
	u[nd].depth = dp;
	if(u[nd].right != DROOT){
		check(u[nd].right, dp);
	}
	if(u[nd].left != DROOT){
		check(u[nd].left, dp+1);
	}
}
void print_leaf(int nd){
	int i, leaf;
	cout << "node " << nd << ": ";
	cout << "parent = " << u[nd].parent << ", ";
	cout << "depth = " << u[nd].depth << ", ";
	if(u[nd].parent == DROOT) cout << "root, ";
	else if(u[nd].left == DROOT) cout << "leaf, ";
	else cout << "internal node, ";
	cout <<"[";
	for(i=0, leaf = u[nd].left; leaf != DROOT; i=1, leaf = u[leaf].right){
		if(i!=0) cout << ", ";
		cout << leaf;
	}
	cout << "]" << endl;
}
int main(){
	int n, i, j, v, k, leaf, l, root;
	cin >> n;
	rep(i, n) u[i].parent = u[i].left = u[i].right = DROOT;

	rep(i, n){
		cin >> v >> k;
		rep(j, k){
			cin >> leaf;
			if(j == 0) u[v].left = leaf;
			else u[l].right = leaf;
			l = leaf;
			u[leaf].parent = v; 
		}
	}
	rep(i, n) if(u[i].parent == DROOT) root = i;
	check(root, 0);
	rep(i, n) print_leaf(i);
}



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

typedef long long ll;
int n,k;
ll ans;

inline ll f(int x){
	return (ll)x*x*x;
}

int main(){
	cin>>n>>k;
	if(k&1)
		ans=f(n/k);
	else
		ans=f((n+k/2)/k)+f(n/k);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
long long dp[100100];
bool ok[100100];
int x;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		ok[i]=true;
	for(int i=1;i<=m;i++){
		cin>>x;
		ok[x]=false;
	}
	dp[0]=1;
	for(int i=1;i<=n;i++){
		if(ok[i]){
			dp[i]+=dp[i-1];
			dp[i]%=1000000007LL;
			if(i>=2)
				dp[i]+=dp[i-2];
			dp[i]%=1000000007LL;
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}


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

using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> A(n);
    copy_n(istream_iterator<int>(cin), n, A.begin());

    vector<int> S;
    S.push_back(0);

    for (int i = 0; i < n; i++)
        S.push_back((S[i] + A[i] - 1) % k);

    map<int, int> cnt;
    int64_t ans = 0;

    for (int i = 0; i < k and i < n + 1; i++){
        ans += cnt[S[i]];
        cnt[S[i]]++;
    }

    for (int i = k; i < n + 1; i++){
        cnt[S[i - k]]--;
        ans += cnt[S[i]];
        cnt[S[i]]++;
    }

    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef double db;

#define dbg(x) cout<<#x<<" is "<<x<<endl

const int maxn = 1e6;

char str[maxn];

int main() {
    int n;
    scanf("%d%s", &n, str);
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (str[i] == 'R') {
            cnt++;
        }
    }
    int tmp = cnt;
    for (int i = 0; i < cnt; i++) {
        if (str[i] == 'R') {
            tmp--;
        }
    }
    printf("%d\n", tmp);
    return 0;
}

Measured memory_bytes: 4004
#include<stdio.h>
int main(void)
{
    unsigned char stage[120][120] = {{0}};
    int check[200][200] = {{0}};
    int i,j;
    int w,h;
    int a=0,b=0;

for(;;){
    scanf("%d%d",&h,&w);
    if(h == 0 && w == 0)break;
    for(i = 0;i < h; i++)scanf("%s",stage[i]);

    for(i = 0;i < h; i++){
        for(j = 0;j < w; j++){
            if(stage[i][j] == '>')check[i][j] = 6;
            if(stage[i][j] == '<')check[i][j] = 4;
            if(stage[i][j] == 'v')check[i][j] = 2;
            if(stage[i][j] == '^')check[i][j] = 8;
            if(stage[i][j] == '.')check[i][j] = 5;
        }
    }

    for(;;){
        if(check[a][b] == 6){
            check[a][b] = 1;
            b++;
        }
        if(check[a][b] == 4){
            check[a][b] = 1;
            b--;
        }
        if(check[a][b] == 8){
            check[a][b] = 1;
            a--;
        }
        if(check[a][b] == 2){
            check[a][b] = 1;
            a++;
        }
        if(check[a][b] == 5){
            printf("%d %d\n",b,a);
            break;
        }
        if(check[a][b] == 1){
            printf("LOOP\n");
            break;
        }
    }
    for(i = 0;i < h; i++)for(j = 0;j < w; j++){
        stage[i][j] = 0;
        check[i][j] = 0;
    }
    a = 0;b = 0;
}
    return 0;
}

Measured memory_bytes: 792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl

int main(){
    int x;
    cin >> x;
    ll n = 2;
    rep(i, x) n = n+n+1+1;
    cout << n << endl;
}


Measured memory_bytes: 256