akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Long N = sc.nextLong();
      
        int sq = (int) Math.floor(Math.sqrt((double)N));
      	for(int i = sq; i > 0; i--){
          	if(N%i==0){
              if(i>(N/i)){
                System.out.println(String.valueOf(i).length());
                return;
              }else{
                Long ans = (long) (N/i);
                System.out.println(String.valueOf(ans).length());
                return;
              }
            }
        }
		System.out.println(String.valueOf(N).length());
	}
}


Measured memory_bytes: 23252
def main():
    n,k = map(int,input().split())
    h = list(map(int,input().split()))
    h.sort()
    sum = 0
    for i in range(0,len(h)-k):
        sum += h[i]
    print(sum)
    return 

if __name__=="__main__":
    main()
    

Measured memory_bytes: 87372
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] cards = new int[N];
		for (int i = 0; i < cards.length; i++) {
			cards[i] = sc.nextInt();
		}
		Arrays.sort(cards);
		int aliceSum = 0;
		int bobSum = 0;
		for (int i = cards.length - 1; i >= 0; i--) {
			if ((cards.length % 2 == 0 && i % 2 != 0) || (cards.length % 2 != 0 && i % 2 == 0)) {
				aliceSum += cards[i];
			} else {
				bobSum += cards[i];
			}
		}
		System.out.println(aliceSum - bobSum);
		sc.close();
	}
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#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 << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

void test_case(){
	int x , y , z; cin >> x >> y >> z;
	swap(x,y);
	swap(x,z);
	cout<<x<<" "<<y<<" "<<z<<"\n";
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/05/25  Problem: ABC 127 A / Link: http://abc127.contest.atcoder.jp/tasks/abc127_a  ----- */


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

	LL A, B; cin >> A >> B;
	LL ans = 0LL;
	if (A >= 13)ans = B;
	else if (A >= 6)ans = B / 2;
	else ans = 0;




	cout << (ans) << "\n";

	return 0;
}


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

#define N 100

int main(void){
  char s[N], p[N], a[2*N];

  scanf("%s %s", s, p);
  strcpy(a, s);
  strcat(a, s);
  if(strstr(a, p) != NULL){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 540
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {

  i64 N, K, i;
  cin >> N >> K;
  vi x(N);
  REP(0, N, i) {
    cin >> x[i];
  }
  i64 ans = max(-x[0], x[N-1]) + x[N-1] - x[0];
  REP(0, N-K+1, i) {
    i64 b = x[i];
    i64 e = x[i+K-1];
    if(b > 0) {
      ans = min(ans, e);
    }
    else if(e < 0) {
      ans = min(ans, -b);
    }
    else {
      ans = min(ans, e-b+min(e,-b));
    }
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

/*************** using variables **************/
int h, w, n;
vector<int> a, b;
map<P, int> mp;
int ans[10];
/**********************************************/

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

    cin >> h >> w >> n;
    a.resize(n);
    b.resize(n);
    REP(i, n) cin >> a[i] >> b[i];
    REP(i, n) a[i]--, b[i]--;

    REP(i, n){
        if(a[i] < h-2 && b[i] < w-2) mp[P(a[i], b[i])]++;

        if(a[i]-2 < h-2 && b[i] < w-2 && a[i] - 2 >= 0) mp[P(a[i] - 2, b[i])]++;
        if(a[i]-1 < h-2 && b[i] < w-2 && a[i] - 1 >= 0) mp[P(a[i] - 1, b[i])]++;
        if(a[i] < h-2 && b[i]-2 < w-2 && b[i] - 2 >= 0) mp[P(a[i], b[i] - 2)]++;
        if(a[i] < h-2 && b[i]-1 < w-2 && b[i] - 1 >= 0) mp[P(a[i], b[i] - 1)]++;
        if(a[i]-2 < h-2 && b[i]-2 < w-2 && a[i] - 2 >= 0 && b[i] - 2 >= 0) mp[P(a[i] - 2, b[i] - 2)]++;
        if(a[i]-2 < h-2 && b[i]-1 < w-2 && a[i] - 2 >= 0 && b[i] - 1 >= 0) mp[P(a[i] - 2, b[i] - 1)]++;
        if(a[i]-1 < h-2 && b[i]-2 < w-2 && a[i] - 1 >= 0 && b[i] - 2 >= 0) mp[P(a[i] - 1, b[i] - 2)]++;
        if(a[i]-1 < h-2 && b[i]-1 < w-2 && a[i] - 1 >= 0 && b[i] - 1 >= 0) mp[P(a[i] - 1, b[i] - 1)]++;
    }

    ans[0] = (h-2) * (w-2);
    for(auto x: mp){
        ans[x.second]++;
    }
    FOR(i, 1, 10) ans[0] -= ans[i];
    REP(i, 10) cout << ans[i] << endl;
}


Measured memory_bytes: 58112
#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ss string
#define ll long long int
#define Endl endl
#define forn for(long long int i=0;i<n-1;i++)
#define u_b upper_bound
#define rep(i,n)         for(int i=0;i<n;i++)
#define ld long double
#define tc long long t;cin>>t;while(t--)
#define fr(i,a,b)        for(long long int i=a;i<=b;i++)
#define E endl
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define V vector<ll>v;
#define aaste long long int n;cin>>n;long long int a[n];for(long long int i=0;i<n;i++)cin>>a[i];
const ll   mod=            1000000007;
const ll   MOD1=           (int)1e9 + 9;
const ll   MOD2=           998244353;
const ld    pi=             atan2(0, -1);
const ld    eps=            1e-9;

const int MAXR = 1000005;
ll         tests=          1;

using namespace std;
int binarySearch(int arr[], int l, int r, int x)
{
	if (r >= l) {
		int mid = l + (r - l) / 2;
		if (arr[mid] == x)
			return mid;
		if (arr[mid] > x)
			return binarySearch(arr, l, mid - 1, x);
		return binarySearch(arr, mid + 1, r, x);
	}
	return l;
}
bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
void swap(ll *p1, ll *p2)
{
   ll temp=*p1;
   *p1=*p2;
   *p2=temp;
}
ll cbratt(ll x)
{
    ll l = 0, r = MAXR;
    while (l != r) {
        ll m = (l + r + 1) / 2;
        if (m * m * m > x)
            r = m - 1;
        else
            l = m;
    }
    return l;
}
// ll ctr=1;
// ll vis[10001];
// ll color[10001];
// vector<ll>v[10001];
// void dfs(ll node,ll colr)
// {
// 	vis[node]=1;
// 	for(ll i=0;i<v[node].size();i++)
// 	{
//        if(!vis[v[node][i]])
//        {
//        	  if(color[v[node][i]]!=colr)
//        	  	ctr++;
//        	dfs(v[node][i],color[v[node][i]]);
//        }
// 	}
// }
 // for(ll i=2;i<=n;i++)
    // {
    //       ll x;
    //      cin>>x;
    //    v[i].push_back(x);
    //    v[x].push_back(i);
    // }
    // fr(i,1,n)
    // {
    // 	cin>>color[i];
    // }
    // ll result=0;
    // dfs(1,color[1]);
    // result+=ctr;
    // cout<<result;
   // for(ll i=1;i<=n;i++)
   // {
   // 	   cout<<i;
   // 	for(ll j=0;j<v[i].size();j++)
   // 	{
   // 		cout<<"-"<<v[i][j];
   // 	}
   // 	cout<<endl;
   // }
int main()
{
    #ifndef ONLINE_JUDGE
	{
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	}
  #endif
ss s1;
ss s2;
cin>>s1>>s2;
ss s3;
for(ll i=0;i<s1.size();i++)
  s3+=s2[i];
if(s3==s1&&s2.size()-s1.size()==1)
  cout<<"Yes";
else
  cout<<"No";

}


Measured memory_bytes: 3624
"""
We Love ABC
DP使う問題
T : 文字列
i < j < k < len(T)
Ti = "A"
Tj = "B"
Tk = "C"
i j k の順で取れたら、1カウント
- TはA, B, C, ? で構成される
- ? は　ABC のいずれか
これらを満たす場合の数

i番目の文字において、ABCのどこまで進んだか
null:   0
A   :   1
B   :   2
C   :   3

?の扱いが厄介
?があると単純に選択肢が3倍になる
A? -> AA, AB, AC
B? -> BA, BB, BC
まだ選んでいない時 : 入力の選択肢が3倍に増える
dp[i+1][1]: 
    すでにAを選んでいる時 : iまでのAの選び方が3倍に増えるので、dp[i][1]*3
    何も選んでいない場合  : ?がAになれるので、dp[i][0]を加える
ほかも同じ
"""
mod = 10**9 + 7

S = input()
N = len(S)
dp = [[0]*4 for i in range(100800)]
dp[0][0] = 1
for i in range(N):
    s = S[i]
    dp[i+1][0] = dp[i][0] 
    dp[i+1][1] = dp[i][1] 
    dp[i+1][2] = dp[i][2] 
    dp[i+1][3] = dp[i][3] 
    if s == "A":
        # Aを選ぶ選択肢がそれまでのA,?分増える
        dp[i+1][1] += dp[i][0]
    if s == "B":
        # Bを選ぶ選択肢がそれまでのAの選択肢分増える
        dp[i+1][2] = dp[i][2] + dp[i][1] 
    if s == "C":
        # Cを選ぶ選択肢がBまでを選んだ分だけ増える
        dp[i+1][3] = dp[i][3] + dp[i][2]
    if s == "?":
        # ?を選んだ場合。選択肢は3倍に広がる
        dp[i+1][0] = (3*dp[i][0])%mod
        dp[i+1][1] = (dp[i][0] + 3*dp[i][1]) % mod
        dp[i+1][2] = (dp[i][1] + 3*dp[i][2]) % mod
        dp[i+1][3] = (dp[i][2] + 3*dp[i][3]) % mod
        
# Cまで行った数を求める
print(dp[N][3]%mod)

Measured memory_bytes: 27636
n = int(input())
x = list(map(int, input().split()))

for i in range(n):
    x[i] = (x[i], i)

x.sort()

answers = [x[n//2 - 1][0]] * n

ans = x[n//2][0]
for i in range(n//2):
    answers[x[i][1]] = ans

for i in answers:
    print(i)

Measured memory_bytes: 105096
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
String a=sc.next();
String b=sc.next();
String c=sc.next();
if(a.charAt(a.length()-1)==b.charAt(0)&&b.charAt(b.length()-1)==c.charAt(0)){
    out.println("YES");
}else{
    out.println("NO");
}
}
}

Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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/gcd(a,b)*b;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using graph = vector<vector<ll>>;
pair<pair<ll,ll>,ll> p[100010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,m;
    cin>>n>>m;
    rep(i,m){
        ll a,b;
        cin>>a>>b;
        p[i]=make_pair(make_pair(-a,b),i);
    }
    sort(p,p+m);
    ll c=1;
    vec<pair<ll,pair<ll,ll>>> v(m);
    rep(i,m){
        v[i].first=p[i].second;
        if(i>=1 && p[i].first.first==p[i-1].first.first) c++;
        else c=1;
        v[i].second.first=abs(p[i].first.first);
        v[i].second.second=c;
    }
    sort(ALL(v));
    rep(i,m){
        cout<<setw(6)<<setfill('0')<<v[i].second.first;
        cout<<setw(6)<<setfill('0')<<v[i].second.second<<endl;
    }
    return 0;
}



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

/**
 * Created by fcdkbear on 15.10.16.
 */
public class Main {

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


    static class Task {

        public void solve(InputReader in, PrintWriter out) {

            String s = in.next();
            int cIndex = s.indexOf('C');
            int fIndex = s.lastIndexOf('F');
            if ((cIndex == -1) || (fIndex == -1) || (cIndex > fIndex)) {
                out.println("No");
            } else {
                out.println("Yes");
            }

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

    }

}


Measured memory_bytes: 8404
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int a,b,k;
    cin >> a >> b >> k;
    rep(i,k/2){
        if(a%2==1)a--;
        b += a/2;
        a/=2;
        if(b%2==1)b--;
        a += b/2;
        b/= 2;
    }
    if(k%2){
        if(a%2==1)a--;
        b += a/2;
        a/=2;
    }
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n;
  cin >> n;
  vector<pair<ll,ll>> a(n);
  rep(i,n){
    ll c,b;
    cin >> c >> b;
    a.at(i)=make_pair(b,c);
  }
  string s="Yes";
  ll p=0;
  sort(a.begin(),a.end());
  rep(i,n){
    p+=a.at(i).second;
    if(p>a.at(i).first){
      s="No";
    }
  }
  cout << s;
}
    

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

int toA(char c) {
	if (c == 'a') return 0;
	else return int('z' - c) + 1;
}

int main() {
	string s;
	int K;
	cin >> s >> K;
	for (int i = 0; i < s.length(); i++) {
		int ta = toA(s[i]);
		if (K >= ta) {
			s[i] = 'a';
			K -= ta;
		}	
	}
	s[s.length() - 1] = ((s[s.length() - 1] - 'a') + K) % 26 + 'a';
	cout << s;
	return 0;
}

Measured memory_bytes: 640
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
ll pow(ll x, ll ntimes) {
    ll ret = 1;
    while (ntimes > 0) {
        if ((ntimes & 1) == 1) {
            ret = ret * x;
        }
        x = x * x;
        ntimes >>= 1;
    }
    return ret;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vvint nb(n);
    vvint g(n,vint(n,-1));
    REP(i,n-1){
        int a,b;
        cin >> a >> b;
        a--; b--;
        nb[a].pb(b);
        nb[b].pb(a);
        g[a][b]=i;
        g[b][a]=i;
    }
    int m;
    cin >> m;
    vvint path(m,vint(n-1,0));
    REP(i,m){
        int u,v;
        cin >> u >> v;
        u--; v--;
        queue<int> q;
        q.push(u);
        vint par(n,-1);
        while(true){
            int now = q.front();
            q.pop();
            if(now==v){
                int p = par[now];
                while(true){
                    int ed = g[p][now];
                    path[i][ed] = 1;
                    if(p==u){
                        break;
                    }
                    now = p;
                    p = par[now];
                }
                break;
            }
            for(int j:nb[now]){
                if(j!=par[now]){
                    q.push(j);
                    par[j] = now;
                }
            }
        }
    }
    ll ans = (1LL<<(n-1));
    int num = (1<<m);
    vvint use(num+1,vint(n-1,0));
    REP(i,m){
        int pre = (1<<i);
        REP(j,pre){
            int t = j;
            int cnt = 0;
            while(t>0){
                if(t%2==1){
                    cnt++;
                }
                t >>= 1;
            }
            cnt++;
            int now = pre;
            int ed = 0;
            REP(k,n-1){
                use[j+now][k] = max(path[i][k], use[j][k]);
                ed += max(path[i][k], use[j][k]);
            }
            if(cnt%2==1){
                ans -= pow(2,n-1-ed);
            }else{
                ans += pow(2,n-1-ed);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;

    cout << "100 100\n";
    REP(i,100){
        REP(j,100){
            if(i<50) cout << (i%2&&j%2&&--a>0 ? "." : "#");
            else  cout << (i%2&&j%2&&--b>0 ? "#" : ".");
        }
        cout << "\n";
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

int main(){

    int n;
    cin >> n;
    vector<ll> a(n);

    REP(i,n){
        cin >> a[i];
    }
    VSORT(a);

    cout << a[n-1]-a[0] << endl;

    return 0;
}

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

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

  int n;

  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> a[i][j];
    }
  }

  cin >> n;

  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (a[j][k] == tmp) {
          a[j][k] = -1;
        }
      }
    }
  }

  for (int i = 0; i < 3; i++) {
    int cnt = 0;
    for (int j = 0; j < 3; j++) {
      if (a[i][j] == -1)
        cnt++;
      else
        break;
      if (cnt == 3) {
        cout << "Yes";
        return 0;
      }
    }
  }

  for (int i = 0; i < 3; i++) {
    int cnt = 0;
    for (int j = 0; j < 3; j++) {
      if (a[j][i] == -1)
        cnt++;
      else
        break;
      if (cnt == 3) {
        cout << "Yes";
        return 0;
      }
    }
  }

  if (a[0][0] == -1 && a[1][1] == -1 && a[2][2] == -1) {
    cout << "Yes";
  } else if (a[0][2] == -1 && a[1][1] == -1 && a[2][0] == -1) {
    cout << "Yes";
  } else {
    cout << "No";
  }

  return 0;
}

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

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

ll pow(ll a, ll b) {
    if (b == 0) return 1;
    if (b % 2) return a * pow(a, b - 1);
    return pow(a * a, b / 2);
}
//a^(-1)≡a^(p-2) (mod p) (but p is prime)
ll powMod(ll a, ll b, ll p) {
    if (b == 0) return 1;
    if (b % 2) return (a * powMod(a, b - 1, p)) % p;
    return powMod(a * a % p, b / 2, p);
}

int main() {
    ll n, k, ans = 1, combi = 1;
    cin >> n >> k;
    ll cnt = (n < k ? n - 1 : k);
    for (int i = 1; i <= cnt; ++i) {
        (combi *= (n - i + 1)) %= MOD7;
        (combi *= powMod(i, MOD7 - 2, MOD7)) %= MOD7;
        (ans += ((combi * combi) % MOD7) * (((n - i) * powMod(n, MOD7 - 2, MOD7)) % MOD7)) %= MOD7;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A,B;
    cin>>A>>B;
    if(A==B) cout <<A+B<<"\n";
    else cout <<2*max(A,B)-1<<"\n";
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

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

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int H, W; cin >> H >> W;
	vector<vector<string> > a(H, vector<string>(W));
	rep(y, H) rep(x, W) cin >> a[y][x];
	rep(y, H) rep(x, W) if (a[y][x] == "snuke") cout << (char)('A' + x) << y + 1 << endl;
}


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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int H, W, h, w;
  cin >> H >> W >> h >> w;

  int result = H * W - (w * H + h * W - h * w);

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
def solve():
    A, B, K = map(int, input().split())
    for i in range(K):
        if i % 2 == 0:
            if A % 2 == 1: A -= 1
            A //= 2
            B += A
        else:
            if B % 2 == 1: B -= 1
            B //= 2
            A += B
    print(A, B)

    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 3064
using System;
using System.Linq;

class A
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var st = Console.ReadLine().Split();
		var ab = Read();
		var u = Console.ReadLine();

		ab[u == st[0] ? 0 : 1]--;
		Console.WriteLine($"{ab[0]} {ab[1]}");
	}
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<char>> F(N, vector<char>(M));
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < M; ++j)
      cin >> F[i][j];

  int ans = 1000000001;
  for (int w = 0; w < N - 2; ++w) {
    for (int b = w + 1; b < N - 1; ++b) {
      int diff = 0;
      for (int i = 0; i < N; ++i) {
        for (int j = 0; j < M; ++j) {
          if (0 <= i && i <= w && F[i][j] != 'W')
            ++diff;
          if (w < i && i <= b && F[i][j] != 'B')
            ++diff;
          if (b < i && i < N && F[i][j] != 'R')
            ++diff;
        }
      }

      ans = min(diff, ans);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3164
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mp make_pair
  #define pb push_back
  #define inf INT_MAX
  #define f first
  #define s second
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define all(v) v.begin(), v.end()
  #define mod INT_MAX 
  const int MOD=1e9+7;
  const int N=2e5+2;

  int32_t main()
  {
    /*#ifndef ONLINE_JUDGE
       freopen("in.txt","r",stdin);
       freopen("out.txt","w",stdout);
    #endif*/
       IOS
       int a,b,c,d,t1,t2,t3;
       cin>>a>>b>>c>>d;
       t1 =  max(a*c,a*d);
       t2=  max(t1,b*c);
       t3 = max(t2,b*d);
       cout<<t3;
       return 0;

    }

Measured memory_bytes: 3648
/**
 * @author torith
 * @date 2018-11-06
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, A; cin >> N >> A;
    int a[50] = {};
    int max_a = 0;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        max_a = max(a[i], max_a);
    }
    max_a = (A, max_a);

    vector<vector<vector<ll>>> dp(N+1,vector<vector<ll>>(N+1, vector<ll>(max_a * N + 1,0)));
    dp[0][0][0] = 1;
    for (int i = 1; i <= N; ++i) {
        for (int j = 0; j <= N; ++j) {
            for (int k = 0; k <= N*max_a; ++k) {
                if (j >= 1 && k >= a[i-1]) {
                    dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-a[i-1]];
                }else if (k < a[i-1]) {
                    dp[i][j][k] = dp[i-1][j][k];
                }
            }
        }
    }

    ll ans = 0;
    for (int i = 1; i <= N; ++i) {
        ans += dp[N][i][i*A];
    }

    cout << ans << "\n";

    return 0;
}



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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll n,k;
  cin >> n >> k;

  vll a(n), b(n);
  vector<vll> edge(n);
  REP(i, n-1){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    edge[a[i]].push_back(b[i]);
    edge[b[i]].push_back(a[i]);
  }


  vector<bool> visited(n, false);
  queue<ll> que;
  que.push(0);
  visited[0] = true;
  ll ans = k;
  bool flag = true;
  while(!que.empty()){
    ll v = que.front();
    que.pop();
    ll now = k-2;
    if(flag){
      now = k-1;
      flag = false;
    }


    for(ll i = 0; i < edge[v].size(); i++){
      ll cur = edge[v][i];
      if(visited[cur])
        continue;
      if(now == 0){
        cout << 0 << endl;
        return 0;
      }
      ans = (ans*now) % MOD;
      que.push(cur);
      visited[cur] = true;
      now--;
    }
  }


  cout << ans << endl;
}


Measured memory_bytes: 8948
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    char a;
    cin>>a;
    for(char i='a';i<='z';i++){
        if(a-i==0){
            cout << "a"<<endl;
            return 0;
        }
    }
    cout << "A" << endl;

    



}


Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {

	ll X;
	cin >> X;
	ll ans = 2199 - X;
	ans /= 200;

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

Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <string>
#include <random>
#include <map>
#pragma warning(disable : 4996)



int main(void) {
	int a, b, c;
	char op;
	scanf("%d %c %d", &a, &op, &b);
	if (op == '+') {
		c = a + b;
	}
	else {
		c = a - b;
	}
	printf("%d\n", c);
	return 0;
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int a, b;
    cin >> a >> b;
    for(int i = 1; i < 4; i++) if((a*b*i) % 2 == 1 ){
        cout << "Yes";
        return 0;
    }
    cout << "No";
}

Measured memory_bytes: 256
def resolve():
    n,m=map(int,input().split())
    ab=[]
    check=[]
    for i in range(n):
        tmp=list(map(int,input().split()))
        ab.append(tmp)
    for i in range(m):
        tmp=list(map(int,input().split()))
        check.append(tmp)
    for i in range(n):
        num=1
        ans=1000000000
        for j in range(m):
            len=abs(ab[i][0]-check[j][0])+abs(ab[i][1]-check[j][1])
            if ans>len:
                tmp=num
                ans=len
            num+=1
        print(tmp)
resolve()

Measured memory_bytes: 39152
# ABC056 C - Go Home
X = int(input())

T = []
total = 0
idx = 0
ans = 0

while total < 2500000000:
    idx += 1
    total += idx
    T.append(total)

for i in range(len(T)-1):
    if i == 0:
        if X == T[i]:
            ans = i+1
            break
    if T[i-1]<X<=T[i]:
        ans = i+1
        break
print(ans)

Measured memory_bytes: 6040
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

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

#define F first
#define S second
#define PB push_back
#define MP make_pair

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

#define INF 1e18
#define MOD 1000000007
//#define DEBUG

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::default_random_engine e(seed);
std::mt19937 rng((int) seed);

ll a[200010];
ll b[200010];

void solvetask() {
    ll n, m, k;
    cin >> n >> m >> k;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(i > 0) a[i] += a[i-1];
    }
    for(int i = 0; i < m; i++) {
        cin >> b[i];
        if(i > 0) b[i] += b[i-1];
    }

    ll ans = int(upper_bound(b, b + m, k) - b);

    for(int i = 0; i < n; i++) {
        if(a[i] > k) break;
        ll at = int(upper_bound(b, b + m, k - a[i]) - b) + i + 1;
        ans = max(ans, at);
    }

    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);

    int t = 1;

    while(t--) solvetask();
}


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

#define F first
#define S second

using namespace std;

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

const int N = 100010, M = 110;

int n, m;
map<int, int> f[2];

int main()
{
	scanf("%d%d", &n, &m);
	
	int t = 0;
	f[t][0] = 0;
	for (int i = 1; i <= n; i ++ )
	{
		int w, v;
		scanf("%d%d", &w, &v);
		
		t ^= 1;
		for (auto u : f[t ^ 1])
		{
			f[t][u.F] = max(f[t][u.F], u.S);
			if (u.F + w <= m) f[t][u.F + w] = max(f[t][u.F + w], u.S + v);
		}
	}
	
	int res = 0;
	for (auto u : f[t]) res = max(res, u.S);
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 512
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=float('inf')
for i in range(M):
    x,y,c=map(int,input().split())
    ans=min(a[x-1]+b[y-1]-c,ans)
ans=min(min(a)+min(b),ans)
print(ans)

Measured memory_bytes: 66924
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;


void CountTriangles(vector <int> A){
  
    int n=A.size();
  
    sort(A.begin(), A.end());
  
    int count = 0;
      
    for( int i = n-1; i >= 1; i--){
        int l = 0, r = i-1;
        while( l < r){
            if( A[l] + A[r] > A[i]){
  
                // If it is possible with a[l], a[r]
                // and a[i] then it is also possible
                // with a[l+1]..a[r-1],a[r] and a[i]
                count += r - l ;
  
                //checking for more possible solutions
                r--;
            }
            else
  
                // if not possible check for
                // higher values of arr[l]
                l++;
        }
    }
    cout<<count <<endl;
}
int main(){
    int x;
    cin >> x;
    vector<int> A ;
    for(int i=0;i<x;i++){
        int tmp;
        cin >> tmp;
        A.push_back(tmp);
        
    }

    CountTriangles(A);
    
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int H,W,x1,y1;
    cin >> H >> W;
    string array[H][W];
    for(int x=0;x<H;x++){
        for(int y=0;y<W;y++){
            cin >> array[x][y];
            cin.get();
        }
    }
    for(int x=0;x<H;x++){
        for(int y=0;y<W;y++){
            if(array[x][y]=="snuke"){
                x1 = x+1;
                y1 = y+1;
            }
        }
    }
    if(y1==1){
        cout << "A" << x1 << endl;
    }else if(y1==2){
        cout << "B" << x1 << endl;
    }else if(y1==3){
        cout << "C" << x1 << endl;
    }else if(y1==4){
        cout << "D" << x1 << endl;
    }else if(y1==5){
        cout << "E" << x1 << endl;
    }else if(y1==6){
        cout << "F" << x1 << endl;
    }else if(y1==7){
        cout << "G" << x1 << endl;
    }else if(y1==8){
        cout << "H" << x1 << endl;
    }else if(y1==9){
        cout << "I" << x1 << endl;
    }else if(y1==10){
        cout << "J" << x1 << endl;
    }else if(y1==11){
        cout << "K" << x1 << endl;
    }else if(y1==12){
        cout << "L" << x1 << endl;
    }else if(y1==13){
        cout << "M" << x1 << endl;
    }else if(y1==14){
        cout << "N" << x1 << endl;
    }else if(y1==15){
        cout << "O" << x1 << endl;
    }else if(y1==16){
        cout << "P" << x1 << endl;
    }else if(y1==17){
        cout << "Q" << x1 << endl;
    }else if(y1==18){
        cout << "R" << x1 << endl;
    }else if(y1==19){
        cout << "S" << x1 << endl;
    }else if(y1==20){
        cout << "T" << x1 << endl;
    }else if(y1==21){
        cout << "U" << x1 << endl;
    }else if(y1==22){
        cout << "V" << x1 << endl;
    }else if(y1==23){
        cout << "W" << x1 << endl;
    }else if(y1==24){
        cout << "X" << x1 << endl;
    }else if(y1==25){
        cout << "Y" << x1 << endl;
    }else if(y1==26){
        cout << "Z" << x1 << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 998244353;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

int a[200000];
int n;
bool ok(int k)
{
	map<int, int> M;
	fup(i, 1, n - 1, 1)
	{
		if (a[i] <= a[i - 1])
		{
			M.erase(M.upper_bound(a[i]), M.end());
			int t = a[i];
			M[t]++;
			while (t > 0 && M[t] == k)
			{
				M.erase(t);
				M[--t]++;
			}
			if (t == 0)return 0;
		}
	}
	return 1;
}
int main() {
	scanf("%d", &n);
	fup(i, 0, n - 1, 1)scanf("%d", a + i);
	bool o = 1;
	fup(i, 1, n - 1, 1)if (a[i] <= a[i - 1])o = 0;
	if (o)return !printf("1");
	int l = 2, r = n;
	while (l <= r)
	{
		int k = (l + r) >> 1;
		if (ok(k))r = k - 1;
		else l = k + 1;
	}
	printf("%d", l);
}

Measured memory_bytes: 1024
def L(N):
    if N==0:
        return 1
    else:
        prev_L = L(N-1)
        return 1+prev_L+1+prev_L+1
def numP(N):
    if N==0:
        return 1
    else:
        prev_P = numP(N-1)
        return 2*prev_P+1
def eated_P(N,X):
    ans = 0
    fh=int(L(N)/2)
    if X<=0:
        return 0
    elif N==0:
        return 1
    elif fh<X:
        ans = numP(N-1)+1+eated_P(N-1,X-fh-1)
        return ans
    else:
        rem = X-1
        ans = eated_P(N-1,rem)
        return ans
N,X = map(int,input().split())
print(eated_P(N,X))

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

int SumOfDigits(int n) {
    int sum = 0;
    int remainder;
    while (n > 0) {
        remainder = n % 10;
        sum += remainder;
        n /= 10;
    }
    return sum;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int total = 0;
    for (int i = 1; i < n + 1; i++) {
        int sum = SumOfDigits(i);
        if (sum >= a && sum <= b) {
            total += i;
        }
    }
    cout << total << endl;
}

Measured memory_bytes: 256
# ABC070 B - Two Switches
a,b,c,d = map(int,input().split())

ans = 0
Alice = False
Bob = False

for i in range(0,101):
    if a <= i <= b:
        Alice = True
    else:
        Alice = False
    
    if c <= i <= d:
        Bob = True
    else:
        Bob = False
    
    if Alice and Bob:
        ans += 1

if ans == 0:
    print(0)
else:
    print(ans-1)


Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>

using namespace std;

int v[100010];
long long v1[100010],v2[100010],v3[100010];

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%d",&v[i]);
    for(int i=1;i<n;i++)
    {
        if(v[i]<v[i+1])
        {
            int c=v[i+1]-v[i];
            v1[1]+=c;v1[v[i]+1]-=c;
            v1[v[i+1]+1]+=c;
            v2[v[i]+1]+=c;
            v3[v[i]+2]+=1;
            v3[v[i+1]+2]-=1;
        }
        else
        {
            int c=m-v[i]+v[i+1];
            v1[v[i+1]+1]+=c;v1[v[i]+1]-=c;
            v2[v[i]+1]+=c;v3[v[i]+2]+=1;
            v2[1]+=v[i+1];
            v3[2]+=1;
            v3[v[i+1]+2]-=1;
        }
    }
    long long sol=0,rez=1e18,a=0;
    for(int i=1;i<=m;i++)
    {
        sol+=v1[i]+v2[i];
        a+=v3[i];
        sol-=a;
        rez=min(rez,sol);
    }
    printf("%lld",rez);
    return 0;
}


Measured memory_bytes: 2944
using System;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Text;

namespace Fish.aizu
{
	public static class AizuOnlineJudge
	{
		public static int[] SplitToInts(string line)
		{
			return line.Split(' ').Select(x => int.Parse(x)).ToArray();
		}
		public static double[] SplitToDoubles(string line)
		{
			return line.Split(' ').Select(x => double.Parse(x)).ToArray();
		}
		public static long[] SplitToLongs(string line)
		{
			return line.Split(' ').Select(x => long.Parse(x)).ToArray();
		}
		public static int Main()
		{
			Compute(Console.In, Console.Out);
			return 0;
		}
		
		public static void Compute(TextReader reader, TextWriter writer)
		{
			var line = reader.ReadLine();
			var stringBuilder = new StringBuilder(1200);
			foreach (var c in line)
			{
				stringBuilder.Append(char.IsLower(c) ? char.ToUpper(c) : char.ToLower(c));
			}
			writer.WriteLine(stringBuilder.ToString());
		}
	}
}

Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}

Vec fac, finv;

ll PowMod(ll a, ll n){
    if(n == 1) return a;
    if(n%2 == 0) return PowMod(a*a%MOD, n/2);
    return a*PowMod(a*a%MOD, n/2)%MOD;
}

ll combi(ll n, ll k){
    if(k>n) return 0;
    return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

int main(){
    int s, w;
    R s >> w;
    if(w >= s){
        co("unsafe");
    }
    else{
        co("safe");
    }
}


Measured memory_bytes: 3652