akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

#define MAX 1000000

int main(){
	char prime[MAX];
	int num, i, j, ans;

	for(i = 0; i < MAX; i++)
	{
		prime[i] = 1;
	}
	prime[0] = prime[1] = 0;
	for(i = 2; i < (MAX/2); i++)
	{
		if(prime[i])
		{
			for(j = 2*i; j < MAX; j += i)
			{
				prime[j] = 0;
			}
		}
	}
	
	while(scanf("%d", &num) != EOF)
	{
		ans = 0;
		
		for(i = 2; i <= num; i++)
		{
			ans += prime[i];
		}
		
		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 1572
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)
int main(){
    int H,W;
    int a[500][500];
    cin>>H>>W;
    rep(i,H) rep(j,W) cin>>a[i][j];
    int n=0;
    string ans="";
    rep(i,H-1){
        rep(j,W){
            if(a[i][j]%2==0) continue;
            a[i+1][j]++;
            ans+=to_string(i+1)+" "+to_string(j+1)+" "+to_string(i+2)+" "+to_string(j+1)+"\n";
            n++;
        }
    }
    rep(j,W-1){
        if(a[H-1][j]%2==0) continue;
        a[H-1][j+1]++;
        ans+=to_string(H)+" "+to_string(j+1)+" "+to_string(H)+" "+to_string(j+2)+"\n";
        n++;
    }
    cout<<n<<endl;
    cout<<ans;

    return 0;
}

Measured memory_bytes: 4996
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef vector<vector<P>> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<ll> vec;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    string s;
    cin>>s;
    int w;
    cin>>w;
    int n=s.size();
    rep(i,n){
        cout<<s[i];
        i+=w;
        i--;
    }
    cout<<endl;
    
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var err error
var inputReader *bufio.Reader

func main(){
	inputReader = bufio.NewReader(os.Stdin)
	var input string
	A := make([]int, 1000,1000000)
	input, err = inputReader.ReadString('\n')
	input = strings.Replace(input, "\n", "",-1)
	//fmt.Printf("%s\n",input)
	var data =strings.Split(input," ")
	//fmt.Println(len(data))
	i:=0
	for j:=0;j<len(data) ;j++{
		/*input, err = inputReader.ReadString(' ')
		fmt.Printf("%s\n",input)
		input = strings.Replace(input, " ", "",-1)*/
		//func Split(s, sep string) []string
		//fmt.Printf("%s\n",data[j])
		if data[j] == "+" {
			A[i]=A[i-2]+A[i-1]
			i=i-2
			A[i]=A[i+2]
			i++
		}else if data[j] == "-"{
			A[i]=A[i-2]-A[i-1]
			i=i-2
			A[i]=A[i+2]
			i++
		}else if data[j] == "*"{
			A[i]=A[i-2]*A[i-1]
			i=i-2
			A[i]=A[i+2]
			i++
		}else {
			//buf := bytes.NewBuffer(data[j]) // b is []byte
			//myfirstint, err := binary.ReadVarint(buf)
			A[i], err = strconv.Atoi(data[j])
			//fmt.Printf("%d\n",A[i])
			i++
		}
		//fmt.Println(i)
	}
	fmt.Printf("%d\n",A[0])

}


Measured memory_bytes: 1656
#include <iostream>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <algorithm>
using namespace std;

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

    for (int i = X; ; ++i) {
        for (int j = 2; j < i; ++j) {
            if (i % j == 0) goto LOOP_I;
        }

        cout << i << endl;
        return 0;

        LOOP_I:;
    }

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using ull=unsigned long long int;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
map<char,int> ind;
int main(){
  V<char> d(52);
  for(char c='a';c<='z';c++){
    ind[c]=(int)c-'a';
    d[ind[c]]=c;
  }
  int p=26;
  for(char c='A';c<='Z';c++){
    ind[c]=p++;
    d[ind[c]]=c;
  }
  while(1){
    int  n;
    cin>>n;
    if(n==0)return 0;
    V<int> k(n);
    for(int i=0;i<n;i++)cin>>k[i];
    string s;
    cin>>s;
    int m=s.size();
    int id;
    for(int i=0;i<m;i++){
      id=ind[s[i]];
      cout<<d[(id+52-k[i%n])%52];
    }
    cout<<"\n";
  }
}


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

int main(){
  int N,W;
  cin>>N>>W;
  int v[N],w[N];
  for(int i=0;i<N;i++){
    cin>>v[i]>>w[i];
  }
  int DP[N+1][W+1];
  for(int j=0;j<=W;j++){
    DP[0][j]=0;
  }
  for(int i=1;i<=N;i++){
    for(int j=0;j<=W;j++){
      if(j<w[i-1]){
        DP[i][j]=DP[i-1][j];
      }
      else{
        if(DP[i-1][j]>DP[i][j-w[i-1]]+v[i-1]){
          DP[i][j]=DP[i-1][j];
        }
        else{
          DP[i][j]=DP[i][j-w[i-1]]+v[i-1];
        }
      }
    }
  }
  cout<<DP[N][W]<<endl;
}



Measured memory_bytes: 7008
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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 (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n; cin >> n;
    vector<P> x(n);
    rep(i, n) {
        cin >> x[i].fr >> x[i].sc;
    }
    sort(all(x));
    cout << x[n - 1].fr + x[n - 1].sc << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 1024
// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;
 
#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using d=double;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

using point=pair<d,d>;

struct line {
    d m, b;
    bool vertical; d x;
    point intersect(const line& o) {
        if(vertical) return {x, o.m*x+o.b};
        if(o.vertical) return {o.x, m*o.x+b};
        d x = (o.b-b)/(m-o.m);
        return {x, m*x+b};
    }
    line flipthru(const point& p) {
        line ans;
        if(fabs(m) <= 1e-9) {
            ans.vertical = 1;
            ans.x = p.fi;
            return ans;
        }
        ans.vertical = 0;
        if(vertical) ans.m = 0;
        else ans.m = -1/m; 
        ans.b = p.se - ans.m * p.fi;
        return ans;
    }
};

inline line passthru(const point& a, const point& b) {
    line ans;
    if(fabs(a.fi-b.fi) <= 1e-9) {
        ans.vertical = 1;
        ans.x = a.fi;
        return ans;
    }
    ans.vertical = 0;
    ans.m = (a.se-b.se)/(a.fi-b.fi);
    ans.b = a.se - ans.m * a.fi;
    return ans;
}

inline bool colli(const point& a, const point& b, const point& c) {
    if(fabs(a.fi-b.fi) <= 1e-9 && fabs(b.fi-c.fi) <= 1e-9) return true;
    else if(fabs(a.fi-b.fi) <= 1e-9 || fabs(b.fi-c.fi) <= 1e-9) return 0;
    return fabs((a.se-b.se)/(a.fi-b.fi) - (b.se-c.se)/(b.fi-c.fi)) <= 1e-9;
}

inline d dist(const point& a, const point& b) {
    return sqrt((a.fi-b.fi)*(a.fi-b.fi) + (a.se-b.se)*(a.se-b.se));
}

inline point mid(const point& a, const point& b) {
    return {(a.fi+b.fi)/2, (a.se+b.se)/2};
}

int N;
point pts[55];

inline d check(const point& p) {
    d ans = 0;
    rep(i, N) ans = max(ans, dist(p, pts[i]));
    return ans;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    d best = 200000;
    cin >> N;
    rep(i, N) { 
        cin >> pts[i].fi >> pts[i].se; 
        pts[i].fi *= 100;
        pts[i].se *= 100;
    }
    rep(i, N)
        rep(j, N) {
            best = min(best, check(mid(pts[i], pts[j])));
            rep(k, N) {
                if(colli(pts[i], pts[j], pts[k])) continue;
                line A = passthru(pts[i], pts[j]);
                A = A.flipthru(mid(pts[i], pts[j]));
                line B = passthru(pts[j], pts[k]);
                B = B.flipthru(mid(pts[j], pts[k]));
                best = min(best, check(A.intersect(B)));
            }
        }
    cout << setprecision(18) << fixed << best/100 << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

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

    if(N==0){
        cout << 0 << endl;
        return 0;
    }

    int s = N;
    string ans = "";
    while(s != 0){
        if(s % (-2) == 0){
            ans += "0";
            s /= (-2);
        }else{
            ans += "1";
            s--;
            s /= (-2);
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import bisect
N, W = map(int, input().split())
min_w = []
for i in range(N):
  w, v = map(int, input().split())
  l = [w] * v + [i + w for i in min_w]
  min_w = [min(min_w[i], l[i]) for i in range(len(min_w))] + l[len(min_w):]
#  print(min_w, len(min_w))
print(bisect.bisect_right(min_w, W))

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

main(){
  int n;
  cin >> n;
  int W;
  cin >> W;
  int weight[n],value[n];
  for(int ii=0;ii<n;ii++)cin >> weight[ii] >> value[ii];
  long dp[n+2][W+2];
  for(int ii=0;ii<=n;ii++){
    for(int jj=0;jj<=W;jj++){
      dp[ii][jj]=0;
    }
  }
  for(int ii=0;ii<n;ii++){
    for(int jj=0;jj<=W;jj++){
      if(jj-weight[ii]>=0)dp[ii+1][jj]=max(dp[ii][jj],dp[ii][jj-weight[ii]]+value[ii]);
      else dp[ii+1][jj]=dp[ii][jj];
    }
  }
  cout << dp[n][W] << endl;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    int n;
    cin >> n;
    int a=n%10;
    if(a==2||a==4||a==5||a==7||a==9) print("hon");
    else if(a==3) print("bon");
    else print("pon");
    return 0;
}

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


int dmin(int ball, int k) {
  int da, db, d;
  da = ball;
  db = k - ball;
  d = min(da, db);
  return d;
}

int main() {
  int N, K;
  cin >> N;
  cin >> K;
  vector<int> x(110);
  for(int i = 0; i < N; i++) {
    cin >> x.at(i);
  }

  int sum = 0;
  for(int i = 0; i < N; i++) {
    int D = dmin(x.at(i), K);
    sum += D * 2;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    private static int N;
    private static int M;
    private static boolean[] record;
    private static HashMap<Integer,Integer>[] map;
    private static int[] coordinate;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        M = sc.nextInt();
        record = new boolean[N+1];
        coordinate = new int[N+1];
        int[] L = new int[M];
        int[] R = new int[M];
        int[] D = new int[M];
        for(int i=0;i<M;i++){
            L[i] = sc.nextInt();
            R[i] = sc.nextInt();
            D[i] = sc.nextInt();
        }
        map = new HashMap[N+1];
        for(int i=0;i<=N;i++) map[i] = new HashMap<>();
        for(int i=0;i<M;i++){
            map[L[i]].put(R[i],D[i]);
            map[R[i]].put(L[i],-D[i]);
        }
        for(int i=1;i<=N;i++){
            if(!record[i]){
                boolean flag = dfs(i,0);
                if(!flag){
                    System.out.println("No");
                    System.exit(0);
                }
            }
        }
        System.out.println("Yes");
    }
    private static boolean dfs(int i, int pos){
        if(record[i]){
            return pos == coordinate[i];
        }
        record[i] = true;
        coordinate[i] = pos;
        for(Integer w:map[i].keySet()){
            if(!dfs(w,pos+map[i].get(w))) return false;
        }
        return true;
    }
}

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

const int N = 105, M = 105, inf = N * M;

struct edge {
	int to, nxt, cap, cost;
} g[N * M * 10];
int n, m, s, t, head[N * M * 10], cnt = 0;
char str[N][M];
void addedge(int u, int v, int cap, int cost) {
	edge e = {v, head[u], cap, cost};
	g[head[u] = cnt++] = e;
}

queue<int> que;
int par[N * M * 10], dist[N * M * 10], path[N * M * 10];
bool vis[N * M * 10];
bool spfa() {
	for (int i = s; i <= t; i++) vis[i] = false, dist[i] = -inf;
	dist[s] = 0, vis[s] = true, que.push(s);
	while (!que.empty()) {
		int u = que.front();
		for (int i = head[u]; ~i; i = g[i].nxt) {
			int v = g[i].to;
			if (g[i].cap && dist[v] < dist[u] + g[i].cost) {
				dist[v] = dist[u] + g[i].cost;
				par[v] = u, path[v] = i;
				if (!vis[v]) vis[v] = true, que.push(v);
			}
		}
		vis[u] = false, que.pop();
	}
	return dist[t] > -inf;
}

int id(int x, int y) {
	return x * m + y;
}
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++) scanf("%s", str[i]);

	s = 0, t = n * m + 1;
	for (int i = s; i <= t; i++) head[i] = -1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (str[i][j] == 'o') {
				addedge(s, id(i, j) + 1, 1, 0);
				addedge(id(i, j) + 1, s, 0, 0);
			}
			if (str[i][j] != '#') {
				addedge(id(i, j) + 1, t, 1, 0);
				addedge(t, id(i, j) + 1, 0, 0);
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m - 1; j++) {
			if (str[i][j] != '#' && str[i][j + 1] != '#') {
				addedge(id(i, j) + 1, id(i, j + 1) + 1, inf, 1);
				addedge(id(i, j + 1) + 1, id(i, j) + 1, 0, -1);
			}
		}
	}
	for (int i = 0; i < n - 1; i++) {
		for (int j = 0; j < m; j++) {
			if (str[i][j] != '#' && str[i + 1][j] != '#') {
				addedge(id(i, j) + 1, id(i + 1, j) + 1, inf, 1);
				addedge(id(i + 1, j) + 1, id(i, j) + 1, 0, -1);
			}
		}
	}
	int ans = 0;
	while (spfa()) {
		ans += dist[t];
		for (int i = t; i != s; i = par[i]) g[path[i]].cap--, g[path[i] ^ 1].cap++;
	}
	printf("%d\n", ans);
	return 0;
}

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

string shuffle(string str, int h){
	string head = str.substr(0,h);
	string tail = str.substr(h,str.size()-h);
	return tail + head;
}

int main(){
	string cards;
	int m,h;

	while(1){
		cin >> cards;
		if(cards == "-") break;

		cin >> m;
		for(int i=0;i<m;i++){
			cin >> h;
			cards = shuffle(cards,h);
		}
		cout << cards << endl;
	}

	return 0;
}

Measured memory_bytes: 3120
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();

		long num = c - a - b;
		//c < a + bならば絶対にNo
		if (num < 0)  { 
			System.out.print("No");
		} else {

			if(num * num > 4 * a * b) {
				System.out.print("Yes");
			} else {
				System.out.print("No");
			}
		}
	}
}


Measured memory_bytes: 22484
import java.util.*;

public class Main {

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

        int cnt = 0;
        for (int i = 1; i <= n; ++i) {
            String s = Integer.toString(i);
            if (s.length() % 2 == 1) ++cnt;
        }

        System.out.println(cnt);
    }
}

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

int dp[100001];

int func(int *a,int i,int n,int k)
{
	if(i>=n-1)
		return 0;
	if(i==n-2)
	{
		return abs(a[n-1]-a[n-2]);
	}
	if(dp[i]!=-1)
	return dp[i];
	int mn=INT_MAX;
	for(int j=1;j<=k;j++)
	{
		if(i+j>=n)
		continue;
		int x=abs(a[i]-a[i+j])+func(a,i+j,n,k);
		mn=min(mn,x);
	}
	dp[i]=mn;
	return dp[i];
}

int main()
{
	for(int i=0;i<100001;i++)
	dp[i]=-1;
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	cout<<func(a,0,n,k)<<endl;
}


Measured memory_bytes: 13764
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, M;
int A[200000];
int C[200000];
int S[200000];

int ans;
int add(int x) {
  if (x >= C[x]) {
    int t = x-C[x];
    if (S[t] == 0) ans--;
    S[t]++;
  }
  C[x]++;
}
int del(int x) {
  C[x]--;
  if (x >= C[x]) {
    int t = x-C[x];
    S[t]--;
    if (S[t] == 0) ans++;
  }
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> M;
  ans = N;
  rep(i, N) {
    cin >> A[i];
    A[i]--;
  }
  rep(i, N) add(A[i]);

  rep(i, M) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    del(A[x]);
    A[x] = y;
    add(A[x]);
    cout << ans << "\n";
  }
  return 0;
}


Measured memory_bytes: 3840
s = gets.chomp.reverse!
t = ["dream","dreamer","erase","eraser"].map(&:reverse)
i = 0
while true
  t.each_with_index do |str,j|
    if s[i..(i+str.size-1)] == str
      i += str.size
      if i == s.size
        puts "YES"
        exit
      end
      break
    else
      if j == 3
        puts "NO"
        exit
      end
    end
  end
end

Measured memory_bytes: 1916
while 1 :
	n, m = map(int,raw_input().split(" "))
	if (n, m) == (0,0):
		break
	Lon = [0 for i in range(1000 * n + 1)]
	Lat = [0 for i in range(1000 * m + 1)]
	Lon_sum = []
	Lat_sum = []
	for i in range(0,n):
		h = input()
		Lon_sum = [h + j for j in Lon_sum] + [h]
		for j in Lon_sum:
			Lon[j] += 1
	for i in range(0,m):
		w = input()
		Lat_sum = [w + j for j in Lat_sum] + [w]
		for j in Lat_sum:
			Lat[j] += 1
	max_width = min(Lon_sum[0],Lat_sum[0])
	print sum([Lon[i]*Lat[i] for i in range(1,max_width+1)])

Measured memory_bytes: 99240
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair

#define ll long long
#define sc(n) int n; scanf("%d",&n);
#define mod 10000007
#define N 100001
#define MX 1000000001
#define log(n) (int)log2(n)
#define logg(a)(b) log(b)/log(a)
#define pb(x) push_back(x);
#define T int t, q=0; scanf("%d", &t); while(q++<t)
#define pi acos(-1)
#define flag bool fl=true;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

int main() {

    int s,w;
    cin>>s>>w;
    if(w>=s)
    {
        cout<<"unsafe"<<endl;

    } else
    {
        cout<<"safe"<<endl;
    }
}

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

using namespace std;

vector <int> graph[2010];
int N, K;
bool used[2010];
#define Length(x) (int)(x).size()

void input() {
	scanf ("%d %d", &N, &K);
	for (int i = 0; i < N - 1; ++i) {
		int x, y;
		scanf ("%d %d", &x, &y);
		graph[x].push_back(y);
		graph[y].push_back(x);
	}
}
int center;
int cnt;
int candidate;
int winner;
void dfs(int v, int par = -1, int len = 0) {
	used[v] = 1;
	if (K % 2 !=0 && len == (K + 1) / 2) 
		++cnt;
	if (len > (K + 1) / 2)
		candidate += 1;
	bool flag = 0;
	if (par == center)
		flag = 1;
	for (int i = 0; i < Length(graph[v]); ++i) {
		int to = graph[v][i];
		if (!used[to])
			dfs(to, v, len + 1);
	}
	if (flag == 1) {
		if (cnt > winner) {
			candidate += winner;
			winner = cnt;
		}
		else {
			candidate += cnt;
		}
		cnt = 0;
	}
}

int DoggyStyle = (1 << 30);
void solve() {
	for (center = 1; center <= N; ++center) {
		cnt = 0;
		candidate = 0;
		winner = 0;
		for (int i = 1; i <= N; ++i)
			used[i] = 0;		
		dfs(center);
		// cout << center << ' ' << candidate << "\n";
		DoggyStyle = min(DoggyStyle, candidate);
	}
}
void output() {
	cout << DoggyStyle << "\n";
}

int main() {
	input();
	solve();
	output();
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
typedef long long ll;

using namespace std;

// n! を計算　O(N)
ll factorial(ll n) {
    ll factorial = 1;
    for(ll i = 1; i <= n; i++) {
        factorial *= i;
    }
    return factorial;
}

// xCn を計算
ll conbination(ll x, ll n) {
    return factorial(x) / (factorial(n) * factorial(x - n));
}

int main() {
    int n;
    cin >> n;
    
    vector<string> v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
        sort(v[i].begin(), v[i].end());
    }
    
    sort(v.begin(), v.end());
    
    ll num[100005] = {0};
    num[0] = 1;
    for(int i = 0; i < 100004; i++) {
        num[i + 1] = num[i] + i + 2;
    }
    
    ll ans = 0;
    ll cnt = 0;
    for(int i = 0; i < n - 1; i++) {
        if(v[i] == v[i + 1]) {
            cnt++;
        }
        else {
            if(cnt > 0) {
                ans += num[cnt - 1];
                cnt = 0;
            }
        }
        
        if(i == n - 2 && cnt != 0) {
            ans += num[cnt - 1];
        }
    }
    
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int N; cin >> N;
	vl A(N);
	ll sum = 0;
	REP(i, N) {
		cin >> A[i];
		sum += A[i];
	}
	ll sum_half = 0;
	ll other_sum_half;
	int half_i;
	REP(i, N) {
		sum_half += A[i];
		if (sum / 2 <= sum_half) {
			other_sum_half = sum_half - A[i];
			break;
		}
	}
	ll res = abs(sum - sum_half - sum_half);
	res = min(abs(sum - other_sum_half - other_sum_half), res);
	cout << res << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
    long int a , b , cnt;
    cin >> a >> b;
    vector<long long int> v;
    if(a % 2 == 0){
        v.push_back(2LL);
        while(a % 2 == 0){
            a /= 2;
        }
    }
    for(long long int i = 3 ; i * i <= a ; i += 2){
        if(a % i == 0){
            v.push_back(i);
            while(a % i == 0){
                a /= i;
            }
        }
    }
    if(a > 1){
        v.push_back(a);
    }
    cnt = 1;
    for(auto it : v){
        if(b % it == 0){
            cnt++;
        }
    }
    cout << cnt ;
    return 0;
}

Measured memory_bytes: 256
<?php
  $tmp = explode(" ",trim(fgets(STDIN)));

  $val1 = $tmp[0];
  $val2 = intval(str_replace(".", "", $tmp[1]));

  $tmp2 = $val1*$val2;
  if(strlen($tmp2)>2){
    echo substr($tmp2, 0, -2)."\n";
  }else{
    echo "0\n";
  }
  


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

int main(){
  int n,k,p;
  int ans[111];
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> k >> p;
    while(k - p > 0){
      k -= p;
    }
    ans[i] = k;
  }
  for(int i=0;i<n;i++){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define long long ll
using namespace std;
main(){
	int n,a[9];
	cin>>n;
	while(n--){
		int c=0,ans=0;
		r(i,9)scanf("%llx",&a[i]);
		r(i,32){
			int x=0;
			r(j,8)x+=a[j]^ans;
			if((x>>i&1)!=(a[8]>>i&1))ans|=1<<i;
		}
		printf("%llx\n",ans);
	}
}

Measured memory_bytes: 3096
let () =
  let n = read_int () in
  let flag = Array.make 8 false in
  let other = ref 0 in
  let rec peek i =
    if i = 0 then ()
    else
      let x = Scanf.scanf "%d " (fun x -> x) in
      if x >= 3200 then other := !other + 1 else flag.(x / 400) <- true ;
      peek (i - 1)
  in
  let minimum = ref 0 in
  let rec f i' =
    if i' = 8 then ()
    else if flag.(i') then
      let () = minimum := !minimum + 1 in
      f (i' + 1)
    else f (i' + 1)
  in
  let () = peek n ; f 0 in
  Printf.printf "%d %d\n" (max 1 !minimum) (!minimum + !other)

Measured memory_bytes: 384
s = list(input())
ans = 0
for i in range(1,len(s)):
    if s[i-1] == '1' and s[i] == '1':
        s[i] = '0'
        ans += 1
    elif s[i-1] == '0' and s[i] == '0':
        s[i] = '1'
        ans += 1
print(ans)


Measured memory_bytes: 3956
import java.util.*;

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

      if(a>=3200){
        System.out.println(s);
      }else{
        System.out.println("red");
      }

  }
}

Measured memory_bytes: 23764
N,K = map(int, input().split())
A=[]
d=[0 for i in range(K)]
recode={}
for i in range(K):
    d[i]=int(input())
    a=list(map(int, input().split()))
    A.append(a)
for i in range(K):
    for j in range(d[i]):
        recode[A[i][j]]=1
count=0
for i in range(1,N+1):
    if i in recode.keys():
        continue
    else:
        count+=1
print(count)

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
const ll limit=50;
ll n,m;
ll a[limit],b[limit];
bool graph[limit][limit];
bool visited[limit];

void dfs(ll v){
    visited[v]=true;
    for(ll v2=0;v2<n;v2++){
        if(graph[v][v2]==false) continue;
        if(visited[v2]==true) continue;
        dfs(v2);
    }
}

int main() {
    cin >> n >> m;
    for(ll i=0;i<m;i++){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
    }
    ll ans=0;
    for(ll i=0;i<m;i++){
        graph[a[i]][b[i]]=graph[b[i]][a[i]]=false;
        for(ll j=0;j<n;j++) visited[j]=false;
        dfs(0);
        bool judge=false;
        for(ll j=0;j<n;j++){
            if(visited[j]==false) judge=true;
        }
        if(judge) ans++;
        graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
    }
    cout << ans << endl;
}
    

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

int main(void)
{
	char a, b;
	while((cin >> a >> b) && a != NULL)
	{
		if(a == 'H' && b == 'H')
			cout << "H" << endl;
		else if(a == 'D' && b == 'H')
			cout << "D" << endl;
		else if(a == 'D' && b == 'D')
			cout << "H" << endl;
		else if(a == 'H' && b == 'D')
			cout << "D" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int q;
    cin >> q;
    vi b(q);
    rep(i, q) cin >> b[i]; 

    //cout << "yeah" << endl;

    set<int> s;
    for(int bit = 0; bit < (1 << n); bit++) {
        int t = 0;
        for(int i = 0; i < n; i++) {
            if(bit & 1 << i) t += a[i];
        }
        s.insert(t);
    }

    rep(i, q) {
        bool ok = false;
        for(int j : s) {
            if(b[i] == j) ok = true;
        }
        yn(ok);
    } 

    return 0;
}



Measured memory_bytes: 3140
#include<iostream>
#include <climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	vector<vector<int>> chi(n); // 子
	vector<int> par(n, -1); // 親
	vector<int> dep(n, 0); // 深さ
	vector<string> type = { "root", "internal node", "leaf" };
	vector<int> type_index(n, 0);

	REP(i, n) {
		int node;
		cin >> node;
		int k;
		cin >> k;
		chi[node] = vector<int>(k);
		REP(j, k) {
			cin >> chi[node][j];
			par[chi[node][j]] = node;
			type_index[chi[node][j]] = 2;
		}
	}
	REP(i, n) {
		int x = i;
		while (par[x] != -1) {
			dep[i]++;
			x = par[x];
		}
		if (par[i] == -1) type_index[i] = 0;
		else if (chi[i].empty()) type_index[i] = 2;
		else type_index[i] = 1;
	}
	REP(node, n) {
		cout << "node" << " " << node << ": ";
		cout << "parent = " << par[node] << ", ";
		cout << "depth = " << dep[node] << ", ";
		cout << type[type_index[node]] << ", ";
		cout << "[";
		REP(i, chi[node].size()) {
			if (i < chi[node].size() - 1) cout << chi[node][i] << ", ";
			else cout << chi[node][i];
		}
		cout << "]\n";
	}

	return 0;
}


Measured memory_bytes: 6812
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <map>
#include <set>
#include <queue>
#include <functional>
using namespace std;


typedef double W;

const W INF = 1e9;

struct edge {
	int to;
	W cost;
};
typedef pair<W, int> P;
typedef vector<vector <edge > > Graph;

void dijkstra(int s, const Graph& G, vector<W>& d) {
	priority_queue< P, vector<P>, greater<P> > que;
	fill(d.begin(), d.end(), INF);
	d[s] = 0;
	que.push(P(0, s));
	while(!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

typedef pair<double, int> Pdi;
typedef pair<int, int> Pii;
typedef pair<double, Pii> S;

double dist(Pdi p1, Pdi p2) {
	p1.first -= p2.first;
	p1.second -= p2.second;
	return sqrt(p1.first * p1.first + p1.second * p1.second);
}

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

	int n;
	while(cin >> n, n) {
		vector<Pii> point(n);
		vector<int> ys;
		for(int i = 0; i < n; i++) {
			cin >> point[i].first >> point[i].second;
			ys.push_back(point[i].second);
		}
		sort(ys.begin(), ys.end());
		ys.erase(unique(ys.begin(), ys.end()), ys.end());

		vector<Pdi> ps;
		for(int i = 0; i < n - 1; i++) {
			int x1 = point[i].first, y1 = point[i].second;
			int x2 = point[i + 1].first, y2 = point[i + 1].second;
			if(i == 0) ps.push_back(Pdi(x1, y1));
			ps.push_back(Pdi(x2, y2));
			double a = double(y2 - y1) / (x2 - x1), b = y1 - a * x1;
			for(int y : ys) {
				double x = (y - b) / a;
				if(x1 < x && x < x2) ps.push_back(Pdi(x, y));
			}
		}
		sort(ps.begin(), ps.end());
		int P = ps.size();

		map<Pii, double> m;
		priority_queue<S, vector<S>, greater<S> > q;
		S s = S(0, Pii(0, P - 1));
		q.push(s);
		m[s.second] = 0;
		while(q.size()) {
			s = q.top();
			q.pop();
			double d = s.first;
			Pdi p1 = ps[s.second.first];
			Pdi p2 = ps[s.second.second];
			for(int i = -1; i <= 1; i++) {
				for(int j = -1; j <= 1; j++) {
					int ni = s.second.first + i, nj = s.second.second + j;
					if(ni < 0 || P <= ni) continue;
					if(nj < 0 || P <= nj) continue;
					if(ps[ni].second != ps[nj].second) continue;
					double nd = d + dist(p1, ps[ni]) + dist(p2, ps[nj]);
					S ns = S(nd, Pii(ni, nj));
					if(m.count(ns.second) == 0 || m[ns.second] > nd) {
						m[ns.second] = nd;
						if(ni != nj) q.push(ns);
					}
				}
			}
		}

		double ans = 1e9;
		for(int i = 0; i < P; i++) {
			if(m.count(Pii(i, i))) {
				ans = min(ans, m[Pii(i, i)]);
			}
		}
		cout << fixed << setprecision(10) << ans << endl;
	}
}

Measured memory_bytes: 8752
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    LL q, h, s, d;
    cin >> q >> h >> s >> d;
    LL n;
    cin >> n;

    n *= 100;
    LL cost = 0;
    while( n ) {
        if( n >= 200 ) {
            cost += min( min( q * 8, h * 4 ), min( s * 2, d ) );
            n -= 200;
        } else if( n >= 100 ) {
            cost += min( min( q * 4, h * 2 ), s );
            n -= 100;
        }

    }

    cout << cost << endl;
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define llp 1000000007
#define mod 1000000007

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

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;


int32_t main(){
	ios::sync_with_stdio(false);
    int r, d, x;
    cin>>r>>d>>x;
    for(int i=1;i<=10;i++){
        // deb(i);
        x=r*x-d;
        // deb(x);
        cout<<x<<"\n";
    }



	return 0;
}

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

int main(int argc, const char * argv[]) {
    int n,c,k;
    cin >> n >> c >> k;
    int t[n];
    for (int i=0; i<n; i++) {
        cin >> t[i];
    }
    sort(t,t+n);
    int maxTime = t[0]+k;
    int capacity = 1;
    int answer = 1;
    for (int i=1; i<n; i++) {
        if(maxTime >= t[i] && capacity<c){
            capacity++;
        }else{
            capacity = 1;
            maxTime = t[i] + k;
            answer++;
        }
    }
    cout << answer;
    return 0;
}


Measured memory_bytes: 640
#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>;
ll mod = 1000000007;
int N, K;
ll dp[101010];

ll modpow(ll a, ll n){
    ll r = 1; a %= mod;
    while(n) r = r * ((n % 2) ? a : 1) % mod, a = a * a % mod, n >>= 1;
    return r;
}

void solve(){
    cin >> N >> K;
    ll sum = 0;
    for (int i = K; i >= 1; i--)
    {
        dp[i] = modpow(K/i, N);
        for(int j = i * 2; j <= K; j += i) dp[i] -= dp[j];
        dp[i] = (dp[i] % mod + mod) % mod;
        sum += i * dp[i] % mod;
    }
    cout << sum % mod << endl;
}
int main() {
    solve();
    return 0;
}

Measured memory_bytes: 4392
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &&i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(a) ((int)a.size())
#define pow2(n) (n * n)
#define int ll
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-8;
ll mod = static_cast<ll>(1e9 + 7);
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class F>
class FixPoint : private F {
public:
    explicit constexpr FixPoint(F &&f) : F(std::forward<F>(f)) {}
    template <class... Args>
    constexpr decltype(auto) operator()(Args &&... args) const { return F::operator()(*this, std::forward<Args>(args)...); }
};
template <class F>
constexpr decltype(auto) funcs(F &&f) { return FixPoint<F>{std::forward<F>(f)}; }
template <class T>
std::vector<T> vecs(int n, T &&val) { return std::vector<T>(std::forward<int>(n), std::forward<T>(val)); }
template <class... Args>
decltype(auto) vecs(int n, Args &&... args) { return std::vector<decltype(vecs(std::forward<Args>(args)...))>(std::forward<int>(n), vecs(std::forward<Args>(args)...)); }
template <class V, class T>
void fill(V &x, const T &val) { x = val; }
template <class V, class T>
void fill(vector<V> &vec, const T &val) {
    for (auto &&v : vec)
        fill(v, val);
}

void solve() {
    int n;
    cin >> n;

    int ans = 0;
    reps(i, n) {
        int res = n / i;
        if (i * res == n) --res;
        ans += res;
    }

    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout.flush();
    return 0;
}

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

#define all(x) (x).begin(),(x).end()
using namespace std;

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

    set<int> a,b,c;
    int n,m;
    int x;

    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        a.insert(x);
    }

    cin>>m;
    for(int i=0;i<m;i++)
    {
        cin>>x;
        b.insert(x);
    }

    set_union(all(a),all(b),inserter(c,c.end()));

    for(int i:c)
    {
        cout<<i<<endl;
    }

    return 0;
}



Measured memory_bytes: 40720
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll read(){
    ll c = getchar(),Nig = 1,x = 0;
    while(!isdigit(c))
        c = getchar();
    if(c == '-')
        Nig = -1,c = getchar();
    while(isdigit(c))
        x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();
    return Nig*x;
}
#define read read()
int main(){
    int n = read,t,flag = 0;
    while(n--){
        t = read;
        if(t%2)
            flag = 1;
    }
    printf("%s\n",flag?"first":"second");
	return 0;
}


Measured memory_bytes: 256
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL); clock_t beg = clock()
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 3e5+7 ;
const int INF = 1e18 ;
const int MOD = 1e9 + 7 ;
string s ;

void solve(){
	int n  ,  m ;
	cin >> n >>  m ;
	int ans = ceil(1.0 * n/m) ;
	cout << ans << endl ;
}

int32_t main(){
	FAST_IO ;
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int w;
	
	while (cin >> w) {
		if (w == -1) break;
		
		int price = 1150;
		
		for_(i,11,w+1) {
			if (i > 10 && i <= 20) price += 125;
			if (i > 20 && i <= 30) price += 140;
			if (i > 30) price += 160;
		}
		
		cout << 4280 - price << endl;
	}
}

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

signed main(){
int a;
while(cin>>a,a){
	int sum=0;
	vector<vector<int>>c(a+1);
	c[0].push_back(0);
	for(int b=0;b<a;b++){
		int e;
		scanf("%lld",&e);
		sum+=e;
		for(int d=0;d<c[b].size();d++){
			c[b+1].push_back(c[b][d]);
			c[b+1].push_back(c[b][d]+e);
		}
	}
	sort(c[a].begin(),c[a].end());
	auto t=upper_bound(c[a].begin(),c[a].end(),(double)sum/2);
	auto qq=t;
	qq--;
printf("%d\n",min(abs(*t-(sum-*t)),abs(*qq-(sum-*qq))));
}
}

Measured memory_bytes: 27456
#include<bits/stdc++.h>
using namespace std;
int main()
{ int a,b,c;
   cin>>a>>b>>c;
   int sum=0;
   sum=(a*100)+(b*10)+c;
   if(sum%4==0)cout<<"YES\n";
   else cout<<"NO\n";

return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{
	char s[100000];
	scanf("%s",&s);
	int l=strlen(s);
	for(int i=0; i<l; i++) {
		if(i%2==0) {
			printf("%c",s[i]);
		}
	}
	printf("\n");
	return 0;
}

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

int main(){
	int rail[11];
	int num=0;
	while(true){
		int now;
		cin >> now;
		if(cin.eof())
			break;
		else if(now ==0){
			cout << rail[num] << endl;
			num--;
		}
		else{
			num++;
			rail[num] = now;
		}
	
	}
	return 0;

}

Measured memory_bytes: 0
//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
//これは、頭が悪く競プロが世界で一番できないHIR180が
//IOI2014日本代表になるまでのN日間の記録である。
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define f first
#define s second
#define rep(i,x) for(int i=0;i<x;i++)
short dp[4005][4005]; char a[4005],b[4005];
int main()
{
	srand((unsigned int)time(NULL));
	while(scanf("%s%s",&a,&b)!=-1)
	{
		int x=strlen(a);
		int y=strlen(b);
		memset(dp,0,sizeof(dp));
		int ret=0;
		for(int i=1;i<=x;i++)
		{
			for(int j=1;j<=y;j++)
			{
				if(a[i-1]==b[j-1])
				{
					dp[i][j]=(dp[i-1][j-1]+1);
				}
				else
				{
					dp[i][j]=0;
				}
				ret=max(ret,(int)dp[i][j]);
			}
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 32488
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
const ll INF = 1e18 +9;

void solve(){
	int n,w;cin >> n >> w;
	vector<ll> value(n),weight(n);
	ll sumvalue = 0;
	for(int i = 0;i<n;++i){
		cin >> weight[i] >> value[i];
		sumvalue+=value[i];
	}
		
	vector<vector<ll>> hash(n+1,vector<ll> (sumvalue+1,INF));
	for(int i = 0;i<=n;++i)
		hash[i][0] = 0;
	for(int i = 1;i<=n;++i){
		for(int j = 1;j<=sumvalue;++j)
		{
			if(j<value[i-1])
			{
				hash[i][j] = hash[i-1][j];
			}
			else
			{ 
				hash[i][j] = min(hash[i-1][j],weight[i-1] + hash[i-1][j-value[i-1]]);
				//cout << hash[i][0];
			}
			//cout << hash[i][j] << ' ';
		}
		cout << '\n';
	}
	ll max = 0;
	for(int i = 0;i<sumvalue+1;++i)
	{
		if(hash[n][i]<=w)
			max = i;
	}
	cout << max;
		
	
}
int main() {
    int t = 1;
    while(t--) solve();
}


Measured memory_bytes: 80256