akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N, M);
  vvi g(N, vi());
  rep(i, 0, M) {
    VAR(int, ai, bi);
    g[ai - 1].push_back(bi - 1);
  }

  // dijkstra
  priority_queue<pii, vector<pii>, greater<>> que;
  vi d(N, INF);
  d[0] = 0;
  que.push(pii(0, 0)); // index、cost

  while (!que.empty()) {
    pii p = que.top(); que.pop();
    int i = p.first;
    if (d[i] < p.second) continue;
    each(x, g[i]) {
      if (d[x] > d[i] + 1) {
        d[x] = d[i] + 1;
        que.push(pii(x, d[x]));
      }
    }
  }
  if (d[N - 1] < 3) {
    print("POSSIBLE");
  } else {
    print("IMPOSSIBLE");
  }
}


Measured memory_bytes: 10360
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#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__) << "] "
typedef long long ll;

void solve()
{
	int n;
	cin>>n;
	n %= 10;
	if (n==3) {
		cout << "bon\n";
	}	
	else if (n==0 || n==1 || n==6 || n==8) {
		cout << "pon\n";
	}
	else {
		cout << "hon\n";
	}
}

int main()
{
	fastIO;
	int t=1;
	// cin>>t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
#include <stdlib.h>
#define N 100
#define BIG 1000000

int omomi();

int n,arr[N+1][N+1];

int main(){
  int i,j,min;
  scanf("%d",&n);
  if(n<1 || n>N) exit(2);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      scanf("%d",&arr[i][j]);
      if(arr[i][j] == -1) arr[i][j] = BIG;
    }
  }
  min = omomi();
  printf("%d\n",min);
  
  
  
  return 0;
}

int omomi(){
  int i,k,x,min,sum;
  int dis[N+1],pa[N+1],col[N+1];

  for(i=0;i<=n;i++){
    dis[i]=BIG;
    pa[i]=-1;
    col[i]=0; // 1...発見してない
  }
  dis[1]=0;
  while(1){
    min=BIG;
    x=-1;
    for(i=1;i<=n;i++){
      if(min > dis[i] && col[i] != 2){ // 2...でていった
	x=i;
	min=dis[i];
      }
    }
    if(x==-1) break;
    col[x] = 2;
    for(k=1;k<=n;k++){
      if(col[k] != 2 && arr[x][k] != BIG){
	if(dis[k] > arr[x][k]){
	  dis[k] = arr[x][k];
	  pa[k] = x;
	  col[k] = 1; // 1...発見した
	}
      }
    }
  }
  sum=0;
  for(i=1;i<=n;i++){
    if(pa[i] != -1)sum += arr[i][pa[i]];
  }
  return sum;
}



Measured memory_bytes: 2112
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if X == 500 * a + 100 * b + 50 * c:
                count = count + 1
print(count)

Measured memory_bytes: 9152
#include<iostream>
using namespace std;int main(){int n,a,b,c,x,i;int y[100];int fl;for(;;){cin >> n >> a >> b >> c >> x;if(n==0&&a==0&&b==0&&c==0&&x==0)break;for(i=0;i<n;i++){cin >> y[i];}fl=i=0;int f=1;for(;;){if(fl==10001){f=0;break;}if(y[i]==x){i++;x=(a*x+b)%c;if(i==n)break;fl++;}else{fl++;x=(a*x+b)%c;}}if(f==1)cout << fl << endl;else cout << "-1" << endl;}}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
 
        while(true) {
            String[] set = br.readLine().split(" ");
            int m = Integer.parseInt(set[0]);
            int f = Integer.parseInt(set[1]);
            int r = Integer.parseInt(set[2]);
            int sum = m + f;
            if(m == -1 && f == -1 && r == -1) {
                break;
            } else if (m == -1 || f == -1) {
                sb.append("F\n");
            } else if ( sum >= 80) {
                sb.append("A\n");
            } else if (sum >= 65 && sum < 80) {
                sb.append("B\n");
            } else if (sum >= 50 && sum < 65) {
                sb.append("C\n");
            } else if (sum >= 30 && sum < 50) {
                if (r >= 50) {
                    sb.append("C\n");
                } else {
                    sb.append("D\n");
                }
            } else if (sum < 30) {
                sb.append("F\n");
            }
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 24208
#include <complex>
#include <cmath>
#include <cstdio>
#include <iostream>

using namespace std;
typedef complex<double> xy_t;
xy_t P[110];

double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }
int main() {
    int N;
    scanf("%d", &N);
    int x, y;
    for(int i=0; i<N; i++){
        scanf("%d %d", &x, &y);
        P[i] = xy_t((double)x,(double)y);
    }
    double sum = 0.0;
    xy_t a=P[0];
    for (int i=0; i+2<N; ++i) {
        xy_t b=P[i+1], c=P[i+2];
        sum += cross_product(c-a, b-a)/2.0;
    }
    printf("%.1f\n", abs(sum));
 }

Measured memory_bytes: 1228
import java.io.*;
import java.util.*;

public class Main {


    private void solve(InputReader in, PrintWriter out) {
        int a = in.nextInt();
        int b = in.nextInt();
        if (a + b == 15) {
            out.println("+");
        } else if (a * b == 15) {
            out.println("*");
        } else {
            out.println("x");
        }
    }


    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        try (
                InputReader in = new InputReader(System.in);
                PrintWriter out = new PrintWriter(System.out)) {
            solve(in, out);
        }
    }


    static class InputReader implements AutoCloseable {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        @Override
        public void close() {

        }
    }

}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    vector<int> d(n);
    for(int in=0;in<n;in++) {
        cin >> d.at(in);
    }

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

    int ans = 0;
    for(int in=1;in<n;in++) {
        if(d.at(in-1)!=d.at(in)) ans++;
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
#define INT_MAX 1<<30
const ll mod = 1e9+7;



int main(){
	ll n; cin >> n;
	vector<vector<char>> ans(n,vector<char>(n,'.'));
	string a3[3] = {"aa.","..a","..a"};
	string a4[4] = {"aacd","bbcd","cdaa","cdbb"};
	string a5[5] = {"aabbc","dde.c",".fegg","hf..i","h.jji"};
	string a6[6] = {"aabbcc","d.e.f.","d.e.f.",".g.h.i",".g.h.i","jjkkll"};
	string a7[7] = {"aa.bbcc","..d.e.f","..d.e.f","gg.h.i.","..jh.i.","..j.kkl","mmnn..l"};
	if(n==1 || n==2) puts("-1");
	else if(n==3) rep(i,3) cout << a3[i] << endl;
	else if(n==4) rep(i,4) cout << a4[i] << endl;
	else if(n==5) rep(i,5) cout << a5[i] << endl;
	else if(n==6) rep(i,6) cout << a6[i] << endl;
	else if(n==7) rep(i,7) cout << a7[i] << endl;
	else{
		n -= 4;
		ll q = n/4;
		ll r = n%4;
		ll y = 0, x = 0;
		while(q--){
			rep(i,4){
				rep(j,4) ans[y+i][x+j] = a4[i][j];
			}
			y += 4;
			x += 4;
		}
		if(r==0){
			rep(i,4){
				rep(j,4) ans[y+i][x+j] = a4[i][j];
			}
		}
		else if(r==1){
			rep(i,5){
				rep(j,5) ans[y+i][x+j] = a5[i][j];
			}
		}else if(r==2){
			rep(i,6){
				rep(j,6) ans[y+i][x+j] = a6[i][j];
			}
		}else if(r==3){
			rep(i,7){
				rep(j,7) ans[y+i][x+j] = a7[i][j];
			}
		}
		n += 4;
		rep(i,n){
			rep(j,n) cout << ans[i][j];
			cout << endl;
		}
	}
}


Measured memory_bytes: 2176
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll N;
	cin >> N;
	ll W[N];
	for (ll i = 0; i < N; ++i) cin >> W[i];
 
	// 解法
	ll ans = 10000;
	ll S1 = 0;
	ll S2 = 0;
	REP(i,N){
		S2 += W[i];
	}
	REP(i,N){
		ll tmp = abs(S1 - S2);
		if (tmp<ans) ans = tmp;
		S1 += W[i];
		S2 -= W[i];
	}
	
	//出力
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int h, w, c[10][10], a[210][210];
vector<P> p;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> h >> w;
    rep(i, 0, 10) rep(j, 0, 10) cin >> c[i][j];
    rep(k, 0, 10) rep(i, 0, 10) rep(j, 0, 10) {
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
    }
    int ans = 0;
    rep(i, 0, h) rep(j, 0, w) {
        cin >> a[i][j];
        if (a[i][j] >= 0) ans += c[a[i][j]][1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        var sc = new Scanner();
        //スイッチn
        int n = sc.nextInt();
        //電球m
        int m = sc.nextInt();

        var s = new int[m][];
        for (int i = 0; i < m; i++)
        {
            int k = sc.nextInt();
            s[i] = new int[k];
            for (int j = 0; j < k; j++)
            {
                s[i][j] = sc.nextInt();
            }
        }
        var p = new int[m];
        for (int i = 0; i < m; i++)
        {
            p[i] = sc.nextInt();
        }

        long ans = 0;
        for (int i = 0; i < 1 << n; i++)
        {
            var sw = new bool[n];
            for (int j = 0; j < n; j++)
            {
                if ((1 & i >> j) == 1)
                {
                    sw[j] = true;
                }
            }
            bool flag = false;
            for (int j = 0; j < m; j++)
            {
                int tmp = 0;
                for (int t = 0; t < s[j].Length; t++)
                {
                    if (sw[s[j][t] - 1]) tmp++;
                }
                if (tmp % 2 == p[j]) flag = true;
                else
                {
                    flag = false;
                    break;
                }
            }
            if (flag) ans++;
        }
        Console.WriteLine(ans);
    }
}

// chokudai's Scanner
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    string s;cin>>s;
    rep(i,s.size()){
        if(s[i]=='1')s[i]='9';
        else s[i]='1';
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl;
#define all(x) (x).begin(),(x).end()

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

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

int main()
{
    ll n;
    cin >> n;
    vector<pair<ll, ll>> xl(n);
    rep0(i, n){
        ll a,b;
        cin >> a >> b;
        xl[i].first = a + b;
        xl[i].second = a - b;
    }
    sort(all(xl));
    ll ans = 0,t = -1e9 * 2 + 1;
    rep0(i, n){
        if(t <= xl[i].second){
            ++ans;
            t = xl[i].first;
        }
    }
    pf(ans)
    return 0;
}


Measured memory_bytes: 1792
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
	public static void main(String... args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		List<Integer> list = IntStream.range(0, n).map(i -> scan.nextInt()).boxed().collect(Collectors.toList());
		Collections.sort(list);
		Collections.reverse(list);

		long sum = 0;
		for (int i = k; i < list.size(); i++) {
			sum += list.get(i);
		}

		System.out.println(sum);
		scan.close();
	}
}

Measured memory_bytes: 97068
#include<iostream>
#include<algorithm>
 
using namespace std;
 
int main(){
    while( true ){
        int n;
        int ma = 0;
        int mi = 0;
        cin >> n;

        if(n == 0){
            break;
        }

        int a[n];

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

        sort(a,a+n);

        for(int i = 2;i < n-1;i++){
            a[1]+=a[i];
        }

        cout << a[1]/(n-2) << endl;
    }   
 
}

Measured memory_bytes: 1176
import sys
from itertools import combinations
from bisect import bisect_left

def main():
    input = sys.stdin.readline
    N = int(input())
    L = list(map(int, input().split()))

    L = sorted(L)
    ans = 0
    for a, b in combinations(range(N), 2):
        a, b = min(a, b), max(a, b)

        c_max = L[a] + L[b]

        left = b + 1
        right = bisect_left(L, c_max)

        ans += right - left

    return ans

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3188
n, m = map(int, input().split())
events = []
for i in range(m):
    a, b = map(int, input().split())
    events.append((a, 0, i))
    events.append((b-1, 1, i))
events.sort()
solved = [False] * m
todo = []
ans = 0
for i, etype, req in events:
    if etype == 0:
        todo.append(req)
    else:
        if not solved[req]:
            ans += 1
            for req_id in todo:
                solved[req_id] = True
            todo = []
print(ans)

Measured memory_bytes: 102796
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> a(m), b(m), c(m);
    vector<vector<ll>> dist(n, vector<ll>(n));

    rep(i, 0, m) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--, b[i]--;
    }

    rep(i, 0, n) {
        rep(j, 0, n) {
            if (i == j) dist[i][j] = 0;
            else dist[i][j] = INF;
        }
    }

    rep(i, 0, m) {
        chmin(dist[a[i]][b[i]], c[i]);
        chmin(dist[b[i]][a[i]], c[i]);
    }

    rep(k, 0, n) rep(i, 0, n) rep(j, 0, n) chmin(dist[i][j], dist[i][k] + dist[k][j]);

    ll ans = m;
    rep(i, 0, m) {
        bool is_shortest = false;
        rep(j, 0, n) if(dist[j][a[i]] + c[i] == dist[j][b[i]]) is_shortest = true;
        if(is_shortest) ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split(" ");;
	//文字列から10進数に変換するときはparseIntを使います
	var A = parseInt(input[0], 10);
	var B = parseInt(input[1], 10);
	var X = parseInt(input[2], 10);
	
        if (A + B < X){
          console.log('NO');
        }else if(A > X){
          console.log('NO');
        }else{
          console.log('YES');
        }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <math.h>

#define SWAP(a, b) a = a ^ b; b = a ^ b; a = a ^ b

void swap(int * a, int * b)
{
    int temp = *a;
    *a = *b;
    *b = temp;
}

void print_int(int n)
{
    printf("%d\n",n);
    
}

void sort(int a[], int n)
{
    int h, i, j;

    for(h = 1; h < n / 9; h = h * 3 + 1)
        continue;

    for(; h > 0; h /= 3)
    {
        for(i = h; i < n; i++)
        {
            j = i;
            while(j >= h && a[j] < a[j-h])
            {
                swap(&a[j], &a[j-h]);
                j -= h;
            }
        }
    }
}

void print_list(int a[], int n)
{
    for(int i = 0; i < n; i++)
    {
        printf("%d ", a[i]);
    }
}

void intcpy(int a[], const int b[], int count)
{
    for(int i = 0; i < count; i++)
    {
        a[i] = b[i];
    }
}

int list_sum(int a[], int n)
{
    int sum = 0;

    for(int i = 0; i < n; i++)
    {
        sum += a[i];
    }

    return sum;
}


void permutate(int s[], int count, int n)
{
    if(n == count)
        return;

    for(int i = n; i < count; i++)
    {
        swap(&s[i], &s[n]);

        if(i != n)
        {
            //intcpy(result[j++], s, count);
        }
        
        permutate(s, count, n+1);
        swap(&s[i], &s[n]);
    }
}



int main(void)
{
    int a, b;
    scanf("%d %d", &a, &b);
    int ans[3];
    ans[0] = a + b;
    ans[1] = a + a -1;
    ans[2] = b + b -1;
    sort(ans,3);
    print_int(ans[2]);
    
    return 0;
}



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

int main() {
  int a, b;
  cin >> a >> b;
  
  if (a > b){
       for (int i = 0; i < a; i++){
            cout << b ;
       }
  }
  
  else if (b > a) {
       for (int i = 0; i < b; i++){
            cout << a ;
       }
  }
  
  else if (a == b) {
       for (int i = 0; i < a; i++){
            cout << a ;
       }
  }
  
}



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

#define ll long long

using namespace std;

int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    string s1,s2;
    cin >> s1 >> s2;
    int res = 0;
    for(int i = 0; i < s1.length(); i++)
    {
        if(s1[i] == s2[i])
        {
            res++;
        }
    }
    cout << res;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int a,b,c,d,e,k;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&k);

    if(b-a<=k && c-a<=k && d-a<=k && e-a<=k && c-b<=k && d-b<=k && e-b<=k && d-c<=k && e-c<=k && e-d<=k )

    {
        printf("Yay!\n");
    }

    else
    {
        printf(":(\n");
    }

    return 0;
}


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

int64_t si(string s){
  int64_t res=0;
  int64_t m=s.size();
 
  for(int i=0;i<s.size();++i){
  int64_t n=s[i]-'0';
  res +=  n*(int64_t)pow(10,m-i-1);
  }
 
  return res;
}

int main(){
  int K;
  cin>>K;
  
  queue<pair<string,int>> que;
  vector<int64_t> v;
  for(int i=0;i<10;++i) que.push(make_pair(to_string(i),1));
  while(true){
    auto p=que.front();
    que.pop();
    if(p.second>10){
      break;
    }
    else{
      string s=p.first;
      //cout<<s<<endl;
      int t=p.second;
      int u=s[0]-'0';
      if(u==0){
        que.push(make_pair("0"+s,t+1));
        que.push(make_pair("1"+s,t+1));
      }
      else if(u<9){
        v.push_back(si(s));
        que.push(make_pair(to_string(u-1)+s,t+1));
        que.push(make_pair(to_string(u)+s,t+1));
        que.push(make_pair(to_string(u+1)+s,t+1));
      }
      else{
        v.push_back(si(s));
        que.push(make_pair(to_string(u-1)+s,t+1));
        que.push(make_pair(to_string(u)+s,t+1));
      }
    }
  }

  sort(v.begin(),v.end());
  int cnt=0;
  for(int i=0;i<v.size();++i){
  if(v[i]!=0){
    ++cnt;
    //cout<<v[i]<<endl;
  }
  if(cnt==K){
    cout<<v[i]<<endl;
    break;
  }
  }
}


Measured memory_bytes: 26992
#include<stdio.h>
int main()
{
	int n, a[201], i, j, flag;
	while(~scanf("%d", &n))
	{
		for(i=0; i<n; i++)
			scanf("%d", a+i);
		j=0;
		flag = 0;
		while(++j)
		{
			for(i=0; i<n; i++)
			{
				if(a[i]%2)
				{
					flag = 1;
					break;
				}		
				a[i]/=2;		
			}
			if(flag) break;
		}
		printf("%d\n", --j);
	}
	return 0;
}

Measured memory_bytes: 504
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

bool f(int a, int b, int c)
{
	if(a == 2 && b == 1 && c == 1) return true;
	if(a == 1 && b == 2 && c == 1) return true;
	if(a == 1 && b == 1 && c == 2) return true;
	
	return false;
}

int main()
{
    for(int a, b, c; cin >> a >> b >> c && (a || b || c); )
	{
		vint S(a+b+c, 2);
		
		int N;
		cin >> N;
		
		vector<pair<pint, pint> > tests(N);
		rep(i, N)
		{
			cin >> tests[i].first.first >> tests[i].first.second;
			cin >> tests[i].second.first >> tests[i].second.second;
			
			if(tests[i].second.second == 1)
			{
				S[tests[i].first.first-1] = 1;
				S[tests[i].first.second-1] = 1;
				S[tests[i].second.first-1] = 1;
			}
		}
		
		rep(i, N)
		{
			if(f(S[tests[i].first.first-1], S[tests[i].first.second-1], S[tests[i].second.first-1]))
			{
				if(S[tests[i].first.first-1] == 2) S[tests[i].first.first-1] = 0;
				if(S[tests[i].first.second-1] == 2) S[tests[i].first.second-1] = 0;
				if(S[tests[i].second.first-1] == 2) S[tests[i].second.first-1] = 0;
			}
		}
		
		rep(i, a+b+c) cout << S[i] << endl;
	}
}

Measured memory_bytes: 1212
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("mmx,sse,sse2")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set = tree <T, null_type ,  less<T> ,  rb_tree_tag ,  tree_order_statistics_node_update>;

template<class T>
using ordered_multiset = tree <T, null_type ,  less_equal<T> ,  rb_tree_tag ,  tree_order_statistics_node_update>;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvii = vector<vii>;

int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int X, s[] = {600, 800, 1000, 1200, 1400, 1600, 1800, 2000};
	cin >> X;
	for(int k = 0; k < 8; ++k) {
		if(X < s[k]) {
			cout << 8 - k << '\n';
			break;
		}	
	}
	return 0;
}

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

int main()
{
	register int n, ans = 0;
	scanf("%d", &n);
	for (register int i = 1, x; i <= n; ++i) {
		scanf("%d", &x);
		ans = ans ^ x;
	}
	if (ans == 0) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n,h,w;
  cin >> n >> h >> w;
  cout << (n-h+1)*(n-w+1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

constexpr int inf = 0x3f3f3f3f;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, p; cin >> n >> p;
  --p;
  V<> a(n), b(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
  }
  V<> idx(n);
  iota(begin(idx), end(idx), 0);
  sort(begin(idx), end(idx), [&](int i, int j) { return a[i] < a[j]; });
  V<> dp(p + 1, -inf);
  dp[0] = 0;
  int res = 0;
  for (int i : idx) {
    res = max(res, *max_element(begin(dp), end(dp)) + b[i]);
    auto ndp = dp;
    for (int x = a[i]; x <= p; ++x) {
      ndp[x] = max(ndp[x], dp[x - a[i]] + b[i]);
    }
    swap(dp, ndp);
  }
  cout << res << '\n';
}


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

//ライブラリ始まり

//定数

//円周率
const double PI = 3.1415926535897932384;

//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 1000000000000000; // = 10^15

//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";

//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//データ構造

//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す
    return SIZE.at(root(x));
  }
};

//関数

//ctoi
int ctoi(char c){
  if (c == '0') {
    return 0;
  }
  if (c == '1') {
    return 1;
  } 
  if (c == '2') {
    return 2;
  } 
  if (c == '3') {
    return 3;
  }
  if (c == '4') {
    return 4;
  } 
  if (c == '5') {
    return 5;
  } 
  if (c == '6') {
    return 6;
  }
  if (c == '7') {
    return 7;
  } 
  if (c == '8') {
    return 8;
  } 
  if (c == '9') {
    return 9;
  }
  return -1;  
}

//素数判定
bool PN(int x) {
  if (x <= 1) {
    return false; // 1や0,-1は素数ではない
  }
  if (x == 2) {
    return true; // √2 + 1 > 2 なので下でやると 2 ％ 2 = 0 となり判定できない
  }
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) {
      return false; // 割れたら素数じゃない
    }
  }
  return true;
}

//ライブラリ終わり

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A * B > C * D) {
    cout << A * B << endl;
  }
  else {
    cout << C * D << endl;
    
    }
    }
  

Measured memory_bytes: 3540
A = int(input())
B = int(input())
C = int(input())
X = int(input())

res = 0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if 500*i+100*j+50*k == X:
        res+=1

print(res)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 998244353LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}
};
ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x %mod;
		x = x * x%mod;
		n >>= 1;
	}
	return res;
}
typedef vector<vector<Edge>> Graph;
signed main(void) {
	int h, w;
	cin >> h >> w;

	vector<string> mp(h);

	set<pii> fr, nx;

	vector<vector<int>> turn(h, vector<int>(w, -1));
	REP(i, h) {
		cin >> mp[i];
		REP(j, w)
			if (mp[i][j] == '#')
				fr.insert({ i,j }), turn[i][j] = 0;
	}

	int ans = 0, ct = 1;
	while(1){
		while (fr.size())
		{
			pii cur = *fr.begin();
			fr.erase(fr.begin());
			REP(i, 4) {
				pii buf = {cur.first + Dir[i].first,cur.second + Dir[i].second};
				if (buf.first < 0 || buf.second < 0 || buf.first >= h || buf.second >= w) continue;
				if (turn[buf.first][buf.second] == -1) {
					turn[buf.first][buf.second] = ct;
					chmax(ans, ct);
					nx.insert(buf);
				}

			}



		}
		ct++;
		if (nx.size() == 0) break;
		swap(fr, nx);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 52096
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new ABC108().doIt(); //LCM
	}
	class ABC108{
		void doIt() {
			int N = sc.nextInt();
			int K = sc.nextInt();
			long A = 0;
			long A_2 = 0;
			for(int i = 1;i <= N;i++) {
				if(i % K == 0)A++;
				else if(i*2 % K == 0)A_2++;
			}
			long ans = A*A*A + A_2*A_2*A_2;
			System.out.println(ans);
		}
	}
	class ABC109{
		int euqulid(int A,int B) {
			if(B > 0)return euqulid(B,A % B);
			else return A;
		}
		void doIt(){
			int n = sc.nextInt();
			int X = sc.nextInt();
			int ans = Integer.MAX_VALUE;
			for(int i = 0;i < n;i++) {
				int x = sc.nextInt();
				int dist = Math.abs(x - X);
				if(i == 0)ans = dist;
				else ans = euqulid(dist,ans);
			}
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 21844
using System;
using System.Linq;
class Test{ 
  public static void Main(){    
    var KN =  Console.ReadLine().Split(' ').Select(n => int.Parse(n)).ToList();
    var nums = Console.ReadLine().Split(' ').Select(n => int.Parse(n)).ToList();
    long between = 0;
    for(int i =0; i<KN[1]; i++){
      var sub = 0;
      if(i == KN[1]-1){
        sub = KN[0] - nums[i] + nums[0];
        if(sub > between ){
          between = sub;
        }
      }else{
        sub = nums[i+1]- nums[i];
        if(sub > between){
          between = sub;
        }
      }
    }   
    Console.WriteLine(KN[0]-between);
  }
}

Measured memory_bytes: 34780
def solve(lis):
    # 全要素が0の場合
    if is_all_zero(lis):
        return 0

    # 0がある場合、0を境に分割
    zero_index = search_zero_index(lis)
    if zero_index != -1:
        return solve(lis[:zero_index]) + solve(lis[zero_index+1:])

    # 0が無い場合、最小値の数をリスト全体から引く
    min_num = min(lis)
    lis = list(map(lambda x: x - min_num, lis))
    return min_num + solve(lis)

def is_all_zero(lis):
    return len(list(filter(lambda x : x == 0, lis))) == len(lis)

def search_zero_index(lis):
    if 0 in lis:
        return lis.index(0)
    else:
        return -1

if __name__ == "__main__":
    N = int(input())
    h_list = list(map(int, input().split()))
    print(solve(h_list))


Measured memory_bytes: 3188
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
using namespace std;
#define rep(N) for(int i=0;i<N;i++)
#define rep2(N1,N2) for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)for(int k=0;k<N3;k++)
#define For(i,N) for(int i=0;i<N;i++)
void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int ctoi(char c) {
	return c - '0';
}



int main() {
	int K, A, B;
	cin >> K >> A >> B;
	int flag = 1;
	for (int i = A; i <= B; i++) {
		if (i%K == 0)
			flag = 0;
	}
	if (flag == 0)
		cout << "OK";
	else
		cout << "NG";
	return 0;
}

Measured memory_bytes: 3592
#include "bits/stdc++.h"
#define F first
#define S second
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll h = 0, a = 0;
  cin >> h >> a;
  if (h % a == 0)
    cout << h / a;
  else
    cout << h / a + 1;
}



Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N;
string S;

void solve() {
    //cout.precision(10);
    cin >> N >> S;
    S.push_back('#');
    int ans = 0;
    for(int i = 0; i + 1 < S.size(); i++) {
        if(S[i] != S[i+1]) ans++;
    }
    cout << ans << endl;
    return;
}

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


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

int main(){
  int x, y;
  cin >> x >> y;
  if(x*4<y||y%2==1) {
    cout<<"No"<<endl;
    return 0;
  }
  if(y/2-x<0 || 2*x + y/2 < 0) {
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	int N, num = 0, ans=0, n;
	cin >> N;
	REP(i, 0, N){
		cin >> n;
		if(n == ans+1) ++ans;
		else ++num;
	}
	cout << (ans==0?-1:num);

}


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

using namespace std;

int main() {
	string S;
	string T;
	cin >> S >> T;
	vector<int> s(S.size() + 1);
	vector<int> t(T.size() + 1);
	int count = 0;
	for (int i = 0; i < s.size(); i++) {
		s[i] = count;
		if (i< S.size()) {
			if (S[i] == 'A')count++;
			else count += 2;
		}
	}
	count = 0;
	for (int i = 0; i < t.size(); i++) {
		t[i] = count;
		if (i < T.size()) {
			if (T[i] == 'A')count++;
			else count += 2;
		}
	}
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		if ((s[b] - s[a - 1] -( t[d] - t[c - 1]) %3+3)%3==0)cout << "YES" << endl;
		else cout << "NO" << endl;

	}
}

Measured memory_bytes: 1792
#define  _USE_MATH_DEFINES

#define  rep(i, n) for(int i = 0; i < n; i++)
#define  repx(i, a, n) for(int i = a; i < n; i++)
#define  loop while(1)
#define  lli long long int
#define  aryout(ary) rep(i, ary.size()) cout << ary[i] << (i < ary.size() - 1 ? " " : "\n");
#define  arysort(v) sort(v.begin(), v.end())
#define  aryreverse(v) reverse(v.begin(),v.end())
#define  arysum(v) accumulate(v.begin(), v.end(), 0)
 
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <utility>
#include <set>

using namespace std;

int main() {

  int n, w;
  cin >> n >> w;

  vector<vector<lli>> dp(n+1, vector<lli>(w+1, 0));
  vector<pair<int, int>> trs(n); //{weight, value}

  rep (i, n) {
    pair<int, int> tmp;
    cin >> tmp.first >> tmp.second;
    trs[i] = tmp;
  }
  //rep(i, n) cout << trs[i].first << " " << trs[i].second << endl;

  repx (var, 1, n+1) {
    repx (hor, 1, w+1) {
      if (trs[var-1].first > hor) {
        dp[var][hor] = dp[var-1][hor];
      } else {
        lli tmp1 = dp[var-1][hor-(trs[var-1].first)] + trs[var-1].second;
        lli tmp2 = max(dp[var-1][hor], dp[var][hor-1]);
        dp[var][hor] = max(tmp1, tmp2);
      }
      //cout << "#####" << endl;
      //rep(i, n+1) rep(j, w+1) cout << dp[i][j] << (j == w ? "\n" : " ");
    }
  }
  cout << dp[n][w] << endl;
  return 0;
}


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

int main(){
int A,B,C,X;
  cin>>A>>B>>C>>X;
  
  int count=0;
  for(int a=0; a<=A; a++){
   for(int b=0; b<=B; b++){
    for(int c=0; c<=C; c++){
     if(500*a+100*b+50*c==X){count++;}
    }
   }
  }
  cout<<count;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    list<int> l;
    string s;
    int x;
    for(int i = 0; i < n; ++i){
        cin >> s;
        if(s == "insert"){
            cin >> x;
            l.push_front(x);
        } else if(s == "delete"){
            cin >> x;
            list<int>::iterator it = find(l.begin(),l.end(),x);
            if(it != l.end()){
                l.erase(it);
            }
        } else if(s == "deleteFirst"){
            l.pop_front();
        } else if(s == "deleteLast"){
            l.pop_back();
        }
    }
    
    for(list<int>::iterator it = l.begin(); it != l.end(); ++it){
        if(it != l.begin()) cout << ' ';
        cout << *it;
    }
    cout << endl;
}

Measured memory_bytes: 32476
#include<bits/stdc++.h>
#define ll long long int
#define ff first
#define ss second
#define eps 1e-9

using namespace std;

int main()
{

    ll t,n,m,f,a,b,c,l,r,q,k,x,y,z,ans,mn,mx,sum=0;
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    cin>>x>>n;

    set<ll> st;

    for(int i=0;i<n;i++)
    {
        cin>>y;
        st.insert(y);
    }
    c=x;
    while(1)
    {

        if(st.count(c)==0)
        {
            mn=c;
            break;
        }
        c--;
    }

    c=x;
    while(1)
    {

        if(st.count(c)==0)
        {
            mx=c;
            break;
        }
        c++;
    }
    c=x;
    if(abs(c-mn) == abs(c-mx))
    {
        cout<<min(mn,mx)<<endl;
    }
    else if(abs(c-mn) < abs(c-mx))
    {
        cout<<mn<<endl;
    }
    else
    {
        cout<<mx<<endl;
    }


}


Measured memory_bytes: 3556
function Main(input) {
  input = input.trim()
  input = input.split(" ").map(Number);
if(input[0]%3==0||input[1]%3==0||(input[1]+input[0])%3==0){
console.log("Possible");
}else{
console.log("Impossible")
}
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(){
  int n;
  cin >> n;
  int t[n];
  for(int i = 0;i < n;i++){
    cin >> t[i];
  }
  int m;
  cin >> m;
  int a[m];
  int b[m];
  for(int i = 0;i < m;i++){
    cin >> a[i];
    cin >> b[i];
    int ans = 0;
    for(int j = 0;j < n;j++){
      if(j == a[i]-1){
        ans += b[i];
      }else{
        ans += t[j];
      }
    }
    cout << ans << endl;
  }

}


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

using namespace std;

struct SuffixArray
{
    int sz;
    string s;
    vector<int> rank,sa;

    SuffixArray(string str){
        s=str;
        sz=str.length();
        rank.resize(sz+1);
        sa.resize(sz+1);
        build();
    }

    void build(){
        for(int i=0;i<=sz;i++){
            sa[i]=i;
            rank[i]=i<sz?s[i]:-1;
        }

        int k;
        auto compare = [&](int i, int j) {
            if (rank[i] != rank[j]) return rank[i] < rank[j];
            else {
                int ri = i + k <= sz ? rank[i + k] : -1;
                int rj = j + k <= sz ? rank[j + k] : -1;
                return ri < rj;
            }
        };

        vector<int> tmp(sz+1);
        for(k=1;k<=sz;k*=2){
            sort(sa.begin(),sa.end(),compare);
            tmp[sa[0]]=0;
            for(int i=1;i<=sz;i++){
                tmp[sa[i]]=tmp[sa[i-1]]+(compare(sa[i-1],sa[i])?1:0);
            }
            for(int i=0;i<=sz;i++){
                rank[i]=tmp[i];
            }
        }
    }
    bool contains(string t){
        int l=0,r=sz;
        while(r-l>1){
            int mid=(l+r)/2;
            if(s.substr(sa[mid],t.length())<t) l=mid;
            else r=mid;
        }
        return s.substr(sa[r],t.size()) ==t;
    }
    void print(){
        for(int i=0;i<sz;i++){
            cout<<s.substr(sa[i])<<endl;
        }
    }
};

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

    string t;cin>>t;
    int q;cin>>q;
    SuffixArray sf(t);
    //sf.print();
    for(int i=0;i<q;i++){
        string p;cin>>p;
        cout<<sf.contains(p)<<endl;
    }
}

Measured memory_bytes: 16500
N, M = gets.split.map(&:to_i)

def to_bits(c)
  ret = 0
  c.each do |n|
    n -= 1
    ret += 2 ** n
  end
  ret
end

AC = M.times.map do
  a, b = gets.split.map(&:to_i)
  c = gets.split.map(&:to_i)
  [a, to_bits(c)]
end

INF = 1 << 60
FIN = (1 << N) - 1
def dfs(state, dp)
  return dp[state] if dp[state]
  return dp[state] = 0 if state == FIN
  ret = INF
  AC.each do |a, c|
    if state | c != state
      cost = dfs(state | c, dp) + a
      ret = cost if cost < ret
    end
  end
  dp[state] = ret
end

dp = Array.new(1 << N)
ans = dfs(0, dp)
if ans == INF
  puts -1
else
  puts ans
end

Measured memory_bytes: 4220