akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define foro(i, n) for(i=0; i<n; i++)
#define forl(i, n) for(i=1; i<=n; i++)
#define x first
#define y second
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 1e18 + 1;

int main()
{
	int i, j, k, l, tmp;
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int a, b, n;
	cin >> a >> b;
	int low = b*10;
	int high = low+9;
	for(i=low; i<=high; i++){
		if(floor(i*0.08)==a){
			printf("%d\n", i);
			return 0;
		}
	}
	printf("-1\n");
}


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

#define fi first
#define se second

const int maxn = 1e3 + 10;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
char mp[maxn][maxn];
int step[maxn][maxn];
bool vis[maxn][maxn];
int n,m;

bool check(int x,int y) {
    if(x < 0 || y < 0|| x >= n || y >= m || vis[x][y] || mp[x][y] == '#') return false;
    return true;
}

int BFS() {
    queue<pair<int ,int> > q;
    q.push(make_pair(0,0));
    step[0][0] = 1;
    vis[0][0] = true;
    while (!q.empty()) {
        pair<int ,int> t = q.front();
        q.pop();
        for(int i = 0;i < 4;i++) {
            int tox = t.fi + Move[i][0];
            int toy = t.se + Move[i][1];
            if(tox == n - 1 && toy == m - 1) return step[t.fi][t.se] + 1;
            if(check(tox,toy)) {
                vis[tox][toy] = true;
                step[tox][toy] = step[t.fi][t.se] + 1;
                q.push(make_pair(tox,toy));
            }
        }
    }
    return -1;
}


int main(){
    cin>>n>>m;
    int cnt = 0;
    for(int i = 0;i < n;i++)
        for(int j = 0;j < m;j++) {
            cin>>mp[i][j];
            if(mp[i][j] == '#') cnt++;
        }
    int res = BFS();
    if(res == -1) {
        cout<<"-1"<<endl;
    } else {
        cout<<n*m - res - cnt<<endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstring>
#include<cstdio>
#define MN 200000
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int n,V,x[MN+5],s,nxt[20][MN+5],lst[20][MN+5],res[MN+5],f[1<<18],g[1<<18];
inline void R(int&x,int y){y>x?x=y:0;}
inline void L(int&x,int y){y<x?x=y:0;}
void Dp()
{
    memset(f,200,sizeof(f));f[0]=1;
    for(int i=0;i<1<<s;++i)
        for(int j=1;j<=s;++j) if(!(i&(1<<j-1)))
            R(f[i|(1<<j-1)],nxt[j][f[i]]);
    memset(g,63,sizeof(g));g[0]=n;
    for(int i=0;i<1<<s;++i)
        for(int j=1;j<=s;++j) if(!(i&(1<<j-1)))
            L(g[i|(1<<j-1)],lst[j][g[i]]);
}
void Solve(int l,int r)
{
    bool flag=0;
    for(int i=0;i<1<<s;++i)
        if(f[i]>=l&&g[(1<<s)-1-i]<=r) {flag=1;break;}
    if(flag)for(int i=l;i<=r;++i) res[i]=1;
}
int main()
{
    n=read();V=read();
    for(int i=1;i<=n;++i) x[i]=read();
    for(int t=V;;t>>=1,++s)
    {
        nxt[s][n]=nxt[s][n+1]=n+1;
        lst[s][0]=lst[s][1]=0;
        for(int i=2;i<=n;++i) lst[s][i]=x[i]-x[i-1]>t?i-1:lst[s][i-1];
        for(int i=n-1;i;--i)  nxt[s][i]=x[i+1]-x[i]>t?i+1:nxt[s][i+1];
        if(!t) break;
    }
    int tot=0;Dp();
    for(int i=1;i<=n;i=nxt[0][i],++tot);
    if(tot<=s+1) for(int b=1;b<=n;b=nxt[0][b],++tot) Solve(b,nxt[0][b]-1);
    for(int i=1;i<=n;++i) puts(res[i]?"Possible":"Impossible");
    return 0;
}


Measured memory_bytes: 37248
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,ok=0,x; cin>>n; 
    while (n--){
    	cin >> x; 
    	if (x&1) ok=1; 
    }
    cout << ((ok>0)?"first":"second") << endl; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3596
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){ 
    int n; cin>>n; 
    int a[n+1],b[n+1],f,s; 
    for (int i=1;i<=n;i++) {
        cin>>a[i]; 
        b[i]=a[i];
    }
    sort(a+1,a+n+1);
    f=a[n/2],s=a[n/2+1]; 
    for (int i=1;i<=n;i++){
        if (b[i]<=f) cout << s << endl;
        else cout << f << endl;
    }
} 

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 6712
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
const int MAX_N = 10010;
int par[MAX_N], rank[MAX_N];
class UnionFind
{
    public:
        vector<int> par, rank;
        UnionFind(int n)
        {
            par.resize(n);
            rank.resize(n, 0);
            for(int i = 0; i < n; i++) par[i] = i;
        }
        int find(int x)
        {
            return (par[x] == x ? x : par[x] = find(par[x]));
        }
        void unite(int x, int y)
        {
            x = find(x);
            y = find(y);
            if(x == y) return;
            if(rank[x] < rank[y]) par[x] = y;
            else 
            {
                par[y] = x;
                if(rank[x] == rank[y]) rank[x]++;
            }
        }
        bool same(int x, int y)
        {
            return find(x) == find(y);
        }
};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    UnionFind uf(n);
    for(int i = 0; i < q; i++)
    {
        int com, x, y;
        cin >> com >> x >> y;
        if(com == 0)
        {
            uf.unite(x, y);
        }
        else if(com == 1)
        {
            cout << uf.same(x, y) << "\n";
        }
    }
    return 0;
}




Measured memory_bytes: 3304
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  long a[n];
  int i,j;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  long s[n];
  s[0] = a[0];
  for(i=1;i<n;i++){
    s[i]=s[i-1]+a[i];
  }
  long bit[n];
  bit[0]=a[0];
  for(i=1;i<n;i++){
    bit[i]=bit[i-1]^a[i];
  }
  int left,right;
  left=0;
  right=0;
  long ans = 0;
  int chk=0;
  for(left=0;left<n;left++){
    right=max(left,right);
    for(i=right;i<n;i++){
      if(left==0){
        if(s[i]!=bit[i]){
          right = i-1;
          break;
        }
      }else{
        if(s[i]-s[left-1]!=(bit[i]^bit[left-1])){
          right=i-1;
          break;
        }
      }
      if(i==n-1)right=n-1;
    }
    ans += right-left+1;
  }
  cout << ans;
}


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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int n;
	cin >> n;

	vector<pair<int, int>> a(n);
	vector<pair<int, int>> b(n);
	rep (i, 0, n)
		cin >> a[i].first >> a[i].second;
	rep (i, 0, n)
		cin >> b[i].first >> b[i].second;
	sort(a.begin(), a.end(), [](const pair<int, int>& a, const pair<int, int>& b) {
			return a.second > b.second;
		});
	sort(b.begin(), b.end());

	int res = 0;
	vector<int> memo(n, 0);
	rep (i, 0, n) { // loop a
		rep (j, 0, n) {
			if (b[j].first > a[i].first && b[j].second > a[i].second && memo[j] == 0) {
				res++;
				memo[j] = 1;
				break;
			}
		}
	}

	cout << res << endl;
	return 0;
}


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

int main(){
	int n, i;

	cin>>n;

	int a[n];

	for(i = 0; i < n; i++){
		cin>>a[i];
	}
	for(i = n -1; i > 0; i--){
		cout<<a[i]<<" ";
	}
	cout<<a[0]<<endl;
		
	return 0;
}


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

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  string s,t;
  int cnt;
  cin >> s >> t;
  for (int i = 0; i < 3; i++){
    if (s[i] == t[i]){
      cnt ++;
    }
  }
  cout << cnt << '\n';
  return 0;
}

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

int64_t MOD = 1000000007;
double PI = 3.141592653589793;

int64_t MAX = 500000;
vector<int64_t> fac(MAX), finv(MAX), inv(MAX);

void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main()
{
    COMinit();
    int64_t N, K;
    cin >> N >> K;
    vector<int64_t> list(N);
    for (int i = 0; i < N; i++)
        cin >> list[i];
    sort(list.begin(), list.end());
    int64_t ans = 0, mi, ma;
    for (int i = 0; i < N; i++)
    {
        mi = COM(N - i - 1, K - 1);
        ma = COM(i, K - 1);
        ans = (ans + (ma - mi) * list[i]) % MOD;
    }
    cout << ans;
}

Measured memory_bytes: 15536
n = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)

x = 0
y = 0
v = 0
for a in A:
    #print(a)
    if v == 0 or v != a:
        v = a
        continue
    if x == 0:
        x = v
        v = 0
        #print('x=%d' % x)
        continue
    else:
        y = v
        #print('y=%d' % y)
        break
print(x*y)


Measured memory_bytes: 14244
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll n=in();
    bool app=true;
    for(int i=0;i<n;++i){
        ll a=in();
        app&=a%2==1||a%3==0||a%5==0;
    }
    cout<<(app?"APPROVED":"DENIED")<<endl;
}


Measured memory_bytes: 256
using System;

namespace SortThreeNumber
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');

            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int c = int.Parse(str[2]);
            int d;

            if (a > b)
            {
                d = a;
                a = b;
                b = d;
            }

            if (b > c)
            {
                d = b;
                b = c;
                c = d;
            }

            if (a > b)
            {
                d = a;
                a = b;
                b = d;
            }

            Console.WriteLine(a + " " + b + " " + c);
        }
    }
}

Measured memory_bytes: 9140
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll ar[100009];
int main()
{
   ll i,j,n,k,q,mn=0,r;
   cin>>n>>k>>q;
   for(i=1; i<=n; i++)
   {
     ar[i]=k;
   }
   

   for(i=1; i<=q; i++)
   {
     cin>>r;
     mn++;
     ar[r]+=1;
   }   
    
    for(i=1; i<=n; i++)
    {
     
       ar[i]-=mn;
    }

   for(i=1; i<=n; i++)
   {
     if(ar[i]>0)
     {
       cout<<"Yes"<<endl;
     }

     else cout<<"No"<<endl;
   }
   return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
int main(){
  ll n;cin>>n;vector<ll> a(n);for(ll i=0;i<n;i++)cin>>a[i];
  sort(a.begin(),a.end(),greater<ll>());
  ll sum=0;
  ll m1=-1,m2=-1;
  for(ll i=0;i<n-1;){
    if(a[i]==a[i+1]){
      if(m1==-1)m1=a[i];
      else{
        m2=a[i];
        break;
      }
      i+=2;
    }
    else i++;
  }
  sum=m1*m2;
  if(m1==-1||m2==-1)cout<<0<<endl;
  else cout<<sum<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	long long n; cin >> n;
	vector<long long> av;
	vector<long long> bv;
	
	for(long long i = 0; i < n+1; i++){
		long long a; cin >> a;
		av.push_back(a);
	}

	for(long long j = 0; j < n; j++){
		long long b; cin >> b;
		bv.push_back(b);
	}

	long long cnt = 0;
	for(long long i = 0; i < n; i++){
		if(av[i] <= bv[i]){
			cnt += av[i];
			if(av[i+1] < bv[i] - av[i]){
				cnt += av[i + 1];
				av[i+1] = 0;
			}else{
				av[i + 1] -= (bv[i] - av[i]);
				cnt += bv[i] - av[i];
			}
			av[i] = 0;
		}else{
			cnt += bv[i];
			av[i] = av[i] - bv[i];
		}
		
		//cout << av[i] << " ";
	}
	//cout << av[n]<<  endl;

	cout << cnt << endl;
}

Measured memory_bytes: 2548
#include <iostream>

using namespace std;

int main()
{
    string str;
    cin >> str;


  
    if(str == "SUN"){
        cout << "7" << endl;
    }
    else if(str == "MON"){
        cout << "6" << endl;
    }
    else if(str == "TUE"){
        cout << "5" << endl;
    }
    else if(str == "WED"){
        cout << "4" << endl;
    }
    else if(str == "THU"){
        cout << "3" << endl;
    }
    else if(str == "FRI"){
        cout << "2" << endl;
    }
    else if(str == "SAT"){
        cout << "1" << endl;
    }
   
    return 0;
}

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

using namespace std;

#define REP(a, b, c) for (register int a = b, _n = c; a <= _n; ++a)
#define DREP(a, b, c) for (register int a = b, _n = c; a >= _n; --a)
#define FOR(a, b, c) for (register int a = b, _n = c; a < _n; ++a)
#define DFOR(a, b, c) for (register int a = b, _n = c; a > _n; --a)
#define EREP(a, b) for (register int a = head[b]; a; a= edge[a].nxt)

inline int rd () {
	int x = 0; char IO = getchar();
	bool f = 0;
	while ((IO < '0' || IO > '9') && IO != '-') IO = getchar();
	if (IO == '-') f = 1, IO = getchar();
	while (IO >= '0' && IO <= '9') x = (x << 3) + (x << 1) + (IO ^ 48), IO = getchar();
	return f ? -x : x;
}

long long a;

string b;

void _main () {
	cin >> a;
	cin >> b;
	if (a < 3200)
		puts("red");
	else
		cout << b;
}

int main () {
#ifdef LOCAL
	freopen("in.txt", "r", stdin);
#endif
	_main();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <map>
 
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
 
int main(int argc, char *argv[]) {
    string a, b;
    int result;
    cin >> a >> b;
 
    result = stoi(a + b);
    double r = sqrt(result);
    if (r == static_cast<int>(r) ){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#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 N, M; cin >> N >> M;
  ll cnt = 0;
  for (ll i = 0; i < M; i++) {
    ll a; cin >> a;
    cnt += a;
  }
  cout << (cnt > N ? -1 : N - cnt) << endl;

  return 0;
}



Measured memory_bytes: 3636
#include"bits/stdc++.h"


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 100010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n,m;

int x[maxn],y[maxn],ban[maxn],vi[maxn];

bitset<maxn> Is[410][2];

void Work(){
	REP(i,1,n){
		REP(j,1,n)vi[j]=0;
		vi[i]=1;
		RREP(j,m,1){
			if(vi[x[j]]&&vi[y[j]])ban[i]=1;
			else if(vi[x[j]])Is[i][0][j]=1,vi[y[j]]=1;
			else if(vi[y[j]])Is[i][1][j]=1,vi[x[j]]=1;
		}
	}
	int ans=0;
	REP(i,1,n)REP(j,i+1,n)if(!ban[i]&&!ban[j]){
		if(!(Is[i][0]&Is[j][1]).any()&&!(Is[i][1]&Is[j][0]).any())ans++;
	}
	iout(ans);
}

void Init(){
	read(n,m);
	REP(i,1,m)read(x[i],y[i]);
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 11264
use std::io::*;
use std::str::FromStr;
use std::cmp::{min, max};

fn read<T: FromStr>() -> T {
    let s = stdin().bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    let a = read::<i32>();
    let b = read::<i32>();
    let c = read::<i32>();
    let d = read::<i32>();

    println!("{}", min(a, b) + min(c, d));
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
 int a,b,c;
  cin >> a >> b >> c;
  bool ans = false;
  if(a==b && a!=c) ans = true;
  if(a==c && a!=b) ans = true;
  if(b==c && a!=b) ans = true;
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
//D 数轴：0__(k)__i-1____________n-i+1___(k)____n 每次求出前后两个K区间和的差值，差值间的数都可以取到。由于10^100很大，区间重合的数加上大数后不会一样
const ll mod=1e9+7;
int main(){
    ll n,k,i,ans=0;
    cin>>n>>k;
    for(i=k;i<=n+1;i++){
        ans+=(i*(n-i+1+n)/2-(i-1)*i/2+1+mod)%mod;//先减后mod b%mod-a%mod=(b-a+mod)%mod
        ans%=mod;
    }
    //ans++; 循环中若考虑到区间长度为n+1,ans可以不用+
    cout<<ans<<endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int get(int s){
  set<int>st;
  while(s)st.insert(s%10),s/=10;
  return st.size()==1;
}
int main(){
  string s;
  cin>>s;
  stack<char>st;
  st.push(s[0]);
  r(i,s.size()-1){
    if(st.top()==s[i+1])continue;
    st.push(s[i+1]);
  }
  cout<<st.size()-1<<endl;
}

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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int s = sc.nextInt(); long res = 0;
        initFac(s);
        for (int i = 1; i <= s; i++) {
            int rem = s - 3 * i;
            if (rem < 0) continue;
            res = (res + nck(rem + i - 1, i - 1)) % mod;
        }
        out.println(res);
        out.close();
    }

    static long[] fac;
    static long mod = (long) 1e9 + 7;

    static void initFac(long n) {
        fac = new long[(int)n + 1];
        fac[0] = 1;
        for (int i = 1; i <= n; i++) {
            fac[i] = (fac[i - 1]  * i) % mod;
        }
    }



    static long nck(int n, int k) {
        if (n < k)
            return 0;
        long den = inv((int) (fac[k] * fac[n - k] % mod));
        return fac[n] * den % mod;
    }

    static long pow(long b, long e) {
        long ans = 1;
        while (e > 0) {
            if (e % 2 == 1)
                ans = ans * b % mod;
            e >>= 1;
            b = b * b % mod;
        }
        return ans;
    }

    static long inv(long x) {
        return pow(x, mod - 2);
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

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

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

Measured memory_bytes: 32860
#include "bits/stdc++.h"

#define sz(x) (int)x.size()
#define ld long double
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second

using namespace std;

const ll d = 64;

ll tt;
template<int SZ, typename T> struct XorBasis{
    int sz;
    vector<T> basis;
    XorBasis(){
        sz = 0;
        basis.assign(SZ, 0);
    }
    void insert(T vec){
        for(int i = 0; i < SZ; ++i){
            if(!((vec >> i) & 1)) continue;
            if(!basis[i]){
                basis[i] = vec;
                sz++;
                return;
            }
            vec ^= basis[i];
        }
    }
    bool find(T vec){
        for(int i = 0; i < SZ; ++i){
            if(!((vec >> i) & 1)) continue;
            if(!basis[i]){
                return false;
            }
            vec ^= basis[i];
        }
        return true;
    }
};
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> tt;
    while(tt--){
        ll n;
        string s;
        vector<ll> v;
        cin >> n;
        v.assign(n, 0);
        for(int i = 0; i < n; ++i){
            cin >> v[i];
        }
        cin >> s;
        for(int i = 0; i < n; ++i){
            if(s[i] == '0') continue;
            XorBasis<64, long long> cur;
            for(int j = i + 1; j < n; ++j){
                if(s[j] == '0') cur.insert(v[j]);
            }
            if(!cur.find(v[i])){
                cout << 1 << "\n";
                goto nxt;
            }
        }
        cout << 0 << "\n";
        nxt:;
    }
    return 0;
}

Measured memory_bytes: 3504
#include <bits/stdc++.h>
using namespace std;
int main() {
    char x, y;
    cin >> x >> y;

    if (x < y) {
        cout << '<' << endl;
    } else if (x == y) {
        cout << '=' << endl;
    } else if (x > y) {
        cout << '>' << endl;
    }
}

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

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

int main(int argc, char const *argv[]) {
	ll x, y; cin >> x >> y;
	int cnt = 1;
	while(1) {
		if((long double)x * 2 > (long double)y) break;
		x *= 2;
		cnt++;
	} cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int i, s;
    char x[1001];
    
    while(scanf("%s", x), x[0] != '0'){
        s = 0;
        
        for(i = 0; x[i] != '\0'; ++i){
            s += x[i] - '0';
        }
        
        printf("%d\n", s);
    }
    
    return 0;
}


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

#define M 1046527//质数且能表示999999
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch)
{
	if( ch == 'A') return 1;
	else if( ch == 'C') return 2;
	else if( ch == 'G') return 3;
	else if( ch == 'T') return 4;
	else return 0;
}

long long getKey(char str[])
{
	long long sum = 0, p = 1;
	for (int i = 0; i < strlen(str); ++i)
	{
		sum += p*(getChar(str[i]));
		p *= 5;//5进制
	}
	return sum;//sum is lower than M
}

int h1(int key)
{
	return key%M;
}
int h2(int key)
{
	return (1+key%(M-1));
}

int insert(char str[])
{
	long long key, i, h;
	key = getKey(str);
	for (int i = 0; ; ++i)
	{
		h = (h1(key) + i*h2(key))%M;
		if( strcmp(H[h],str) == 0 )		return 1;
		else if ( strlen(H[h]) == 0 )
		{
			strcpy(H[h], str);
			return 0;
		}
	}
	return 0;
}

int find(char str[])
{
	long long key, h;
	key = getKey(str);
	for (int i = 0; ; ++i)
	{
		h = (h1(key) + i*h2(key))%M;
		if( strcmp(H[h],str) == 0) return 1;
		else if( strlen(H[h]) == 0) return 0;
	}
	return 0;
}

int main(int argc, char const *argv[])
{
	int n, h;
	char str[L], com[9];
	for (int i = 0; i < M; ++i)
	{
		H[i][0] = '\0';
	}
	cin>>n;
	for (int i = 0; i < n; ++i)
	{
		scanf("%s %s",com, str);
		if (com[0]=='i')
		{
			insert(str);
		}
		else
		{
			if (find(str))
			{
				printf("yes\n");
			}
			else
				printf("no\n");
		}
	}
	return 0;
}








Measured memory_bytes: 17476
from collections import Counter as co
n=int(input())
s=set(list("qazwsxedcrfvtgbyhnujmiklop"))
l=[500 for i in range(26)]
for i in  range(n):
  gr=sorted([a for a in co(input()).items()])
  vs=set([a for a in zip(*gr)][0])
  for t in s-vs:
    l[ord(t)-97]=0
  if sum(l)==0:print();exit()
  for v, coun in gr:
    fg=ord(v)-97
    l[fg]=min(l[fg],coun)
  s&=vs
ans=""
for i,c in enumerate(l):
  if c:
    f=chr(i+97)
    ans+=f*c
print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,ans;
    bool a=false;
    cin>>n;
    for(int i=1; i<=50000; i++){
        int b;
        b=i*1.08;
        if(b==n) {
            a=true;
            ans=i;
    }
}
if(a) cout<<ans<<endl;
    else cout<<":("<<endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;

int main(){
    vector<int> A(3);
    rep(i, 3) cin >> A[i];
    sort(all(A));
    int sum = A[0] + A[1] + A[2];
    int d = A[2]*3 - sum;
    int ans;
    if (d%2 == 1) {
        ans = (d+3) / 2;
    } else {
        ans = d / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N+1),B(N+1);
    for(ll i=1; i<N+1; i++){
        cin >> A.at(i) >> B.at(i);
    }
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    if(N%2==0){
        double min = (A.at(N/2)+A.at(N/2+1))/2.0;
        double max = (B.at(N/2)+B.at(N/2+1))/2.0;
      	ll ans = (max - min)*2+1;
        cout << ans << endl;
    }else{
        ll min = A.at((N+1)/2);
        ll max = B.at((N+1)/2);
        cout << max - min + 1;
    }

    return 0;
}


Measured memory_bytes: 6428
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n;
    cin >> n;
    vec d(n);
    rep(i, n) cin >> d[i];

    sort(all(d));

    cout << d[n/2] - d[n/2 - 1] << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	int N; cin >> N;
	int A[2][101];

	rep(i, 0, 2) rep(j, 0, N) cin >> A[i][j];

	int max = 0;
	rep(k, 0, N) {
		int sum = 0;
		repe(i, 0, k) {
			sum += A[0][i];
		}
		rep(j, k, N) {
			sum += A[1][j];
		}
		if (max < sum) {
			max = sum;
		}
	}
	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
N = gets().to_i
btls = []
comp = [true] + Array.new(N, false)
c_mem = (1..N).to_a
N.times do |i|
  btls << gets().chomp!.split(" ").map{|e| e.to_i}
end
btls.unshift([])

ans = 0
# 対戦が全部完了するまで繰り返し
while !comp.all?
  ans += 1
  next_mem = []
  matched = Array.new(N+1, false)
  
  c_mem.each do |i|
    # すでに全戦終了済みだったらスキップ
    next if comp[i] or comp[btls[i][0]]
    vs = btls[i][0]
    
    # 相手の対戦順序と同じかどうか？
    if !matched[i] && !matched[vs] && i == btls[vs][0] 
      btls[i].shift
      btls[vs].shift
      next_mem << i << vs
      matched[i] = true
      matched[vs] = true
      comp[i] = true if btls[i].empty?
      comp[vs] = true if btls[vs].empty?
    end
  end
  if next_mem.empty?
    puts -1
    exit 0
  end
  c_mem = next_mem
end

puts ans



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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

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

    int k,x;
    cin >> k >> x;
    int sol = x-k+1;
    for(int i=0; i<k*2-1; i++)
        cout << sol++ << " ";
}

Measured memory_bytes: 256
N = gets.chomp.to_i
A = gets.chomp.split.map(&:to_i)
B = gets.chomp.split.map(&:to_i)
C = gets.chomp.split.map(&:to_i)
# A, B, C = gets.chomp.split.map(&:to_i)
# S = gets.chomp.chars

ans = 0
A.each do |i|
  ans += B[i-1]
end

0.upto(A.size-2).each do |j|
  i = A[j]
  if (A[j]+1 == A[j+1])
    ans += C[i-1]
  end
end

p ans

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b, c, x, y;
    scanf("%d%d%d%d%d", &a, &b, &c, &x, &y);

    int ans = 0, ans_a = 0, ans_b = 0, ans_c = 0;
    
    ans_a = max(x, y) * 2 * c;

    ans_b = a * x + b * y;
    
    int p = x < y ? b : a;
    ans_c = min(x, y) * 2 * c + p * abs(x - y);
    
    ans = min({ans_a, ans_b, ans_c});
    printf("%d\n", ans);
}

Measured memory_bytes: 3812
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] values = new int[w];
        for(int i = 0;i < values.length;i++){
        values[i] = i + 1;
        }
        for(int i = 0;i < n;i++){
            String str = sc.next();
            String[] ab = str.split(",");
            int a = Integer.parseInt(ab[0]) - 1;
            int b = Integer.parseInt(ab[1]) - 1;
            int tmp = values[a];
            values[a] = values[b];
              values[b] = tmp;
        }
        for(int i = 0;i < values.length;i++){
        System.out.println(values[i]);
        }
    }
}

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

void rot(char pat[8][8]){
	char pat2[8][8];
	for(int i=0;i<8;++i){
		for(int j=0;j<8;++j){
			int x = j;
			int y = 7-i;
			pat2[x][y] = pat[i][j];
		}
	}
	for(int i=0;i<8;++i){
		for(int j=0;j<8;++j){
			pat[i][j] = pat2[i][j];
		}
	}
}

int main() {
	char pattern[8][8];
	
	for(int i=0;i<8;++i)cin>>pattern[i];
	
	rot(pattern);
	cout<<"90"<<endl;
	for(int i=0;i<8;++i){
		for(int j=0;j<8;++j){
			cout<<pattern[i][j];
		}
		cout<<endl;
	}
	cout<<"180"<<endl;
	rot(pattern);
	for(int i=0;i<8;++i){
		for(int j=0;j<8;++j){
			cout<<pattern[i][j];
		}
		cout<<endl;
	}
	cout<<"270"<<endl;
	rot(pattern);
	for(int i=0;i<8;++i){
		for(int j=0;j<8;++j){
			cout<<pattern[i][j];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1136
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
int main() {
	int n; long long int k; std::cin >> n >> k;
	std::vector<int> nums(n); for (auto& a : nums) std::cin >> a;
	std::vector<int> prevs(200001, -1);
	for (auto i = 0; i < nums.size(); ++i) {
		if (prevs[nums[i]] == -1) {
			prevs[nums[i]] = (i + 1) % nums.size();
		}
	}
	std::vector<int> next(n);
	std::vector<int> step(n, 0);
	for (int i = 1; i <= nums.size(); ++i) {
		next[next.size() - i] = prevs[nums[nums.size() - i]];
		step[next.size() - i] = (prevs[nums[nums.size() - i]] - next.size() + i + nums.size() * 2 - 2) % nums.size() + 2;
		prevs[nums[nums.size() - i]] = (next.size() - i + 1) % next.size();
	}
	long long int loop_length = step[0];
	auto current = next[0];
	while (current != 0) {
		loop_length += step[current];
		current = next[current];
	}
	auto rest = n * k % loop_length;
	current = 0;
	std::vector<int> result;
	while (rest > 0) {
		if (rest >= step[current]) {
			rest -= step[current];
			current = next[current];
		}
		else {
			result.push_back(nums[current]);
			current = (current + 1) % nums.size();
			--rest;
		}
	}
	for (auto i = 0; i < result.size(); ++i) {
		if (i != 0) std::cout << ' ';
		std::cout << result[i];
	}
}

Measured memory_bytes: 5492
t = input()
before_is_zero = True
keeped_ones = 0
n0 = 0
ones = [0] * int(1e5+1) # (number of zeros before 1, is_odd)
ones_index = 0
for i, x in enumerate(t):
    if x == '0':
        n0 += 1
        before_is_zero = True
    elif x == '1':
        if before_is_zero:
            ones[ones_index] = (n0, (i+1)%2)
            ones_index += 1
            before_is_zero = False
        else:
            keeped_ones += 1
            ones_index -= 1
            before_is_zero = True

if before_is_zero:
    if len(ones) > 0:
        ones = ones[:-1]

ans = keeped_ones * n0
for i in range(ones_index):
    n0_before, is_odd = ones[i]
    ans += (n0_before + is_odd)//2 + (n0 - n0_before)
ans += (keeped_ones + (ones_index+1)//2) * (keeped_ones + ones_index//2 + 1)
print(ans)

Measured memory_bytes: 19976
N,W=map(int,input().split())
item=[tuple(map(int,input().split())) for _ in range(N)]
#item=(v,w)
dp=[[0 for _ in range(W+1)] for _ in range(N+1)]

for i in range(1,N+1):
    for w in range(1,W+1):
        if w>=item[i-1][1]:
            dp[i][w]=max(dp[i-1][w],dp[i][w-item[i-1][1]]+item[i-1][0])
        else:
            dp[i][w]=dp[i-1][w]
print(dp[N][W])


Measured memory_bytes: 16132
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using ull = unsigned long long;

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̕ϐ� (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    int a;
    string s;
    cin >> a;

    int ans = a + a * a + a * a * a;

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

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 3604
#include<stdio.h>

main(){
  int n,a[10],c,d;
  //山の高さ入力
  for(n = 0;n<10;n++){
    // printf("データ挿入:");
    scanf("%d",&a[n]);
  }

  //高い順に出力
  for(c = 0;c < 3;c++){ 
    // b = a[c];
    d = 0;
    for(n = 0;n < 10;n++){
      if(a[d] < a[n]){
	// b = a[n];
	d = n;
      }
    }
    // a[d] = 0;
    printf("%d\n",a[d]);
    a[d] = 0;
  }
  return(0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
	IOS;
	int h,n;
	cin>>h>>n;
	int v[h+1]; for(int i=0;i<h+1;i++) v[i]=1e18;
	v[h]=0;
	pii p[n];
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		p[i]={x,y};
	} 
	sort(p,p+n);
	for(int i=0;i<n;i++){
		int x=h-p[i].ff;
		x=max((int)0,x);
		for(int j=h-1;j>=x;j--) v[j]=min(v[j],p[i].ss);
		for(int j=x-1;j>=0;j--) v[j]=min(v[j],v[j+p[i].ff]+p[i].ss);
	}
	cout<<v[0]<<endl;
}

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int32_t inf = 1001001001;
const int64_t infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

template <typename T> using vector2d = vector<vector<T>>;

// clang-format off
template <typename T> void sort(vector<T> &v) { sort(all(v)); }
ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int64_t a = in(), b = in();

  int ans = 0;
  while (a <= b) {
    a *= 2;
    ans++;
  }

  cout << ans << endl;
}


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;
    cin >> N;
    vector<ll> W(N);

    ll total = 0;
    REP(i, N){
        cin >> W[i];
        total += W[i];
    }

    ll left = 0;
    ll m = INT_MAX;
    REP(i, N-1){
       left += W[i];
       ll right = total - left;
       m = min(m, abs(right-left));
    }

    cout << m << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        var n = long.Parse(Console.ReadLine());
        var min = long.MaxValue;
        for (long i = 1; i * i <= n; i++)
        {
            if (n % i != 0) continue;
            min = Min(min, n / i + i - 2);
        }
        Console.WriteLine(min);
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;
#define N 3
#define N2 9

struct Puzzle{
  int f[N2];
  int space;
  string path;



  bool operator < (const Puzzle &p) const{
    for(int i=0;i<N2;i++){
      if(f[i]==p.f[i]) continue;
      return f[i]>p.f[i];
    }
    return false;
  }
};

static const int dx[4]={-1,0,1,0};
static const int dy[4]={0,-1,0,1};
static const char dir[4]={'u','l','d','r'};

bool isTarget(Puzzle p){
  for(int i=0;i<N2;i++)
    if(p.f[i]!=(i+1)) return false;
  return true;
}

string bfs(Puzzle s){
  queue<Puzzle> Q;
  map<Puzzle,bool> V;
  Puzzle u,v;
  s.path="";
  Q.push(s);
  V[s]=true;

  while(!Q.empty()){
    u=Q.front(); Q.pop();
    if(isTarget(u)) return u.path;
    int sx=u.space/N;
    int sy=u.space%N;
    for(int r=0;r<4;r++){
      int tx=sx+dx[r];
      int ty=sy+dy[r];
      if(tx<0||ty<0||tx>=N||ty>=N) continue;
      v=u;
      swap(v.f[u.space],v.f[tx*N+ty]);
      v.space=tx*N+ty;
      if(!V[v]){
	V[v]=true;
	v.path+=dir[r];
	Q.push(v);
      }
    }
  }
  return "unsolvable";
}

int main(){
  Puzzle in;

  for(int i=0;i<N2;i++){
    cin>>in.f[i];
    if(in.f[i]==0){
      in.f[i]=N2;
      in.space=i;
    }
  }
  string ans=bfs(in);
  cout << ans.size() << endl;
  return 0;
}

Measured memory_bytes: 30612
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <cmath>
#include <math.h>

using namespace std;
const long long INF = (long long) (1e18)+1;

int main() {
  int n;
  cin >> n;
  cout << (n+ (n*n) + (n*n*n)) << endl;
  return 0;
}

Measured memory_bytes: 3584
import java.util.*;

public class Main{
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		char[][] field = new char[H][W];

		for(int i = 0; i < H; i++) {
			String s = sc.next();
			for(int j = 0; j < W; j++) {
				field[i][j] = s.charAt(j);
			}
		}
		sc.close();

		int row[][] = new int[H][W];

		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				if(j > 0) {
					if(field[i][j] == '.') {
						row[i][j] = row[i][j - 1] + 1;
					}
				}
				else {
					if(field[i][j] == '.') {
						row[i][j] = 1;
					}
				}
			}
			int copy = 0;
			for(int j = W - 1; j >= 0; j--) {
				if(row[i][j] != 0) {
					if(copy == 0){
						copy = row[i][j];
						}
					else {
						row[i][j] = copy;
					}
				}
				else copy = 0;
			}
		}
		
		int col[][] = new int[H][W];

		for(int i = 0; i < W; i++) {
			for(int j = 0; j < H; j++) {
				if(j > 0) {
					if(field[j][i] == '.') {
						col[j][i] = col[j - 1][i] + 1;
					}
				}
				else {
					if(field[j][i] == '.') {
						col[j][i] = 1;
					}
				}
			}
			int copy = 0;
			for(int j = H - 1; j >= 0; j--) {
				if(row[j][i] != 0) {
					if(copy == 0){
						copy = col[j][i];
						}
					else {
						col[j][i] = copy;
					}
				}
				else copy = 0;
			}
		}
		int max = 0;
		
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				max = Math.max(max, row[i][j] + col[i][j] - 1);
			}
		}

		System.out.println(max);
	}
}

Measured memory_bytes: 67896
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<iomanip>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end()
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) // <a> must be sorted in advance

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}


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

    int N;
    cin >> N;
    int ans = 0;
    REP(i, N) {
        int l, r;
        cin >> l >> r;
        ans += 1+r-l;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
        int n, u, k, v;
        int g[100][100];

        for (int i = 0; i < 100; i++) {
                for (int j = 0; j < 100; j++) {
                        g[i][j] = 0;
                }
        }
        cin >> n;
        for (int i = 0; i < n; i++) {
                cin >> u >> k;
                if (k > 0) {
                        for (int j = 0; j < k; j++) {
                                cin >> v;
                                g[u - 1][v - 1] = 1;
                        }
                }
        }
        for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                        cout << g[i][j];
                        if (j < n - 1) {
                                cout << " ";
                        }
                }
                cout << endl;
        }

        return 0;
}

Measured memory_bytes: 3140