akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <iomanip>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2")
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long double ld;
typedef long long ll;
typedef double db;
#define endl '\n'
#define pb push_back
#define pii pair<ll, ll>
#define ff first
#define ss second
#define sz(x) (ll)(x).size()
#define optimize1() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#pragma warning(disable:4996)

using namespace std;

const ll MX = 1e6 + 10, INF = 1e9 + 1;
ll n, m, k, x, y, ans = 0;
vector<pii> sp;
signed main() {
	optimize1();
	cin >> n >> m >> k;
	ans = n;
	for (ll i = 0; i < k; ++i) {
		cin >> x >> y;
		sp.pb({ x, y });
	}
	ll res = 0;
	sort(all(sp));
	for (auto& c : sp) {
		x = c.ff;
		y = c.ss;
		if (x > y + res)
			ans = min(ans, x - 1);
		if (x == y + res)
			res++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6512
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define lowbit(x) (x&(-x))
#define mid ((l+r)>>1)
using namespace std;
template<class T>il read(T &x){
	x=0;int f=1;char k=getchar();
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=x*10+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x>9) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
const int N = 2e5+5;
const ll inf = 1e18;
int n,num,val[N];
ll k;
vector<int> pos,neg;
inl bool chk(ll lim){
	ll res=0;
	for(ri i=1;i<=n;++i){
		if(!val[i]&&lim>=0) res+=n-1;
		if(val[i]>0){
			if(!lim) res+=neg.size()+num;
			else if(lim>0){
				res+=neg.size()+num;
				if(1ll*val[i]*pos[0]>lim) continue;
				int l=0,r=pos.size()-1;
				while(l<r){
					if(1ll*val[i]*pos[mid+1]<=lim) l=mid+1;
					else r=mid;
				}
				res+=l+1-(pos[l]>=val[i]);
			}
			else{
				int l=0,r=neg.size()-1;
				if(r==-1) continue;
				if(1ll*val[i]*neg[0]>lim) continue;
				while(l<r){
					if(1ll*val[i]*neg[mid+1]<=lim) l=mid+1;
					else r=mid;
				}
				res+=l+1;
			}
		}
		if(val[i]<0){
			if(!lim) res+=pos.size()+num;
			else if(lim>0){
				res+=pos.size()+num;
				int l=0,r=neg.size()-1;
				if(1ll*val[i]*neg[r]>lim) continue;
				while(l<r){
					if(1ll*val[i]*neg[mid]<=lim) r=mid;
					else l=mid+1;
				}
				res+=neg.size()-l-(neg[l]<=val[i]);
			}
			else{
				int l=0,r=pos.size()-1;
				if(r==-1) continue;
				if(1ll*val[i]*pos[r]>lim) continue;
				while(l<r){
					if(1ll*val[i]*pos[mid]<=lim) r=mid;
					else l=mid+1;
				}
				res+=pos.size()-l;
			}
		}
	}
	return res>=k;
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),read(k),k<<=1;
	for(ri i=1;i<=n;++i){
		read(val[i]);
		if(val[i]>0) pos.push_back(val[i]);
		if(val[i]<0) neg.push_back(val[i]);
		if(!val[i]) ++num;
	}
	sort(pos.begin(),pos.end());
	sort(neg.begin(),neg.end());
	ll l=-inf,r=inf;
	while(l<r){
		if(chk(mid)) r=mid;
		else l=mid+1;
	}
	print(l);
	return 0;
}

Measured memory_bytes: 1912
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

double dp[305][305][305] = {0.0};

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

    LL n;
    cin>>n;
    VL a(n);
    REP(i,n)cin>>a[i];

    LL sum = 0;
    LL cnt[4] = {0};
    REP(i,n){
        cnt[a[i]]++;
        sum += a[i];
    }

    //1 1 1 -> 0 1 1
    //      -> 2 0 1
    //      -> 1 2 0
    //dp[i][j][k] = n/(i+j+k)
    //              + i/(i+j+k)*dp[i-1][j][k]
    //              + j/(i+j+k)*dp[i+1][j-1][k]
    //              + k/(i+j+k)*dp[i][j+1][k-1];
    REP(k,n+1)REP(j,n+1)REP(i,n+1){
        if(i+j+k == 0)continue;
        double dish = i+j+k;
        dp[i][j][k] = n/dish;
        dp[i][j][k] += i == 0 ? 0.0 : i / dish * dp[i-1][j][k];
        dp[i][j][k] += j == 0 ? 0.0 : j / dish * dp[i+1][j-1][k];
        dp[i][j][k] += k == 0 ? 0.0 : k / dish * dp[i][j+1][k-1];
    }

    printf("%.12f\n", dp[cnt[1]][cnt[2]][cnt[3]]);
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}


void _main() {
        int n, k; cin >> n >> k;
        vector<int> p(n), c(n); cin >> p >> c;
        auto go = [&](int i) -> ll {
                ll cnt = 0;
                vector<ll> cycle;
                vector<bool> vis(n);
                for (int rep = 0; rep < k; rep++) {
                        i = p[i - 1];
                        if (vis[i - 1]) break;
                        vis[i - 1] = 1;
                        cnt += c[i - 1];
                        cycle.emplace_back(cnt);
                }

                ll res = -1e18;

                for (int j = 1; j <= sz(cycle); j++) {
                        if (k - j < 0) break;
                        int cn = (k - j) / sz(cycle);
                        res = max(res, cycle[j - 1] + max(0LL, cn * cycle.back()));
                }

                return res;
        };


        ll ans = -1e18;
        for (int i = 0; i < n; i++) {
                ans = max(ans, go(i + 1));
        }

        cout << ans;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3808
n, m, k = gets.split.map(&:to_i)
a_books = gets.split.map(&:to_i)
b_books = gets.split.map(&:to_i)

a_times = (0...n).each_with_object([0]) { |num, result|
  result << result.last + a_books[num]
}

b_times = (0...m).each_with_object([0]) { |num, result|
  result << result.last + b_books[num]
}

sum_times = [0]
(0..n).each_with_object(sum_times) { |a_count, result|
  rest_time = k - a_times[a_count]
  next if rest_time < 0

  over = b_times.bsearch_index { |b_time| b_time > rest_time } || m + 1
  result << a_count + over - 1
}

puts sum_times.max


Measured memory_bytes: 45288
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define int long long int
#define ull unsigned long long

using namespace std;
const int MOD = 1e9 + 7;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m, k;
    cin>>n>>m>>k;
    int a[k];
    map<int, int> cnt;
    for(int i = 0;i<k;i++){
    	cin>>a[i];
    	cnt[a[i]]++;
    }
    for(int i = 0;i<n;i++){
    	if(m - (k - cnt[i+1]) > 0){
    		cout<<"Yes"<<endl;
    	} else {
    		cout<<"No"<<endl;
    	}
    }
    return 0;
}






Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = INT_MAX;
bool mywish(const pii &a,const pii &b)
  {
    return a.first > b.first;
  }
int power(int base,int n,int m)
 {
  if(n == 0)
     return 1;
  if(n&1)
     {
      int y = power(base,n-1,m);
      return (y*base)%m;
     }
  else
     {
      int y = power(base,n/2,m);
      return (y*y)%m;
     }
 }

void solve()
  {
   int n,m;
   cin>>n>>m;
   vector<int> v(n);
   int lcm = 1;
   int p2 = -1;
   loop(i,0,n)
    { 
     cin>>v[i];
     int x = v[i];
     int temp = 0;
     while(x%2==0)
       {
        x/=2;
        temp++;
       }
     if(p2 == -1)
       {
         p2 = temp;
         lcm = x;
       }
     else if(p2 != temp)
       p2 = -2;
     else
       lcm = lcm*x/__gcd(x,lcm);
    }
  if(p2 == -2)
     {
      cout<<0;
      return;
     }
  lcm = lcm * (1<<p2);
  int count = 2*m/lcm;
  if(count%2)
     count = count/2+1;
  else
     count /= 2ll;
  cout<<count;
  }
signed main()
 {
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
}    

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

#define ll long long
#define int ll
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define files(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(a) a.begin(), a.end()
#define pii pair<int, int>

using namespace std;

const int mod = 1e9 + 7;
const int max_n = 1e6 + 5;
const ld pi = acos(-1);
const int inf = 1e6 * 1e6 * 1e6;

int get_len(int n){
    if (0 <= n && n <= 9) return 1;
    return 1 + get_len(n / 10);

}

void run() {
    int n;
    cin >> n;
    __int128 ans = 1;
    rep(i, n){
        int el;
        cin >> el;
        if (el == 0) ans *= el;
        if (ans == 0) continue;
        if (ans <= inf) ans *= el;
    }
    if (ans <= inf) cout << (int)ans << '\n';
    else cout << -1 << '\n';
}

signed main() {
#ifndef ONLINE_JUDGE
    files("input.txt", "output.txt");
#endif
    //files("multiply.in", "multiply.out");
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    //cin >> t;
    while (t--)
        run();
    return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>
int main()
{
  int n,i,m,s=0;        
  scanf("%d",&n);        
    int ar[n];
   for(i=0;i<n;i++)
   {
    scanf("%d",&ar[i]);       
   } 
   m=ar[0];
   for(i=0;i<n;i++)
   {
   if(ar[i]>m) 
    {
      m=ar[i];            
    }  
   }
   for(i=0;i<n;i++)        
    {        
     s=s+ar[i];   
    } 
   if(s-m>m)         
   { 
            printf("Yes\n");
            
   } 
 
    else         
        {
               printf("No\n");
       }
    
  return 0;        
}

Measured memory_bytes: 1660
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
    long long int n;
    cin>>n;
    if(n%2==0){
        cout<<n<<endl;
    }else{
        cout<<n*2<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long destroyer(long long x){
    if(x==1){
        return 1;
    }
    else{
        return 2*destroyer(x/2)+1;
    }
}
int main(){
    long long H;
    cin >>H;
    cout <<destroyer(H)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int t;
    cin>>t;
    int i,j,x=1,z;
    string s[t+1];
    map<string,int>mp;
    map<string,int>m;
    vector<string> v;
    for(i=0; i<t; i++)
        {
        cin>>s[i];
        v.push_back(s[i]);
        mp[s[i]]++;
    }
    int mx=-1000000000;
    for(i=0; i<t; i++)
    {
        mx=max(mx,mp[s[i]]);
    }
    sort(v.begin(),v.end());
    for(i=0;i<v.size();i++)
    {
        if(mx==mp[v[i]])
        {
 
        if(m[v[i]]==0)
        {
            m[v[i]]++;
            cout<<v[i]<<endl;
        }
        else
        {
            continue;
        }
        }
    }
     return 0;
}

Measured memory_bytes: 40816
import java.io.PrintWriter;
import java.util.*;

public class Main {
    PrintWriter out = new PrintWriter(System.out);
    final long mod = 1000000000+7;
    public static void main(String[] args) {
        Main main = new Main();
        System.out.println(main.solve());
    }
    long solve(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n+1], b = new int[n+1];
        for(int i=1;i<=n;i++) a[i]=sc.nextInt();
        for(int i=n;i>=1;i--){
            int sum = 0;
            for(int j=2*i;j<=n;j+=i) sum += b[j];
            if((sum%2)!=(a[i]%2)) b[i] = 1; // otherwise no need to change status quo
        }
        List<Integer> ans = new LinkedList<>();
        for(int i=1;i<=n;i++){
            if(b[i]>0) ans.add(i);
        }
        out.println(ans.size());
        for(int i:ans){
            out.print(String.format("%d ",i));
        }
        out.flush();
        System.exit(0);
        return -1;
    }
}

Measured memory_bytes: 99524
import java.util.*;
    
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int i;
    for(i=1;i*i<=N;i++){
    }
    System.out.println((i-1)*(i-1));
  }
}


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

struct card{
	int id;
	unsigned int val;
	char mark;
};

int Partition(card* array, int begin, int end){
	unsigned int mid = array[end].val;

	int i = begin;
	for(int j = begin; j < end; j ++ ){
		if(array[j].val <= mid){
			card buf = array[i];
			array[i] = array[j];
			array[j] = buf;
			i ++ ;
		}
	}
	{
		card buf = array[end];
		array[end] = array[i];
		array[i] = buf;
	}

	return i;
}

void QuickSort(card* array, int begin, int end){
	if(begin >= end)return;
	
	int mid = Partition(array, begin, end);
	
	QuickSort(array, begin, mid - 1);
	QuickSort(array, mid + 1, end);
}

int main(){
	ios_base::sync_with_stdio(false);
	int num;
	card array[100001];
	cin >> num;

	for(int i = 0; i < num; i++){
		char mark;
		int val;
		cin >> mark;
		cin >> val;
		array[i].val = val;
		array[i].mark = mark;
		array[i].id = i;
	}
	QuickSort(array, 0, num - 1);
	bool flag = true;
	for(int i = 0; i < num - 1 && flag; i++){
		for(int j = 1; array[i].val == array[i + j].val; j++){
			if(array[i + j - 1].id > array[i + j].id){
				flag = false;
				break;
			}
		}
	}
	cout << (flag ? "Stable" : "Not stable") << endl;
	
	for(int i = 0; i < num; i++){
		cout << array[i].mark << " " << array[i].val << endl;
	}

	return 0;
}

Measured memory_bytes: 2372
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-10;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int p[610][610];
int q[610][610];
vector<pair<int,int> > v1;
vector<pair<int,int> > v2;
int n;
void dfs(int a,int b,int c,int d){
	if(a==0){
		for(int i=0;i<v1.size();i++){
			int tr=b+v1[i].first;
			int tc=c+v1[i].second;
			if(tr<0||tc<0||tr>=n||tc>=n)continue;
			if(p[tr][tc]==-1){
				p[tr][tc]=!d;
				dfs(0,tr,tc,!d);
			}
		}
	}else{
		for(int i=0;i<v2.size();i++){
			int tr=b+v2[i].first;
			int tc=c+v2[i].second;
			if(tr<0||tc<0||tr>=n||tc>=n)continue;
			if(q[tr][tc]==-1){
				q[tr][tc]=!d;
				dfs(1,tr,tc,!d);
			}
		}
	}
}
vector<pair<int,int> > s[4];
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
n=a*2;
	for(int i=-1000;i<1000;i++){
		for(int j=-1000;j<1000;j++){
			if(i*i+j*j==b)v1.push_back(make_pair(i,j));
			if(i*i+j*j==c)v2.push_back(make_pair(i,j));
		}
	}
	for(int i=0;i<a*2;i++)for(int j=0;j<a*2;j++)p[i][j]=q[i][j]=-1;
	for(int i=0;i<a*2;i++)for(int j=0;j<a*2;j++){
		if(p[i][j]==-1){
			dfs(0,i,j,0);
		}
		if(q[i][j]==-1){
			dfs(1,i,j,0);
		}
	}
	for(int i=0;i<a*2;i++)for(int j=0;j<a*2;j++){
		int to=p[i][j]*2+q[i][j];
		s[to].push_back(make_pair(i,j));
	}
	for(int i=0;i<4;i++){
		if(s[i].size()>=a*a){
			for(int j=0;j<a*a;j++)printf("%d %d\n",s[i][j].first,s[i][j].second);
			return 0;
		}
	}
}

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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll x; cin >> x;
  cout << 1 - x << endl;

  return 0;
}



Measured memory_bytes: 3676
S = input() # S_i = B(lack) or W(hite)
N = len(S)

"""
    最終的には W..W...B...B のような並びになる。
    元の状態から B がどれだけ右に進んだかの総和が答え。
"""

# def sum_contin_int(l, r):
#     return (r * (r + 1) - l * (l - 1)) // 2

cnt_initial = 0
cnt_b = 0
for i in range(N):
    if S[i] == 'B':
        cnt_initial += i
        cnt_b += 1

# cnt_final = sum_contin_int(N - cnt_b, N - 1)
cnt_final = sum([i for i in range(N - cnt_b, N)])

ans = cnt_final - cnt_initial
print(ans)

Measured memory_bytes: 11368
#include<iostream>
#include <math.h>
#include <iomanip>
#include <vector>

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

using namespace std;

int main() {
    ll a,b,c,d,e,o,n;
    cin >> a >> b >> c >> d >> e;
    n = d + (c*60);
    o = b + (a*60);
    cout << abs(n - o)-e;
}


Measured memory_bytes: 3552
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		boolean c = false;
		int a,b;
		a=stdin.nextInt();
		b=stdin.nextInt();
		if(a%3==0||b%3==0||a+b%3==0){
			c=true;
		}
		if(a%3==0||b%3==0||(a+b)%3==0){
			c=true;
		}
		if(c){
			System.out.println("Possible");
		}else{
			System.out.println("Impossible");

		}
	}

}

Measured memory_bytes: 20052
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=1005;
const int INF=1e9;
int n,X[MAXN],Y[MAXN];
int bi[100],l,f[5];
void Print(int x,int y){
	for(int i=1;i<=l;i++){
		if(fabs(x)>fabs(y)){
			if(x<0)printf("D"),x+=bi[i];
			else printf("U"),x-=bi[i];
		}
		else{
			if(y<0)printf("L"),y+=bi[i];
			else printf("R"),y-=bi[i];
		}
	}
	puts("");
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&X[i],&Y[i]);
		f[(X[i]+Y[i])%2]=1;
	}
	if(f[0]==f[1]){
		printf("-1\n");
		return 0;
	}
	l=0;
	for(int i=30;i>=0;i--)
		bi[++l]=(1<<i);
	if(f[0])bi[++l]=1;
	printf("%d\n",l);
	for(int i=1;i<l;i++)
		printf("%d ",bi[i]);
	printf("%d\n",bi[l]);
	for(int i=1;i<=n;i++)
		Print(Y[i],X[i]);
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end(), greater<int>());
  map<int, int> mp;
  mp[A.front()]++;
  queue<int> que;
  que.push(A.front());
  int64_t res = 0;
  for (int i = 1; i < N; i++) {
    if (que.front() == A[i]) {
      mp[A[i]]++;
      res += A[i];
    } else {
      mp[que.front()]--;
      mp[A[i]] += 2;
      res += que.front();
      que.push(A[i]);
    }
    while (mp[que.front()] == 0) {
      que.pop();
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 13700
#include<stdio.h>
int main(){
  int w,h;
  int x,y,r;
  int Rectangle;
  scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
  
  
  if(x<w&&y<h&&r<=x&&r<=y){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return(0);
}



Measured memory_bytes: 2080
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;

int main()
{ 
    fast;
ll n;
cin>>n;
   string s,t;
   cin>>s>>t;
   for(ll i=0;i<n;i++)
    cout<<s[i]<<t[i];


   }

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int n;
    std::cin >> n;
    long long int result = 0;

    long long int chunk  = (1 + 15) * 15 / 2 - (3 + 5 + 6 + 9 + 10 + 12 + 15);
    long long int repeat = n / 15;
    long long int a      = repeat;
    long long int b;
    if (repeat % 2 == 0)
    {
        b = repeat / 2 * (repeat - 1);
    }
    else
    {
        b = (repeat - 1) / 2 * repeat;
    }
    result += (a * chunk + b * 8 * 15);

    for (int i = 0; i <= n % 15; ++i)
    {
        if (i % 3 != 0 && i % 5 != 0) result += (repeat * 15 + i);
    }

    std::cout << result << std::endl;
    return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    double a, b, x;
    cin >> a >> b >> x;

    x /= a;

    if (x * 2 > a * b)
    {
        double s = a * b - x;

        double t = s * 2 / a;

        cout << setprecision(20) << atan2(t, a) * 180.0 / PI << endl;
    }
    else
    {
        double s = x;

        double t = s * 2 / b;

        cout << setprecision(20) << atan2(b, t) * 180.0 / PI << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <limits>
using namespace std;

#define rep(i,N) for(int i=0; i<N; i++)

typedef long long ll;

int main(void)
{
    int N, W;
    cin >> N >> W;

    int w[N];
    int v[N];
    
    rep(i,N) cin >> w[i] >> v[i];

    ll dp[N][W+1];
    rep(t,W+1){
        rep(s,N) {
            dp[s][t] = 0;
        }
    }
    
    rep(i,N) {
        if (i == 0) {
            rep(j, W+1) {
                if (j <= W-w[i]) dp[i][j] = v[i];
            }
        } else {
            rep(j, W+1) {
                if (w[i]+j > W) {
                    dp[i][j] = dp[i-1][j]; 
                } else {
                    dp[i][j] = max(dp[i-1][w[i]+j] + v[i], dp[i-1][j]);
                }
            }
        }

       //rep(t,W+1){
       //    cout << t << ":";
       //    rep(s,N) {
       //        cout << dp[s][t] << ",";
       //    }
       //    cout << endl;
       //}
       //cout << endl;
    }

    ll ans = 0;
    rep(j, W+1) {
        ans = max(ans, dp[N-1][j]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 78336
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;

int v, e;


typedef struct edge {
    int s;
    int t;
    int w;
} Edge;

vector<Edge> es;

struct Node {
    Node *p;
    int d; // depth
};

Node nodes[10000];

Node *find_root(int x) {
    Node *nd = &nodes[x];
    while(nd->p != nd) nd = nd->p;
    return nd;
}

void unite(int x, int y) {
    Node *xr = find_root(x);
    Node *yr = find_root(y);
    if(xr->d < yr -> d){
        xr->p = yr;
    } else {
        yr->p = xr;
        if(xr->d == yr -> d){
            (xr->d)++;
        }
    }
}

bool same(int x, int y) {
    auto xr = find_root(x);
    auto yr = find_root(y);
    return xr == yr;
}

bool cmp(Edge x, Edge y) {
    return x.w < y.w;
}

int kruskal() {
    sort(es.begin(), es.end(), cmp);
    int cost = 0;
    for (int i = 0; i < e; ++i) {
        Edge e = es[i];
        if(!same(e.s, e.t)) {
            unite(e.s, e.t);
            cost += e.w;
        }
    }
    return cost;
}

int main() {
    cin >> v >> e ;
    es.resize(e);
    for (int j = 0; j < v; ++j) {
        nodes[j].p = &nodes[j];
    }
    for (int i = 0; i < e; ++i) {
        int s,t ,w;
        cin >> s >> t >> w;
        Edge e = {s,t,w};
        es[i] = e;
    }

    cout << kruskal() << endl;

    return 0;
}



Measured memory_bytes: 4112
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
using namespace std;
#define ll long long
#include <cstdint>

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) 
{
    ll n;
    cin >>n;
    vs s(n);
    vll ss(n, 0);
    
    map <string, ull> mp;
    
    ull r = 0;
    rep(i, n) {
        cin >>s[i];
        Sort(s[i]);
        mp[s[i]] ++;
    }
    for(auto i: mp) {
        r += i.second * (i.second-1)/2;
    }
    mes(r);
}


Measured memory_bytes: 14736
fn solver(
    pos: usize,
    g: &Vec<Vec<usize>>,
    dis: &mut Vec<usize>,
    fin: &mut Vec<usize>,
    time: &mut usize,
) {
    for j in &g[pos] {
        if dis[*j - 1] == 0 {
            *time += 1;
            dis[*j - 1] = *time;
            solver(*j - 1, &g, dis, fin, time);
        }
    }
    *time += 1;
    fin[pos] = *time;
}

fn main() {
    let mut buf = String::new();
    let _ = std::io::stdin().read_line(&mut buf).ok();
    let n: usize = buf.trim().parse().unwrap();
    let mut g = Vec::new();
    for _ in 0..n {
        let mut buf = String::new();
        let _ = std::io::stdin().read_line(&mut buf).ok();
        let mut buf = buf.split_whitespace();
        let _: usize = buf.next().unwrap().parse().unwrap();
        let k: usize = buf.next().unwrap().parse().unwrap();
        let mut e = Vec::new();
        for _ in 0..k {
            let p: usize = buf.next().unwrap().parse().unwrap();
            e.push(p);
        }
        g.push(e);
    }
    let mut dis = vec![0; n];
    let mut fin = vec![0; n];
    let mut time = 0;
    for i in 0..n {
        if dis[i] == 0 {
            time += 1;
            dis[i] = time;
            solver(i, &g, &mut dis, &mut fin, &mut time);
            //println!("{:?}", dis);
            //println!("{:?}", fin);
            //println!();
        }
    }
    //solver(0, &g, &mut dis, &mut fin, &mut time);
    //println!("{:?}", g);
    //println!("{:?}", dis);
    //println!("{:?}", fin);
    for i in 0..n {
        println!("{} {} {}", i + 1, dis[i], fin[i]);
    }
}



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

int main(void)
{
    int A,B,N;
    cin>>N>>A>>B;
    if(N==1)
    {
        if(A==B)
            cout<<"1";
        else
            cout<<"0";
    }
    else 
    {
        if(A>B)
            cout<<"0";
        else
            printf("%lld\n",(long long )(B-A)*(N-2)+1);//问题所在※
    }
    return 0;
}


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

using namespace std;

string s;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	cin >> s;
	if (s[s.size() - 1] != 's') s += "s";
	else s += "es";
	
	cout << s << '\n'; 
	
	return 0; 
}

Measured memory_bytes: 3664
<?php

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(" ", $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int)$this->next();
    }

    public function nextDouble()
    {
        return (double)$this->next();
    }
}

class out
{
    public static function printIn($str = "")
    {
        echo $str . PHP_EOL;
    }
}

$sc = new Scanner;

// (最小値を求めるだけでなく、最小になる index を求める書き方も確認しましょう)

$n = $sc->nextInt();
$t = $sc->nextInt();
$a = $sc->nextInt(); // goal
$h = []; // heights array (x)
for ($i = 0; $i < $n; $i++) {
    $h[] = $sc->nextInt();
}

$nearest = 100000;
$point = 0;

for ($i = 0; $i < $n; $i++) {
    $x = $h[$i];
    $avg = $t - ($x * 0.006);
    if (abs($a - $avg) < abs($a - $nearest)){
        $nearest = $avg;
        $n_h = $h[$i]; // テストのために記載
        $point = 1 + $i;
    }
}

echo $point;

Measured memory_bytes: 4856
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds;  
using namespace std;



typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set; 
    
    
    
//defines
typedef long long ll;
typedef long double ld;

ll a,b,c,n,m,k;

ll t=1;


void solve()
{
    string s;
   cin>>n>>s>>m;
   m--;
   char check=s[m];
   for(auto p:s)
   {
       cout<<((check==p)?p:'*');
   }
 if(t>0)cout<<"\n";
}



int32_t main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  //cin>>t;
    while(t--)
    {
        solve();
    }
  //cout<<sum;
        
    return 0;
}

Measured memory_bytes: 3608
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       mut a:i32,
       b:i32,
       mut c:i32,
       d:i32,
    }

    loop {
        c -= b;
        if c <= 0 {
            echo!("Yes");
            return;
        }
        a -= d;
        if a <= 0 {
            echo!("No");
            return;
        }
    }
}


Measured memory_bytes: 2108
import java.util.*;

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

		for (int i=0; i<n; i++) {
			x[i] = stdIn.nextInt();
		}

		int p1 = 0;
		double p2 = 0;
		double p3 = 0;
		int pInf = -1;

		for (int i=0; i<n; i++) {
			x[i] = Math.abs(x[i] - stdIn.nextInt());
			p1 += x[i];
			p2 += Math.pow(x[i],2);
			p3 += Math.pow(x[i],3);
			pInf = Math.max(pInf,x[i]);
		}
		System.out.println(p1);
		System.out.printf("%.5f\n",Math.pow(p2,0.5));
		System.out.printf("%.5f\n",Math.pow(p3,(double)1/3));
		System.out.println(pInf);
	}
}

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

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

  ll a, b, x;
  cin >> a >> b >> x;

  if (a % x != 0) a += x - (a % x);
  if (b % x != 0) b -= b % x;
  ll d = b - a;

  ll res = a <= b ? d / x + 1: 0;
  cout << res << "\n";
}


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

long long a[100005];

int main(){
	long long k,i;
	cin >> k;
	long long ans_min,ans_max;
	for(i=0;i<k;i++){
		cin >> a[i];
	}
	ans_min = 2;
	ans_max = 2;
	bool flag = true;
	for(i=k-1;i>=0;i--){
		if(a[i]>ans_min&&a[i]>ans_max){
			flag = false;
			break;
		}
		else{
			if(ans_min%a[i]) ans_min += a[i];
			ans_min = (ans_min/a[i])*a[i];
			ans_max = (ans_max/a[i]+1)*a[i]-1;
			if(ans_min>ans_max){
				flag = false;
				break;
			}
		}
	}
	if(flag){
		cout << ans_min << " " << ans_max << endl;
	}
	else{
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m,q;
  while(cin >> n >> m >> q) {
    if(n==0 && m==0 && q==0) break;
    bool d[m][n];
    for(int i=0; i<m; i++) {
      for(int j=0; j<n; j++) d[i][j]=true;
    }
    vector<bool> v(m);
    fill(v.begin(),v.end(),0);
    while(q--) {
      string s1,s2;
      cin >> s1 >> s2;
      vector<bool> s(n),t(m);
      for(int i=0; i<n; i++) {
        if(s1[i]=='1') s[i]=true;
        else s[i]=false;
      }
      for(int i=0; i<m; i++) {
        if(s2[i]=='1') t[i]=true;
        else t[i]=false;
      }
      for(int i=0; i<n; i++) {
        for(int j=0; j<m; j++) {
          bool ck=(t[j]!=v[j]);
          if(s[i]&&!ck || !s[i]&&ck) d[j][i]=false;
        }
      }
      v=t;
    }
      
    for(int i=0; i<m; i++) {
      int ans=-1;
      for(int j=0; j<n; j++) {
        if(d[i][j]) {
          if(ans==-1) ans=j;
          else ans=-2;
        }
      }
      if(ans<0) cout << "?";
      else {
        char c;
        if(ans<10) c=(char)(ans+'0');
        else {
          ans-=10;
          c=(char)(ans+'A');
        }
        cout << c;
      }
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 1256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ll long long
#define ld long double
#define zeros(x) x^(x-1)&x
#define pii pair<ll,ll>
#define cd complex<double>
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#define Nmax 200005
#define OFF 100001
using namespace std;

int fr[Nmax], n, m, nr[Nmax], x, y;

int main()
{
    cin >> n >> m;
    fr[1] = 1;
    for (int i=1;i<=n;i++) nr[i] = 1;
    for (int i=1;i<=m;i++){
        cin >> x >> y;
        fr[y] |= fr[x];
        nr[x]--;
        nr[y]++;
        if (nr[x]==0) fr[x] = 0;
    }
    int ans = 0;
    for (int i=1;i<=n;i++){
        ans += fr[i];
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define ll long long int
#define X first
#define Y second
#define fw(i, start, end) for (ll i = start; i < end; ++i)
#define fe(i, start, end) for (ll i = start; i <= end; ++i)
#define L(T)  \
    ll T;     \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
#define endl "\n"
int main()
{
    FASTIO
    // L(T)
    {
        ll a, b, h, m;
        cin >> a >> b >> h >> m;
        double val1, val2, val3;
        double x = (double)(h + (double)m / 60) * 30 - (double)m * 6;
        double th = fabs(x);
        val1 = a * a;
        val2 = b * b;
        val3 = sqrt(val1 + val2 - 2 * a * b * cos(th / 57.2957795131));
        printf("%.12lf\n", val3);
    }
    return 0;
}

Measured memory_bytes: 4120
def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

from collections import Counter

N = INT()
s = [input() for _ in range(N)]
M = INT()
t = [input() for _ in range(M)]

s = Counter(s)
t = Counter(t)
ans = 0

for k, v in s.items():
    ans = max(ans, v - t[k])
    
print(ans)

Measured memory_bytes: 65756
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 #include<memory>
 
 using namespace std;
 
 int abs(int a,int b)
 {
   if(a>=b) return (a-b);
   else return (b-a);    
 }

 int main()
 {
   string s;
   while(cin>>s)
   {
     int cnt=0;
     int kk[3]={0};
     int sum=0;
     for(int i=0;i<s.length();i++)
     {
       kk[s[i]-'a']++;        
     }
     for(int i=0;i<3;i++)
     { 
       if(kk[i]>0)
       { 
         cnt++;
         sum+=kk[i];
       }
     }
     if(cnt==1)
     { 
       if(sum==1) cout<<"YES"<<endl;
       else cout<<"NO"<<endl;
     }
     else if(cnt==2)
     {
       if(sum==2) cout<<"YES"<<endl;
       else cout<<"NO"<<endl;     
     }
     else
     {
       if(abs(kk[0]-kk[1])<=1&&abs(kk[1]-kk[2])<=1&&abs(kk[0]-kk[2])<=1)
       {
         cout<<"YES"<<endl;                                                             
       }    
       else cout<<"NO"<<endl;
     } 
   }
   return 0;
 }
 

        


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
    long long int n,i,j,k=-1,c=0;
    vector<long long int>v;
    cin>>n>>j;
    for(i=0;i<n;i++)
    {
        cin>>k;
        v.push_back(k);

    }
   c=j;
    for(i=1;i<n;i++)
    {

       if(v[i]-v[i-1]>=j)
       {
           c+=j;

       }
       else
       {

           c+=v[i]-v[i-1];
       }
    }


    cout<<c<<endl;
    return 0;
}



Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, k;
	cin >> n >> k;
	vector<int>dp1(n);
	vector<bool>dp2(n);
	dp2[0] = true;
	for (int i = 0; i < n; i++) {
		dp1[i] = 1;
	}
	for (int i = 1; i < n; i++) {
		dp2[i] = false;;
	}
	for (int i = 0; i < k; i++) {
		int fro, to;
		cin >> fro >> to;
		fro--, to--;
		if (dp2[fro]) {
			dp2[to] = true;
		}
		dp1[to]++;
		dp1[fro]--;
		if (dp1[fro] == 0) {
			dp2[fro] = false;
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (dp2[i] > 0)ans++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 3728
/**
  @file c.cpp
  @title C - こだわり者いろはちゃん / Iroha's Obsession
  @url https://atcoder.jp/contests/abc042/tasks/arc058_a
**/

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, N) for (int i = 0; i < (N); ++i)

int ret = 1e6;

int dfs(int now, const int N, const set<int> like) {
  // end condition
  if (N <= now && now < 1e5) {
    return now;
  }

  for (auto l : like) {
    int next = now * 10 + l;
    // cout << now << " -> " << next << "\n";

    if (next == 0) continue;

    if (N <= next && next < 1e5) {
      ret = min(ret, dfs(next, N, like));
    } else {
      ret = dfs(next, N, like);
    }
  }
  return ret;
}

int main() {
  int N, K;
  cin >> N >> K;

  set<int> like = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
  vector<int> D(K);
  REP(i, K) {
    cin >> D[i];
    like.erase(D[i]);
  }

  // for (auto e : like) {
  //   cout << e << endl;
  // }

  cout << dfs(0, N, like) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe

int main(void){ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////////////////
int a,b,ans=1;
cin >> a >> b;
int c=a;
for(int i=0;i<20;i++){
   if(b==1){
      cout << 0 << endl;
      break;
   }
   else if(a<b){
      a=a+c-1;
      ans++;
   }
   else{
      cout << ans << endl;
      break;
   }
}
////////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.regex.Pattern;

public class Main {

	public static void main(String[] args) {
		OriginScanner os = new OriginScanner();
		PrintWriter pw = new PrintWriter(System.out);
		
		int n = os.nextInt();
		String s = os.next();
		
		String str = "";
		for (int i = 0; i < s.length(); i++) {
			char se = s.charAt(i);
			int a = 0;
			while(a++ < n) {
				se++;
				if (!Pattern.matches("^[A-Z]+$", String.valueOf(se))) se = 'A';
			}
			str += String.valueOf(se);
		}
		pw.println(str);
		pw.close();
	}
	
	static class OriginScanner {
		private BufferedReader br;
		private StringTokenizer st;
		
		public OriginScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String nextLine() {
			String str = null;
			try {
				str = br.readLine();
			}
			catch (IOException e) {
				System.out.println(e);
			}
			return str;
		}
		String next() {
			if (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(nextLine());
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}


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

// 渦巻きで外から中に
// ↓→↑←の順
const int y_mv[] = {+1,  0, -1,  0, +1,  0, -1,  0};
const int x_mv[] = { 0, +1,  0, -1,  0, +1,  0, -1};
int blocks[500+2][500+2]; // blocks[y][x]

typedef struct {
	int from_x;
	int from_y;
	int to_x;
	int to_y;
} mv;


int main(void)
{
	int H, W;
	cin >> H >> W;
	
	for (int x = 0; x <= W+1; x++) {
		blocks[0][x] = -1;
		blocks[H+1][x] = -1;
	}
	for (int y = 0; y <= H+1; y++) {
		blocks[y][0] = -1;
		blocks[y][W+1] = -1;
	}

	for (int y = 1; y <= H; y++) {
		for (int x = 1; x <= W; x++) {
			int num;
			cin >> num;
			if ((num&1)==1) blocks[y][x] = 1; // odd
			else            blocks[y][x] = 0; // even
		}
	}

	vector <mv> movelist;
	vector <mv> tmp_movelist;
	int now_x = 1, now_y = 1; // start pos
	int rotate = 0;
	bool odd_found = false;
	mv m;
	
	while (rotate < 8) {
		if (rotate >= 4) rotate -= 4;

		if (blocks[now_y][now_x] == -1) break;

		if (odd_found) { // add
			m.to_x = now_x;
			m.to_y = now_y;
			tmp_movelist.push_back(m);
		}

		if (blocks[now_y][now_x] == 1) { // odd
			if (odd_found) { // add
				movelist.insert(movelist.end(), tmp_movelist.begin(), tmp_movelist.end());
				tmp_movelist.clear();
				odd_found = false;
			} else {
				odd_found = true;
			}
		}

		m.from_x = now_x;
		m.from_y = now_y;
		blocks[now_y][now_x] = -1;

		while (rotate < 8) {
			int to_x = now_x + x_mv[rotate];
			int to_y = now_y + y_mv[rotate];
			int next_block = blocks[to_y][to_x];
			if (next_block != -1) {
				now_x = to_x; now_y = to_y;
				break;
			}
			rotate++;
		}
	}


	cout << movelist.size() << endl;
	for (unsigned int i = 0; i < movelist.size(); i++) {
		mv m;
		m = movelist.at(i);
		cout << m.from_y << " " << m.from_x << " " << m.to_y << " " << m.to_x << endl;
	}
	return 0;
}


Measured memory_bytes: 6604