akhauriyash/Code-Regression huggingface dataset:
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
	n = len(l)
	

N = int(stdin.readline())
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
# print(len(l))
print(l[N-1])


Measured memory_bytes: 39408
n , m, c= map(int, input().split())

b = list(map(int, input().split()))
ans = 0
for i in range(n):
    a = list(map(int, input().split()))
    if sum([j * k for  j, k in zip(a, b)]) + c > 0:
        ans += 1

print(ans)

Measured memory_bytes: 3060
#n, m = map(int,input().split())
#n = int(input())
#ls = list(map(int,input().split()))
#ls = [list(map(int,input().split()))[1:] for i in range(n)]
#ls = [int(input()) for i in range(n)]
s = input()
ls = []
for i in range(len(s)-2):
  ls.append(abs(int(s[i:i+3])-753))
print(min(ls))

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 605;
const int P = 1e9 + 7;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int s[MAXN], home[MAXN], dp[MAXN][MAXN];
int n, m, p[MAXN], fac[MAXN];
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
int main() {
	read(n), read(m), fac[0] = 1;
	for (int i = 1; i <= n; i++)
		fac[i] = fac[i - 1] * (2ll * i - 1) % P;
	for (int i = 1; i <= m; i++) {
		int x, y; read(x), read(y);
		home[x] = home[y] = i;
	}
	int ans = 0;
	for (int i = 1; i <= n * 2; i++) {
		static bool col[MAXN]; int cnt = 0, empty = 0;
		memset(col, false, sizeof(col));
		for (int j = i; j <= n * 2; j++) {
			if (home[j]) {
				cnt -= col[home[j]];
				col[home[j]] ^= true;
				cnt += col[home[j]];
			} else empty += 1;
			if (cnt == 0 && empty % 2 == 0) {
				dp[i][j] = fac[empty / 2];
				for (int k = i, cmt = 0; k <= j - 1; k++) {
					cmt += !home[k];
					if (cmt % 2 == 0) update(dp[i][j], P - 1ll * dp[i][k] * fac[empty / 2 - cmt / 2] % P);
				}
				update(ans, 1ll * dp[i][j] * fac[n - m - empty / 2] % P);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const int INF=1e9;

ll AttackTime(ll h){
  if(h==1){
    return 1;
  }else{
    return 2*AttackTime(h/2)+1;
  }
}


int main(){
  ll h;
  cin>>h;
  cout<<AttackTime(h);
  
}


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

struct UnionFind{
    vector<int> par;
    vector<int> siz;

    UnionFind(int n): par(n), siz(n){
        for(int i=0; i<n; i++){
            par[i] = i;
            siz[i] = 1;
        }
    }

    int root(int x){
        if(par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

    int size(int x){
        return siz[root(x)];
    }

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx != ry){
            par[ry] = rx;
            siz[rx] += siz[ry];
        }
    }

    bool same(int x, int y){
        return root(x) == root(y);
    }
};

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n, m;
    cin >> n >> m;

    UnionFind uf(n);
    for(int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        uf.unite(a-1, b-1);
    }

    int maxsize = 0;
    for(int i=0; i<n; i++){
        maxsize = max(maxsize, uf.size(i));
    }
    cout << maxsize << endl;

    return 0;
}

Measured memory_bytes: 6548
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define mp make_pair
#define int long long
#define mod 1000000007
#define DEBUG cout<<"Hello1\n";
#define all(v) (v).begin(),(v).end()
#define clr(x) memset(x,0,sizeof(x))
#define deb(...) debug(#__VA_ARGS__, __VA_ARGS__);
const int N = 1e6 + 5;
const double pi =  acosl(-1);
const long long inf = 1e18 + 5;
using namespace std;
template<typename T> void debug(string s, T x) {cout << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cout << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}
template<class T> void print_container(T &container) { for (auto &t : container) { cout << t << " ";} cout << endl;}
template<class T> void printArr(T &a , int n) { for (int i = 0; i < n; i++) {cout << a[i] << " ";} cout << endl;}
typedef long long ll;
typedef pair<int, int> pii;

//Template Ends
int n;
int r, g, b, k;

void solve() {
	cin >> r >> g >> b >> k;

	while (r >= g && k > 0) {
		g *= 2;
		k--;
	}

	while (g >= b && k > 0) {
		b *= 2;
		k--;
	}
	// deb(r, g, b);
	if (g > r && b > g) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}

int32_t main() {
	IOS;



	solve();

	return 0;
}




Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,k;
ll a[2000005];
ll Count(ll x)
{
    ll ret=0;
    ll ok,ng,mid;
    for(int i=0;i<n;i++)
    {
        if(a[i]>=0)
        {
            ok=-1;ng=n;
            while(ng-ok>=2)
            {
                mid=(ok+ng)/2;
                if(a[i]*a[mid]<=x) {
                    ok=mid;
                }
                else
                ng=mid;
            }
            if(ok>=i) ret+=ok;
            else ret+=ok+1;

        }
        else
        {
            ok=n;ng=-1;
            while(ok-ng>=2)
            {
                mid=(ok+ng)/2;
                if(a[i]*a[mid]<=x) {
                    ok=mid;
                }
                else
                ng=mid;
            }
            if(ok<=i) ret+=n-ok-1;
            else ret+=n-ok; 
        }
    }
    return ret/2;
}
int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    ll INF = 2 * (1e+18);
	ll st = -INF, ed = INF, mid;	//(st, ed]
	while (ed - st >= 2) {
        //cout<<st<<" "<<ed<<" "<<mid<<" "<<Count(mid)<<endl;
		mid = (st + ed) / 2;
		if (Count(mid) < k) st = mid; //mid以下の数が何個？
		else ed = mid;
        
	}
	cout << ed << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <unordered_map>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
constexpr ll INF = 1000000000;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n; cin >> n; 
	unordered_map<string, int>mp;

	vector<string>s(n);
	rep(i, n)cin >> s[i];

	rep(i, n) {
		sort(s[i].begin(), s[i].end());
		mp[s[i]]++;
	}

	ll ans = 0;
	for(pair<string,int> p : mp) {
		ll m = p.second;
		ans += m * (m - 1) / 2;
	}
	cout << ans << endl;
	/*vector<int>vec = { 2,3,4,5,6,9 };
	for (auto i : vec)cout << i << endl;*/
}

Measured memory_bytes: 16164
#include <bits/stdc++.h>
typedef long long ll;

#define pll pair<ll,ll>
#define ff first
#define snd second
#define pb push_back
#define vll vector<ll>
#define vpll vector<pll>
#define endl "\n"
#define MOD 1000000007
using namespace std;

ll const N = 13;
vll cost(N);
std::vector<vll>v(N,vll(N));
vll z(N,0);
ll n,m,k;
ll dp[N][5000];

ll getAns(vll &arr, int curr=0,int state = 0)
{
        if(curr==n)
        {
                for(int i=0;i<m;i++)
                {
                        if(arr[i]<k)
                        return 1e9;
                }
                return 0;
        }
        
        if(dp[curr][state]!=-1)
        return dp[curr][state];
        
        ll s = 1<<curr;
        int d = (state | s);
        vll vec(m);
        for(int i=0;i<m;i++)
        {
                vec[i] = arr[i] + v[curr][i];
        }
        ll a1 = getAns(vec,curr+1,d)+cost[curr];
        ll a2 = getAns(arr,curr+1,state);
        dp[curr][state] = min(a1,a2);
        return dp[curr][state];
}

void solve()
{
   
   cin>>n>>m>>k;
   
   memset(dp,-1,sizeof(dp));
   bool done = 1;
   for(int i=0;i<n;i++)
   {
           cin>>cost[i];
           for(int j=0;j<m;j++)
           {
                   cin>>v[i][j];
                   z[j]+=v[i][j];
                   if(i==n-1)
                   {
                           if(z[j]<k)
                           {
                                   done = 0;
                           }
                   }
           }
   }
   
   if(!done)
   {
     cout<<-1;
     return;
   }
 
  vll arr(m,0);   
   cout<<getAns(arr);
}
 
int main() {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
	    int t=1;
	    //cin>>t;
	    while(t--)
	    {
	            solve();
	    }
	    return 0;
}

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

int main() {
  int h1,m1,h2,m2,k;
  cin>>h1>>m1>>h2>>m2>>k;
  if(h1*60+m1<=h2*60+m2){
    cout<<(h2-h1)*60+(m2-m1)-k<<endl;
  }
  else{
    cout<<((h2+24)*60+m2)-(h1*60-m1)-k<<endl;
  }
}

Measured memory_bytes: 3620
//ll _(){
//    string s;
//    cin >> s;
//    return sz(s)/2-count(all(s),'p');
//}
#include <iomanip>
#include <algorithm>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define all(v) (v).begin(), (v).end()
#define sz(v) ll(v.size())
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
ll _(){
    string s;
    cin >> s;
    return sz(s)/2-count(all(s),'p');
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        cout << _() << '\n';
}


Measured memory_bytes: 512
#include <bits/stdc++.h>	
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)
#define int long long

// random_device rd; mt19937 g(rd());    
                                        	
using namespace std;
using namespace __gnu_pbds;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}

template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
const int mod = (int)1e9 + 7;
const int N = (int)1e5 + 213;

int n, m;
int a[N];
int b[N];
int ans;
int pref[N];

int get(int x)
{
	int j = 1;
	int cnt = 0;
	for(int i = 1; i <= n; i++)
	{
		while(j <= n && a[i] + b[j] >= x) j++;
		cnt += j - 1;
	}
	return cnt;
}

main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();
	cin >> n >> m;
	for(int i = 1; i <= n; i++) cin >> a[i], b[i] = a[i];
	sort(a + 1, a + n + 1);
	sort(b + 1, b + n + 1);
	reverse(b + 1, b + n + 1);
	int l = 0, r = 200002;
	while(l + 1 < r)
	{
		int mid = (l + r) / 2;
		if(get(mid) >= m) l = mid;
		else r = mid;
	}
	for(int i = 1; i <= n; i++) pref[i] = pref[i - 1] + b[i];
	int j = 1;
	int cnt = 0;
	for(int i = 1; i <= n; i++)
	{
		while(j <= n && a[i] + b[j] > l) j++;
		cnt += j - 1;
		ans += pref[j - 1] + a[i] * (j - 1);
	}
	ans += (m - cnt) * l;
	cout << ans << endl;
}      

Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

public class Main {
  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out)) {
          String[] s = in.readLine().split(" ");
          int n = Integer.parseInt(s[0]);
          int k = Integer.parseInt(s[1]);

          String line = in.readLine();
          int[] a = new int[n];
          char regex = ' ';
          boolean isContinue = true;
          for(int i=0, offset=0,next=0; isContinue; i++, offset = ++next) {
            if((next = line.indexOf(regex,offset)) == -1) {
              next = line.length();
              isContinue = false;
            }
            a[i] = Integer.parseInt(line.substring(offset,next));
          }

          List<Long> list = new ArrayList<>();
          for(int i=0; i<n; i++) {
            long sum = 0;
            for(int j=i; j<n; j++) {
              sum += (long)a[j];
              list.add(sum);
            }
          }
          list.sort(Comparator.reverseOrder());

          long ans = 0;
          for(int i=62;i>=0;--i) {
            long b = 1L << i;
            int cnt = 0;
            for(long v: list) {
              if( (v&b) > 0 )
                ++cnt;
              if(cnt == k) {
                ans |= b;
                list.removeIf(e -> (e&b) == 0);
                break;
              }
            }
          }

          System.out.println(ans);
      }
      catch(IOException e) {
        System.err.println(e);
      }
  }
}

Measured memory_bytes: 50836
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define debug(x) cerr<<#x<<" = "<<x
#define sp <<"  "
#define el <<endl
#define fgx cerr<<" ---------------------------------------------- "<<endl
#define uint unsigned int 
#define ULL unsigned long long
#define LDB long double
#define DB double
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
inline LL read(){
	LL nm=0; bool fh=true; char cw=getchar();
	for(;!isdigit(cw);cw=getchar()) fh^=(cw=='-');
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return fh?nm:-nm;
}

#define mod 998244353
namespace  CALC{
	inline int add(int x,int y){return (x+y>=mod)?(x+y-mod):(x+y);}
	inline int mns(int x,int y){return (x-y<0)?(x-y+mod):(x-y);}
	inline int mul(int x,int y){return (LL)x*(LL)y%mod;}
	inline void upd(int &x,int y){x+=y;(x>=mod)?(x-=mod):0;}
	inline void dec(int &x,int y){x-=y;(x<0)?(x+=mod):0;}
	inline int qpow(int x,int sq){int res=1;for(;sq;sq>>=1,x=mul(x,x))if(sq&1)res=mul(res,x);return res;}
}using namespace CALC;
#define M 400200
int n,K,S;
#define lim 1000000000
int main(){
	
	n=read(),K=read(),S=read();
	for(int i=1;i<=K;i++) printf("%d ",S);
	for(int i=K+1;i<=n;i++) printf("%d ",(S)%lim+1);
	puts("");
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;
 
template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)
 
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;
  

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i,N) cin >> d[i];
    sort(begin(d), end(d), greater<int>());

    int res = 1;
    rep(i,N-1) {
        if (d[i] > d[i+1]) res += 1;
    }

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


Measured memory_bytes: 256
/*
  In the name of ALLAH
  Author : Raashid Anwar
*/

#include <bits/stdc++.h>
using namespace std;
 
#define int int64_t
const int M1 =  998244353;
const int M2 =  1000000007;
mt19937 rng((uint64_t)chrono::steady_clock::now().time_since_epoch().count());

int cnt[1000001];
 
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, g = 0;
  cin >> n;
  for(int i = 0; i < n; i++) {
    int x;
    cin >> x;
    cnt[x]++;
    g = __gcd(g, x);
  }
  bool ok = true;
  for(int i = 2; i <= 1000000; i++) {
    int x = 0;
    for(int j = i; j <= 1000000; j += i)
      x += cnt[j];
    if(x > 1) {
      ok = false;
      break;
    }
  }
  if(ok)
    cout << "pairwise coprime\n";
  else if(!ok && g == 1)
    cout << "setwise coprime\n";
  else
    cout << "not coprime\n";
}

Measured memory_bytes: 11468
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 2 - 170;

int main() {
    ll N;
    cin >> N;
    for (ll n = 1; n <= 3500; ++n) {
        for (ll w = 1; w <= 3500; ++w) {
            if(4*n*w-N*w-N*n < 1) continue;
            if((N*n*w)%(4*n*w-N*w-N*n)) continue;
            cout << (N*n*w)/(4*n*w-N*w-N*n) << " " <<  n << " " << w << "\n";
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);
const double eps=1e-8;

ll n,x,ans,h,w;

int main(){
	cin>>n>>x;
	ans=n;
	h=n-x;
	w=x;
	while(1){
		if(h>w){
			if(h%w==0){
				ans+=(h/w*2-1)*w;
				break;
			}
			ans+=(h/w*2)*w;
			h%=w;
		}
		else if(h<w){
			if(w%h==0){
				ans+=(w/h*2-1)*h;
				break;
			}
			ans+=(w/h*2)*h;
			w%=h;
		}
		else{
			ans+=h;
			break;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define ull unsigned long long
#define si short int
#define ll long long
#define piii pair<pair<int, int>, int>
#define piiii pair<pair<int, int>, pair<int, int>>

/*-----------------------------------------------------MATH------------------------------------------------*/
inline ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

inline int pwm(ll xx, ll pow, int MD) {
    if (pow < 0) { pow = pow % (MD - 1) + MD - 1; }
    ll mlt = 1;
    while (pow) {
        if (pow & 1) {
            mlt *= xx;
            mlt %= MD;
        }
        xx *= xx;
        pow >>= 1;
        xx %= MD;
    }
    return (int) mlt;
}

inline ll gcdex(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll xx, yy;
    ll gc = gcdex(b, a % b, yy, xx);
    x = xx;
    y = yy - (a / b) * xx;
    return gc;
}

inline int inv(ll r, int _mod) { return pwm(r % _mod, _mod - 2, _mod); }

inline int64_t hilbertOrder(int x, int y, int pow, int rotate) {
    if (pow == 0) {
        return 0;
    }
    int hpow = 1 << (pow - 1);
    int seg = (x < hpow) ? (
            (y < hpow) ? 0 : 3
    ) : (
                      (y < hpow) ? 1 : 2
              );
    seg = (seg + rotate) & 3;
    const int rotateDelta[4] = {3, 0, 0, 1};
    int nx = x & (x ^ hpow), ny = y & (y ^ hpow);
    int nrot = (rotate + rotateDelta[seg]) & 3;
    int64_t subSquareSize = int64_t(1) << (2 * pow - 2);
    int64_t ans = seg * subSquareSize;
    int64_t add = hilbertOrder(nx, ny, pow - 1, nrot);
    ans += (seg == 1 || seg == 2) ? add : (subSquareSize - add - 1);
    return ans;
}

/*-----------------------------------------------------MATH------------------------------------------------*/
ll mod = 1e9 + 7;
vector<int> arr;
void solve() {
   int a,b;
   cin>>a>>b;
   if(a==b){
       for(int i=0;i<a;i++)cout<<a;
   }
   else{
       if(b>a) swap(a,b);
       for(int i=0;i<a;i++) cout<<b;
   }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);
    unsigned int beg_time = clock();

    int n = 1;
    for (int i = 0; i < n; i++) solve();


    unsigned int end_time = clock();
    //cout<<endl<<endl<<end_time-beg_time;

    return 0;
}

Measured memory_bytes: 256
while True:
    n,x=map(int,input().split())
    if n==x==0:
        break
    ans=0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            if(j<x-i-j<n+1):
                ans +=1
    print(ans)
    


Measured memory_bytes: 5596
#include<stdio.h>
#include<iostream>
#include<map>
using namespace std;

string S;
map<int, int> mp;
int main (){
    cin >> S;
    int N = S.length();
    int a[26];
    for( int i=0; i<N; i++){
        mp[S[i]-'a']++;
    }
    for(int i=0; i<26; i++){
        if (mp[i] == 0) {
            printf("%c\n",i+'a');
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
// const int mod=998244353;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0){
        c-=b;
        if(c<=0){
            cout<<"Yes"<<endl;
            return;
        }
        a-=d;
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int sp=0;
char s[1000];


bool is_cat(){
//  cout<<sp<<endl;
  if(s[sp]=='m'&&s[sp+1]=='e'&&s[sp+2]=='w'){
    sp+=3;
    return true;
  }
  if(s[sp]=='m'&&s[sp+1]=='e'){
    sp+=2;
    bool res=is_cat();
    if(res&&s[sp]=='w'){
      sp++;
      return true;
    }
  }
  else if(s[sp]=='m'){
    sp++;
    bool res=is_cat();
    if(res&&s[sp]=='e'&&s[sp+1]=='w'){
      sp+=2;
      return true;
    }
    else if(res&&s[sp]=='e'){
      sp++;
      res=is_cat();
      if(res&&s[sp]=='w'){
        sp++;
        return true;
      }
    }
  }
  return false;
}


int main(){
  cin>>s;
  bool res=is_cat();
//  cout<<sp<<endl;
  if(res&&s[sp]==0){
    cout<<"Cat"<<endl;
  }
  else{
    cout<<"Rabbit"<<endl;
  }

}



Measured memory_bytes: 3120
import java.util.Scanner;


public class Main {    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        double min = h * 60 + m;
        double ar = min * 0.5;
        double br = m * 6;
        double rad = Math.abs(ar - br);
        double cos = Math.cos(Math.toRadians(rad));
//        System.out.println(ar + "ar");
//        System.out.println(br + "br");
//        System.out.println(rad + "rad");
//        System.out.println(cos + "cos");
        double ans = a * a + b * b - (2 * a * b * cos); 
        System.out.println(Math.sqrt(ans));
        sc.close();
    }   
}


Measured memory_bytes: 35752
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>

using namespace std;

int main() {
    ios :: sync_with_stdio(false);
    int n, f[101][11], p[101][12], s[11];
    int i, j, k, m = -2147483647, sum, sumj;
    memset(f, 0, sizeof(f));
    memset(p, 0, sizeof(p));
    cin>>n;
    for(i=0; i<n; ++i) {
        for(j=0; j<10; ++j) {
            cin>>f[i][j];
        }
    }
    for(i=0; i<n; ++i) {
        for(j=0; j<11; ++j) {
            cin>>p[i][j];
        }
    }
    for(i=1; i<1024; ++i) {
        sum = 0;
        memset(s, 0, sizeof(s));
        for(j=0; j<10; ++j) {
            s[9-j] = (i>>j)&1;
        }
        for(j=0; j<n; ++j) {
            sumj = 0;
            for(k=0; k<10; ++k) {
                if(s[k]&f[j][k]) {
                    ++sumj;
                }
            }
            sum+=p[j][sumj];
        }
        if(m<sum) {
            m = sum;
        }
    }
    cout<<m;
    return 0;
}

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

int dir[4][2]={{-1,0},{0,1},{1,0},{0,-1}};
int w,h;

void goStraight(int *x,int *y,int d,int dist){
  *x += dir[d][1]*dist;
  *y += dir[d][0]*dist;

  if(*x<0) *x=0;
  if(*x>=w) *x=w-1;
  if(*y<0) *y=0;
  if(*y>=h) *y=h-1;
}

int changeDir(int d,int LR){
  if(LR==0){
    d--;
    if(d<0) d=3;
  }
  else{
    d++;
    if(d>3) d=0;
  }
  return d;
}

int main(void){
  int x,y,d,dist;
  char op[9];

  while(1){
    scanf("%d%d",&w,&h);
    if(!w && !h) break;

    x = y = 0;
    d = 2;
    while(1){
      scanf("%s",op);
      if(!strcmp(op,"STOP")) break;

      if(!strcmp(op,"FORWARD")){
	scanf("%d",&dist);
	goStraight(&x,&y,d,dist);
      }
      else if(!strcmp(op,"BACKWARD")){
	scanf("%d",&dist);
	goStraight(&x,&y,d,-dist);
      }
      else if(!strcmp(op,"RIGHT")){
	d = changeDir(d,0);
      }
      else{
	d = changeDir(d,1);
      }
    }
    printf("%d %d\n",x+1,y+1);
  }

  return 0;
}

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

typedef long long int ll;

int main()
{
  ll x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<ll> va(a); for(int i = 0; i < a; ++i) cin >> va[i];
  vector<ll> vb(b);  for(int i = 0; i < b; ++i) cin >> vb[i];
  vector<ll> vc(c);  for(int i = 0; i < c; ++i) cin >> vc[i];
  sort(va.begin(), va.end());
  sort(vb.begin(), vb.end());
  sort(vc.begin(), vc.end());
  
  vector<int> v;
  for(int i = max(0LL, a - x) ; i < a; ++i) vc.push_back(va[i]);
  for(int i = max(0LL, b - y) ; i < b; ++i) vc.push_back(vb[i]);
  sort(vc.begin(), vc.end(), greater<int>());
  ll total = 0;
  for(int i = 0 ; i < x + y; ++i) total += vc[i];
  cout << total;
  return 0;
}


Measured memory_bytes: 6256
#include<bits/stdc++.h>
using namespace std;
//define
typedef pair<int,int>pi;
#define int long long
#define elif else if
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define Rep(x,y) for(int k=x;k<y;k++)
#define all(x) x.begin(),x.end()
#define pb push_back
#define vint vector<int>
#define vvint vector<vector<int>>
#define vtr vector<string>
#define vvtr vector<vector<string>>
#define vhar vector<char>
#define vvhar vector<vector<char>>
#define mod 100000007
#define elif else if
#define str string

signed main(){
  int N,M,O,P=0,c=0,co=0,cou=0;
  double D,Do;
  char C,Ca;
  str S,T;
  cin>>N>>M;
  C=N+48;Ca=M+48;
  rep(0,max(C,Ca)-48){
    cout<<min(C,Ca);
  }
  cout<<endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt(), k = in.nextInt();

			if (n % k == 0) {
				out.println(0);
				return;
			} else {
				out.println(1);
			}

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

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

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 21460
import java.util.*;
public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
      
		if(a == 1){
			System.out.println("Hello World");
			return;
		}else if(a==2) {
          
		// スペース区切りの整数の入力
		int b = sc.nextInt();
		int c = sc.nextInt();

			System.out.println(b+c);
			return;

		}
	}
}

Measured memory_bytes: 23124
package main

import (
  "fmt"
)

func main() {
  var (
    s string
  )
  fmt.Scan(&s)

  l := len(s)
  ans := make([]int,l)

  for i:=0;i<l;i++ {
    flag := true
    for j:=i;j<l;j++ {
      //fmt.Println(s[j:j+1])
      if flag {
        if s[j:j+1] == "A" || s[j:j+1] == "T" || s[j:j+1] == "G" || s[j:j+1] == "C" {
          ans[i]++
          } else {
            flag = false
          }
      }
    }
  }

  max := ans[0]
  for i:=1;i<l;i++ {
    if max < ans[i] {
      max = ans[i]
    }
  }
  fmt.Println(max)
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
  	int n;
  	cin >> n;
  	if(n==25)
      	cout << "Christmas\n";
  	if(n==24)
      	cout << "Christmas Eve\n";
  	if(n==23)
      	cout << "Christmas Eve Eve\n";
  	if(n==22)
      	cout << "Christmas Eve Eve Eve\n";
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main():
    H, W = map(int, input().split())
    a = []
    for i in range(H):
        ai = list(map(int, input().split()))
        a.append(ai)
    ans = []
    for i in range(H):
        for j in range(W-1):
            if a[i][j] % 2 == 1:
                a[i][j] -= 1
                a[i][j+1] += 1
                ans.append((i+1, j+1, i+1, j+2))
    for i in range(H-1):
        if a[i][-1] % 2 == 1:
            a[i][-1] -= 1
            a[i+1][-1] += 1
            ans.append((i+1, W, i+2, W))
    N = len(ans)
    print(N)
    for ansi in ans:
        print(ansi[0], ansi[1], ansi[2], ansi[3])


if __name__ == '__main__': main()

Measured memory_bytes: 26680
#include <bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(x) (int)(x).size()
#define f(n) for(int i=0;i<n;++i)
#define f2(n) for(int j=0;j<n;++j)
#define f3(n) for(int k=0;k<n;++k)
#define F(i,x,n,y) for(int i=x;i<n;i+=y)
#define fa(x,y) for(auto x:y)
 
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
 
//Warsaw debug template
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1,debug&>::type operator<<(c i){
sim > struct rge {c b,e;};
sim > rge<c> range(c i, c j) {return rge<c>{i,j};}
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug{
#ifdef LOCAL
~debug() {cerr<<endl; }
eni(!=) cerr<< boolalpha << i; ris;}
eni(==) ris <<range(begin(i),end(i)); }
sim, class b dor(pair<b,c> d){
ris<<"("<<d.first<<","<<d.second<<")";
}
sim dor(rge<c> d){
    *this << "[";
    for(auto it=d.b;it!=d.e;++it)
        *this <<"," +(it==d.b)<< *it;
    ris<<"]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) "["<<#__VA_ARGS__":"<<(__VA_ARGS__)<<"]"
//End of debug template
#define isOn(S, j) (S & (1<<j))
#define setBit(S, j) (S | (1<<j))
#define clearBit(S, j) (S & ~(1<<j))
#define toggleBit(S, j) (S ^ (1<<j))
#define lowBit(S) (S & (-S))
typedef vector<ll> vll;

int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    ll n,k;
    cin>>n>>k;
    long double ans=0;
    for (int i =1; i<=n; i++){
        ll steps=0;
        ll c=i;
        while(c<k){
            ++steps;
            c<<=1;
        }
        ans+=(1.0/(double)n)*pow(0.5,steps);
        //debug()<<imie(pow(0.5,steps))<<imie(ans);
    }
    cout<<setprecision(20)<<ans<<endl;
    return 0;
}
    


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

using ll = long long;
using namespace std;
constexpr ll inf = 1e15;
constexpr ll mod = 1e9+7;

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

    ll N, K;
    cin>>N>>K;
    map<ll, ll> AB;
    for (int n = 0; n < N; n++) {
        int A, B;
        cin>>A>>B;
        if (AB.count(A) == 0) AB[A] = B;
        else AB[A] += B;
    }

    for (auto ab : AB) {
        if (K - ab.second <= 0) {
            cout<<ab.first<<endl;
            return 0;
        } else K -= ab.second;
    }
    return 0;
}

Measured memory_bytes: 4224
import math

n, d = [int(i) for i in input().split()]
lst = []
ret = 0
for i in range(n):
	now = [int(j) for j in input().split()]
	for l in lst:
		sum = 0
		for j in range(d):
			sum += pow(l[j] - now[j], 2)
		if math.sqrt(sum) - int(math.sqrt(sum)) == 0.0:
			ret += 1
	lst.append(now)
print (ret)

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

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

const lines = [];

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

reader.on("close", () => {
  const [n, q] = lines[0].split(" ").map(Number);
  const processes = [];
  for (let i = 1; i <= n; i++) {
    const [name, time] = lines[i].split(" ");
    processes.push([name, time - 0]);
  }

  let processedTime = 0;
  while (processes.length > 0) {
    const [name, time] = processes.shift();
    const processingTime = Math.min(time, q);
    processedTime += processingTime;
    const nextTime = time - processingTime;
    if (nextTime > 0) {
      processes.push([name, nextTime]);
    } else {
      console.log(`${name} ${processedTime}`);
    }
  }
});



Measured memory_bytes: 67424
#include<iostream>
using namespace std;
int main()
{
	string a;
	cin>>a;
	int ans=0;
	int p=a.size()-1;
	for(int i=0;i<a.size()/2;i++)
	{
		if(p==i)
		{
			break;
		}
		if(a[i]!=a[p])
		{
			ans++;
		}
		p--;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pll;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int k;
    string s;
    cin >> k >> s;
    if(s.size() <= k)
        cout << s;
    else
        cout << s.substr(0, k) << "...";
    return 0;
}


Measured memory_bytes: 3652
import java.util.Scanner;

/**
 *
 * @author cs18097
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        int high = 0;
        int[] poyo = new int[n];
        poyo[0] = sc.nextInt();
        for(int i = 1;i < n;i++){
            poyo[i] = sc.nextInt();
        }
        for(int i = n-1;i > 1;i--){
            if(poyo[i] < poyo[i-1])poyo[i-1]--;
        }
        for(int i = 1;i < n;i++){
            if(poyo[i-1]>poyo[i]){
                System.out.print("No");
                return;
            }
        }
        System.out.print("Yes");
    }
    
}


Measured memory_bytes: 49992
#include<bits/stdc++.h>
const int m= 998244353;
using namespace std;
long long  st[(int)1e6];
long long get(int n){
    long long x=0;
    while(n>0){
        x+=st[n];
        n-=n&(-n);
    }
    return x;
}
void update(int i,int x){
    while(i<1e6){
        st[i]+=x;
        i+=i&(-i);
    }
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);

    memset(st,0,sizeof(st));
    long long n,k,a,b;
    cin>>n>>k;
    set<pair<int,int>> s;
    while(k--){
        cin>>a>>b;
        s.insert({a,b});
    }
    update(1,1);
    long long r=0;
    for(int i=2;i<=n;i++){
        r=0;
        for(auto x:s){
            r+=get(i-x.first)-get(i-x.second-1);
            r%=m;
        }
        update(i,r);
    }
            
    cout<<r;
}


Measured memory_bytes: 11440
import java.io.*;

public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
            String line = reader.readLine();
            String[] num = line.split(" ", -1);
            int a = Integer.parseInt(num[0]);
            int b = Integer.parseInt(num[1]);
            int c = Integer.parseInt(num[2]);
            if(a < b && b < c) {
                System.out.println("Yes");
            }else {
                System.out.println("No");
            }
        } catch (IOException e) {
            System.out.println(e);
        } catch (NumberFormatException e) {
            System.out.println("error");
        }
    }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
//#define int long long

signed main(){
    int N, M;
    cin >> N >> M;
    cout << N*(N-1)/2+M*(M-1)/2 << endl;
}

Measured memory_bytes: 256
// D - An Ordinary Game

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const int MOD = 1e9 + 7;

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

	bool c1 = (s.size() % 2 == 0);
	bool c2 = (s[0] == s[s.size() - 1]);

	string ans;
	if (c1 == c2) ans = "First";
	else ans = "Second";

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  int q = in();
  set<int> s;
  rep(_,q){
    int kind = in();
    if(kind==0){
      int add = in();
      s.emplace(add);
      cout << s.size() << endl;
    }else if(kind==1){
      int x = in();
      cout << s.count(x) << endl;
    }else if(kind==2){
      int x = in();
      s.erase(x);
    }else{
      int x = in();
      int y = in();
      auto from = s.lower_bound(x);
      auto end = s.upper_bound(y);
      while(from!=end){
        cout << *from << endl;
        ++from;
      }
    }
  }
}



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

int main() {
    long long a, b, x;
    cin >> a >> b >> x;
    if (a == b) {
        if (b % x == 0) {
            cout << 1 << endl;
            return 0;
        }
    }
    long long tmpa, tmpb;
    if (a % x == 0) {
        tmpa = a / x;
    } else {
        tmpa = a / x + 1;
    }
    if (tmpa > b / x) {
        cout << 0 << endl;
        return 0;
    }
    if (tmpa == b / x) {
        cout << 1 << endl;
        return 0;
    }
    cout << b / x - tmpa + 1 << endl;
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    int min_divide = 1e9;
    for(int i = 0; i < N; i++){
        int num;
        cin >> num;
        int count = 0;
        while(num % 2 == 0){
            num /= 2;
            count++;
        }
        min_divide = min(min_divide, count);
    }
    cout << min_divide << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def solve(inp):
    (A, B, M) = map(int, inp.readline().strip().split(' '))
    A = list(map(int, inp.readline().strip().split(' ')))
    B = list(map(int, inp.readline().strip().split(' ')))
    XYC = [map(int, inp.readline().strip().split(' ')) for i in range(M)]

    r = min(A) + min(B)
    for x, y, c in XYC:
        r = min(r, A[x - 1] + B[y - 1] - c)

    return str(r)


def main():
    import sys
    result = solve(sys.stdin)
    if result is not None and result != '':
        print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62376
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;

typedef pair<int,int> pii;
const int MAXN=805;
const int INF=0x3f3f3f3f;
#define x first
#define y second

int n,m,K,ans=INF;
int vis[MAXN][MAXN];
char s[MAXN][MAXN];
pii S;
int df[4][2]={{0,-1},{0,1},{-1,0},{1,0}};

int f(int x,int y){
    int len=min(min(x-1,y-1),min(n-x,m-y));
    return len/K+((len%K)?1:0);
}

queue <pii> q;
void bfs(){
    memset(vis,0,sizeof vis);
    q.push(S);
    vis[S.x][S.y]=1;
    while(!q.empty()){
        pii now=q.front(); q.pop();
        ans=min(ans,f(now.x,now.y));
        for(int i=0;i<4;i++){
            int nx=now.x+df[i][0];
            int ny=now.y+df[i][1];
            if(nx<1||ny<1||nx>n||ny>m||vis[nx][ny]||abs(nx-S.x)+abs(ny-S.y)>K||s[nx][ny]=='#') continue;
            vis[nx][ny]=1;
            q.push(make_pair(nx,ny));
        }
    }
}

int main(){

    scanf("%d%d%d",&n,&m,&K);
    for(int i=1;i<=n;i++){
        scanf("%s",s[i]+1);
        for(int j=1;j<=m;j++)
            if(s[i][j]=='S') S.x=i,S.y=j;
    }
    if(S.x==1||S.x==n||S.y==1||S.y==m) return puts("0"),0;
    bfs();
    printf("%d",ans+1);

    fclose(stdin);
    fclose(stdout);
}


Measured memory_bytes: 3580
#include<map>
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
	int i;
	map<int,int> mp;
	while(cin>>i){
		if(!mp.count(i))	mp.insert(make_pair(i,0));
		else				mp.find(i)->second++;
	}

	int vmax=-1e9;
	map<int,int>::iterator it;
	for(it=mp.begin();it!=mp.end();it++)vmax=max(vmax,it->second);
	for(it=mp.begin();it!=mp.end();it++)if(it->second==vmax)printf("%d\n",it->first);

	return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python

nm = [int(i) for i in input().split()]
n = nm[0]
m = nm[1]

a = list()
b = list()
c = list()
d = list()

for i in range(n):
    ab = [int(tmp) for tmp in input().split()]
    a.append(ab[0])
    b.append(ab[1])

for j in range(m):
    cd = [int(tmp) for tmp in input().split()]
    c.append(cd[0])
    d.append(cd[1])

for i in range(n):
    min_dist = abs(a[i]-c[0]) + abs(b[i]-d[0])
    checkpoint = 1
    for j in range(m):
        cur_dist = abs(a[i]-c[j]) + abs(b[i]-d[j])
        if min_dist > cur_dist:
            min_dist = cur_dist
            checkpoint = j + 1
    print(checkpoint)

Measured memory_bytes: 3064
#include <cstring>
#include <iostream>

using namespace std;

#define MAX_N 5000
#define INF 0x3f3f3f3f3f3f3f3f

long dp[MAX_N + 1][MAX_N + 1];
int x0[MAX_N + 1], P[MAX_N];

long rotation_sort( int N, int A, int B )
{
    for ( int i = 0; i < N; i++ ) x0[P[i]] = i;

    memset( dp, INF, sizeof( dp ) );
    memset( dp[0], 0, sizeof( dp[0] ) );

    for ( int k = 1; k <= N; k++ )
    {
        long min_prev = INF;

        for ( int x = 0; x <= N; x++ )
        {
            int cost;
            if ( x == x0[k] )
                cost = 0;
            else if ( x < x0[k] )
                cost = B;
            else
                cost = A;

            min_prev = min( min_prev, dp[k - 1][x] );
            dp[k][x] = min_prev + cost;
        }
    }

    long ans = INF;
    for ( auto v : dp[N] ) ans = min( ans, v );

    return ans;
}

int main( int argc, char **argv )
{
    long N, A, B;
    cin >> N >> A >> B;

    for ( int i = 0; i < N; i++ ) cin >> P[i];

    cout << rotation_sort( N, A, B ) << endl;

    return 0;
}


Measured memory_bytes: 195712
I = lambda s:map(int, s)

p = int(input().split()[1])
s = input()
if 10 % p == 0:
  r = sum(i for i, x in enumerate(I(s), 1) if x % p == 0)
else:
  d = [1] + [0] * (p - 1)
  t, y = 0, 1
  for i, x in enumerate(I(reversed(s)), 1):
    t = (t + x * y) % p
    d[t] += 1
    y = y * 10 % p;
  r = sum(i * (i - 1) // 2 for i in d)
print(r)


Measured memory_bytes: 3500