akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()

class RollingHash(object):
    _base1, _base2 = 1007, 1009
    _mod1, _mod2 = 10 ** 9 + 9, 10 ** 9 + 7

    def __init__(self,s):
        self._n=len(s)
        H1, H2 = [0] * (self._n + 1), [0] * (self._n + 1)
        P1, P2 = [1] * (self._n + 1), [1] * (self._n + 1)
        for i in range(self._n):
            H1[i + 1] = (H1[i] * self._base1 + ord(s[i])) % self._mod1
            H2[i + 1] = (H2[i] * self._base2 + ord(s[i])) % self._mod2
            P1[i + 1] = P1[i] * self._base1 % self._mod1
            P2[i + 1] = P2[i] * self._base2 % self._mod2
        self._H1, self._H2 = H1, H2
        self._P1, self._P2 = P1, P2

    def __len__(self):
        return self._n

    def __getitem__(self,x):
        l, r = x.start, x.stop;
        return ((self._H1[r] - self._P1[r - l] * self._H1[l] % self._mod1) % self._mod1,
                (self._H2[r] - self._P2[r - l] * self._H2[l] % self._mod2) % self._mod2)

from collections import defaultdict
def resolve():
    n=int(input())
    S=input()
    rh=RollingHash(S)

    def check(k):
        D=defaultdict(lambda:-1)
        for i in range(n-k+1):
            h=rh[i:i+k]
            if(D[h]!=-1):
                if(i-D[h]>=k): return True
            else:
                D[h]=i
        return False

    left = 0
    right = n
    while right - left > 1:
        mid = (left + right) // 2
        if check(mid):
            left = mid
        else:
            right = mid
    print(left)
resolve()

Measured memory_bytes: 43120
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll dp[MAX+5][2][2],n;
ll recur(int pos,int x,int y)
{

    if(pos==n)
    {
        if(x && y)
            return 1;
        return 0;
    }
    ll &ret=dp[pos][x][y];
    if(~ret)
        return ret;
    ret=0;
    for(int i=0; i<10; i++)
    {
        ret+=recur(pos+1,x|(i==0),y|(i==9));
        ret%=MOD;
    }
    return ret;
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    cin>>n;
    memset(dp,-1,sizeof(dp));
    cout<<recur(0,0,0)<<endl;

    return 0;
}


Measured memory_bytes: 97240
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 100'000;

int n, m, k;

void solve(int test)
{
  string s;
  cin >> s;
  n = (int)s.size();
  int64 ans = 0;
  int b = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'B')
      ++b;
    else
      ans += b;
  }
  cout << ans;
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
      solve(i);
  //cout << endl << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count();
  return 0;
}


Measured memory_bytes: 1356
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
    int n,m;
  while(1){
   cin>>n>>m;
   if(n==0||m==0)return 0;
   V<ll> a(n),b(m);
   ll asum=0,bsum=0;
   for(int i=0;i<n;i++){cin>>a[i];asum+=a[i];}
   for(int i=0;i<m;i++){cin>>b[i];bsum+=b[i];}
   ll sum=inf;
   int l,r;
   for(int i=0;i<n;i++){
       for(int j=0;j<m;j++){
           ll u=asum-a[i]+b[j],v=bsum-b[j]+a[i];
           if(u==v&&sum>u){
               sum=u;
               l=a[i];r=b[j];
           }
       }
   }
  if(sum==inf)cout<<-1<<endl;
  else cout<<l<<" "<<r<<endl;
  }
}


Measured memory_bytes: 3144
//#pragma GCC optimize(3)
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<utility>
#include<iterator>
#include<iomanip>
using namespace std;
#define lowbit(x) x&(-x)
typedef long long ll;
typedef long double lb;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const int maxn = 5005;
int bit[maxn];
int read();
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    int d = a-b;
    int res = c -d;
    if(res>0)
    {
    	cout<<res<<endl;
    }else
    {
    	cout<<0<<endl;
    }



    return 0;
}
inline int read()
{
	int x = 0,w = 0;
	char ch = 0;
	while(!isdigit(ch)){
		w |= (ch == '-');
		ch = getchar();
	}
	while(isdigit(ch)){
		x = (x<<3)+(x<<1)+(ch^48);
		ch = getchar();
	}
	return w?-x:x;
}


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

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int n=fsc.nextInt();
        long[] s=new long[n];
        for(int i=0;i<n;i++) s[i]=fsc.nextLong();
        fsc.close();
        long max=0;
        for(int step=1;step<n-1;step++){
            int f=0, b=n-1;
            long score=0;
            while(f<n-1 && b>0 && !(b%step==0 && b<=f)){
                score+=s[f]+s[b];
                if(score>max && b-step>0){
                    max=score;
                }
                f+=step; b-=step;
            }
        }
        System.out.println(max);
    }
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte(){
        if(ptr<buflen) return true;
        else{
            ptr = 0;
            try{
                buflen = in.read(buffer);
            }
            catch(IOException e){
                e.printStackTrace();
            }
            if(buflen<=0) return false;
        }
    return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) throw new NumberFormatException();
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }
            else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
            else throw new NumberFormatException();
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
    public void close(){
        try{in.close();}
        catch(IOException e){e.printStackTrace();}
    }
}

Measured memory_bytes: 24752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int a;
  string s;
  cin >> a >> s;
  if (a >= 3200) cout << s << endl;
  else cout << "red" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define fi first
#define se second
#define UP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define UU(a,b,c) for(ll (a)=(b);(a)<=(c);(a)++)
#define DN(a,b,c) for(ll (a)=(b);(a)>(c);(a)--)
#define DU(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)

ll a, b, c, d;

void reset()
{
}

void input()
{
	cin>>a>>b>>c>>d;
	
}

void solve()
{
	cout<<max(max(a * c, b * c), max(a * d, b * d))<<endl;
}

void LetsRock()
{
	solve();
}

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
		reset();
		input();
		LetsRock();
	
	return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
int main() {
	int data[100] , length;
	int i;
	scanf("%d" , &length);
	for(i = 0; i < length; i++) {
		scanf("%d" , &data[i]);
	}
	for(i = length - 1; i >= 0; i--) {
		printf("%d" , data[i]);
		if (i > 0) printf(" ");
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
using System;

namespace ABC176.Problems
{
    class B
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            string str = Console.ReadLine();

            long sum = 0;
            foreach (var c in str)
            {
                sum += c - '0';
            }

            Console.WriteLine(sum % 9 == 0 ? "Yes" : "No");

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 26392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

template<class T> inline bool chmin(T &a,T b){
    if (a>b){a=b; return true;}
    return false;
}
template<class T> inline bool chmax(T &a,T b){
    if (a<b){a=b; return true;}
    return false;
}

//Be careful MOD=1e9+7
const int MAX = 510000;
vector<ll> fac(MAX),finv(MAX),inv(MAX);
void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    rep2(i,2,MAX){
        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 COM(int n,int k){
    if (n<k) return 0;
    if (n<0||k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K; cin >> N >> K;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    sort(all(A));
    COMinit();
    ll ans=0;
    rep(i,N){
        ans=(ans+A[i]*COM(i,K-1)%MOD+3*MOD)%MOD;
        ans=(ans-A[i]*COM(N-i-1,K-1)%MOD+3*MOD)%MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 13056
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using VI = vector<int>;
using VB = vector<bool>;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;

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

ll lcm(ll a, ll b)
{
  return a * b / gcd(a, b);
}
int main()
{
  ll a, b;
  cin >> a >> b;
  cout << lcm(a, b) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#define ll long long
using namespace std;
int n,m,k;
int main(){
	scanf("%d%d",&n,&m);
	k=m/n;
	for(int i=k;i>=1;i--){
		if((m-i*n)%i==0){
			printf("%d\n",i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

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

void solve() {
    string s;
    cin >> s;
    cout << s.substr(0, 3) << endl;
}

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



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

using namespace std;
int s,k;
int main()
{
    while (~scanf("%d%d",&k,&s))
    {
        long long ans=0;
            for (int i=0;i<=k;++i){
                for (int j=0;j<=k;++j){
                    if ((s-i-j)<=k&&(s-i-j)>=0)
                        ans++;
                }
            }
        printf("%lld\n",ans);
    }
    return 0;
}


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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        long a = 1000000000000001L;
        long n = in.nl();
        StringBuilder sb = new StringBuilder();
        long k = 0;
        while(n*25 > (Math.pow(26, k)-1)*26) k++;
        n -= (Math.pow(26, k-1)-1)/25*26+1;
        for (int i = 0; i < k; i++) {
            sb.append((char)(n%26+'a'));
            n /= 26;
        }
        out.println(sb.reverse());
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 33052
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

void judge(int a, int b, int c) {
	(b - a) == (c - b) ? printf("YES\n") : printf("NO\n");
}


int main(void)
{
	int a, b, c;

	scanf("%d %d %d", &a, &b, &c);
	judge(a, b, c);

	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

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

    int ans = 0;
    rep(i,1,k){
	rep(j,i+1,k+1){
	    ans++;
	    j++;
	}
    }
    P(ans);
    return  0;
}


Measured memory_bytes: 256
n, w = gets.split.map &:to_i

wv = Array.new(n){ gets.split.map &:to_i }

V_MAX = wv.map{ |x| x[1] }.inject(:+)

# index値の価値を達成するのに必要な最低重量
weights = Array.new(V_MAX + 1, Float::INFINITY)

s_v = 0
s_w = 0

(1..n).each.with_index(0){ |nn, i| 
	temp_w = wv[i][0]
	temp_v = wv[i][1]

	s_v += temp_v
	s_w += temp_w

	s_v.downto(temp_v + 1).each{ |vv|
		temp = weights[vv - temp_v] + temp_w
		if weights[vv] > temp then
			weights[vv] = temp
		end
	}
	
	temp_v.downto(0).each{ |vv|
		if weights[vv] > temp_w then
			weights[vv] = temp_w
		end
	}
}

index = weights.bsearch_index{ |x| x > w}

if index == nil then
	puts weights.size - 1
else
	puts index -1
end


Measured memory_bytes: 2556
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

int l , r;

int main(){
    cin >> l >> r;
    int mnn = 2e9;
    for(int i = l; i <= min(l+2019 , r); i++){
        for(int j = max(i + 1 , (l , r - 2019)); j <= r; j++){
            mnn = min(1ll*mnn , (1ll*i*j) % 2019);
        }
    }
    for(int i = l; i <= min(l+2019 , r); i++){
        for(int j = i+1; j <= min(i+2019 , r); j++){
            mnn = min(1ll*mnn , (1ll*i*j) % 2019);
        }
    }
    for(int i = max(l , r - 2019); i <= r; i++){
        for(int j = i+1; j <= min(i+2019 , r); j++){
            mnn = min(1ll*mnn , (1ll*i*j) % 2019);
        }
    }
    cout << mnn << endl;
}

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

int main(){
  int N, k;
  cin >> N;
  for (int i = 0;i<N;i++){
    int j = 0;
    int a;
    cin >> a;
    while(!(a%2)){
      j++;
      a/=2;
    }
    if(!i){
      k=j;
    }
    else{
      k = (k<=j)*k+(k>j)*j;
    }
  }
  cout << k << endl;
  return 0;
}


Measured memory_bytes: 256
n, m, r = gets.strip.split.map(&:to_i)
r = gets.strip.split.map(&:to_i)
abc = readlines.map {|line| line.strip.split.map(&:to_i) }
 
roads = Array.new(n+1) { [10**8]*(n+1) }
 
abc.each do |a, b, c|
  roads[a][b]=c
  roads[b][a]=c
end 
 
(n+1).times do |via|
  (n+1).times do |s|
    s_via = roads[s][via]
    (n+1).times do |g|
      via_center = s_via + roads[via][g]
      roads[g][s] = roads[s][g] = via_center if roads[s][g] > via_center
    end
  end
end

def recursive_roads_check(current, cost, remains, roads)
  return cost if remains.empty?

  remains.map {|next_town|
    next_remains = remains.dup - [next_town]
    next_cost = 0
    next_cost = cost + roads[current][next_town] if current
    recursive_roads_check(next_town, next_cost, next_remains, roads)
  }.min
end

#roads.each {|r|p r}

p recursive_roads_check(nil, 0, r, roads)



Measured memory_bytes: 6140
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s, i##_len=(n); i < i##_len; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
typedef long long ll;
const int MOD = 1000000007;
using namespace std;

int main(){
    string s, t; cin >> s >> t;
    sort(ALL(s)); sort(ALL(t), greater<char>());
    cout << (s < t ? "Yes\n" : "No\n");
    return 0;
}


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

ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            a = L[i]
            b = L[j]
            c = L[k]
            if a == b or b == c or c == a:
                continue
            if abs(b-c) < a and a < b + c:
                ans += 1

print(ans)

Measured memory_bytes: 73964
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#include <math.h>

int main() {

	long long A,B,C,K;
	long long ans;
	ans = 0;
	cin >> A >> B >> C >>K;

	if (K <= A) {
		ans = K;
	}
	else if (K <= A+B){
		ans = A;
	}
	else {
		ans = A - (K - A - B);
	}

	cout << ans << endl;

	cin >> A;

	return 0;


}

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

int main()
{
    ll n, k;
    cin >> n >> k;
    bool vis[n + 1] = {0};
    ll arr[n + 2];
    vector<ll> vec;
    for (int i = 1; i < n + 1; i++)
        cin >> arr[i];
    int i = 1, j;
    int count = 0;
    vec.push_back(0);
    while (!vis[i])
    {

        vec.push_back(i);
        vis[i] = 1;
        i = arr[i];
        // cout << "ejdks"
        //    << "\n";
    }
    // vec.push_back(i);
    //  for (int j = 0; j < vec.size(); j++)
    //    cout << vec[j] << " ";
    if (k < vec.size() - 1)
    {
        // cout << "sdjck"
        //    << "\n";
        cout << vec[k + 1];
        return 0;
    }
    vector<ll> vec1;
    for (int j = 1; j < vec.size(); j++)
        vec1.push_back(vec[j]);

    for (j = 0; j < vec1.size(); j++)
        if (vec1[j] == i)
            break;
    // if (k <= j)
    // {
    //     cout << vec[k];
    //     return 0;
    // }
    k -= j;
    ll p = vec1.size() - j;
    ll k1 = k % p;
    cout << vec1[k1 + j];

    return 0;
}

Measured memory_bytes: 9472
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int i;
    int n;
    int j = 0;
    int a[202];
    int b[202];
    vector<int> t1(1000010, 0),t2(1000010, 0);
    for(i = 0; i < 200; i++){
        a[i] = (i+1)*(i+2)*(i+3)/6;
        if(a[i] % 2 == 1){
            b[j] = a[i];
            j++;
        }
    }
    /*cout << a[82] << b[20] << endl;
    for(i = 0; i < 200; i++){
        cout << "a[" << i << "] = " << a[i] << endl;
    }
    for(i = 0; i < 200; i++){
        cout << "b[" << i << "] = " << b[i] << endl;
    }*/

        for(i = 0; i <= 1000005; i++){
            t1[i] = i;
        }

        for(i = 0; i <= 179; i++){
            for(j = a[i]; j <= 1000005; j++){
                if(t1[j] > t1[j - a[i]] + 1){
                    t1[j] = t1[j -a[i]] + 1;
                }
            }    
        }        

        for(i = 0; i <= 1000005; i++){
            t2[i] = i;
        }
        
        for(i = 0; i <= 44; i++){
            for(j = b[i]; j <= 1000005; j++){
                if(t2[j] > t2[j - b[i]] + 1){
                    t2[j] = t2[j - b[i]] + 1;
                }
            }
        }
            


    while(1){
        cin >> n;
        if(n == 0){
            break;
        }
        cout << t1[n] << " " << t2[n] << endl;
    }
    return 0;
}

Measured memory_bytes: 10508
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define int long long
#define INF 1000000000000000000
using namespace std;

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
template<typename T>
void debug(vector<vector<T>> m){ REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;} }

//追加クエリの傾きは広義単調減少と仮定
class CHT
{
public:
    vector<Pii> lines;

    int f(int i, int x){
        return lines[i].first * x + lines[i].second;
    }

    //f2を取り除いて良いか
    bool check(Pii l1, Pii l2, Pii l3){
        return (l1.first - l2.first) * (l2.second - l3.second) >= (l2.first - l3.first) * (l1.second - l2.second);
    }

    void add(int a, int b){
        Pii tmp = Pii(a, b);
        while(lines.size() >= 2 && check(lines[lines.size() - 2], lines[lines.size() - 1], tmp))
            lines.pop_back();
        //傾き等しく切片がでかいやつが来る可能性があるとき
        //if(!(lines.size() >= 1 && tmp >= lines[lines.size() - 1]))
        lines.push_back(tmp);
    }

    int get(int x){
        int i1 = -1, i2 = lines.size() - 1;
        while(i2 - i1 > 1){
            int i = (i1 + i2) / 2;
            if(f(i, x) < f(i + 1, x)) i2 = i;
            else i1 = i;
        }
        return f(i2, x);
    }
};

signed main(){

    int N, C; cin >> N >> C;
    vec h(N);
    readv(h);
    vec dp(N);
    CHT cht;
    dp[0] = 0;
    FOR(i, 1, N){
        cht.add(-2 * h[i - 1], dp[i - 1] + h[i - 1] * h[i - 1] + C);
        dp[i] = cht.get(h[i]) + h[i] * h[i];
    }
    cout << dp[N - 1] << endl;

    return 0;
}


Measured memory_bytes: 9456
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<stack>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
using ll = long long;
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	int max = -100 * 100;
	max < (a + b) ? max = a + b : 0;
	max < (a - b) ? max = a - b : 0;
	max < (a * b) ? max = a * b : 0;
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import numpy as np
import copy
from collections import defaultdict, Counter
from itertools import product
from bisect import bisect_left, bisect_right
def inpl(): return list(map(int, input().split()))

A, B, C = map(int,input().split())

if B/A>=C:
    print(C)
else:
    print(B//A)

Measured memory_bytes: 21656
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

vector<int> erat(int n) {
    vector<int> primes(n);
    for (int i = 2; i < n; ++i) primes[i] = i;
    for (int i = 2; i*i < n; ++i)
        if (primes[i])
            for (int j = i*i; j < n; j+=i) primes[j] = 0;
    // ?´???°?????????vector???????´?????????´????????\?????????????????? (0 ??§??????????´??????¨??????)
    primes.erase(remove(primes.begin(), primes.end(), 0), primes.end());
    return primes;
}

int main() {
    vector<int> v = erat(55000);

    int n;
    while(cin >> n) {
        int d = lower_bound(v.begin(), v.end(), n) - v.begin();
        if(v[d] == n) printf("%d %d\n",v[d-1],v[d+1]);
        else printf("%d %d\n",v[d-1], v[d]);
    }
    return 0;
}

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

#define int long long
#define fi first
#define se second
#define pb push_back

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int oo = 1e18 + 7;
int n, a[200005], pref[200005];

int seg(int l, int r){ return pref[r] - pref[l - 1];}

signed main(){
	ios_base::sync_with_stdio(0);
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		pref[i] = pref[i - 1] + a[i];	
	}
	int ans = oo;
	for(int i = 3; i <= (n - 1); i++){
		int l = 1, r = i - 2;
		while(l < (r - 1)){
			int mid = (l + r) >> 1;
			if(seg(1, mid) <= seg(mid + 1, i - 1)) l = mid;
			else r = mid;
		}
		if(seg(1, r) <= seg(r + 1, i - 1)) l = r;
		int temp1 = seg(1, l), temp2 = seg(l + 1, i - 1), temp5 = temp1 + a[l + 1], temp6 = temp2 - a[l + 1];
		l = i, r = n - 1;
		while(l < (r - 1)){
			int mid = (l + r) >> 1;
			if(seg(i, mid) <= seg(mid + 1, n)) l = mid;
			else r = mid;
		}
		if(seg(i, r) <= seg(r + 1, n)) l = r;
		int temp3 = seg(i, l), temp4 = seg(l + 1, n), temp7 = temp3 + a[l + 1], temp8 = temp4 - a[l + 1];
		ans = min(ans, max(temp1, max(temp2, max(temp3, temp4))) - min(temp1, min(temp2, min(temp3, temp4))));
		ans = min(ans, max(temp1, max(temp2, max(temp7, temp8))) - min(temp1, min(temp2, min(temp7, temp8))));
		ans = min(ans, max(temp5, max(temp6, max(temp3, temp4))) - min(temp5, min(temp6, min(temp3, temp4))));
		ans = min(ans, max(temp5, max(temp6, max(temp7, temp8))) - min(temp5, min(temp6, min(temp7, temp8))));
		//cout << i << " " << temp1 << " " << temp2 << " " << temp3 << " " << temp4 << " " << temp5 << " " << temp6 << " " << temp7 << " " << temp8 << "\n";
		//ans = min(ans, max(temp1, max(temp2, max(temp3, temp4))) - min(temp1, min(temp2, min(temp3, temp4))));
	}
	cout << ans;
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int u[220000], v[220000];
signed main() {
    cin >> N;
    int ans = 0;
    reps(i, N) { ans += i * (N - i + 1); }
    rep(i, N - 1) {
        cin >> u[i] >> v[i];
        if (u[i] > v[i]) { swap(u[i], v[i]); }
        ans -= u[i] * (N - v[i] + 1);
    }
    cout << ans << endl;

}

Measured memory_bytes: 6756
#include<stdio.h>
#define MAX 500001
#define SENTINEL 2000000000

 int count=0;

 int merge(int S[],int left,int right,int mid){
         int n1,n2,i,L[MAX/2+2],R[MAX/2+2],j,k;
         n1=mid-left;
         n2=right-mid;
         for(i=0;i<n1;i++){L[i]=S[left+i];}
         for(i=0;i<n2;i++){R[i]=S[mid+i];}
         L[n1]=R[n2]=SENTINEL;
         i=0;
         j=0;
         for(k=left;k<right;k++){
                        count++;
                        if(L[i]<=R[j]){S[k]=L[i];
                                      i++;
                                      }
                        else {S[k]=R[j];
                              j++;
                              }
                        }
          }
                                   
                    

 int mergesort(int S[],int left,int right){
        if(right-left>1){
             int mid=(left+right)/2;
             mergesort(S,left,mid);
             mergesort(S,mid,right);
             merge(S,left,right,mid);
             }
        }

 int main(){
        int i,n;
        
        int S[MAX];
        scanf("%d",&n);
        for(i=0;i<n;i++){
                   scanf("%d",&S[i]);
                   }
        
        mergesort(S,0,n);
        for(i=0;i<n;i++){
                   printf("%d%c",S[i],(i==n-1)?'\n':' ');
                   }
        printf("%d\n",count);
        return 0;
        }




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

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }

    map<int,int> mp;
    for(int i=0;i<n;i++){
        if(mp.count(a[i])){
            mp[a[i]]++;
        }
        else{
            mp[a[i]]=0;
        }

    }

    for(auto &x:mp){
        int u=x.first;
        int k=2;
        while(u*k<=1000000){
            if(mp.count(u*k)){
                mp.erase(u*k);
            }

            k++;
        }

    }

    int ans=0;

    for(auto &x:mp){
        if(x.second){
            continue;
        }
        ans++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 13200
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

#define SWAP(type, a, b) do { type t = a; a = b; b = t; } while(0)

typedef struct {
    int key;
} Node;

typedef struct {
    Node *node;
    int size;
} Heap;

int getParent(int idx);
int getLeft(int idx);
int getRight(int idx);
bool isCorrectHeapIdx(int idx, int heapSize);
bool initialize(Heap *heap, int size);
void maxHeapify(Heap *heap, int idx);
void buildMaxHeap(Heap *heap);
void printHeap(Heap *heap);
void terminate(Heap *heap);

int getParent(int idx) {
    return idx / 2;
}

int getLeft(int idx) {
    return idx * 2;
}

int getRight(int idx) {
    return idx * 2 + 1;
}

bool isCorrectHeapIdx(int idx, int heapSize) {
    return idx <= heapSize && 1 <= idx;
}

bool initialize(Heap *heap, int size) {
    if((heap->node = malloc((size + 1) * sizeof(Node))) == NULL) {
        return false;
    }

    heap->size = size;
    return true;
}

void maxHeapify(Heap *heap, int idx) {
    int left = getLeft(idx);
    int right = getRight(idx);

    int maxIdx = idx;
    if(isCorrectHeapIdx(left, heap->size) && heap->node[maxIdx].key < heap->node[left].key) {
        maxIdx = left;
    } if(isCorrectHeapIdx(right, heap->size) && heap->node[maxIdx].key < heap->node[right].key) {
        maxIdx = right;
    }

    if(maxIdx != idx) {
        SWAP(int, heap->node[maxIdx].key, heap->node[idx].key);
        maxHeapify(heap, maxIdx);
    }
}

void buildMaxHeap(Heap *heap) {
    for(int i = getParent(heap->size); i >= 1; i--) {
        maxHeapify(heap, i);
    }
}

void printHeap(Heap *heap) {
    for(int i = 1; i <= heap->size; i++) {
        printf(" %d", heap->node[i].key);        
    }
    puts("");
}

void terminate(Heap *heap) {
    free(heap->node);
    heap->node = NULL;
    heap->size = 0;
}

int main(void) {
    int n;
    Heap heap;

    scanf("%d", &n);
    initialize(&heap, n);

    for(int i = 1; i <= n; i++) {
        scanf("%d", &heap.node[i].key);
    }

    buildMaxHeap(&heap);

    printHeap(&heap);

    terminate(&heap);
    return 0;
}


Measured memory_bytes: 3300
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll k,n,i,pre,sum=0,ans=0,ok=0,t;
char s[105];
int main()
{
	scanf("%s%lld",s,&k);
	n=strlen(s);
	pre=s[0];sum=1;
	for(i=1;i<n;i++)
	{
		if(s[i]!=pre)
		{
			ok=1;
			ans+=sum/2;
			if(t==0)t=sum;
			sum=0;
		}
		sum++;
		pre=s[i];
	}
	if(ok==0)printf("%lld\n",n*k/2);
	else
	{
		ans+=sum/2;
		ans*=k;
		if(t%2==1&&sum%2==1&&s[0]==s[n-1])ans+=k-1;
		printf("%lld\n",ans);
	}
	return 0;	
} 

Measured memory_bytes: 128
# from fractions import gcd
# from datetime import date, timedelta
# from heapq import*
# import math
from collections import defaultdict, Counter, deque
# import sys
# from bisect import *
# import itertools
# import copy
# sys.setrecursionlimit(10 ** 7)
# MOD = 10 ** 9 + 7


def main():
    n = int(input())
    print(0)
    v = input()
    if v == "Vacant":
        exit()
    l, r = 0, n - 1
    while True:
        m = (l+r)//2
        print(m)
        q = input()
        if q == "Vacant":
            exit()
        elif m % 2 != 0:
            if v == q:
                r = m 
            else:
                l = m + 1
        else:
            if v == q:
                l = m+1
            else:
                r = m 


if __name__ == '__main__':
    main()


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int s,w; cin>>s>>w;
    if (w>=s){
        cout<<"unsafe\n";
    }else{
        cout<<"safe\n";
    }
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <cmath>

int main(){
   std::string S;
   std::cin >> S;
   long long int K;
   std::cin >> K;
   bool flag = false;
   int index = 0;
   char val;
   for (int i=0; i<S.size(); i++){
      if (S.at(i) != '1'){
         if (i >= K){
            std::cout << 1 << std::endl;
         } else{
            std::cout << S.at(i) << std::endl;
         }
         flag = true;
         break;
      }
   }

   if (!flag)
      std::cout << 1 << std::endl;
}



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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;
long long int n,cnt=0,ans=0,a[ohara],b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos,k;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl,ok;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

bool okk(ll i){
        bool tmp;
        if(k<=a[i]){
          return true;
        }
        bitset<5000+10> dp;
        dp[0]=true;
        ok=true;
        rep(j,n){
          if(i==j)continue;
          dp|=(dp<<a[j]);
        }
        rrep(j,k-a[i],k){
          if(dp[j]){
            ok=false;
            break;
          }
        }
        if(!ok)tmp=true;
        else tmp=false;

        return tmp;
}

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
      cin>>n>>k;
      rep(i,n)cin>>a[i];
      sort(a,a+n);
      ll le=0,ri=n-1,mid;
      while(ri-le>1){
        mid=(le+ri)/2;
        if(okk(mid)){
          ri=mid;
        }
        else{
          le=mid;
        }
        //cout<<le<<" "<<ri<<" "<<mid<<"\n";
      }
      //cout<<le<<" "<<ri<<" "<<mid<<"\n";
      if(!okk(ri))ans=ri+1;
      else if(!okk(le))ans=le+1;
      else ans=le;
      Cout(ans);
    
       
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};



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

    string s; cin >> s;
    int A = (int) (s[0] - '0');
    int B = (int) (s[1] - '0');
    int C = (int) (s[2] - '0');
    int D = (int) (s[3] - '0');
 
    if(A + B + C + D == 7) {cout << A << '+' << B << '+' << C << '+' << D << "=7"<< endl; return 0;}
    if(A + B + C - D == 7) {cout << A << '+' << B << '+' << C << '-' << D << "=7"<< endl; return 0;}
    if(A + B - C + D == 7) {cout << A << '+' << B << '-' << C << '+' << D << "=7"<< endl; return 0;}
    if(A + B - C - D == 7) {cout << A << '+' << B << '-' << C << '-' << D << "=7"<< endl; return 0;}
    if(A - B + C + D == 7) {cout << A << '-' << B << '+' << C << '+' << D << "=7"<< endl; return 0;}
    if(A - B + C - D == 7) {cout << A << '-' << B << '+' << C << '-' << D << "=7"<< endl; return 0;}
    if(A - B - C + D == 7) {cout << A << '-' << B << '-' << C << '+' << D << "=7"<< endl; return 0;}
    if(A - B - C - D == 7) {cout << A << '-' << B << '-' << C << '-' << D << "=7"<< endl; return 0;}

    return 0;
}


Measured memory_bytes: 256
import math

X = int(input())
M = 500

def culc():
  for a in range(-M, M):
    a5 = pow(a, 5)

    for b in range(-M, M):
      b5 = pow(b, 5)

      if(a5 - b5 == X):
        print(" ".join(map(str, [a, b])))
        return

culc()

Measured memory_bytes: 9192