akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head

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

    ll a;
    cin >> a;
    string s;
    cin >> s;

    int ind = find(all(s),'.') - s.begin();
    ll p1 = stoi(s.substr(0,ind));
    ll x = a * p1 + (a * stoi(s.substr(ind+1))) / 100;
    cout << x << endl;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  int a[n][6];
  rep(i,n) {
    rep(j,6) {
      int h,m;
      cin >> h >> m;
      a[i][j]=h*60+m;
    }
  }
  int ans=-1;
  rep(i,n)rep(ii,2)rep(j,n)rep(jj,2)rep(k,n)rep(kk,2) {
    int t[3]={a[i][ii],a[j][2+jj],a[k][4+kk]};
    int cnt=0;
    rep(l,n) {
      int c=0;
      rep(ll,3) {
        if(a[l][ll*2]<=t[ll]&&t[ll]<=a[l][ll*2+1]) c++;
      }
      if(c==3) cnt++;
    }
    ans=max(ans,cnt);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3092
n = int(input())
a = sorted(list(map(int,input().split())))
am = a[-1]+1
b = [0]*am
for i in a:
    b[i]+=1
    if b[i]==1:
        for j in range(i*2,am,i):
            b[j]=2
print(b.count(1))

Measured memory_bytes: 32156
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int n,m,l;
	cin>>n>>m>>l;
	vector<vector<int> > A(n,vector<int>(m)),B(m,vector<int>(l));
	for(int i=0;i<n;++i){
		for(int j=0;j<m;++j){
			cin>>A[i][j];
		}
	}
	for(int i=0;i<m;++i){
		for(int j=0;j<l;++j){
			cin>>B[i][j];
		}
	}
	for(int i=0;i<n;++i){
		for(int j=0;j<l;++j){
			long long sum=0;
			for(int k=0;k<m;++k){
				sum+=A[i][k] * B[k][j];
			}
			cout<<sum<<(j+1==l?"\n":" ");
		}
	}
	return 0;
}



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

int z[1001][1001];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string x,y;
    int n;
    cin>>n;
    while(n--) {
        cin>>x>>y;
        int lx=x.size(), ly=y.size();
        for(int i=0; i<=lx; i++) z[i][0]=0;
        for(int i=0; i<=ly; i++) z[0][i]=0;
        for(int i=1; i<=lx; i++) {
            for(int j=1; j<=ly; j++) {
                if(x[i-1]==y[j-1]) z[i][j]=z[i-1][j-1]+1;
                else z[i][j]=max(z[i][j-1],z[i-1][j]);
            }
        }
        cout<<z[lx][ly]<<'\n';
    }
    return 0;
}

Measured memory_bytes: 5120
#include<cstdio>
#include<algorithm>
#include<cctype>
using namespace std;
#define G getchar()
inline int read()
{
	int x=0; bool flg=false; char ch=G;
	for (;!isdigit(ch);ch=G) if (ch=='-') flg=true;
	for (;isdigit(ch);ch=G) x=(x<<3)+(x<<1)+(ch^48);
	return flg?-x:x;
}
#undef G

int n,nn,Mod;
int a[200010];
bool check(int x){
	for (int l=x+x+1,r=nn;l<r;l++,r--) if (a[l]+a[r]<Mod) return 0;
	return 1;
}
int work(int x){
	int res=0;
	for (int l=x+x+1,r=nn;l<r;l++,r--) res=max(res,a[l]+a[r]-Mod);
	for (int l=1,r=x+x;l<r;l++,r--) res=max(res,a[l]+a[r]);
	return res;
}
int main()
{
	n=read(),Mod=read(); nn=n<<1;
	for (int i=1;i<=nn;i++) a[i]=read();
	sort(a+1,a+nn+1);
	int l=0,r=n,mid;
	while (l<r){
		mid=l+r>>1;
		if (check(mid)) r=mid;
		else l=mid+1;
	}
	printf("%d\n",work(l));
	return 0;
}

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

int main() {
  int H,W;
  cin >> H >> W;
  
  vector<string> vec(H);
  
  for(int i=0;i<H;i++){
    cin >> vec.at(i);
  }
  
  cout << string(W+2,'#') << endl;
  
  for(int i=0;i<H;i++){
    cout << '#' << vec.at(i) << '#' << endl;
  }
cout << string(W+2,'#') << endl;
}


Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n, m, q;
  cin >> n >> m >> q;
  vll a(q), b(q), c(q), d(q);
  rep(i, q){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--; b[i]--;
  }
  vll x;
  ll ans = -INF;
  auto dfs = [&](auto& Self, int node) -> void{
    if(node == n){
      ll tmp = 0;
      rep(i, q){
        if(x[b[i]]-x[a[i]] == c[i]){
          tmp += d[i];
        }
      }
      chmax(ans, tmp);
    }else if(node == 0){
      repr(i, 1, m+1){
        x.emplace_back(i);
        Self(Self, node+1);
        x.pop_back();
      }
    }else{
      ll y = x.back();
      repr(i, y, m+1){
        x.emplace_back(i);
        Self(Self, node+1);
        x.pop_back();
      }
    }
  };
  dfs(dfs, 0);
  print(ans);
}


Measured memory_bytes: 3652
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(__,v.size()){rep(_,v[__].size())cout<<" "<<v[__][_];cout<<endl;}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

vi t;
bool f(int a){
	map<int,int>ma;
	stack<int>len;
	rep(i,t.size()){
		int w=t[i];
		ma[w]++;
		while(!len.empty()&&len.top()>w){
			ma.erase(len.top());
			len.pop();
		}
		len.push(w);
		while(w>0&&ma[w]==a){
			ma.erase(w);
			len.pop();
			ma[--w]++;
			if(len.empty()||len.top()-w)len.push(w);
		}
		if(ma[0])return 0;
	}
	return 1;
}
signed main(){
	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	rep(i,n-1)if(in[i]>=in[i+1])t.pb(in[i+1]);
	if(t.size()==0){
		cout<<1<<endl;
		return 0;
	}
	t=vi(0);
	rep(i,n-1)if(in[i]>=in[i+1]&&in[i+1]<30)t.pb(in[i+1]);
	int l=1,r=n;
	while(r-l>1){
		int h=(l+r)/2;
		if(f(h))r=h;
		else l=h;
	}
	cout<<r<<endl;
}


Measured memory_bytes: 5884
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
int main(void){
    string s;
    cin>>s;
    int n=s.size();
    int count=0;
    int ans=0;
    for(int i=0;i<n;i++){
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
            count++;
        }
        else{
            ans=max(ans,count);
            count=0;
        }
    }
    ans=max(ans,count);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
r = []
for i in range(n):
    city, score = map(str, input().split())
    score = int(score)
    r.append((city, score, i+1))

r.sort(key=lambda x: x[1], reverse=True)
r.sort(key=lambda x: x[0])

for x in r:
    print(x[2])


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define rf(i,n) for(int i=n-1;i>=0;i--)
#define rf1(i,n) for(int i=n-1;i>=1;--i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)
#define PI 3.1415926535897932384626433832795
#define fi first
#define se second
#define mp(x,y) make_pair(x,y)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define BIN(n,x) bitset<n>(x)  //bitshift works on 32 bit integers only
#define mod (ll)1000000007
#define mod1 (ll)998242353
using namespace std;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<ll,ll>> vpl;

//nC2
ll C2(ll n){
    ll ans= max(((n*(n-1))/2),(ll)0);
    return ans;
}
//square
ll sq(ll n){
    return n*n;
}

//GCD
ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    if(b==0){
        return a;
    }    
    else{
        return gcd(b,a%b);
    }
}

//LCM
ll lcm(ll a,ll b){
    if(a==0 || b==0){
        return 0;
    }
    else{
        return((ll)((a*b)/gcd(a,b)));
    }
}

//sort pair by second values
bool sortsec(const pair<ll,ll> &a, const pair<ll,ll> &b){ 
    return (a.second < b.second); 
}
//sort pair by first vals in descending
bool sortinrev(const pair<ll,ll> &a, const pair<ll,ll> &b){ 
    return (a.first > b.first); 
} 

//Binary Exponentiation
ll BinExp(ll a, ll b, ll m){
    a%=m;
    ll res =1;
    while(b>0){
        if(b&1){
            res = (res * a)%m;
        }
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}

//All Non-Empty SubSequences(O(2*n))
vvi SubSeq;
void allSub(vector<int> arr, int index,vector<int> subarr){
    if (index == arr.size()){ 
        int l = subarr.size(); 
        if (l != 0){
            SubSeq.pb(subarr); 
        }
    } 
    else{ 
        allSub(arr, index + 1, subarr); 
        subarr.push_back(arr[index]); 
        allSub(arr, index + 1, subarr); 
    } 
    return; 
} 

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

    char x;
    cin>>x;
    int n=x;
    if(n<=95)cout<<'A'<<endl;
    else cout<<'a'<<endl;
    


    return 0;
}



Measured memory_bytes: 3652
n = int(input())
a = list(map(int, input().split()))

b = a[1::2]
c = a[::2]

b_dic = {}
c_dic = {}

for i in range(n//2):
  if b[i] in b_dic.keys():
    b_dic[b[i]] += 1
  else:
    b_dic[b[i]] = 1
    
  if c[i] in c_dic.keys():
    c_dic[c[i]] += 1
  else:
    c_dic[c[i]] = 1
    
b_max = max(b_dic, key=b_dic.get)
c_max = max(c_dic, key=c_dic.get)

if b_max == c_max:
  m_b = b_dic[b_max]
  m_c = c_dic[c_max]
  
  b_dic[b_max] = 0
  c_dic[c_max] = 0
  
  b_max2 = max(b_dic, key=b_dic.get)
  c_max2 = max(c_dic, key=c_dic.get)

  ans = n - max(m_b + c_dic[c_max2], b_dic[b_max2] + m_c)
  
else:
  ans = n - b_dic[b_max] - c_dic[c_max]
  
print(ans)

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

int main(){
	vector<vector<int>> bingo(3, vector<int>(3));

	for (int i = 0; i < 3;i++){
		for (int j = 0; j < 3;j++){
			cin >> bingo.at(i).at(j);
		}
	}

	int n;
	cin >> n;

	vector<int> b(n);
	for (int i = 0; i < n;i++){
		cin >> b.at(i);
		for (int j = 0; j < 3;j++){
			for (int k = 0; k < 3;k++){
				if(b.at(i) == bingo.at(j).at(k)){
					bingo.at(j).at(k) = 0;
					break;
				}
			}
		}
	}

	int flag = 0;
	for (int i = 0; i < 3;i++){
		if (bingo.at(i).at(0) == 0 && bingo.at(i).at(1) == 0&& bingo.at(i).at(2) == 0){
			flag = 1;
			break;
		}else if(bingo.at(0).at(i) == 0 && bingo.at(1).at(i) == 0 && bingo.at(2).at(i) == 0){
			flag = 1;
			break;
		}
	}
	if(bingo.at(0).at(0) ==0&&bingo.at(1).at(1) ==0&&bingo.at(2).at(2) == 0 ||
	bingo.at(0).at(2)==0&&bingo.at(1).at(1) == 0 && bingo.at(2).at(0) == 0){
		flag = 1;
	}
	if(flag == 1){
		cout << "Yes"<< endl;
	}else{
		cout << "No" << endl;
	}
	
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N],d[N],f[N],tt;

void dfs_visit(int u)
{
  int v;
  color[u]=GRAY;
  d[u]=++tt;
  for(v=0;v<n;v++){
    if(M[u][v]==0) continue;
    if(color[v]==WHITE){
      dfs_visit(v);
    }
  }
  color[u]=BLACK;
  f[u] = ++tt;
}

void dfs()
{
  int u;
  for(u=0;u<n;u++)
    color[u]=WHITE;
  tt=0;

  for(u=0;u<n;u++){
    if(color[u]==WHITE)dfs_visit(u);
  }
  for(u=0;u<n;u++)
    printf("%d %d %d\n",u+1,d[u],f[u]);
}

int main(){
  int u, v, k, i, j;

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

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
	}
  }
  dfs();

  return 0;
}



Measured memory_bytes: 2144
n = input()
x = int(n)

ans = 0

for i in range(len(n)):
    if i%2==1:
        continue

    if i == len(n)-1:
        ans += (x - 10**(len(n)-1) +1)
    elif i%2==0:
        ans += 9 * (10**i)

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define repeat(i,a,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
  int N,L;
  cin >>N>>L;
  
  vector<string> S(N);
  repeat(i,0,N) cin >> S[i];
  sort(S.begin(),S.end());
 
  string ans;
  repeat(i,0,N) ans += S[i];
    
  cout <<ans<< endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
using Data = pair<ll, vector<int>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };
typedef tuple<ll, ll, ll>T;
typedef pair<ll,ll>pll;

const int MAX = 202020;
ll fac[MAX], finv[MAX], inv[MAX];

void combinit() {
	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;
	}
}
ll comb(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(){
	ll n, m, k;
	cin >> n >> m >> k;

	combinit();
	ll ans = 0;

	ll sum1 = 0;
	for (ll j = 1; j <= m - 1; j++) {
		sum1 += (j * (j + 1)) / 2;
		sum1 %= MOD;
	}
	sum1 *= n * n;
	sum1 %= MOD;
	sum1 *= comb(m*n-2,k-2);
	ll sum2 = 0;
	for (ll j = 1; j <= n - 1; j++) {
		sum2 += (j * (j + 1)) / 2;
		sum2 %= MOD;
	}
	sum2 *= m * m;
	sum2 %= MOD;
	sum2 *= comb(m*n - 2, k - 2);
	ans = sum1 + sum2;
	ans %= MOD;
	cout << ans << endl;

	
	return 0;
}

Measured memory_bytes: 4992
// ------------------------------------
// Date:2018/ 3/ 5
// Problem:ABC 083 SomeSums b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

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

  int a, b, n, ans = 0;
  cin >> n >> a >> b;
  REP(i, n + 1) {
    int tmp = i;
    int sum = 0;
    while (tmp > 9) {
      sum += tmp % 10;
      tmp /= 10;
    }
    sum += tmp;
    //cout << i << ":" << sum << endl;
    if (a <= sum and sum <= b) {
      ans += i;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  string s;
  cin >> s;
  int a=0,d=0;
  char c=s[0];
  char b='_';
  for (int i=1; i<4; i++){
    if (c==s[i]) {
      a++;
    }
    else if (b==s[i]){
      d++;
    }
    else b=s[i]; 
  }
  if (a==1 && d==1) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

typedef struct pp{
  char name[100];
  int t;
}A;
A Q[100000];
int head=0, tail, n;
void enqueue(A x){
  strcpy(Q[tail].name,x.name);
  Q[tail].t = x.t;
  tail++;
  if(tail == 100000){
    tail = 0;
  }
}
int main(){
  int elaps = 0;
  int i, q;
  scanf("%d %d", &n, &q);
  for ( i = 0; i < n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  tail = n;
  while(tail!=head){
    if(Q[head].t > q){
      elaps += q;
      Q[head].t -= q;
      enqueue(Q[head]);
    }
    else{
      elaps+=Q[head].t;
      printf("%s %d\n",Q[head].name,elaps);
    }
    head++;
    if(head == 100000){
      head = 0;
    }
  }
  return 0;
}

Measured memory_bytes: 10768
#include<stdio.h>
#define MAX 10000
#define NIL -1

typedef struct Node{int parent,left,right;}N;

N T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u,int d){
	if(u == NIL)return;
	D[u] = d;
	setDepth(T[u].left,d+1);
	setDepth(T[u].right,d+1);
}

int setHeight(int u){
	int h1 = 0;
	int h2 = 0;
	if(T[u].left != NIL)h1 = setHeight(T[u].left)+1;
	if(T[u].right != NIL)h2 = setHeight(T[u].right)+1;
	H[u] = (h1 > h2 ? h1 : h2);
	return H[u];
}


int getSibling(int u){
	if(T[u].parent == NIL) return NIL;
	if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)return T[T[u].parent].left;
	if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)return T[T[u].parent].right;
	return NIL;

}

void print(int u){
	printf("node %d: ",u);
	printf("parent = %d, ",T[u].parent);
	printf("sibling = %d, ",getSibling(u));
	int deg = 0;
	if(T[u].left != NIL)deg++;
	if(T[u].right != NIL)deg++;
	printf("degree = %d, ",deg);
	printf("depth = %d, ",D[u]);
	printf("height = %d, ",H[u]);
	
	if(T[u].parent == NIL){
	printf("root\n");
	}else if(T[u].left == NIL && T[u].right == NIL){
	printf("leaf\n");
	}else{
	printf("internal node\n");
	}

}

int main(void){
	int v, l,r,root = 0;
	
	scanf("%d",&n);

	for(int i = 0;i<n;i++){
	T[i].parent = NIL;
	}


	for(int i = 0;i < n;i++){
	scanf("%d %d %d",&v,&l,&r);
	T[v].left = l;
	T[v].right = r;
	if(l != NIL)T[l].parent = v;
	if(r != NIL)T[r].parent = v;
	}
	
	for(int i = 0;i < n; i++){
	if(T[i].parent == NIL)root =i;
	}
	
	setDepth(root,0);
	setHeight(root);
	
	for(int i = 0;i < n;i++)print(i);
	
	return 0;
	
}


Measured memory_bytes: 2080
#include "bits/stdc++.h"
using namespace std;
char Str[100005];
vector<pair<int,int> > V;

int main(){
    int N , i , Count = 1;
    char ch;
    scanf( "%s" , Str );
    ch = Str[0];
    N = strlen( Str );

    for( i = 1 ; i < N ; ++i ){
        if( ch != Str[i] ){
            V.emplace_back( make_pair( ch - '0' , Count ) );
            Count = 1;
            ch = Str[i];
        }
        else ++Count;
    }

    V.emplace_back( make_pair( ch - '0' , Count ) );
    int Ans = 0;
    int Value = V[0].first;
    int Pre = V[0].second;

    for( i = 1 ; i < V.size() ; ++i ){
        if( Value == -1 ){
            Value = V[i].first;
            Pre = V[i].second;
            continue;
        }

        if( V[i].first == 0 ){
            if( Value == 0 ) Pre += V[i].second;
            else{
                if( Pre == V[i].second ) Value = -1;
                else if( Pre < V[i].second ) Value = 0;
                else Value = 1;
                Ans += 2 * min( Pre , V[i].second ); 
                Pre = abs( Pre - V[i].second );
            }
        }
        else{
            if( Value == 0 ){
                if( Pre == V[i].second ) Value = -1;
                else if( Pre < V[i].second ) Value = 1;
                else Value = 0;
                Ans += 2 * min( Pre , V[i].second );
                Pre = abs( Pre - V[i].second );
            }
            else Pre += V[i].second;
        }
    }

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

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

using namespace std;

#define rep(i,a,b) for(int i = a; i<int(b);++i)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define trav(a,c) for(auto a: c)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;

int main(){
	cin.sync_with_stdio(false);
    ll n,y;
    cin>>n>>y;
    rep(i,0,n+1){
        rep(j,0,n+1){
            if((y-10000*i-5000*j)<0) continue;
            if((y-10000*i-5000*j)/1000+i+j==n){
                cout<<i<<" "<<j<<" "<<(y-10000*i-5000*j)/1000<<endl;
                exit(0);
            }
        }
    }
    cout<<"-1 -1 -1"<<endl;
    exit(0);
}


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

int main()
{
  string str;
  cin >> str;
  char ch = str[0];
  for(int i=1;i<str.size();i++){
    if(ch != str[i]){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define FOR(i,a,b) for(long long i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(long long i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll>pll;

signed main() {
	int k,a,b;
    cin>>k>>a>>b;
	
    int money=0,bis=1;

    if(b<a+2||k+1<a+2){
        cout<<k+1<<endl;
        return 0;
    }

    int ans=0;
    k++;
    ans+=b;
    k-=(a+2);
    ans+=k/2*(b-a);
    ans+=k%2;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

struct Edge {
    long long to, id;
};
using Graph = vector<vector<Edge>>;

vector<int> path;
bool dfs(const Graph &G, int u, int v, int p) {
    if (u == v) {
        return true;
    }
    for (auto e : G[u]) {
        if (e.to != p) {
            if (dfs(G, e.to, v, u)) {
                path.push_back(e.id);
                return true;
            }
        }
    }
    return false;
}

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N;
    cin >> N;
    Graph G(N);
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back({b, i});
        G[b].push_back({a, i});
    }

    int M;
    cin >> M;
    vector<ll> cons(M);
    rep(i, M) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        path = vector<int>();
        dfs(G, u, v, -1);
        for (auto e : path) {
            cons[i] |= 1LL << e;
        }
    }

    ll ans = 0;
    rep(bit, 1LL << M) {
        ll eset = 0;
        rep(i, M) {
            if (bit & (1LL << i)) {
                eset |= cons[i];
            }
        }
        int white = __builtin_popcountll(eset);
        ll num = 1LL << (N - 1 - white);
        // cout << "white:" << white << " num:" << num << endl;
        if (__builtin_popcountll(bit) % 2 == 0) {
            ans += num;
        } else {
            ans -= num;
        }
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
    int N;
    int ans=0;
    cin >> N;
    string b="",a="";
    vector<int> nums(N),B(N);
    for (int i = 0; i < N; i++) {
        cin >> nums.at(i);
        a += to_string(nums.at(i));
    }
    for (int i = 0; i < N; i++) {
        cin >> B.at(i);
        b += to_string(B.at(i));
    }

    if(a.compare(b)==0) cout << 0 << endl;
    else if(a.compare(b)>0){
    do {
        string e="";
        for (int value : B) {
            e += to_string(value);
            if(e.compare(a)==0){
                cout << ans << endl;
                return 0;
            }
        }
        ans++;
    } while (next_permutation(B.begin(), B.end()));

    }else{
        do {
        string e="";
        for (int value : nums) {
            e += to_string(value);
            if(e==b){
                cout << ans << endl;
                return 0;
            }
        }
        ans++;
    } while (next_permutation(nums.begin(), nums.end()));
    }
    
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
typedef long long ll;
typedef long double ld;


#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
ll S[1000] = { 0 };
int N,M,Q;


int main() {
	cin >> N;
	vector<int>A(N);
	vector<int>B(N);
	vector<int>C(N);
		rep(i, N) {
			cin >> A[i];
			B[i] = A[i];
			C[i] = A[i];
		}
		if (prev_permutation(A.begin(), A.end())) {
			rep(i, N - 1) {
				cout << A[i] << " ";
			}
			cout << A[N - 1] << endl;
		}
			rep(i, N - 1) {
				cout << B[i] << " ";
			}
			cout << B[N - 1] << endl;
		if (next_permutation(C.begin(), C.end())) {
			rep(i, N - 1) {
				cout << C[i] << " ";
			}
			cout << C[N - 1] << endl;
		}
	return 0;
}





Measured memory_bytes: 3100
import java.util.*;
class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            int H = sc.nextInt(), W = sc.nextInt();
            if(H == 0 && W == 0) break;
            for(int i = 0; i < H; i++) {
                for(int j = 0; j < W; j++) {
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 35300
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
import bisect
ans = 0
for j in range(len(b)):
    i = bisect.bisect_left(a,b[j])
    k = bisect.bisect_right(c,b[j])
    ans += i*(n-k)
print(ans)

Measured memory_bytes: 23328
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

using namespace std;

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}
template <class Con>
string concat(const Con &c, const string &spr){
	stringstream ss;
	typename Con::const_iterator it = c.begin(), en = c.end();
	bool fst = true;
	for(; it != en; ++it){
		if(!fst){ ss << spr; }
		fst = false;
		ss << *it;
	}
	return ss.str();
}

template <class Con, class Fun>
vector<typename Con::value_type> cfilter(const Con &c, Fun f) {
	vector<typename Con::value_type> ret;
	typename Con::const_iterator it = c.begin(), en = c.end();
	for(; it != en; ++it){
		if(f(*it)){
			ret.emplace_back(*it);
		}
	}
	return ret;
}
#if __cplusplus >= 201103L
template <class Con, class Fun>
auto cmap(const Con &c, Fun f) -> vector<decltype(f(*c.begin()))> {
	vector<decltype(f(*c.begin()))> ret;
	ret.reserve(c.size());
	for(const auto &x: c){
		ret.emplace_back(f(x));
	}
	return ret;
}
#endif


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()
#define tget(t,i) get<i>(t)

#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int n;
	scanf("%d", &n);
	LL s = 0, s2 = 0;
	for(int i = 0; i < n; ++i){
		LL a;
		scanf("%lld", &a);
		s = (s + a) % MOD;
		s2 = (s2 + a * a) % MOD;
	}
	LL ans = (s * s % MOD - s2 + MOD) * ((MOD + 1) / 2) % MOD;
	printf("%lld\n", ans);
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(const exception &e){
	cerr << "exception: " << e.what() << endl;
	abort();
}
catch(...){
	cerr << "exception" << endl;
	abort();
}


Measured memory_bytes: 3716
#include "stdio.h"

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

	for (int i=2; i>0; i--) {
		for (int j=0; j<i; j++) {
			if (array[j] > array[j+1]) {
				int tmp = array[j];
				array[j] = array[j+1];
				array[j+1] = tmp;
			}
		}
	}

	printf("%d %d %d\n", array[0], array[1], array[2]);
}




Measured memory_bytes: 2712
import numpy as np

N, K = map(int, input().split())
S = input()

l = [[], []]
ans = []
k = [int(s) for s in S]
if k[0] == 0:
    l[1].append(0)
v0 = 1 if k[0] == 0 else 0
v1 = 1 if k[0] == 1 else 0
for i in range(1, N):
    if (k[i]==0) & (k[i-1]==0):
        v0 += 1
    elif (k[i]==1) & (k[i-1]==0):
        l[0].append(v0)
        v0 = 0
        v1 += 1
    elif (k[i]==0) & (k[i-1]==1):
        l[1].append(v1)
        v0 += 1
        v1 = 0 
    else:
        v1 += 1
        
for i, v in enumerate([v0, v1]):
    if v > 0:
        l[i].append(v)
        
if k[0] == 0:
    l[1].append(0)

if len(l[0]) <= K:
    print(N)

else:
    l[0].extend(np.repeat(0,K+1))
    l[1].extend(np.repeat(0,K+1))
    a = sum(l[0][:K]) + sum(l[1][:K+1])
    ans.append(a)
    for i in range(1, len(l[0])-K-1):
        a -= l[0][i-1] + l[1][i-1]
        a += l[0][i+K-1] + l[1][i+K]
        ans.append(a)
    print(max(ans))

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

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

string s;

int main()
{
  while(cin >> s){
    int JOI = 0;
    int IOI = 0;
    rep(i, s.length()){
      if(s.substr(i, 3) == "JOI") JOI += 1;
      if(s.substr(i, 3) == "IOI") IOI += 1;
    }

    cout << JOI << endl;
    cout << IOI << endl;
  }

  return 0;
}

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

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
    ifstream t("/proc/self/status");
    cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;

const int MAXN = (int) 3e5;

int n;

char s[MAXN + 5];

inline void input()
{
	n = read<int>();
	scanf("%s", s + 1);
}

inline void solve()
{
	static int prefix[MAXN + 5], suffix[MAXN + 5];

	prefix[0] = 0;
	for(int i = 1; i <= n; ++i) prefix[i] = prefix[i - 1] + (s[i] == 'W');
	suffix[n + 1] = 0;
	for(int i = n; i; --i) suffix[i] = suffix[i + 1] + (s[i] == 'E');

	int ans = INT_MAX;
	for(int i = 1; i <= n; ++i) chkmin(ans, prefix[i - 1] + suffix[i + 1]);
	printf("%d\n", ans);
}

int main()
{
//	freopen("C.in", "r", stdin);
//	freopen("C.out", "w", stdout);

	input();
	solve();

	return 0;
}



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

int main() {
    int n, score1, score2;
    string s1, s2;
    score1 = score2 = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s1 >> s2;
        if (s1 > s2) {
            score1 += 3;
        } else if (s1 < s2) {
            score2 += 3;
        } else {
            score1 += 1;
            score2 += 1;
        }
    }
    cout << score1 << " " << score2 << endl;
    return 0;
}


Measured memory_bytes: 3156
#include <stdio.h>
main(){
  
  int a,b,c,x,y,z;
  
  scanf("%d%d%d",&a,&b,&c);
  
  if(a > b){ 
    x = a;
    a = b;
    b = x;
  }
  
  if(b > c){
    y = b;
    b = c;
    c = y;
  }
  
  if(a > b){
    z = a;
    a = b;
    b = z;
  }
  
  printf("%d %d %d\n",a,b,c);
  
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    int h[n];
    int ans = 1;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    int max = h[0];

    for (int i = 1; i < n; i++) {
        max = h[i-1] - max > 0 ? h[i-1]: max;
        
        if (h[i] >= max) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	map<string, int> mp;
	for(int i=0;i<n;i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	int most = 0;
	for(auto &s : mp) most=max(most, s.second);
	vector<string> ans;
	for(auto &s: mp) if(s.second==most) ans.push_back(s.first);
	sort(ans.begin(), ans.end());
	for(auto &s : ans) cout << s << "\n";
	return 0;
}


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

typedef long long LL;
typedef pair<int, int> pii;

#define fst first
#define snd second
#define pb push_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int maxn = 2e3 + 10;
const int oo = 0x7fffffff;

template<typename T> T read() {
	T n(0), f(1);
	char ch = getchar();
	for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
	for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}

int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif

    LL A, B;
    cin >> A >> B;
    if(A == B) {
        return puts("1"), 0;
    }

    int bit;
    for(int i = 61; i >= 0; --i) if(!(A >> i & 1LL) && (B >> i & 1LL)) { bit = i; break; }

    LL T = 1LL << bit;

    A &= (T-1);

    LL ans = T - A;

    LL L1, L2, R1, R2;

    R1 = L1 = T;
    for(int i = bit-1; i >= 0; --i) if(B >> i & 1LL) {
        R1 = T + (1LL << (i+1)) - 1;
        break;
    }

    L2 = T + A; R2 = (T<<1LL) - 1;

    if(L2 <= R1) { ans += R2 - L1 + 1; }
    else {
        ans += R1 - L1 + 1 + R2 - L2 + 1;
    }

    printf("%lld\n", ans);
    return 0;
}


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

typedef complex<int> Point;

vector<Point> e = {{+1,0}, {0,+1}, {-1,0}, {0,-1}};
string dir[4] = {"R","U","L","D"};

string command(Point cur, Point goal,int arm){
    if(arm == 0){
        if(cur == goal) return "";
        else arm = 1;
    }

    double min_dist = 2e9;
    int d = -1;
    rep(i,4){
        Point nxt = cur + e[i]*arm;
        if (min_dist > abs(goal - nxt)){
            min_dist = abs(goal - nxt);
            d = i;
        }
    }
    return dir[d] + command(cur + e[d]*arm, goal, arm/2);
}

int main(void){
    int n;
    cin>>n;
    vector<Point> ps(n);
    set<int> even_odd;
    rep(i,n){
        int x,y;
        cin>>x>>y;
        ps[i] = Point(x,y);
        even_odd.insert((abs(x+y))&1);
    }
    if(even_odd.size()!=1){
        cout<<-1<<endl;
        return 0;
    }

    vector<string> commands(n);
    rep(i,n){
        commands[i] = command(Point(0,0), ps[i], 1<<30);
    }
    int m = commands[0].size();
    cout<<m<<endl;
    int arm = 1<<30;
    rep(i,m){
        cout<<arm<<(i == m-1 ? "\n": " ");
        arm = arm==1 ? 1 : arm/2;
    }
    rep(i,n) cout<<commands[i]<<endl;

    return 0;
}


Measured memory_bytes: 384
/*Made by Shivam Solanki*/
#include<bits/stdc++.h> 
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define ll long long int
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<pii> vp;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef set<int> sii;
typedef set<ll> sll;
typedef priority_queue<int> pq;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
typedef queue<int> qii;
#define rep(i,k,n) for (int i = k; i < n; ++i) 
#define repr(i,k,n) for (int i = n; i>=k; --i)
#define repll(i,k,n) for (ll i = k; i < n; ++i) 
#define repllr(i,k,n) for (ll i = n; i >= k; --i) 
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int INF = 1e9+5;
const int MOD = 1e9+7;

void solve(){
    int n;
    cin>>n;
    cout<<(n+1)/2;
} 
 
  
int main(){
    // #ifndef ONLINE_JUDGE  
        // freopen("input.txt", "r", stdin); 
        // freopen("output.txt", "w", stdout); 
    // #endif 
    fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vb=vector<bool>;
ll n,m,k,l,ans;
vll a,b;

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    string s;
    cin >> s;
    int x = 0;
    int y = 0;
    for(auto c:s){
        if(c=='1') x++;
        if(c=='0') y++;
    }
    cout << (2*min(x,y)) << endl;
    return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
int main() {
	while (1) {
		int H, W, N; cin >> H >> W >> N;
		if (!H)break;
		vector<vector<int>>easts(H, vector<int>(W));
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				cin >> easts[i][j];
			}
		}
		vector<vector<int>>nums(H+1, vector<int>(W+1));
		nums[0][0] = N - 1;
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				const int total = nums[i][j];
				int a = (total + 1) / 2;
				int b = total / 2;
				if (!easts[i][j]) {
					nums[i][j + 1] += b;
					nums[i + 1][j] += a;
				}
				else {
					nums[i][j + 1] += a;
					nums[i + 1][j] += b;
				}
			}
		}
		int nx = 0, ny = 0;
		while (nx != W&&ny != H) {
			if ((easts[ny][nx] + nums[ny][nx]) % 2) {
				nx++;
			}
			else {
				ny++;
			}
		}
		cout << ny+1 << " " << nx+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 10748
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

int main()
{
	boost;
	int n, i;
	cin >> n;
	string s;
	cin >> s;
	
	int r = 0, w = 0;
	for(char c : s) {
		if(c == 'R') r++;
		else w++;
	}
	
	int totr = 0, totw = 0;
	fo(i, 0, r) {
		if(s[i] == 'R')
		totr++;
	}
	for(i = n - 1; i >= n - w; i--) {
		if(s[i] == 'W')
		totw++;
	}
	cout << min(r - totr, w - totw);
}


Measured memory_bytes: 3732
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int UF[100000];
int ijk[100000];
bool v[100000];
vector<pair<int,int> > g[100000];
pair<int,pair<int,int> >edge[200000];
vector<int>t[100000];
int segtree[524288];
int query(int a,int b,int c,int d,int e){
	if(d<a||b<c)return 99999999;
	if(c<=a&&b<=d)return segtree[e];
	return min(query(a,(a+b)/2,c,d,e*2),query((a+b)/2+1,b,c,d,e*2+1));
}
void set(int a,int b){
	a+=262144;
	while(a){
		segtree[a]=min(segtree[a],b);
		a/=2;
	}
}
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);b=FIND(b);
	if(a==b)return;
	UF[a]+=UF[b];
	UF[b]=a;
	t[a].push_back(b);
}int now=0;
int F[100000];
int TO[100000];
int num=0;
void dfs(int a){
	F[a]=now;
	int K=num++;
	TO[K]=a;
	set(now++,K);
	for(int i=0;i<t[a].size();i++){
		dfs(t[a][i]);
		set(now++,K);
	}
}
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	for(int i=0;i<b;i++){
		int p,q,r;scanf("%d%d%d",&p,&q,&r);
		p--;q--;g[p].push_back(make_pair(q,r));g[q].push_back(make_pair(p,r));
		edge[i]=make_pair(0,make_pair(p,q));
	}
	for(int i=0;i<a;i++)ijk[i]=1999999999;
	for(int i=0;i<a;i++)UF[i]=-1;
	for(int i=0;i<524288;i++)segtree[i]=99999999;
	priority_queue<pair<int,int> >Q;
	for(int i=0;i<c;i++){
		int e;scanf("%d",&e);e--;
		ijk[e]=0;Q.push(make_pair(0,e));
	}
	while(Q.size()){
		int cost=-Q.top().first;
		int at=Q.top().second;
		Q.pop();
		if(v[at])continue;
		v[at]=true;
		ijk[at]=cost;
		for(int i=0;i<g[at].size();i++){
			if(!v[g[at][i].first]&&ijk[g[at][i].first]>ijk[at]+g[at][i].second){
				ijk[g[at][i].first]=ijk[at]+g[at][i].second;
				Q.push(make_pair(-ijk[g[at][i].first],g[at][i].first));
			}
		}
	}
	for(int i=0;i<b;i++)edge[i]=make_pair(-min(ijk[edge[i].second.first],ijk[edge[i].second.second]),make_pair(edge[i].second.first,edge[i].second.second));
	std::sort(edge,edge+b);
	int s=0;
	int w=0;
	for(int i=0;i<b;i++){
		int l=edge[i].second.first;int r=edge[i].second.second;
		if(FIND(l)!=FIND(r)){
			if(ijk[l]>ijk[r])swap(l,r);
			UNION(l,r);
			w++;
			if(w==a-1)s=l;
		}
	}dfs(s);
	for(int i=0;i<d;i++){
		int x,y;
		scanf("%d%d",&x,&y);x--;y--;
	//	printf("%d\n",TO[query(0,262143,F[x],F[y],1)]);
		printf("%d\n",ijk[TO[query(0,262143,min(F[x],F[y]),max(F[x],F[y]),1)]]);
	}
}

Measured memory_bytes: 0
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    a, b = LI()
    if a > b:
        print(str(b) * a)
    else:
        print(str(a) * b)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
//verma_ankit484

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

typedef long long ll;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const ll mod = (ll) 1e9+7;

using namespace std;
//using namespace __gnu_pbds;

//#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>


int main() {
  char ch;
  cin >> ch;
  ch++;
  cout << ch << endl;
  return 0;
}


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

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

    vector<int> A(N);
    for(int i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }

    int min = pow(10,9) + 1;
    long long max = 0;

    for(int i = 0; i < N; i++)
    {
        if(min > A.at(i))
        {
            min = A.at(i);
        }

        if(max < A.at(i))
        {
            max = A.at(i);
        }
    }

    cout << max - min << endl;

    return 0;
}

Measured memory_bytes: 256