akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    ll ans = 1;
    while (n >= k) {
        ans++;
        n /= k;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long[] a = new long[n];
        long[][] b = new long[n][n];
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }
        long max = 0L;
        for (int i = 0; i < n; i++) {
            b[i][i] = a[i];
            if(max < b[i][i]) max = b[i][i];
            list.add(b[i][i]);
            for (int j = i+1; j < n; j++) {
                b[i][j] = b[i][j-1] + a[j];
                if(max < b[i][j]) max = b[i][j];
                list.add(b[i][j]);
            }
        }
        int digit = Long.toBinaryString(max).length();
        long ans = 0L;
        for (int i = digit-1; i >= 0; i--) {
            int tmp = 0;
            List<Long> nex = new ArrayList<>();
            for (int j = 0; j < list.size(); j++) {
                if((list.get(j) >>> i & 1) == 1){
                    tmp++;
                    nex.add(list.get(j));
                }
            }
            if(k <= tmp){
                ans += (1L << i);
                list = nex;
            }
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 55140
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>
#include <ctime>
#include <string>
#include <iostream>
#include <bitset>
#define PII pair <int, int>
#define PPI pair <PII, int>
#define x first
#define y second

using namespace std;

typedef long long ll;

int n;

ll A[10010];

vector <int> V(0);

int npr[100010];

int gcd(int x, int y) {
    return !y ? x : gcd(y, x % y);
}

int main() {
    for(int i = 2; i <= 100000; i++)
        for(int j = i + i; j <= 100000; j += i)
            npr[j] = 1;
    scanf("%d", &n);
    for(int i = n; i >= 0; i--) scanf("%lld", &A[i]);
    for(int i = 2; i <= n + 2; i++)
        if(!npr[i]) {
            int flag = 1;
            for(int j = 1; j <= n && j <= i - 1; j++) {
                ll sum = 0;
                for(int k = j; k <= n; k += (i - 1))
                    sum += A[k];
                if(sum % i) {
                    flag = 0;
                    break;
                }
            }
            if(flag && A[0] % i == 0) V.push_back(i);
        }
    ll lw = A[n];
    for(int i = 0; i <= n; i++) if(A[i]) {
        if(A[i] < 0) lw = __gcd(lw, -A[i]);
        else lw = __gcd(lw, A[i]);
    }
    if(lw < 0) lw = -lw;
    for(ll i = 2; i * i <= lw; i++) if(lw % i == 0) {
        while(lw % i == 0) lw /= i;
        V.push_back(i);
    }
    if(lw != 1 && lw != 0) V.push_back(lw < 0 ? -lw : lw);
    sort(V.begin(), V.end());
    V.resize(unique(V.begin(), V.end()) - V.begin());
    for(int i = 0; i < V.size(); i++) printf("%d\n", V[i]);
    return 0;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

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

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, m;
  while (cin >> n >> m) {
    vector<int> g[n];
    for (int i = 0; i < m; ++i) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      g[a].push_back(b);
      g[b].push_back(a);
    }

    set<int> vis;
    vector<int> path;
    function<void(int)> rec = [&] (int curr) {
      vis.insert(curr);
      path.push_back(curr);
      bool f = true;
      each (next, g[curr]) {
        if (vis.count(next)) continue;
        f = false;
        rec(next);
      }
      if (f) throw "";
      return ;
    };
    try { rec(0); } catch (const char* e) {}
    vector<int> a = path;
    path.clear();
    try { rec(path[0]); } catch (const char* e) {}
    vector<int> b = path;

    vector<int> c = b;
    reverse(c.begin(), c.end());
    if (c.size()) c.pop_back();
    each (i, a) c.push_back(i);
    cout << c.size() << endl;
    for (int i = 0; i < c.size(); ++i) {
      if (i) cout << ' ';
      cout << c[i] + 1;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 18020
#include <iostream>
#include <map>
#include <cstring>

using namespace std;

int main() {
  unsigned N;
  std::cin >> N;
  unsigned long long ret = 0;
  unsigned a[200010];
  std::map<unsigned, unsigned> num_to_index;
  unsigned countr[200010];
  unsigned countl[200010];
  a[0] = 0;
  a[N + 1] = 0;
  for (unsigned i = 1; i <= N; ++i) {
    std::cin >> a[i];
    num_to_index.emplace(std::make_pair(a[i], i));
  }
  for (unsigned i = N; i > 0; --i) {
    auto index = num_to_index.find(i)->second;
    countr[index] = 0;
    countl[index] = 0;
    auto bi = index - 1;
    auto ni = index + 1;
    while (a[bi] > a[index]) {
      countl[index] += countl[bi] + 1;
      bi -= countl[bi] + 1;
    }
    while (a[ni] > a[index]) {
      countr[index] += countr[ni] + 1;
      ni += countr[ni] + 1;
    }
  }
  for (unsigned i = 1; i <= N; ++i) {
    unsigned long long hoge = a[i];
    ret += hoge * (1 + countr[i]) * (1 + countl[i]);
  }
  std::cout << ret;
  return 0;
}

Measured memory_bytes: 11904
<?php
$n = trim(fgets(STDIN));

for ($i=3; $i<=$n; $i++) {
  if (($i % 3) == 0) {
    // * 3
    echo " {$i}";
  } else {
    // include 3
    $x = $i;
    while ($x > 0) {
      if ($x % 10 == 3){
        echo " {$i}";
        break;
      }
      $x /= 10;
    }
  }
}
echo PHP_EOL;

Measured memory_bytes: 15236
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define Debug printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define debug(x) cerr<<#x<<'='<<x<<endl
#define mem(x) memset(x,0,sizeof x)
namespace mine
{
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=400+10;

    ll fac[N],facinv[N];
    int aa[N],bb[N],S,invS;
    int dp[2][N][N];
    void main()
    {
        fac[0]=1;fo(i,1,N-1) fac[i]=fac[i-1]*i%MOD;
        facinv[N-1]=invm(fac[N-1]);fd(i,N-1,1) facinv[i-1]=facinv[i]*i%MOD;

        int n=qread();fo(i,1,n) aa[i]=qread(),bb[i]=qread(),S+=aa[i];invS=invm(S);
        int A=0,B=0;dp[0][0][0]=1;
        fo(i,1,n)
        {
            int w=i&1;mem(dp[w]);
            fo(a,0,A) fo(b,0,B) if(dp[w^1][a][b])
            {
                add(dp[w][a+aa[i]][b],dp[w^1][a][b]);
                ll tmp=1;fo(j,0,bb[i]-1) add(dp[w][a][b+j],MOD-dp[w^1][a][b]*tmp%MOD*facinv[j]%MOD ),tmp=tmp*aa[i]%MOD*invS%MOD;
            }
            A+=aa[i],B+=bb[i]-1;
        }
        ll ans=0;fo(a,0,A-1) fo(b,0,B) add(ans, MOD-fac[b]*qpower(MOD+1-1ll*a*invS%MOD,MOD-1-(b+1))%MOD*dp[n&1][a][b]%MOD );write(ans);
    }
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second

using namespace std;

const ll N = 3e5 + 10;
const ll big = 1e18;
const ll block = 100;
const ll mod = 1e6;

ll n, m;

vector<ll> g[N];

ll ans[N];

ll dp[N];

ll dfs(ll v = 1 ,ll p = -1){
	dp[v] = 1;
	for(auto u : g[v]){
		if(u != p){
			ll x = dfs(u, v) % m;
			dp[v] *= (x + 1) % m;
			dp[v] %= m;
		}
	}		
	return dp[v];
}

void dfs2(ll v = 1, ll p = -1,ll x = 0){
	ll mn = g[v].size();
	ll pref[mn] ,suf[mn] ;
	ans[v] = (x + 1) % m;
	for(auto u : g[v])
		if(u != p)
			ans[v] *= (dp[u] + 1) % m, ans[v] %= m;
	for(int i = 0 , j = mn - 1; i < mn || j >= 0 ; j-- ,i++){
		ll u = g[v][i];
		ll to = g[v][j];
		if(u != p)
			pref[i] = ((dp[u] + 1) % m) * (i ? pref[i - 1] : 1);
		else
			pref[i] = (x + 1) * (i ? pref[i - 1] : 1);
		if(to != p)
			suf[j] = ((dp[to] + 1) % m) * (j + 1 != mn ? suf[j + 1] : 1);
		else
			suf[j] = (x + 1) * (j + 1 != mn ? suf[j + 1] : 1);
		pref[i] %= m, suf[j] %= m;
	}
	for(int i = 0 ; i < mn ; i++){
		ll u = g[v][i];
		if(u != p){
			dfs2(u, v, ((i ? pref[i - 1] % m : 1) * (i + 1 != mn ? suf[i + 1] % m : 1)) % m);
		}
	}
	
} 


int main() {
    speed;
	cin >> n >> m;
	for(int i = 1 ; i < n ; i++){
		ll x, y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs();
	dfs2();
	for(int i = 1 ; i <= n;  i++)
		cout << ans[i] % m << '\n';
}

/*
	Code written by
	Codeforces : I_Love_Trott
	mail : dzhon.snoudin@mail.ru
*/


Measured memory_bytes: 27392
import math

a,b,C = map(int, input().split())

S = 1/2 * a * b * math.fabs(math.sin(C / 360 * 2 * math.pi))
c = math.sqrt( a **2 + b **2 - 2*a*b*math.cos(C/360 * 2 * math.pi))
L = a + b + c
h = 2* S / a

print('{0:.7f}'.format(S))
print('{0:.7f}'.format(L))
print('{0:.7f}'.format(h))

Measured memory_bytes: 7896
s = input().strip()
s_sorted = sorted(s)
t = input().strip()
t_sorted = sorted(t, reverse=True)

for i in range(min(len(s), len(t))):
    if s_sorted[i] < t_sorted[i]:
        print('Yes')
        exit()
    elif  s_sorted[i] > t_sorted[i]:
        print('No')
        exit()
if len(s) < len(t):
    print('Yes')
else:
    print('No')   

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6+500;

ll w,h;
ll p[N],q[N];

void solve()
{
    for(int i=0;i<w;i++)cin>>p[i];
    sort(p,p+w);
    for(int i=0;i<h;i++)cin>>q[i];
    sort(q,q+h);

    ll ans=0;
    int row=0,column=0;
    while(true)
    {
//        cout<<row<<" "<<column<<endl;
        if(row==w&&column==h)break;
        if(row==w||(column!=h&&q[column]<=p[row]))
        {
            ans+=q[column]*max((w-row+1),0ll);
            column++;
            continue;
        }
        if(column==h||(row!=w&&p[row]<=q[column]))
        {
//            puts("p");
            ans+=p[row]*max((h-column+1),0ll);
            row++;
            continue;
        }
    }
    cout<<ans<<endl;

}

int main()
{
    while(cin>>w>>h)solve();
    return 0;
}


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

typedef long long ll;

int main() {
	int n , k;
	cin >> k >> n;
	vector<int> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}
		if (k >= n) {
		cout << 0;
		return 0;
	}
	sort(v.begin(),v.end());
	vector<int> ans(n - 1);
	for (int i = 1; i < n; ++i) {
		ans[i - 1] = v[i] - v[i - 1];
	}
	sort(ans.begin(),ans.end());
	ll res = 0;
	for (int i = 0; i < n - k; ++i) {
		res += 1LL * ans[i];
	}
	cout << res;
}



Measured memory_bytes: 3952
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll=long long;  
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
ll a[51],p[51];
ll f(ll n, ll x){
    if(n==0){
        if(x<=0) return 0;
        else{
            return 1;
        }
    }else if(x<=1+a[n-1]){
        return f(n-1,x-1);
    }else{
        return p[n-1]+1+f(n-1,x-(1+1+a[n-1]));
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll X;

    a[0]=p[0]=1;
    
    cin >> N >> X;
    for(ll i=1;i<=N;++i){
        a[i]=2*a[i-1]+3;
        p[i]=2*p[i-1]+1;
    }
    cout << f(N,X) <<endl;
    return 0;
}

Measured memory_bytes: 256
import math

n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
ret = 0
for i in range(n):
    for j in range(i + 1, n):
        distance = sum((x[i][k] - x[j][k]) * (x[i][k] - x[j][k]) for k in range(d))
        sq = int(math.sqrt(distance))
        if distance == sq * sq:
            ret += 1
print(ret)


Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int K = 1008;

int k;
int s[2];
int v[2][K][K];
int ps[2][K][K];

void init() {
	for (int t = 0; t < 2; t++) {
		for (int i = 1; i <= k; i++) {
			for (int j = 1; j <= k; j++) {
				ps[t][i][j] = ps[t][i - 1][j] + ps[t][i][j - 1] - ps[t][i - 1][j - 1] + v[t][i - 1][j - 1];
			}
		}
	}
}

int ans = 0;

int sum(int t, int i1, int j1, int i2, int j2) {
	return ps[t][i2][j2] - ps[t][i1][j2] - ps[t][i2][j1] + ps[t][i1][j1];
}

void relax(int t) {
	for (int i = 0; i < k; i++) {
		for (int j = 0; j < k; j++) {
			int cur = sum(t, 0, 0, i, j) + sum(t, i, j, k, k);
			int ot = s[t ^ 1] - sum(t ^ 1, 0, 0, i, j) - sum(t ^ 1, i, j, k, k);
			ans = max(ans, cur + ot);
		}
	}
}

void add(int t, int i, int j) {
	v[t][i][j]++;
	s[t]++;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);	

	int n;
	cin >> n >> k;
	while (n--) {
		int x, y;
		char c;
		cin >> x >> y >> c;
		int vv = 0;
		if (c == 'B') vv = 1;
		add((vv + (x / k + y / k)) % 2, x % k, y % k);
	}
	init();
	relax(0);
	relax(1);
	cout << ans << endl;
}


Measured memory_bytes: 16128
#ifndef TEMPLATE_HPP
#define TEMPLATE_HPP
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())
using namespace std;
using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename U> vector<U> make_vector(T&& n, U&& val) { return vector<U>(forward<T>(n), forward<U>(val)); }
template <typename T, typename... Args> decltype(auto) make_vector(T&& n, Args&&... args) { return vector<decltype(make_vector(forward<Args>(args)...))>(forward<T>(n), make_vector(forward<Args>(args)...)); }
const int INF = 1001001001;
const i64 LINF = 1001001001001001001ll;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
#endif

void solve() {
  vi32 x(3);
  int k;
  cin >> x >> k;
  int c = 0;
  reps(i, 2) {
    while (x[i-1] >= x[i]) {
      x[i] <<= 1;
      c += 1;
    }
  }
  if (c <= k) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(16);
  cerr << fixed << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 3588
#include <iostream>

using namespace std;

int main(void){

  int x,y,h,w,n,N;
  cin >> n;

  while(n--){

    cin >> x >> y >> w >> h;
    cin >> N;
    int X,Y;
    int cnt = 0;
    for( int i = 0 ; i < N ; i++ ){
      cin >> X >> Y;
      if(  x <= X && X <= x + w && y <= Y && Y <= y + h ){
	cnt++;
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>

int main(void){
  int n;
  scanf("%d", &n);
  int a[n];
  for(int i = 0; i<n; i++){
    scanf("%d", &a[i]);
  }
  int temp;
  int count =0;
  for(int i=0; i<n; i++){
    int minj = i;
    for(int j=i; j<n; j++){
      if(a[j]<a[minj]){
          minj = j;
      }


    }
    if(i!=minj){
      temp =a[i];
      a[i]=a[minj];
      a[minj]=temp;
      count++;
    }

  }

  for(int j=0; j<n-1; j++){
    printf("%d ",a[j]);
  }
  printf("%d\n", a[n-1]);
  printf("%d\n",count);

  return 0;
}



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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n; cin>>n;
    vector<ll> a(n),b(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    vector<ll> aa(n+1,0),bb(n+1,0);
    rep(i,n){
        aa[i+1]=aa[i]+a[i];
        bb[i+1]=bb[i]+b[i];
    }
    ll ans=a[0]+b[0];
    for(int i=1;i<n;i++){
        ans=max(ans,aa[i]+bb[n]-bb[i-1]);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  string S, three_string = "";
  int num = 0, difference = 753, min_difference = 1000000;
  cin >> S;
  for(int i = 0; i < S.length(); i++){
    three_string = S.substr(i, 3);
    num = atoi(three_string.c_str());
    min_difference = min(min_difference, abs(difference - num));
  }
  cout << min_difference << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() 
{
	int x,n; cin>>x>>n;
	vector<int>a(n);
	set<int>s;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		s.insert(a[i]);
	}
	int ans=INT_MAX;
	int cur=INT_MAX;
	for(int i=-200;i<=20000;i++)
	{
		if(!s.count(i))
		{
			if(abs(i-x)<cur)
			{
				ans=i; cur=abs(i-x);
			}
		}
		
	}
//	if(n==0){cout<<
cout<<ans;

}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);

        int X = in.nextInt();   // 庭の動物の総数
        int Y = in.nextInt();   // それらの足の総数
        
        if( Y%2 == 1 || 2*X > Y || (Y-(X*2))/2 > X ){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 35600
//#define _GLIBCXX_DEBUG
//#include <atcoder/all>
#include <bits/stdc++.h>


using namespace std;
//using namespace atcoder;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

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()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll T; cin>>T;
  rep(_,T){
    ll N,A,B,C,D; cin>>N>>A>>B>>C>>D;
    map<ll,ll> dp;
    //dp[N]=0;
    priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> pq;
    pq.push({0LL,N});
    while(!pq.empty()){
      auto p=pq.top(); pq.pop();
      ll c,v; tie(c,v)=p;
      if(dp.count(v)) continue;
      dp[v]=c; if(v==0) break;
      if((INF-c)/D>=v+1) pq.push({c+D*v,0});
      ll nv=v/2;
      if(!dp.count(nv)){
        pq.push({c+A+D*abs(v-nv*2),nv});
      }
      if(v%2!=0) nv++;
      if(!dp.count(nv)){
        pq.push({c+A+D*abs(v-nv*2),nv});
      }
      nv=v/3;
      if(!dp.count(nv)){
        pq.push({c+B+D*abs(v-nv*3),nv});
      }
      if(v%3!=0) nv++;
      if(!dp.count(nv)){
        pq.push({c+B+D*abs(v-nv*3),nv});
      }
      nv=v/5;
      if(!dp.count(nv)){
        pq.push({c+C+D*abs(v-nv*5),nv});
      }
      if(v%5!=0) nv++;
      if(!dp.count(nv)){
        pq.push({c+C+D*abs(v-nv*5),nv});
      }
    }
    cout<<dp[0]<<'\n';
    /*
    for(auto p:dp){
      cout<<p.first<<" "<<p.second<<'\n';
    }
    */
  }
  return 0;
}


Measured memory_bytes: 4196
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define WMAX 10000
#define HMAX 10000

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

int A,B,C;
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};


int main(){
	cin >> A >> B >> C;
	cout << (A+B)*C/2 << "\n";
	
	return 0;
}

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

int main(){
  int n, k;
  int index = 0;
  int sum = 0;
  int *p;
  cin >> n >> k;
  p = new int[n];
  for(int i = 0; i < n; i++){
    cin >> p[i];
  }
  for(int i = 0; i < n; i++){
  	int index = i;
  	int min = p[i];
  	for(int j = i + 1; j < n; j++){
    	if(p[j] < min){
      		min = p[j];
      		index = j;
    	}
  	}
  	p[index] = p[i];
  	p[i] = min;
  }

  for(int i = 0; i < k; i++){
    sum += p[i];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define ll long long
#define fo(i,x,y) for(register int i=x;i<=y;++i)
#define go(i,x,y) for(register int i=x;i>=y;--i)
using namespace std;

inline int read(){
	int x=0,fh=1;
	char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-') fh=-1;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=(x<<1)+(x<<3)+ch-'0';
		ch=getchar();
	}
	return x*fh;
}
int main(){
	int n=5;
	fo(i,1,n){
		int a=read();
		if(!a){
			printf("%d\n",i);
			return 0;
		}
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
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; }
const ll MOD = 1e9+7;

int main(){
    int N;
    int R, G ,B;
    cin >> R >> G >> B >> N;

    int ans = 0;
    REP(i,N+1){
        int r = R*i; 
        REP(j,N+1){
            int g = G*j;
            int b = N - r - g;
            if(b < 0) continue;
            if(b % B == 0){
                ans++;
            }
            //ans++;
        }
    }

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


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc153/tasks/abc153_f
# 座標圧縮、貪欲法、imos法


import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


# まず、何回攻撃すればいいのかを計算する。これがとにかく必要だ(なくてもいいけど)。
#
# 素直な戦略として、左から倒せるギリギリの爆弾を投下して倒すのが最適
# だけどナイーブに実装すると、O(N^2)。だから体力を管理するのが重要。
# どこにどれだけダメージが蓄積したのかはimos法(デルタ関数をおいてから累積和)で管理できる。

from bisect import bisect_left
N, D, A = read_ints()
XH = read_tuple(N)
XH.sort()  # 座標でソート

n_atk = []  # 何回攻撃するのが必要か
X = []  # 座標アクセス用配列
for x, h in XH:
    n_atk.append((h - 1) // A + 1)
    X.append(x)

damege = [0] * (N + 10)  # ダメージ管理用、配列外アクセスがめんどくさいので長めに取る
ans = 0
j = 0  # 次のxが、今のx+2d以下でもっとも大きなidx
for i, (x, n) in enumerate(zip(X, n_atk)):
    damege[i] += damege[i - 1]  # 積分して、現時点の蓄積回数を表示
    atk = max(0, n - damege[i])  # iには何回攻撃したか
    ans += atk
    # 攻撃下回数を記録
    damege[i] += atk
    # 効果が切れる点を予約 # 尺取ならO(1)で次に行けるけど二分探索でも間に合うか
    while j < len(X) and X[j] < x + 2 * D + 1:
        j += 1
    damege[j] -= atk  # 効果切れを予約

print(ans)


Measured memory_bytes: 48636
#include <iostream>
constexpr long long m   = 1'000'000'000LL;  //' 1e9
constexpr long double e = 0.001000000000L;  // error
constexpr long long h   = 100LL;

int main(void) {
    long long a, bh;
    long double b;
    std::cin >> a >> b;
    bh = (b + e) * h;  // b * 100

    if (a == 0LL || bh == 0LL) {
        std::cout << "0\n";
        return 0;
    }

    long long ua, ba;
    ua = a / m;  // a / 1e9
    ba = a % m;  // a % 1e9
    if (ua == 0LL) {
        std::cout << a * bh / h << std::endl;
        return 0;
    }

    // a * (b * 100)
    ua *= bh;
    ba *= bh;
    ba += (ua % h) * m;

    // (a * (b * 100)) / 100
    ua /= h;
    ba /= h;
    ua += ba / m;
    ba %= m;

    if (ua == 0LL) {
        std::cout << ba << std::endl;
    } else {
        printf("%lld%09lld\n", ua, ba);
    }

    return 0;
}

Measured memory_bytes: 3784
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int a = stdIn.nextInt();
    int b = stdIn.nextInt();
    int c = stdIn.nextInt();

    if (a < b && b < c) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> card(n * 2);
	for (int i = 0; i < n * 2; i++) {
		card[i] = i + 1;
	}
	int m;
	cin >> m;
	while (m--) {
		int k;
		cin >> k;
		if (k == 0) {
			auto tmp = card;
			for (int i = 0; i < n; i++) {
				card[i * 2] = tmp[i];
				card[i * 2 + 1] = tmp[n + i];
			}
		}
		else {
			auto tmp = card;
			for (int i = 0; i < n * 2; i++) {
				if (i < k) {
					card[n * 2 - k + i] = tmp[i];
				}
				else {
					card[i - k] = tmp[i];
				}
			}
		}
	}
	for (int i = 0; i < n * 2; i++) {
		cout << card[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 3156
n = int(input())

ans = True
words = []
wset = set()
for i in range(n):
    word = input()
    words.append(word)
    if word in wset:
        ans = False
    wset.add(word)

last = words[0]
for w in words[1:]:
    if last[-1] != w[0]:
        ans = False
        break
    last = w

print("Yes" if ans else "No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int N;
    cin >> N;
    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        ans += (N-1) / i;
    }
    printf("%lld\n", ans);

}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000
using namespace std;
typedef pair<int, int> P;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int main()
{
    int N, W, H;
    cin >> N >> W >> H;
    vector<int> h(H + 10, 0);
    vector<int> w(W + 10, 0);
    rep(i, N)
    {
        int x, y, p;
        //cin >> x >> y >> p;
        scanf("%d%d%d", &x, &y, &p);
        h[max(0, y - p)]++;
        h[min(y + p, H + 1)]--;
        w[max(0, x - p)]++;
        w[min(x + p, W + 1)]--;
    }
    for (int i = 0; i <= W; i++)
    {
        if (i == 0)
            continue;
        w[i] += w[i - 1];
    }
    for (int i = 0; i <= H; i++)
    {
        if (i == 0)
            continue;
        h[i] += h[i - 1];
    }
    bool flag = false;
    for (int i = 0; i < W; i++)
    {
        if (w[i] == 0)
            //0があったらもう片方を確認する
            flag = true;
    }
    if (flag == false)
    {
        cout << "Yes" << endl;
        return 0;
    }
    else
    {
        for (int i = 0; i < H; i++)
        {
            if (h[i] == 0)
                flag = false;
        }
    }
    if (!flag)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    //return 0;
    /*rep(i, W + 1) cout << w[i] << " ";
    cout << endl;
    rep(i, H + 1) cout << h[i] << " ";
    cout << endl;*/
    return 0;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
//vector<ll> graph[1000005];
bool compare(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.second > b.second); 
}
int findmax(int arr[], int n){
	int curr_max = -1;
	for(int i=0;i<n;i++){
		curr_max = max(curr_max, arr[i]);
		}
	return curr_max;
	}
bool help(int arr[], int mid, int n, int c){
	int last_pos = arr[0];
	int cows = 1;
	for(int i=0;i<n;i++){
		if(abs(arr[i]-last_pos) >= mid){
			last_pos = arr[i];
			if(++cows == c)
				return true;
			last_pos = arr[i];
		}
	}
	return false;
}
ll calc(ll a, ll b, ll c){
	return abs(a-b)+abs(b-c)+abs(c-a);
	}
ll nc2(ll n){
	return n*(n-1)/2;
	}
ll gcd(ll a, ll b)  
{  
    if (a == 0)  
    {  
        return b;  
    }
    return gcd(b%a, a);  
}  
int main() 
{
	fast 
	ll t;
	//cin>>t;
	t=1;
	while(t--){
		int k, n;
		cin>>k>>n;
		vector<int> v;
		for(int i=0;i<n;i++){
			int x; cin>>x;
			v.push_back(x);
			}
		sort(v.begin(), v.end());
		int mx = 0;
		for(int i=1;i<n;i++){
			mx = max(mx, v[i]-v[i-1]);
			}
		mx = max(mx, k+v[0]-v[n-1]);
		cout<<k-mx<<endl;
	}
} 


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int a[105];
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++){
        int v=a[i];
        int j=i-1;
        while(j>=0 && v<a[j]){
            a[j+1]=a[j];
            j--;
            a[j+1]=v;
        }
        for(int j=0;j<n;j++){
            cout<<a[j];
            if(j!=n-1) cout<<" ";
        }
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 3092
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>


int main(void)
{
	int i, j, n, k, L[50], box, ans = 0;

	scanf("%d %d",&n,&k);

	for (i = 0; i < n; i++){
		scanf("%d",&L[i]);
	}

	for (i = n - 1; i > 0; i--){
		for (j = 0; j < i; j++){
			if (L[i] > L[j]){
				box = L[j];
				L[j] = L[i];
				L[i] = box;
			}
		}

	}

	for (i = 0; i < k; i++){
		ans += L[i];
	}
	
	printf("%d\n",ans);
	

	return 0;
}


Measured memory_bytes: 128
n = int(input())
s = list(input())
w = []
e = []
x = 0
y = 0
ans = 1000000

#西と東の累積和を取る
for c in s:
    if c == "W":
        x += 1
    else:
        y += 1
    w.append(x)
    e.append(y)

for i in range(n):
    if i == 0:
        z = e[n-1] - e[i]
    elif i == n-1:
        z = w[i-1]
    else:
        z = w[i-1] + e[n-1] - e[i]
    if z < ans:
        ans = z

print(ans)

Measured memory_bytes: 96576
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
#define INF 1<<20

struct edge{
	int to;
	int cost;
	edge() {};
	edge(int a, int b) {
		to = a;
		cost = b;
	}
};

struct Node {
	int pos;
	int cost;
	Node() {};
	Node(int a, int b) {
		pos = a;
		cost = b;
	}
	bool operator <(const Node& rhs) const {
		return cost > rhs.cost;
	}
};

void dijkistra(int st, int TO,int V,vector<vector<edge> > graph) {
	priority_queue<Node> q;
	vector<int> d(V);
	for (int i = 0;i < V;i++) {
		d[i] = INF;
	}
	d[st] = 0;
	q.push(Node(st, 0));
	while (!q.empty()) {
		Node s = q.top(); q.pop();
		int pos = s.pos;
		for (int i = 0;i < graph[pos].size();i++) {
			int to = graph[pos][i].to;
			int cost = graph[pos][i].cost;
			if (d[pos] + cost < d[to]) {
				d[to] = d[pos] + cost;
				q.push(Node(to, d[to]));
			}

		}
	}
	cout << d[TO] << endl;
}
int partition(int A[],int p, int r) {
	int x = A[r];
	int i = p - 1;
	for (int j = p;j < r;j++) {
		if (x >= A[j]) {
			i = i + 1;
			swap(A[i], A[j]);
		}
	}
		swap(A[i + 1], A[r]);
		return i + 1;
}
void quicksort(int A[], int p, int r) {
	if (p < r) {
		int q = partition(A, p, r);
		quicksort(A, p, q-1);
		quicksort(A, q + 1, r);
	}
}

int getNumberOfCoin(int C[],int n,int m) {
	int T[50000];
	for (int j = 0;j <= n;j++) {
		T[j] = INF;
	}
	T[0] = 0;
	for (int i = 0;i < m;i++) {
		for (int j = 0;j <= n;j++) {
			if (j - C[i] >=0  ) {
				T[j] = min(T[j], T[j - C[i]] + 1);
			}
		}
	}
	return T[n];
}
int knapsack(int w, int n,int* v,int* ww) {
	int W[101][10001];
		for (int j = 0;j <= w;j++) {
			W[0][j] = 0;
		}
	for (int i = 0;i < n;i++) {
		for (int k = 0;k < n;k++){
			for (int j = 0;j <= w;j++) {
				if (j - ww[k] < 0) {
					W[i + 1][j] = W[i][j];
				}
				if (j - ww[i] >= 0) {
					W[i + 1][j] = max(W[i][j], W[i][j - ww[k]] + v[k]);

				}
			}
		}
	}
	return W[n][w];
}
int fib(int n) {
	vector<int> v(n+1);
	v[0] = 1;
	v[1] = 1;
	for (int i = 2;i < n+1;i++) {
		v[i] = v[i - 2] + v[i - 1];
	}
	return v[n];
}
int isPrime(int x) {
	if (x <= 1) return false;
	if (x>2 && x % 2 == 0) return false;
	for (int i = 2;i <= sqrt(x);i++) {
		if (x%i == 0) {
			return false;
		}
	}
	if (x == 2) return true;
	return true;
}
int Prime(int x) {
	vector<int> prime(x+1,1);
	int num = 2;
	while (num <= sqrt(x)) {
		for (int i = 2;i <= x / num;i++) {
			prime[num*i] = 0;
		}
		num++;
		while (prime[num] == 0)
			num++;
	}
	int count = 0;
	for (int i = 2;i < x + 1;i++) {
		if (prime[i] == 1) count++;
	}
	return count;
}
int main(){
	int a[4], b[4];
	while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) {
		int H = 0;
		int B = 0;
		for (int i = 0;i < 4;i++) {
			for (int j = 0;j < 4;j++) {
				if (a[i] == b[j]) {
					if (i == j) H++;
					else B++;
				}
			}
		}
		cout << H << " " << B<<endl;
	}

}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> X(N),Y(N);
  for(int i=0;i<N;i++){cin >> X[i]; Y[i]=X[i];}
  sort(X.begin(),X.end());
  int a=X[N/2-1]; int b=X[N/2];
  for(int i=0;i<N;i++){
    if(Y[i]<=a){cout << b << endl;}
    else{cout << a << endl;}
  }
}

Measured memory_bytes: 3712
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		int ans = 0;
		for (int i = 1; i <= N; i++) {
			String str = String.valueOf(i);
			int count = 0;
			for (char c : str.toCharArray()) {
				count += (int)c - 48;
			}
			
			if (count >= A && count <= B) {
				ans += i;
			}
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define iint int
#define pll std::pair<iint,iint>
#define rep(i,a,b) for(iint i=(iint)a;i<(iint)b;i++)
#define per(i,a,b) for(iint i=(iint)a;i>(iint)b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;
const long long mul = 1e6+1;

long long pow_mod(long long a, long long b){
	if(a==0)
		return 0ll;

	if(b==0)
		return 1ll;

	if(b==1)
		return a%MOD;

	long long x = pow_mod(a,b/2);
	if(b%2==1)
		return (((x*x)%MOD)*a)%MOD;

	return (x*x)%MOD;
}

void solve(){
	long long a,b,x, y;
	std::cin >> x >> y;
	a = 2*y-x;
	b = 2*x-y;

	if(a < 0 || b < 0 || a%3 != 0 || b%3 != 0){
		std::cout << 0 << "\n";
		return;
	}

	a/=3;
	b/=3;

	std::vector<long long> dp(int(a+b+1),1ll);
	for(int i=2;i<dp.size();i++){
		dp[i] = (dp[i-1]*(1ll*i))%MOD;
	}

	std::cout << (dp[a+b]*(pow_mod((dp[a]*dp[b])%MOD,MOD-2)))%MOD << "\n";
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);

	// int t;
	// std::cin >> t;
	// while(t--){
	// 	solve();
	// }

	solve();
	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
#define INF 1e8
typedef long long ll;
typedef long double ld;

vector<ll> prime_fact(ll a){
    ll i = 2;
    vector<ll> rel;
    for(ll d = 2; d*d <= a; d++){
        if(a % d != 0) continue;
        rel.emplace_back(d);
        while(a % d == 0){
            a /= d;
        }
    }
    if(a != 1) rel.emplace_back(a);
    return rel;
}

long long gcd(long long a,long long b){
    if(a < b) swap(a, b);
    if(b == 0) return a;
    if(a % b == 0) return b;
    return gcd(b, a % b);
}

int main() {
    ll a, b;
    cin >> a >> b;
    ll x = gcd(a, b);
    vector<ll> pf = prime_fact(x);
    
    cout << pf.size()+1 << endl;
}




Measured memory_bytes: 256
n,m = map(int, input().split())

es = [tuple(map(lambda x: int(x)-1, input().split())) for _ in range(m)]

class UnionFind:
    def __init__(self, n):
        self.parent = [i for i in range(n)]
        self.rank = [0] * n
        self.count = 0

    def root(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.root(self.parent[x])
            return self.parent[x]

    def is_same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry:
            return
        if self.rank[rx] < self.rank[ry]:
            self.parent[rx] = ry
        else:
            self.parent[ry] = rx
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1
        self.count += 1


ans = 0
for i in range(m):
    uf = UnionFind(n)
    for j, (a, b) in enumerate(es):
        if i == j:
            continue # 一つ辺を外す
        if uf.is_same(a, b):
            continue # 現時点で繋がってるのでOK
        uf.unite(a, b)
    x, y = es[i]
    if not uf.is_same(x, y):
        ans += 1 # ある辺を外した時にその辺の両端のノードが同じ集合でないと繋がってないので橋といえる

print(ans)

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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

#define MX 100016

bool vis[MX];
int f[MX];
vpii adj[MX];
pii e[MX];

int dfs(int u)
{
    vis[u] = true;
    int s = 0;
    for (const pii &ep : adj[u]) {
        int v = ep.fir, i = ep.sec;
        ctif(vis[v]);
        int t = dfs(v);
        s ^= t;
        if (t) swap(e[i].fir, e[i].sec);
    }
    return s^f[u];
}

int main()
{
    canhazfast();

    int n, m;

    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        e[i] = {u, v};
        adj[u].empb(v, i);
        adj[v].empb(u, i);
        f[u] ^= 1;
    }
    retif(m%2) cout << "-1\n", 0;
    dfs(1);
    for (int i = 0; i < m; ++i) cout << e[i].fir << ' ' << e[i].sec << '\n';

    return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
const ll INF=100000000000000LL;
ll ans=0,ans2=0;
ll A,B,C,D;
ll N;
int main() {
	cin>>N>>A>>B;
	for(int i=0;i<=N;++i){
		int k=i,r=10000,m=0;
		for(int j=0;j<5;++j){
			m+=k/r;
			k%=r;
			r/=10;
		}
		if(m>=A&&m<=B)ans+=i;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
%:pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
// by piano
template<typename tp> inline void read(tp &x) {
    x = 0;char c = getchar();bool f = 0;
    for(; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
    for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if(f) x = -x;
}
const int N = 2e5 + 10 ;

// f[i] ±íÊ¾µÚiÎ»µÄ´ð°¸
// b[set] ±íÊ¾×Ó¼¯Î»setÊ±ºò×îÐ¡µÄ´ð°¸ÊÇ¶àÉÙ
int f[N], b[(1 << 26) + (1 << 4)], bit[30], n;
char str[N];
int xors = 0;
int solve(int x) {
	int ans = b[xors] + 1;
	for(int i = 0; i < 26; i ++) {
		ans = min(ans, b[xors ^ bit[i]] + 1);
	}
	b[xors] = min(b[xors], ans);
	return ans;
}


main() {
	scanf("%s", str + 1); n = strlen(str + 1);
	for(int i = 0; i <= 26; i ++) bit[i] = (1 << i);
	memset(b, 38, sizeof(b));
	xors = 0;b[0] = 0;
	for(int i = 1; i <= n; i ++) {
		str[i] -= 'a';
		xors ^= bit[str[i]];
		f[i] = solve(i);
//		cout << b[0] << "\n";
//		cout << xors << "\n";
//		cout << f[i] << "\n";
	}
	cout << f[n] << "\n";
}

Measured memory_bytes: 263424
# -*- coding: utf-8 -*-

def bs(n, k, W):
    left, right = max(W), sum(W)
    mid = 0
    while left < right:
        mid = left + (right - left) // 2
        if is_enough(mid, k, W):
            right = mid
        else:
            left = mid + 1
    return left

def is_enough(p, k, W):
    trk_cnt = 1
    weight = 0
    for i in W:
        weight += i
        if weight > p:
            trk_cnt += 1
            weight = i
            if trk_cnt > k:
                return False
    return True

def main():
    n, k = map(int, input().split())
    W = [int(input()) for _ in range(n)]
    rslt = bs(n, k, W)
    print(rslt)

if __name__ == '__main__':
    main()


Measured memory_bytes: 11496
from numpy import average
from decimal import Decimal, ROUND_HALF_UP
 
n=int(input())
x=list(map(int,input().split()))
 
p=Decimal(str(average(x))).quantize(Decimal('1'),rounding=ROUND_HALF_UP)
 
ans=0
for i in x:
	ans+=((i-p)**2)

print(ans)

Measured memory_bytes: 27152
<?php
 
function input_and_explode() {
    $input_line = trim(fgets(STDIN));
    return explode(" ", $input_line);
}

list($N, $K) = input_and_explode();
list($N, $K) = [(int)$N, (int)$K];

$diff = 0;

if ($N % $K === 0) {
    $diff = 0;
} else {
    $diff = 1;
}

echo "$diff\n";

Measured memory_bytes: 4856
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<string,int> P;

int main(){
  	int N;
    cin >> N;
    int h[N];

    for(int i=0;i<N;i++){
        cin >> h[i];
    }
    sort(h, h+N);

    int ans = 0;
    for(int i=0;i<N-1;i++){
        if(h[i]!=h[i+1]) ans++;
    }

    cout << ans + 1 <<endl;



  return 0;
}






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

int main(){
    int N;
    cin >> N;
  
  	int num = N % 10;
	if(num == 2 || num == 4 || num == 5 || num == 7 || num == 9){
      cout << "hon" << endl;
    } else if(num == 0 || num == 1 || num == 6 || num == 8){
      cout << "pon" << endl;
    } else {
      cout << "bon" << endl;
    }  
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iomanip>
#define f(i,a,b) for(ll i=a;i<b;i++)
#define r(i,a,b) for(ll i=a;i>b;i--)
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){

ll a,b;
cin>>a>>b;
cout << a*b << endl;

}

Measured memory_bytes: 3192
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;

int main(){
  int n;cin>>n;
  int odd=0;
  for(int i=0;i<n;i++){int t;cin>>t;if(t&1)odd++;}
  cout<<(odd&1?"NO":"YES")<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        String s = sc.next();
        String t = sc.next();

        int n = s.length();

        System.out.println(s.substring(0, n).equals(t.substring(0, n)) ? "Yes" : "No");
        sc.close();
    }
}

Measured memory_bytes: 35604