akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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; }

int memo[200005];

int calc(int n){
    if(n == 0) return 0;
    if(memo[n] != -1) return memo[n];
    int p = 0, m = n;
    while(m > 0){
        p += m%2;
        m /= 2;
    }
    if(p == 0) return 0;
    return calc(n%p) + 1;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    if(n == 1){
        if(s[0] == '0') cout << 1 << endl;
        else cout << 0 << endl;
        return 0;
    }
    memset(memo, -1, sizeof(memo));
    memo[0] = 0;
    for(int i = 1; i <= 200002; ++i){
        memo[i] = calc(i);
        //if(i <= 10) cout << i << " " << memo[i] << endl;
    }
    int origin_cnt = 0;
    rep(i,n){
        if(s[i] == '1') ++origin_cnt;
    }
    //cout << origin_cnt << endl;
    int lower_cnt = origin_cnt - 1;
    chmax(lower_cnt, 1);
    int upper_cnt = origin_cnt + 1;
    int lower_num = 0;
    int upper_num = 0;
    rep(i,n){
        lower_num = (lower_num * 2 + (s[i]-'0')) % lower_cnt;
        upper_num = (upper_num * 2 + (s[i]-'0')) % upper_cnt;
    }
    //cout << "lower_num: " << lower_num << endl;
    //cout << "upper_num: " << upper_num << endl;
    vector<int> ans(n, 0);
    int lower_two = 1, upper_two = 1;
    for(int i = n-1; i >= 0; --i){
        int num = 0;
        if(s[i] == '1'){
            if(origin_cnt != 1){
                num = (lower_num + lower_cnt - lower_two) % lower_cnt;
                ans[i] = memo[num] + 1;
            }
            else{
                ans[i] = 0;
            }
        }
        else{
            num = (upper_num + upper_two) % upper_cnt;
            ans[i] = memo[num] + 1;
        }
        //cout << "ans[" << i << "] = " << ans[i] << ", num = " << num << endl;
        lower_two = (lower_two * 2) % lower_cnt;
        upper_two = (upper_two * 2) % upper_cnt;
    }
    rep(i,n) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 5164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
vector<pl> v;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;

    cin >> n;
    for(int i=0;i<n;i++)
    {
        int a,b;
        cin >> a >> b;
        v.push_back({b, a});
    }
    sort(v.begin(), v.end());
    ll cur = 0;
    for(int i=0;i<n;i++)
    {
        cur += v[i].second;
        if(cur > v[i].first)
        {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}

Measured memory_bytes: 6384
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
const int N = 1001;
int n, m, k;
string a[N];

int dist[N][N];
vector <ii> v = { { -1, 0 }, { 1, 0}, {0, -1}, {0, 1}};
void bfs() {
    for (int i = 0; i < N; ++i)
        for (int j = 0; j < N; ++j)
            dist[i][j] = N * N;
    queue <ii> q;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
            if (a[i][j] == 'S') {
                q.push(mp(i, j));
                dist[i][j] = 0;
                break;
            }   
    while (q.size()) {
        auto p = q.front(); q.pop();
        for (auto e : v) {
            int x = p.f + e.f, y = p.s + e.s;
            if (0 <= x && x < n && 0 <= y && y < m && a[x][y] != '#' && dist[p.f][p.s] + 1 < dist[x][y]) {
                dist[x][y] = dist[p.f][p.s] + 1;
                q.push(mp(x, y));
            }   
        }   
    }               
}   

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    cin >> n >> m >> k;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    bfs();
    int ans = N * N;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {

            if (dist[i][j] <= k) {

                int d = min(min(i, n - i - 1), min(j, m - j - 1));
                ans = min(ans, 1 + (d + k - 1) / k);

            }   

        }   
    }   
    cout << ans << endl;
}   

Measured memory_bytes: 8832
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

vector<int> to[100005];

int main(){
    int n,m;
    cin >> n >> m;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--,b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    vector<int> dist(n, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;
    vector<int> parent(n,0);
    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : to[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            parent[nv]=v+1;
            que.push(nv);
        }
    }
    bool ok = 1;
    rep(i,n)if(dist[i]==-1)ok=0;
    if(ok){
        cout << "Yes" << endl;
        for(int i = 1;i<n;i++){
            cout << parent[i] << endl;
        }
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 10556
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#define WHITE 0//まだ訪問してない
#define GRAY 1//訪問中
#define BLACK 2//訪問した
#define N 1000
using namespace std;

int n;
int M[N][N] = {};
int color[N];
int d[N] = {}, f[N] = {};
int t = 0;

//頂点uからの深さ優先
void dfs(int u) {
	color[u] = GRAY;
	t++;
	d[u] = t;
	//cout << "a" << endl;
	for (int i = 1; i <= n; i++) {
		if (M[u][i] == 0)continue;
		if (color[i] != WHITE)continue;
		dfs(i);
	}
	color[u] = BLACK;
	t++;
	f[u] = t;
}

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		color[i] = WHITE;
	}
	for (int i = 0; i < n; i++) {
		int v;
		int s;
		int k;
		cin >> s;
		cin >> k;
		for (int j = 0; j < k; j++) {
			cin >> v;
			M[s][v] = 1;
		}
	}
	//cout << "動いてる" << endl;

	for (int i = 1; i <= n; i++) {
		if (color[i] == WHITE)dfs(i);
	}
	for (int i = 0; i < n; i++) {
		cout << (i + 1) << " " << d[i+1] << " " << f[i+1] << endl;
	}
	return 0;
}


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

typedef long long ll;

ll X;
const ll L = 300;

int main() {
  cin >> X;
  for (ll a = -L; a <= L; ++a)
    for (ll b = -L; b <= L; ++b) {
      if (a * a * a * a * a - b * b * b * b * b == X) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  assert(false);
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    vi A(Q);
    cin >> A;

    vi score(N, K);
    rep(i, 0, Q) {
        score[A[i] - 1]++;
    }
    rep(i, 0, N) {
        score[i] -= Q;
        if (score[i] > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return (0^_^0);
}



Measured memory_bytes: 2176
//=============================================================
// Name        : d
// Date        : Mon Jun 10 10:34:28 CST 2019
// Author      : landcold7
// Description : Actions speak louder more than words
//=============================================================
#include <bits/stdc++.h>
using namespace std;

#define x first
#define y second
#define sz(x) ((int)(x).size())
#ifndef _has_trace
#define trace(...)
#endif
typedef long long ll;

const int maxn = 2007;
char a[maxn][maxn];

void solve() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    scanf("%s", a[i] + 1);
  }
  vector<vector<pair<int, int>>> dp(n + 2, vector<pair<int, int>>(m + 2));
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (a[i][j] == '.') {
        dp[i][j].x = dp[i][j - 1].x + 1;
        dp[i][j].y = dp[i - 1][j].y + 1;
      }
    }
  }
  vector<vector<pair<int, int>>> np(n + 2, vector<pair<int, int>>(m + 2));
  for (int i = n; i >= 1; --i) {
    for (int j = m; j >= 1; --j) {
      if (a[i][j] == '.') {
        np[i][j].x += np[i][j + 1].x + 1;
        np[i][j].y += np[i + 1][j].y + 1;
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= m; ++j) {
      if (a[i][j] == '.') {
        dp[i][j].x += np[i][j].x;
        dp[i][j].y += np[i][j].y;
        ans = max(ans, dp[i][j].x + dp[i][j].y);
      }
    }
  }
  // trace(dp, np);
  cout << ans - 3 << "\n";
}

int main() {
  // ios_base::sync_with_stdio(0);
  // cin.tie(0);
  solve();
  return 0;
}


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

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;
const double PI = acos(-1.0);
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to;
    int cost;
};

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

bool isPrime[1000010];
bool dp[1000010];

void Eratostenes(int N)
{
    rep(i, 1e6 + 1) isPrime[i] = true;

    isPrime[0] = false;
    isPrime[1] = false;

    for(int i = 2; i <= sqrt(N); i++)
    {
        if(isPrime[i])
        {
            for(int j = i * 2; j <= N; j += i)
                isPrime[j] = false;
        }
    }   
}

int main()
{
    int N, X;
    Eratostenes(1000000);   

    while(cin >> N >> X && N)
    {
        vector<int> v(N);
        rep(i, N) cin >> v[i];
        rep(i, X + 1) dp[i] = false;

        dp[0] = true;

        rep(i, N)
        {
            rep(j, X + 1)
            {
                if(!dp[j] || j + v[i] > X) continue;

                dp[j + v[i]] = true;
            }
        }

        int ans = 0;

        rep(i, X + 1)
        {
            if(dp[i] && isPrime[i])
                ans = max(ans, i);
        }

        cout << (ans == 0 ? "NA" : to_string(ans)) << endl;

    }

    return 0;
}


Measured memory_bytes: 5224
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
	int n,k,q,x;
	cin >> n >> k >> q;
	for(int i=1;i<=n;i++){
		a[i]=k;
	}
	for(int i=0;i<q;i++){
		scanf("%d",&x);
		a[x]++;
	}
	for(int i=1;i<=n;i++){
		if(a[i]-q>0) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,ans,k;
int m;
int h[111111];
vector<int> v[111111];
signed main(){
	cin>>n>>m;
	rep(i,n)cin>>h[i];
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--;b--;
		v[b].push_back(a);
		v[a].push_back(b);
	}
	rep(i,n){
		int f=1;
		for(auto x:v[i]){
			if(h[i]<=h[x])f=0;
		}
		if(f)ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 10460
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
typedef long long ll;
typedef unsigned int uint;
using namespace std;
const int INF = 1000000007;

int N,M,R;
int d[201][201];
int r[9];
int A,B,C;
int res;
bool used[9];

void dfs (int c, int las, int dist) {
    if (c == R + 1) {
        res = min(res, dist);
        return;
    }

    for (int i = 1; i <= R; i++) {
        if (!used[i]) {
            used[i] = true;
            if (las == -1) {
                dfs(c + 1, i, 0);
            } else {
                dfs(c + 1, i, dist + d[r[las]][r[i]]);
            }
            used[i] = false;
        }
    }
}

int main () {
    cin >> N >> M >> R;
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            if (i != j) d[i][j] = INF;
        }
    }

    for (int i = 1; i <= R; i++) {
        cin >> r[i];
    }

    for (int i = 1; i <= M; i++) {
        cin >> A >> B >> C;
        if (d[A][B] > C) {
            d[A][B] = d[B][A] = C;
        }
    }

    for (int k = 1; k <= N; k++){
        for (int i = 1; i <= N; i++){
            for (int j = 1; j <= N; j++){
                if (d[i][j] > d[i][k] + d[k][j]) {
                    d[i][j] = d[i][k] + d[k][j];
                }
            }
        }
    }

    res = INF;
    dfs(1, -1, 0);
    cout << res;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

inline int read()
{
	int x=0;char ch=getchar();
	while(ch<'0' || '9'<ch)ch=getchar();
	while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
	return x;
}

const int N=1e5+9;

unsigned int bit[N];
int n,f[N],ans;
int to[N<<1],nxt[N<<1],beg[N],tot;

inline void add(int u,int v)
{
	to[++tot]=v;
	nxt[tot]=beg[u];
	beg[u]=tot;
}

inline void dfs(int u,int fa)
{
	bit[u]=f[u]=0;
	int las=0;
	for(int i=beg[u],v;i;i=nxt[i])
		if((v=to[i])!=fa)
		{
			dfs(v,u);
			las|=bit[v]&bit[u];
			bit[u]|=bit[v];
		}
	if(bit[u]==0)
		bit[u]=1;
	else
	{
		while((1<<f[u])<las || bit[u]&(1<<f[u]))f[u]++;
		bit[u]=(bit[u]>>f[u]<<f[u])|(1<<f[u]);
	}
	if(ans<f[u])ans=f[u];
}

int main()
{
	if(fopen("vj.in","r"))
	{
		freopen("vj.in","r",stdin);
		freopen("vj.out","w",stdout);
	}

	n=read();
	for(int i=1,u,v;i<n;i++)
	{
		u=read();v=read();
		add(u,v);add(v,u);
	}

	dfs(1,0);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 4992
#![allow(non_snake_case)]
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let N:usize = sc.read();
    let A:Vec< i64> = sc.vec(N);
    let mut S:i64 = 0;
    for i in 0..N{
        S += A[i];
    }
    let mut now:i64 = 0;
    let mut M:i64 = S;
    for i in 0..N{
        S -= A[i];
        now += A[i];
        let dif:i64 = (S - now).abs();
        if dif < M{
            M = dif;
        }
    }
    println!("{}", M);



}

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

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



Measured memory_bytes: 6396
#include<stdio.h>
#define K 10000

void countingSort(int a[], int b[], int k, int n){
  int c[k+1];
  int i;
  for(i = 0; i <= k; i++)
    c[i] = 0;

  for(i = 1; i <= n; i++)
    c[a[i]]++;

  for(i = 1; i <= k; i++)
    c[i] = c[i] + c[i-1];

  for(i = n; i >= 1; i--){
    b[c[a[i]]] = a[i];
    c[a[i]]--;
  }
}

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

int main(void){
  int n = 0;
  scanf("%d", &n);
  int i;
  int a[n+1];
  int b[n+1];

  for(int i = 1; i <= n; i++)
    scanf("%d", &a[i]);

  countingSort(a, b, K, n);
  trace(b, n);

  return 0;
}

Measured memory_bytes: 17404
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007;



int main() {
    int N;
    cin>>N;
    vector<int> A(N+1),B(N);
    rep(i,N+1)cin>>A.at(i);
    rep(i,N)cin>>B.at(i);
    int nex=0;
    ll ans=0;
    rep(i,N){
        int zan=A.at(i)-nex;
        ans+=min(nex,A.at(i));
        if(zan<0){zan=0;}
        if(zan>=B.at(i)){ans+=B.at(i);nex=0;}
        else{ans+=zan;nex=B.at(i)-zan;}
    }
    ans+=min(nex,A.at(N));
    cout<<ans<<endl;
}


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

using namespace std;

int main()
{
    uint32_t nn;
    uint64_t hp = 0;
    cin >> nn;

    hp = (nn / 500) * 1000 + ((nn % 500) / 5) * 5;
    
    cout << hp << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int,input().split()))

L.sort()

c = 0

for i in range(len(L)-2):
    for j in range(i+1,len(L)-1):
        for k in range(j+1,len(L)):
            if L[i]==L[j] or L[j]==L[k]:
                continue
            if L[i] + L[j] > L[k]:
                c +=1

print(c)                    


Measured memory_bytes: 9180
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    int n,m;
    cin>>n>>m;
    if(n==m)cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
/* Isn't passion overrated?*/

#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    string s,t;
    cin>>s>>t;
    string tt = s;
    tt.pb(t[t.size()-1]);
    if(s.size() == t.size()-1 &&  tt== t)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;

#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
#define int ll

const int N = 2e5;
const int INF = 1e9;

int ta, ua, tp, ans;

main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> ua >> ta >> tp;
	ans += min(tp, ua);
	tp -= min(tp, ua);
	if(tp == 0) {
		cout << ans + ta;
		return 0;
	}
	int cost = min(tp, ta);
	ans += (cost * 2);
	tp -= cost;
	ta -= cost;
	if(tp == 0) {
		cout << ans + ta;
		return 0;
	}
	if(ta == 0) {
		cout << ans + 1;
	}
	return 0;
}
/*
	If you only do what you can do, 
	You will never be more than you are now!
	----------------------------------------
	We must all suffer from one of two pains: the pain of discipline or the pain of regret. 
	The difference is discipline weighs grams while regret weighs tons.
*/


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
#define all(v)          ((v).begin()), ((v).end())
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define clr(v,d)		memset(v, d, sizeof(v))
const double EPS = 1e-8;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int>P;
const ll mod = ll(1e9 + 7);
int dx[] = { 0, 0, -1, 1, 1, 1, -1, -1 };
int dy[] = { 1, -1, 0, 0, 1, -1, -1, 1 };
const int N = 1000001;
#define endl '\n'
#define ever ;;
#define F first
#define S second
#define pii pair<int,int>
#define sz(v) ((int)((v).size()))
#define pll pair<ll,ll>
void stop() {
#ifndef ONLINE_JUDGE
	system("pause");
#endif
}
void file() {
#ifndef ONLINE_JUDGE
	freopen("pizza.in", "r", stdin);
	freopen("pizza.out", "w", stdout);
#endif
}
struct point {
	double x, y;
};
ull gcd(ull a, ull b) { return !b ? a : gcd(b, a % b); }
ll fixMod(ll a, ll b) { return ((a%b) + b) % b; }
double triangle_area(int x1, int y1, int x2, int y2, int x3, int y3) {
	return abs((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)) / 2.;
};
ll dis(point a, point b) {
	ll x = a.x - b.x, y = a.y - b.y;
	return x * x + y * y;
}
ull LCM(ull a, ull b) {
	return a / gcd(a, b)*b;
}
ll power(ll x, ll y)
{
	if (y == 0)return 1;
	if (y == 1)return x;
	ll r = power(x, y / 2) % mod;
	return r%mod*r%mod*power(x, y % 2) % mod;
}
int main() {
	fast
		string s;
	cin >> s;
	map<char, int>mp;
	for (int i = 0; i < s.size(); i++)mp[s[i]]++;
	for (int i = 0; i < s.size(); i++)if (mp[s[i]] == 2&&mp.size()==2)return cout << "Yes", 0;
	cout << "No";
	stop();
	return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=(n)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define maxs(a,b) a=max(a,b);
#define mins(a,b) a=min(a,b);
#define max3(a,b,c) max(a,max(b,c)) 
#define mix3(a,b,c) mix(a,mix(b,c))

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){
   
    int a,b;cin>>a>>b;

    if(a>=10 || b>=10)cout<<-1<<endl;
    else cout<<a*b<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>

#define mod 1000000007
#define REP(i,n) for(int i=0; i<n; i++)

using namespace std;
using ll = long long;

void solve() {
    ll n, y;
    cin >> n >> y;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            ll k = n-i-j;
            if(k >= 0 && (i+j+k <= n)&&(k*10000+j*5000+i*1000 == y)){
                printf("%d %d %d\n", k, j, i);
                return;
            }
        }
    }
    printf("-1 -1 -1\n");
}

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

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
    string a,ans;
    cin >> a;
    
    while (a.size()>0){
         a.erase(a.size()-1);
        if(a.size()%2 ==0){
            int n = a.size()/2;
            string b = a.substr(0,n);
            string c = a.substr(n,a.size()-1);
            if(b == c){
                ans = a;
                break;
            }
            
        }
    }
    cout << ans.size() << endl;
}
 

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

int main() {
    int a, b, c; cin >> a >> b >> c;
    int ans = 0, cnt = 0;
    while (a!=b || b!=c) {
        if (a - b >= 2) b += 2;
        else if (b - a >= 2) a += 2;
        else if (b - c >= 2) c += 2;
        else if (c - b >= 2) b += 2;
        else {
            int t = max({a,b,c});
            if (a==t) { b++; c++; }
            else if (b==t) { a++; c++; }
            else { a++; b++; }
        }
        ans++;
    }
    cout << ans << endl;
}

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


int main() {
int a, b;
cin >> a >>b;
if(a==1) a+=13;
if(b==1) b+=13;
if(a>b) cout<<"Alice" << endl;
else if(a==b) cout << "Draw" <<endl;
else if (a<b) cout << "Bob" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn = 2000009;
const int mod = 1e9+7;

ll f[maxn],sum[maxn],fib[maxn],fac[maxn],nfac[maxn],inv[maxn];
int n;
ll ans;

ll C(int x,int y)
{
	if(x<y) return 0;
	return fac[x]*nfac[y]%mod*nfac[x-y]%mod;
}

int main()
{
	scanf("%d",&n);
	fib[0]=1;fib[1]=2;fac[0]=nfac[0]=inv[1]=1;
	for(int i=2;i<=n*2;i++) fib[i]=(fib[i-1]+fib[i-2])%mod;
	for(int i=1;i<=n*2;i++) fac[i]=fac[i-1]*i%mod;
	for(int i=2;i<=n*2;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for(int i=1;i<=n*2;i++) nfac[i]=nfac[i-1]*inv[i]%mod;
	for(int i=1;i<=n-1;i++)
	{
		int zero=n-1-i,one=i;
		ll tmp=C(n-3+1-zero,zero)*fac[zero]%mod*fac[one]%mod;
		tmp=(tmp-sum[i-1]+mod)%mod;
		ans=(ans+tmp*i)%mod;
		sum[i]=(sum[i-1]+tmp)%mod;
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

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; }

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    ll a,b,c;
    cin >> n >> a >> b >> c;
    vector<char> ans;
    string s[n];
    rep(i,n)cin >> s[i];
    rep(i,n){
        string t;
        t = s[i];
        if(t == "AB"){
            if(a == 0 && b == 0){
                cout << "No" << endl;
                return 0;
            }
            if( a == 1 && a == b && i+1 < n){
                string next = s[i+1];
                if(next == "BC"){
                    b++;
                    a--;
                    ans.push_back('b');
                }else{
                    a++;
                    b--;
                    ans.push_back('a');
                }
            }else if(a > b){
                a--;
                b++;
                ans.push_back('b');
            }else a++,b--,ans.push_back('a');
        }else if(t == "AC"){
            if( a == 0 && c == 0 ){
                cout << "No" << endl;
                return 0;
            }
            if( a == 1 && a == c && i+1 < n){
                string next = s[i+1];
                if(next == "AB"){
                    a++;
                    c--;
                    ans.push_back('a');
                }else{
                    c++;
                    a--;
                    ans.push_back('c');
                }
            } else if( a < c )a++,c--,ans.push_back('a');
            else a--,c++,ans.push_back('c');
        }else if(t == "BC"){
            if( b == 0 && c == 0 ){
                cout << "No" << endl;
                return 0;
            }
            if( b == 1 && b == c && i+1 < n){
                string next = s[i+1];
                if(next == "AB"){
                    b++;
                    c--;
                    ans.push_back('b');
                }else b--,c++,ans.push_back('c');
            }else if( b < c )b++,c--,ans.push_back('b');
            else b--,c++,ans.push_back('c');
        }
    }
    cout << "Yes" << endl;
    for(int i=0;i<n;i++)cout << (char)(ans[i] + 'A' - 'a') << endl;

}


Measured memory_bytes: 6920
coordinate = []
n = int(input())
cost = n
for _ in range(n):
    coordinate.append([int(i) for i in input().split()])

coordinate.sort()

dif = []
for i in range(n-1):
    for j in range(i+1, n):
        dif.append([coordinate[j][0]-coordinate[i][0], coordinate[j][1]-coordinate[i][1]])

dif.sort()

i = 0
while i < n*(n-1)/2:
    counter = dif.count(dif[i])
    cost = min(cost, n-counter)
    i += counter

print(cost)

Measured memory_bytes: 3188
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>

long long int test_minscore(long long int N, long long int K, std::vector<long long int> &A, std::vector<long long int> &F, long long int min);

int main(){
  
  // read problem
  long long int N, K, tmp;
  std::vector<long long int> A, F;
  
  scanf("%lld%lld", &N, &K);
  for(long long int i = 0; i < N; i++){
    scanf("%lld", &tmp);
    A.push_back(tmp);
  }
  
  for(long long int i = 0; i < N; i++){
    scanf("%lld", &tmp);
    F.push_back(tmp);
  }
  
  std::sort(A.begin(), A.end(), std::less<long long int>());
  std::sort(F.begin(), F.end(), std::greater<long long int>());
  
  /*std::cerr << "sorted A:" << std::endl;
  for(long long int i = 0; i < N; i++){
    std::cerr << A[i] << " ";
  }std::cerr << std::endl;
  std::cerr << "sorted F:" << std::endl;
  for(long long int i = 0; i < N; i++){
    std::cerr << F[i] << " ";
  }std::cerr << std::endl;*/
  
  // solve problem
  long long int l, r, mid;
  // if the minimum score is zero
  if(test_minscore(N, K, A, F, 0) == 1){
    std::cerr << "Answer: " << std::endl;
    std::cout << 0 << std::endl;
    return 0;
  }
  // if the minimum score is positive
  l = 0;
  r = 0;
  for(long long int i = 0; i < N; i++){
    if(r < A[i]*F[i])r = A[i]*F[i];
  }
  while(r-l>1){
    mid = (r+l)/2;
    if(test_minscore(N, K, A, F, mid) == 1){
      r = mid;
    }
    else{
      l = mid;
    }
  }
  
  std::cerr << "Answer:" << std::endl;
  std::cout << r << std::endl;
  
  return 0;
}

long long int test_minscore(long long int N, long long int K, std::vector<long long int> &A, std::vector<long long int> &F, long long int min){
  long long int K_tmp = 0;
  
  for(long long int i = 0; i < N; i++){
    if(A[i] * F[i] > min){
      K_tmp += A[i] - min/F[i];
    }
  }
  
  if(K_tmp <= K){
    return 1;
  }
  else{
    return 0;
  }
}



Measured memory_bytes: 4848
N = int(input())
S = [input() for i in range(N)]
 
ac = 0
wa = 0
tle = 0
re = 0
for s in S:
  if s == 'AC': ac += 1
  elif s == 'WA': wa += 1
  elif s == 'TLE': tle += 1
  elif s == 'RE': re += 1

print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))

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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n, d;
    cin >> n >> d;
    vector<vector<int>> x(n, vector<int>(d));
    rep(i, 0, n){
        rep(j, 0, d){
            cin >> x[i][j];
        }
    }
    int cnt = 0;
    rep(i, 0, n){
        int tmp;
        rep(j, i, n){
            if(i == j) continue;
            tmp = 0;
            rep(k, 0, d) {
                tmp += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
            }
            rep(l, 1, sqrt(tmp) + 2){
                if(tmp == l * l) cnt++;
            }
        }
    }
    cout << cnt << endl;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	long long ans = 1;
	for(int i = 0; i < n; i++) {
		long long a;
		cin >> a;
		ans = ans / __gcd(a, ans) * a;
	}
	cout << ans << endl;
	return 0;	
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h,w;
  cin >> h >> w;
  string S;
  REP(i,w+2)cout << "#";
  cout << endl;
  REP(i,h){
      cin >> S;
      cout << "#" << S << "#" << endl;
  }
  REP(i,w+2)cout << "#";
  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <algorithm>
#include <unordered_map>
#include <iomanip>
#include <time.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];

  int minv=1000000, sum=0;
  rep(i, n){
    minv = min(minv, p[i]);
    if(p[i] <= minv)
      sum++;
  }
  cout << sum << endl;
   return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

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

if(400 <= N && N <= 599)cout << 8;

if(600 <= N && N <= 799)cout << 7;

if(800 <= N && N <= 999)cout << 6;

if(1000 <= N && N <= 1199)cout << 5;

if(1200 <= N && N <= 1399)cout << 4;

if(1400 <= N && N <= 1599)cout << 3;

if(1600 <= N && N <= 1799)cout << 2;

if(1800 <= N && N <= 1999)cout << 1;

}

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

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}


 main()

{
    fast
    string s;
    cin>>s;
    int sz=s.size();
    if(s[sz-1]=='1' || s[0]=='0')
    {
        cout<<"-1"<<endl;
        return 0;
    }
    int mid=sz/2;
    f(i,0,mid-1)
    {
        int lft=i;
        int rgt=sz-(i+2);
        if(s[lft]!=s[rgt])
        {
            cout<<"-1"<<endl;
            return 0;
        }
    }
    int cur=1;
    int nxt=2;
    int pos=0;
    vector<pi>ses;
    while(pos<mid)
    {
        if(s[pos]=='1')
        {
            ses.pb(mp(cur,nxt));
            cur=nxt;nxt++;
        }
        else
        {
           ses.pb(mp(cur,nxt));
           nxt++;
        }
        pos++;
    }
    f(i,nxt,sz)
    {
        ses.pb(mp(cur,i));
    }
    for(auto x:ses)
    {
        cout<<x.fi<<" "<<x.si<<endl;
    }
    return 0;

}













Measured memory_bytes: 3264
fun main() {
    val n = readInt().toLong()
    var ans = (n downTo 1).fold(0L) { acc, num -> acc + num * (num + 1) }/2

    repeat(n.toInt() - 1) {
        val edge = readInts().sorted()
        ans -= edge[0] * (n - edge[1] + 1)
    }

    println(ans)
}

// Input Reader
private fun readLn() = readLine()!!

private fun readStrings() = readLn().trim().split(" ")
private fun readInt() = readLn().toInt()
private fun readInts() = readStrings().map { it.toInt() }


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

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

bool palin(string s) {
  int n = s.size();
  for (int j = 0; j < n; j++) {
    if (s[j] != s[n - j - 1]) return 0;
  }
  return 1;
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int a, b;
  cin >> a >> b;
  int ans = 0;
  for (int i = a; i <= b; i++) {
    if (palin(to_string(i))) ans++;
  }
  cout << ans << '\n';
}


Measured memory_bytes: 3784
#include<stdio.h>
int main()
{
long  long int N,i,sum=0;
scanf("%lld",&N);
for(i=1;i<=N;i++)
{
    if(i%3!=0 && i%5!=0)
    {
        sum=sum+i;
    }
}
printf("%lld",sum);
}


Measured memory_bytes: 1732
N,M = gets.split(' ').map(&:to_i)
lr = M.times.map{ gets.split(' ').map(&:to_i)}
l_max = 0
r_min = 1000000000000000000000000

for i in 0..M-1
  if l_max<lr[i][0]
    l_max = lr[i][0]
  end
  if r_min>lr[i][1]
    r_min = lr[i][1]
  end
end

#puts l_max
#puts r_min
if l_max > r_min
  puts 0
elsif N<l_max
  puts 0
elsif N>=r_min
  puts r_min - l_max + 1
else
  puts N-l_max
end


Measured memory_bytes: 9596
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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; }

P f(int x) {
	int b = x%10;
	int a = 0;
	while(x) {
		a = x;
		x /= 10;
	}
	return P(a,b);
}
int main() {
	int n;
	cin >>n ;
	map<P,int>freq;
	for(int i = 1;i<=n;i++) {
		P p = f(i);
		freq[p]++;
	}
	ll ans = 0;
	for(int i = 1;i<=n;i++) {
		P p = f(i);
		P q(p.second,p.first);
		ans += freq[q];
	}
	cout << ans << endl;
}




Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {

	private static BufferedReader brStdin = new BufferedReader(new InputStreamReader(System.in));
	private static String[] readBuf = null;
	private static int readPtr = 0;
	private static String getString() throws IOException {
		while ( readBuf == null || readPtr >= readBuf.length ) {
			readBuf = brStdin.readLine().split(" ");
			readPtr = 0;
		}
		return readBuf[readPtr++];
	}
	private static int getInt() throws IOException {
		return Integer.parseInt(getString());
	}
	private static long getLong() throws IOException {
		return Long.parseLong(getString());
	}
	private static BigDecimal getBD() throws IOException {
		return new BigDecimal(getString());
	}
	@SuppressWarnings("unused")
	private static String[] getStringArray(int size) throws IOException {
		String stringArray[] = new String[size];
		for (int i = 0; i < stringArray.length; i++) {
			stringArray[i] = getString();
		}
		return stringArray;
	}
	@SuppressWarnings("unused")
	private static int[] getIntArray(int size) throws IOException {
		int intArray[] = new int[size];
		for (int i = 0; i < intArray.length; i++) {
			intArray[i] = getInt();
		}
		return intArray;
	}
	@SuppressWarnings("unused")
	private static long[] getLongArray(int size) throws IOException {
		long longArray[] = new long[size];
		for (int i = 0; i < longArray.length; i++) {
			longArray[i] = getLong();
		}
		return longArray;
	}
	@SuppressWarnings("unused")
	private static BigDecimal[] getBDArray(int size) throws IOException {
		BigDecimal bdArray[] = new BigDecimal[size];
		for (int i = 0; i < bdArray.length; i++) {
			bdArray[i] = getBD();
		}
		return bdArray;
	}
	
	public static void main(String args[]) throws IOException {
		int n = getInt();
		int p[] = new int[n];
		for ( int i = 0 ; i < n ; i++ ) {
			p[i] = getInt();
		}
		int a=0;
		for ( int i = 1 ; i < n-1 ; i++ ) {
			if ( p[i-1] > p[i] && p[i] > p[i+1]  || p[i-1] < p[i] && p[i] < p[i+1] ) {
				a++;
			}
		}
		System.out.println(a);
	}
}


Measured memory_bytes: 21204
#include<iostream>
#include<cstdio>
using namespace std;
int a,b,c,mx,cnt;
int main()
{
	cin>>a>>b>>c;
	mx=max(a,max(b,c));
	for (int i=mx;i<=100;i++)
	{
		cnt=0;
		if ((i-a)&1) cnt++;
		if ((i-b)&1) cnt++;
		if ((i-c)&1) cnt++;
		if (cnt%2==0) 
		{
			cout<<(i*3-a-b-c)/2<<endl;
			return 0;
		}
	}
	return 0;
} 

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.awt.geom.*;

public class Main {
    double box_len;
    double rs[];
    BufferedReader br;
    double[][] dp;
    int n;

    Main() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    boolean init() {
        try {
            String[] data = br.readLine().split(" ");
            box_len = Double.parseDouble(data[0]);
            rs = new double[data.length-1];
            n = rs.length;
            for (int i = 1; i < data.length; i++) 
                rs[i-1] = Double.parseDouble(data[i]);

            dp = new double[n][1<<n]; 

            return true;
        } catch (IOException e) {
            return false;
        } catch (NullPointerException e) {
            return false;
        }
    }

    double dist(double a, double b) {
        return Math.sqrt( (a+b)*(a+b) - (a-b)*(a-b) );
    }

    double solve(int v, int S) {
//        System.out.printf("%d %d\n", v, S);
        if (S == ((1<<n)-1)) return rs[v];
        if (dp[v][S] > 0) return dp[v][S];

        double minl = INF;
        for (int i = 0; i < n; i++) {
            if ((S & (1<<i)) != 0) continue;
            minl = Math.min(minl, solve(i, S + (1<<i)) + dist(rs[v], rs[i]));
        }

        return dp[v][S] = minl;
    }

    static final double INF = 1e18;
    void run() {
        while (init()) {
            double min_len = INF;

            for (int i = 0; i < n; i++) 
                min_len = Math.min(min_len, solve(i, (1<<i)) + rs[i]);

            if (box_len >= min_len) 
                System.out.println("OK");
            else
                System.out.println("NA");
        }
    }

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

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int a, b;
    cin >> a >> b;

    if(b%a == 0) cout << a + b << endl;
    else cout << b - a << endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

var scanner *bufio.Scanner

func printIt() {
	cnt := 1
	for {
		a := nextInt()
		b := nextInt()
		if a != 0 || b != 0 {
			if a < b {
				fmt.Println(a, b)
			} else {
				fmt.Println(b, a)
			}
		} else {
			break
		}
		cnt++
	}
}

func nextInt() int {
	scanner.Scan()
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(1)
	}
	return num
}

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	printIt()
}



Measured memory_bytes: 1104
#include <iostream>

using namespace std;

int ca(int c){
  int x = 0;
  for(int i=1; i<=c; i++){
    if(c<i) break;
    c-=i;
    x++;
  }
  return x;
}

int main(void){

  long long N;
  int c, ans = 0;

  cin >> N;

  for(long long z=2; z*z<=N; z++){
    c = 0;
    while(true){
      if(N%z==0){
        N = N / z;
        c++;
      }
      else{
        ans += ca(c);
        break;
      }
    }
  }
  if(N!=1) ans++;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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;
}


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

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

// edit

void solve() {
    int N, K;
    cin >> N >> K;

    set<int> neri;
    for(int i = 0; i < K; ++i){
        int d;
        cin >> d;
        REP(i, d){
            int tmp;
            cin >> tmp;
            neri.insert(tmp);
        }
    }
    
    int ans = N - SZ(neri);
    cout << ans << endl;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


Measured memory_bytes: 3192