akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using Pi_i = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
using VLL = vector<ll>;
using VS = vector<string>;
using VC = vector<char>;
using VB = vector<bool>;

const int MOD = 1000000007;
const int INF = 1000000000;

template<class T>
bool chmax(T &a, const T &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T>
bool chmin(T &a, const T &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}


bool linearSearch(VI &t, int key){
    int n = SZ(t);
    if(key == t[n-1]) return true;
    int tmp = t[n-1]; t[n-1] = key;
    int i = 0;
    while(t[i] != key){
        ++i;
    }
    t[n-1] =  tmp;
    if(i < n-1) return true;
    return false;

}

int main(){
    int n, cnt = 0; cin >> n;
    VI S(n);
    REP(i, n) cin >> S[i];
    int q; cin >> q;
    VI T(q);
    REP(i, q) cin >> T[i];
    REP(i, q){
        if(linearSearch(S, T[i])) ++cnt;
    }
    cout << cnt << "\n";
    return 0;
}



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

int main(){
    int m, n;
    while(cin >> m >> n && m){
        const int X = 7368791;
        static int ok[X + 10];
        memset(ok, 0, sizeof ok);
        for(int i = m, c = 0; c < n; ++i){
            if(ok[i]) continue;
            ++c;
            for(int j = i; j <= X; j += i) ok[j] = true;
        }
        int ans = 0;
        while(ok[m+ans]) ++ans;
        cout << ans+m << endl;
    }
}

Measured memory_bytes: 31852
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int MOD = 998244353;

int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	if(k == 1) printf("%d\n", 0);
	else printf("%d\n", n - k);
	return 0;
}

Measured memory_bytes: 256
import sys
bingo_size = 3
a = []
an = set()
for _ in range(3):
  a.append(list(map(int, input().split())))

n = int(input())
b = set()
for _ in range(n):
  bi = int(input())
  b.add(bi)

for hi in range(3):
  ok = True
  for _ in range(3):
    if a[hi][_] not in b:
      ok = False
      
  if ok:
    print("Yes")
    sys.exit()

for wi in range(3):
  ok = True
  for _ in range(3):
    if a[_][wi] not in b:
      ok = False
      
  if ok:
    print("Yes")
    sys.exit()

if all([a[0][0] in b, a[1][1] in b, a[2][2] in b]) or all([a[0][2] in b, a[1][1] in b, a[2][0] in b]):
           print("Yes")
           sys.exit()
           
print("No")   

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i,a) for(int i = 0;i < (a); i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)
#define repd(i,a,b) for(int i = (a); i >= (b); i--)
#define repit(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)
#define all(u) (u).begin(),(u).end()
#define rall(u) (u).rbegin(),(u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)),(u).end())
#define pb push_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define PI acos(-1.0)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef complex<double> P;
typedef vector<P> G;

/* 円 */
struct C {
    P p; double r;
    C() : p(0), r(0) {}
    C(const P &p, double r) : p(p), r(r) { }
};

bool intersectCC(const C &c, const C &d){
    return (norm(c.p - d.p) - (c.r + d.r)*(c.r + d.r) < -EPS);
}

int ans, n;
set<int> done;
vi E[32];
vector<C> cir;
vi col;

void input(){
    rep(i,n){
	int x, y, r, c;
	cin >> x >> y >> r >> c;
	cir.pb(C(P(x,y),r));
	col.pb(c);
    }
}

void init(){
    ans = 0;
    done.clear();
    cir.clear();
    col.clear();
    rep(i,32) E[i].clear();
    return;
}

void make_edge(){
    rep(i,n)repi(j,i+1,n)
	if(intersectCC(cir[i],cir[j])){
//	    cerr << i << ' ' << j << endl;
	    E[j].pb(i);
	}
    return;
}

void saiki(int S){
    if(done.find(S) != done.end()) return;
    done.insert(S);
    bool naiyo = true;
    rep(i,n)repi(j,i+1,n)if(((S>>i)&1) && ((S>>j&1)) && (col[i] == col[j])){
	bool ok = true;
	rep(a,E[i].size())if((S>>E[i][a])&1){
	    ok=false;
	    break;
	}
	if(!ok) continue;
	ok = true;
	rep(a,E[j].size())if((S>>E[j][a])&1){
	    ok=false;
	    break;
	}
	if(!ok) continue;
/*
	cerr << "hoge\n";
	cerr << i << " " << j << endl;
*/
	saiki(S^(1<<i)^(1<<j));
	naiyo = false;
    }
    if(naiyo){
	int cnt = 0;
	rep(i,n)if((S>>i)&1)cnt++;
	ans = max(ans, n-cnt);
    }
    return;
}

int main() {
    while(cin >> n, n){
	init();
	input();
	make_edge();
	saiki((1<<n)-1);
	cout << ans << endl;
    }
    return 0;
}

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

int main(){
  int a, b ,c;
  cin >> a >> b >> c;
  if(a==b && b==c){
    cout << "1" << endl;
    return 0;
  }else if((a==b && b!=c) || (a==c && a!=b) || (b==c && a!=b)){
    cout << "2" << endl;
    return 0;
  }
  cout << "3" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;

int main(){
    string s;cin>>s;
    int n =s.length();
    reverse(been(s));
    vi ama(2019,0),sum(n+1,0);
    ll now =0;
    int p =1;
    rep(i,n){
        int a =s[i]-'0';
        a*=p;
        a%=2019;
        sum[i+1]=sum[i]+a;
        sum[i+1]%=2019;
        p*=10;
        p%=2019;
    }
    rep(i,n+1){
        ama[sum[i]]++;
    }
    ll ans =0;
    rep(i,2019){
        ans+=(ama[i]*(ama[i]-1))/2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4404
from numba import njit
import numpy as np


def cc_export():
    @njit('(i8, i8, i8[:], i8[:], i8[:], i8)')
    def update(n, w, que, there, cost, pos):
        que[0] = pos
        i, l = 0, 1
        while i < l:
            pos = que[i]
            i += 1
            c = cost[pos]
            t = there[pos]
            k = c + t
            for df in (-w, w, -1, 1):
                pp = pos + df
                if cost[pp] > k:
                    cost[pp] = k
                    que[l] = pp
                    l += 1

    @njit('(i8, i8[:])')
    def main(n, p):
        w = n + 2
        que = np.zeros(4 * w * w, dtype=np.int64)
        there = np.ones(w * w, dtype=np.int64)
        # there = np.array([
        #     1 if 1 <= i and i <= n and 1 <= j and j <= n else 0
        #     for j in range(w) for i in range(w)
        # ],
        #                  dtype=np.int64)
        cost = np.array([
            -1 if i == 0 or i == n + 1 or j == 0 or j == n + 1 else min(
                i - 1, n - i, j - 1, n - j) for j in range(w) for i in range(w)
        ],
                        dtype=np.int64)

        ans = 0
        for pos in p:
            # v = list(map(lambda x: ' ' if x == 0 else '*', list(there)))
            # for i in range(w):
            #     print(' '.join(v[i * w:(i + 1) * w]))
            # print(cost.reshape((w, w)))
            # print("add", cost[pos], "for", divmod(pos, w))
            ans += cost[pos]
            there[pos] = 0
            update(n, w, que, there, cost, pos)
        return ans

    from numba.pycc import CC
    cc = CC('solution')
    cc.export('update', '(i8, i8, i8[:], i8[:], i8[:], i8)')(update)
    cc.export('main', '(i8, i8[:])')(main)
    cc.compile()


if __name__ == '__main__':
    import sys
    if sys.argv[-1] == 'ONLINE_JUDGE':
        cc_export()
        sys.exit(0)

    def transform(t):
        y, x = divmod(int(t) - 1, n)
        return (y + 1) * (n + 2) + (x + 1)

    from solution import update, main
    n = int(input())
    p = np.array(list(map(transform, input().split())), dtype=np.int64)
    print(main(n, p))


Measured memory_bytes: 120968
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>

#define mod 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define PB push_back

using namespace std;

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

int main(){
    int N;
    cin>>N;
    bool visited[10001]={};
    queue<int> visit;
    vector <int> ans(N);

    map<int, vector<int>> m;
    int a,b;
    rep(i,0,N-1){
        cin>>a>>b;
        m[a].PB(b);
        m[b].PB(a);
    }

    vector<int> c(N);
    rep(i,0,N){
        cin>>c[i];
        c[i]*=-1;
    }
    sort(c.begin(),c.end());
    rep(i,0,N)c[i]*=-1;

    //計算

    visited[1]=true;
    visit.push(1);
    int now,until=0;
    while(!visit.empty()){
        now=visit.front();
        visit.pop();
        ans[now-1]=c[until];
        rep(i,0,m[now].size()){
            if(!visited[m[now][i]]){
                visited[m[now][i]]=true;
                visit.push(m[now][i]);
            }
        }
        until++;
    }
    long long sum=0;
    rep(i,1,N)sum+=c[i];

    cout<<sum<<endl;
    rep(i,0,N)cout<<ans[i]<<" ";
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define mem(dp,a) memset(dp,a,sizeof(dp))
#define pb(x) push_back(x)
#define m_p(x,y) make_pair(x,y)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repush_back(i,a,b) for(ll i=a;i>=b;i--)
#define f(n) for(ll i=0;i<n;i++)
#define r(n) for(ll j=0;j<n;j++)
#define F first
#define S second
#define pi 3.14159265359
#define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int ll;
ll HRX=1e18;
ll INF=1e9+7;

int main()
{
 hs;
 ll x,n;
 cin>>x>>n;
 if(x<n)
    cout<<"0"<<endl;
 else
    cout<<"10"<<endl;
 return 0;
}

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

const int limit = 50;

int n,m;
int a[limit], b[limit];

bool graph[limit][limit];
bool visited[limit];

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


int main(){
    cin >> n >> m;
    for(int 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;
    }

    int ans = 0;

    for(int i = 0; i < m; i++){
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

        for(int j = 0; j < n; j++) visited[j] = false;

        dfs(0);

        bool bridge = false;
        for(int j = 0; j < n; j++) if(visited[j] == false) bridge = true;
        if(bridge) ans += 1;

        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;

    }

    cout << ans << endl;
}

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

int main() {
	int N, A[100], v, j;
	cin >> N;
	for (int i = 0; i < N; i++)cin >> A[i];
	for (int i = 0; i < N; i++) {
		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		for (int j = 0; j < N - 1; j++)cout << A[j] << " ";
		cout << A[N - 1] << endl;
	}

	return 0;
}

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

char chess(int h, int w){
    if((h+w)%2 == 0){
        return '#';
    }
    return '.';
}

int main(void){
    int H,W;
    while(true){
    cin >> H >> W;
    if(H == 0 && W == 0){
        break;
    }
    for(int j = 0; j < H; j++){
        for(int i = 0; i < W; i++){
            cout << chess(i,j) ;
        }
        cout << endl;
    }
    cout << endl;
    }
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define allof(a) (a).begin(),(a).end()

void uniqueVector(vector< int >& vec) {
	sort(allof(vec));
	vec.erase(unique(allof(vec)), vec.end());
}

void solve(
	int n, int m,
	const vector< int >& tx, const vector< int >& ty
	) {
	vector< int > x_sort = tx, y_sort = ty;
	uniqueVector(x_sort);
	uniqueVector(y_sort);
	
	vector< vector< int > > imos(n + 1, vector< int >(n + 1, 0));
	for_(i,0,n) {
		int x = lower_bound(allof(x_sort), tx[i]) - x_sort.begin() + 1;
		int y = lower_bound(allof(y_sort), ty[i]) - y_sort.begin() + 1;
		++imos[y][x];
	}
	
	for_(y,0,n+1) for_(x,0,n) imos[y][x + 1] += imos[y][x];
	for_(x,0,n+1) for_(y,0,n) imos[y + 1][x] += imos[y][x];
	
	for_(i,0,m) {
		int lft, bot, rgt, top;
		scanf("%d %d %d %d", &lft, &bot, &rgt, &top);
		
		int lx = lower_bound(allof(x_sort), lft) - x_sort.begin() + 1;
		int by = lower_bound(allof(y_sort), bot) - y_sort.begin() + 1;
		int rx = upper_bound(allof(x_sort), rgt) - x_sort.begin();
		int ty = upper_bound(allof(y_sort), top) - y_sort.begin();
		
		printf("%d\n", imos[ty][rx] - imos[ty][lx - 1] - imos[by - 1][rx] + imos[by - 1][lx - 1]);
	}
}

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	
	vector< int > tx(n), ty(n);
	for_(i,0,n) scanf("%d %d", &tx[i], &ty[i]);
	
	solve(n, m, tx, ty);
}

Measured memory_bytes: 100792
#include<bits/stdc++.h>
using namespace std;
typedef pair< int, int > Pi;

int main() {
  int N;
  double R;
  set< Pi > sets;
  scanf("%d %lf", &N, &R);
  for(int i = 0; i < N; i++) {
    double A, B;
    scanf("%lf %lf", &A, &B);
    sets.insert(make_pair((A + 1e6) / R, (B + 1e6) / R));
  }
  int ret = 0;
  while(!sets.empty()) {
    ++ret;
    set< Pi >::iterator it1 = sets.begin();
    for(int i = -1; i <= 1; i++) {
      for(int j = -1; j <= 1; j++) {
        if(i == 0 && j == 0) continue;
        set< Pi >::iterator it2 = sets.find(make_pair(it1 -> first + i, it1 -> second + j));
        if(it2 != sets.end()) {
          sets.erase(it2);
        }
      }
    }
    sets.erase(it1);
  }
  printf("%d\n", ret);
}

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

int main()
{
	int num[3];
	int temp;

	for (int i = 0; i < 3; i++) cin >> num[i];

	for (int i = 0; i < 3; i++){
		for (int j = i; j < 3; j++){
			if (!(num[i] <= num[j])){
				temp = num[i];
				num[i] = num[j];
				num[j] = temp;
			}
		}
	}

	for (int i = 0; i < 3; i++){
		cout << num[i];
		if (i == 2){
			cout << '\n';
			break;
		}
		cout << ' ';
	}

	return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 0
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_W 15
#define MAX_H MAX_W

#define FAKE_ANS

ll W, H;
vector<string> S;

// 列の入れ替えのみで点対象にできるなら true
bool CheckCol(const vector<string>& s) {
    bool isUsedMapped[MAX_W] = {};
    bool isUsedS[MAX_W] = {};
    bool isFind = false;
    ll mapped_ind_head = 0;
    ll mapped_ind_tail = W-1;
    ll dbg_cnt = 0;
    REP(i, W) {
        if(isUsedS[i]) { continue; }
        isFind = false;
        isUsedS[i] = true;
        // i 列を上下反転したような列 j を探す
        REP(j, W) {
            if(isUsedS[j]) { continue; }
            bool isRev = true;
            REP(k, H) {
                if(s[k][i] != s[H-1-k][j]) { isRev = false; break; }
            }
            // 上下反転があった
            if(isRev) {
                DBG("%lld %lld is pair.\n", i, j);
                isUsedS[j] = true;
                isUsedMapped[mapped_ind_head] = true;
                isUsedMapped[mapped_ind_tail] = true;
                mapped_ind_head++;
                mapped_ind_tail--;
                dbg_cnt += 2;
                isFind = true;
                break;
            }
        }
        if(!isFind) {
            DBG("%lld is not pair.\n", i);
            // 上下反転がなかった
            if(W % 2 == 0) {
                return false;
            }
            else {
                // 奇数なら、列が上下対象なら真ん中に置ける
                bool isSym = true;
                REP(j, H / 2) {
                    if(s[j][i] != s[H-1-j][i]) { isSym = false; break; }
                }
                if(isSym && !isUsedMapped[W / 2]) {
                    DBG("  But can mapped %lld\n", W / 2);
                    isUsedMapped[W / 2] = true;
                    dbg_cnt++;
                } else {
                    return false;
                }
            }
        }
    }
    assert(dbg_cnt == W);
    return true;
}

signed main()
{
    cin >> H >> W;
    REP(i, H) {
        string tmp_s;
        cin >> tmp_s;
        S.push_back(tmp_s);
    }

#ifdef FAKE_ANS
    // 簡易チェック
    if(CheckCol(S)) {
        printf("YES\n");
        return 0;
    }
    // ランダムに行をシャッフル
    random_device r;
    mt19937 mt(r());
    REP(i, 1000000) {
        vector<string> sh;
        REP(j, H) { sh.push_back(S[j]); }
        shuffle(sh.begin(), sh.end(), mt);
        if(CheckCol(sh)) {
            printf("YES\n");
            return 0;
        }
    }
    printf("NO\n");
    return 0;
#else
    // 行のペアを作成
#endif
    return 0;
}


Measured memory_bytes: 256
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)


a,b,c,d=map(int,input().split())
e=lcm(c,d)

n=(b//c)-((a-1)//c)
m=(b//d)-((a-1)//d)
o=(b//e)-((a-1)//e)



print(b-a+1-n-m+o)

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in();
	REP(i,N){
		int v=in();
		if(v%2){
			out("first");
			return 0;
		}
	}
	out("second");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct node
{
    int x;
    int y;
}a1[100005];
bool cmp(node a,node b)
{
    if(a.y==b.y)
        return a.x<b.x;
    return a.y<b.y;
}
int main()
{
    int a, b;
    int min1=1000000;
    cin>>a>>b;
    int ans=1;
    for(int i=0;i<b;i++)
    {
        cin>>a1[i].x>>a1[i].y;
        min1=min(min1,a1[i].y);
    }
    sort(a1,a1+b,cmp);
    for(int i=0;i<b;i++)
    {
        if(a1[i].x>=min1)
            {
                ans++;
                min1=a1[i].y;
            }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ErraticSleepHabits solver = new ErraticSleepHabits();
        try {
            int testNumber = 1;
            while (true)
                solver.solve(testNumber++, in, out);
        } catch (UnknownError e) {
            out.close();
        }
    }

    static class ErraticSleepHabits {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            final int INF = (int) 1e9;
            int T = in.nextInt();
            if (T == 0) {
                throw new UnknownError();
            }
            int[] t = new int[T]; // cycle
            for (int i = 0; i < T; i++) {
                t[i] = in.nextInt();
            }
            int N = in.nextInt();
            int[] d = new int[101];
            Arrays.fill(d, INF);
            for (int i = 0; i < N; i++) {
                int day = in.nextInt() - 1;
                d[day] = Math.min(d[day], in.nextInt());
            }
            final int MAX_DAY = 100;
            int[][] dp = new int[MAX_DAY][T];
            for (int i = 0; i < MAX_DAY; i++) {
                Arrays.fill(dp[i], INF);
            }
            dp[0][0] = 0;
            for (int i = 0; i < MAX_DAY - 1; i++) {
                for (int j = 0; j < T; j++) {
                    if (dp[i][j] < INF) {
                        int nxtCycle = (j + 1) % T;
                        if (t[nxtCycle] <= d[i + 1]) {
                            // サイクルリセットしない
                            dp[i + 1][nxtCycle] = Math.min(dp[i + 1][nxtCycle], dp[i][j]);
                        }
                        if (t[0] <= d[i + 1]) {
                            // サイクルリセットする
                            dp[i + 1][0] = Math.min(dp[i + 1][0], dp[i][j] + 1);
                        }
                    }
                }
            }
            int ans = 100;
            for (int i = 0; i < T; i++) {
                ans = Math.min(ans, dp[MAX_DAY - 1][i]);
            }
            out.println(ans);
        }

    }
}




Measured memory_bytes: 31900
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let [n;m] = reads int
    let lrs = List.map (fun _ -> reads int |> fun [l;r] -> (l, r)) [1..m]
    let a = Array.create (n + 2) 0

    for (l, r) in lrs do
        a.[l] <- a.[l] + 1
        a.[r + 1] <- a.[r + 1] - 1

    Array.scan (+) 0 a
    |> Array.filter ((=) m)
    |> Array.length
    |> printfn "%i"

    0

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

int main() {
    int N;
    cin >> N;
    vector<int> b(N);
    for(int i = 0; i < N; i++)cin >> b.at(i);

    bool c = true;
    for(int i = 0; i < N; i++)
    {
        if(b.at(i) > (i+1)){
            c = false; break;
        }
    }
    
    if(!c)cout << -1 << endl;
    else {
        vector<int> left(N, 0);

        for(int i = 0; i < N; i++)
        {
            left.at(i) = i+1 - b.at(i);
        }

        vector<int> right(N, 0);

        vector<int> ans(N, 0);

        for(int i = N-1; i >=0; i--)
        {
              int j = 0;
             while(ans.at(N - left.at(i)-1-j) > 0 || right.at(N - left.at(i)-1-j) != j){
                j++;
                if(N - left.at(i)-1 - j < 0){
                    cout << -1 << endl; return 0;;
                }
            }

            ans.at(N - left.at(i)-1-j) = b.at(i);

            for(int k = 0; k < N - left.at(i)-1-j; k++)right.at(k)++;
            
        }

            for(int i = 0; i < N; i++)
            {
                cout << ans.at(i) << endl;
            }
            
     }
        return 0;
        
}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

#define All(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

int main(){
   int a,b,c,x;
   cin >> a >> b >> c >> x;
   int ans = 0;
   for(int i=0;i<=a;i++){
      for(int j=0;j<=b;j++){
         for(int k=0;k<=c;k++){
            if(500*i+100*j+50*k == x)ans++;
         }
      }
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_set>
#include <unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
constexpr int MAXN = (1 << 20) + 5;
constexpr int MOD = 1e9 + 7;
constexpr double eps = 1e-6;
constexpr int INF = 1e9 + 7;
int dir[4][2] = { { -1,0 },{ 0,1 },{ 1,0 },{ 0,-1 } };

int a[200050], b[200050];
int main()
{
	//freopen("in.in", "r", stdin);&
	//freopen("out.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		cin >> b[i];

	sort(a, a + n);
	sort(b, b + n);
	int ans = 0;
	for (int v = (1 << 28); v > 0; v >>= 1)
	{
		for (int i = 0; i < n; i++)
		{
			a[i] &= (2*v - 1);
			b[i] &= (2*v - 1);
		}
		sort(a, a + n);
		sort(b, b + n);
		int cnt = 0;
		for (int i = 0; i < n; i++)
		{
			auto _u = lower_bound(b, b + n, v-a[i]);
			auto _v = lower_bound(b, b + n, 2 * v-a[i]);
			auto _w = lower_bound(b, b + n, 3 * v-a[i]);
			auto _x = lower_bound(b, b + n, 4 * v-a[i]);
			cnt += (_x - _u) + (_v - _w);
		}
		//cout << cnt << endl;
		if (cnt % 2)
			ans += v;
	}
	cout << ans << endl;

	//system("pause");
	return 0;
}

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

int a[37] = {0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k;

int main()
{
	cin >> k;
	cout << a[k];
	return 0;
}

Measured memory_bytes: 256
k,n = map(int, input().split())
a = list(map(int, input().split()))
dis = [0]*n
for i in range(n):
    if i == n-1:
        dis[i] = k + a[0] - a[i]
    else:
        dis[i] = a[i+1] - a[i]

print(k - max(dis))

Measured memory_bytes: 77388
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

int main(){

  string o, e;
  cin >> o >> e;
  for (int i = 0; i < o.size() - 1; i++){
    cout << o[i];
    cout << e[i];
  }
  if (o.size() == e.size()){
    cout << o[o.size() - 1];
    cout << e[e.size() - 1];
  }
  else {
    cout << o[o.size() - 1];
  }
  cout << endl;

  return 0;
}


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

#ifdef LOCAL
        #include "debug.h"
        #define input freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#else
        #define debug(...) 4
        #define input 4
#endif

using ll = long long;
const int N = 2e5+ 5;
const int mod = 1e9 + 7;


int ans = 0;
    
int32_t main() {
    input;
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        if(i % 2) {
            if(x % 2)
                ans++;
        }
    }
    cout << ans;
}



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

using pii = pair <int, int>;

#define N 300000

int n, m;
int dp[N], val[N], w[N];

int D, Q;

vector <pii> can[N];

void query(int &ans, int v, int L, int cur) {
    if (L < 0) return;
	if (v <= m) {
		ans = max(ans, cur + (--lower_bound(can[v].begin(), can[v].end(), pii(L + 1, 0))) -> second);
		return;
	}
	query(ans, v >> 1, L, cur);
	query(ans, v >> 1, L - w[v], cur + val[v]);
	return;
}

int main() {
	D = 10;
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++) scanf("%d %d", &val[i], &w[i]);
	dp[1] = 0;
	for (int i = 2; i <= n; i ++) dp[i] = dp[i>>1] + 1;
	m = min(n, (1<<D) - 1);
	can[0] = {{0, 0}};
	for (int i = 1; i <= m; i ++) {
		auto &res = can[i];
		auto &from = can[i>>1];
		vector <pii> tmp;
		tmp = from;
		for (auto x : from) {
			tmp.emplace_back(x.first + w[i], x.second + val[i]);
		}
		sort(tmp.begin(), tmp.end());
		for (auto x : tmp) {
			if (!res.empty() && res.back().second >= x.second) continue;
			res.push_back(x);
		}
	}
	scanf("%d", &Q);
	while (Q --) {
		int v, L, ans = 0;
		scanf("%d %d", &v, &L);
		query(ans, v, L, 0);
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 19284
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main() {
    int X, A, B;
    cin >> X >> A >> B;
    if(-A + B <= 0) cout << "delicious" << endl;
    else if(-A + B <= X) cout << "safe" << endl;
    else cout << "dangerous" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define TRACE
#define M 1000000007
#define oo 1000000000000000007
#define F first
#define S second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
#define pb push_back
#define M6 5000009
#define M5 100009
#define pi 3.14159265
#define epsilon 1e-6

#ifdef TRACE
    #define trace1(x)                cerr << #x << ": " << x << endl;
    #define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
    #define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
    #define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
    #define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
    #define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
#else
 
    #define trace1(x)
    #define trace2(x, y)
    #define trace3(x, y, z)
    #define trace4(a, b, c, d)
    #define trace5(a, b, c, d, e)
    #define trace6(a, b, c, d, e, f)
 
#endif

ll n,m,A[M6],F[M6];
int  main()
{   //ios_base::sync_with_stdio (0), cin.tie (0);
    //sieve();
    //init();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll tc=1,t=0,i,j,k,a,b,c,d,l,r;
    //cin>>tc;
    while(t++<tc){
//        cout<<"Case #"<<t<<": ";
        cin>>n;
        cout<<n*(n-1)/2;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define L long long
using namespace std;
int n,m,t,a[100010],b[100010],x[100010],w[100010];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k;
	scanf("%d%d%d",&n,&m,&t);
	for(i=1;i<=n;i++)
	  {
       scanf("%d%d",&a[i],&b[i]);
       if(b[i]==1)
         x[i]=(a[i]+t)%m;
       else
         x[i]=((a[i]-t)%m+m)%m;
      }
    j=x[1];
    sort(x+1,x+n+1);
    for(i=2,k=0;i<=n;i++)
      if(b[i]!=b[1])
        if(b[1]==1)
          {
           if((a[i]-a[1]+m)%m<2*t)
             k=(k+(2*t-(a[i]-a[1]+m)%m-1)/m+1)%n;
          }
        else
          if((a[1]-a[i]+m)%m<=2*t)
            k=(k-(2*t-(a[1]-a[i]+m)%m)/m-1)%n;
    k=(k+n)%n+1;
    for(i=1;i<=n;i++)
      if(x[i]==j)
        break;
    for(j=i;;j=j%n+1,k=k%n+1)
      {
       w[k]=x[j];
       if(j%n+1==i)
         break;
      }
    for(i=1;i<=n;i++)
      printf("%d\n",w[i]);
	return 0;
}


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

int main(){
  string s,t,u;
  int a,b;
  cin>>s>>t>>a>>b>>u;
  if(s==u)
    cout<<a-1<<' '<<b<<endl;
  else
    cout<<a<<' '<<b-1<<endl;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	int score;
	std::cin >> score;
	if (score < 1200) {
		std::cout << "ABC" << '\n';
	}
	else if (score < 2800) {
		std::cout << "ARC" << '\n';
	}
	else  {
		std::cout << "AGC" << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0077
"""
import sys




def expand(data):
    result = []
    skip_count = 0
    for i in range(len(data)):
        if skip_count:
            skip_count -= 1
        else:
            if data[i] == '@':
                skip_count = 2
                num = int(data[i+1])
                c = data[i+2]
                result.append(c*num)
            else:
                result.append(data[i])
    return (''.join(result))



def main(args):
    for line in sys.stdin:
        result = expand(line.strip())
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

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

int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  if(4*a*b<(c-a-b)*(c-a-b) && (c-a-b)>0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

using namespace std;

using button_t = std::pair<int, int>;

int64_t solve(const std::vector<button_t>& buttons) {
  int64_t ret = 0;
  for (auto itr = buttons.crbegin(); itr != buttons.crend(); itr++) {
    auto const a = itr->first;
    auto const b = itr->second;
    ret += (b - (a + ret) % b) % b;
  }
  return ret;
}

int main() {
  int n;
  std::cin >> n;
  std::vector<button_t> buttons(n);
  for (auto& button : buttons) {
    std::cin >> button.first >> button.second;
  }
  std::cout << solve(buttons) << std::endl;
  return 0;
}

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

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

  int n, minNum, maxNum;

  cin >> n;

  for (int i = 0; i < n; i++)
  {
    int ai;

    cin >> ai;

    if (i == 0)
    {
      minNum = ai;
      maxNum = ai;
    }
    else
    {
      minNum = min(minNum, ai);
      maxNum = max(maxNum, ai);
    }
  }

  cout << maxNum - minNum << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define ll long long
#define rep(i,j,k) for (i=j;i<=k;i++)
#define down(i,j,k) for (i=j;i>=k;i--)
using namespace std;
const int N=1e5+5,INF=1e9,mod=1e9+7;
int n,i,j,ra[N],rb[N],la[N],lb[N];
ll A,B,s[N];
int f[N],g[N];
void updata(int &x,int y) { x+=y; if (x>=mod) x-=mod; }
int main()
{
	//freopen("division.in","r",stdin);
	//freopen("division.out","w",stdout);
	scanf("%d%lld%lld",&n,&A,&B);
	rep(i,1,n) scanf("%lld",&s[i]);
	s[n+1]=INF; ra[n]=rb[n]=ra[n+1]=rb[n+1]=n+1;
	down(i,n-1,1)
	{
		if (abs(s[i+1]-s[i])<A) ra[i]=i; else ra[i]=ra[i+1];
		if (abs(s[i+1]-s[i])<B) rb[i]=i; else rb[i]=rb[i+1];
	}
	rep(i,1,n)
	{
		la[i]=max(la[i-1],i+1);
		while (la[i]<=n && abs(s[la[i]]-s[i])<A) la[i]++;
		lb[i]=max(lb[i-1],i+1);
		while (lb[i]<=n && abs(s[lb[i]]-s[i])<B) lb[i]++;
	}
	f[1]=g[1]=1;
	rep(i,1,n-1)
	{
		if (abs(s[i+1]-s[i])>=A) updata(f[i+1],f[i]);
		if (rb[i+1]>=la[i]-1) updata(g[max(i+1,la[i]-1)],f[i]);
		if (abs(s[i+1]-s[i])>=B) updata(g[i+1],g[i]);
		if (ra[i+1]>=lb[i]-1) updata(f[max(i+1,lb[i]-1)],g[i]);
	}
	printf("%d\n",(f[n]+g[n])%mod);
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

// 最大公約数
ll gcd(ll a, ll b)
{
   if (a%b == 0) {
       return(b);
   } else {
       return(gcd(b, a%b));
   }
}

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

//素数判定
bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された
    if(n % 2 == 0 || n % 3 == 0) return false;
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }
    return true;
}

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() {
    ll n, m, x; cin >> n >> m >> x;
    Vl a(m);
    rep(i, 0, m) cin >> a[i];
    ll l = 0, r = 0;
    rep(i, 0, m){
        if(a[i]<x) l++;
        else r++;
    }
    cout << min(l, r) << endl;
}

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

    solve();
    return 0;
}


Measured memory_bytes: 256
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        for _ in range(num): return []
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(map(int, input().split())) for _ in range(N)]
        return map(list,zip(*read_all))

#################

from operator import itemgetter
from bisect import bisect_left

N,Q = II()
a = []
for _ in range(N):
    s,t,x = II()
    a.append((x, s-x-0.5, t-x-0.5))
a.sort(key=itemgetter(0))
D = Line(Q,1)

ans = [-1]*(Q+1)
right = [0]*Q
for a0 in a:
    l = bisect_left(D,a0[1])
    r = bisect_left(D,a0[2])
    while l<r:
        while ans[l]!=-1:
            l = right[l]
            if l==N:
                break
        if l>=r:
            break
        ans[l] = a0[0]
        right[l] = r
        l += 1

for i in range(Q):
    print(ans[i])

Measured memory_bytes: 106588
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin>>N;
    vector<tuple<string,int,int>> a(N);
    for(int i=0;i<N;i++){
        string x;
        int b;
        cin>>x>>b;
        a.at(i)=make_tuple(x,-b,i+1);
    }
    sort(a.begin(),a.end());

    for(int i=0;i<N;i++){
    cout<<get<2>(a.at(i))<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
const int MAXN=51;
const int P=1e9+7;
int add(int a,int b)
{
	return (a+b>=P)?(a+b-P):(a+b);
}
int mul(int a,int b)
{
	return 1LL * a * b % P;
}
void upd(int &x,int y)
{
	x=add(x,y);
}
int N,K;
int f[MAXN][MAXN][MAXN*MAXN];
int main()
{
	N=read(),K=read();
	f[0][0][0]=1;
	for(int i=1;i<=N;++i)
		for(int j=0;j<=i;++j)
			for(int k=2*j;k<=K;++k)
			{
				upd(f[i][j][k],mul(2*j+1,f[i-1][j][k-2*j]));
				upd(f[i][j][k],mul(j*j+2*j+1,f[i-1][j+1][k-2*j]));
				if(j)
					upd(f[i][j][k],f[i-1][j-1][k-2*j]);
			}
	cout<<f[N][0][K]<<endl;
	return 0;
}


Measured memory_bytes: 24704
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[5];
    cin>>s;
    if(s[0]==s[1])
    {
        if(s[2]==s[3]&&s[2]!=s[0])
        {
            cout<<"Yes";
        }
        else
        {
            cout<<"No";
        }
    }
    else if(s[0]==s[2])
    {
        if(s[1]==s[3]&&s[1]!=s[0])
        {
            cout<<"Yes";
        }
        else
        {
            cout<<"No";
        }
    }
    else if(s[0]==s[3])
    {
        if(s[1]==s[2]&&s[1]!=s[0])
        {
            cout<<"Yes";
        }
        else
        {
            cout<<"No";
        }
    }
    else
    {
        cout<<"No";
    }
    return 0;
}


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

int main() {
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if (-100 > x || x > 100) {
        return 0;
    }
    if (-100 > y || y > 100) {
        return 0;
    }
    if (0 >= w || w > 100) {
        return 0;
    }
    if (0 >= h || h > 100) {
        return 0;
    }
    if (0 >= r || r > 100) {
        return 0;
    }
    if (y + r > h || y - r < 0) {
        cout << "No" << endl;
    } else if (x + r > w || x - r < 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3108
#include<stdio.h>
#define N 2000000

int A[N],a=0;

void increase(int i, int n){
  int temp;
  if(n < A[i]){
    return;
  }
  A[i] = n;
  while(i > 1 && A[i/2] < A[i]){
    temp = A[i];
    A[i] = A[i/2];
    A[i/2] = temp;
    i = i/2;
  }
}

void insert(int n){
  a++;
  A[a] = -1000000000;
  increase(a,n);
}

void maxheap(int i){
  int l,r,temp2,largest;
  l = 2 * i;
  r = 2 * i + 1;
  if(A[l] > A[i] && l <= a){
    largest = l;
  }else{
    largest = i;
  }
  if(A[r] > A[largest] && r <= a){
    largest = r;
  }

  if(largest != i){
    temp2 = A[i];
    A[i] = A[largest];
    A[largest] = temp2;
    maxheap(largest);
  }
}

int extract(){
  int m;
  if(a < 1){
    return -1000000000;
  }
  m = A[1];
  A[1] = A[a];
  a--;
  maxheap(1);
  return m;
}
  
int main(){
  int n;
  char com[20];
  while(1){
    scanf("%s",com);
    if(com[0] == 'e' && com[1] == 'n'){
      break;
    }
    if(com[0] == 'i'){
      scanf("%d",&n);
      insert(n);
    }else{
      printf("%d\n",extract());
    }
  }
  return 0;
}



Measured memory_bytes: 5600
#include <bits/stdc++.h>
#include <algorithm>
#include <queue>
using namespace std;
int main(){
	int N, K; 
	cin >> N >> K; 
	long long int X[55] = {}; 
	long long int Y[55] = {}; 
	for(int i = 0; i < N; i++){
		cin >> X[i] >> Y[i];
	}
	long long int ans = 4e18; 
	for(int l = 0; l < N; l++){
		for(int r = l+1; r < N; r++){
			for(int d = 0; d < N; d++){
				for(int u = d+1; u < N; u++){
					int count = 0; 
					for(int i = 0; i < N; i++){
						if(X[i] <= max(X[l], X[r]) && X[i] >= min(X[l],X[r]) && Y[i] <= max(Y[d],Y[u]) && Y[i] >= min(Y[d],Y[u])){
							count ++; 
						}
					if(count >= K){
						long long int area = abs(X[l] - X[r]) * abs(Y[d] - Y[u]); 
						ans = min(ans, area); 
					}
					}
				}
			}
		}
	}
	cout << ans << endl; 
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        if (A >= 10 || B >= 10) {
            System.out.println(-1);
        } else {
            System.out.println(A * B);
        }
    }
}

Measured memory_bytes: 23636
/**********************************

Sometimes the people whom no one ever imagines anything of,
do the things that no one can ever imagine.

***********************************/
#include <bits/stdc++.h>
using namespace std;

#define EPS (1e-12)
#define ll long long int
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define pi 3.141592653589
#define printa(a,L,R) for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?'\n':' ')
#define precise(n) cout << fixed << setprecision(n)
#define pcase cout<<"Case "<<++cs<<": "
const int mod=1e9+7;
ll gcd(ll a,ll b){while(b){ll x=a%b;a=b;b=x;}return a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll qpow(ll n,ll k) {ll ans=1;assert(k>=0);n%=mod;while(k>0){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}



int main()
{
      int a,b,n,i,j,k=0,cnt=0;
      string s, s1;

      cin >> s ;
      s1=s;

      for(i=0;i<s.length();i++)
      {
        if(i%2==0) {
            if(s[i]!='0') cnt++;
        }else
        {
            if(s[i]!='1') cnt++;
        }
      }
 for(i=0;i<s.length();i++)
      {
        if(i%2==0) {
            if(s[i]!='1') k++;
        }else
        {
            if(s[i]!='0') k++;
        }
      }

cout << min(cnt,k) << endl;

      return 0;
}


Measured memory_bytes: 512
s=input()

left=0
right=len(s)-1

ans=0
while left<right:
  c1=s[left]
  c2=s[right]
  if c1==c2:
    left+=1
    right-=1
    continue

  elif c1!='x' and c2!='x':
    print(-1)
    exit()
  elif c1=='x':
    ans+=1
    left+=1
  elif c2=='x':
    ans+=1
    right-=1

print(ans)

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

int main() {

	int n, p[55], a[55];

	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> p[i];
		a[i] = i;
	}
	int diff = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] != p[i])
			diff++;
	}
	cout << (diff <= 2 ? "YES" : "NO") << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    map<ll,ll> ma;
    ll n = N;
    ll ans = 0;
    for(ll i = 2;i * i <= N;i++){
        //cout << ans << endl;
        ll cnt = 0;
        if(n % i == 0){
            while(n % i == 0){
                n /= i;
                cnt++;
            }
        }
        //cout << n << "\n";
        //cout << cnt << "\n";
        if(cnt != 0){
        for(ll i = 1;i <= 10;i++){
            ll sa = i * (i + 1) / 2;
            if(cnt < sa){
                ans += i - 1;
                break;
            }
        }
        }
    }
    if(n != 1){
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620