akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#include <bits/stdc++.h>
#define pb(X) push_back(X)
#define x first
#define y second
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define int long long
using namespace std;

const int Max = 1e5 + 7;
int n, m, now;
int u[Max], v[Max], Ans[Max];

struct DSU {
	int connected;
	int par[Max], Sz[Max];
	
	void init(int n) {
		for (int i = 1; i <= n; ++i) {
			par[i] = i;
			Sz[i] = 1;
		}
		connected = n;
	}
	
	int getPar(int k) {
		while (k != par[k]) {
			par[k] = par[par[k]];
			k = par[k];
		}
		return k;
	}
	
	int getSize(int k) {
		return Sz[getPar(k)];
	}
	
	void unite(int u, int v) {
		int par1 = getPar(u), par2 = getPar(v);
		if (par1 == par2) {
			return;
		}
		--connected;
		if (Sz[par1] > Sz[par2]) {
			swap (par1, par2);
		}
		
		now -= Sz[par1] * Sz[par2];
		Sz[par2] += Sz[par1];
		Sz[par1] = 0;
		par[par1] = par2;
	}
} A;
main() {
	INIT
	cin >> n >> m;
	A.init(n);
	now = n * (n - 1) / 2;
	for (int i = 1; i <= m; ++i) {
		cin >> u[i] >> v[i];
	}
	for (int i = m; i >= 1; --i) {
		Ans[i] = now;
		A.unite(u[i], v[i]);
	}
	for (int i = 1; i <= m; ++i) {
		cout << Ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 5248
import java.util.*;

//update 2019/12/13

public class Main{

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {

    int n = nextInt();  int k = nextInt();
    int r = nextInt();  int s = nextInt();  int p = nextInt();
    String t = next();

    long ans = 0;

    String[] machine = splitString(t);

    //理想の手
    String[] ideal = win(machine);

    for(int i=0;i<k;i++){
      if(ideal[i].equals("p")){
        ans += p;
      }
      else if(ideal[i].equals("r")){
        ans += r;
      }
      else if(ideal[i].equals("s")){
        ans += s;
      }
    }

    //制限の調整
    for(int i=k;i<n;i++){
      int mae = i-k;
      if(ideal[mae].equals(ideal[i])){ //k回前と同じなら
        //書き換えないと後に響く
          ideal[i] = "-";
      }
      else{ //k回前と同じでないなら、
        if(ideal[i].equals("p")){
          ans += p;
        }
        else if(ideal[i].equals("r")){
          ans += r;
        }
        else if(ideal[i].equals("s")){
          ans += s;
        }
      }
    }

    System.out.println(ans);


/*
    for(int i=0;i<n;i++){
      System.out.println("machine["+i+"]="+machine[i]);
    }
    for(int i=0;i<n;i++){
      System.out.println("real["+i+"]="+ideal[i]);
    }
*/

  }

  static String[] win(String[] machine){
    int lng = machine.length;
    String[] ideal = new String[lng];
    for(int i=0;i<lng;i++){
      if(machine[i].equals("r")){
        ideal[i] = "p";
      }
      else if(machine[i].equals("s")){
        ideal[i] = "r";
      }
      else if(machine[i].equals("p")){
        ideal[i] = "s";
      }
    }
    return ideal;
  }


  static String next(){
    return sc.next();
  }

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

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

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char aaa){
    return aaa - 48;
  }

  public static int maxInt(int[] a,int lng){
    int max=a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }

  public static int minInt(int[] a,int lng){
    int min=a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }

  public static long maxLong(long[] a,int lng){
    long max=a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }

  public static long minLong(long[] a,int lng){
    long min=a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }

}


Measured memory_bytes: 33844
<?php
    while ( ! feof(STDIN) ) {
        $num[] = trim(fgets(STDIN));
    }
    for($i = 0; $i < count($num); $i++){
        if($num[$i] == 0){
            $a = $i - 1;
            echo $num[$a] ."\n";
            unset($num[$i]);
            unset($num[$a]);
            $num = array_values($num);
            $i = 0;
        }
    }   
?>


Measured memory_bytes: 9276
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();  
        int X, Y, Z, K;
        {int[] a = r.ii(); X = a[0]; Y = a[1]; Z = a[2]; K = a[3];}
        long[] A = r.ll();
        long[] B = r.ll();
        long[] C = r.ll();
        long[] D = new long[106307];
        
        Arrays.sort(A);
        Arrays.sort(B);
        Arrays.sort(C);
        
        int l = 0;
        for(int i = 0; i < X; i++)
            for(int j = 0; j < Y; j++)
                for(int k = 0; k < Z; k++)
                    if((i+1)*(j+1)*(k+1) <= K)
                        D[l++] = A[X-1-i]+B[Y-1-j]+C[Z-1-k];
                    else
                        break;
        Arrays.parallelSort(D, 0, l);
        
        StringBuilder sb = new StringBuilder();
        for(int i = l; i > l-K; i--)
            sb.append(D[i-1]+"\n");
        print(String.valueOf(sb));
    }

    static void print(Object o){
        System.out.print(o.toString());
    }

    static void println(Object o){
        System.out.println(o.toString());
    }

    static int Int(String s){
        return Integer.parseInt(s);
    }

    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s() throws IOException{
            return readLine();
        }

        String[] ss() throws IOException{
            return s().split(" ");
        }

        int i() throws IOException{
            return Int(s());
        }

        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }

        long l() throws IOException{
            return Long(s());
        }

        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

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

int main() {
  int n,m;cin>>n>>m;
  vector<vector<char>> a(n,vector<char>(n)),b(m,vector<char>(m));
  rep(i,n)rep(j,n)cin>>a[i][j];
  rep(i,m)rep(j,m)cin>>b[i][j];
  rep(i,n-m+1)rep(j,n-m+1){
    bool ans=true;
    if(a[i][j]==b[0][0]){
      rep(k,m)rep(l,m){
        if(a[i+k][j+l]!=b[k][l])ans=false;
      }
    }
    else continue;
    if(ans){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3576
N, W = map(int, input().split())
items = [list(map(int, input().split())) for _ in range(N)]

# dp[i+1][w]: 重さwを超えないようにi番目まで選んだときの価値の合計の最大値
dp = [[0] * (W+1) for _ in range(N+1)]
for i in range(N):
    for w in range(W+1):
        dp[i+1][w] = max(dp[i][w-items[i][1]] + items[i][0], dp[i][w]) if w >= items[i][1] else dp[i][w]
print(dp[N][W])


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

typedef long long ll;

void solve(long long A, long long B, long long C, long long K){
    ll ans;
    if(K % 2 != 0) ans = - A + B;
    else ans = A - B;
    cout << ans << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long K;
    scanf("%lld",&K);
    solve(A, B, C, K);
    return 0;
}


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

int main(){
    while(1){
        int a;
        cin >> a;
        if(a == 0) break;
        int sum = 0;
        for(int i=0; i<9; i++){
            int b;
            cin >> b; 
            sum += b;
        }
        cout << a-sum << endl;
    }

    return 0;
}



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

int main() {
   int D,T,S;
   std::cin >> D >> T >> S;
   double n = (double)D / S;
   if (n <= T) {
      std::cout << "Yes" << '\n';
   } else {
      std::cout << "No" << '\n';
   }
}


Measured memory_bytes: 3628
import java.util.*;

public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	String s = sc.next();
        int res = 0;
      	if ("SUN".equals(s)) res = 7;
      	if ("MON".equals(s)) res = 6;
      	if ("TUE".equals(s)) res = 5;
      	if ("WED".equals(s)) res = 4;
      	if ("THU".equals(s)) res = 3;
      	if ("FRI".equals(s)) res = 2;
      	if ("SAT".equals(s)) res = 1;
      	System.out.println("" + res);
    }
}

Measured memory_bytes: 22868
//#pragma comment(linker, "/stack:200000000") //  (UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")  // $ (UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define endl "\n"
#define int long long
#define ll long long
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define fi first
#define se second
#define vi vector<int>
#define vii vector< vector<int> >
#define vpi vector< pair<int,int> >
#define pair <int, int> pii

typedef tree< int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>
    ordered_set;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the iterator to kth largest element.(0-based)

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<"  ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

int modpow(int x, int n, int mod)
{
	x %= mod ;
	int res = 1;
	while(n > 0) {
		if(n & 1)
			res = res * x % mod ;
		x = x * x % mod ;
		n >>= 1 ;
	}
	return res;
}

const long long inf = 2e18 ;
const int mod = 1e9+7 ;
// const int mod = 998244353 ;
const int N = 1e5 + 10 ;

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

        int a,b ; 
	cin >> a >> b ; 

	if( a<=9 && a>=1 && b<=9 && b>=1 )
	{
		cout << a*b << endl ; 
	}
	else
	{
		cout << "-1" ; 
	}
	

return 0 ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
#define MOD 1000000007
typedef long long ll;
//------------------------------------------------------------------------

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

  int k,n; cin >> k >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  vector<int> r(n);
  rep1(i,n-1){
    r[i] = abs(a[i]-a[i-1]);
  }
  r[0] = a[0] + abs(k-a[n-1]);
  sort(all(r));

  ll ans = 0;
  rep(i,n-1){
    ans+=r[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main (){
  int N,K;
  int ans = 0;
  cin >>N>>K;
  int s[N];
  for (int i=0; i<N; i++){
    cin >> s[i];
    if (s[i] >= K-s[i]){
      ans += (K-s[i]);
    }
    else{
      ans += s[i];
    }
  }
  printf("%d", 2*ans);
}

Measured memory_bytes: 256
S = input()
se = set()
for s in S:
    se.add(s)
if len(S) < 26:
    for i in range(26):
        s = chr(ord('a')+i)
        if not s in se:
            print(S+s)
            exit()
else:
    while len(S) > 1:
        se.remove(S[-1])
        S = S[:-1]
        for i in range(ord(S[-1]), ord('z')+1):
            s = chr(i)
            if not s in se:
                print(S[:-1]+s)
                exit()
print(-1)


Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,a,b;
    int ans=0;
    cin >> n>>a>>b;
    for(int i =1;i<=n;i++){
        int sum=0;
        int num =i;
        while(num !=0){
            sum += num%10;
            num /= 10;
        }
        if(a <= sum && sum <= b){
            ans += i;
        }
        // cout << sum<<endl;
    }
    cout << ans<<endl;
}

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

typedef long long ll;

using namespace std;

int main(){
    int N,L;
    cin >> N >> L;
    int sum = 0;
    int mini = 1000000000;
    int ans = 0;
    for(int i = 1; i <= N ; i++){
        int deli = L + i - 1;
        sum += deli;
        int dai = abs(deli);
        if(mini > dai){
            ans = deli;
            mini = dai;
        } 
    }
    cout << sum - ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100000

int parent (int i){ return i/2;}
int left(int i){ return 2*i;}
int right(int i){return 2*i+1;}

int main(){
  int H, i, A[MAX+1];

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

  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i, A[i]);
    if(parent(i) >= 1) printf("parent key = %d, ", A[parent(i)]);
    if(left(i) <= H) printf("left key = %d, ",A[left(i)]);
    if(right(i) <= H) printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2104
def dfs(f, i, j)
    return f if f[i][j] == 0
    f[i][j] = 0
    if i.between?(0, f.size-2) && j.between?(0, f[0].size-2) && f[i+1][j+1] == 1
        f = dfs(f, i+1, j+1)
    end
    if i.between?(0, f.size-2) && j.between?(0, f[0].size-1) && f[i+1][j] == 1
        f = dfs(f, i+1, j)
    end
    if i.between?(0, f.size-2) && j.between?(1, f[0].size-1) && f[i+1][j-1] == 1
        f = dfs(f, i+1, j-1)
    end
    if i.between?(0, f.size-1) && j.between?(0, f[0].size-2) && f[i][j+1] == 1
        f = dfs(f, i, j+1)
    end
    if i.between?(0, f.size-1) && j.between?(1, f[0].size-1) && f[i][j-1] == 1
        f = dfs(f, i, j-1)
    end
    if i.between?(1, f.size-1) && j.between?(0, f[0].size-2) && f[i-1][j+1] == 1
        f = dfs(f, i-1, j+1)
    end
    if i.between?(1, f.size-1) && j.between?(0, f[0].size-1) && f[i-1][j] == 1
        f = dfs(f, i-1, j)
    end
    if i.between?(1, f.size-1) && j.between?(1, f[0].size-1) && f[i-1][j-1] == 1
        f = dfs(f, i-1, j-1)
    end
    return f
end

loop do
    m, n = gets.split.map(&:to_i)
    break if m == 0 && n == 0
    f = n.times.map{gets.split.map(&:to_i)}
    count = 0
    f.each_with_index do |r,i|
        r.each_with_index do |c,j|
            next if c == 0
            f = dfs(f, i, j)
            count += 1
        end
    end
    puts count
end

Measured memory_bytes: 6452
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In,' '));
        }

        public void Solve(ConsoleInput cin)
        {
            long N = cin.ReadLong;
            long M = cin.ReadLong;
            long Money = 0;
          	long count = 0;
            List<Info> list = new List<Info>();
            for(int i=0;i<N;i++){
                list.Add(new Info(cin.ReadInt,cin.ReadInt));
            }

            foreach (var info in list.OrderBy(info => info.Price))
            {
                if(count + info.Num > M){
                    Money += info.Price * (M - count);
                  	break;
                }
                Money += info.Price * info.Num;
                count += info.Num;
			}
            WriteLine(Money);
        }

    }
    class Info
    {
        public long Price;
        public long Num;

        public Info(long price , long num){
            this.Price = price;
            this.Num = num;
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream,char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0;i < tmp.Length;i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }

}

Measured memory_bytes: 26052
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper


print('ABC{:03d}'.format(int(input())))


Measured memory_bytes: 3572
#include <stdio.h>
#include <stdlib.h>
int main(void){
    // Your code here!
    int N,A,max = -1,semimax = -2,maxindex = 0;
    scanf("%d",&N);
    for(int i = 0; i < N; i++)
    {
        scanf("%d",&A);
        if(A > max)
        {
            semimax = max;
            max = A;
            maxindex = i;
        }
        else if(A > semimax)
        {
            semimax = A;
        }
    }
    for(int i = 0; i < N; i++)
    {
        if(i == maxindex)
            printf("%d\n",semimax);
        else
            printf("%d\n",max);
    }
}


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

int main()
{
    int n, X, Y;
    cin>>n>>X>>Y;
    int arr[n];
    for(int i=0; i<n; i++)
    {
        arr[i]=0;
    }
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            int x = min(abs(j-i), min((abs(X-i) + 1 + abs(Y-j)), (abs(Y-i) + 1 + abs(X-j))));
            arr[x]++;
        }
    }
    for(int i=1; i<n; i++)
        printf("%d\n", arr[i]/2);
}

Measured memory_bytes: 256
n = int(input())
cnt = 0
flag = 0
for i in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        cnt += 1
        if cnt == 3:
            flag = 1
            break
    else:
        cnt = 0

if flag == 0:
    print('No')
else:
    print('Yes')
        

Measured memory_bytes: 9040
#include <stdio.h>
#define ll long long

int main(){
	ll n,a,b;
	scanf("%lld%lld%lld",&n,&a,&b);
	if(n==1)printf("%d",a==b);
	else if(a>b)puts("0");
	else printf("%lld",(b-a)*(n-2)+1);
}

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

int main() {
  int K, N, l[60];
  cin >> N >> K;
  for(int i=0; i<N; i++) cin>>l[i];

  sort(l, l+N, greater<int>());

  int sum=0;
  for(int i=0; i<K; i++) sum+=l[i];
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;


ll attack(ll r) {
  if (r == 1) {
    return 1;
  }
  ll half = floor(r/2);
  return 1 + 2*attack(half);
}

int main() {
  ll H; cin >> H;
  cout << attack(H) << endl;
  return 0;
}

Measured memory_bytes: 256
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

N = int(input())
d = list(map(int, input().split()))

d = sorted(d)

m = d[N//2-1]
M = d[N//2]
print(M-m)






Measured memory_bytes: 90296
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

n=int(input())
if n==1:
    print(1)
    exit()
d=defaultdict(int)
for i in range(2,n+1):
    tmp=factorization(i)
    for j in tmp:
        yaku,ko=j
        d[yaku]+=ko
# print(d)
ans=1
for i in d.values():
    ans*=i+1
    ans%=mod
print(ans)

Measured memory_bytes: 67304
#include <cstdio>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;

typedef vector<int> vi;
typedef long long ll;
typedef vector<ll> vl;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define ALL(a) (a).begin(),a.end()
#define MAXE(a) *max_element(ALL(a))
#define MINE(a) *min_element(ALL(a))

int main(){
  ll k,x;
  cin >> k >> x;
  ll p1 = x-(k-1);
  ll p2 = x+(k-1)+1;
  if(p1<-1000000)p1=1000000;
  for(int i = p1;i<p2&&i<1000001;i++){
    cout << i << " ";
  }
  cout << endl;
}
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long N,ans = 0;
    cin >> N;
    for(int i = 1; i < N; i++){
        for(int j = 1; j <= N/i; j++){
            if(i*j != N) ans++;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

namespace {

#define VEVE(i, a, b) for (ll i = a, __##i = b; i < __##i; ++i)
#define DYDY(i, a, b) for (ll i = a, __##i = b; i > __##i; --i)
#define RARA(x, seq) for (auto &x : seq)
#define SIZE(x) ((ll)(x.size()))
#define ALL(x) x.begin(), x.end()

typedef int ll;
typedef double dd;

void Solve(ll) {
  ll n;
  string str;
  if (not(cin >> n >> str))
    return;
  ll all[2] = {0, 0};
  RARA(c, str) ++all[c == 'W'];
  ll res = n, cnt[2] = {0, 0};
  RARA(c, str) {
    res = min(res, cnt[1] + all[0] - cnt[0] - (c == 'E'));
    ++cnt[c == 'W'];
  }
  cout << res << endl;
}

void Init() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
}
}

int32_t main() {
#ifdef AZN
  freopen("input.txt", "r", stdin);
#endif
  Init();
  ll tests = 11;
  VEVE(test, 1, tests + 1) Solve(test);
  return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int a,b;
  cin >> a>>b;
  cout<<a*b<<endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<55)+1e9; // ~ 3.6 * 1e16
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> &a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
template<class T>void prArr(T a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int n;
  cin>>n;

  vector<string> A(n);
  cin>>A;

  vector<Int> dp(30,INF);
  dp[A[0][0] - 'a'] = 1;
  for(Int i=1;i<n;i++) Min(dp[A[i][0] - 'a'], dp[A[i-1][0] - 'a'] + 1);
  Int ans = dp[A[n-1][0] - 'a'];
  cout<<ans<<endl;
  return 0;
}



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

int main() {
	string o, e, s;
	cin >> o >> e;
		
	for (int i = 0; i < o.size(); i++) {
		cout << o[i];
		if(i < e.size()) cout << e[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<cstdlib>
#define ll long long
#define lowbit(x) (x&(-x))
using namespace std;

const ll mod=1e9+7;
ll C,n,k,a[100007],ans,d[100007];

ll Ni(ll x){
    ll p=mod-2,ans=1;
    for (;p;p>>=1){
        if (p&1) ans=(ans*x)%mod;
        x=(x*x)%mod;
    }
    return ans;
}

void Init(){
    d[k-1]=1;
    for (int i=k;i<n;++i)
        d[i]=d[i-1]*i%mod*Ni(i+1-k)%mod;
}

int main(){
    scanf("%lld%lld",&n,&k);
    Init();
    for (int i=1;i<=n;++i)
        scanf("%lld",&a[i]);
    sort(a+1,a+n+1);
    for (int i=1;i<=n;++i)
        ans=(ans+d[i-1]*a[i]%mod)%mod,ans=(ans-d[n-i]*a[i]%mod)%mod;;
    ans=(ans%mod+mod)%mod;
    printf("%lld\n",ans);
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int main(){
  string S, T;
  cin >> S >> T;

  map<char,char> memo;

  bool flg = true;
  rep(i,S.size()){
    if(memo.count(S[i]) > 0){
      if(memo[S[i]] != T[i]) flg = false;
    }
    memo[S[i]] = T[i];
  }

  string str = "";
  FOR(it,memo){
    str += it->first;
  }

  map<char,int> used;
  rep(i,str.size()){
    char c = str[i];
    char nc = memo[c];
    if(used.count(nc) > 0) flg = false;
    used[nc] = 1;
  }

  if(flg) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 776
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))

n, m = map(int, input().split())
h = list(map(int, input().split()))
ans = [True for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    if h[a - 1] >= h[b - 1]:
        ans[b - 1] = False
    if h[a - 1] <= h[b - 1]:
        ans[a - 1] = False
cnt = 0
for x in ans:
    if x: cnt += 1
print(cnt)

Measured memory_bytes: 21656
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
int n,c,k,ans,x,b;
int t[100005];
int main(void){
    scanf("%d%d%d",&n,&c,&k);
    for(int i=0;i<n;i++)scanf("%d",t+i);
    sort(t,t+n);
    x=c+1;
    for(int i=0;i<n;i++){
        if(++x>c||b+k<t[i]){
            ans++;
            x=1;
            b=t[i];
        }
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 640
// https://atcoder.jp/contests/abc115/tasks/abc115_b

#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))

int main() {
    int n, sum = 0;
    cin >> n;
    int price[n];

    if (n > 0) {
        for (int i = 0; i < n; i++) {
            cin >> price[i];
        }
        sort(price, price + n);

        for (int i = 0; i < n; i++) {
            if (i == n - 1) {
                sum += price[i] / 2;
            } else {
                sum += price[i];
            }
        }
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
signed main(){
  int numa , numb , m , a[100005] , b[100005] , mina , minb , x , y , c , ans;
  cin>>numa>>numb>>m;
  for(int i=0;i<numa;i++){
    cin>>a[i];
    if(i == 0){
      mina=a[i];
    } else {
      mina=min(mina,a[i]);
    }
  }
  for(int i=0;i<numb;i++){
    cin>>b[i];
    if(i == 0){
      minb=b[i];
    } else {
      minb=min(minb,b[i]);
    }
  }
  ans=mina+minb;
  for(int i=0;i<m;i++){
    cin>>x>>y>>c;
    ans=min(ans,a[x-1]+b[y-1]-c);
  }
  cout<<ans<<endl;
  return(0);
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <set>
 
using namespace std;
 
#define MAX 1500
 
int cnt[MAX*MAX];
 
int main(){
    int N, M;
 
    while(scanf("%d %d" ,&N ,&M), (N | M)){
	int h[MAX], w[MAX];
	memset(cnt, 0, sizeof(cnt));
	for(int i = 0 ; i < N ; i++){      
	    scanf("%d" ,&h[i]);
	}
 
	set<int> st;
	for(int i = 0 ; i < N ; i++){
	    int S = 0;
	    for(int j = i ; j < N ; j++){
		S += h[j];
		st.insert(S);
		cnt[S]++;
	    }
	}
	for(int i = 0 ; i < M ; i++){
	    scanf("%d" ,&w[i]);
	}
	int ans = 0;
	for(int i = 0 ; i < M ; i++){
	    int S = 0;
	    for(int j = i ; j < M ; j++){
		S += w[j];
		if(st.count(S)){
		    ans += cnt[S];
		}
	    }
	}
	printf("%d\n" ,ans);
    }
    return 0;
}

Measured memory_bytes: 24888
q,h,s,d=map(int, input().split())
n = int(input())
q*=4
h*=2
t = min(q, h, s)
ans=0
while n!=0:
    if n==1:
        ans+=t
        break
    if n%2==1:
        if 2*t < d:
            ans+=2*t*(n-1)//2
            n=1
        else:
            ans+=d*(n-1)//2
            n=1
    else:
        if 2*t < d:
            ans+=t*(n)
            n=0
        else:
            ans+=d*(n)//2
            n=0

print(ans)


Measured memory_bytes: 3064
import sys
X=int(input())
l=[i**5 for i in range(1000)]
for i in range(1000):
    for j in range(-999,0):
        if l[i]+l[j*-1]==X:
            print(i,j)
            sys.exit()
    for j in range(i):
        if l[i]-l[j]==X:
            print(i,j)
            sys.exit()

Measured memory_bytes: 9116
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int N=10000;
string  a,b;
int main()
{
	int len1,len2,flag;
	getline(cin,a);
	len1=a.size();
	getline(cin,b);
	len2=b.size();
	flag=0;
	for(int i=0;i<len2;i++)
	{
		for(int k=0;k<len1;k++)
		{
			if(a[k]<b[i])
			{
				flag=1;
				cout<<"Yes\n"<<endl;
				break;
			}
			else
				flag=2;
		}
		if(flag==1)
			break;
	}
	if(flag==2)
	{
		int f=0;
		for(int j=0;j<len1;j++)
			{
				if(a[0]==a[j])
				f++;
			}
		for(int j=0;j<len2;j++)
			{
				if(a[0]==b[j])
				f++;
			}
			if(f==len1+len2&&len1<len2)
				cout<<"Yes"<<endl;
			else
		cout<<"No\n"<<endl;
	}
}

Measured memory_bytes: 256
/*
进行列的翻转操作之后，合法的矩形一定满足每一行的颜色都相等（无所谓黑白，因为可以有行操作来调整）
每一行颜色相等等价于该行任意相邻两个格子颜色相等，等价于两个格子对应的列的翻转情况是 / 否相等
相当于有一些限制，同时两个相邻格子对应的列在每一行的限制都相等 
故可以直接转化成一个最大子矩形问题 
*/

#include <stack>
#include <cstdio>
#include <algorithm>

using namespace std;
const int Max_NM(2050);

int N, M, rev[Max_NM][Max_NM], up[Max_NM][Max_NM];
char S[Max_NM];

void init()
{
	scanf("%d%d", &N, &M);
	for (int i = 1;i <= N;++i)
	{
		scanf("%s", S + 1);
		for (int j = 2;j <= M;++j)
			rev[i][j] = (S[j - 1] != S[j]), up[i][j] = (rev[i][j] == rev[i - 1][j] ? up[i - 1][j] : 0) + 1; 
	}
}

int L[Max_NM], R[Max_NM];
void work()
{
	int Ans(N);
	for (int i = 1;i <= N;++i)
	{
		stack<int> S;
		for (int j = 2;j <= M;++j)
		{
			while (S.empty() == false && up[i][S.top()] > up[i][j])
				R[S.top()] = j - 1, S.pop();
			S.push(j);
		}
		while (S.empty() == false)
			R[S.top()] = M, S.pop();
		for (int j = M;j >= 2;--j)
		{
			while (S.empty() == false && up[i][S.top()] > up[i][j])
				L[S.top()] = j + 1, S.pop();
			S.push(j);
		}
		while (S.empty() == false)
			L[S.top()] = 2, S.pop();
		for (int j = 2;j <= M;++j)
			Ans = max(Ans, up[i][j] * (R[j] - L[j] + 2));
	}
	printf("%d", Ans);
}

int main()
{
	init();
	work();
	return 0;
}

Measured memory_bytes: 33024
N = int(input())
h = list(map(int, input().split()))

dp = [float("inf") for _ in range(N)]

def cost(k, l):
  return abs(h[k] - h[l])
dp[0] = 0
dp[1] = cost(1,0)

for i in range(1, N):
  dp[i] = min(dp[i - 1] + cost(i, i-1), dp[i - 2] + cost(i, i-2))

print(dp[N -1])

Measured memory_bytes: 13976
import java.util.*;
//import java.util.Math.*;

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

    Scanner sc = new Scanner(System.in);
    int n;
    int q;
    int i,j;
    int count = 0;
    
    n = sc.nextInt();
    int N[] = new int[n];
    for(i = 0; i < n; i++){
        N[i] = sc.nextInt();
    }
    
    q = sc.nextInt();
    int Q[] = new int[q];
    for(i = 0; i < q; i++){
        Q[i] = sc.nextInt();
    }

    for(i = 0; i < q; i++){
        for(j = 0; j < n; j++){
            if(N[j] == Q[i]){
                count++;
                break;
            }
        }
    }
    System.out.println(count);
    
    
    

    }

}



Measured memory_bytes: 40440
import sys
from collections import Counter


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instr = lambda: sys.stdin.readline()
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()
c = instr()
ans = 0

t = {"R":0, "W":0}

for i in range(n):
    t[c[i]] += 1

num_r = t["R"]

for i in range(num_r):
    if c[i] == "W":
        ans += 1

print(ans)


Measured memory_bytes: 68256
#include<bits/stdc++.h>
#define ll long long
#define R register
#define int long long
using namespace std;
const int N = 2e6+200;
const int mod = 1e9+7;
template <class Ruby> inline void read(Ruby &x)
{
	x=0;
	char ch=getchar(), w=0;
	while(!isdigit(ch))w=(ch=='-'), ch=getchar();
	while(isdigit(ch))x=(x<<1)+(x<<3)+(ch^48), ch=getchar();
	x=w?-x:x;
}
inline int quickpow(int base, int w){
	int ans=1;
	while(w)
	{
		if(w&1)ans=ans*base%mod;
		base=base*base%mod, w>>=1;
	}
	return ans;
}
int n, m, val[N], fac[N], inv[N];
inline int C(int n, int m){if(n<m)return 0;return fac[n]*inv[m]%mod*inv[n-m]%mod;}
signed main()
{
	read(n), read(m);
	for(R int i=1; i<=n; i++)read(val[i]);
	fac[0]=1;  for(R int i=1; i<N; i++)fac[i]=fac[i-1]*i%mod;
	inv[N-1]=quickpow(fac[N-1], mod-2); for(R int i=N-2; i>=0; i--)inv[i]=inv[i+1]*(i+1)%mod;
	sort(val+1, val+1+n);
	int ans=0;
	for(R int i=1; i<=n; i++)
	{
		ans=(ans + val[i] * C(i-1, m-1))%mod;
//		cout<<val[i]*C(i-1, m-1)<<endl;
		ans=(ans - val[i] * C(n-i, m-1))%mod;
	}
	cout<<(ans%mod+mod)%mod;
	return 0;
}

Measured memory_bytes: 33024
#include<stdio.h>
int main()
{
	int a, b, c, d, e, f;
	double x, y;
	while (scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f)>0) {
		x = (double)c*e-(double)b*f;
		if (x) x /= (double)a*e-(double)b*d;
		y = (double)c*d-(double)a*f;
		if (y) y /= (double)b*d-(double)a*e;
		printf("%.3f %.3f\n", x, y);
	}
	return 0;
}

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

typedef long long ll;

int getIdx(int N, ll *X, ll x) {
  return lower_bound(X, X + N, x) - X;
}

typedef pair<ll,ll> P;

int main() {
  int N;
  ll D, A;
  cin >> N >> D >> A;
  vector<P> v;
  ll X[200002], H[200002];
  for (int i = 0; i < N; i++) {
    ll a, b;
    cin >> a >> b;
    v.push_back(P(a, b));
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < N; i++) {
    X[i] = v[i].first;
    H[i] = v[i].second;
  }

  ll ans = 0;
  ll time = 0;
  ll minus[200002];
  fill(minus, minus + N, 0);
  
  for (int i = 0; i < N; i++) {
    time -= minus[i];
    ll rem = max(0LL, H[i] - time * A);
    if (rem > 0) {
      ll add = (rem - 1) / A + 1;
      int idx = getIdx(N, X, X[i] + 2 * D + 1);
      minus[idx] += add;
      time += add;
      ans += add;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 9840
N, W = list(map(int, input().split()))
w, v = [None] * N, [None] * N
for i in range(N):
    w[i], v[i] = list(map(int, input().split()))

V = sum(v)
dp = [[W + 1] * (V + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i in range(1, N + 1):
    for j in range(V + 1):
        if v[i - 1] <= j:
            dp[i][j] = min(dp[i - 1][j], w[i - 1] + dp[i - 1][j - v[i - 1]])
        else:
            dp[i][j] = dp[i - 1][j]

ans = 0
for i in range(V + 1):
    if dp[-1][i] <= W:
        a = i
        ans = max(a, ans)
print(ans)

Measured memory_bytes: 148824
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
diff = [a - b for a, b in zip(A, B)]
upper = sorted([x for x in diff if x > 0])
lower = sorted([x for x in diff if x < 0], reverse=True)
ans = N - len([x for x in diff if x == 0])
while upper and lower:
    rest = upper.pop()
    while lower:
        tgt = lower.pop()       # negative value
        if rest + tgt >= 0:
            rest += tgt
        else:
            lower.append(tgt + rest)
            break
if lower:
    print(-1)
else:
    print(ans - len(upper))

Measured memory_bytes: 18356
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int INF=1e18;
const int MOD=1e9+7;

signed main(){
    int N,A,B,C,D;cin>>N>>A>>B>>C>>D;B-=A;
    REP(i,N){
        int u=D*(N-1-i)-C*i;
        int s=C*(N-1-i)-D*i;
        if(s<=B&&u>=B){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
}

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

int main(){
  int N, H, W;
  cin >> N >> H >> W;
  int A, B;
  int Ans=0;
  for(int i=0; i<N; i++){
    cin >> A >> B;
    if(A>=H && B>=W){
      Ans++;
    }
  }
  cout << Ans << endl;
}

Measured memory_bytes: 256
import Control.Applicative ((<$>), (<*>), (<*), (*>), (<$))
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- getl read
  solve n <$> getl (map read . words) >>= print

solve :: Int -> [Integer] -> Integer
solve n xs = f 0 ys
  where
    ys = take (n * 2) $ sortBy (flip compare) xs
    f acc (x:y:zs) = f (acc + y) zs
    f acc _ = acc
    
getl :: (String -> a) -> IO a
getl f = f <$> getLine


Measured memory_bytes: 138620
N = int(input())
mod = 10**9+7
dp = [[[[0]*4 for _ in [0]*4] for _ in [0]*4] for _ in [0]*(N+1)]
dp[0][3][3][3] = 1
for i in range(1,N+1):
    for c1 in range(4):
        for c2 in range(4):
            for c3 in range(4):
                for k in range(4):
                    if (c2,c3,k) == (0,1,2) : continue
                    if (c2,c3,k) == (1,0,2) : continue
                    if (c2,c3,k) == (0,2,1) : continue
                    if (c1,c3,k) == (0,1,2) : continue
                    if (c1,c2,k) == (0,1,2) : continue
                    dp[i][c2][c3][k] += dp[i-1][c1][c2][c3]
ans = 0
for c1 in range(4):
    for c2 in range(4):
        for c3 in range(4):
            ans += dp[-1][c1][c2][c3]
            ans %= mod
print(ans)

Measured memory_bytes: 3444
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		//String s = stdIn.next();
		
		char[] a = stdIn.next().toCharArray();
		
		System.out.println(a[0]+""+a[1]+""+a[2]);
		
		
	}

}


Measured memory_bytes: 39272
#include <algorithm> //STLͨ���㷨
#include <cmath> //������ѧ����
#include <cstdio> //��������/�������
#include <iostream> //����������/���
#include <cstring> //�ַ�������
#include <string> //�ַ�����
#include <ctime> //�������ʱ��ĺ���
#define itn int
#define fro for
#define ll long long
#define reg register
#define inf 1234567890
#define rep(i,a,b,c) for (int i=a;i<=b;i+=c)
/*#include <bitset> //STLλ������
#include <cstype> //�ַ�����
#include <cerrno> //���������
#include <complex> //������
#include <clocale> //���屾�ػ�����
#include <cstdlib> //������������ڴ���亯��
#include <deque> //STL˫�˶�������
#include <exception> //�쳣������
#include <fstream> //�ļ�����/���
#include <functional> //STL�������㺯��(���������)
#include <limits> //�����������������ֵ����
#include <list> //STL�����б�����
#include <map> //STLӳ������
#include <iomanip> //����������/���
#include <ios> //��������/���֧��
#include <iosfwd> //����/���ϵͳʹ�õ�ǰ������
#include <istream> //����������
#include <ostream> //���������
#include <queue> //STL��������
#include <set> //STL��������
#include <sstream> //�����ַ�������
#include <stack> //STL��ջ����
#include <stdexcept> //��׼�쳣��
#include <streambuf> //�ײ�����/���֧��
#include <utility> //STLͨ��ģ����
#include <vector> //STL��̬��������
#include <cwchar.h>//���ַ�����������/���
#include <cwctype.h> //���ַ�����*/

using namespace std;

int ans;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

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

void exgcd(int a,int b,int &d,int &x,int &y){if (!b){d=a,x=1,y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}

int quick_power(ll a,int b){ll r=1;for (;b;b>>=1,a=a*a)if (b&1) r=r*a;return r;}

inline char read() {
	static const int IN_LEN = 1000000;
	static char buf[IN_LEN], *s, *t;
	return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
	static bool iosig;
	static char c;
	for (iosig = false, c = read(); !isdigit(c); c = read()) {
		if (c == '-') iosig = true;
		if (c == -1) return;
	}
	for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0');
	if (iosig) x = -x;
}

char sr[10000000],z[20];int C=-1,Z=0;
void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(int x){
	if (x<0) sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
//int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);}

//void add(int x,int y,int z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;}
int main()
{
	int n,k;
	read(n);read(k);
	if (k==1) cout<<0;
	else cout<<n-k;
	return 0;
}









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

inline int64_t ceiling_div(int64_t a, int64_t b){
  int64_t ans= ((a>=0 && b > 0) || (a<=0 && b < 0)) ? (abs(a)+abs(b)-1)/abs(b)
                                                    : -abs(a)/abs(b);
  return ans;
}

int main(){
  constexpr int bill= 1000;
  int N;
  cin >> N;

  int ans= ceiling_div(N, bill)* bill- N;
  
  cout << ans << endl;
}

Measured memory_bytes: 3632
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    h,w=parseMap(split(readline()))
    if h==1 || w==1
        println(1)
    else
        println(parseInt(ceil(h*w/2)))
    end
end
main()

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    if(n==1)
        cout << "Hello World";
    else
    {
        int d,p;
        cin >> d >> p;
        cout << d+p;
    }
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	string A,B,C;
	cin>>A>>B>>C;
	int aLen=A.length();
	int bLen=B.length();
	if (A[aLen-1]==B[0] && B[bLen-1]==C[0]){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    
	int h1, h2, m1, m2, k;
	scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
	int rangem;
	int rangeh;
	
	if(m2<m1){
		m2+=60;
		h2-=1;
		rangem = m2-m1;
	}
	else{
		rangem = m2 - m1;
	}
	
	rangeh = h2-h1;
	int total = rangeh*60 + rangem;
	
	printf("%d\n", total - k);
	
    return 0;
}

Measured memory_bytes: 1708
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        HashSet<String> gacha = new HashSet<>();
        for (int i = 0; i < n; i++){
            gacha.add(scanner.nextLine());
        }
        System.out.println(gacha.size());
    }
}

Measured memory_bytes: 79508