akhauriyash/Code-Regression huggingface dataset:
x = int(input())
power5 = [(i ** 5) for i in range(1000)]
for i in range(1000):
  for j in range(1000):
    if power5[i] - power5[j] == x:
      print(i, j)
      exit()
for i in range(1000):
  for j in range(1000):
    if power5[i] + power5[j] == x:
      print(i, -j)
      exit()
for i in range(1000):
  for j in range(1000):
    if -power5[i] + power5[j] == x:
      print(-i, -j)
      exit()

Measured memory_bytes: 9216
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val s, w = sc.nextInt()

    if (s <= w) {
      println("unsafe")
    } else {
      println("safe")
    }
  }
}


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

int main(){
  while(true){
    int min_m = 100000000;
    int e;
    cin >> e;
    if( e == 0 ) break;
    for(int z = 0; z <= 100; ++z){
      for(int y = 0; y <= 1000; ++y){
	int x = e -  (int)pow((double)z,3) - (int)pow((double)y,2);
	if( x >= 0 )
	  min_m = min( min_m, x + y + z );
      }
    }
    cout << min_m << endl;
  }
  return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int k, t; cin >> k >> t;
  vi a(t);
  for(int i=0;i<t;++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  if(t == 1) {
    cout << a[0] - 1 << endl;
    return 0;
  }

  cout << max(0, a[t-1] - (k - a[t-1]) - 1) << endl;

}


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

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i = 0; i < N; i++)
        cin >> d[i];
    
    sort(d.begin(), d.end());
    if(d[N/2-1] == d[N/2])
        cout << 0 << endl;
    else
        cout << d[N/2] - d[N/2-1] << endl;

    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  cout << (N % 10 == (N / 100) % 10 ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 256
<?php
    while($num = array_map('intval',explode(" ",trim(fgets(STDIN))))){
        if($num[0]==0 && $num[1]==0){
            break;
        }
        for($j=1;$j<=$num[0];$j++){
            for($i=1;$i<=$num[1];$i++){
                if((($j%2)&&($i%2))||(($j%2==0)&&($i%2==0))){
                    echo "#";
                }else{
                    echo ".";
                }
            }
            echo "\n";
        }
        echo "\n";
    }
?>


Measured memory_bytes: 9224
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let s: Vec<char> = iterator.next().unwrap().chars().collect();

    let mut ans: isize = 0;
    for c in s {
        if c == '+' {
            ans += 1;
        } else {
            ans -= 1;
        }
    }
    ans.to_string()
}


Measured memory_bytes: 2088
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,a,b,i,j,k;
  cin>>n>>m>>a>>b;
  int d[n];
  for(i=0;i<n;i++)cin>>d[i];
  vector<int> v;
  for(i=0;i<n;i++) if(d[i]>=a) v.push_back(i); else break;
  reverse(v.begin(),v.end());
  int c=v.size();
  
  if(n-c<m){ 
    for(i=0;i<v.size();i++){
      //cout << i << ";" << c << endl;
      if(d[v[i]]<=b) c--;
      else break;
    }
  }

  cout << c << endl;
  return 0;
}

Measured memory_bytes: 1224
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int h = scanner.nextInt();
		int w = scanner.nextInt();

		char[][] c = new char[w][h * 2];
		for (int i = 0; i < h * 2; i += 2) {
			String s = scanner.next();
			for (int j = 0; j < w; j++) {

				c[j][i] = s.charAt(j);
				c[j][i + 1] = c[j][i];

			}
		}

		for (int i = 0; i < (2 * h); i++) {
			for (int j = 0; j < w; j++) {
				System.out.print(c[j][i]);
			}
			System.out.println();
		}

	}
}


Measured memory_bytes: 28944
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()
tmp = math.ceil(n/1.08)
if n==int(tmp*1.08):
    print(tmp)
else:
    print(":(")

Measured memory_bytes: 3444
def func():
    if len(S) == 1:
        return int(K/2)
    
    cnt = 1
    pre_s = S[0]
    tup_list = []
    for s in S[1:]:
        if pre_s == s:
            cnt += 1
        else:
            tup_list.append([pre_s, cnt])
            cnt = 1
        pre_s = s
    else:
        tup_list.append([pre_s, cnt])

    if len(tup_list) == 1:
        return int(cnt* K/2)
    
    ext = 0
    if tup_list[0][0] == tup_list[-1][0]:
        a = tup_list.pop()[1]
        b = tup_list[0][1]
        ext = int(a/2) + int(b/2) - int((a+b)/2)
        tup_list[0][1] += a
        
    res = 0
    for _,cnt in tup_list:
        res += int(cnt/2) * K
    return res + ext
    
S = input()
K = int(input())
print(func())

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i,a,n) for(ll i=a;i<(ll)(n);i++)

int main(){
    int N; cin>>N;
    string S[N];
    rep(i, N){
        cin>>S[i];
    }

    map<char, long> m;

    int i=0;
    for(string s : S){
        map<char, long> a;
        for(char c : s){
            a[c]++;
        }
        if(i == 0){
            for(auto v : a){
                m[v.first] = v.second;
            }
        }else{
            for(auto v : m){
                m[v.first] = min(v.second, a[v.first]);
            }
        }
        i++;
    }

    for(auto v : m){
        rep(i, v.second) cout<<v.first;
    }
    cout<<endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
inline i64 solve(i64 x,i64 y){
	if(x>y)swap(x,y);
	i64 res=0;
	res+=x*(y/x)*2;
	if(y%x)res+=solve(x,y%x);
	else res-=x;
	return res;
}
int main(){
	i64 n,x;cin>>n>>x;
	cout<<solve(x,n-x)+n;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef long long ll;
/////////////////////////(๑•﹏•๑｀)/////////////////////////
int main(){
	int n; SCD(n);
	int v[n];
	REP(i,n){
		v[i] = i+1;
	}

	 do {
		printf("%d",v[0]);
		FORq(i,1,n-1){
			printf(" %d",v[i]);
		}
		printf("\n");

	} while( next_permutation(v,v+n) );

	return 0;
}
	
	



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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define rep2r(i, l, r) for (int i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int N; cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  sort(range(A), greater<>());
  int ans = 0;
  rep(j, N) {
    int k = j + 1;
    rep(i, j) {
      while (k < N && A[i] < A[j] + A[k]) k++;
      ans += k - (j + 1);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int tmp = n % 500;
        if(tmp <= a ) System.out.println("Yes");
        else System.out.println("No");
    }
}

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

int main()
{
	// 1<<29だとWA
	// 1LL<<60にするとAC
	const long long int INF = 1LL << 60;

	int N, K;
	cin >> N >> K;
	vector<long long int> H(N+K+1, INF);
	for(int i = 0; i < N; i++) cin >> H[i];

	vector<long long int> dp(N+K+1, INF);
	dp[0] = 0;

	for(int i = 0; i < N; i++)
	{
		for(int j = 1; j <= K; j++)
		{
			dp[i+j] = min(dp[i+j], dp[i] + abs(H[i] - H[i+j]));
		}
	}

	cout << dp[N-1] << endl;

	return 0;
}


Measured memory_bytes: 1792
import sys
input = sys.stdin.buffer.readline

from operator import itemgetter

N = int(input())
AB = []

for _ in range(N):
    A, B = map(int, input().split())
    AB.append([A, B, A+B])

AB.sort(key=itemgetter(2), reverse=True)

takahashi = True
ans = 0

for i in range(N):
    if takahashi:
        ans += AB[i][0]
    else:
        ans -= AB[i][1]
    takahashi = not takahashi

print(ans)

Measured memory_bytes: 24472
sx,sy,tx,ty=map(int, input().split())
x=tx-sx
y=ty-sy
ans="R"*x+"U"*y+"L"*x+"D"*y
ans+="D"+"R"*(x+1)+"U"*(y+1)+"L"+"U"+"L"*(x+1)+"D"*(y+1)+"R"
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

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

struct Node {
  ll value;
  Node *left = nullptr,
       *right = nullptr,
       *parent = nullptr;

  Node(ll value = 0): value(value) {}
};

class BST {
  Node *root = nullptr;

  string tos_pre(Node *nd) {
    string s = "";

    s += " " + to_string(nd->value);
    if (nd->left) s += tos_pre(nd->left);
    if (nd->right) s += tos_pre(nd->right);

    return s;
  }

  string tos_in(Node *nd) {
    string s = "";

    if (nd->left) s += tos_in(nd->left);
    s += " " + to_string(nd->value);
    if (nd->right) s += tos_in(nd->right);

    return s;
  }
  
  Node *find_partial(ll value, Node *nd) {
    if (!nd) return nullptr;
    if (nd->value == value) return nd;
    
    return nd->value > value
      ? find_partial(value, nd->left)
      : find_partial(value, nd->right);
  }
  
  Node *get_min(Node *x) {
    while (x->left) x = x->left;
    return x;
  }

  Node *get_successor(Node *x) {
    if (x->right) return get_min(x->right);

    auto y = x->parent;
    while (y && x == y->right) {
      x = y;
      y = y->parent;
    }

    return y;
  }

public:
  void insert(ll value) {
    Node *x = root, *y = nullptr, *z = new Node(value);
    
    while (x) {
      y = x;
      x = z->value < x->value ? x->left : x->right;
    }
    z->parent = y;

    if (!y) root = z;
    else if (z->value < y->value) y->left = z;
    else y->right = z;
  }

  Node *find(ll value) {
    return find_partial(value, root); 
  }

  void del(ll value) {
    auto nd = find(value);
    if (nd) del(nd); 
  }

  void del(Node *nd) {
    int n_linked = 0;
    if (nd->left) n_linked++;
    if (nd->right) n_linked++;

    if (n_linked < 2) {
      auto cur = nd->left ? nd->left : nd->right;
      if (cur) cur->parent = nd->parent;
      
      if (nd->parent) {
        if (nd->parent->left == nd) nd->parent->left = cur;
        else nd->parent->right = cur;
      }
      delete nd;
    } else {
      auto next = get_successor(nd);
      nd->value = next->value;
      del(next);
    }
  }
  
  string print_pre() {
    return tos_pre(root);
  }

  string print_in() {
    return tos_in(root);
  }
};

int main() {
  int n;
  cin >> n;
  
  auto bst = BST();
  rep(i, n) {
    string cmd;
    cin >> cmd;
    
    if (cmd == "print") {
      cout << bst.print_in() << endl;
      cout << bst.print_pre() << endl;
    } else {
      ll opr;
      cin >> opr;

      if (cmd == "insert") bst.insert(opr);
      else if (cmd == "find") 
        cout << (bst.find(opr) ? "yes" : "no") << endl;
      else if (cmd == "delete") bst.del(opr);
    }
  }
}



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

int main(){
    int n;
    int suc_zero;

    while(cin>>n,n){
        suc_zero=0;
        for(int i=5;i<=n;i+=5){
            int tmp=i;
            while(tmp%5==0){
                suc_zero++;
                tmp/=5;
            }
        }

        cout<<suc_zero<<endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define vec vector
#define psb push_back
#define ppb pop_back
#define mkp make_pair
#define fst first
#define scd second
#define ins insert
#define psf push_front
#define ppf pop_front
using namespace std;
int main() {
	ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll n,i,k,r,s,p,ans=0;
	string mc;
	cin>>n>>k>>r>>s>>p>>mc;
	if(n<=k) {
		for(i=0;i<n;i++){
			if(mc[i]=='r')
				ans+=p;
			else if(mc[i]=='p')
				ans+=s;
			else
				ans+=r;
		}
	}
	else{
		vec<char> cache;
		for(i=0;i<k;i++){
			if(mc[i]=='r'){
				ans+=p;
				cache.psb('p');
			}
			else if(mc[i]=='p'){
				ans+=s;
				cache.psb('s');
			}
			else{
				ans+=r;
				cache.psb('r');
			}
		}
		for(i;i<n;i++){
			if(mc[i]=='r'){
				if(cache[i-k]=='p'){
					if(i+k<n) {
						if(mc[i+k]=='p')
							cache.psb('r');
						else
							cache.psb('s');
					}
					else
						cache.psb('s');
				}
				else{
					ans+=p;
					cache.psb('p');
				}
			}
			else if(mc[i]=='p'){
				if(cache[i-k]=='s'){
					if(i+k<n) {
						if(mc[i+k]=='s')
							cache.psb('p');
						else
							cache.psb('r');
					}
					else
						cache.psb('r');
				}
				else{
					ans+=s;
					cache.psb('s');
				}
			}
			else{
				if(cache[i-k]=='r'){
					if(i+k<n) {
						if(mc[i+k]=='p')
							cache.psb('p');
						else
							cache.psb('s');
					}
					else
						cache.psb('s');
				}
				else{
					ans+=r;
					cache.psb('r');					
				}
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
type ABC(stream:System.IO.TextReader) =
  member this.Scan1 f = stream.ReadLine() |> f
  member this.Scan2 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1]))
  member this.Scan3 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2]))
  member this.Scan4 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2], a.[3]))
  member this.ScanVecH f = stream.ReadLine().Split() |> Array.map f
  member this.ScanVecV n f = [| for i in 1..n -> stream.ReadLine() |> f |]
  member this.ScanMatrix n f  = [ for i in 1..n do yield stream.ReadLine().Split() |> Array.map f ]
  member this.ScanCharMatrix n = [ for i in 1..n -> stream.ReadLine().ToCharArray() ]
  member this.Close () = stream.Close()

let util = ABC(stdin)

util.Scan1 id |> ignore
let xs = util.ScanVecH int

let rec count cnt m xs =
  match xs with
  | [] -> cnt
  | x::xs ->
      if x >= m
      then count (cnt+1) x xs
      else count cnt m xs

count 0 -1 (Array.toList xs)
|> printfn "%d"



Measured memory_bytes: 14928
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int i, j;
	int h, w;
	string s;
	cin >> h >> w;
	for (i = 0; ; i++) {
		for (j = 0; j < w; j++) {
			cin >> s;
			if (s == "snuke") {
				printf("%c%d\n", 'A' + j, i + 1);
				return 0;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#include <variant>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll r,c,k;
  cin>>r>>c>>k;
  vector mat(r, vecll(c));
  REP(i,k) {
    ll y,x,v;
    cin>>y>>x>>v;
    --y;--x;
    mat[y][x] = v;
  }
  vector dp(4, vecll(c));
  REP(i,r) {
    vector nx(4, vecll(c));
    REP(j,c) {
      REP(m,3) {
        if (j > 0) {
          nx[m+1][j] = max(nx[m+1][j], nx[m][j-1] + mat[i][j]);
        }
      }
      REP(m,4) {
        if (j > 0) {
          nx[m][j] = max(nx[m][j], nx[m][j-1]);
        }
        nx[0][j] = max(nx[0][j], dp[m][j]);
        nx[1][j] = max(nx[1][j], dp[m][j] + mat[i][j]);
      }
    }
    swap(dp, nx);
  }
  ll mx = 0;
  REP(i,4) {
    mx = max(mx, dp[i][c-1]);
  }
  cout<<mx<<endl;
  return 0;
}


Measured memory_bytes: 74260
#include<bits/stdc++.h>
using namespace std;
int a[100005];

int main(){
	int n,ai;
	scanf("%d",&n);
	while(n--){
		scanf("%d",&ai);
		a[ai]++;
		a[ai+1]++;
		a[ai-1]++;
	}
	int max=0;
	for(int i=0;i<100005;i++){
		if(a[i]>max)
		    max=a[i];
	}
	printf("%d\n",max);
    return 0;	
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int dc = 2*c;
  ll ans = 0;
  if(dc <= a + b){
    if(x < y){
      ans += dc*x;
      y -= x;
      if(dc <= b) ans += dc*y;
      else ans += b*y;
    }else{
      ans += dc * y;
      x -= y;
      if(dc <= a) ans += dc * x;
      else ans += a * x;
    }
  }else{
    ans = x*a + b*y;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ab = 0;
        int a = 0;
        int b = 0;
        int ba = 0;
        for (int i = 0; i < n; i++) {
            char[] s = sc.next().toCharArray();
            if(s[0] == 'B') b++;
            if(s[s.length-1] == 'A') a++;
            if(s[0] == 'B' && s[s.length-1] == 'A') ba++;
            for (int j = 0; j < s.length - 1; j++) {
                if(s[j] == 'A' && s[j+1] == 'B') ab++;
            }
        }
        int c = (a == ba && b == ba && 0 < ba)? ba - 1 : Math.min(a, b);
        System.out.println(ab + c);
        sc.close();
    }

}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    ll x, y;
    cin >> x >> y;
    ll q = y / x;
    int ans = 0;
    while(q > 0) {
        q /= 2;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    ll A,B,C,D;
    cin>>A>>B>>C>>D;
    ll sum=B-A+1;
    ll C_cnt=B/C-((A-1)/C);
    ll D_cnt=B/D-((A-1)/D);
    ll x=C*D;
    if(C<D){
        ll temp=C;
        C=D;
        D=temp;
    }
    ll r=C%D;
    while(r!=0){
        C=D;
        D=r;
        r=C%D;
    }
    x=x/D;
    ll x_cnt=B/x-((A-1)/x);
    cout<<sum-(C_cnt+D_cnt)+x_cnt<<endl;
    return 0;
}

Measured memory_bytes: 3636
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let n:usize = read();
    let mut candidates = Vec::new();
    candidates.push(1usize);

    for i in 0..7 {
        candidates.push(6usize.pow(i));
    }
    for i in 0..6 {
        candidates.push(9usize.pow(i));
    }
    let mut dp = [std::usize::MAX; 100001];
    dp[0] = 0;

    for i in 1..100001 {
        for cand in candidates.iter() {
            if i >= *cand {
                dp[i] = std::cmp::min(dp[i], dp[i - cand] + 1);
            }
        }
    }
    println!("{:?}", dp[n]);
}


Measured memory_bytes: 5116
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,M, a[1000],b[1000],c[1000],d[100][100];
    cin>>N>>M;
    for(int i=0;i<M;i++){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--, b[i]--;
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(i==j) d[i][j]=0;
            else d[i][j]=100000000;
        }
    }
    for(int i=0;i<M;i++){
        d[a[i]][b[i]]=min(d[a[i]][b[i]], c[i]);
        d[b[i]][a[i]]=min(d[b[i]][a[i]], c[i]);
    }
    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++)
                d[i][j]=min(d[i][j], d[i][k]+d[k][j]);
        }
    }
    int ans=M;
    for(int i=0;i<M;i++){
        for(int j=0;j<N;j++)
            if(d[j][a[i]]+c[i]==d[j][b[i]]) goto minus;
        continue;
        minus: ans--;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import numpy as np

n = int(input())
arr_base = list(map(int,input().split()))
cap_base = list(map(int,input().split()))

arr = arr_base.copy()
cap = cap_base.copy()

ans = 0
for i in range(n):
    if arr[i] < cap[i]:
        ans += arr[i]
        sup = cap[i]-arr[i]
        if sup > arr[i+1]:
            ans += arr[i+1]
            arr[i+1] = 0

        else:
            arr[i+1]-=sup
            ans += sup
    else:
        ans += cap[i]
temp = ans
ans = 0


cap = cap_base.copy()
arr= arr_base.copy()
for i in range(1,n+1):
    if arr[-i] < cap[-i]:
        ans += arr[-i]
        sup = cap[-i]-arr[-i]
        if sup > arr[-i-1]:
            ans += arr[-i-1]
            arr[-i-1] = 0
        else:
            arr[-i-1]-=sup
            ans += sup
    else:
        ans += cap[-i]
#     print(ans)
#     print(arr)
# print(temp,ans)

print(max(temp,ans))


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

namespace ABC143
{
    class B
    {
        static void Main(string[] args)
        {
            //int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            long N = long.Parse(Console.ReadLine());
            //string S = Console.ReadLine();
            long[] d = Console.ReadLine().Split().Select(long.Parse).ToArray();

            long sum = 0;
            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < N; j++)
                {
                    if (i != j) sum += (d[i] * d[j]);
                }
            }
            Console.WriteLine(sum / 2);
        }
    }
}


Measured memory_bytes: 13396
s = input()
n = len(s)
for i in range((n-1)//2):
    if s[i] != s[n-i-1] or s[i] != s[(n-1)//2-i-1] or s[i+(n+1)//2] != s[n-i-1]:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll   long long int  
#define pb push_back
const int M=1e9 + 7;
using namespace std;
int N=1000000+1;
int main() {
   
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,m;cin>>n>>m;
    string s[n];
    for(int i=1;i<=n;i++)
    {
    	cin>>s[i-1];
	}
	int** dp=new int*[n];
	for(int i=0;i<n;i++)
	{
		dp[i]=new int[m];
		for(int j=0;j<m;j++)
		{
			dp[i][j]=0;
		}
	}
	for(int i=0;i<n;i++)
	{    
	    if(s[i][0]=='#')
	    {
	    	break;
		}
		dp[i][0]=1;
	}
	for(int j=0;j<m;j++)
	{
		if(s[0][j]=='#')
		{
			break;
		}
		dp[0][j]=1;
	}
	
	for(int i=1;i<n;i++)
	{   
	    
		for(int j=1;j<m;j++)
		{  
		    if(s[i][j]=='#')
		    {
		    	continue;
			}
			if(s[i-1][j]!='#' && s[i][j-1]!='#')
			{
				dp[i][j]=(dp[i-1][j]%M+dp[i][j-1]%M)%M;
			}else if(s[i-1][j]=='#' && s[i][j-1]=='#')
			{
				dp[i][j]=0;
			}else if(s[i-1][j]!='#')
			{
				dp[i][j]=dp[i-1][j]%M;
			}else if(s[i][j-1]!='#')
			{
				dp[i][j]=dp[i][j-1]%M;
			}
		}
	}
	cout<<dp[n-1][m-1]<<endl;
	return 0;
}
 
 
 
 
 

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll a,b,c;
    cin >> a >> b >> c;
    ll cnt = 0;
    rep(i,100000)
    {
        ll tmpa,tmpb,tmpc;
        if (a%2==1 || b%2==1 || c%2==1) break;
        cnt++;
        tmpa = (b+c)/2;
        tmpb = (a+c)/2;
        tmpc = (a+b)/2;
        a = tmpa;
        b = tmpb;
        c = tmpc;
    }
    if (cnt==100000)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << cnt << endl;
    }
    
    
    
}




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

int main() {
    string S;
    cin >>S;
    bool judge = false;
    for (int i=1;i<=S.size();i++){
        if((i%2!=0) &&  ((S.at(i-1) != 'R') && (S.at(i-1) != 'U') && (S.at(i-1) != 'D'))){
            judge = true;
            break;
        }
         else if((i%2==0) && ((S.at(i-1) != 'L') && (S.at(i-1) != 'U') && (S.at(i-1) != 'D'))) {
            judge = true;
            break;
        }
        else continue;
    }
    if(judge) cout << "No" <<endl;
    else cout << "Yes"  <<endl;
}

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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
    ll P, Q;
    cin >> P >> Q;
    ll G = gcd(P, Q);
    Q /= G;
    ll ans = 1;
    ll QQ = Q;
    for(ll i = 2; i * i <= Q; i++) {
        ll cnt = 0;
        while(QQ % i == 0) {
            QQ /= i;
            cnt++;
        }
        if(cnt) ans *= i;
    }

    if(QQ > 1) ans *= QQ;

    cout << max<ll>(2, ans) << endl;
    return 0;
}



Measured memory_bytes: 3120
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl

ll n,m,a,b,c,x,y,z,aa[200010],ab[200010],ac[200010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc,cd[1000][1000];
vector<ll> va,vb,vc;
deque<int> qa;

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>aa[i];
        if((i+n)%2){
            qa.push_front(aa[i]);
        }
        else{
            qa.push_back(aa[i]);
        }
    }
    
    for(int it:qa)C it<<" ";
    cout<<endl;
}

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

using namespace std;

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // LOCAL_EXEC
    vector<long long int>vt;
    long long int i,n,j;
    cin>>n;
    long long int A[n+1];
    bool ok=true;
    vt.push_back(1);
    for(i=0;i<=n;i++){
        cin>>A[i];
        if(A[i]>vt[vt.size()-1])
            ok=false;
        if((vt[i]-A[i])*2<1e18)
        vt.push_back(max(0ll,(vt[i]-A[i])*2));
        else
            vt.push_back(1e18);
        }
        //for(i=0;i<vt.size();i++){
          //  cout<<vt[i]<<endl;
        //}
        //cout<<vt.size()<<endl;
        if(n==0&&A[0]!=1)
            ok=false;
        if(ok==false)
            cout<<-1;
        else{
            long long int sum=0,dp[n+1];
            //cout<<ok<<endl;
                    dp[n]=A[n];
                    for(i=n-1;i>=0;i--){
                        dp[i]=A[i]+dp[i+1];
                        //cout<<vt[i]<<" ";
                        dp[i]=min(vt[i],dp[i]);
                    }
            for(i=0;i<=n;i++){
                sum+=dp[i];
            }
            cout<<sum;
            }
    return 0;
}


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

using namespace std;

#define int long long
#define tie() ios_base :: sync_with_stdio(0); cin.tie(0) ; cout.tie(0);
#define err(x) cerr << #x << " is : " << x << endl
#define mem(a , v)   memset(a , v , sizeof a)
#define all(v)       v.begin() , v.end()
#define pb           push_back
#define ff           first
#define ss           second

int nc2(int n)
{
      return (n * (n - 1)) / 2;
}

int32_t main()
{
      tie();
      int t = 1;
      //cin >> t;
      while(t--)
      {
            int n , x;
            cin >> n;
            int fq[n] , a[n];
            for(int i = 0 ; i < n ; i++)
                  fq[i] = 0;
            for(int i = 0 ; i <n ; i++)
            {
                  cin >> x;
                  x--;
                  a[i] = x;
                  fq[x] ++;
            }

            int sum = 0;
            for(int i = 0 ; i < n ; i++)
            {
                  sum += nc2(fq[i]);
            }

            for(int i = 0 ; i < n ; i++)
            {
                  if(fq[a[i]])
                        cout << sum - (fq[a[i]] - 1) << endl;
                  else
                        cout << sum << endl;
            }
      }
      return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
long b(long n,long x){
    if(n==0) return 1;
    if(x==1) return 0;
    else if(2<=x&&x<=pow(2,n+1)-2) return b(n-1,x-1);
    else if(x==pow(2,n+1)-1) return pow(2,n);
    else if(pow(2,n+1)<=x&&x<=pow(2,n+2)-4) return pow(2,n)+b(n-1,x-pow(2,n+1)+1);
    else if(pow(2,n+2)-3) return pow(2,n+1)-1;
}
int main(){
    long n,x;
    cin >> n >> x;
    cout << b(n,x) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include <algorithm>
#include <math.h>
using namespace std;
int main(void)
{
	int N;
	cin >> N;
	vector<int> data(N);
	for (int i = 0; i < N; i++)
	{
		cin >> data[i];
	}
	int cnt = 0;
	for (int i = 0; i < N - 2; i++)
	{
		if (data[i] < data[i + 1] && data[i + 2] >= data[i + 1])
		{
			cnt++;
		}
		else if(data[i+2] < data[i + 1] && data[i] >= data[i + 1])
		{
			cnt++;
		}
	}
	cout << cnt << endl;
}

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

public class Main{
    final static String alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".toLowerCase();//.toCharArray();
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));}
        String next(){while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException  e){e.printStackTrace();}}return st.nextToken();}
        int nextInt(){return Integer.parseInt(next());}
        long nextLong(){return Long.parseLong(next());}
        double nextDouble(){return Double.parseDouble(next());}
        int[] readArray(int n){int[] a=new int[n];for (int i=0; i<n; i++) a[i]=nextInt();return a;}
        long[] readLongArray(int n){long[] a=new long[n];for (int i=0; i<n; i++) a[i]=nextLong();return a;}
        String nextLine(){String str = "";try{str = br.readLine();}catch (IOException e){e.printStackTrace();}return str;}
    }
    static int getGcd(int n1,int n2){
        while(n1 != n2){
            if(n1 > n2) n1 -= n2;
            else n2 -= n1;
        }
        return n1;
    }
    static boolean isSorted(int[] arr, int n){
        for(int i=1;i<n;i++){
            if(arr[i]<arr[i-1]) return false;
        }
        return true;
    }
    static boolean isPrime(long n){
        if(n==2) return true;
        else if(n%2==0) return false;
        for(int i=3;i<=n/2;i+=2){
            if(n%i==0) return false;
        }
        return true;
    }
    static boolean isPrime(int n){
        if(n==2) return true;
        else if(n%2==0) return false;
        for(int i=3;i<=n/2;i+=2){
            if(n%i==0) return false;
        }
        return true;
    }
    static void printArray(int[] arr){
        for(int x:arr){
            System.out.print(x+" ");
        }
        System.out.println();
    }
    static long Fact(int n){
        //int p=1000000007;
        long result = 1;
        for (int i = 1; i <= n; i++) result = (result*i);
        //for (int i = 1; i <= n; i++) result = (result*i)%p;
        return result;
    }
    static final Random random=new Random();
    static void ruffleSort(int[] a) {
        int n=a.length;//shuffle, then sort
        for (int i=0; i<n; i++) {
            int oi=random.nextInt(n), temp=a[oi];
            a[oi]=a[i]; a[i]=temp;
        }
        Arrays.sort(a);
    }
    public static void main(String[] args) throws NumberFormatException, IOException {
        FastReader s = new FastReader();
        PrintWriter pw = new PrintWriter(System.out,true);
        String str = s.nextLine();
        int sum=0;
        for(int i=0;i<str.length();i++){
            sum+=Character.getNumericValue(str.charAt(i));
        }
        if(sum%9==0) pw.println("Yes");
        else pw.println("No");
    }
}

Measured memory_bytes: 29476
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (a == b || b == c || c == a) {
			if (a == b && b == c) {
				System.out.println("No");
			} else {
				System.out.println("Yes");
			}
		} else {
			System.out.println("No");
		}

		sc.close();
	}
}

Measured memory_bytes: 35652
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> lengths(N);
    for (int i = 0; i < N; ++i) cin >> lengths[i];
    int max = *max_element(lengths.begin(), lengths.end());
    int sum = accumulate(lengths.begin(), lengths.end(), 0);
    if (max < sum - max)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 384
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


n, x = map(int, input().split())
x_l = list(map(int, input().split()))
dist = []
for i in range(n):
    dist.append(abs(x - x_l[i]))

res = dist[0]
for i in range(len(dist)):
    res = gcd(res, dist[i])
print(res)


Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
#define gc getchar
#define pc putchar
#define st static
#define cs const

inline
ll getint(){
	re ll num=0;
	re char c=gc();
	while(!isdigit(c))c=gc();
	while(isdigit(c))num=(num<<1)+(num<<3)+(c^48),c=gc();
	return num;
}

int n,a[300005];

inline
bool check(int l,int r){
	int maxn=0,minn=n+1;
	for(int re i=l;i<=r;++i)maxn=max(maxn,a[i]),minn=min(minn,a[i]);
	if(maxn!=r||minn!=l)return false;
	int submaxn=0;
	maxn=0;
	for(int re i=l;i<=r;i+=2){
		if(maxn<a[i])maxn=a[i];
		else if(submaxn<a[i])submaxn=a[i];
		else return false;
	}
	return true;
}

int main(){
	n=getint();
	for(int re i=1;i<=n;++i){
		a[i]=getint();
	}
	for(int re i=1;i<=n;++i){
		if(a[i]==i)continue;
		int p;
		for(p=i;p<=n-2;p+=2){
			if(a[p+1]!=p+1||a[p+2]==p+2)break;
		}
		if(!check(i,p)){
			puts("No");
			return 0;
		}
		i=p;
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 1536
'use strict';
(function(stdin) {
  var inputs  = stdin.toString().split('\n')[0].split(' ').map(Number);
  (function(a,b) {
    var d = Math.floor(a / b);
    var r = Math.floor(a % b);
    var f = (a / b).toFixed(5);

    console.log('%d',d,r,f);

}(inputs[0],inputs[1]
  )); 
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15940
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    int N,Q;
    cin >> N >> Q;
    string S;
    cin >> S;

    vector<int> cumsum;
    cumsum.push_back(0);
    char left = '0';
    for(int i=0; i<(int)S.size(); ++i)
    {
        int tmp;
        if(left=='A' && S[i]=='C')
        {
            tmp = cumsum.back();
            cumsum.push_back(tmp+1);
        }
        else
        {
            tmp = cumsum.back();
            cumsum.push_back(tmp);
        }
        left = S[i];
    }
    vector<int> ans;
    for (int i=0; i<Q; ++i)
    {
        int l,r;
        cin >> l >> r;
        ans.push_back(cumsum[r]-cumsum[l]);
        // cout << cumsum[r]-cumsum[l] << endl;
    }
    for(auto x:ans)
    {
        cout << x << endl;
    }
    return 0;
}

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

int main() {
    int a, b, c, k, temp, ans = 0;
    cin >> a >> b >> c >> k;
    temp = max(a, max(b, c));
    ans = a + b + c - temp;
    rep(i, k) temp *= 2;
    ans += temp;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int d = sc.nextInt();
    int n = sc.nextInt();
    if(n==100){
      n=101;
    }
    for(int i=0;i<d;i++){
      n*=100;
    }
    System.out.println(n);
  }
}


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

#define int long long
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
ll ltmp;
int f(string s,int a){
  if(a==0)return -1;
  int res=0,t=1;
  reverse(s.begin(),s.end());
  for(int i=0;i<s.size();i++){
    (res+=t*(s[i]=='1'))%=a;
    (t*=2)%=a;
  }
  return res;
}
int p(int a){
  int res=0;
  while(a){
    if(a&1)res++;
    a>>=1;
  }
  return res;
}
int F(int a){
  int res=0;
  while(a){
    res++;
    a%=p(a);
  }
  return res;
}

ll getMod(ll value,ll mod){
    if(value == 0) return 0;
    return (value + mod) % mod;
}

#define base10_6 1000000    //1e6
ll getPower(ll value,ll shisu,ll mod){
    ll ans = 1;
    ll cnt = shisu;
    while(cnt>0){
        if(cnt%2==1){
            ans = ans * value % mod;
        }
        value = value * value % mod;
        cnt = cnt/2;
    }
    return ans;
}
ll bit2[1000010]={};

ll mod_p[base10_6+10]={};
ll mod_m[base10_6+10]={};
ll getIntSubstr(string s,ll start_index,ll length){
    return atoi(s.substr(start_index,length).c_str());
}

signed main(){
    int n;cin>>n;
    string s;cin>>s;
    int sum=0;
    for(char p:s)sum+=p=='1';
  
    ll base_pop = 0;
    string S = s;
    ll N = n;
    rep(ni,N){
        bit2[ni] = getIntSubstr(S,ni,1);
        //bit2[ni] = 1;
        base_pop+=bit2[ni];
    }
    sum = base_pop;

    ll basev= 1;

    basev=1;



    ll base_pop_p;
    ll base_pop_m;
    base_pop_p = base_pop+1;
    base_pop_m = base_pop-1;
    if(base_pop_m==0) base_pop_m=1;

    basev = 1;
    ltmp = 1;
    for( ll keta = 1 ; keta <=base10_6 ; keta++ ){
        mod_p[keta] = basev;
        basev = basev * 2;
        basev = getMod(basev,base_pop_p); 
    }
    basev = 1;
    for( ll keta = 1 ; keta <= base10_6 ; keta++ ){
        mod_m[keta] = basev;
        basev = basev * 2;
        basev = getMod(basev,base_pop_m); 
    }

    ll base_f1_p = 0;
    ll base_f1_m = 0;
    for( ll keta = 1 ; keta <=N ; keta++ ){
        ll ind = N -keta;
        base_f1_p += mod_p[keta] * bit2[ind];
        base_f1_m += mod_m[keta] * bit2[ind];
        base_f1_p = getMod(base_f1_p,base_pop_p );
        base_f1_m = getMod(base_f1_m,base_pop_m );
    }

    int A=base_f1_p;//f(s,sum+1);
    int B=base_f1_m;//f(s,sum-1);


  for(int i=0;i<n;i++){
    if(sum==1&&s[i]=='1'){
      cout<<0<<endl;
      continue;
    }
    if(s[i]=='0'){
      int res=A;
      res+=getPower(2,n-i-1,sum+1);res%=sum+1;
      cout<<F(res)+1<<endl;
    }
    else{
      int res=B;
      res-=getPower(2,n-i-1,sum-1);
      res+=sum-1;res%=sum-1;
      cout<<F(res)+1<<endl;
    }
  }
}


Measured memory_bytes: 21092
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;
ll power(ll a, ll b,ll m)
{
  a%=m;
  ll ans=1;
  if(a==0)
    ans=0;

  while(b>0)
  {
    if(b&1)
      ans=(ans*a)%m;

    a=(a*a)%m;
    b>>=1;
  }

  return ans;
}

int main()
{ 

ll x,y;
cin>>x>>y;

if((x+y)%3)
cout<<0<<endl;

else
{
    ll a=y-(x+y)/3;
    ll b=x-(x+y)/3;
    
    if(a<0 or b<0 or a+2*b!=x or 2*a+b!=y)
    cout<<0<<endl;
    
    else
    {
        ll z=max(a,b);
        ll f[a+b+1],inv[z+1];
        f[0]=1;
        for(ll i=1;i<a+b+1;i++)
        f[i]=(f[i-1]*i)%mod;
        
        for(ll i=0;i<z+1;i++)
        inv[i]=power(f[i],mod-2,mod);
        
        ll ans=1;
        ans*=f[a+b];
        ans=(ans*inv[a])%mod;
        ans=(ans*inv[b])%mod;
        cout<<ans<<endl;
    }
}
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define fi first
#define se second
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);



int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<min(a+b , min(b+c,c+a));
}


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

typedef struct{
    int k;
    int p;
    int l;
    int r;
}Node;

Node node[500002];
int nil = -1;
int root = -1;
int z;

void insert(int k){
    int y = nil;
    int x = root;
    z++;
    node[z].k = k;
    node[z].l = nil;
    node[z].r = nil;

    while(x != nil){
        y = x;
        if(node[z].k < node[x].k){
            x = node[x].l;
        }
        else x = node[x].r;
    }
    node[z].p = y;
    if(y == nil){
        root = z;
    }
    else{
        if(node[z].k < node[y].k){
            node[y].l = z;
        }
        else node[y].r = z;
    }
}

void inorder(int ppp){
    if (ppp == nil) return;
    inorder(node[ppp].l);
    printf(" %d", node[ppp].k);
    inorder(node[ppp].r);
}

void preorder(int ppp){
    if (ppp == nil) return;
    printf(" %d", node[ppp].k);
    preorder(node[ppp].l);
    preorder(node[ppp].r);
}

int find(int a, int k){
    while(a!=nil && k!=node[a].k){
        if(k<node[a].k) a = node[a].l;
        else a = node[a].r;
    }
    return a;
}


int main()
{
    char cccc[20];
    int n;
    int a;

    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%s", cccc);
        switch (cccc[0]){
            case 'f':
                scanf("%d", &a);
                if(find(root, a) != nil) printf("yes\n");
                else printf("no\n");
                break;
            case 'i':
                scanf("%d", &a);
                insert(a);
                break;
            default:
                inorder(root);
                printf("\n");
                preorder(root);
                printf("\n");
                break;
        }
    }
    return 0;
}


Measured memory_bytes: 7948
import java.util.Scanner;
import java.util.Arrays;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long takahashi = sc.nextLong();
    long aoki = sc.nextLong();
    long k = sc.nextLong();
    if(k > takahashi){
      k -= takahashi;
      takahashi = 0L;
      if(k > aoki){
        k-= aoki;
        aoki = 0L;
      }else{
        aoki -= k;
      }
    }else{
      takahashi -= k;
    }
    System.out.println(takahashi + " " + aoki);
  }
}

Measured memory_bytes: 23508
#!/usr/bin/env python3


def count_points(d, ps):
    return sum(x * x + y * y <= d * d for x, y in ps)


def main():
    n, d = (int(z) for z in input().split())
    ps = []
    for _ in range(n):
        x, y = (int(z) for z in input().split())
        ps.append((x, y))
    res = count_points(d, ps)
    print(res)


if __name__ == '__main__':
    main()

Measured memory_bytes: 35912
#include <iostream>
#include <vector>
#include <queue>
#include <bits/stdc++.h>

using namespace std;

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

typedef vector<int> vint;


template<class V> class MaxFlow_dinic{
public:
	struct edge{int to,reve;V cap;};
	static const int MV = 1100;
	vector<edge> E[MV];
	int itr[MV],lev[MV];

	void add_edge(int x,int y,V cap,bool undir=false){
		E[x].push_back((edge){y,(int)E[y].size(),cap});
		E[y].push_back((edge){x,(int)E[x].size()-1,undir?cap:0});
	}	
	void bfs(int cur){
		memset(lev,0xff,sizeof(lev));
		queue<int> q;
		lev[cur]=0;
		q.push(cur);
		while(q.size()){
			int v=q.front();
			q.pop();
			for(__typeof(E[v].begin()) e=E[v].begin();e!=E[v].end();e++) if(e->cap>0&&lev[e->to]<0) lev[e->to]=lev[v]+1,q.push(e->to);
		}
	}

	V dfs(int from,int to,V cf){
		if(from==to){
			return cf;
		}
		for(;itr[from]<E[from].size();itr[from]++){
			edge* e=&E[from][itr[from]];
			if(e->cap>0&&lev[from]<lev[e->to]){
				V f=dfs(e->to,to,min(cf,e->cap));
				if(f>0){
					e->cap-=f;
					E[e->to][e->reve].cap += f;
					return f;
				}
			}
		}
		return 0;
	}
	V maxflow(int from,int to){
		V fl = 0,tf;
		while(1){
			bfs(from);
			if(lev[to]<0) return fl;
			memset(itr,0,sizeof(itr));
			while((tf=dfs(from,to,numeric_limits<V>::max()))>0) fl += tf;
		}
	}
};


int main(){
	int n,m;
	while(cin>>n>>m,n||m){
		vint a(n);
		vint b(m);
		rep(i,n) cin>>a[i];
		rep(i,m) cin>>b[i];
		MaxFlow_dinic<int> mf;
		rep(i,n){
			rep(j,m){
				int t = __gcd(a[i],b[j]);
				if(t==1) continue;
				mf.add_edge(i,n+j,1);
			}
		}
		int souce = n+m;
		int sink = n+m+1;
		rep(i,n) mf.add_edge(souce,i,1);
		rep(i,m) mf.add_edge(n+i,sink,1);
		int ans = 0;
		ans = mf.maxflow(souce,sink);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 7372
import bisect,collections,copy,heapq,itertools,math,string
import sys
def I():
    # 1 line 1 int
    return int(sys.stdin.readline().rstrip())
def LI():
    # 1 line n ints
    return list(map(int,sys.stdin.readline().rstrip().split()))
def S():
    # 1 line 1 string
    return sys.stdin.readline().rstrip()
def LS():
    # 1 line n strings
    return list(sys.stdin.readline().rstrip().split())

a, b = LI()
x = a + b

if x%2 == 0:
    print(x//2)
else:
    print((x+1)//2)

Measured memory_bytes: 9956