akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = [int(input()) for i in range(n)]
xora = 0
xorls = []
for i in a:
  xora ^= i
  xorls.append(i^(i-1))
xorls.sort(reverse=True)
ans = 0
for i in xorls:
  if xora == 0:
    break
  if xora.bit_length() == i.bit_length():
    xora ^= i
    ans += 1
if xora:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 56908
#include <iostream>
#include <cmath>

using namespace std;

const int MAXN = 1000000000;

int main() {
	int n, k;
	cin >> n >> k;
	
	int ans[n], h[n];

	for (int i = 0;i < n;i++) cin >> h[i];
	
	ans[0] = 0;

	for (int i = 1;i < n;i++) {
		ans[i] = MAXN;
		for (int j = max(0, i - k);j < i;j++) 
			ans[i] = min(ans[i], ans[j] + abs(h[i] - h[j]));
	}

	cout << ans[n - 1];
}
                                            

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int[] A = inpNum(n);

		bubbleSort(A);

	}

	private static void bubbleSort(int[] A) {
		boolean flag = true;
		int cnt = 0;

		while(flag) {
			flag = false;

			for (int j = A.length - 1; j > 0; j-- ) {
				if (A[j] < A[j -1]) {
					int tmp;
					tmp = A[j];
					A[j] = A[j - 1];
					A[j -1] = tmp;
					cnt++;
					flag = true;
				}

			}

		}

		for (int k = 0; k < A.length; k++ ) {
			System.out.print(A[k]);
			if(k < A.length -1) {
				System.out.print(" ");
			}

		}
		System.out.println();
		System.out.println(cnt);

	}

	private static int[] inpNum(int n) {
		int[] nums = new int[n];

		for (int i = 0; i < n; i++) {
			nums[i] = sc.nextInt();
		}
		return nums;
	}

}


Measured memory_bytes: 26392
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
 
unordered_set<long long> sarvesh;
unordered_set<long long> sarvesh2;
unordered_set<long long> sarvesh3;
 
void primeFactors(long long n, unordered_set<long long> &s)
{
s.insert(1);
  while (n%2==0){
    s.insert(2);
    n /= 2;
  }
  for (long long i = 3; i <= sqrt(n); i+= 2){
    while (n%i == 0)
    {
      s.insert(i);
      n /= i;
    }
  }
  if (n > 2)
    s.insert(n);
}
 
int main(){
	long long A, B;
  	scanf("%lld%lld",&A,&B);
  	primeFactors(A, sarvesh);
  	primeFactors(B, sarvesh2);
  	for (auto i = sarvesh.begin(); i != sarvesh.end(); i++) {
        if (sarvesh2.find(*i) != sarvesh2.end()) sarvesh3.insert(*i);
    }
  	cout << sarvesh3.size();
}

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

int main(){
	int i;
	string s, t;
	cin >> s >> t;
	for(i=0; i<s.length(); ++i){
		if(s[i] != t[i]){
			break;
		}
	}
	if(i == s.length() && t.length() == i+1){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int N,M;
    long long K;
    cin>>N>>M>>K;
    vector<int> A,B;
    vector<long long> As(N+1),Bs(M+1);
    rep(i,N){
        int a;
        cin>>a;
        A.push_back(a);
    }
    rep(i,M){
        int b;
        cin>>b;
        B.push_back(b);
    }
    //累積和
    As[0]=0;
    rep2(i,1,N+1){
        As[i]=As[i-1]+A[i-1];
    }
    Bs[0]=0;
    rep2(i,1,M+1){
        Bs[i]=Bs[i-1]+B[i-1];
    }

    //A全部,B0冊から始めてB増やす⇒出来ないならA減らしてB増やすを繰り返してA0冊、B全部になるまでやる
    int ans =0;
    int tmpa=N;
    int tmpb=0;
        while(1){
            if(As[tmpa]+Bs[tmpb]<=K){
                ans = max(ans,tmpa+tmpb);
                tmpb++;
            }else{
                tmpa--;
            }
            if(tmpb>M||tmpa<0)break;
        }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8700
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

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

    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    long[] a = new long[n];
    for(int i=0; i<n; i++){
      a[i] = sc.nextLong();
    }

    long total = 0;
    long min = a[0];
    for(int i=1; i<n; i++){
      if(a[i] >= min){
        min = a[i];
      }else{
        total += min - a[i];
      }
    }

    System.out.println(total);

    return;

  }
}

Measured memory_bytes: 61260
def MI(): return map(int, input().split())
def LI(): return list(MI())
if __name__ == "__main__":
    N, M, X = MI()
    C = [LI() for _ in range(N)]
    ans = float('inf')
    for i in range(1<<N):
        score = [0] * M
        money = 0
        for j in range(N):
            if (1<<j) & i != 0:
                money += C[j][0]
                for k in range(M):
                    score[k] += C[j][k+1]
        if min(score) >= X:
            ans = min(ans, money)
    print(ans if ans != float('inf') else -1)


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

using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y 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 rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'



signed main() {
    fio();
    vi a(3);
    rep (i, 3) cin >> a[i];
    int k;
    cin >> k;

    int cnt = 0;
    for (int i = 1; i < 3; i++) {
        while (a[i] <= a[i - 1]) {
            cnt++;
            a[i] *= 2;
        }
    }
    if (cnt <= k) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
				int i = 1;
		while (true) {
			int x = sc.nextInt();
			// System.out.println("Case " + i + ": " + x);
			if (x == 0) {
				break;
			} else {
				System.out.println("Case " + i + ": " + x);
				i++;
			}
		}
	}
}


Measured memory_bytes: 41296
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math



def fx(s):
  ret = 0
  for c in s:
    ret += int(c)
  return ret

if __name__ == "__main__":
  n = str(input())
  if int(n) % fx(n) == 0:
    print('Yes')
  else:
    print('No')

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int X = in.nextInt();
            int Y = in.nextInt();
            out.println(X + Y / 2);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

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

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

    }
}



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

int main() {
	int N,M,A;
	cin >> N >> M;

	rep(i,M) {
		cin >> A;
		N -= A;

		if(N < 0) {
			cout << -1 << endl;
			return 0;
		}
	}

	cout << N << endl;
}

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

const int N = (1e6) + 5;
const ll MOD = 1e9 + 7;
ll fact[N], factin[N];
int x, y;

struct Tuple {
  ll x, y, gcd;
  Tuple(ll a, ll b, ll c) {
    x = a, y = b, gcd = c;
  }
};

Tuple extGcd(ll a, ll b) {
  if (b == 0) return Tuple(1, 0, a);
  Tuple ret = extGcd(b, a % b);
  return Tuple(ret.y, ret.x - a / b * ret.y, ret.gcd);
}

ll modInv(ll a, ll mod) {
  Tuple t = extGcd(a, mod);
  if (t.gcd == 1) return (t.x % mod + mod) % mod;
  return -1;
}

void preModFact(int n, ll mod) {
  fact[0] = 1;
  for (int i = 1; i <= n; ++i) {
    fact[i] = (fact[i - 1] * i) % mod;
  }
}  

void preModInvFact(int n, ll mod) {
  factin[0] = 1;
  for (int i = 1; i <= n; ++i) {
    factin[i] = modInv(fact[i], mod);
  }
}

ll C(int n, int k, ll mod) {
  if (0 <= k and k <= n) return ((fact[n] * factin[n - k]) % mod) * factin[k] % mod;
  return 0;
}

int main() { // claudio van
  preModFact(N - 5, MOD);
  preModInvFact(N - 5, MOD);
  cin >> x >> y;
  if ((x + y) % 3 == 0) {
    int r = (x + y) / 3;
    int c = y - r;
    cout << C(r, c, MOD) << "\n";
  } else {
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 16000
N = int(input())
shiritori = []

for i in range(N):
    word = input()
    shiritori.append(word)
    if i == 0:
        pass
    else:
        if shiritori[i].startswith(shiritori[i-1][-1:]):
            pass
        else:
            print("No")
            exit()


if len(set(shiritori)) == N:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define FIO {ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
typedef long long ll;
#define vi vector<int>

int main(){
	int n,l;cin>>n>>l;
	vector<string> st;
	while(n--){
		string s;cin>>s;
		st.push_back(s);
	}
	sort(st.begin(),st.end());
	for(auto i:st)cout<<i;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <algorithm>    
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cmath>
#include <bitset>
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define int long long
using namespace std;

typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef unsigned long long ull; 
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const int M = 1e9 + 7;
//__int128


signed main()
{
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  string s, t;
  int n, m;
  cin >> n >> m >> s >> t;
  int l = n * m / __gcd(n, m);
  int x = l / n, y = l / m;
  for(int i = 0; i < min(m, n); ++i) {
  	if(i * x % y == 0 && s[i] != t[i * x / y]) {
  		cout << -1 << endl;
  		return 0;

  	}
  }
  cout << l << endl;
	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>
#include <cmath>

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};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >>n;
    vint x(n),y(n);
    REP(i,n) cin >> x[i] >> y[i];
    double sum = 0.0;
    REP(i,n){
        REP(j,n){
            if(i!=j){
                sum += sqrt((double)((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])));
            }
        }
    }
    sum = sum/(double)n;
    printf("%.10f\n", sum);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll x, y;

void solve() {
    if (y > x) {
        if (x * y >= 0) {
            cout << abs((abs(y) - abs(x))) << endl;
        } else {
            cout << abs(abs(y) - abs(x)) + 1 << endl;
        }
    } else {
        if (x * y == 0) {
            cout << abs(x) + abs(y) + 1 << endl;
        } else if (x * y > 0) {
            cout << (abs(abs(x) - abs(y))) + 2 << endl;
        } else {
            cout << (abs(abs(y) - abs(x))) + 1 << endl;
        }
    }
}

int main() {
    cin >> x >> y;
    solve();
    return 0;
}

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

typedef long long int ll;
#define endl "\n"
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pair<int, int>>
#define mems(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define forn(i, s, e) for (int i = s; i < (e); ++i)
#define FASTIO                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define FILEIO                          \
    freopen("./input.txt", "r", stdin); \
    freopen("./output.txt", "w", stdout);
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)                                                               \
    for (                                                                       \
        auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
        blockTime.second;                                                       \
        debug("%s : %lld ms\n ", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false)
const int M = 998244353;

template <class T>
T ABS(const T &x) { return x > 0 ? x : -x; }
ll inv(ll a, ll b) { return 1 < a ? b - inv(b % a, a) * b / a : 1; }
ll gcd(ll n1, ll n2) { return n2 == 0 ? ABS(n1) : gcd(n2, n1 % n2); }
ll lcm(ll n1, ll n2) { return n1 == 0 && n2 == 0 ? 0 : ABS(n1 * n2) / gcd(n1, n2); }

ll Pow(ll a, ll b)
{
    ll x = 1, y = a;
    while (b > 0)
    {
        if (b % 2)
        {
            x = x * y;
            if (x > M)
                x %= M;
        }
        y = y * y;
        if (y > M)
            y %= M;
        b /= 2;
    }
    return x;
}

int main()
{
    FASTIO
#ifdef LOCAL
    FILEIO
#endif
    int n, s;
    cin >> n >> s;
    int dp[n + 1][s + 1], a[n + 1];
    forn(i, 0, n)
    {
        cin >> a[i];
    }
    forn(i, 0, n + 1) forn(j, 0, s + 1) dp[i][j] = 0;
    ll inv2 = inv(2, M);
    dp[0][0] = Pow(2, n);
    forn(i, 0, n)
    {
        forn(j, 0, s + 1)
        {
            dp[i + 1][j] = (dp[i][j] + dp[i + 1][j]) % M;
            if (j + a[i] <= s)
            {
                dp[i + 1][j + a[i]] = (dp[i + 1][j + a[i]] + (dp[i][j] % M * inv2) % M) % M;
            }
        }
    }
    cout << dp[n][s] << endl;
    return 0;
}

Measured memory_bytes: 38804
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int a=sc.nextInt(),b=sc.nextInt();
    if((a!=1&&a<b)||(b==1&&b<a)){
      System.out.println("Bob");
    }else if(a==b){
      System.out.println("Draw");
    }else{
      System.out.println("Alice");
    }
  }
}


Measured memory_bytes: 21588
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;

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

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

int main() {
	static int dp[1024][1024];
	for(int i = 1; i <= 1000; i++) dp[1][i] = i * (i + 1) / 2;
	for(int i = 2; i <= 1000; i++) {
		for(int j = 1; j <= i; j++) {
			dp[j][i] = dp[1][i] - (j - 1) * j / 2;
		}
	}
	map<int, int> m;
	for(int i = 2; i <= 1000; i++) {
		for(int j = 1; j <= i - 1; j++) {
			m[dp[j][i]]++;
		}
	}
	for(int N; cin >> N, N;) {
		cout << m[N] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
if (i%3==0)
    cout << " " << i;
else {
int x = i;
while (x > 0) {
 if (x%10==3) {
     cout << " " << i;
     break;
 }
 x /= 10;
}
}
}
cout << "\n";
}

Measured memory_bytes: 3188
gets.to_i.times do
  p0, p1, p2, p3 = gets.split.map(&:to_i).each_slice(2).map {|a, b| a + b * 1i }
  u, v, w, z = p1 - p0, p3 - p2, p2 - p0, p3 - p0
  d, c = (u.conj * v).rect
  if c.zero?
    if (u.conj * w).imag.zero?
      ud, wd, zd = [u, w, z].map {|x| (u.conj * x).real }
      a, b = 0, ud
      a, b = b, a if b < a
      p wd < a && zd < a || wd > b && zd > b ? 0 : 1
    else
      p 0
    end
  else
    # t, s are such that p0 + t * u = p2 + s * v
    t = (Complex(*v.rect.reverse!) * w).real.to_f / c
    s = (Complex(*u.rect.reverse!) * w).real.to_f / c
    p 0 <= t && t <= 1 && 0 <= s && s <= 1 ? 1 : 0
  end
end

Measured memory_bytes: 8920
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    List<Integer>[] edges = new ArrayList[N];
    for (int i = 0; i < N; i++) {
      edges[i] = new ArrayList<Integer>();
    }
    for (int i = 0; i < M; i++) {
      int x = sc.nextInt();
      int y = sc.nextInt();
      int w = sc.nextInt();
      edges[x-1].add(y-1);
      edges[y-1].add(x-1);
    }
    boolean[] visited = new boolean[N];
    int ans = 0;
    for (int i = 0; i < N; i++) {
      if (visited[i]) continue;
      LinkedList<Integer> queue = new LinkedList<Integer>();
      queue.offerLast(i);
      visited[i] = true;
      ans++;
      while (queue.size() > 0) {
        int v = queue.pollFirst();
        for (int w : edges[v]) {
          if (visited[w]) continue;
          queue.offerLast(w);
          visited[w] = true;
        }
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 104704
using System;
using System.IO;
using System.Collections.Generic;

namespace ARC096C
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var A = ss.Next(int.Parse);
            var B = ss.Next(int.Parse);
            var C = ss.Next(int.Parse);
            var X = ss.Next(long.Parse);
            var Y = ss.Next(long.Parse);

            var ans = 0L;
            ans += Math.Min(A + B, C * 2) * Math.Min(X, Y);
            if (X > Y) ans += Math.Min(A, C * 2) * (X - Y);
            if (Y > X) ans += Math.Min(B, C * 2) * (Y - X);
            sw.WriteLine(ans);
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}

Measured memory_bytes: 11220
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

public class Main{
 boolean[] p;
 int MAX = 50001;
 void run() {
  p = new boolean[MAX];
  for(int i=2;i<MAX;i++) if(!p[i]) {
   for(int j=2*i;j<MAX;j+=i) p[j] = true;
  }
  Scanner sc = new Scanner(System.in);
  for(;;) {
   int n = sc.nextInt();
   if( n == 0 ) break;

   int cnt = 0;
   for(int i=2;i<(n+1)/2;i++) if(!p[n-i] && !p[i]) cnt++;
   if(n/2 == n-n/2 && !p[n/2]) cnt++;
   System.out.println(cnt);
  }
 }
 public static void main(String[] args) {
  new Main().run();
 }
}

Measured memory_bytes: 13000
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < (int)(x); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = LLONG_MAX/4;
const int n_max = 1e5+10;

int main(){
    ll n,a,b; cin >> n >> a >> b;
    vector<ll> x(n);
    rep(i,n) cin >> x[i];
    ll res = 0;
    rep(i,n-1){
        ll num = x[i+1] - x[i];
        if(num * a < b)res += num*a;
        else res += b;
    }
    cout << res << endl;
}

Measured memory_bytes: 1024
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = getLine >>= putChar . succ . head >> putChar '\n'

Measured memory_bytes: 380
def carriable_baggage(baggage, baggage_num, truck_capacity, truck_num):
    """Return the number of baggae which trucks can carry."""
    laden_baggage = 0
    for i in range(truck_num):
        laden_weight = 0
        while laden_weight + baggage[laden_baggage] <= truck_capacity:
            laden_weight += baggage[laden_baggage]
            laden_baggage += 1
            if laden_baggage == baggage_num:
                return baggage_num
    return laden_baggage

def min_capacity(baggage, baggage_num, truck_num):
    """Return the minimum value of maximum load capacity of trucks."""
    left = 0
    right = sum(baggage)
    while right - left > 1:
        mid = (left + right) // 2
        v = carriable_baggage(baggage, baggage_num, mid, truck_num)
        if v >= baggage_num:
            right = mid;
        else:
            left = mid
    return right


import sys

n, k = map(int, sys.stdin.readline().split())

T = list(map(int, sys.stdin))

P = min_capacity(T, n, k)

print(P)

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

int main()
{
	std::string s;
	std::cin >> s;
	for (int i = 0; i < s.size(); ++i)
	{
		putchar('x');
	}
	puts("");
	return 0;
}

Measured memory_bytes: 384
N=int(input())
S=list(map(int,input().split()))
Z=[0]*N
start=S[0]
for i in range(1,N):
    Z[i]=S[i]-start
    if S[i]>start:
        start=S[i]


flug=False
for i in range(N):
    
    if  Z[i]<=-2:
        print("No")
        exit()
        

print("Yes")

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

#define ll long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ld long double

#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)
#define Fit(i,v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++i)
#define Fitd(i,v) for(__typeof((v).rbegin()) i = (v).rbegin(); i != (v).rend(); ++i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))

using namespace std;

#include <bits/stdc++.h>

using namespace std;


int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    string s;
    int n;

    cin >> s;
    n = s.length();
    int res = 0;
    for (int i = 0; n - 1 - i > i; ++i) {
    	if (s[i] != s[n - 1 - i]) {
    		res++;
    	}
    }
    cout << res << "\n";
#ifdef LOCAL
    cout << (double) clock() / CLOCKS_PER_SEC << "\n";
#endif
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
bool solve(){
    int W,H,N;
    bool fix[16][16]={{0}};
    cin>>W>>H;
    if(W==0&&H==0)return false;
    cin>>N;
    while(N--){
        int x,y;
        cin>>x>>y;
        fix[--y][--x]=true;
    }

    int dp[17][17]={{0}};
    dp[1][1]=1;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(fix[i][j])continue;
            dp[i+1][j+1]+=dp[i][j+1]+dp[i+1][j];
        }
    }
    cout<<dp[H][W]<<endl;
    return true;
}
int main(){
    while(solve());
    return 0;
}

Measured memory_bytes: 1160
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [i64; 3 * n],
    };
    let mut pq_0 = std::collections::BinaryHeap::new();
    let mut pq_1 = std::collections::BinaryHeap::new();
    let mut s_0 = 0_i64;
    let mut s_1 = 0_i64;
    for i in 0..n {
        let a_i = a[i];
        pq_0.push(-a_i);
        s_0 += a_i;

        let a_j = a[3 * n - i - 1];
        pq_1.push(a_j);
        s_1 -= a_j;
    }

    let mut c_0 = vec![s_0];
    for i in n..2 * n {
        let a_l = a[i];
        pq_0.push(-a_l);
        s_0 += a_l;
        let m_0 = pq_0.pop().unwrap();
        s_0 -= -m_0;
        c_0.push(s_0);
    }

    let mut c_1 = vec![s_1];
    for i in (n..2 * n).rev() {
        let a_r = a[i];
        pq_1.push(a_r);
        s_1 -= a_r;
        let m_1 = pq_1.pop().unwrap();
        s_1 += m_1;
        c_1.push(s_1);
    }

    let mut ans = -1_000_000_000_000_000_i64;
    for (&s_0, &s_1) in c_0.iter().zip(c_1.iter().rev()) {
        ans = std::cmp::max(ans, s_0 + s_1);
    }

    println!("{}", ans);
}


Measured memory_bytes: 10884
package main

import (
  "fmt"
)

func maxInt(a ...int) int {m := a[0]; for _, x := range a {if x > m {m = x}}; return m}
func minInt(a ...int) int {m := a[0]; for _, x := range a {if x < m {m = x}}; return m}

func main() {
  var a, b int
  fmt.Scan(&a, &b)
  fmt.Println(maxInt(a+b, a-b, a*b))
}

Measured memory_bytes: 512
# coding: utf-8

n = int(input())
prt = [-1 for i in range(n)]
chd = [[] for i in range(n)]
dpt = [0 for i in range(n)]

def putDepth(nodenum, d):
    dpt[nodenum] = d
    if len(chd[nodenum]) > 0:
        for i in chd[nodenum]:
            putDepth(i, d + 1)

for i in range(n):
    ipt = list(map(int, input().split()))
    idx = 0
    for j in ipt:
        idx += 1
        if idx < 3:
            continue
        prt[j] = ipt[0]
        chd[ipt[0]].append(j)

for i in range(n):
    if prt[i] == -1:
        putDepth(i, 0)
        break
    
for i in range(n):
    if dpt[i] == 0:
        nodetype = 'root'
    elif len(chd[i]) == 0:
        nodetype = 'leaf'
    else:
        nodetype = 'internal node'
    print('node {0}: parent = {1}, depth = {2}, {3}, {4}'.format(i, prt[i], dpt[i], nodetype, chd[i]))


Measured memory_bytes: 24908
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
//cout << fixed << setprecision(20) << *** << endl;
#define rep(i,N) for(int i=0;i<(int)N;++i)
typedef long long ll;
using namespace std;

ll Factorial(ll a){
	ll b=1;
	for(ll i=a;i>=1;i--){
		b=b*i;
	}
	return b;
}

int main()
{
	ll N;
	string S;
	string base="keyence";
	cin>>S;
	N=S.size()-7;
	rep(i,S.size()-N){
		string t=S;
		t.erase(i,N);
		if(t==base){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
}

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

using namespace std;

const int MAXN=110000;
const int OO = INT_MAX;
int N, K;
int sol[MAXN], A[MAXN];
int main(){
	cin>>N>>K;
	for(int i=0;i<N;i++){
		cin>>A[i];
		sol[i]=OO;	
	}
	sol[0]=0;
	for(int i=1;i<N;i++){
		for(int j=1;i-j>=0 && j<=K;j++)
		if(sol[i-j]+abs(A[i]-A[i-j])<sol[i])
			sol[i] = sol[i-j]+abs(A[i]-A[i-j]);
	}
	cout<<sol[N-1];
}

Measured memory_bytes: 1024
// C.

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long LL;

LL get_min(LL a, LL b) {
	LL c = a / 3;
	LL m = (a - c * 2 - (a - c) / 2) * b;
	for (LL i = 1; i <= a / 2; ++i) {
		LL p = i * b;
		LL q = (a - i) * (b / 2);
		LL r = (a - i) * (b - b / 2);
		LL s = min(min(p, q), r);
		LL t = max(max(p, q), r);
		m = min(m, t - s);
	}
	return m;
}

int main(int argc, char *argv[])
{
	LL h, w;
	cin >> h >> w;
	LL ans = min(get_min(h, w), get_min(w, h));
	cout << ans << endl;
	return 0;
}


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

typedef long long ll;

vector<ll > adj[200000];
bool memo[200000];
ll N, M;
const ll WHITE = 0;
const ll BLACK = 1;

bool DFS(ll depth, ll pos){
    memo[pos] = BLACK;
    if(depth==2){
        if(pos==N-1) return true;
        else return false;
    }else{
        bool flag;
        flag = false;
        for(ll i=0; i<adj[pos].size(); i++){
            if(memo[adj[pos][i]]==WHITE){
                flag = DFS(depth+1, adj[pos][i]);
                if(flag) return flag;
            }
        }
        return flag;
    }
}

int main(){
    cin >> N >> M;
    ll a, b;
    for(ll i=0; i<N; i++){
        memo[i] = WHITE;
    }
    for(ll i=0; i<M; i++){
        cin >> a >> b;
        a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    if(DFS(0, 0)){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }

}


Measured memory_bytes: 12904
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using lint = long long;
using namespace std;

const int MOD = 1000000007;

int main() {
    int N;
    lint A[300050];
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];

    lint res = 0;

    for (int i = 0; i < 60; i++) {
        lint c = 0;
        for (int j = 0; j < N; j++) {
            lint t = A[j];
            t = (t >> i) & 1;
            if (t) c++;
        }
        lint te = c * (N - c) % MOD;
        for (int j = 0; j < i; j++) te = te * 2 % MOD;
        res += te;
        res %= MOD;
    }

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


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



int main() {
  string S,T;
  int ans = 10000, k;

  cin >> S >> T;
  for(int i=0;i<=S.size() - T.size() ;++i){
    k = 0;
    for(int j=0;j<T.size();++j){
      if(S.at(i+j) != T.at(j)){
        k++;
      }
    }
    if(ans > k) ans = k;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
// acdart
#include <iostream>
#include <cstring>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <cmath>
#include <cctype>
#include <string>
#include <numeric>
#include <utility>
#include <queue>
#include <memory>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <cstdlib>
#include <list>
#include <limits.h>
#include <utility>
#include <functional>
#include <iterator>
#include <deque>
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second
#define F first
#define S second
#define MOD9 1000000009ll
#define MOD7 1000000007ll
#define MOD
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define SZ(x) ((int)(x).size())
#define MAXN 10010
#define MAXM
#define ALL(x) ((x).begin()),((x).end())
#define RESET(a,b) memset(a,b, sizeof a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define LEN(X) strlen(X)
#define FI(a,b,c) for(int a=b; a<c; a++)
#define FD(a,b,c) for(int a=b; a>c; a--)
using namespace std;
typedef long long ll;
typedef long long LL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
/*********default*********/
// #define ONLINE_JUDGE
#define inf 0x3f3f3f3f
#define mod
#define maxm
#define maxn 55
char a[maxn][maxn];
int main()
{/*
	#ifdef ONLINE_JUDGE
    	freopen("aplusb.in", "r", stdin);
    	freopen("aplusb.out", "w", stdout);
	#endif*/
	// ios::sync_with_stdio(false);
	int n, m;
	
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf("%s", a[i]);
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (a[i][j] == '#') {
				printf("#");
			} else {
				int tmp = 0;
				for (int k = -1; k <= 1; k++) {
					for (int p = -1; p <= 1; p++) {
						if (p == 0 && k == 0) continue;
						if (i + k >= 0 && i + k < n && 
							j + p >= 0 && j + p < m && 
							a[i + k][j + p] == '#') tmp++;
					}
				}
				printf("%d", tmp);
			}
		}
		puts("");
	}
}


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

int main(void) {
	double x1, y1, x2, y2;
	if (scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2) != 4) return 1;
	printf("%.15f\n", sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)));
	return 0;
}



Measured memory_bytes: 2068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> h(n);
	forn(i, n) cin >> h[i];
	vector<set<int>> g(n);
	forn(i, m) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		g[a].insert(h[b]);
		g[b].insert(h[a]);
	}
	int cnt = 0;
	for(int i = 0; i < n; i++) {
		if(sz(g[i]) == 0 || *prev(g[i].end()) < h[i]) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 17780
import java.util.Scanner;


public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        String sen;
        
        sen = sc.nextLine();

        int length = sen.length();
        for(int i=0; i<length; i++){
            char c = sen.charAt(i);
            if(c>= 'a' && c<='z'){
                c -= 32;
                sb.append(c);
            }else if(c >= 'A' && c <= 'Z'){
                c += 32;
                sb.append(c);
            }else{
                sb.append(c);
            }
        }

        System.out.println(sb);

        sc.close();

    }
}


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

int main()
{
  int x;cin>>x;
  if(x>=2100)cout<<1<<endl;
  else if(x<100)cout<<0<<endl;
  else
  {
    int num=x/100;
    if(x<=num*105)cout<<1<<endl;
    else cout<<0<<endl;
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp(a, b) make_pair(a, b)
#define ls (rt << 1)
#define rs (rt << 1 | 1) 
typedef pair<int, int> pii; 
const ll mod = 1e9 + 7;
template <class T> T lowbit(T x){return ((x)&(-(x)));}
const int maxn = 2e5 + 10;
int n;
int a[maxn];
ll pre[maxn][2], suf[maxn][2], f[maxn][2];

void solve0()
{
	for(int i = 1; i <= n; ++i)
	{
		pre[i][0] = pre[i - 1][0];
		pre[i][1] = pre[i - 1][1];
		pre[i][i & 1] += a[i];
	}
	for(int i = n, j = 1; i; --i, ++j)
	{
		suf[i][0] = suf[i + 1][0];
		suf[i][1] = suf[i + 1][1];
		suf[i][j & 1] += a[i];
	}
	ll ans = -1e18;
	for(int i = 0; i <= n; i += 2)
		ans = max(pre[i][1] + suf[i + 1][1], ans);
	cout << ans << endl;
}
void solve1()
{
	for(int i = 1; i <= n; ++i)
	{
		pre[i][0] = pre[i - 1][0];
		pre[i][1] = pre[i - 1][1];
		pre[i][i & 1] += a[i];
	}
	for(int i = n, j = 1; i; --i, ++j)
	{
		suf[i][0] = suf[i + 1][0];
		suf[i][1] = suf[i + 1][1];
		suf[i][j & 1] += a[i];
	}
	for(int i = 2; i <= n + 1; i += 2)
	{
		f[i][0] = f[i - 2][0] + a[i - 1];
		f[i][1] = max(f[i - 2][0] + a[i], f[i - 2][1] + a[i]);
	}
	ll ans = -1e18;
	for(int i = 2; i <= n + 1; i += 2)
		ans = max(max(f[i - 2][0], f[i - 2][1]) + suf[i + 1][1], ans);
	cout << ans << endl;
}
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	if(n % 2 == 0) solve0();
	else solve1();
	return 0;
}

Measured memory_bytes: 13924
#include <bits/stdc++.h>
using ll = long long;
ll l;
std::vector<int> vec;
int main() {
    std::cin >> l;
    int ans = 0;
    while (l > 1) {
        int i = l % 2;
        l -= i;
        l /= 2;
        ans++;
    }
    ll sum = 0;
    int i = 0;
    for (int p = ans; p >= 0; p--) {
        sum += (p * std::pow(2, i));
        i++;
    }
    sum += (ans+1);
    std::cout << sum << std::endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    vector<vector<int>> c(26);
    rep(i, n) c[s[i]-'a'].push_back(i);
    rep(i, n) c[s[i]-'a'].push_back(i+n);
    int p = 0;
    ll ans = 0;
    rep(i, m) {
        int now = t[i] - 'a';
        int l = c[now].size();
        if (l==0) {
            cout << -1 << endl;
            return 0;
        }
        p = *lower_bound(c[now].begin(), c[now].end(), p) + 1;
        if (p >= n) {
            p -= n;
            ans += n;
        }
    }
    ans += p;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4644
INF = 1<<60
d = [[INF]*51 for _ in range(51)]
for i in range(51):
    for j in range(i):
        for m in range(1, i+1):
            if i%m==j:
                d[i][j] = 1<<m
                break
    d[i][i] = 0
for k in range(51):
    for i in range(51):
        for j in range(51):
            if d[i][j] > d[i][k] | d[k][j]:
                d[i][j] = d[i][k] | d[k][j]
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A = list(map(lambda x: {x}, A))
ans = 0
for i in range(N):
    #print(i, A)
    ma = -1
    ama = -1
    for j, (a, b) in enumerate(zip(A, B)):
        d_ = INF
        for a_ in a:
            d_ = min(d_, d[a_][b])
        if d_ > ma:
            ma = d_
            ama = j
    del A[ama], B[ama]
    M = [m for m in range(1, 51) if ma>>m & 1]
    for j in range(len(A)):
        for a_ in list(A[j]):
            for m in M:
                A[j].add(a_%m)
    #print(ma)
    ans |= ma
print(ans if ans < INF else -1)


Measured memory_bytes: 3192
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    int count=1;
    while (n/k>0) {
      n=n/k;
      count++;
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>

using namespace std;

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

	int ac = 0;
	int wa = 0;
	int tle = 0;
	int re = 0;

	for(int i = 0; i < n; i++){
		string tmp;
		cin >> tmp;

		if(tmp == "AC")
			ac++;
		else if(tmp == "WA")
			wa++;
		else if(tmp == "TLE")
			tle++;
		else
			re++;
	}

	cout << "AC x " << ac << '\n';
	cout << "WA x " << wa << '\n';
	cout << "TLE x " << tle << '\n';
	cout << "RE x " << re << '\n';
}

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

using namespace std;

int n;
char s[123];
int cl[26], cr[26];

int main() {
  scanf("%d", &n);
  scanf("%s", s);
  for (int i = 0; i < n; i++) {
    cr[s[i] - 'a']++;
  }
  int ans = 0;
  int cur = 0;
  for (int i = 0; i < n - 1; i++) {
    int c = s[i] - 'a';
    bool bef = (cl[c] > 0 && cr[c] > 0);
    cl[c]++;
    cr[c]--;
    bool aft = (cr[c] > 0);
    cur += (!bef && aft);
    cur -= (bef && !aft);
    ans = max(ans, cur);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
void cmx(int&x,int y){if(x<y)x=y;}
void cmn(int&x,int y){if(x>y)x=y;}
int main(){
    int x0=0,y0=0;
    int x1,y1,n;std::cin>>x1>>y1>>n;
    while(n--){
        int x,y,a;std::cin>>x>>y>>a;
        if(a==1)cmx(x0,x);
        if(a==2)cmn(x1,x);
        if(a==3)cmx(y0,y);
        if(a==4)cmn(y1,y);
    }
    std::cout<<std::max(0,x1-x0)*std::max(0,y1-y0)<<std::endl;
}



Measured memory_bytes: 256
#include <iostream>

int main(){
  int n, d[100];
  std::cin >> n;
  for(int i = 0; i < n; i++){
    std::cin >> d[i];
  }

  int ret = 0;
  for(int i = 0; i < n-1; i++){
    for(int j = i+1; j < n; j++){
      ret += d[i]*d[j];
    }
  }

  std::cout << ret << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
int dp[301][301][301];
signed main(){
	int n,m;
	cin>>n>>m;
	if( n > m ){
		cout<<0<<endl;
		return 0;
	}
	dp[0][1][1] = 1;
	int sum = 0;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=j;k++){
				dp[i][j][k] += dp[i-1][j-1][k] * (n-j+1); dp[i][j][k] %= inf;
				dp[i][j][k] += dp[i-1][j][k] * (j-k); dp[i][j][k] %= inf;
				dp[i][j][j] += dp[i-1][j][k] * k; dp[i][j][j] %= inf;
			}
			//for(int k=1;k<=j;k++){cout<<i<<j<<k<<" "<<dp[i][j][k]<<endl;}
		}
	}
	int ans = dp[m][n][n];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 212608
fun main(args: Array<String>) {
    val N = nextInt()
    val A = listOfLong()
    val S = LongArray(N + 1)
    for (i in 0 until N) S[i + 1] = S[i] + A[i]
    var ans = Long.MAX_VALUE
    var l = 1
    var r = 3
    for (i in 2 .. N - 2) {
        while (Math.abs(S[l] - (S[i] - S[l])) > Math.abs(S[l + 1] - (S[i] - S[l + 1]))) l++
        while (Math.abs(S[N] - S[r] - S[r] + S[i]) > Math.abs(S[N] - S[r + 1] - S[r + 1] + S[i])) r++
        val list = listOf(S[l], S[i] - S[l], S[r] - S[i], S[N] - S[r])
        ans = Math.min(ans, Math.abs(list.max()!! - list.min()!!))
    }
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }


Measured memory_bytes: 93740
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

const int N = 1000;

int T[N + 1] = { 0 };

int main() {
	int x;
	T[1] = 1;
	for(int i = 2;i <= sqrt(N);++i){
		for(int j = i * i;j <= N;j *= i){
			T[j] = 1;
		}
	}
	cin >> x;
	for(int i = x;0 <= i;--i){
		if(T[i]){
			cout << i << endl;
			break;
		}
	}
	return 0;
}


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

#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define ld long double
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) cin>>n
#define pl(n) cout<<n
#define sze(v) (int)(v.size())

typedef vector<int>Vl;
typedef pair<int,int>pii;
typedef vector<pii>Vll;
typedef vector<vector<int>>Vv;
typedef vector<pair<int,pii> >Vlll;
typedef priority_queue <int, vector<int>, greater<int>>PQL;
typedef unordered_map<int,int>ump;

const int mod=1e9+7;
const int modx=998244353;
const int Nx=1e5+2;
const int inf= (int)(1e19+10LL);

void solve(){
  char ch;
  sl(ch);
  if(ch>='a'){
	  cout<<"a"<<endl;
	  return;
  }
  cout<<"A"<<endl;

		
}
 
signed main(){
   int test=1;
   //sl(test);
   while(test--){
      solve();
 
   }
  return 0;
}


Measured memory_bytes: 3620