akhauriyash/Code-Regression huggingface dataset:
import itertools

n, m = map(int, input().split())
k = []
s = []
for _ in range(m):
    words = list(map(int, input().split()))
    k.append(words[0])
    s.append(words[1:])
p = tuple(map(int, input().split()))

sw_stat_list = list(itertools.product([0, 1], repeat=n))
for i in range(m):
    sw_stat_list_next = []
    for sw_stat in sw_stat_list:
        sw_on_num = sum([sw_stat[sw - 1] for sw in s[i]])
        if sw_on_num % 2 == p[i]:
            sw_stat_list_next.append(sw_stat)
    sw_stat_list = sw_stat_list_next

print(len(sw_stat_list))


Measured memory_bytes: 9092
#include<bits/stdc++.h>
using namespace std;
const int inf=0x3f3f3f3f;
int n;
int nu[200200];
int pos[200200];
int ans[200200];
struct SEG{
	int mi[1000100][2];
	void build(int rt,int l,int r)
	{
		if(l==r)
		{
			mi[rt][0]=mi[rt][1]=inf;
			mi[rt][l&1]=nu[l];
			return;
		}
		int mid=(l+r)/2;
		build(rt*2,l,mid);
		build(rt*2+1,mid+1,r);
		mi[rt][0]=min(mi[rt*2][0],mi[rt*2+1][0]);
		mi[rt][1]=min(mi[rt*2][1],mi[rt*2+1][1]);
	}
	int ask(int rt,int l,int r,int st,int ed,int sym)
	{
		if(l>ed||r<st)return inf;
		if(l>=st&&r<=ed)return mi[rt][sym];
		int mid=(l+r)/2;
		return min(ask(rt*2,l,mid,st,ed,sym),
					ask(rt*2+1,mid+1,r,st,ed,sym));
	}
}seg;

struct Sta{
	int l,r,mi;
	bool operator >(const Sta &o)const{
		return mi>o.mi;
	}
};

priority_queue<Sta,vector<Sta>,greater<Sta> >q;
int top;
void ins(int l,int r)
{
	int mi=seg.ask(1,1,n,l,r,l&1);
	q.push((Sta){l,r,mi});
}
void solve()
{
	q.push((Sta){1,n,seg.ask(1,1,n,1,n,1)});
	int l,r;
	Sta cur;
	while(!q.empty())
	{
		cur=q.top();q.pop();
		l=pos[cur.mi];
		r=pos[seg.ask(1,1,n,l+1,cur.r,(l+1)&1)];
		ans[++top]=nu[l];ans[++top]=nu[r];
		if(cur.l<=l-1)ins(cur.l,l-1);
		if(l+1<=r-1)ins(l+1,r-1);
		if(r+1<=cur.r)ins(r+1,cur.r);
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",&nu[i]),pos[nu[i]]=i;
	seg.build(1,1,n);
	solve();
	for(int i=1;i<=n;++i)printf("%d ",ans[i]);
	puts("");
	return 0;
}


Measured memory_bytes: 12280
#include <iostream>
#include <vector>
#include <functional>
using namespace std;

//===
template<typename Abel>
struct WeightedUnionFind {
    using OP = function<Abel(Abel, Abel)>;

    vector<int> parent;
    vector<Abel> diff_weight; //親からの距離
    const OP add;
    const OP sub;
    const Abel e;
    
    WeightedUnionFind(){};

    WeightedUnionFind(int nmemb,
                      const Abel &e = 0,
                      const OP &add = [](Abel x, Abel y){return x+y;},
                      const OP &sub = [](Abel x, Abel y){return x-y;}):
        add(add),
        sub(sub),
        e(e)
    {
        parent.assign(nmemb, -1);
        diff_weight.assign(nmemb, e);
    }

    int root(int x)
    {
        if (parent[x] < 0) {
            return x;
        }
        
        int p = root(parent[x]);
        diff_weight[x] = add(diff_weight[x], diff_weight[parent[x]]);
        parent[x] = p;

        return p;
    }

    bool same(int x, int y)
    {
        return root(x) == root(y);
    }
    
    bool unite(int x, int y, Abel w)
    {
        Abel wx = weight(x);
        Abel wy = weight(y);

        x = root(x);
        y = root(y);

        if (x == y) return false;

        w = sub(add(w, wx), wy);

        parent[x] += parent[y];
        parent[y] = x;
        diff_weight[y] = w;
        
        return true;
    }
    
    Abel weight(int x)
    {
        root(x);
        return diff_weight[x];
    }

    Abel diff(int x, int y)
    {
        return sub(weight(y), weight(x));
    }

    int size(int x)
    {
        x = root(x);
        return -parent[x];
    }
};
//===

typedef long long ll;

int abc087D(void)
{
    WeightedUnionFind<ll> uf(1000005);
    ll n, m;
    ll l, r, d;

    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        cin >> l >> r >> d;

        uf.unite(l, r, d);

        if (uf.diff(l, r) != d) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

int main()
{
    return abc087D();
}


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

int main(){
    double n,a,b,c,d,e,i;
    double limit_min=1000000000000001;
    double time=0;//所要時間
    double mod;
    double result;
    cin>>n;
    cin>>a;
    if(a<limit_min){
        limit_min=a;
    }
    cin>>b;
    if(b<limit_min){
        limit_min=b;
    }
    cin>>c;
    if(c<limit_min){
        limit_min=c;
    }
    cin>>d;
    if(d<limit_min){
        limit_min=d;
    }
    cin>>e; 
    if(e<limit_min){
        limit_min=e;
    }

    mod=fmod(n,limit_min);
    if(mod!=0){
        result=(n-mod)/limit_min+5;
    }else{
        result=n/limit_min+4;
    }
    printf("%.0f\n",result);
}

Measured memory_bytes: 256
import numpy as np
N, W = map(int, input().split())
w, v = [], []
for i in range(N):
    a, b = map(int, input().split())
    w += [a]
    v += [b]
 
DP = np.zeros(W+1, dtype=int)
# i 円以下で買える商品の最大価値
# TLE案件のやつ
for i in range(N):
    DP[w[i]:] = np.maximum(DP[:-w[i]]+ v[i], DP[w[i]:])
print(DP[-1])
	

Measured memory_bytes: 15476
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define Rep(i,a,n) for(int i = a;i<n;i++)
#define ll long long  
const long long MOD = 1000000007LL;
int main(){
    int n;
    cin >> n;
    bool fl = true;
    rep(i,30){
        rep(j,20){
            if(n == 4*i + 7*j){
                cout << "Yes" << endl;
                fl = false;
                break;
            }
        }
        if(!fl){
            break;
        }
    }
    if(fl){
        cout << "No" << endl;
    }
}

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

int main() {
  int a[10], v1, v2,i;
  while(scanf("%d%*c%d%*c%d%*c%d%*c%d%*c%d%*c%d%*c%d%*c%d%*c%d%*c%d%*c%d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9],&v1,&v2)==12) {
    int sum=0,nv1,nv2;
    for(i=0; i<10; i++) sum+=a[i];
    nv1=nv2=0;
    sum*=100;
    while(sum>nv1+nv2) {
      nv1+=v1;
      nv2+=v2;
    }
    sum=0;
    for(i=0; i<10; i++) {
      if(sum>=nv1) break;
      sum+=a[i]*100;
    }
    cout << i << endl;
  }
  return 0;
}


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

int main() {
	vector<string> s;
	s.push_back("KIHBR");
	s.push_back("KIHBRA");
	s.push_back("KIHBAR");
	s.push_back("KIHBARA");
	s.push_back("KIHABR");
	s.push_back("KIHABRA");
	s.push_back("KIHABAR");
	s.push_back("KIHABARA");
	s.push_back("AKIHBR");
	s.push_back("AKIHBRA");
	s.push_back("AKIHBAR");
	s.push_back("AKIHBARA");
	s.push_back("AKIHABR");
	s.push_back("AKIHABRA");
	s.push_back("AKIHABAR");
	s.push_back("AKIHABARA");
	string t;
	cin >> t;
	cout << (count(s.begin(), s.end(), t) ? "YES\n" : "NO\n");
	return 0;
}

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

int n;

int main(void){
    cin >> n;
    vector<int> c(9, 0);
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        if(a >= 3200) c[8]++;
        else c[a/400]++;
    }
    int res1=0, res2;
    for(int i = 0; i < 8; i++){
        if(c[i]>0){
            res1++;
        }
    }
    if(res1 == 0){
        res1 = 1;
        c[8]--;
    }
    res2 = res1+c[8];
    cout << res1 << " " << res2 << endl;
    return 0;
}


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

int main(){
  int N;
  double a, b; // 分子, 分母
  cin >> N;
  
  b = N;
  a = N%2 ? (N+1)>>1 : N>>1;
  a = (double) a;
 
  printf("%.6f\n", a/b);
  return 0;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    
    string s1,s2,s3;
    cin>>s1>>s2>>s3;
    char diff = 'A' - 'a';
    cout<<char(s1[0]+diff)<<char(s2[0]+diff)<<char(s3[0]+diff)<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
const int INF = 12000001;

int main(){
  int n,m,x;
  cin >> n >> m >> x;
  vector<int> c(n);
  int a[12][12];
  for(int i=0;i<n;i++){
    cin >> c[i];
    for(int j=0;j<m;j++){
      cin >> a[i][j];
    }
  }
  
  int ans = INF;
  for(int i=0;i<(1<<n);i++){
    int cost = 0;
    vector<int> d(m);
    for(int j=0;j<n;j++){
      if(i>>j&1){
        cost += c[j];
        for(int k=0;k<m;k++){
          d[k] += a[j][k];
        }
      }
    }
    //cout << cost << endl;
    bool ok = true;
    for(int k=0;k<m;k++){
      if(d[k] < x) ok = false;
    }
    if(ok) ans = min(ans,cost);
  }
  if(ans == INF) cout << "-1" << endl;
  else cout << ans << endl;
  //cout << INF << endl;
    
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <map>


using namespace std;

int main() {
	string w;
	map<char, int> value;
	cin >> w;
	for (int i = 0; i < w.length(); ++i)
	{
		if (value.find(w[i]) == value.end()) {
			value.insert(pair<char, int>(w[i], 1));
		}
		else
		{
			value[w[i]] += 1;
		}
	}
	for (map<char,int>::iterator key = value.begin(); key!=value.end(); ++key) {
		if (key->second % 2 != 0)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define abs(x) (x) > 0 ? (x) : -(x)
using namespace std;

int main() {
    string S;
    cin >> S;
    int mi = 1010;
    for (int i = 0; i + 3 <= S.size(); i++) {
        int x = (S[i] - '0') * 100 + (S[i + 1] - '0') * 10 + (S[i + 2] - '0');
        mi = min(mi, abs(753 - x));
    }
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
//#define s second
#define f first
long long const mod = 1000000007; 
#define inf 1000000000000000000
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod)+mod)%mod;}
inline ll mul(ll a, ll b){ return (((a%mod)*(b%mod))%mod+mod)%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

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

ll power(ll x,ll y,ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
}

ll modInv(ll x)
{
    return power(x,mod-2,mod)%mod;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
        
   
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=1;i<=n;i++)
    {
        if(i%3==0 || i%5==0)
            ;
        else
        {
            ans+=i;
        }
        
    }
    cout<<ans<<endl;

    return 0;
}

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

using namespace std;

int main(){
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for (auto &s: S)
        cin >> s;
    
    int ans = 0;
    int cnt = 0;
    for (const auto &s: S){
        for (const auto &t: s)
            cnt += t == '.';
    }
    array<int, 4> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            vector<vector<bool>> visited(H, vector<bool>(W));
            int v_cnt = 0;
            queue<array<int, 3>> Q;
            Q.push({i, j, 0});
            while (!Q.empty()){
                int h = Q.front()[0], w = Q.front()[1], d = Q.front()[2];
                Q.pop();
                if (h < 0 or h >= H or w < 0 or w >= W)
                    continue;
                if (S[h][w] == '#')
                    continue;
                if (visited[h][w])
                    continue;
                visited[h][w] = true;
                v_cnt++;
                if (v_cnt == cnt){
                    ans = max(ans, d);
                    break;
                }
                for (int k = 0; k < 4; k++){
                    Q.push({h + dy[k], w + dx[k], d + 1});
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		String a = scanner.nextBigInteger().subtract(BigInteger.ONE).toString();
		String b = scanner.next();
		M = scanner.nextInt();

		System.out.println((slove(b) - slove(a) + mod) % mod);
	}

	private int slove(String s) {
		n = s.length();
		num = new int[n + 1];
		for (int i = 0; i < n; i++)
			num[n - i - 1] = s.charAt(i) - '0';
		dp = new int[2][2][10][n][M];
		for (int[][][][] dp1 : dp)
			for (int[][][] dp2 : dp1)
				for (int[][] dp3 : dp2)
					for (int[] dp4 : dp3)
						Arrays.fill(dp4, -1);
		int res = 0;
		for (int i = n - 1; i >= 0; i--)
			for (int j = 1; j <= (i == n - 1 ? num[i] : 9); j++) {
				res = (res + slove(i, j % M, j, 1, i == n - 1 && j == num[i]))
						% mod;
				if (i != 0)
					res = (res + slove(i, j % M, j, 0, i == n - 1
							&& j == num[i]))
							% mod;

			}

		return res % mod;
	}

	private int slove(int p, int m, int pre, int s, boolean b) {
		if (p == 0)
			return m == 0 ? 1 : 0;
		if (dp[s][b ? 1 : 0][pre][p][m] != -1)
			return dp[s][b ? 1 : 0][pre][p][m];
		int ans = 0;

		if (s == 0 || s == 2) {
			int size = (b ? num[p - 1] : 9);
			for (int i = pre + 1; i <= size; i++)
				ans += slove(p - 1, (m * 10 + i) % M, i, 1, b
						&& i == num[p - 1]);
		}
		if (s == 1 || s == 2) {
			int size = Math.min(b ? num[p - 1] : 9, pre - 1);
			for (int i = 0; i <= size; i++)
				ans += slove(p - 1, (m * 10 + i) % M, i, 0, b
						&& i == num[p - 1]);
		}
		return dp[s][b ? 1 : 0][pre][p][m]= ans % mod;

	}

	int M, n;
	int mod = 10000;
	int[] num;
	int[][][][][] dp;
}

Measured memory_bytes: 137868
#include <stdio.h>
 
int h;
 
int getleft(int i){
  i=i*2;
  if(i>h) return 500002;
  else return i;
}
 
int getright(int i){
  i=i*2+1;
  if(i>h) return 500002;
  else return i;
}
 
void maxHeapify(int A[],int i){
  int l = getleft(i),r = getright(i);
  int largest,j;
 
  if( l <= h && A[l] > A[i]) largest = l;
  else largest = i;
  if( r <= h && A[r] > A[largest]) largest = r;
  if (largest != i){
    j=A[i];
    A[i]=A[largest];
    A[largest]=j;
    maxHeapify(A,largest);
  }
}
 
void buildMaxHeap(int A[]){
    int i;
    for(i=h/2;i>=1;i--){
      maxHeapify(A,i);
    }
}
 
int main(){
    int i,A[500001];
     
    scanf("%d",&h);
     
    for(i=1;i<=h;i++){
      scanf("%d",&A[i]);
    }
 
    buildMaxHeap(A);
 
    for(i=1;i<=h;i++){
      printf(" %d",A[i]);
    }
    printf("\n");
    return 0;
 }

Measured memory_bytes: 2552
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    ll N;
    ll mLeft = 0;
    ll ans = 0;

    cin >> N;

    ll A[N+1];
    ll B[N];

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

    mLeft = A[0];
    for(int i = 0; i < N; i++){
        if(mLeft + A[i+1] <= B[i]){
            ans += mLeft + A[i+1];
            mLeft = 0;
        }else if(mLeft <= B[i] && mLeft + A[i+1] > B[i]){
            ans += B[i];
            mLeft = mLeft + A[i+1] - B[i];
        }else{
            ans += B[i];
            mLeft = A[i+1];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<set>
#include<vector>
using namespace std;
#define PI acos(-1.0)
#define pppp cout<<endl;
#define EPS 1e-8
#define LL long long
#define ULL unsigned long long     //1844674407370955161
#define INT_INF 0x3f3f3f3f      //1061109567
#define LL_INF 0x3f3f3f3f3f3f3f3f //4557430888798830399
// ios::sync_with_stdio(false);
// 那么cin, 就不能跟C的 scanf，sscanf, getchar, fgets之类的一起使用了。
const int dr[]={0, 0, -1, 1, -1, -1, 1, 1};
const int dc[]={-1, 1, 0, 0, -1, 1, -1, 1};
const LL mod=1e9+7;
map<LL,LL> dp;
LL f(LL x)
{
    if(dp[x]!=0)
        return dp[x];
    return dp[x]=(f(x/2)%mod+f((x-1)/2)%mod+f((x-2)/2)%mod)%mod;
}
int main()
{
    //freopen("D:\\chnegxubianji\\inORout\\in.txt", "r", stdin);
    //freopen("D:\\chnegxubianji\\inORout\\out.txt", "w", stdout);
    LL n;
    scanf("%lld",&n);
    dp[0]=1;
    dp[1]=2;
    printf("%lld",f(n));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[100005], n;
vector<int> c[100005];
void dfs(int x, int pa){
	int add = 0;
	for(int i = 0; i < c[x].size(); ++i){
		int v = c[x][i];
		if(v != pa){
			dfs(v, x);
			dp[x] += dp[v];
			if(dp[v] == 0) add++;
		}
	}
	dp[x] += max(add - 1, 0);
}
int main(){
	cin >> n;
	for(int i = 1; i <= n - 1; ++i){
		int x, y;
		cin >> x >> y;
		c[x].push_back(y);
		c[y].push_back(x);
	}
	int maxi = 0;
	for(int i = 0; i < n; ++i){
		if(c[i].size() > c[maxi].size()) maxi = i;
	}
	if(c[maxi].size() < 2){
		cout << 1;
		return 0;
	}
	dfs(maxi, -1);
	cout << dp[maxi] << endl;
}

Measured memory_bytes: 13824
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

mn = 10000000
ans = 0
for i in range(N):
    now = T - H[i] * 0.006
    if abs(now - A) <= mn:
        mn = abs(now - A)
        ans = i
print(ans + 1)


Measured memory_bytes: 9268
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

int main(){
    LL N;cin>>N;
    if(N==1){
        cout<<0<<endl;return 0;
    }
    LL mod=1e9+7;
    LL n10=1,n9=1,n8=1;
    REP(i,N){
        n10*=10;n10%=mod;
        n9*=9;n9%=mod;
        n8*=8;n8%=mod;
    }
    cout<<(n10+10LL*mod-2*n9+n8)%mod<<endl;
    return 0;
}

Measured memory_bytes: 3632
/*
Author: Suvrojit Ghosh
Language: C++
*/
#include <bits/stdc++.h>
using namespace std;

typedef long long unsigned llu;
typedef long long lld;
typedef long ld;
typedef unsigned int ui;

#define ff 			first
#define ss 			second
#define pb 			push_back
#define pf			push_front
#define pob 		pop_back
#define mp 			make_pair
#define gcd(a,b)    __gcd(a,b)
#define IOS 		ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define SET(a,val)  memset(a,val,sizeof(a))
#define PI          3.1415926535897932384626433832795

#define count1(n)   __builtin_popcount(n)   //count number of ones
#define trail0(n)   __builtin_ctz(n)        //count number of trailing zeros

#define imax 	INT_MAX
#define imin 	INT_MIN
#define ldmax	LONG_MAX
#define ldmin	LONG_MIN
#define lldmax  LLONG_MAX
#define lldmin  LLONG_MIN
#define llumax  ULLONG_MAX

#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()

//constants
const lld MOD=1000000007;
#define INF 	1L<<57
#define MAX 	100000
#define gc 		getchar
//Delete a single element 'a[0]' from a multimap
/*if(s.find(a[0])!=s.end())
            s.erase(s.equal_range(a[0]).ff);*/
int main()
{
    //freopen("input.txt", "r", stdin)
    //freopen("output.txt", "w", stdout)
	int n,a,d;
	scanf("%d",&n);
	scanf("%d",&a);
	d=n%500;
	if(a>=d)
	    puts("Yes");
	else
	    puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int a,b;
	while(1){
	scanf("%d",&a);
	scanf("%d",&b);
	if(a==0&&b==0)break;
		if(a<b)
	{
		printf("%d %d\n",a,b);
	}
	else
	{
		printf("%d %d\n",b,a);
	}}
	return 0;}


Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////
#define N 400004

ll kai[N];
ll kai2[N];
ll po(ll i,ll p){
    if(p==0)return 1;
    else if(p==1)return mod(i);
    else if(p%2==0)return po(mod(mod(i)*mod(i)),p/2);
    else  return mod(mod(i)*po(i,p-1));
}
void calc(){
    kai[0]=1;
    kai2[0]=1;
    rep(i,1,N-1){
        kai[i]=mod(kai[i-1]*i);
    }
    kai2[N-1]=po(kai[N-1],i_5);
    for(ll i=N-2;i>=0;i--){
        kai2[i]=mod(kai2[i+1]*(i+1));
    }
}
ll comb(ll n,ll k){
    if(n<k)return 0;
    else if(n==0)return 1;
    else return mod(mod(kai[n]*kai2[n-k])*kai2[k]);
}
ll bunbo(ll n){
    return po(n,i_5);
}

string t="RBG";
string s;
ll cal(ll p){
    rep(j,0,2){
        if(t[j]==s[p])return j;
    }
    return -1;
}
int main(){fastio
    
    calc();
    ll n;cin>>n;
    cin>>s;
    ll c[3];memset(c,0,sizeof(c));
    ll r[3];memset(r,0,sizeof(r));
    ll mid[3*n];memset(mid,-1,sizeof(mid));
    rep(i,0,3*n-1){
        ll k=cal(i);
        bool flag=true;
        if(r[k]>=1){
            r[k]--;
            mid[i]=100;
            continue;
        }
        rep(j,0,2){
            if(j==k)continue;
            if(c[j]>=1){
                mid[i]=j;
                c[j]--;
                ll p=3-j-k;
                r[p]++;
                flag=false;
            }
        }
        if(flag){
            c[k]++;
            mid[i]=-100;
        }

    }
    //rep(i,0,3*n-1)cout<<mid[i]<<" ";cout<<endl;
    
    ll ans=1;
    memset(c,0,sizeof(c));
    rep(i,0,3*n-1){
        ll k=cal(i);
        if(mid[i]==-100){
            c[k]++;
        }else if(mid[i]<=2){
            ans=mod(ans*c[mid[i]]);
            c[mid[i]]--;
        }
    }
    memset(c,0,sizeof(c));
    for(ll i=3*n-1;i>=0;i--){
        ll k=cal(i);
        if(mid[i]==100){
            c[k]++;
        }else if(mid[i]>=0){
            ll p=3-mid[i]-k;
            ans=mod(ans*c[p]);
            c[p]--;
        }
    }
    ans=mod(ans*kai[n]);
    cout<<mod(ans)<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 9236
#include<iostream>
                using namespace std;
                 
                int main(){
                  char a;
                  cin >> a;
                  if(a == 'A'){
                	cout << "T" << endl;
                  }
                  if(a == 'T'){
                	cout << "A" << endl;
                  }
                   if(a == 'G'){
                	cout << "C" << endl;
                  } if(a == 'C'){
                	cout << "G" << endl;
                  }
                  return 0;
                }

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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("575");
            //4
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("3600");
            //13
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("999999999");
            //26484
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
        int N = wkArr[0];

        string[] wk753Arr = Derive753Arr();

        int Answer = 0;
        foreach (string EachStr in wk753Arr) {
            if (int.Parse(EachStr) <= N) {
                Answer++;
            }
        }
        Console.WriteLine(Answer);
    }

    static string[] Derive753Arr()
    {
        var WillReturn = new List<string>();

        var Stk = new Stack<string>();
        Stk.Push("");

        while (Stk.Count > 0) {
            string Popped = Stk.Pop();
            if (Popped.Contains("3") && Popped.Contains("5") && Popped.Contains("7")) {
                WillReturn.Add(Popped);
            }
            if (Popped.Length == 9) {
                continue;
            }

            Stk.Push(Popped + "3");
            Stk.Push(Popped + "5");
            Stk.Push(Popped + "7");
        }
        return WillReturn.ToArray();
    }
}


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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

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

  ll n; cin >> n;
  ll ans = 0;
  for(ll i=1; i*i<=n; i++) {
    if (n%i == 0) {
      auto j = n/i;
      auto a = j-1;
      auto b = i-1;
      debug(a, b);
      if (a!=0 && n/a == n%a) ans += a;
      if (b!=0 && a!=b && (n/b == n%b)) ans += b;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  int p, q, r;
  cin >> p >> q >> r;

  // if(p >= q && q >= r) cout << q+r;
  // else if(p <= q && q >= r) cout << p+r;
  // else if(p <= r && q <= r) cout << q+p;

  int max;
  if(p >= q) max = p;
  else max = q;

  if(max <= r) max = r;

  cout << (p+q+r) - max;
}


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

using namespace std;

int main() {
  int n, m = INT_MAX, ng = 0;
  ll s = 0;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a.at(i);
    s += abs(a.at(i));
    m = min(m, abs(a.at(i)));
    if(a.at(i) < 0)
      ng++;
  }
  if(ng % 2)
    cout << s - m * 2 << endl;
  else
    cout << s << endl;
}

Measured memory_bytes: 640
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;


public class Main {
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
	

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

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
    public static long mod = (long) (1e9+7);
    public final static int MAX = (int) 90000000;
  // static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
	   
	 FastReader sc = new FastReader();
	 int n = sc.nextInt();
	 int x = sc.nextInt();
	 Integer[] a = new Integer[n];
	 for(int i=0;i<n;++i) a[i] = new Integer(sc.nextInt());
	 Arrays.sort(a);
	 int[] b = new int[n];
	 for(int i=0;i<n-1;++i) {
		 int min = Math.min(a[i], x);
		 x-=min;
		 b[i] = min;
	 }
	 b[n-1] = x;
	
	 int ans = 0;
	 for(int i=0;i<n;++i) if(a[i] == b[i]) ++ans;
	 out.print(ans);
	 
	 
	
	 out.close();
		
	}
	
}

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

typedef long long ll;

ll f(ll x) {
    ll ans[4] = {x,1,x+1,0};
    return ans[x%4];
}

ll solve(ll a, ll b) { return a==0? f(b) : f(b)^f(a-1); }

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll a,b;
    while(cin >> a >> b) {
        cout << solve(a,b) << '\n';
    }
    return 0;
}

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

int main() {
	long long int result;
	std::vector<long long int> v;

	for (int i = 0; i < 2; i++) {
		int a;
		std::cin >> a;
		v.push_back(a);
	}

	std::sort(v.begin(), v.end());

	result = (v[1] - v[0]);

	if (result % 2 == 0) {
		std::cout <<v[1]-result/2 << std::endl;

	}else {
		std::cout << "IMPOSSIBLE" << std::endl;
	}

	
	return 0;
}

Measured memory_bytes: 256
#ABC131c 3.4以前ではmathではなくfractons

import fractions

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


count_c=b//c - (a-1)//c
count_d=b//d - (a-1)//d
count_cd=b//(c*d//fractions.gcd(c,d)) - (a-1)//(c*d//fractions.gcd(c,d))

print(b-a+1-count_c-count_d+count_cd)



Measured memory_bytes: 5048
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// ReSharper disable PossibleNullReferenceException
// ReSharper disable AssignNullToNotNullAttribute

namespace ProCon
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            var divMaxCandidate = (long) Math.Sqrt(n) + 1;
            long divMax = 0;
            for (long i = 1; i < divMaxCandidate; i++)
            {
                if (n%i == 0) divMax = i;
            }
            var d = n/divMax;
            Console.WriteLine(d+divMax-2);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

static const double PI = 3.14159265359;

struct Point {
  double x;
  double y;
};

void printPoint(const Point& p) {
  cout << p.x << " " << p.y << endl;
}

void koch(int d, Point p1, Point p2) {
  if (d == 0) return;

  Point s, t, u;
  s.x = (2 * p1.x + 1 * p2.x) / 3;
  s.y = (2 * p1.y + 1 * p2.y) / 3;
  t.x = (1 * p1.x + 2 * p2.x) / 3;
  t.y = (1 * p1.y + 2 * p2.y) / 3;
  u.x = (t.x - s.x) * cos(PI / 3) - (t.y - s.y) * sin(PI / 3) + s.x;
  u.y = (t.x - s.x) * sin(PI / 3) + (t.y - s.y) * cos(PI / 3) + s.y;

  koch(d - 1, p1, s);
  printPoint(s);
  koch(d - 1, s, u);
  printPoint(u);
  koch(d - 1, u, t);
  printPoint(t);
  koch(d - 1, t, p2);
}

int n;

int main() {
  cin >> n;
  cout << fixed << setprecision(8);
  Point p1 {0., 0.}, p2 {100., 0.};
  printPoint(p1);
  koch(n, p1, p2);
  printPoint(p2);
}



Measured memory_bytes: 3228
#include<stdio.h>
int main()
{
	int n,i,s;
	for(n=i=s=0;scanf("%d",&n)&&n!=0;printf("%d\n",s),n=i=s=0)
		for(;n>0;n-=4,s+=i)
			scanf("%d",&i);
	return 0;
}

Measured memory_bytes: 600
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<u32> = procon_read();
	let n = v[0];
	let k = v[1];
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut s:Vec<char> = buf.trim().chars().collect();
	for i in 0..(k-1){
		print!("{}", s[i as usize]);
	}
	print!("{}", s[(k-1) as usize].to_lowercase().next().unwrap());
	for i in k..n{
		print!("{}", s[i as usize]);
	}
	println!("");
}

Measured memory_bytes: 4352
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<sstream>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)
#define pb push_back


class Input{
	public:
	bool isObject;
	int space;
	string key;
	string data;
	
	Input(string str){
		int nspace = 0;
		for(;;nspace++)if(str[nspace]!=' ')break;
		
		int colon = nspace;
		for(;;colon++)if(str[colon-1]==':')break;
		
		int lspace =  colon+1;
		
		space = nspace;
		key = str.substr(nspace, colon-nspace-1);
		
		if(lspace+1 <= str.size()){
			data = str.substr(lspace, str.size()-lspace);
			isObject = false;
		}else{
			isObject = true;
		}
	}
	
	void print(){
		cout<<"sp = "<<space<<" key="<<key<<" data="<<data<<endl;
	}
};


string query;
vector<Input> in;


bool input(){
	getline(cin, query);
	while(!cin.eof()){
		string s;
		getline(cin, s);
		if(s=="")break;
		in.pb(Input(s));
	}
	return true;
}

class Data{
	public:
	bool isprop;
	string prop;
	string key;
	vector<Data> data;
	
	Data(string key){
		isprop = false;
		this->key = key;
	}
	Data(string key, string prop){
		isprop = true;
		this->key = key;
		this->prop = prop;
	}
	
	void print(int index){
		string space = "";
		rep(i,index)space += ' ';
		
		cout<<space; puts("----------------------");
		cout<<space; cout<<"key    : '"<<key<<"'"<<endl;
		cout<<space; cout<<"isprop : "<<isprop<<endl;
		cout<<space; cout<<"prop   : '"<<prop<<"'"<<endl;
		rep(i,data.size()){
			data[i].print(index+2);
		}
	}
};


Data kaiseki(int st, int en){
	
	//printf("st=%d  en=%d\n",st,en);
	if(st+1==en){
		return Data(in[st].key,  in[st].data);
	}
	
	
	Data ret(in[st].key);
	int head = st+1;
	int stspace = in[st+1].space;
	reps(i,st+2, en+1){
		if(i==en || in[i].space==stspace){
			ret.data.pb(kaiseki(head, i));
			head = i;
		}
	}
	return ret;
}


string calc(Data& data, string& q){
	
	
	if(q==""){
		if(data.isprop){
			stringstream sst;
			return "string \""+data.prop+"\"";
		}
		return "object";
	}
	
	int en = 1;
	for(;en<q.size();en++){
		if(q[en]=='.')break;
	}
	string key = q.substr(1, en-1);
	string nq = q.substr(en, q.size()-(en));
	
	//cout<<"q:"<<q<<"   nq:"<<nq<<"   key:"<<key<<endl;
	rep(i,data.data.size()){
		if(data.data[i].key==key){
			return calc(data.data[i], nq);
		}
	}
	
	return "no such property";
}


void solve(){
	Data parent("parent");
	
	int head = 0;
	reps(i,1,in.size()+1){
		if(i==in.size() || in[i].space==0){
			parent.data.pb(kaiseki(head, i));
			head=i;
		}
	}
	string ans = calc(parent, query);
	cout<<ans<<endl;
}

int main(){
	input();
	solve();
}

Measured memory_bytes: 1384
#include <iostream>

using namespace std;

int solve(int x, int y) {
  if (x == y)
    return x;

  int l, s;
  l = max(x,y);
  s = min(x,y);
  
  if (l % s == 0) 
    return s;
  return solve(l % s, s);
}

int main() {
  int x, y;
  cin >> x >> y;
  int res = solve(x, y);
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
int a, b, c, d;
int main() {
	cin >> a >> b >> c >> d;
	for (int i = 0; a > 0 && c > 0; i ^= 1) {
		if (i== 0)c -= b;
		else a -= d;
	}
	if (a > 0)puts("Yes");
	else puts("No");
	return 0;
}

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

int main() {
    long long k;
    long long x;
    cin >> k >> x;
    long long di;
    long long si;
    for (long long i = (k - 1); i > 0; --i) {
        di = x - i;
        cout << di << " ";
    } 
    cout << x << " ";
    for (long long i = 1; i < k ; ++i) {
        si = x + i;
        cout << si << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    int a, b, d, r;
    double f;
    
    cin >> a >> b;
    
    d = a / b;
    
    r = a % b;
    
    f = (double)a / (double)b;
    
    cout << d << " " << r << " " << fixed << setprecision(5) << f << endl;
}

Measured memory_bytes: 1244
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cctype>
#include <stdlib.h>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <iterator>

#define rep(i,n) for(i=1;i<=n;i++)
#define Rep(i,n) for(i=0;i<n;i++)
#define For(i,a,b) for(i=a;i<=b;i++)

#define pb(x) push_back(x)
#define sz(x) x.size()

#define mem(ara,val) memset(ara,val,sizeof(ara))
#define eps 1e-9

#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define ss(ch) scanf("%s",ch)
#define pi(x) printf("%d",x)
#define pii(x,y) printf("%d %d",x,y)
#define pl(x) printf("%lld",x)
#define pll(x,y) printf("%lld %lld",x,y)
#define ps(ch) printf("%s",ch)
#define NL printf("\n")
#define debug(x) printf("wow %d !!\n",x)

typedef long long LL;

using namespace std;

LL n;

LL fun(LL i,LL tot,LL num)
{
    if(tot>n || num>4 || i>9)return 0;
    if(tot==n)return 1;
    LL ans = 0;
    Rep(i,10)
    {
        if(num<4)ans+=fun(i,tot+i,num+1);
    }
    return ans;
}

int main()
{
    while(sl(n)!=EOF)
    {
        LL ans = fun(0,0,0);
        pl(ans);
        NL;
    }
    return 0;
}

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

using namespace std;

int main()
{
    int a,b,c,k,p,q,i;

    cin>>a>>b>>c>>k;

    for(i=1;a>=b;++i){

        b*=2;

        --k;

        if(k==0)break;

    }

    if(a>=b || k==0){

        cout<<"No"<<endl;

        return 0;

    }

    else{

        for(i=1;b>=c;++i){

            c*=2;

            --k;

            if(k==0)break;

        }

        if(b>=c)cout<<"No"<<endl;

        else cout<<"Yes"<<endl;

    }

    return 0;
}


Measured memory_bytes: 3508
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    
    odd_line = ""
    even_line = ""
    for i in range(W):
        if i % 2 == 0:
            odd_line = odd_line + "#"
            even_line = even_line + "."
        else:
            odd_line = odd_line + "."
            even_line = even_line + "#"
    
    print_str = "#" * W
    for i in range(H):
        if i % 2 == 0:
            print(odd_line)
        else:
            print(even_line)
    print("")


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

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        String[] s = new String[n];
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
        }
        String[] str = new String[n];
        for (int i = 0; i < n; i++) {
            char[] ch = s[i].toCharArray();
            Arrays.sort(ch);
            for (int j = 0; j < ch.length; j++) {
                str[i] += ch[j];
            }
        }
        Arrays.sort(str);
        long ans = 0;
        long cnt = 1;
        for (int i = 0; i < n - 1; i++) {
            if (!str[i].equals(str[i + 1])) {
                ans += cnt * (cnt - 1) / 2;
                cnt = 1;
                continue;
            }
            cnt++;
        }
        ans += cnt * (cnt - 1) / 2;
        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 96388
#include <stdio.h>
#include <string.h>

int main(void){
	char s[100];
	int i,j,len,flag=0;
	int tagi[26] = {0};
	scanf("%s",s);
	len = strlen(s);
	for(i=0;i<len;i++){
		for(j=0;j<26;j++){
			if('a' + j == s[i]){
				tagi[j]++;
			}
		}
	}
	for(i=0;i<26;i++){
		if(tagi[i]%2!=0){
			flag = 1;
		}
	}
	if(flag==1)printf("No\n");
	else printf("Yes\n");
	return 0;
}

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

using namespace std;

int main()
{
    int A, B;
    int count = 0;

    cin >> A >> B;

    for(int i=A; i<=B; i++){
        int d1, d2, _d1, _d2;

        _d1 = i % 10;
         d1 = i / 10000 % 10;

        _d2 = i /10 % 10;
         d2 = i /1000 % 10;

         if(d1 == _d1 && d2 == _d2)
         {
             count++;
         }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  string s;cin >> s;
  if(s[0]==s[1]&&s[1]==s[2]) cout << "No" << "\n";
  else cout << "Yes" << "\n";
  return 0;
}


Measured memory_bytes: 256
N,M,Q = map(int,input().split())
abcd = [list(map(int,input().split())) for i in range(Q)]

import itertools

A = list(itertools.combinations_with_replacement(range(1,M+1),N))
answer = 0

for i in range(len(A)):
    ans = 0
    for j in range(Q):
        if A[i][ abcd[j][1]-1 ] - A[i][ abcd[j][0]-1 ] == abcd[j][2]:
            ans += abcd[j][3]  
    answer = max(answer,ans)
    
print(answer)

Measured memory_bytes: 21436
#include <bits/stdc++.h>
using namespace std;
int n,m;
vector<int> a(28),b(28);
int ans=0;

bool check_point(vector<bool> reached,int next){
  if (reached.at(next-1)) return false;
  else return true;
}

int move(int now,vector<bool> reached,vector<bool> used_line,vector<bool> check){
  reached.at(now-1)=true;
  if (reached==check) {
    ans++;
  }
  
  for (int i=0;i<m;i++) {
    if (a.at(i)==now && used_line.at(i)==false && check_point(reached,b.at(i))) {
      used_line.at(i)=true;
      move(b.at(i),reached,used_line,check);
    }
    if (b.at(i)==now && used_line.at(i)==false && check_point(reached,a.at(i))) {
      used_line.at(i)=true;
      move(a.at(i),reached,used_line,check);
    }
  }
}

int main() {
  cin >> n>>m;
  for (int i=0;i<m;i++) cin>>a.at(i)>>b.at(i);
  vector<bool> reached(n,false),used_line(m,false),check(n,true);
  move(1,reached,used_line,check);
  cout<<ans<<endl;  
}

Measured memory_bytes: 256
#include <iostream>
int main(){
	int a,b,c,x,y;
	std::cin>>a>>b>>c>>x>>y;
	if(a>b){
		a=b;
	}
	if(a>c){
		a=c;
	}
	if(y<=x){
		x=y;
	}
	std::cout<<a+x-50<<std::endl;
	return 0;
}

Measured memory_bytes: 3080
N,Y = [int(i) for i in input().split()]

item = [10000, 5000, 1000]

result = '-1 -1 -1'
for num_10000 in range(N + 1):
    for num_5000 in range(N - num_10000 + 1):
        if Y == 10000 * num_10000 + 5000 * num_5000 + 1000 * (N - num_10000 -num_5000):
            result = str(num_10000)  + " " + str(num_5000) + " " + str(N- num_10000 -num_5000)
            break
print(result)


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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	string str;
	cin >> str;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		a[i]=(int)(str[i]-'0');
		a[i]--;
	}
	bool bo=true;//0 or 2
	for(int i=0;i<n;i++){
		if(a[i]==1) bo=false;
	}
	
	int coef=1;
	if(bo){
		coef=2;
		for(int i=0;i<n;i++){
			if(a[i]==2) a[i]=1;
		}
	}else{
		coef=1;
		for(int i=0;i<n;i++){
			if(a[i]==2) a[i]=0;
		}
	}
	
	vector<int> bp(n);
	for(int i=0;i<n;i++){
		//parity of binom(n-1,i)
		int a=n-1,b=i;
		b=min(b,a-b);
		int aa=a-b;
		int bb=b;
		if(aa&bb) bp[i]=0;
		else bp[i]=1;
	}
	//cout << bp << "\n";
	
	//cout << a << "\n";
	int res=0;
	for(int i=0;i<n;i++){
		res+=bp[i]*a[i];
	}
	res=res%2;
	
	cout << res*coef << "\n";
	return 0;
}

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

int main(){
  	string s;cin>>s;
    bool flag=false;
  	for(int i=0;i<3;i++){
      if(s[i]==s[i+1]){
        flag=true;
      }
    }
  	if(flag){
      cout<<"Bad"<<endl;
    }else{
      cout<<"Good"<<endl;
    }
  
	return 0;
}

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

xors = lambda x, y: sum([(a & x) ^ y for a in A])
memo = {}

def dp(flag, k):
  if k < 0: return 0
  if (flag, k) in memo: return memo[(flag, k)]

  x = 1 << k
  ans = 0

  if flag and not(K & x):
    ans = xors(x, 0) + dp(True, k-1)
  else:
    ans = max(xors(x, x) + dp(flag, k-1), xors(x, 0) + dp(False, k-1))

  memo[(flag, k)] = ans
  return ans

print(dp(True, 40))


Measured memory_bytes: 15144
#include <iostream>
#include <unordered_map>
using namespace std;
int main(){
  int n;
  cin >> n;
  unordered_map<int, int> mp;
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    auto itr = mp.find(a);
    if(itr != mp.end()){
      mp[a]++;
    }else{
      mp[a] = 1;
    }
  }

  int kaburi = 0;
  for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
    if(itr->second >= 2){
      kaburi += itr->second - 1;
    }
  }

  cout << n - (kaburi+1) / 2 * 2 << endl;
}


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

using namespace std;

int main(){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout.setf(ios::fixed); cout.precision(17);

  int n;
  cin >> n;
  vector<double> p(n);
  for(int i = 0; i < n; i++) cin >> p[i];
 
  vector<vector<double>> f(n+1, vector<double>(n+1, 0.0)); 
  f[0][0] = 1.0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j <= i + 1; j++){
      f[i+1][j] += f[i][j] * p[i];
      f[i+1][j+1] += f[i][j] * (1.0 - p[i]);
    }
  }
  
  double ans = 0.0;
  for(int j = 0; j <= n; j++){
    if(j < n - j) ans += f[n][j];
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 70784