akhauriyash/Code-Regression huggingface dataset:
/*
  4*100+8 ?
*/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
using ll = long long;

string convert(deque<int> &a){
    string s,t;
    rep(i,a.size()){
        s += "#."[a[i]>>0&1];
        t += "#."[a[i]>>1&1];
    }
    return s + "\n" + t;
}

char ask(deque<int> &a){
    cout << convert(a) << endl;
    string s;
    cin >> s;
    char c = s[0];
    if(c == 'e') exit(0);
    return c;
}

int main(){
    int N;
    while(cin >> N){
        deque<int> X;
        while(1){
            int f = -1;
            rep(i,4){
                X.push_back(i);
                char c = ask(X);
                if(c == 'T'){
                    f = i;
                    break;
                }
                X.pop_back();
            }
            if((int)X.size() == N || f == -1) break;
        }
        while(1){
            int f = -1;
            rep(i,4){
                X.push_front(i);
                char c = ask(X);
                if(c == 'T'){
                    f = i;
                    break;
                }
                X.pop_front();
            }
            assert(f != -1);
        }
    }
}


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

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

    int maxHeight;
    cin >> maxHeight;

    int counter = 0;
    for(int i=0; i<num; i++) {
        int val;
        cin >> val;
        if(val >= maxHeight) {
            counter++;
        }
    }

    cout << counter << 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 h = sc.nextInt();
        int w = sc.nextInt();
        int[][] map = new int[h][w];
        ArrayDeque<Point> que = new ArrayDeque<>();

        for (int i=0; i<h; i++) {
            char[] c = sc.next().toCharArray();
            for (int j=0; j<w; j++) {
                if (c[j] == '.') {
                    map[i][j] = Integer.MAX_VALUE;
                } else if (c[j] == '#'){
                    map[i][j] = 0;
                    que.addFirst(new Point(i,j));
                }
            }
        }
        int[] dh = {1,-1,0,0};
        int[] dw = {0,0,1,-1};
        while (que.size() > 0) {
            Point p = que.removeFirst();
            for (int i=0; i<4; i++) {
                int nh = p.h + dh[i];
                int nw = p.w + dw[i];
                if (nh < 0 || nh >= h) continue;
                if (nw < 0 || nw >= w) continue;
                if (map[nh][nw] == Integer.MAX_VALUE) {
                    que.addLast(new Point(nh, nw));
                    map[nh][nw] = map[p.h][p.w] + 1;
                }
            }
        }
        int max = 0;
        for (int[] array : map) {
            for (int a : array) {
                max = Math.max(max, a);
            }
        }
        System.out.println(max);

    }
    static class Point {
        int h;
        int w;
        Point (int h, int w) {
            this.h = h;
            this.w = w;
        }
    }
}

Measured memory_bytes: 65580
import java.util.*;

public class Main{
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			int N = sc.nextInt(), ans = 0, count = 0;
			String S = sc.next();
			for(int i = 0; i < N; i++){
				if(S.charAt(i) == '('){
					count++;
				}else{
					count--;
					if(count < 0){
						count = 0;
						ans++;
					}
				}
			}
			for(int i = 0; i < ans; i++){
				S = '(' + S;
			}
			for(int i = 0; i < count; i++){
				S = S + ')';
			}
			System.out.println(S);
		}
	}
}



Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define lld long long
#define pb push_back
#define mk make_pair
#define MAX (lld)1e18+7
#define lim (lld)1e9+7
#define MAX2 (int)2e5+9
#define ff first
#define ss second
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

const lld mod=lim;

lld power(lld x, lld y, lld p)  
{   lld res = 1;     x = x % p; if (x == 0) return 0;  
  
    while (y > 0)  
    { if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;   }  
    return res;  } 


int extend_gcd(int a, int b, int& x, int& y) {
    if (b == 0) { x = 1;y = 0;return a;}
    int x1, y1;
    int d = extend_gcd(b, a % b, x1, y1);
    x = y1; y = x1 - y1 * (a / b);return d;	}

int rowNum[]={-1,0,0,1};
int colNum[]={0,-1,1,0};

int main()
{
	fastio
	int n,k;
	cin>>n>>k;

	std::vector<int> v(n);

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

	sort(v.begin(), v.end());

	int ans=0;

	for(int i=0;i<k;i++)
		ans+=v[i];

	cout<<ans<<endl;
}

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

using LL = long long;

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

  vector<LL> W = {0}, T = {0};
  for(int i = 1; i <= M; ++i) {
    LL w, t;
    cin >> w >> t;
    W.push_back(W.back() + w);
    T.push_back(T.back() + t);
  }

  vector<int> C(N), B(N);
  for(int i = 0; i < N; ++i) cin >> C[i] >> B[i];

  auto weight = [W](int i, int j) {return W[j] - W[i - 1];};
  auto thickness = [T](int i, int j) {return T[j] - T[i - 1];};
  auto lastvolume = [&](LL start, int i) {
    LL low = start - 1, high = M + 1;
    while(high - low > 1) {
      int middle = (low + high) / 2;
      auto w = weight(start, middle) <= C[i];
      auto b = thickness(start, middle) <= B[i];
      if(w & b) low = middle;
      else      high = middle;
    }
    return low;
  };

  const int BIT = 1 << N;
  auto get = [](int bit, int i) {return (bit >> i) & 1;};
  auto set = [](int bit, int i) {return bit | (1 << i);};

  vector<LL> dp(BIT);
  for(int bit = 0; bit < BIT; ++bit) {
    for(int i = 0; i < N; ++i) if(!get(bit, i)) {
      auto nex = set(bit, i);
      dp[nex] = max(dp[nex], lastvolume(dp[bit] + 1, i));
    }
  }
  cout << *max_element(begin(dp), end(dp)) << endl;
}

Measured memory_bytes: 9400
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    string s;
    cin>>s;
    int l1 = s.length();
    int num1 = 0;
    for(int i = l1 - 1; i >= 0; --i){
        num1 += (int)(s[i] - '0') ;
    }
    if(num1%9==0) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 3744
#include <stdio.h>
#define N 100

int main()
{
  int min,i,j,a[N],t=0,n,tmp;

  scanf("%d",&n);
  for(i = 0;i < n;i++) scanf("%d",&a[i]);

  for(i = 0;i < n;i++)
    {
      min = i;
      for(j = i;j < n;j++) if(a[j] < a[min]) min = j;

      if(a[i] != a[min])
	{
	  tmp = a[i];
	  a[i] = a[min];
	  a[min] = tmp;
	  t++;
	}
      
    }

  for(i = 0;i < n;i++)
    {
      if(i > 0) printf(" ");
      printf("%d",a[i]);
    }

  printf("\n%d\n",t);
  
  return 0;
}



Measured memory_bytes: 2128
N = int(input())
A = [int(_) for _ in input().split()]
B = [int(_) for _ in input().split()]


def count(A, B):
    ret = 0
    for i in range(N - 1, -1, -1):
        m = min(A[i + 1], B[i])
        B[i] -= m
        ret += m
        m = min(B[i], A[i])
        A[i] -= m
        ret += m
    return ret


print(max(count(A, B), count(A[::-1], B[::-1])))


Measured memory_bytes: 19156
// #include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <iomanip> // setprecision
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath> // pow

#define int long long

// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define all(v) v.begin(), v.end()
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<decltype(c)::value_type>())
#define SIZE(x) ((int)(x).size())
// union of two containers
template <typename T>
void container_union(T &c1, T &c2, T &c3) {
  std::vector<int> vec;
  std::set_union(c1.begin(), c1.end(),
                 c2.begin(), c2.end(),
                 std::back_inserter(vec));
  T tmp(vec.begin(), vec.end());
  c3 = tmp;
}

// chmax, chmin
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

// grid-search
std::vector<int> dx = {1, -1, 0,  0};
std::vector<int> dy = {0,  0, 1, -1};
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// type alias
using VI = std::vector<int>;
using VII = std::vector<VI>;
using VB = std::vector<bool>;
using VBB = std::vector<VB>;
using VS = std::vector<std::string>;
using PII = std::pair<int, int>;

// yes/no
std::string yes = "Yes";
std::string no = "No";
std::string YES = "YES";
std::string NO = "NO";

void solve();

signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout << std::fixed << std::setprecision(10);
  solve();
  return 0;
}

void solve() {
  int n;
  std::cin >> n;
  std::vector<PII> v(n);
  int x, l;
  REP(i, n) {
    std::cin >> x >> l;
    v.at(i).first = x + l;
    v.at(i).second = x - l;
  }
  ASORT(v);

  // 座標は負にもなり得るので、lastの初期値はあり得る最小の左端よりも小さい値にする
  int last = -10000000000;
  int count = 0;
  REP(i, n) {
    // cout(i << "(" << v.at(i).second << ", " << v.at(i).first << ")");
    if (last <= v.at(i).second) {
      count++;
      last = v.at(i).first;
      // cout("yes");
    }
  }
  cout(count);
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int A=S[0]-'0',B=S[1]-'0',C=S[2]-'0',D=S[3]-'0';
  for(int i=0;i<8;i++){
    int sum=A;
    for(int j=0;j<3;j++){
      if(j==0){
        if(i&1<<j)sum+=B;
        else sum-=B;
      }
      if(j==1){
        if(i&1<<j)sum+=C;
        else sum-=C;
      }
      if(j==2){
        if(i&1<<j)sum+=D;
        else sum-=D;
      }
    }
    if(sum==7){
      cout<<A<<(i&1?"+":"-")<<B<<(i&1<<1?"+":"-")<<C<<(i&1<<2?"+":"-")<<D<<"=7"<<endl;
      return 0;
    }
  }
  return 0;
}


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

using namespace std;

typedef long long LL;

int main() {
    int n;
    vector< pair<int, int> > dir = {
        make_pair(-1, 0),
        make_pair(0, 1),
        make_pair(1, 0),
        make_pair(0, -1)
    };

    while (cin >> n, n) {
        vector< pair<int, int> > c(n);
        c[0] = make_pair(0, 0);

        int maxh = 0, maxw = 0;
        int minh = 0, minw = 0;
        for (int i = 0; i < n - 1; i++) {
            int a, d;
            cin >> a >> d;
            int x = c[a].first + dir[d].first;
            int y = c[a].second + dir[d].second;
            c[i + 1] = make_pair(x, y);
            maxw = max(x, maxw);
            minw = min(x, minw);
            maxh = max(y, maxh);
            minh = min(y, minh);
        }

        cout << maxw - minw + 1 << " " << maxh - minh + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3056
import java.util.Scanner;

public class Main {
  
  public static void main(String[] args) {
    
    Scanner sin = new Scanner(System.in);

    int a = sin.nextInt();
    int b = sin.nextInt();

    if ( a < b) { System.out.println("a < b"); }
    else if ( a > b) { System.out.println("a > b"); }
    else { System.out.println("a == b"); }
  }
}


Measured memory_bytes: 26392
#include<cstdio>
#include<climits>
#include<algorithm>

using namespace std;

typedef long long ll;

int main(){
	int n, k; scanf("%d %d", &n, &k);
	int a[100000], b[100000];
	for(int i = 0; i < n; i++) scanf("%d %d", &a[i], &b[i]);
	ll res = 0;
	for(int i = 0; i < n; i++) if((k | a[i]) <= k) res += b[i];
	for(int i = 0; i < 30; i++) if((k >> i) & 1){
		int t = k & ~((1 << (i + 1)) - 1) | ((1 << i) - 1);
		ll ret = 0;
		for(int j = 0; j < n; j++) if((t | a[j]) <= t) ret += b[j];
		res = max(res, ret);
	}
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int GCD(int i,int j,int l){
    int tmp=__gcd(i,j);
    tmp=__gcd(tmp,l);
    return tmp;
}
int main(){
    int K; cin>>K;
    int sum=0;
    for(int i=1;i<=K;i++){
        for(int j=1;j<=K;j++){
            for(int l=1;l<=K;l++){
                sum=sum+GCD(i,j,l);
            }
        }
    }
    cout<<sum;
    return 0;
}

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

using namespace std;

int main()
{

   string str;
   cin>>str;

   int i =str.length()-1;

   if(str[i]=='s')
   str.append("es");

   else
   {
       str.append("s");
   }
   cout<<str<<endl;
   



    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define INF LLONG_MAX
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int n,m,x,y;
vector<P> vec;
signed main(){
	cin>>n>>m;
	rep(i,n){
		cin>>x>>y;
		vec.push_back({x,y});
	}
	int ans=INF;
	for(P i:vec){
		for(P j:vec){
			for(P a:vec){
				for(P b:vec){
					int cnt=0;
					for(P k:vec){
						if((i.first<=k.first&&k.first<=j.first)||(i.first>=k.first&&k.first>=j.first)){
							if((a.second<=k.second&&k.second<=b.second)||(a.second>=k.second&&k.second>=b.second)){
								cnt++;
							}
						}
					}
					if(cnt>=m){
						ans=min(ans,abs(i.first-j.first)*abs(a.second-b.second));
					}
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
INF = float("inf") #const
MOD = 10**9+7 #const
MAX = 510000 #const

def main():
    n = int(input())
    h = list(map(int,input().split()))
    dp = [INF]*(n+1)
    dp[0] = 0

    for i in range(1,n):
        dp[i] = min(dp[i],dp[i-1] + abs(h[i]-h[i-1]))
        if i > 1:
            dp[i] = min(dp[i],dp[i-2] + abs(h[i]-h[i-2]))
    print(dp[n-1])


if __name__ == "__main__":
    main()


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

#define FOR(i,a,b) for(ll i=a; i<b; i++)
#define IN(a) cin>>a
#define OUT(a) cout<<a<<endl

int main(){
  int x, y;
  IN(x);
  IN(y);
  if(y%2==0&&(2*x<=y&&y<=4*x)){
    OUT("Yes");
  }else{
    OUT("No");
  }

}

Measured memory_bytes: 3596
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	S, C := getInt(), getInt()

	ans := 0
	if S*2 == C {
		ans = S
	} else if S*2 < C {
		ans = (2*S + C) / 4
	} else {
		ans = C / 2
	}
	out(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
double dp[305][305][305];
int n;
int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    cin >> n;
    vector<int> arr(4);
    for (int i=0; i<n; i++){
        int ele;
        cin >> ele;
        arr[ele]++;
    }
    cout.precision(15);
    for (int k=0; k<=arr[3]; k++)
        for (int j=0; j<=arr[2]+arr[3]; j++)
            for(int i=0;  i<=arr[1]+arr[2]+arr[3]; i++){
                if ((i+j+k)==0)
                    continue;
                double val = 1.0*n/(i+j+k);
                dp[i][j][k] = val;
                if (i)
                    dp[i][j][k] += dp[i-1][j][k]*val*i/n;
                if (j)
                    dp[i][j][k] += dp[i+1][j-1][k]*val*j/n;
                if (k)
                    dp[i][j][k] += dp[i][j+1][k-1]*val*k/n;
            }
    cout << dp[arr[1]][arr[2]][arr[3]] << "\n";
}

Measured memory_bytes: 220744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,p;
string s;
ll d[200005],e[200005];
ll a;
ll ans;
int main(void){
	cin>>n>>p>>s;
	ll D=1;
	for(int i=n-1;i>=0;i--){
		a=s[i]-48;
		d[i]=D*a%p;
		D=D*10%p;
	}
	if(p==2||p==5){
		for(int i=0;i<n;i++){
			if((s[i]-48)%p==0){
				ans+=i+1;
			}
		}
		cout<<ans<<endl;
		return 0;
	}
	for(int i=0;i<n;i++){
		e[i+1]=(e[i]+d[i])%p;
	}
	sort(e,e+n+1);
	ll co=1;
	for(int i=0;i<n;i++){
		if(e[i]==e[i+1]){
			co++;
		}else{
			ans+=co*(co-1)/2;
			co=1;
		}
	}
	ans+=co*(co-1)/2;
	cout<<ans<<endl;
	
}


Measured memory_bytes: 3716
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int c = 0;
        for (int i = 0; i < n; i++) {
            if (sc.nextInt() != i + 1) {
                c++;
            }
        }
        System.out.println((c == 0 || c == 2) ? "YES" : "NO");
    }
}

Measured memory_bytes: 23892
import Data.Int (Int64)

solve :: Integral a => a -> a -> a -> a
solve a b c = minimum [f a * b * c, f b * a * c, f c * a * b]
    where f x = mod x 2

main :: IO ()
main = do
    [a, b, c] <- fmap read . words <$> getLine :: IO [Int64]
    print $ solve a b c


Measured memory_bytes: 508
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define sz size()
#define mk make_pair
#define clr clear()
#define B begin()
#define E end()
#define EM empty()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define all(cont) cont.begin(),cont.end()
#define pb push_back
string en="\n";
string t="hello";
#define sqr(a) ((a) * (a))
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef unsigned long long ULL;
bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1;
    while(cin>>n>>m)
    {
        x=__gcd(n,m);
        cout<<x<<en;
    }
}




Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
#define incant() cin.tie(0), ios::sync_with_stdio(false)
#define int long long
#define uint unsigned long long
#define double long double
using str = string;
template <class T> using vec = vector<T>;
template <class T> using vvec = vec<vec<T>>;
template <class T> using que = queue<T>;
template <class T> using pque = priority_queue<T>;
template <class... T> using tup = tuple<T...>;
using vint = vec<int>;
using vvint = vvec<int>;
using vstr = vec<str>;
using pint = pair<int, int>;
using vp = vec<pint>;
using tll = tup<int, int, int>;
using vt = vec<tll>;
using mint = map<int, int>;
using dict = map<str, int>;
using qint = que<int>;
using qp = que<pint>;
using pqint = pque<int>;
using pqp = pque<pint>;
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define left second
#define right first
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define sz(x) x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define ms(v, x) memset(v, x, sizeof(v))
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload3(__VA_ARGS__, revi, _rev,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define space() cout << " "
#define indent() cout << '\n'
#define print(x) out(x), indent()
#define debug(x) cerr << __LINE__ << ": " << #x << ": " << (x) << '\n'
#define YN(x) print((x) ? "YES" : "NO")
#define Yn(x) print((x) ? "Yes" : "No")
#define yn(x) print((x) ? "yes" : "no")
#define POS(x) print((x) ? "POSSIBLE" : "IMPOSSIBLE")
#define Pos(x) print((x) ? "Possible" : "Impossible")
#define pos(x) print((x) ? "possible" : "impossible")
const int INF = LLONG_MAX - INT_MAX, MOD = 1e9 + 7, LIMIT = 100001;
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
// const int dx[] = {-1, 0, 1, -1, 1, -1, 0, 1}, dy[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const double EPS = 1e-9;
int gcd(int a, int b){return b == 0 ? a : gcd(b, a % b);}
int lcm(int a, int b){return a / gcd(a, b) * b;}
int factorial(int a){return a < 2 ? 1 : factorial(a - 1) * a;}
int summation(int a){return a < 1 ? 0 : (a * a + a) / 2;}
int combination(int n, int r){int res = 1; rep(i, 1, r + 1) res *= n--, res /= i; return res;}
const str alphabet = "abcdefghijklmnopqrstuvwxyz";
int a, b, c, k, n, m, x, y, z, w, h, res = 0, cnt = 0, sum = 0, mx = -INF, mn = INF;
str s, t;
bool flag = true;

signed main(){
    incant();
    vp demand;
    cin >> n >> m;
    rep(i, m){
        cin >> a >> b;
        demand.pb(mp(b, a));
    }
    sort(all(demand));
    res = m, cnt = 0;
    rep(i, 1, m){
        if(demand[i].left < demand[cnt].right){
            res--;
        }else{
            cnt = i;
        }
    }
    print(res);
}


Measured memory_bytes: 2420
n, y = map(int,input().split())
r1,r2,r3 = -1,-1,-1
for f in range(n+1):#0 <= f <= n
    for h in range(n-f+1):# 0 <= h <= n-f

        if 10000 * f + 5000 * h + 1000 *( n-(f + h)) == y:

            r1,r2,r3 = f, h, n-(f + h)
            break

print(str(r1) + ' ' + str(r2) + ' ' + str(r3))
        

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node {
   int key;
   Node *prev, *next;
};

Node *nil;

void init(){
   nil = (Node *)malloc(sizeof(Node));
   nil->next = nil;
   nil->prev = nil;
}

void insert(int key){
   Node *x = (Node *)malloc(sizeof(Node));
   x->key = key;

   x->next = nil->next;
   nil->next->prev = x;
   nil->next = x;
   x->prev = nil;
}

void printList(){
   Node *cur = nil->next;
   int isf = 0;
   while(1){
      if (cur == nil) break;
      if (isf++ > 0) printf(" ");
      printf("%d", cur->key);
      cur = cur->next;
   }
   printf("\n");
}

Node* listSearch(int key){
   Node *cur = nil->next;
   while (cur != nil && cur->key != key){
      cur = cur->next;
   }
   return cur;
}

void deleteNode(Node *t){
   if (t == nil) return;
   t->prev->next = t->next;
   t->next->prev = t->prev;
   free(t);
}

void deleteFirst(){
   deleteNode(nil->next);
}

void deleteLast(){
   deleteNode(nil->prev);
}

void deleteKey(int key){
   deleteNode(listSearch(key));
}

int main(){
   int key, n, i;
   int size = 0;
   char com[20];
   int np = 0, nd =0;
   scanf("%d", &n);

   init();
   for (i=0; i<n; i++){
      scanf("%s%d", com, &key);
      if (com[0]=='i'){insert(key); np++; size++;}
      else if (com[0]=='d'){
         if (strlen(com) > 6){
            if(com[6]=='F') deleteFirst();
            else if (com[6]=='L') deleteLast();
         } else {
            deleteKey(key); nd++;
         }
         size--;
      }
   }
   printList();
   return 0;
}







Measured memory_bytes: 33872
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    ll n,m;
    cin>>n>>m;
    if(n==1&&m==1)cout<<1<<endl;
    else if(n==1)cout<<m-2<<endl;
    else if(m==1)cout<<n-2<<endl;
    else cout<<(n-2)*(m-2)<<endl;
    
    return 0;
}


Measured memory_bytes: 256
import sys
N = int(input())
# S = list(map(str,input().split()))
S = list(input())
if N % 2 == 0:
	T_1 = S[:int(len(S)/2)]
	T_2 = S[int(len(S)/2):]
	# print(T_1)
	# print(T_2)
	for i in range(len(T_1)):
		if T_1[i] != T_2[i]:
			print("No")
			sys.exit()	
	print("Yes")
	sys.exit()
else:
	print("No")

Measured memory_bytes: 3060
/*input
1 1000000000000000000 3
*/

#include <iostream>

using namespace std;

int main()
{

	long long a, b, x;
	cin >> a >> b >> x;

	if(a==0 && b==0){
		cout << 1 << endl;
	}else if(a==0){
		cout << (b/x)+1 << endl;
	}else{
		cout << ((b/x) - (a-1)/x) << endl;
	}

	return 0;
}


Measured memory_bytes: 256
loop do
  n = gets.to_i
  break if n==0
  max = max_n = -100000
  r = 0
  n.times do
    m = gets.to_i
    max_n = [max_n, m].max
    r = [r+m, 0].max
    max = [max, r].max
  end
  puts max_n > 0 ? max : max_n
end

Measured memory_bytes: 6088
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  #define int long long
  #define endl "\n"
  const int N = 200005;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>



int32_t main()
{


 
    IOS


    string s;
    cin >> s;

    for(int i = 0; i < s.length(); i++)
    {
        if(s[i] == '?')cout << 'D';
        else cout << s[i];
    }
    




    return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>
#include <regex>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define P pair<int, int>

using namespace std;
//using ll = long long;
using ll = int64_t;

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

void solve(){
    string s;
    int k;
    cin >> s >> k;

    set<string> x;
    for(int i = 0; i < s.length(); i++){
        for(int j = 1; j <= k; j++){
            x.insert(s.substr(i, j));
        }
    }
    int c = 0;
    for(auto itr = x.begin(); itr != x.end(); itr++){
        if(c == k-1){
            cout << *itr << endl;
            return;
        }
        c++;
    }
}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 1664
/* Simplicity and Goodness */

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

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B)
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;


void solve()
{
    int n, k;
    scn(n); scn(k);

    string s;
    cin >> s;

    int ans = 0, cnt = 0;

    for(int i=0; i+1<n; i++) 
        ans += s[i] == s[i+1];

    for(int i = 0; i < n; ) {
        int j = i + 1;
        while(j < n and s[i] == s[j])
            j ++;
        cnt ++;
        i = j;
    }

    while(cnt > 2 and k > 0) {
        cnt -= 2;
        ans += 2;
        k --;
    }

    while(cnt > 1 and k > 0) {
        cnt --;
        ans ++;
        k --;
    }

    prin(ans);
}

int main()
{
    int t = 1;
    // scn(t);
    
    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXN = 2e5 + 3;
ll n,a[MAXN], spre[MAXN], xpre[MAXN];

int main(){
	cin>>n;
	for(ll i=1;i<=n;i++){
		cin>>a[i];
		spre[i] = a[i] + spre[i-1];
		xpre[i] = a[i]^xpre[i-1];
	}

	ll ans = 0;
	for(ll i=1;i<=n;i++){
		ll l = i,r = n + 1;
		while(l<r-1){
			ll mid = (l+r)/2;
			if((spre[mid]-spre[i-1]) == (xpre[mid]^xpre[i-1]))l=mid;
			else r=mid;
		}

		ans += l-i+1;
	}

	cout<<ans<<endl;
}

Measured memory_bytes: 4992
#include<stdio.h>
#define N 2000

int solve(int, int);

int A[N];
int n;

int main()
{
  int m,sum,i;

  scanf("%d",&n);

  for(i = 0; i < n; i++)
    scanf("%d",&A[i]);

  scanf("%d",&m);

  int B[m];

  for(i = 0; i < m; i++)
    {
      scanf("%d",&B[i]);
      sum = solve(0,B[i]);


      if(sum == 1)
	printf("yes\n");
      
      else printf("no\n");
    }
  return 0;
}

 int solve(int i,int m)
    {
	if(m == 0)
	    return 1;

	if(i >= n)
	    return 0;

	int res = solve(i + 1, m) || solve(i + 1, m - A[i]);

	    return res;
    }

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

using namespace std;

vector<vector< int > > g;


signed main(){ 
    //ofstream cout("output.txt");
    //ifstream cin("input.txt");
    int n,w;
    cin>>n>>w;
    vector<int> weight(n);
    vector<int> value(n);
    vector<vector<int> > dp(n+1, vector<int>(w+1,0));
    //cout<<colour[1];
    //cout<<1;
    for (int i = 0; i<n; i++){
        int a,b;
        cin>>a>>b;
        weight[i]=a;
        value[i]=b;
    }
    //cout<<2;
    for(int i =0; i<=n; i++){
        for(int j=0; j<=w; j++){
            if(i==0	|| j==0){
                dp[i][j]=0;
            }
            else if(weight[i-1]<=j){
                dp[i][j] = max(dp[i-1][j],dp[i-1][j-weight[i-1]]+value[i-1]);
            }
            else{
                dp[i][j]= dp[i-1][j];
            }
        }
    }
    
    cout<<dp[n][w];

    

    /*for (int i = 0; i<n; i++){
        for (int a = 0; a<graph[i].size();a++){
            cout<<graph[i][a]<<" ";
        }
        cout<<visited[i];
        cout<<'\n';
    }
    cout<<itworks;
    */
    
    return 0;
}






Measured memory_bytes: 80256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> t(n);
	for (int i = 0; i < n;i++)
		cin >> t[i];
	sort(t.begin(), t.end());
	int min_diff = 1000000000;
	for (int i = 0; i < n - k + 1;i++){
		if((t[i+k-1] - t[i]) < min_diff)
			min_diff = t[i + k - 1] - t[i];
	}
	cout << min_diff << endl;

	return 0;
}


Measured memory_bytes: 640
// ref: https://qiita.com/tubo28/items/e6076e9040da57368845
use std::io::{stdin, Read};
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let c: u32 = read();
    let a: u32 = read();
    let b: u32 = read();
    let ans = c * a / 2;
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define maxn 120
#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x) for(register int i = head[x] ; i ; i = e[i].next)
#define pb push_back
#define prev prev_
#define stack stack_
#define inf 0x3f3f3f3f

typedef unsigned long long ll;

struct node{
	int next,to;
}e[maxn * 2];
int head[maxn],cnt;
int n,dth[maxn],fa[maxn],deg[maxn];
int mx[maxn];
int col;
ll num = 1e18,sum[maxn];

inline void adde(int x,int y){
	e[++cnt].to = y;
	e[cnt].next = head[x];
	head[x] = cnt;
}
void dfs(int x){
	fore(i,x){
		if ( e[i].to == fa[x] ) continue;
		fa[e[i].to] = x , dth[e[i].to] = dth[x] + 1;
		dfs(e[i].to);
	}
}

void dfs(int x,int fa){
	fore(i,x){
		if ( e[i].to == fa ) continue;
		dth[e[i].to] = dth[x] + 1;
		dfs(e[i].to,x);
	}
}
bool legal(int x,int fa){
	return 1;
}
void init(){
	dfs(1);
	int rt = 0,x = 0;
	rep(i,1,n) if ( dth[rt] < dth[i] ) rt = i;
	rep(i,1,n) fa[i] = dth[i] = 0;
	dth[rt] = 1 , dfs(rt);
	rep(i,1,n) if ( dth[x] < dth[i] ) x = i;
	col = (dth[x] + 1) / 2;
	if ( dth[x] & 1 ){
		rep(i,1,col - 1) x = fa[x];
		dth[x] = 0 , dfs(x,0);
		rep(i,1,n) mx[dth[i]] = max(mx[dth[i]],deg[i] - 1);
		sum[col - 1] = 1;
		repd(i,col - 2,1){
			sum[i] = sum[i + 1] * mx[i];
		}
		num = sum[1] * deg[x];
		fore(i,x){
			if ( legal(e[i].to,x) ){
				int mid1 = x , mid2 = e[i].to;
				dth[mid1] = dth[mid2] = 0 , dfs(mid1,mid2) , dfs(mid2,mid1);
				rep(j,0,n) sum[j] = 0 , mx[j] = 0;
				rep(j,1,n) mx[dth[j]] = max(mx[dth[j]],deg[j] - 1);
				sum[col - 1] = 1;
				repd(j,col - 2,0){
					sum[j] = sum[j + 1] * mx[j];
				}
				num = min(num,2ll * sum[0]);
			}
		}
	}
	else{
		int mid1,mid2;
		rep(i,1,col - 1) x = fa[x];
		mid1 = x , mid2 = fa[x];
		dth[mid1] = dth[mid2] = 0 , dfs(mid1,mid2) , dfs(mid2,mid1);
		rep(i,1,n) mx[dth[i]] = max(mx[dth[i]],deg[i] - 1);
		sum[col - 1] = 1;
		repd(i,col - 2,0){
			sum[i] = sum[i + 1] * mx[i];
		}
		num = 2ll * sum[0];
	}
}
int main(){
	
	scanf("%d",&n);
	rep(i,1,n - 1){
		int x,y;
		scanf("%d %d",&x,&y);
		adde(x,y) , adde(y,x);
		deg[x]++ , deg[y]++;
	}
	init();
	cout<<col<<" "<<num<<endl;
}


Measured memory_bytes: 256
n = int(input())
s = input()

a = []
#  .##..#.##.
w = s.count(".")
b = s.count("#")
m = min(w,b)

bb=0

for i in range(n):
    if s[i]=='.':
        w-=1
        a.append(bb+w)
    if s[i]=='#':
        bb += 1
        a.append(bb+w)
if len(a)>0:
    I = min(a)
    print(min(m,I))
else:
    print(m)


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

using ll = long long;
using namespace std;

#define int ll

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define YES(f) if((f)){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(f) if((f)){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(12)

#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);

#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);
#define MOD 1000000007

template<class T>
inline T GET() {
	T x;
	cin >> x;
	return x;
}


void init();
void solve();

signed main()
{
	init();
	solve();
}

void init()
{
	string st;
	cin >> st;
	if (st[5] == '0' && st[6] <= '4') {
		cout << "Heisei" << endl;
	} else {
		cout << "TBD" << endl;
	}
}

void solve()
{
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int iINF = 100100100;
const ll llINF = 1LL << 60;
ll chmin(ll a, ll b)
{
	return a > b ? b : a;
}
int main()
{
	ll n, m;
	cin >> n >> m;
	ll ans = 0;
	vector<ll> v(n);
	rep(i, n) {
		cin >> v[i];
		ans += v[i];
	}
	sort(v.begin(), v.end());
	vector<pair<ll, ll>> change(m);
	rep(i, m) cin >> change[i].second >> change[i].first;	// cでソートしたいので, cをfirstに入れる
	sort(change.rbegin(), change.rend());
	vector<ll> comp;
	int c = 0;
	rep(i, m) {
		rep(j, change[i].second) {
			comp.push_back(change[i].first);
			c++;
			if (c == n)	break;
		}
		if (c == n)	break;
	}
	int s = comp.size();
	rep(i, s) {
		if (v[i] < comp[i])	ans += comp[i] - v[i];
		else break;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6584
# -*- coding: utf-8 -*-
n = int(input())
p = list(map(int, input().split()))

# p[i] != iの個数をカウントして 0 or 2ならpossible
count = 0
for i in range(n):
    if p[i] != i+1:
        count += 1
if count > 2:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
ll A, B, r, k, ans;
int main() {
    scanf("%lld %lld", &A, &B);
    if(A == B) { puts("1"); return 0; }
    for(r = 60; (A >> r) == (B >> r); --r);
    A &= (1LL << (r + 1)) - 1;
    B &= (1LL << (r + 1)) - 1;
    for(k = r - 1; (~B >> k & 1) && k >= 0; --k);
    ll ans = ((1LL << r) - A) + min(1LL << r, (1LL << (k + 1)) + ((1LL << r) - A));
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <set>

using namespace std;

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

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  for (auto &x: a) cin >> x;
  for (auto &x: b) cin >> x;

  a.push_back(b[0]);
  b.push_back(b[0]);
  a.insert(a.begin(), b[n-1]);
  b.insert(b.begin(), b[n-1]);

  priority_queue<pair<ll, int> > que;
  for (int i = 1; i < n+1; i++) que.emplace(b[i], i);
  ll ans = 0;
  while (!que.empty()) {
    auto now = que.top();
    que.pop();
    if (now.first == a[now.second]) continue;
    if (now.first - (b[now.second - 1] + b[now.second + 1]) < a[now.second]) {
      cout << -1 << endl; // impossible
      return 0;
    }
    ans += (b[now.second] - max(max(b[now.second - 1], b[now.second + 1]), a[now.second]) + (b[now.second - 1] + b[now.second + 1]) - 1) / (b[now.second - 1] + b[now.second + 1]);
    b[now.second] -= (b[now.second - 1] + b[now.second + 1]) * ((b[now.second] - max(max(b[now.second - 1], b[now.second + 1]), a[now.second]) + (b[now.second - 1] + b[now.second + 1]) - 1) / (b[now.second - 1] + b[now.second + 1]));
    if (now.second == 1) b[n+1] = b[1];
    else if (now.second == n) b[0] = b[n];
    que.emplace(b[now.second], now.second);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 13000
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,x,t;
    cin>>n>>x>>t;
    cout<<(n-1)/x*t+t<<'\n';
}

Measured memory_bytes: 3624
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();

		System.out.printf("%d %d %.10f\n", a/b,a%b,(double)a/(double)b);
	}
}



Measured memory_bytes: 26616
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		System.out.println(Curtain(a,b));
	}

	private static int Curtain(int a, int b) {
		if(a-(2*b)>0) {
			return a-(2*b);
		}else {return 0;}
	}

}


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

int main(){
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;

    if ( a1 + a2 + a3 >= 22 ) {
        cout << "bust" << endl;
    }
    else {
        cout << "win" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import numpy as np 
N=int(input())
a=np.array(list(map(int, input().split())))
ans=0
mod=10**9+7
for i in range(60):
   s=np.count_nonzero(a>>i&1)
   ans+=pow(2,i,mod)*s*(N-s)%mod
   ans%=mod
print(ans)

Measured memory_bytes: 68616
<?php
list($n, $k) = explode(" ", trim(fgets(STDIN)));
list($R, $S, $P) = explode(" ", trim(fgets(STDIN)));
$t = str_split(trim(fgets(STDIN)));

$r=0;
$s=0;
$p=0;
$change = [];
for($i=0;$i<$n;$i++){
  if($i >= $k){
    if($t[$i]==$t[$i-$k] && !isset($change[$i-$k])){
      $change[$i]=true;
      continue;
    }
  }
  if($t[$i]=="r") $r++;
  if($t[$i]=="s") $s++;
  if($t[$i]=="p") $p++;
}

$ans = $r*$P+$s*$R+$p*$S;
echo $ans;

Measured memory_bytes: 14840
/*Divyam Goyal - IIT-BHU*/
#include<bits/stdc++.h>
using namespace std;

#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define bitcount    __builtin_popcountll
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define ll long long
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define pb(x) push_back(x)
#define MOD 1000000007
#define MAX 100005



int main()
{
    //ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin>>n;

	int a=0;
	int ans=0;

	for(int i=1;i<=n;i++)
	{
		int x,y;
		cin>>x>>y;
		if(x>a)
		{
			a=x;
			ans=y;
		}
	}

	cout<<a+ans;






    return 0;


}

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

int main() {
    string s;
    while (cin >> s) {
        vector<vector<int> > vv;
        vector<int> v;
        int st = -1;
        for (string::iterator it = s.begin(); it != s.end(); ) {
            if (*it == 'e') {
                if (st == 1) {
                    vv.push_back(v);
                    v.clear();
                }
                v.push_back(1);
                st = 1;
                it += 3;
            } else if (*it == 'c') {
                if (st == 2) {
                    vv.push_back(v);
                    v.clear();
                }
                v.push_back(2);
                st = 2;
                it += 7;
            }
        }
        vv.push_back(v);
        int max_vsize = vv[0].size(), idx = 0;
        for (int i = 1, size = vv.size(); i < size; i++) {
            int vsize = vv[i].size();
            if (max_vsize < vsize) {
                max_vsize = vsize;
                idx = i;
            }
        }
        if (vv[idx].back() == 1) {
            cout << "egg" << endl;
        } else {
            cout << "chicken" << endl;
        }
    }
}

Measured memory_bytes: 1236
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
    int box[10][10];
    char str[12];
    while(cin>>str){
        for(int i=0;i<10;i++){
            for(int j=0;j<10;j++){
                if(str[i]=='0'+j){
                    box[0][i]=j+1;
                    break;
                }
            }
        }
        for(int i=1;i<10;i++){
            for(int j=0;j<10-i;j++){
                if(box[i-1][j]+box[i-1][j+1]>=10)box[i][j]=box[i-1][j]+box[i-1][j+1]-10;
                else box[i][j]=box[i-1][j]+box[i-1][j+1];
            }
        }
      /*  for(int i=1;i<10;i++){
            for(int j=0;j<10-i;j++){
                cout<<box[i][j]<<" ";
            }
            cout<<endl;
        }*/
        cout<<box[9][0]-2<<endl;
    }
}

Measured memory_bytes: 1140
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		char[]s = sc.next().toCharArray();
		for(int i=0;i<s.length;i++){
			s[i] = (char)(((s[i]-'A')-3+26)%26 + 'A');
		}
		System.out.println(s);
	}

}

Measured memory_bytes: 17308
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

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; }
const int INF = (1 << 29);
const long long INFL = (1LL<<60);
const double eps = (1e-9);

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
  return (x / gcd(x, y)) * y;
}

int main(int argc, char* argv[])
{
  int n;
  cin >> n;

  ll ans = 1;
  rep(i, n) {
    ll t;
    cin >> t;
    ans = lcm(ans, t);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256