akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

bool cont = 1;
int q = 0;
int N;

char query(int i){
    i %= N;
    cout << i << '\n';
    fflush(stdout);
    string ans; cin >> ans;
    if (ans[0] == 'V') cont = 0;
    q++;
    return ans[0];
}

int main() {
    cin >> N;
    char a1 = query(0);
    char a2 = a1;

    int A = 0;
    int B = N;

    while (cont){
        int half = (A+B)/2;
        char nv = query(half);
        if (cont == 0) return 0;
        int size1 = half-A-1;
        int size2 = B-half-1;

        if (nv == a1 && size1 % 2 == 0) {
            B = half;
            a2 = nv;
        }else if(nv == a2 && size2 % 2 == 0){
            A = half;
            a1 = nv;
        }else if (nv != a1 && size1 % 2 == 1){
            B = half;
            a2 = nv;
        }else if(nv != a2 && size2 % 2 == 1){
            A = half;
            a1 = nv;
        }else{
            return 0;
        }
    }
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


void solve(long long K, long long A, long long B){
    int f = 0;
    FOR(i, A, B + 1)
    {
        if (i % K == 0) f = 1;
    }
    if (f == 0){
        cout << "NG" << "\n";
    } else{
        cout << "OK" << "\n";
    }
}

int main(){

    long long K;
    scanf("%lld",&K);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(K, A, B);
    return 0;
}



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

using namespace std;

#define ll long long

const int N = (int)1e5 + 7;

string s;
ll freq[5];
string beg = "MARCH";

main() {    
	int n; 
	scanf("%d", &n);
	ll ans = 0;	
	for (int i = 1; i <= n; i++) {
		cin >> s;
		for (int j = 0; j < 5; j++) {
			if (beg[j] == s[0]) {
				freq[j]++;
			}
		}
	}
	for (int i = 0; i < 5; i++) {
		for (int j = i + 1; j < 5; j++) {
			for (int k = j + 1; k < 5; k++) {
				ans += freq[i] * 1LL * freq[j] * freq[k];
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;


int main(){
  ll n,m;
  cin >> n >> m;
  vector<pair<ll,ll>> p;
  ll a,b;
  rep(i,n){
    cin >> a >> b;
    p.push_back(make_pair(a,b));
  }
  sort(p.begin(),p.end());
  ll memo = 0;
  ll ans = 0;
  rep(i,n){
    if(memo + p[i].second < m){
      ans += p[i].first*p[i].second;
      memo += p[i].second;
    }else{
      ans += p[i].first*(m-memo);
      break;
    }
  }
  printf("%lld\n", ans);
    return 0;
}


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

signed main(){
    int N,K,Q; cin>>N>>K>>Q;
    vector<int> cnt(N);
    for(int i=0;i<Q;i++){
        int a; cin>>a;
        cnt[a-1]++;
    }

    for(int i=0;i<N;i++){
        if(K-(Q-cnt[i])<=0){
            cout<<"No"<<endl;
        }else{
            cout<<"Yes"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
#include <cstdint>                                                                                                              

template <std::uint_fast64_t Modulus> class modint {
	using u64 = std::uint_fast64_t;

public:
	u64 a;

	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept {
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept {
		u64 exp = Modulus - 2;
		while (exp) {
			if (exp % 2) {
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};

using mint = modint<MOD>;
mint dp[100][100000];
int main() {
    cin>>n>>k;
    a=int(sqrt(n+0.05));
    vector<mint> A,B;

    for(ll i=1;i<=a;i++){
        A.push_back(i);
    }

    for(ll i=a;i>0;i--){
        A.push_back(n/i);
    }    

    rep(i,A.size()){
        if(i==0)B.push_back(A[0]);
        else B.push_back(A[i]-A[i-1]);
    }
    

    rep(i,k){
    	mint t=0;
        for(ll j=B.size()-1;j>-1;j--){
            if(i==0)dp[i][j]=B[j];
            else{
            	t=t+dp[i-1][B.size()-j-1];
                dp[i][j]=t*B[j];
            }
        }
    }
    
    mint ans=0;

    rep(i,B.size()){
        ans+=dp[k-1][i];
    }

    cout<<ans.a<<endl;
}

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

typedef long long ll;
ll MOD = 1000000007;

typedef long long ll;

int main()
{
    int n, x = 0;
    string s, ans;

    cin >> n >> s;

    for (int i = 0; i < n; i++) {
        if (s[i] == '(') {
            x++;
            ans += '(';
        } else {
            if (x) {
                x--;
                ans += ')';
            } else {
                ans = '(' + ans + ')';
            }
        }
    }
    while (x) {
        ans += ')';
        x--;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;



int main(){FIN

    double c,y; cin>>c>>y;
    cout<< fixed << setprecision(10)<<c/y<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<cmath>
#include<vector>
#include<cstring>
#include<queue>
using namespace std;

int n,a[200002];

int main(){
    
    int i,max = 0, max2 = 0;
    while(cin>>n){
        for(i=0;i<n;i++){
            cin>>a[i];
            if(a[i] >= max){
                max2 = max;
                max = a[i];
            }
            else if(a[i] >= max2){
                max2 = a[i];
            }
        }
        for(i=0;i<n;i++){
            if(a[i] == max)
                cout<<max2<<endl;
            else
                cout<<max<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define INF LLONG_MAX
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    string s, t; cin >> s >> t;
    REP(i, s.size()) {
        if (s[i] == t[i]) continue;
        else {
            REP(j, s.size()) {
                // s[i]はt[i]に,t[i]はs[i]に置き換える。
                if (i == j) continue;
                if (s[j] == s[i]) {
                    if (t[j] != t[i] && j < i) {
                        cout << "No" << endl;
                        return 0;
                    }
                    s[j] = t[i];
                } else if (s[j] == t[i]) {
                    if (t[j] != s[i] && j < i) {
                        cout << "No" << endl;
                        return 0;
                    }
                    s[j] = s[i];
                }
            }
            s[i] = t[i];
        }
    }
    if (s == t)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 776
import copy

N,M,R=map(int,input().split())
r=list(map(int,input().split()))
d=[[10**15 for i in range(0,N+1)] for i in range(0,N+1)]
for i in range(0,M):
    a,b,c=map(int,input().split())
    d[a][b]=c
    d[b][a]=c

for k in range(1,N+1):
    for i in range(1,N+1):
        for j in range(1,N+1):
            if d[i][j]>d[i][k]+d[k][j]:
                d[i][j]=d[i][k]+d[k][j]

ans=10**15
def dfs(load,cost,last):
    global ans
    if len(load)==R:
        if ans>cost:
            ans=cost

    elif len(load)!=0:
        for city in r:
            if not city in load:
                a=copy.copy(load)
                a.add(city)
                dfs(a,cost+d[last][city],city)

    else:
        for city in r:
            dfs(set([city]),0,city)



dfs(set([]),0,0)

print(ans)

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

  #define vi vector<int>
  #define all(v) v.begin(),v.end()
  #define ll long long int
  #define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define D1(x) {cerr<<" [" <<#x<<": "<<x<<"]";cout << endl;}
  #define D2(x) {cerr<<" [" <<#x<<": ";for(auto it:x)cerr<<it<< " ";cerr<<"] ";cout << endl;}

  const ll MOD=1e9+7;

  void solve(){
     string s;
     cin >> s;
     cout << s.substr(0,3);
  }


  int main(){
    IOS
       solve();
       cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying

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

using namespace std;

typedef long long ll;

int main(){
	int n, s;
	vector<int> a;
	vector<vector<ll> > dp;
	vector<vector<ll> > pre;
	cin>>n>>s;
	
	a.assign(n+1, 0);
	dp.assign(n+1, vector<ll>(s+1, 0));
	pre.assign(n+1, vector<ll>(s+1, 0));

	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=s;j++){
			if(j==a[i])
				dp[i][j] = i;
			else{
				if(j>=a[i])
					dp[i][j] = pre[i-1][j-a[i]]%998244353;
			}
			pre[i][j] = (pre[i-1][j]+dp[i][j])%998244353;
			//cout<<i<<" "<<j<<" "<<" "<<pre[i-1][j]<<" "<<dp[i][j]<<" "<<pre[i][j]<<"\n";
		}
	}

	ll ans = 0;
	for(int i=1;i<=n;i++){
		ans = (ans+((n-i+1)*dp[i][s])%998244353)%998244353;
	}
	cout<<ans<<"\n";

	return 0;
}

Measured memory_bytes: 141184
//B
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
//#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

bool isprime(int p) {
	if (p == 1) return false;
	for (int i = 2; i < p; i++) {
		if (p % i == 0) return false;
	}
	return true;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll keta(ll n) {
	ll res = 0;
	while (n >= 1) {
		res += n % 10; n /= 10;
	}
	return res;
}
ll modpow(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= mod; }
		x = x * x % mod; y /= 2;
	}
	return res;
}
ll nCk(ll n, ll k) {
	ll a = 1, b = 1;
	for (int h = n - k + 1; h <= n; h++) { a *= h; a %= mod; }
	for (int h = 1; h <= k; h++) { b *= h; b %= mod; }
	return a * modpow(b, mod - 2) % mod;
}
//printf("%.10f\n", n);

ll test[1234567];
signed main() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	
	string s, t;
	ll n, m, a = 0, b = 0, c = 0, cnt = 0, ans = 0;
	cin >> n;
	rep(i, n) {
		cin >> a >> b;
		if (a == b) { cnt++; }
		else { cnt = 0; }
		if (cnt >= 3) { ans = 1; }
	}
	if (ans == 1) { cout << "Yes\n"; }
	else { cout << "No\n"; }
	return 0;
}

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

ll n;

int main()
{
    cin >> n;
    if(n % 11 == 0){
        cout << (n / 11) * 2 << endl;
    }
    else if(n % 11 > 6){
        cout << (n / 11) * 2 + 2<< endl;
    }
    else{
        cout << (n / 11) * 2 + 1<< endl;
    }
    return 0;
}


Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())
price = A*X + B*Y
tmp = 0
for i in range(1, int(1 + 10e5)):
    tmp = 2*C*i + max(0, X-i)*A + max(0, Y-i)*B
    price = min(price, tmp)
print(price)            

Measured memory_bytes: 3060
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"
#include "cmath"
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll NN[4];
  for (size_t i = 0; i < 4; i++) {
    std::cin >> NN[i];
  }

  ll ans[4];
  ans[0] = 1;
  ans[1] = 9;
  ans[2] = 7;
  ans[3] = 4;

  for (size_t i = 0; i < 4; i++) {
    ll flag = 0;
    for (size_t j = 0; j < 4; j++) {
      if (ans[i] == NN[j]) {
        flag =1;
      }
    }
    if (flag == 0) {
      std::cout << "NO" << '\n';
      return 0;
    }
  }

  std::cout << "YES" << '\n';


  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int partition(int *,int,int);

int main(){

  int i,A[100000],n,m;

  scanf("%d",&n);

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

    scanf("%d",&A[i]);

  }

  m=partition(A,0,n-1);

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

    if(i==n-1) printf("%d\n",A[i]);
    else if(i==m) printf("[%d] ",A[i]);
    else printf("%d ",A[i]);

  }
  
  return 0;

}

int partition(int *A,int p,int r){

  int i,j,kari,x;
  
  x=A[r];
  i=p-1;

  for(j=p;j<r;j++){

    if(A[j]<=x){
      i++;
      kari=A[i];
      A[i]=A[j];
      A[j]=kari;
      
    }
  }

  kari=A[i+1];
  A[i+1]=A[r];
  A[r]=kari;
  
    
  return i+1;
}



  
  

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

int main() {
    int q;
    cin >> q;
    rep (i, q) {
        string n;
        cin >> n;

        map <string, bool> strToBool;
        strToBool[n] = true;

        int cnt = 0;

        while(n.size() != 1) {

            int max_index = -1,
                max_num = -1;

            range (j, 1, n.size()) {
                string pre = "",
                       sub = "";

                rep (k, j) pre += n[k];
                range (k, j, n.size()) sub += n[k];

                if (max_num < stoi(pre.c_str()) * stoi(sub.c_str())) {
                    max_num = stoi(pre.c_str()) * stoi(sub.c_str());
                    max_index = j;
                }
            }

            string pre = "",
                   sub = "";

            rep (j, max_index) pre += n[j];
            range (j, max_index, n.size()) sub += n[j];

            n = to_string(stoi(pre.c_str()) * stoi(sub.c_str()));
            cnt++;

            if (strToBool[n]) {
                cnt = -1;
                break;
            }
        }

        cout << cnt << endl;
    }

    return 0;
}


Measured memory_bytes: 3288
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;

bool used[101];

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int d = a;
  while (!used[d % b]) {
    if (d % b == c) {
      cout << "YES" << endl;
      return 0;
    }
    used[d % b] = true;
    d += a;
  }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
#define maxn 100010
typedef long long ll;
typedef long double ld;
const int MAXI=INT_MAX;
const ll MAXL=LLONG_MAX;
int t;
double m,k;
int main(){
    /*freopen("TASK.inp","r",stdin);
      freopen("TASK.out","w",stdout);*/
    ios_base::sync_with_stdio(0);
    ld a,b;
    cin>> a >> b;
    ll ans = floor(a*b);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3732
#include<cstdio>
#include<cstring>
#include<algorithm>
int n,m,ans=1,mo=1e9+7,p; 
template<class T>
inline void read(T&a){
	char c=getchar();
	for(a=0;c<'0'||c>'9';c=getchar());
	for(;c>='0'&&c<='9';c=getchar())a=a*10+c-'0';
}
int main(){
	read(n),read(m);p=n-m;if(p<0)p=-p;
	for(int i=2;i<=n;i++)ans=(long long)ans*i%mo;
	for(int i=2;i<=m;i++)ans=(long long)ans*i%mo;
	if(p==1)printf("%d\n",ans);
	else if(p>0)puts("0");
	else printf("%d\n",ans*2%mo); 
	return 0;
}

Measured memory_bytes: 128
let () =
  Scanf.scanf "%d %d %s" @@ fun n k s ->
  let s = Array.init n (fun i -> i, s.[i]) in
  let t = Array.make 101010 0 in
  let ans, _, _, _, _ =
    Array.fold_left (fun (ans, cur, cs, ti, p) (i, x) ->
      match p, x with
      | '1', '1' -> (max ans (cur+1), cur+1, cs+1, ti, '1')
      | '0', '0' -> (max ans (cur+1), cur+1, cs+1, ti, '0')
      | '0', '1' -> begin
        t.(ti) <- cs;
        (max ans (cur+1), cur+1, 1, ti+1, '1')
      end
      | _ (* 1, 0 *) -> begin
        if ti < k then
          (max ans (cur+1), cur+1, cs+1, ti, '0')
        else
          (max ans (cur+1-t.(ti-k)), cur+1-t.(ti-k), cs+1, ti, '0')
      end) (0,0,0,0,'1') s
  in
  Printf.printf "%d\n" ans


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

    ll N;
    cin >> N;
    cout << N * (N - 1) / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int a,b,c,d,m,n;
	cin>>a>>b>>c>>d;
	if (a>c) m=a;
	else m=c;
	if (b<d) n=b;
	else n=d;
	if (n<m) cout<<0;
	else cout<<n-m;
	return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if (abs(x-a) < abs(x-b)) {
        cout << "A" << endl;
    } else {
        cout << "B" << endl;
    }
    return 0;
}


Measured memory_bytes: 3608
def gcd(a, b):
    while b != 0:
        a, b = b, a%b
    return a

N, X = map(int, input().split())
x = [abs(int(i) - X) for i in input().split()]

if N == 1:
    print(x[0])
else:
    ans = gcd(x[0], x[1])
    for i in range(N):
        ans = gcd(ans, x[i])
    print(ans)

Measured memory_bytes: 14224
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string S;
    cin >> S;
    sort(S.begin(), S.end());
    if (S[0] == 'a') {
        if (S[1] == 'b') {
            if (S[2] == 'c') {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

void solve() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  string s;
  cin >> s;
  vector<long long> b;
  for (int i = n - 1; i >= 0; i--) {
    long long v = a[i];
    for (auto x : b) {
      v = min(v, v ^ x);
    }
    if (v) {
      if (s[i] == '1') {
        cout << 1 << endl;
        return;
      }
      b.push_back(v);
    }
  }
  cout << 0 << endl;
}

int main(){
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}


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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    public static int[] ans;
    public static Edge[] e;
    public static PriorityQueue<Integer> que;
    public static int sum;
    static void solve(InputReader in, PrintWriter out){
        int n = in.ni();
        ans = new int[n];
        e = new Edge[n];
        sum = 0;
        for (int i = 0; i < n; i++) e[i] = new Edge();
        for (int i = 0; i < n - 1; i++) {
            int a = in.ni()-1, b = in.ni()-1;
            e[a].add(b);
            e[b].add(a);
        }
        que = new PriorityQueue<>();
        for (int i = 0; i < n; i++) que.add(-in.ni());
        ans[0] = -que.poll();
        dfs(-1, 0);
        out.println(sum);
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            sb.append(ans[i]).append(' ');
        }
        out.println(sb.toString());
    }
    public static void dfs(int from, int now){
        for(Integer to: e[now]){
            if(to != from){
                if(!que.isEmpty()){
                    ans[to] = -que.poll();
                    sum += ans[to];
                }
                dfs(now, to);
            }
        }
    }
    public static class Edge extends ArrayList<Integer>{}

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 29012
N = int(input())
A = list(map(int,input().split()))

G = 0
Z = 0
ans = 1
for i in range(N-1):
  if A[i+1] > A[i]:
    G += 1
  elif A[i+1] < A[i]:
    Z += 1
  if G != 0 and Z != 0:
    ans += 1
    G = 0
    Z = 0
print(ans)

    
  

Measured memory_bytes: 14252
import math

A, B, H, M = map(int,input().split())

time = 60 * H + M

theta_A = 6*time % 360
theta_B = 0.5 * time
if (360 <= theta_B):
    theta_B -= 360

theta = abs(theta_A - theta_B)
if (theta > 180):
    theta = 360 - theta 

theta_rad = math.radians(theta)

C = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(theta_rad))
print(C)

Measured memory_bytes: 9512
#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。
int main() {
    int N;
    cin >> N;
    vector <int> W(N);
    int sum = 0;
    for(int i = 0; i < N; i++){
        cin >> W.at(i);
        sum+=W.at(i);
    }
    int num = sum;
    int mum = 0;
    for(int i = 0; i < N ; i++){
        cin >> W.at(i);
        mum+=W.at(i);
        num = min(num , abs(mum - (sum - mum)));
    }
    cout << num << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long i = 0; i < (long long)(n); ++i)

using namespace std;
using ll = long long;

int main() {
	int n;
	ll ans = 1;
	string s;
	cin >> n >> s;
	vector<ll> c(3);
	rep(i, n) {
		if (s[i] == 'R') c[0]++;
		else if (s[i] == 'G') c[1]++;
		else c[2]++;
	}
	rep(i, 3) ans *= c[i];
	rep(i, n) rep(j, i) {
		int k = i + (i - j);
		if (k < n) {
			if(s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) ans--;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <utility>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
using namespace std;
int main(){
	stack<int> s1;
	stack<pair<int,int> > s2;
	string str;	cin>>str;
	int sum=0;
	for(int i=0;i<(int)str.size();i++){
		if(str[i]=='\\')	s1.push(i);
		else if(str[i]=='/'&&s1.size()>0){
			int j=s1.top();	s1.pop();
			sum+=i-j;
			int a=i-j;
			while(s2.size()>0&&s2.top().first>j){
				a+=s2.top().second;
				s2.pop();
			}
			s2.push(make_pair(j,a));
		}
	}
	vector<int> ans;
	while(s2.size()>0){
		ans.push_back(s2.top().second);
		s2.pop();
	}
	reverse(ans.begin(),ans.end());
	cout<<sum<<endl;
	cout<<ans.size();
	for(vector<int>::iterator it=ans.begin();it!=ans.end();it++)	cout<<" "<<*it;
	cout<<endl;
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec[i];
  }
  vector<int> dp(N);
  dp[0]=0,dp[1]=abs(vec[1]-vec[0]);
  for(int i=2;i<N;i++){
    dp[i]=min(dp[i-1]+abs(vec[i]-vec[i-1]),dp[i-2]+abs(vec[i]-vec[i-2]));
  }
  cout << dp[N-1] <<endl;
}


Measured memory_bytes: 3912
import sys
from itertools import accumulate
from bisect import bisect_left

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, H, *AB = map(int, read().split())
    A = AB[::2]
    B = AB[1::2]

    Amax = max(A)
    B = [b for b in B if b >= Amax]
    B.sort(reverse=True)

    ans = 0
    for b in B:
        H -= b
        ans += 1
        if H <= 0:
            break

    if H > 0:
        ans += (H + Amax - 1) // Amax

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 110508
#include <bits/stdc++.h>
using namespace std;
typedef bool boool;
typedef long long ll;
#define vl vector<ll>
#define vb vector<boool>
#define vs vector<string>
#define vp vector<pair<ll, ll>>
#define vvl vector<vector<ll>>
#define vvp vector<vector<pair<ll, ll>>>
#define mod 998244353
#define all(x) x.begin(), x.end()
#define rep1(i, n) for (long long i=0; i<(long long)(n); i++)
#define rep2(i, s, e) for (long long i=(s); i<(long long)(e); i++)
#define GET_MACRO(_1,_2,_3,NAME,...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

int main() {
    ll n, k;
    cin >> n >> k;
    vp vec(k);
    rep(i, k){
        ll l, r;
        cin >> l >> r;
        vec[i] = make_pair(l, r);
    }
    vl dp(n+1, 0);
    dp[0] = 1;
    dp[1] = -1;
    ll plus = 0;
    rep(i, n){
        plus += dp[i];
        plus %= mod;
        rep(j, k){
            if(i+vec[j].first >= n) continue;
            else{
                dp[i+vec[j].first] += plus;
                dp[i+vec[j].first] %= mod;
                dp[min(i+vec[j].second, n-1)+1] = dp[min(i+vec[j].second, n-1)+1]+mod-plus;
                dp[min(i+vec[j].second, n-1)+1] %= mod;
            }
        }
    }
    ll ans = 0;
    rep(i, n){
        ans += dp[i];
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1ll<<30;
const ll longINF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int main() {
	int N;
	cin >> N;
	
	printf("%.15f\n", (double)((N + 1) / 2) / N);
	
	return 0;
}

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

int main()
{  
  int n,k;
  cin >> n >> k;
  double ans=0;
  double j;
  cout << fixed << setprecision(12);
  
  for(int i=1;i<=n;++i,j=1){
    while(i*j<k){
      j*=2;
    }
    ans+=1/(n*j);
  }
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <stack>
#include <string>
#include <cmath>
#include <cstdlib>
#include <set>
using namespace std;

#define M 1e9+7
typedef long long ll;
#define  mem(a) memset(a,0,sizeof a)
#define pi acos(-1.0)
#define inf 0x3f3f3f
struct node
{
        int u,v;double w;
}mp[100000];
struct node1
{
        double x,y;
}c[10005];
int n,m;
int f[10005];
bool cmp(node a,node b)
{
        return a.w > b.w;
}
int find(int x)
{
        while(x != f[x])
                x = f[x];
        return x;
}
int main()
{
        while(~scanf("%d %d",&n,&m))
        {
                for(int i = 1 ; i <= n ; i ++)
                        scanf("%lf %lf",&c[i].x,&c[i].y);
                for(int i = 0 ; i < m ; i ++)
                {
                        int a,b;
                        scanf("%d %d",&a,&b);
                        mp[i].u = a;
                        mp[i].v = b;
                        mp[i].w = sqrt ((c[a].x-c[b].x )*(c[a].x-c[b].x) + (c[a].y-c[b].y)*(c[a].y - c[b].y));
                }
                sort(mp,mp+m,cmp);
                double ans = 0;
                for(int i = 1 ; i <= n ; i ++)
                        f[i] = i;
                for(int i = 0 ; i < m ; i ++)
                {
                        int a = mp[i].u;
                        int b = mp[i].v;
                        int fa = find(a);
                        int fb = find(b);
                        if(fa == fb)
                                ans += mp[i].w;
                        else
                        {
                                int mi = min(fa,fb);
                                int ma = max(fa,fb);
                                f[ma] = mi;
                        }
                }
                printf("%.3f\n",ans);
        }


        return 0;
}

Measured memory_bytes: 3912
import java.util.*;

public 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 c = Integer.parseInt(scan.next());
		int x = Integer.parseInt(scan.next());
		int y = Integer.parseInt(scan.next());

		int ans=0;
		if (c*2<(a+b)){
			ans+=c*2*Math.min(x,y);

			if (c*2<a && x-y>0){
				ans+=c*2*(x-y);
			}else if (x-y>0){
				ans+=a*(x-y);
			}

			if (c*2<b && y-x>0){
				ans+=c*2*(y-x);
			}else if (y-x>0){
				ans+=b*(y-x);
			}
		}else{
			ans+=a*x+b*y;
		}
		System.out.print(ans);




	}
}
//end

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n,t;
    ll cur;
    cin >> n >> t ;
    ll begin = -1;
    ll end = -1;
    ll ans = 0;
    for (int i=0;i<n;i++){
        cin >> cur;
        if (end < cur){
            ans += (end-begin);
            begin = cur;
            end = cur + t;
        }else{
            end = cur + t;
        }
    }
    ans += (end-begin);
    cout << ans << endl;
}

Measured memory_bytes: 256
N, X, Y = map(int, input().split())
ks = [0]*(N-1)
for A in range(1,N):
    for B in range(A+1,N+1):
        if B - A > abs(X -A) + abs(Y - B) + 1:
            ks[B-A-1] -= 1
            ks[abs(X -A) + abs(Y - B)] += 1
for k in range(1,N):
    print(N - k + ks[k-1])

Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <queue>
#include <cmath>
#include <map>
#include <set>
using namespace std;
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define PER(i, a, b) for(int i = a; i >= b; i--)
#define int long long
inline int read() {
    int x = 0, flag = 1;char ch = getchar();
    while(!isdigit(ch)) {
        if(ch == '-') flag = - 1;
        ch = getchar();
    }
    while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
    return x * flag;
}
int n, k, a, b, m;
signed main() {   
    k = read(); a = read(); b = read();
    if(a + 2 >= b || k <= a) {
        cout << k + 1 << endl;
        return 0;
    }
    k = k - a + 1;
    m = k / 2;
    if(k % 2) {
        cout << a + m * (b - a) + 1 << endl;
    } else cout << a + m * (b - a) << endl;
    return 0;
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding("utf8");

const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

const lines = [];

reader.on("line", (line) => {
  lines.push(line);
});

reader.on("close", () => {
  for (let i=0;i<lines.length;i++) {
    const [x,y]=lines[i].split(" ").map(Number)
    if(x===0&&y===0)break;
    const [s,b]=x<y?[x,y]:[y,x]
    console.log(`%d %d`,s,b);
  }
});




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

#define for0(i, n) for (int i = 0; i < (int)(n); ++i) 
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) 
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) 
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) 
#define forrc(i,r,l) for (int i= (int)(r); i>= (int)(l); --i)

#define pb push_back
#define fi first
#define se second
#define mp make_pair

#define all(x) (x).begin(), (x).end() 
#define rall(x) (x).rbegin, (x).rend() 


#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)


#define present(c,x) ((c).find(x) != (c).end())


#define cpresent(c,x) (find(all(c),x) != (c).end())

#define sz(a) int((a).size())

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;


typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;
typedef long long ll;
typedef unsigned long long int ull;

const int MOD=1000000007;

void add_self(int &a, int b){
  a+=b;
  if(a>=MOD){
    a-=MOD;
  }
}

void sub_self(int &a, int b){
  a-=b;
  if(a<0){
    a+=MOD;
  }
}

const ll INF = 1e11 + 5;

int main(){
  fastio; 
  
  int N,W;
  cin >> N >> W;
  vi w(N),v(N);
  for0(i,N){
    cin >> w[i] >> v[i];
  }
  ll total_sum=0;
  for(auto x:v){
    total_sum+=x;
  }
  vvll dp(N,vll(total_sum+1,INF));
  dp[0][0]=0;
  for0(i,N){
    if(i==0){
      dp[i][v[i]]=w[i];
      continue;
    }
    for0(j,total_sum+1){
      dp[i][j]=dp[i-1][j];
      if(j>=v[i]){
        dp[i][j]=min(dp[i][j],dp[i-1][j-v[i]]+w[i]);
      }
    }
  }
  cout << endl;
  ll ans=0;
  for0(i,total_sum+1){
    if(dp[N-1][i]<=W){
      ans=i;
    }
  }
  cout << ans;
}

Measured memory_bytes: 79488
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
	int n,c,d,a=100;
	cin>>n;
	for(int i=1;i<n;i++){
		c=0;
		d=0;
		for(int j=i;j>0;j/=10){
			c+=j%10;
		}
		for(int j=n-i;j>0;j/=10){
			d+=j%10;
		}
		if(a>c+d)a=c+d;
	}
	cout<<a<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+10;
int a[N];
int main()
{
    int k,n,ma;
    cin>>k>>n;
    for(int i=0;i<n;i++) scanf("%d",a+i);
    sort(a,a+n);
    ma=a[0]+k-a[n-1];
    for(int i=1;i<n;i++) ma=max(ma,a[i]-a[i-1]);
    cout<<k-ma<<endl;
    return 0;
}

Measured memory_bytes: 1024
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto D = RD;

	auto x = (D * 2 + 1);
	auto ans = N / x;
	writeln(ans + (N % x != 0 ? 1 : 0));
	stdout.flush();
	debug readln();
}


Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#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>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

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

  int n, a;
  cin >> n >> a;
  YesorNo(n%500 <= a);
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
char str[200005];
int main(){

    scanf("%s",str);
    int ans = 0;
    int a=-1;
    for(int i=0;str[i];i++){
        if(str[i]=='Z'){
            if(a!=-1)
                ans = max(ans,i-a);
        }else if(str[i]=='A' && a==-1)
            a = i;
    }
    printf("%d\n",ans+1);
    return 0;
}


Measured memory_bytes: 384
n = int(input())
s = {}
for i in range(n):
  stn = input()
  if stn in s:
    s[stn] += 1
  else:
    s[stn] = 1
m = int(input())
for i in range(m):
  ttn = input()
  if ttn in s:
    s[ttn] -= 1
  else:
    s[ttn] = -1
maxval = 0
for x in s.values():
  maxval = max(maxval,x)
print(maxval)

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(1000000000)
from itertools import count
from functools import lru_cache
from collections import defaultdict
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok
#


def main():
    X = ii()
    @lru_cache(maxsize=None)
    def rec(n):
        if n == 0:
            return True
        elif n < 0:
            return False
        else:
            return any(rec(n-i) for i in range(100, 105+1))
    
    print(int(rec(X)))




main()


Measured memory_bytes: 7124
Math.sign = Math.sign || function(x){
  x = +x;
  if( x === 0 || isNaN(x)) {
    return x;
  }
  return x > 0 ? 1 : -1;
};

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk){
  var line = chunk.toString().split('\n')[0].split(' ');
  var a = Number(line[0]);
  var b = Number(line[1]);
  
  switch (Math.sign(a - b)) {
  case 1:
    console.log("a > b");
    break;
  case -1:
    console.log("a < b");
    break;
  case 0:
    console.log("a == b");
  }
});

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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

vector<int> tsort(vector<vector<int>> G){

  int n = G.size();
  vector<int> sorted,indeg(n,0); //入次数
  for(int u = 0; u < n; u++){
    for(int v : G[u]){
      indeg[v]++;
    }
  }

  priority_queue<int,vector<int>,greater<int>> q; //最小値
  for(int u = 0; u < n; u++){
    if(indeg[u] == 0) q.push(u);
  }
  while(!q.empty()){
    int u = q.top(); q.pop();
    for(int v : G[u]){
      indeg[v]--;
      if(indeg[v] == 0) q.push(v);
    }
    sorted.push_back(u);
  }
  return sorted;
}

signed main(){

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

  auto v = tsort(G);
  vector<int> dp(n,-1),pre(n,-1); //根からの距離,先祖
  for(int i = 0; i < n; i++){
    for(int j : G[v[i]]){
      if(dp[j] < dp[v[i]]+1)
      dp[j] = dp[v[i]]+1;
      pre[j] = v[i];
    }
  }

  for(int i = 0; i < n; i++){
    cout << pre[i]+1 << endl;
  }

  return 0;
}


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

#define SZ(x) ((int(x.size())))

typedef long long ll;

using namespace std;

const int maxn = 100*1000+10;
int f[maxn], m[maxn], n, k, ans;
vector <int> vec[maxn];

void dfs (int x, int p)
{
	for (int i = 0; i < SZ(vec[x]); i++)
	{
		dfs (vec[x][i], x);
		m[x] = max (m[x], m[vec[x][i]] + 1);
	}
	if (m[x] == k - 1)
	{
		if (p != 0)
			ans++;
		m[x] = -1;
	}
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		cin >> f[i];
		f[i]--;
		if (i == 0)
		{
			if (f[i] != 0)
				ans++;
		}
		else
			vec[f[i]].push_back (i);
	}
	dfs (0, 0);
	cout << ans;
	return 0;
}

Measured memory_bytes: 14336
#define DREP(i, s, e) for(register int i = s; i >= e ;i--)
#define  REP(i, s, e) for(register int i = s; i <= e ;i++)

#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cmath>
#include <queue>
#include <map>

using namespace std;
bool vis[105];

template <typename T> T read() {
	T ans(0), p(1);
	char c = getchar();
	while (!isdigit(c)) {
		if (c == '-') p = -1;
		c = getchar();
	}
	while (isdigit(c)) {
		ans = ans * 10 + c - 48;
		c = getchar();
	}
	return ans * p;
}
int m, n, k;

int main() {
#ifdef CraZYali
	freopen("b.in", "r", stdin);
	freopen("b.out", "w", stdout);
#endif
	n = read<int>();
	while (n--) {
		k = read<int>();
		if (!vis[k]) {
			vis[k] = 1;
			m++;
		}
	}
	cout << m;
	return 0;
}



Measured memory_bytes: 256
N=int(input())
A,B=map(int,input().split())
P=list(map(int,input().split()))

q1=len([i for i in range(N) if P[i]<=A])
q2=len([i for i in range(N) if A<P[i]<=B])
q3=len([i for i in range(N) if B<P[i]])

ans=min(q1,q2,q3)
print(ans)

Measured memory_bytes: 38256
import queue

k = int(input())
q = queue.Queue()

for i in range(1,10):
    q.put(i)

count = 0
while count < k:
    num = q.get()
    num_1 = int((str(num))[-1])
    if num_1 ==0:
        q.put(num*10)
        q.put(num*10+1)
    elif num_1==9:
        q.put(num*10+num_1-1)
        q.put(num*10+num_1)
    else:
        q.put(num*10+num_1-1)
        q.put(num*10+num_1)
        q.put(num*10+num_1+1)
    count+=1
    if k==count:
        ans = num
print(ans)
    



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

int main() {
	int H, W;

	while (1) {
		cin >> H >> W;
		if (H == 0 && W == 0) break;

		for (int i = 0; i < H; i++) {
			if (0 < i && i < H-1) {
				for (int j = 0; j < W; j++) {
					if (0 < j && j < W-1) {
						cout << "." ;
					}
					else  {
						cout << "#";
					}
				}
			}else if (i == 0 || i == H-1) {
				for (int j = 0; j < W; j++) {
					cout << "#";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long int ll;

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

bool valid(int l, vector<int> a, int k)
{
    int cuts = 0;

    for(auto i : a)
    {
        cuts += ceil((double)i/l) - 1;
    }

    if(cuts <= k) return true;

    return false;
}

int main() {

    fastio();

    int n, k;

    cin >> n >> k;

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

    int x = 0;

    for(int b = a[0]; b >= 1; b /= 2)
    {
        while(!valid(x + b, a, k)) x += b;
    }

    cout << x + 1;
    return 0;
}

Measured memory_bytes: 4760
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    int N;
    cin >> N;
    long long int tmp;
    long long int ma = 0, mi = 10000000000;

    for (int i = 0; i < N;i++){
        cin >> tmp;
        ma = max(ma, tmp);
        mi = min(mi, tmp);
    }
    cout << ma - mi << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();

        long answer = n == 1 ? 0 : 1;

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 27544