akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rp(i,n) for(int i=0; i<n; i++)
#define WARU 1000000007
using namespace std;
using ll=long long;
ll RepeatSquare(ll x,ll y,ll mod){
    if(y==0) return 1;
    if(y%2==0){
        ll a=RepeatSquare(x,y/2,mod);
        return a*a%mod;
    }
    if(y%2==1){
        return x*RepeatSquare(x,y-1,mod)%mod;
    }
}

int main(){
    ll n,k;
    cin >> n >> k;
    ll answer=0;
    if(k>n-1) k=n-1;
    ll com0,com1;
    rp(i,k+1){
        if(i==0) {
            com0=1; com1=1;
            answer += 1;
            continue;
        }
        com0 *= n+1-i; com1 *= n-i;
        com0 %= WARU; com1 %=WARU;
        com0 *= RepeatSquare(i,WARU-2,WARU);
        com1 *= RepeatSquare(i,WARU-2,WARU);
        com0 %=WARU; com1 %= WARU;
        answer += com0 * com1;
        answer %= WARU;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#define int long long
using namespace std;

int n;
int t[100];

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

int lcm(int a, int b) {
	return (a / gcd(a, b)) * b;
}

signed main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> t[i];
	
	int ans = 1;
	for (i = 0; i < n; i++) ans = lcm(ans, t[i]);
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);


int main()
{
    LL s;
    cin >> s;

    LL sq = sqrt(s);
    if(sq * sq == s);
    else sq++;

    LL target = sq * sq;

    LL need = target - s;

    LL x2 = need;
    LL y1 = 1;

    LL x1 = sq;
    LL y2 = sq;

    cout << 0 << " " << 0 << " " << x1 << " " << y1 << " "<< x2 << " " << y2 << "\n";
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
template <typename T> T max(T, T);
int gcd(int a, int b);

int main() {
    // source
    int r, d, x;
    cin >> r >> d >> x;

    rep(i, 10) {
        x = r * x - d;
        cout << x << endl;
    }
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T max(T a, T b) {

    if (a > b) {
        return a;
    } else {
        return b;
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

string s, t;
int n, m;

vector<vector<int> > memo;
vector<vector<int> > step;

int solve(int a, int b)
{
    if(a == n || b == m)
        return 0;
    if(memo[a][b] != -1)
        return memo[a][b];

    int ret = 0;
    if(s[a] == t[b]){
        ret = solve(a+1, b+1) + 1;
        step[a][b] = 0;
    }

    int x = solve(a+1, b);
    if(x > ret){
        ret = x;
        step[a][b] = 1;
    }

    int y = solve(a, b+1);
    if(y > ret){
        ret = y;
        step[a][b] = 2;
    }

    return memo[a][b] = ret;
}

int main()
{
    for(;;){
        string input;
        cin >> input;
        if(input == "#END")
            return 0;

        string ret;
        for(unsigned i=1; i<input.size(); ++i){
            s = input.substr(0, i);
            t = input.substr(i);
            n = i;
            m = input.size() - i;

            memo.assign(n+1, vector<int>(m+1, -1));
            step.assign(n+1, vector<int>(m+1, -1));
            solve(0, 0);

            string u;
            int a = 0;
            int b = 0;
            while(step[a][b] != -1){
                if(step[a][b] == 0){
                    u += s[a];
                    ++ a;
                    ++ b;
                }else if(step[a][b] == 1){
                    ++ a;
                }else{
                    ++ b;
                }
            }

            if(u.size() > ret.size())
                ret = u;
        }

        cout << ret << endl;
    }
}

Measured memory_bytes: 1644
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#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>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

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

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

  if(n%2==0)cout << n << endl;
  else cout<<n*2<<endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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(a>b){a=b;return true;}return false;}

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl



int main(){
    int n;
    cin>>n;
    int mi=32;
    REP(i,n){
        int a;
        cin>>a;
        int cnt=0;
        while((a&bit(cnt))==0){
            cnt++;
        }
        chmin(mi,cnt);
    }
    cout<<mi<<endl;
    return 0;
}


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

#define int long long

typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int N;
string S;
int cnt[26];
signed main(){
    cin>>N>>S;
    rep(i,N)if(isalpha(S[i]))cnt[S[i]-'a']++;

    bool f=false;
    int ans=0;

    reps(i,1,10){
        int hoge=count(cnt,cnt+26,i);
        if(hoge==0)continue;
        if(f)ans++;
        else f=true;
        ans+=2*hoge-1;
        if(i!=1){
            if(hoge==1)ans+=2;
            else ans+=4;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1204
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int N, M, a[55], b[55], par[55];
int root(int x) {
	if (x == par[x]) return x;
	return par[x] = root(par[x]);
}
void unite(int x, int y) {
	x = root(x);
	y = root(y);
	par[x] = y;
}
int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) cin >> a[i] >> b[i], a[i]--, b[i]--;
	int ret = 0;
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < N; j++) par[j] = j;
		for (int j = 0; j < M; j++) {
			if (i != j) unite(a[j], b[j]);
		}
		bool f = false;
		for (int j = 1; j < N; j++) {
			if (root(j - 1) != root(j)) f = true;
		}
		if (f) ret++;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
    string s;
    cin>>s;
    bool ok=true;
    for(int i=0; i<s.size()/2; i++){
        if(s[i]!=s[s.size()-1-i]) ok=false;
    }
    int n=s.size();
    n=(n-1)/2;
    for(int i=0; i<n/2; i++){
        if(s[i]!=s[n-1-i]) ok=false;
    }
    n=s.size();
    //if(ok) cout<<"d"<<endl;
    int x=(s.size()+3)/2;
    for(int i=0; i<x/2; i++){
        if(s[x+i-1]!=s[s.size()-i-1]) ok=false;
        //cout<<x+i-1<<" "<<s.size()-i<<endl;
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
S = input()

ans = []
i = N
while i > 0:
    for m in range(M,0,-1):
        if i-m <= 0:
            ans.append(i)
            i = 0
            break
        if S[i-m]=='0':
            ans.append(m)
            i -= m
            break
    else:
        print(-1)
        exit()
print(*ans[::-1])

Measured memory_bytes: 6372
#include <bits/stdc++.h>
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

int main() {
	fastIO;
#ifdef LOCAL
//	freopen("input.in", "rt", stdin);
#endif
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	for (int i = 0; i < 200; ++i) {
		c -= b;
		if(c <= 0) {
			cout << "Yes";
			return 0;
		}
		a -= d;
		if(a <= 0) {
			cout << "No";
			return 0;
		}
	}
	return 0;
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int N;
Vl A;
Vl csum;
ll a;
Vl can;


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

    cin >> N;
    A.resize(N);
    csum.resize(N + 1);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        csum[i + 1] = csum[i] + A[i];
    }

    int left = 0;
    int right = 0;
    ll ans = L_INF;
    Vl s(4);
    for (int i = 2; i <= N - 2; i++) {
        while (left <= i - 1 && csum[left] < csum[i] - csum[left]) ++left;
        if (left > 1) {
            ll u = abs((csum[i] - csum[left]) - csum[left]);
            ll v = abs((csum[i] - csum[left - 1] - csum[left - 1]));
            if (v < u) {
                --left;
            }
        }
        while (right <= N - 1 && csum[right] - csum[i] < csum[N] - csum[right]) ++right;
        if (right > i + 1) {
            ll u = abs((csum[N] - csum[right]) - (csum[right] - csum[i]));
            ll v = abs((csum[N] - csum[right - 1]) - (csum[right - 1] - csum[i]));
            if (v < u) {
                --right;
            }
        }
        s[0] = csum[left];
        s[1] = csum[i] - csum[left];
        s[2] = csum[right] - csum[i];
        s[3] = csum[N] - csum[right];
        sort(s.begin(), s.end());
        ans = min(ans, abs(s[3] - s[0]));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3456
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 262144
#define REP(i,n) for(long long i = 0;i < n;++i)
int main(){
	int h, w;
	cin >> h >> w;
	vector<pair<int,int>> geko;
	REP(i, h) {
		string s;
		cin >> s;
		long long now_max = -1;
		long long now_min = 1e5;
		REP(q, w) {
			if (s[q] == 'B') {
				now_min = min(now_min, q);
				now_max = max(now_max, q);
			}
		}
		if (now_max != -1) {
			geko.push_back(make_pair(i, now_min));
			geko.push_back(make_pair(i, now_max));
		}
	}
	int ans = 0;
	REP(i, geko.size()) {
		REP(q, geko.size()) {
			ans = max(ans, abs(geko[i].first - geko[q].first) + abs(geko[i].second - geko[q].second));
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3268
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
dp = [[0 for i in range(3)] for j in range(n+1)]
for i in range(n):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i+1][j] = max(dp[i+1][j], dp[i][k]+a[i][j])
print(max(dp[n]))

Measured memory_bytes: 47320
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S;
  cin>>N>>S;
  for(int i=0;i<S.size();i++){
    if(((int)S.at(i))+N>(int)'Z'){
      S.at(i)=(char)((int)S.at(i)+N-26);
    }
    else{
      S.at(i)=(char)((int)S.at(i)+N);
    }
  }
  cout<<S<<endl;
}


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

using namespace std;

constexpr size_t MAX_N = 100000;
int N;
int H[MAX_N];
int memo[MAX_N];

int cost(int i) {
  if (i == N-1) return 0;

  if (memo[i] != -1) return memo[i];

  if (!(i+2 < N)) {
    memo[i] = abs(H[i+1] - H[i]) + cost(i+1); 
    return memo[i];
  }

  memo[i] = min(
    abs(H[i+1] - H[i]) + cost(i+1),
    abs(H[i+2] - H[i]) + cost(i+2) 
  );

  return memo[i];
}

int main() {
  
  scanf("%d", &N);

  for (int i=0; i<N; i++) {
    memo[i] = -1;
  }

  for (int i=0; i<N; i++) {
    scanf("%d", &H[i]);
  }

  printf("%d\n", cost(0));
  
  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int f(int a,int b)
{
	return a>b;
}
int main()
{
	int a[100];
	int n=3;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n,f);
	int s=0;
	for(int i=0;i<n-1;i++)
		s=s*10+a[i];

	s=s+a[n-1];
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
using D = double;

const D EPS = 1e-8;

struct Point {
  D x, y, z;
  Point(D x, D y, D z) : x(x), y(y), z(z) {}
};

Point operator-(Point A, Point B){
  A.x -= B.x;
  A.y -= B.y;
  A.z -= B.z;
  return A;
}

D dot(Point A, Point B){
  return A.x*B.x + A.y*B.y + A.z*B.z;
}

D dist(Point A, Point B){
  Point dd = A - B;
  D d = sqrt(dot(dd,dd));
  return d;
}

using L = pair<Point,Point>;

D dist(L l, Point p){
  D d = min(dist(l.first,p),dist(l.second,p));
  if(dot(l.second-l.first,p-l.first) > -EPS and dot(l.first-l.second,p-l.second) > -EPS){
    D ll = sqrt(dot(l.second-l.first,l.second-l.first));
    D lp = sqrt(dot(p-l.first,p-l.first));
    D theta = acos(dot(l.second-l.first,p-l.first)/ll/lp);
    d = min(d,lp*sin(theta));
  }
  return d;
}

int main(){
  using S = pair<Point,D>;
  int N, M, R;
  while(cin >> N >> M >> R, N||M||R){
    vector<S> V;
    for(int i = 0; i < N; ++i){
      D x, y, z, r;
      cin >> x >> y >> z >> r;
      Point p(x,y,z);
      V.emplace_back(p,r);
    }
    vector<S> T;
    for(int i = 0; i < M; ++i){
      D x, y, z, d;
      cin >> x >> y >> z >> d;
      Point p(x,y,z);
      T.emplace_back(p,d);
    }
    D x, y, z;
    cin >> x >> y >> z;
    Point E(x,y,z);
    D ans = 0;
    for(int i = 0; i < (1<<M); ++i){
      D t = 0;
      int c = 0;
      for(int k = 0; k < M; ++k){
        if((i>>k)&1) continue;
        t += T[k].second/dist(E,T[k].first)/dist(E,T[k].first);
      }
      if(t < ans) continue;
      for(int j = 0; j < N; ++j){
        for(int k = 0; k < M; ++k){
          if((i>>k)&1) continue;
          if(dist(L(T[k].first,E),V[j].first) <= V[j].second+EPS and
             (dist(T[k].first,V[j].first) > V[j].second-EPS or
              dist(E,V[j].first) > V[j].second-EPS)){
            ++c;
            break;
          }
        }
        if(c > R) break;
      }
      if(c <= R){
        ans = max(ans,t);
      }
    }
    printf("%.12f\n",ans);
  }
}



Measured memory_bytes: 3748
import collections
N=int(input())
A=list(map(int,input().split()))
c = collections.Counter(A)
x = 0
#print(c)
for i in c.values():
    x += i*(i-1)//2
#print(x)
for i in range(N):
    print(x-c[A[i]]+1)


Measured memory_bytes: 109504
"""dfs"""

n = int(input())
import sys
sys.setrecursionlimit(10**6)

to = [[] for _ in range(n)]
eid = [[] for _ in range(n)]
ans = [0]*n

def dfs(v, c=-1, p=-1):
    k = 1
    for i in range(len(to[v])):
        u = to[v][i]
        ei = eid[v][i]
        if u == p: continue
        if k == c: k += 1
        ans[ei] = k
        k += 1
        dfs(u,ans[ei],v)

for i in range(n-1):
    a,b = map(int, input().split())
    a -= 1; b -= 1
    to[a].append(b); eid[a].append(i)
    to[b].append(a); eid[b].append(i)

dfs(0)
mx = 0
for i in range(n):
    mx = max(mx, len(to[i]))
print(mx)
for i in range(n-1):
    print(ans[i])

Measured memory_bytes: 84656
import java.util.Scanner;
import java.util.Arrays;

public class Main{
  static int judge(String a, String b){
    if(a.equals(b)){
      return 1;
    }else{
      return 0;
    }
  }


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


    String[] s = sc.next().split("");
    //System.out.println(StringTolist(s));
    for(int i=0; i<s.length-1;i++){
    count += judge(s[i],s[i+1]);
   }
   if(count==0){
     System.out.println("Good");
   }else{
     System.out.println("Bad");
   }

  }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
// ==================================================
using i64 = int64_t; using u64 = uint64_t;
#define rep(i,a,b) for(i64 i=(i64)(a);i<(i64)(b);i++)
#define repn(i,n) rep(i,0,n)
#define din(t, ...) t __VA_ARGS__;_din(__VA_ARGS__)
#define stlv(t,n) vector<t> n
#define stls(t,n) set<t> n
void _din() {} void dout() { cout << endl; }
template <typename T, typename ... Args> inline void _din(T& head, Args& ... rest) { cin >> head; _din(rest...); }
template <typename T, typename ... Args> inline void dout(T head, Args ... rest) { cout << head; if (sizeof...(rest)) cout << ' '; dout(rest...); }
template <typename T>inline void vsortg(vector<T>& v) { sort(v.begin(), v.end(), greater<T>()); }
template <typename T>inline void vsortl(vector<T>& v) { sort(v.begin(), v.end(), less<T>()); }
template <typename T> inline T nmax(T f1, T f2) { return max(f1, f2); }
template <typename T, typename ... Args> inline T nmax(T first, Args ... rest) { return nmax(first, nmax(rest...)); }
template <typename T> inline T nmin(T f1, T f2) { return min(f1, f2); }
template <typename T, typename ... Args> inline T nmin(T first, Args ... rest) { return nmin(first, nmin(rest...)); }

int main()
{
	din(i64, n);
	stlv(i64, v(n));

	repn(i, n)
	{
		din(, v[i]);
	}
	vsortl(v);
	i64 st = 0;
	for (;;)
	{
		for (int i = st + 1; i < n; i++)
		{
			if ((v[i] - v[st]) % (n - 1) == 0)
			{
				dout(v[i], v[st]);
				return 0;
			}
		}
		if (st + 1 < n) st++;
		else

			break;
	}
	return 0;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;

int N;
int P[200001];
map<int,int>m;

int main(){
	cin>>N;
	REP(i,N){
		cin>>P[i];
		m[P[i]-1]=i;
	}
	int ans=0;
	int pos=-1;
	int now=0;
	REP(i,N){
		int x=m[i];
		if(x>pos){
			now++;
			ans=max(ans,now);
			pos=x;
		}else{
			pos=x;
			now=1;
			ans=max(ans,now);
		}
	}
	cout<<N-ans<<endl;
	return(0);
}

Measured memory_bytes: 10368
x,y,a,b,c = list(map(int,input().split()))
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
res = 0

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

p = p[:x]
q = q[:y]

p_sum = sum(p)
q_sum = sum(q)

p_num = -1
q_num = -1

for i in r:
    if p_num >= (len(p) * -1):
        p_temp = (p_sum - p[p_num] + i)
    else:
        p_temp = -1
    if q_num >= (len(q) * -1):
        q_temp = (q_sum - q[q_num] + i)
    else:
        q_temp = -1

    if p_temp >= p_sum or q_temp >= q_sum:        
        if p_temp - p_sum > q_temp - q_sum:
            p_sum = p_temp
            p_num -= 1        
        else:
            q_sum = q_temp
            q_num -= 1        
    else:
        break
    




print(p_sum + q_sum)
    

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

int main() {
    ll N; cin >> N;
    vll a(N+1);
    rep(i, N) cin >> a[i+1];
    vll ans(N+1, 0);
    ll cnt = 0;
    for(ll i = N; i >= 1; i--) {
        ll sum = 0;
        for(ll k = N/i; k > 1; k--) sum += ans[i * k];

        if(sum % 2 == a[i]) ans[i] = 0;
        else ans[i] = 1, cnt++;
    }

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

    cout << cnt << endl;
    rep(i, N) if(ans[i+1] == 1) cout << i+1 << " ";
    cout << endl;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(false);cin.tie(0);

typedef long long int ll;
const ll mod = 1e9 + 7;
int n;
ll memo[1000010][2][2];

ll dp(int idx, int cero, int nueve) {
	//cout << idx << " " << zero << " " << nine << "\n";
	if (idx == n) {
		if (cero and nueve)
			return 1;
		return 0;
	}
	if (memo[idx][cero][nueve] != -1) return memo[idx][cero][nueve];
	ll ans = 0;
	for (int i = 0; i < 10; i++) {
		if (i == 0) {
			ans = (ans + dp(idx + 1, 1, nueve)) % mod;
		}
		else if (i == 9) {
			ans = (ans + dp(idx + 1, cero, 1)) % mod;
		}
		else {
			ans = (ans + dp(idx + 1, cero, nueve)) % mod;
		}
	}
	//return ans;
	return memo[idx][cero][nueve] = (ans % mod);
}

int main() {
	optimizar_io

	cin >> n;
	if (n == 1) {
		cout << "0\n";
	}
	else if(n == 2) {
		cout << "2\n";
	}
	else {
		memset(memo, -1, sizeof(memo));
		cout << dp(0, 0, 0) << "\n";
	}
	return 0;
}

Measured memory_bytes: 112900
#include<bits/stdc++.h>
#define P pair<int,int>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	string S;
	cin>>S;
	vector<P>dp;
	int i=0;
	while(i<n){
		if(S[i]=='0'){
			int start=i;
			while(i<n && S[i]=='0')
				i++;
			int end=--i;
			dp.push_back({start,end});
		}
		i++;
	}
	if(k>=dp.size()){
		cout<<n<<"\n";
		return 0;
	}
	// for(int itr=0;itr<dp.size();itr++){
	// 	cout<<dp[itr].first<<" "<<dp[itr].second<<"\n";
	// }
	int max_value=dp[k].first;
	i=0;
	int j=k+1;
	// cout<<"max_value:"<<max_value<<"\n";
	while(j<dp.size()){
		max_value=max(max_value,dp[j].first-dp[i].second-1);
		i++;
		j++;
		// cout<<"max_value:"<<max_value<<"\n";
	}
	
	max_value=max(max_value,n-1-dp[i].second);
	cout<<max_value;
	return 0;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
int a[200010],n;
bool s[200010];
int main()
{
    cin>>n;
    s[0]=true;int t=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(s[a[i]-1]){t++;s[a[i]]=true; s[a[i]-1]=false;}
    }
    if(t==0)t=n+1;
    cout<<n-t<<endl;
    return 0;
}


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

int main() {
  int N, tmp, sum;
  cin >> N;
  tmp = N;
  sum = 0;
  
  while (tmp >= 10)
  {
    sum += tmp % 10;
    tmp /= 10;
  }
  sum += tmp;
  
  if (N % sum == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(){
    int N;
    float ans;
    scanf("%d",&N);
    int tmp = N/2;
    if(N%2==1){
        tmp++;
    }
    float tmp2 = tmp;
    ans = tmp2 / N;
    printf("%f\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    sort(h.begin(), h.end(), greater<int>());
    long long ans = 0;
    for(int i = k; i < n; i++) ans += h[i];
    cout << ans << endl; 
}

Measured memory_bytes: 3976
import java.util.Scanner;

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

        int a = Integer.parseInt(scan.next());
        int b = Integer.parseInt(scan.next());

        int area = a * b;
        int len = 2*a + 2*b;

        System.out.println(area + " " + len);
    }
}

Measured memory_bytes: 26132
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const double pi=3.14159265358979323846;
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b){
    if (a % b == 0){
        return(b);
    }else{
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
bool isprime(int n){
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2){
        if (n % i == 0){
            return false;
        }
    }
    return true;
}
void sayYes(bool f) {
    if (f) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}
void sayYES(bool f) {
    if (f) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

int main() {
  int a;
  cin >> a;
  cout << a+a*a+a*a*a << endl;
}

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


using namespace std;
using ll = long long;


int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(auto& x : a) cin >> x;
  ll res = 0;
  for(ll i = 1; i < n; i++) {
    if(a[i] >= a[i-1]) continue;
    res += a[i-1] - a[i];
    a[i] = a[i-1];
  }
  cout << res << "\n";

    



  return 0;
}



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

int N,X,c=0;
string S;
vector<int> L(105);

int main(){
	cin>>N>>X;
	L.at(0)=0;
	for(int i=1;i<N+1;i++){
		int a;
		cin>>a;
		L.at(i) = L.at(i-1)+a;
	}

	L.resize(N+1);

	for(int i=0;i<N+1;i++){
		if(L.at(i)<=X)
			c++;
	}

	cout<<c<<endl;

}

Measured memory_bytes: 256
'use strict'
 
function Main(input) {
	const ipts = input.split('\n');
	const A = Number(ipts[0].split(' ')[0]);
	const B = Number(ipts[0].split(' ')[1]);
	const C = Number(ipts[0].split(' ')[2]);
	const K = Number(ipts[1]);
	let answer = 0;
	
	answer = Math.max(A, B, C) *  Math.pow(2, K) + A + B + C - Math.max(A, B, C);
	
	console.log(answer);
 
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
S = input().strip()
N = len(S)
R = S[::-1]

if S != R:
    print('No')
    exit()

S2 = S[:(N-1)//2]
R2 = S2[::-1]
if S2 != R2:
    print('No')
    exit()

S3 = S[(N+3)//2-1:]
R3 = S3[::-1]
if S3 != R3:
    print('No')
    exit()

print('Yes')



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

int main(){
  int N,M,C;
  cin >> N >> M >> C;
  
  vector<int> B(M);
  vector<vector<int>> As(N);
  
  for(int i = 0;  i < M;i++){
   cin >> B.at(i); 
  }
  
  int ans = 0;
  for(int n = 0;  n < N; n++){
    int A;
    int sum = 0;
    for(int m = 0; m < M ; m++){
      cin >> A;
      sum += A * B.at(m);
    }
    if(sum + C > 0 ) ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#define Y(V,N)V+D[d][N]*z[j]
D[13][3]={{1,0,0},{0,1,0},{0,0,1},{1,1,0},{1,0,1},{0,1,1},{1,-1,0},{1,0,-1},{0,1,-1},{1,1,1},{-1,1,1},{1,-1,1},{1,1,-1}};
M[9][9][9],z[2];main(n,m,p,I,x,y,i,j,c,d){for(;scanf("%d%d%d",&n,&m,&p),n;){
	for(memset(M,0,sizeof(M)),c=1,I=0;I<p;c*=-1){
		scanf("%d%d",&x,&y),I++;
		for(i=1;;i++)if(!M[x][y][i]){M[x][y][i]=c;break;}
		for(d=0;d<13;d++){
			for(j=0;j<2;j++)for(z[j]=0;z[j]<m;z[j]+=2*j-1)if(M[Y(x,0)][Y(y,1)][Y(i,2)]!=c)break;
			if(z[1]-z[0]-1>=m){printf("%s %d\n",c==1?"Black":"White",I);goto next;}
		}
	}
	puts("Draw");
next:
	for(;I<p;I++)scanf("%d%d",&x,&y);
}exit(0);}

Measured memory_bytes: 608
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define pi pair<ll,ll>
using namespace std;
int main(){
	int W,a,b;
	//	freopen("in.txt","r",stdin);
	scanf("%d%d%d",&W,&a,&b);
	int ans = abs(a-b)-W;
	if(ans<0) printf("0\n");
	else printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define div l
long long int mod = (long long int)1000000007;
using namespace std;
    ll vis[1000001]={0};
    ll look[1000001]={0};
    vector<ll>div[1000001];
void solve()
{
    ll i,j,k,n;
    std::cout.precision(10);
    int yes=0;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        vis[a[i]]++;
    }
    for(i=1;i<=1000000;i++)
    {
        for(j=i;j<=1000000;j+=i)
        {
            div[j].pb(i);
        }
    }
    ll count=n;
    for(i=0;i<n;i++)
    {
        for(j=0;j<div[a[i]].size();j++)
        {
            if(div[a[i]][j]==a[i])
            {
                if(vis[a[i]]>1)
                {
                    count--;
                    break;
                }
            }
            else if(vis[div[a[i]][j]]>=1)
            {
                count--;
                break;
            }
        }
    }
    cout<<count;
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int i,j,k;
    int t;
    std::cout.precision(10);
    t=1;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 193376
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=4005,md=924844033;
int n,K,i,j,k,num,a[N],f[N][N][2],g[N][N],jc[N],ans;
int main()
{
	scanf("%d%d",&n,&K);
	for(i=1,num=0;i<=K;++i)
	{
		j=n/K+(i<=n%K?1:0);
		a[++num]=0;
		for(k=2;k<=j;++k)
			a[++num]=1;
		a[++num]=0;
		for(k=2;k<=j;++k)
			a[++num]=1;
	}
	jc[0]=1;
	for(i=1;i<=num;++i)
		jc[i]=1ll*jc[i-1]*i%md;
	f[1][0][0]=1;
	for(i=2;i<=num;++i)
		for(j=0;j<i;++j)
		{
			f[i][j][0]=(f[i-1][j][0]+f[i-1][j][1])%md;
			if(a[i]==1)
				f[i][j][1]=f[i-1][j-1][0];
		}
	for(i=0;i<=n;++i)
		ans=(ans+1ll*jc[n-i]*(f[num][i][0]+f[num][i][1])%md*(i&1?md-1:1)%md)%md;
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 126592
#include<bits/stdc++.h>
using namespace std;
#define Mod(n) n % 1000000007
const int dx[8] = {1, 0, -1, 0, -1, 1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};
int main()
{
    int H,W;
    cin >> H >> W;
    vector<string> v(H);
    vector<vector<int>> ans(H,vector<int>(W));
    for(int i = 0;i < H;i++)
    {
        cin >> v.at(i); 
    }
    for(int i = 0;i < H;i++)
        for(int j = 0;j < W;j++)
            ans.at(i).at(j) = 0;
    int noww,nowh;
    for(int i = 0;i < H;i++)
    {
        for(int j = 0;j < W;j++)
        {
            if(v[i][j] == '#')
            {
                for(int k = 0;k < 8;k++)
                {
                    noww = j + dx[k];
                    nowh = i + dy[k];
                    if(noww < 0 || W - 1 < noww)
                        continue;
                    if(nowh < 0 || H - 1 < nowh)
                        continue;
                    
                    ans.at(nowh).at(noww)++;
                }
            }
        }    
    }
    for(int i = 0;i < H;i++)
    {   
        for(int j = 0;j < W;j++)
        {   
            if(v[i][j] == '#')
                cout << "#";
            else
                cout << ans.at(i).at(j);
        
        }       
        cout << '\n';
    }
        
        
}


Measured memory_bytes: 256
import os, sys, re, math

(N, K) = [int(i) for i in input().split()]
h = []
for i in range(N):
    h.append(int(input()))

h.sort()
result = 10 ** 9
for i in range(N - K + 1):
    result = min(result, h[i + K - 1] - h[i])

print (result)


Measured memory_bytes: 7716
#include<bits/stdc++.h>
using namespace std;
int main(){
  double n;
  cin>>n;
  double sideAngle = 360/n;
  double sum = 0;
  for(int i=0;i<n;i++){
    sum+=(180.0-sideAngle);
  //  cout<<sum<<endl;
  }

  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

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

    reverse(h.begin(), h.end());
    
    bool ans = true;
    irep(i, n-1) {
        if(h[i] < h[i+1]) {
            if(h[i] < h[i+1]-1) {
                ans = false;
                break;
            } else {
                h[i+1]--;
            }
        }
    }
    if(ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
} /*atcoder*/



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

int main(void) {
  long long x;
  cin >> x;
  long long result = 0;
  result += (x / 500) * 1000;
  x %= 500;
  result += (x / 5) * 5;
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#define ll long long
using namespace std;

int main(void){
    ll n;
    cin >> n;
    vector<ll> a;
    vector<ll> count(n+1, 0);
    vector<ll> com(n+1, 0);
    ll ans = 0;
    for(ll i = 0; i < n; i++){
        ll b; cin >> b;
        a.push_back(b);
        count[b]++;
    }
    for(ll i = 1; i <= n; i++){
        com[i]=count[i]*(count[i]-1)/2;
        ans+=com[i];
    }
    for(ll i = 0; i < n; i++){
        ll check = a[i];
        cout << ans-com[check]+(count[check]-1)*(count[check]-2)/2 << endl;
    }
    return 0;
}


Measured memory_bytes: 7408
#include <stdio.h>

int A[20],n;

int solve(int i,int m){
  int res;
  if(m==0){
    return 1;
  }
  if(i>=n){
    return 0;
  }
  res=solve(i+1,m)||solve(i+1,m-A[i]);
    return res;
}

  int main(){
    int q,i,key;

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

    scanf("%d",&q);
    for(i=0;i<q;i++){
      scanf("%d",&key);
	if(solve(0,key)){
	  printf("yes\n");
	}
	else printf("no\n");
      }

    return 0;
  }



Measured memory_bytes: 2104
//*********Abhay is awesome *************\

#include<bits/stdc++.h>


#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define piii pair<int,pii>
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repc(i,a,n) for(int i=a;i<n;++i)
#define  repd(i,a,n) for(int i=a;i>n;--i)

using namespace std;
using ll = long long;
const ll N = 3*1e5 +5 ;
const ll mod = 1e9+7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;

typedef vector<int> vi;


void solve(){
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes";
	else cout<<"No";
	return;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    //freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    //freopen("output1.txt", "w", stdout);
	//#endif
	solve(); 
	return  0;
}



/////////////

// Hello, this is a snippet.

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// const long double PI = acos(-1);
constexpr int inf = 1e9;
constexpr ll INF = 2e18;
// constexpr ll MOD = 1e9+7;
constexpr ll MOD = 998244353;

int n,m;
vector<int> G[100010];
ll value[100010];
bool used[100010];

void input() {
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> value[i];
    for (int i = 0; i < m; i++) {
        int x,y;
        cin >> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
}

void get_block(int k, vector<ll> &v) {
    if (used[k]) return;
    used[k] = 1;
    v.push_back(value[k]);
    for (int i = 0; i < G[k].size(); i++) {
        get_block(G[k][i], v);
    }
}

void solve() {

    ll ans = 0;
    vector<ll> st;
    ll cnt = 0;

    if (m == n - 1) {
        cout << 0 << endl;
        return;
    }

    //divide blocks
    for (int i = 0; i < n; i++) {
        if (!used[i]) {
            vector<ll> v;
            get_block(i,v);
            sort(v.begin(), v.end());
            ans += v[0];
            cnt++;
            for (int j = 1; j < v.size(); j++) {
                st.push_back(v[j]);
            }
        }
    }

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

    if (cnt - 2 > st.size()) {
        cout << "Impossible" << endl;
        return;
    }

    for (int i = 0; i < cnt - 2; i++) {
        ans += st[i];
    }

    cout << ans << endl;
}

int main(int argc, char *argv[]) {
    input();
    solve();
    return 0;
}


Measured memory_bytes: 8952
import math

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

a2 = 2 * x / (a * b)

if a2 <= a:
    ans = math.atan(b / a2) * 360 / (2 * math.pi)

else:
    y = (a * a * b) - x
    b2 = 2* y / (a * a)
    ans = math.atan(b2 /a) * 360 / (2 * math.pi)

print(ans)


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

int main()
{
    int n;
    string str;
    cin >> n >> str;
    if(n<=1||n%2!=0)
        cout << "No";
    else
    {
        int mid = n/2;
        int flag=1;
        for(int i=0;i<mid;i++)
        {
            if(str[i]!=str[i+mid])
            {
                flag=0;
                break;
            }
        }
        if(flag)
            cout << "Yes";
        else
            cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int desc(const void *a, const void *b) {
  return *(int *)b - *(int *)a;
}

int main(void)
{
  int N,K,i=0;
  long cnt=0;
  int H[200000] = {0};
  
  scanf("%d %d",&N,&K);
  
  for(i=0;i<N;i++)
  {
    scanf("%d",&H[i]);
  }
  
  if(K>=N)
  {
    goto END;
  }
  
  qsort(H, sizeof(H) / sizeof(*H), sizeof(*H), desc);

  for(i=K;i<N;i++)
  {
    cnt += (long)H[i];
  }
  
END:
  printf("%ld\n",cnt);
  
  return 0;
}

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

#define dk23      ios_base :: sync_with_stdio(false);
#define inp       freopen("input.txt","r",stdin);
#define ll        long long

using namespace std;

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



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	int c=scan.nextInt();
	int d=scan.nextInt();
	int ans=0;
	for(int i=0;i<=a;i++) {
		for(int j=0;j<=b;j++) {
			for(int k=0;k<=c;k++) {
				if((500*i+100*j+50*k)==d) {
					ans++;
				}
			}
		}
	}
	System.out.println(ans);
	scan.close();
}
}

Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include<iomanip>

using namespace std;

#define rep(i, b, e) for(int (i) = (b); (i) < (e); (i)++)
#define repm(i, b, e) for(int (i) = (b); (i) < (e); (i)--)

int main() {

  int N, K;
  cin >> N >> K;

  long double ans = 0;
  int cnt = 0;
  rep(i, 1, N+1) {
    int tmp = K/i;
    if (K % i) tmp++;
    double n = log2(tmp);
    int nn = (int)n;
    if (n-nn) nn++;
    //cout << tmp << " " << nn << endl;
    if (i == K) {
      long double aa =  (long double)1/N * (N+1-i);
      //cout <<  aa  << " " << ans << endl;
      ans += aa;
      break;
    }
    long double aaa = (long double)1/N * (long double)pow((long double)0.5,nn);
    //ans += (long double)1/N * (long double)pow((long double)0.5,nn);
    ans += aaa;
    //cout << i << " " << fixed << aaa << " " << fixed << ans << endl;
  }
  cout << fixed << setprecision(10) << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int gcd(long long u, long long v) {
  long long r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}

int main(){
    long long n,m;
    string s,t;
    cin >> n >> m;
    cin >> s >> t;
    long long o = gcd(n,m);
    long long l = n * m / o;
        long long x = n/o;
        long long y = m/o;
        for(long long i=0;i<o;i++){
            if(s[x*i] != t[y*i]){
                goto dame;
            }
        }
        goto oke;
    
    dame:
    cout << "-1" << endl;
    goto owari;
    oke:
    cout << l << endl;
    owari:
    return 0;
    
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
  string s,t;
  cin>>s>>t;
  vector<vector<int>> a(26),b(26);
  for (int i = 0; i < s.size(); ++i) {
    a[s[i]-'a'].emplace_back(i);
    b[t[i]-'a'].emplace_back(i);
  }
  for (int i = 0; i < 26; ++i) {
    if(a[i]!=b[i]){
      for (int j = 0; j < 26; ++j) {
        if(a[i]==b[j])swap(b[i],b[j]);
      }
    }
  }
  if(a==b)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 4744
use std::iter::Iterator;

fn read<T: std::str::FromStr>() -> T {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).ok();
	s.trim().parse().ok().unwrap()
}

fn main() {
	println!("{}", (|| {
    	let code = read::<String>().chars().collect::<Vec<char>>();
        let mut prev = '\0';
        for c in code {
        	if c == prev {
            	return "Bad";
            }
            prev = c.clone();
        }
        return "Good";
    })());
}


Measured memory_bytes: 4352
import math
N,M= map(int, input().split())
Hs = [0] + list(map(int, input().split()))
Hs_set = [-1 for _ in range(N + 1)]
for _ in range(M):
    A,B= map(int, input().split())

    Hs_set[A] = max(Hs[B],Hs_set[A])

    Hs_set[B] = max(Hs[A],Hs_set[B])
ans = 0
for i in range(1,N+1):
    if Hs[i] > Hs_set[i]:
        ans += 1



print(ans)

Measured memory_bytes: 20120