akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
using namespace std;

class dictionary {

private:
	string* hashtable;
	long long table_size;
	int el_num;
	long long hash1(string);
	long long hash2(string);
	long long str_n(string);
public:
	dictionary(int n);
	void insert(string);
	bool find(string);
};
inline dictionary::dictionary(int n)
{
	hashtable= new string[n];
	if( !hashtable ){
		cout<<"Allocation Error"<<endl;
		abort();
	}

	table_size=n;
	el_num=0;
}
inline long long dictionary::hash1( string str )
{
	return str_n(str) % table_size;
}
inline long long dictionary::hash2( string str )
{
	return 1 + (str_n(str) % (table_size - 1));
}

inline long long dictionary::str_n( string str )
{

	long long str_n=0;

	for( unsigned int i=0; i<str.size(); i++ ){
		str_n = str_n * 5 + (long long)str[i] ; // str_n += (int)str[i] ?????????????????????????????????????????£???
	}

	return str_n;

/* <answer>
	long long str_n=0;
	for( unsigned int i=0, p=1; i<str.size(); i++,p*=5 ){
		switch(str[i]){
		case 'A':
			str_n += p*1;
			break;
		case 'C':
			str_n += p*2;
			break;
		case 'G':
			str_n += p*3;
			break;
		case 'T':
			str_n += p*4;
			break;
		}
	}
	return str_n;
</answer> */
}

		

inline void dictionary::insert( string str )
{
/*
	if( el_num >= table_size ){
		cout<<"????????\????????????????????????"<<endl;
		abort();
	}
	long long hash_v;
	do{
		hash_v = ( hash1(str) + hash2(str)*coltimes )%table_size ;

//		printf("I ( hash1, hash2, hash )(coltimes) = ( %d, %d, %d)(%d)\n", hash1(str), hash2(str), hash_v, coltimes );

	}while( hashtable[ hash_v ].size() && hashtable[ hash_v ]!= str, coltimes++ );
*/

	long long hash_v;

	for( int i=0; ; i++ ){
		hash_v= (hash1(str) + hash2(str)*i) % table_size;
		if( hashtable[ hash_v ] == str ){
			return;
		}else if( !hashtable[ hash_v ].size() ){
			hashtable[ hash_v ]=str;
			return;
		}
	}
}
inline bool dictionary::find( string str )
{

	long long hash_v;
	int coltimes=0;
	do{
		
		hash_v = ( hash1(str) + hash2(str)*coltimes )%table_size ;
//		printf("F ( hash1, hash2, hash )(coltimes) = ( %d, %d, %d)(%d)\n", hash1(str), hash2(str), hash_v, coltimes );

		if( hashtable[ hash_v ] == str ){
			return true;
		}

		coltimes++;

	}while( hashtable[ hash_v ].size() &&  coltimes <= table_size);


	return false;
}

int main()
{
	int n;
	scanf("%d", &n);
	char command[7], str[13];
	dictionary dic(1046527);

	for( int i=0; i<n; i++ ){
		scanf("%s %s", command, str);

		if( !strcmp(command, "insert") ){
			dic.insert(str);
		}else if ( !strcmp(command, "find") ){
			cout<<( dic.find(str)? "yes" : "no" )<<endl;
		}
	}
}

Measured memory_bytes: 22324
#include <cstring> // memset
#include <iostream>

using namespace std;

char board[102][102];

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

  int H, W;
  cin >> H >> W;
  memset(board, '#', sizeof(char) * 102 * 102);
  for (int i = 1; i <= H; ++i)
    for (int j = 1; j <= W; ++j) cin >> board[i][j];

  for (int i = 0; i <= H + 1; ++i) {
    for (int j = 0; j <= W + 1; ++j) {
      cout << board[i][j];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;

#define Endl endl

/*--------------------template--------------------*/

char d[400][400];
char dd[400][400];

bool f() {
    REP(i, n) {
        FOR(j, i + 1, n) {
            if (i == j) {
                continue;
            }
            if (dd[i][j] != dd[j][i]) {
                return false;
            }
        }
    }
    return true;
}

void p() {
    REP(i, n) {
        REP(j, n) {
            cout << dd[i][j] << " ";
        }
        cout << endl;
    }
}

int main() {
    cin >> n;
    REP(i, n) {
        REP(j, n) {
            cin >> d[i][j];
        }
    }
    ll a = 0;
    REP(b, n) {
        REP(i, n) {
            REP(j, n) {
                dd[i][j] = d[(i + a) % n][(j + b) % n];
            }
        }
        if (f()) {
            ans++;
        }
    }
    cout << ans * n << endl;

}

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

using namespace std;
typedef long long ll;

int main(){
    string s, t;
    cin >> s >> t;
    ll ans = 0;
    for(int i = 0; i < s.size(); ++i){
        ans += s.at(i) == t.at(i);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 760
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	Main m = new Main();
	m.answer();
    }

    private Scanner scan = new Scanner(System.in);
    private final int A;
    private final int B;
    private final int C;
    private final int D;

    public Main() {
	A = Integer.parseInt(scan.next());
	B = Integer.parseInt(scan.next());
	C = Integer.parseInt(scan.next());
	D = Integer.parseInt(scan.next());
	scan.close();
    }

    public final void answer() {
	int start = Integer.max(A, C);
	int end = Integer.min(B, D);
	int time = end - start;
	if(time < 0) time = 0;

	System.out.println(time);
    }
}


Measured memory_bytes: 21716
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
ll add(ll x,ll y)
{
return (x%hell+y%hell)%hell;
}
ll mul(ll x,ll y)
{
return ((x%hell)*(y%hell))%hell;
}
ll sub(ll x,ll y)
{
return (x-y+hell)%hell;
}
#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        ll n,x,y;
        cin>>n>>x>>y;
        map<ll,ll>lol;
        for(ll i=1;i<n;i++)
        {
            for(ll j=i+1;j<=n;j++)
            {
                if(j<=x)
                    lol[j-i]++;
                else if(i<=x&&j<=y)
                {
                    ll op=y-j+1+x-i;
                    op=min(j-i,op);
                    lol[op]++;
                    //cout<<j;
                }
                else if(i<=x&&j>=y)
                {
                    lol[x-i+j-y+1]++;
                }
                else if(x<=i&&j<=y)
                {
                    
                    lol[min(j-i,y-x-j+i+1)]++;
                }
                else if(i<=y&&j>=y)
                {
                    ll op=j-y+1+i-x;
                    lol[min(op,j-i)]++;
                }
                else
                    lol[j-i]++;
            }
            //cout<<lol[1]<<" ";
        }
        for(int i=1;i<=n-1;i++)
            cout<<lol[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 384
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	n, _ := strconv.Atoi(nextLine())
	dx := strings.Split(nextLine(), " ")
	d, _ := strconv.Atoi(dx[0])
	x, _ := strconv.Atoi(dx[1])

	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(nextLine())
	}

	sum := x
	for i := 0; i < n; i++ {
		sum += (d-1)/a[i] + 1
	}

	fmt.Println(sum)
}


Measured memory_bytes: 640
/*
    @uthor: Amit Kumar
    user --> CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll long long
#define ld double
#define endl "\n"

const ll mod = 1e9+7;
const ll inf = 1e18;

ll popcount(ll num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}


void virus(){
         ll len, m_j;
         cin>>len>>m_j;
         vector<ll> arr(len);
         for(auto &i:arr) cin>>i;
         vector<ll> dp(len,mod);
         dp[0] = 0;
         for(auto i=0; i<len; i++){
             for(auto k=1; k<=m_j; k++){
                 if(i+k<len)
                 dp[i+k] = min(dp[i+k],dp[i] + abs(arr[i] - arr[i+k]));
             }
         }
         cout<<dp[len-1];
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t = 1;
    //cin>>t;
    while(t--){
         //auto start = high_resolution_clock::now();
           virus();
         //auto stop = high_resolution_clock::now();
         //auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct A {
    bool operator<(const A& a) const {
        return p != a.p ? p < a.p : y < a.y;
    }
    int p, y, i;
};

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

    vector<A> a(m), r(m);
    for (int i = 0; i < m; i++) {
        int p, y;
        scanf("%d%d", &p, &y);
        a[i] = { p, y, i };
    }
    sort(a.begin(), a.end());

    int p = -1, k;
    for (int i = 0; i < m; i++) {
        if (a[i].p != p) {
            p = a[i].p;
            k = 0;
        }
        a[i].y = k++;
        r[a[i].i] = a[i];
    }

    for (int i = 0; i < m; i++) {
        printf("%06d%06d\n", r[i].p, r[i].y + 1);
    }

    return 0;
}

Measured memory_bytes: 3840
def solve():
    N = int(input())
    Ss = input().rstrip()

    def isOK(L):
        setCand = set()
        RHs = []
        for i in range(N-L+1):
            RH = hash(Ss[i:i+L])
            RHs.append(RH)
            if i-L >= 0:
                setCand.add(RHs[i-L])
            if RH in setCand:
                return True
        return False

    ng, ok = N//2+1, 0
    while abs(ok-ng) > 1:
        mid = (ng+ok) // 2
        if isOK(mid):
            ok = mid
        else:
            ng = mid

    print(ok)


solve()


Measured memory_bytes: 3404
#include <bits/stdc++.h>
using namespace std;
using lint = long long;

signed main(){
	string s; cin >> s;
  lint MOD = 2019;
  vector<lint> data(2019, 0);
  data[0] = 1;
  lint x = 0;
  lint num = 0, ten = 1;
    for(lint i = 0; i < s.size(); i++){
      ten = (10 * ten) % 2019;
      num = num + (s[s.size() - i - 1] - '0') * ten;
      num %= 2019;
      data[num]++;
    }
  lint ans = 0;
  for(lint i = 0; i < 2019; i++){
    ans += data[i] * (data[i] - 1) / 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3752
/* A - We Love Golf */

#include <stdio.h>

int main(void){
  int K, A, B;
  scanf("%d", &K);
  scanf("%d %d", &A, &B);
  if(A % K == 0 || B % K == 0){
    printf("OK\n");
  }else if(B - A >= K - 1 || B / K - A / K > 0){
    printf("OK\n");
  }else{
    printf("NG\n");
  }
}


Measured memory_bytes: 1624
n,m=map(int,input().split())
l=list(map(int,input().split()))
d=dict({})
for i in range(m):
  a,b=map(int,input().split())
  if a in d:
    d[a].append(l[b-1])
  else:
    d[a]=[l[b-1]]
  if b in d:
    d[b].append(l[a-1])
  else:
    d[b]=[l[a-1]]
for x in d.keys():
  z=max(d[x])
  if l[x-1]>z:
    pass
  else:
    n-=1
print(n)

Measured memory_bytes: 28448
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,n) for(int i=0;i<n;i++)
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(a*c, max(a*d,max(b*c,b*d))) << endl; 


	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define forloop(n) for(int i = 0; i < n; i++)
#define ll long long
 
#define mod 1000000007

ll ebob(ll a, ll b){
	if(a==0) return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (a*b)/ebob(a,b);
}

long long exp(long long taban, long long us) {
    long long carpan = taban;
    long long temp = us;
    long long res = 1;
    for(int i = 0;;i++){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
        if(temp == 0) break;
    }
    return res;
}

ll factarr[100005];
void fact(ll n){
	factarr[0] = 1;
	for(int i = 1; i <= n; i++){
		factarr[i] = (factarr[i-1]*i) % mod;
	}
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	fact(100000);
	int n; cin>>n;
	ll arr[n];
	for(int i = 0; i < n; i++){
		cin>>arr[i];
	}
	ll uzaklik[n];
	for(int i = 0; i < n-1; i++){
		uzaklik[i] = arr[i+1]-arr[i];
	}
	ll m = 1;
	ll res = 0;
	for(int i = 0; i < n-1; i++){
		res = (res + uzaklik[i]*((factarr[n-1]*m)%mod)) % mod;
		m = (m + exp(i+2,mod-2)) % mod;
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
int main(){
	ll x; cin>>x;
	vector<ii>a;
	for(int i=0;i<=4500;i++){
		a.push_back({(i*i*i*i*i),i});
	}
	for(int i=0;i<a.size();i++){
		for(int j=0;j<a.size();j++){
			if(a[i].first - a[j].first == x){
				cout<<a[i].second << " "<<a[j].second<<endl;
				return 0;
			}
			else if(a[i].first + a[j].first == x){
				cout<<a[i].second << " "<<-a[j].second<<endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3728
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
using namespace std;
char str[10][21];
int dx[]={1,1,1,0,0,-1,-1,-1};
int dy[]={1,0,-1,1,-1,1,0,-1};
vector<string> V;
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		V.clear();
		for(int i=0;i<a;i++)scanf("%s",str[i]);
		for(int i=0;i<a;i++){
			for(int j=0;j<b;j++){
				for(int k=0;k<8;k++){
					int row=i;
					int col=j;
					string S="";
					do{
						S+=str[row][col];
						row+=dx[k];
						col+=dy[k];
						if(row<0)row+=a;
						if(row>=a)row-=a;
						if(col<0)col+=b;
						if(col>=b)col-=b;
					}while(row!=i||col!=j);
					V.push_back(S);
				}
			}
		}
		std::sort(V.begin(),V.end());
		int len=0;
		int m=0;
		for(int i=0;i<V.size()-1;i++){
			int P=0;
			for(int j=0;j<min(V[i].size(),V[i+1].size());j++){
				if(V[i][j]!=V[i+1][j])break;
				P++;
			}
			if(P>len){
				len=P;
				m=i;
			}
		}
		if(len<2)printf("0\n");
		else{
			for(int i=0;i<len;i++)printf("%c",V[m][i]);
			printf("\n");
		}
	}
}

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

int main(){
    
    int N, K;
    cin >> N >> K;
    vector<int> l(N);
    
    for(int i = 0; i < N; i++){
        cin >> l[i];
    }
    
    sort(l.rbegin(), l.rend());
    
    int sum = 0;
    for(int i = 0; i < K; i++){
        sum += l[i];
    }
    
    cout << sum << endl;
    
}


Measured memory_bytes: 3180
N = gets.to_i
Ps = (0...N).map{
  gets.split.map &:to_f
}.sort_by{ |x,y| Math.atan2(x,y) }

Ds = Ps + Ps

R2 = (0...N).map{ |k|
  v = [*Ds[k]]
  Ds[k+1...k+N].reduce(v[0]**2 + v[1]**2){ |r,v2|
    v[0] += v2[0]; v[1] += v2[1]
    [r, v[0]**2 + v[1]**2].max
  }
}.max

puts Math.sqrt(R2)


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

using namespace std;
typedef long long ll;
typedef pair <int, int> pp;
#define MAXR 300005
#define MAXP 25
#define A first
#define B second
#define MP make_pair
#define PB push_back
const ll INF = 2e9+13;
const ll MOD = 1e9+7;
int N;
int rec(int x) {
	int ret = 0;
	while(x) {
		ret += x%10;
		x /= 10;
	}
	return ret;
}
int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N;
	int ans = 1000000;
	for(int i=1; i<N; i++) {
		ans = min(ans, rec(i) + rec(N-i));
	}
	cout << ans << endl;

	
}

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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl '\n'

int main()
{
    

    int n,k;
    cin>>n>>k;
    ll a[n];
    ffor(i,0,n) cin>>a[i];
    sort(a,a+n);
    ll ans=0;
    ffor(i,0,k) ans+=a[i];
    cout<<ans;
    
    return 0;
}



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

int main(){
    int ans=0,n=0,h=0,w=0;
    long a[1001],b[1001];
    cin >> n >> h >> w;
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
        if(a[i]>=h && b[i]>=w)ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;



int main()
{
	long long x;
	long long steps = 0;
	long long d = 100;	
	scanf("%lld", &x);
	
	while (d < x) {
		d = d + d / 100;
		steps++;
	}
	printf("%lld\n", steps);
	

	return 0;
}

//硬上 

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2*1e5+10;
const int MOD = 1e9 + 7;
const int INF = 1e18 + 10;

int n;
int k;
int dp[(int)1e5 + 1];
int arr[(int)1e5 + 1];

void printVector(vector<int> s){
    for(int &x:s){
        cout<<x<<" ";
    }
    cout<<endl;
}

int rec(int i){
    if(i==n){
        return INF;
    }
    if(i==n-1){
        return 0;
    }
    if(dp[i]!=-1){
        return dp[i];
    }
    int ans = INF;
    for(int j = 1 ; j <= k ; j++) {
        if (i + j <= n - 1) {
            ans = min(ans, abs(arr[i] - arr[i + j]) + rec(i + j));
        }
    }
    return dp[i] = ans;
}


void solve(){
    cin>>n;
    cin>>k;
    for(int i = 0; i < n ; i++){
        cin>>arr[i];
    }
    for(int i = 0 ; i < 1e5 + 1; i++) dp[i] = -1;
    cout<<rec(0)<<endl;

}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
//    cin>>t;
    t = 1;
    for(int i = 0 ; i < t ; i++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 13008
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>

using namespace std;


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


    long long all_sum = (N + 1) * N / 2;

    long long num_3 = N / 3;
    long long sum_3 = (num_3 * (6 + (num_3 - 1)*3)) / 2;

    long long num_5 = N / 5;
    long long sum_5 = (num_5 * (10 + (num_5 - 1)*5)) / 2;

    long long num_15 = N/15;
    long long sum_15= (num_15 * (30 + (num_15 - 1)*15)) / 2;

    cout << all_sum - sum_3 - sum_5 + sum_15;
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

const long long INF = 1LL << 60;


int main() {
    int n;
    cin >> n;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    vector<ll> dp(n, INF);
    dp[0] = 0;
    repf(i, 1, n) {
        chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if (i > 1)
            chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;
int n;
int a[200];
int b[200];
int ans;


int main()
{
    cin>>n;
    for (int i=1; i<=-1+n; ++i)
        cin >> b[i];
    for (int i=1; i<=n; ++i)
    {
        if (i==1) a[i]=b[i];
        else if (i==n) a[i]=b[i-1];
        else a[i] = min(b[i], b[i-1]);
        ans += a[i];
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
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 = 1001001001;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int ans = inf;
    int now = 0;
    int cnt = 0;
    rep(i,n) {
        now = 1-now;
        if(s[i]-'0' != now) cnt++;
    }
    chmin(ans,cnt);
    now = 1;
    cnt = 0;
    rep(i,n) {
        now = 1-now;
        if(s[i]-'0' != now) cnt++;
    }
    chmin(ans,cnt);
    cout << ans << endl;
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cout.precision(12);
    cout << fixed;
    cin.tie(0);

    int n, x;
    cin >> n >> x;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    int tot = 0;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        tot += v[i];
        if (tot > x) break;
        cnt++;
    }
    if (cnt == n) {
        if (tot != x) {
            cnt--;
        }
    }
    cout << cnt << endl;

    return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    
    double ans;
    bool h = 0;
   
    rep(i, 10000) {
        if((i*2) / 25 == a && i / 10== b) {
            ans = i;
            h = 1;
            break;
        }
    }
    if(h)
        cout << ans << endl;
    else
        cout << -1 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std;

static const int INF=100000;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n,x;
    cin >> n >> x;
    int l[n+2];
    int d[n+2];
    d[0]=0;
    for(int i=0;i<n;i++) cin >> l[i];
    int cnt=1;
    for(int i=1;i<=n;i++){
        d[i]=d[i-1]+l[i-1];
        if(d[i]<=x) cnt++;
        else break;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

void solve(){
 ll n;
  cin >> n;
  
 ll s=0; 
  for(int k=1;k*(k+1)/2<=n;k++){
   if(k*(k+1)/2==n) s=k+1;
  }
  if(!s) {
    cout << "No" << endl;
    return;
  }
  
  vvll res(s);
  for(int i=1;i<=s-1;i++){
    ll sum=i*(i-1)/2;
   for(int j=1;j<=i;j++){
     res[i-1].eb(sum+j);
    if(i!=j) res[j-1].eb(sum+j);
    else res[s-1].eb(sum+j);
   }
  }
  
  cout << "Yes" << endl;
  cout << res.size() << endl;
  rep(i,0,s){
   cout << res[i].size() << " ";
   for(auto c:res[i]) cout << c << " "; 
   cout << endl;
  }
  
     
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}  

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
int N, A[3][3], b[10];
bool appear[3][3];
int main(){ 
  for(int i=0;i<3;i++){
   for(int j=0;j<3;j++)
     cin>>A[i][j]; 
  }
 cin>>N;
   for(int i=0;i<N;i++)
     cin>>b[i];
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      appear[i][j]=false;
      for(int k=0;k<N;k++){
        if(A[i][j]==b[k])
          appear[i][j]=true;
      }
    }
  }
  string ANS = "No";
  for(int i=0;i<3;i++){
    if(appear[i][0] and appear[i][1] and appear[i][2]) ANS = "Yes"; 
 }
  for(int i=0;i<3;i++){
    if(appear[0][i] and appear[1][i] and appear[2][i]) ANS = "Yes";
  }
  if(appear[0][0] and appear[1][1] and appear[2][2]) ANS = "Yes";
  if(appear[0][2] and appear[1][1] and appear[2][0]) ANS = "Yes"; 
  cout<<ANS<<endl; 
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[29]:


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


# In[32]:


ans_list = []
for i in range(1, N):
    #print(Wlist[:i])
    #print(Wlist[i:])
    ans_list.append(sum(Wlist[:i]) - sum(Wlist[i:]))


# In[33]:


print(min(list(map(abs, ans_list))))


# In[ ]:






Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    unsigned long long L, R; cin >> L >> R;

    unsigned long long ans = -1;

    if (R-L < 2019) {
      for (unsigned long long i = L; i <= R; i++) {
	for (unsigned long long j = i+1; j <= R; j++) {
	  ans = min(ans, ((i%2019)*(j%2019))%2019);
       }
      }
    } else {
      ans = 0;
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
int main(){
    int n,t;
    cin>>n>>t;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    
    int sum=0;
    for(int i=0;i<n-1;i++){
        sum+=min(v[i+1]-v[i],t);
    }
    sum+=t;
    cout<<sum<<endl;
    return 0;
}

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

int main()
{
  int i,n;
  double x1,x2,x3,y1,y2,y3,xp,yp,r;
  scanf("%d",&n);
  for (i=0;i<n;i++){
    scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);

    xp=((y1-y3)*(y1*y1 - y2*y2 + x1*x1 - x2*x2)
          - (y1-y2)*(y1*y1-y3*y3+x1*x1-x3*x3))
      /(2*(y1-y3)*(x1-x2)-2*(y1-y2)*(x1-x3));
    yp=((x1-x3)*(x1*x1 - x2*x2 + y1*y1 - y2*y2)
          - (x1-x2)*(x1*x1-x3*x3+y1*y1-y3*y3))
      /(2*(x1-x3)*(y1-y2)-2*(x1-x2)*(y1-y3));
    r = sqrt((xp-x1)*(xp-x1)+(yp-y1)*(yp-y1));

    printf("%.3f %.3f %.3f\n",xp,yp,r);
  }
  return 0;
}

Measured memory_bytes: 656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    int ans=min(a*n,b);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <bitset>
using namespace std;
const int MAX_N = 1e5 + 5;

list<int> adjlist[MAX_N];
int par[MAX_N];
bitset<MAX_N> visited;

int main(){
    int V , E;
    cin >> V >> E;
    for (int i = 0 , a , b ; i < E ; i++){
        cin >> a >> b;
        adjlist[a].push_back(b);
        adjlist[b].push_back(a);
    }

    visited[1] = 1;
    list<int> q = {1};
    while(!q.empty()){
        int now = q.front();
        q.pop_front();
        for (int it : adjlist[now]){
            if (!visited[it]){
                par[it]= now;
                visited[it] = 1;
                q.push_back(it);
            }

        }
    }
    if (visited.count() != V)
        cout << "No\n";
    else{
        cout << "Yes\n";
        for (int i = 2 ; i <= V ; i++)
            cout << par[i] << '\n';
    }
}


Measured memory_bytes: 21928
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#define fo(i,n) for(long long i=0;i<n;i++)
#define ll long long int
#define inf 999999999999999999
#define pb push_back
#define fi first
#define se second
#define vi vector<ll>
#define vii vector<vector<ll>>
#define pi pair<ll,ll>
#define mp make_pair
#define MOD 1000000007
#define tr(c,it) for(auto it = (c).begin(); it != (c).end(); ++it)
#define fio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
//cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
//freopen("explicit.in", "r", stdin);
//freopen("explicit.out", "w", stdout);
 
void SieveOfEratosthenes() 
{ 
    bool prime[10000001];
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=10000000; p++) 
    { 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (ll i=p*p; i<=10000000; i += p) {
                prime[i] = false; 
            }
        } 
    }  
} 
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a);
        a = (a * a);
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
	if(b%a==0)
	   return a;
	return gcd(b%a,a);
}
ll nCrModpDP(ll n, ll r, ll p) 
{ 
    ll C[r+1]; 
    memset(C, 0, sizeof(C));   
    C[0] = 1;
    for (ll i = 1; i <= n; i++) 
    {
        for (ll j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
} 
ll nCrModp(ll n, ll r, ll p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
   ll ni = n%p, ri = r%p; 
  
   return (nCrModp(n/p, r/p, p) * 
           nCrModpDP(ni, ri, p)) % p; 
} 
long long int moduloMultiplication(long long int a, 
                            long long int b, 
                            long long int mod) 
{ 
    long long res = 0;
    a %= mod; 
  
    while (b) 
    { 
        if (b & 1) 
            res = (res + a) % mod; 
        a = (2 * a) % mod; 
  
        b >>= 1; // b = b / 2 
    } 
  
    return res; 
} 
int32_t main() 
{
    fio
	ll i,n,t,l,r,c,h,k,m,maxi,d,x;
	long long int j;
	cin>>n;
	ll a[n];
	for(j=0;j<n;j++)
		cin>>a[j];
	ll sum[n+1]={0};
	sum[n-1]=a[n-1];
	for(j=n-2;j>=0;j--)
	{
		sum[j]=(a[j]+sum[j+1]);
	}
	ll ans=0;
	// cout<<sum[1]<<endl;;
	for(j=0;j<n;j++)
	{
		c=(a[j]);
		d=(sum[j+1]);
		ans=(ans%MOD+moduloMultiplication(d,c,MOD)%MOD)%MOD;
		// ans=ans%MOD;
	}
	cout<<ans;
}


	

		

Measured memory_bytes: 6772
import math
from functools import reduce

def gcd(*numbers):
	return reduce(math.gcd, numbers)

k = int(input())

# 1個のやつはkまでの自然数列の合計
s = k * (k+1) / 2

# 2個のやつ（3つずつある）が，(1,1,2)と(1,2,2)を区別するために6つずつにする
for a in range(1, k):
	for b in range(a+1, k+1):
		s = s + 6 * math.gcd(a,b)

# 3個のやつ（6つずつある）
for a in range(1, k-1):
	for b in range(a+1, k):
		for c in range(b+1, k+1):
			s = s + 6 * gcd(a, b, c)

print(int(s))

Measured memory_bytes: 75088
#include <iostream>
#include <fstream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <utility>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <sstream>
#include <cstring>
#include <bitset>
#include <stack>
using namespace std;
#define MP make_pair
#define PB push_back
const int INF=1e9;

int n,ans=INF;

inline int calc(int x)
{
	int res=0;
	while (x)
	{
		res+=x%10;
		x=x/10;
	}
	return res;
}

int main()
{
	cin>>n;
	for (int i=1;i<n;i++) ans=min(ans,calc(i)+calc(n-i));
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    long long x=0;
    cin>>n>>m;
    int a[m];
    for(int i=0;i<m;i++){
        cin>>a[i];
        x+=a[i];
    }
    if(x<=n)cout<<n-x<<endl;
    else cout<<"-1"<<endl;
    return 0;
}

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

vector<int> b;

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	long long a, b; cin >> a >> b; 
	int t = 1, s = 0;  
	
	while(b > t){
		t += a - 1;
		++s;
	}
	
	cout << s;
	
	
	
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    ll k; cin >> k;
    vector <ll> as;
    REP(i, n){
        ll a; cin >> a;
        as.push_back(a);
    }
    ll ok = 1e18 + 1;
    ll ng = 0;
    ll mid;
    while(ok - ng > 1){
        mid = (ok + ng) / 2;
        ll cnt = 0;
        for(auto a: as){
            cnt += (a*ll(1e9) + mid - 1)  / mid - 1;
            cnt = min(ll(1e18 + 1), cnt);
        }
        if (cnt <= k){
            ok = mid;
        } else {
            ng = mid;
        }
    }
    dump(mid)
    cout << (ok+ll(1e9)-1) / ll(1e9) << endl;
    return 0;
}

Measured memory_bytes: 5352
s, t = 2.times.map{gets.chomp.split('')}
s = s.sort!
t = t.sort.reverse!
s.each_with_index do |sv, i|
  if t[i] == nil || sv > t[i] 
    puts 'No'
    exit
  elsif sv == t[i] 
    next
  elsif sv < t[i]
    puts 'Yes'
    exit
  end
end
puts s.length == t.length ? 'No' : 'Yes'

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  vector<int> v(n); cin >> v;
  map<ll,int> mp;
  ll ans = 0;
  for(int i = 0; i < n; ++i){
    if(i+1 <= v[i]){
      mp[i+1+v[i]]++;
      continue;
    }
    ans += mp[i+1-v[i]];
    mp[i+1+v[i]]++;    
  }
  cout << ans << endl;
  return 0;
}


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

int toMin(string s){
    return stoi(s.substr(0,2)) * 60 + stoi(s.substr(3,2));
}

int main(){
    int N,T;
    cin >> N >> T;
    vector<pair<string,int>> ans;
    string st_time,st_name,ar_time,ar_name;
    cin >> st_time >> st_name;
    for(int i = 0;i < N-1;i++){
        cin >> ar_time >> ar_name >> st_time >> st_name;
        if(toMin(st_time) - toMin(ar_time) >= T){
            ans.push_back(make_pair(st_name,toMin(st_time) - toMin(ar_time)));
        }
    }
    cin >> ar_time >> ar_name;
    cout << ans.size() << endl;
    for(auto p:ans)cout << p.first << ' ' << p.second << endl;
}


Measured memory_bytes: 3232
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		long D = sc.nextLong();
		long E = sc.nextLong();
		sc.close();
		long min = Long.MAX_VALUE;
		long[] trans = new long[] {A,B,C,D,E};
		for(int i = 0;i < 5;i++) {
			min = Math.min(min, trans[i]);
		}
		long btm = N%min==0 ? N/min : N/min + 1;
		System.out.println(btm + 4);
	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define in2(N,s,t) rep(i,N){in(s[i] , t[i]);}
#define in3(N,s,t,u) rep(i,N){in(s[i] , t[i] , u[i]);}
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vs = V<string>;
using vd = V<double>; using vvi = V< V<int> >; using vvl = V< V<> >;
template<typename T>using heap = priority_queue< T , V<T> , greater<T> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

using P = pair<ll,ll>; using vp = V<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
//////////////////

ll f(ll x){
  if(x == 1) return 1;
  return 1 + f(x / 2) * 2;
}
void solve(){
  inl(h);
  out(f(h));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    int main(){
      int n;
      cin>>n;
      vector<int> v1,v2;
      for(int i=0;i<n;i++){
        	int x,y;
        	cin>>x>>y;
        	v1.push_back(x+y);
        	v2.push_back(x-y);
      }
      sort(v1.begin(),v1.end());
      sort(v2.begin(),v2.end());
      cout<<max(v1[n-1]-v1[0],v2[n-1]-v2[0]);
      return 0;
    }

Measured memory_bytes: 5076
import Control.Applicative
import Control.Monad
import Control.Monad.State

main = do
    n <- readLn
    if n == 0
       then return ()
       else do
           cards <- map (map read.words)<$>replicateM n getLine :: IO [[Int]]
           putStrLn $ unwords.map show.(\fs -> execState (sequence_ fs) [0,0]) $ map countPoint cards
           main

countPoint :: [Int] -> State [Int] ()
countPoint [a,b]
  | a < b  = get >>= \[suma, sumb] -> put ([suma, sumb+a+b])
  | a == b = get >>= \[suma, sumb] -> put ([suma+a, sumb+b])
  | a > b  = get >>= \[suma, sumb] -> put ([suma+a+b, sumb])

Measured memory_bytes: 9256
S = input()
c, f = -1, -1
for i, s in enumerate(S):
    if s == 'C':
        c = i
        break
for i, s in enumerate(S[::-1]):
    if s == 'F':
        f = len(S)-i-1
        break
if c >= 0 and f >= 0 and c < f:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9016
import math
import itertools

n = int(input())

p = []
for i in range(n):
    x, y = map(int, input().split())
    p.append((x, y))
    
def dist(p1, p2):
    return math.sqrt(math.pow(p1[0]-p2[0], 2) + math.pow(p1[1]-p2[1], 2))
    
patterns = list(itertools.permutations(list(range(n))))


total = 0
for pattern in patterns:
    for i in range(n):
        if i+1 == n:
            continue
        total += dist(p[pattern[i]], p[pattern[i+1]])
        
print(total/len(patterns))

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

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;

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

	int cnt = 0, maxV = 1000000;
	while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
		int na = (b+c)/2, nb = (c+a)/2, nc = (a+b)/2;
		cnt++;
		a = na; b = nb; c = nc;
		if(cnt > maxV) break;
	}
	if(cnt > maxV) cnt = -1;
	printf("%d\n", cnt);
	return 0;
}

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

int main() {

  int N;
  cin >> N;

  string tmp;
  map<string, int> m;
  int max = 0;
  for(int i = 0; i < N; i++){
    cin >> tmp;
    m[tmp]++;
  }

  for(auto iter = begin(m); iter != end(m); iter++){
    if(iter->second > max){
      max = iter->second;
    }
  }

  for(auto iter = begin(m); iter != end(m); iter++){
    if(iter->second == max){
      cout << iter->first << endl;
    }
  }
}

Measured memory_bytes: 25216
#include <iostream>
 
int main()
{
  int N, D;
  std::cin >> N >> D;
  
  int cap = 2*D + 1;
  
  if(N % cap == 0){
    std::cout << int(N/cap);
  } else {
  	std::cout << int(N/cap) + 1;
  }
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        String str = s.next();
        char[] c = str.toCharArray();
        int size = c.length;
        int count = 0;
        int Count = 0;
        for (char value : c) if (value == 'W') count++;
        if (count <= size - count) {
            for (int i = 0; i < size - count; i++) if (c[i] == 'W') Count++;
        } else {
            for (int i = 0; i < count; i++) if (c[size - i - 1] == 'R') Count++;
        }
        System.out.println(Count);
    }
}

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

int main(){
    string s;
    cin >> s;
    int n=s.size();
    ll ans=0;
    for(int i=0; i<(1<<(n-1)); i++){
        ll cnt=0;
        vector<int> cut(n-1,0);
        for(int j=0; j<n-1; j++){
            if(i & (1<<j)){
                cut.at(j)=1;
            }
        }
        string num;
        num+=s.at(0);
        for(int i=1; i<n; i++){
            if(cut.at(i-1)!=0) num += s.at(i);
            else{
                cnt+=stoi(num);
                num="";
                num+=s.at(i);
            }
        }
        cnt+=stoll(num);
        ans += cnt;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int n,pt[20],dif;
int abs(int a){
    if(a<0)a*=-1;
    return a;
}
void dfs(int atnum,int a,int b){
    if(atnum==n){
        dif=min(dif,abs(a-b));
        return;
    }
    dfs(atnum+1,a+pt[atnum],b);
    dfs(atnum+1,a,b+pt[atnum]);
}
int main(){
    while(cin>>n,n){
        dif=100000000;
        for(int i=0;i<n;i++)cin>>pt[i];
        dfs(0,0,0);
        cout<<dif<<endl;
    }
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
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;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    // vector<string> ss(n);
    map<string, int> sm;
    int cm = 0;
    rep(i,n){
        string s; cin>>s;
        sm[s]++;
        cm = max(cm, sm[s]);
    }
    for(auto a : sm){
        if(a.second==cm){
            cout<<a.first<<endl;
        }
    }
}

Measured memory_bytes: 23836
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  int cnt= 0;
  for(int i = 0; i < n-1; i++){
    for(int j = 0; j < n-1-i; j++){
      if(a[j] > a[j+1]){
        cnt ++;
        swap(a[j+1], a[j]);
      }
    }
  }
  for(int i = 0; i < n; i++){
    if(i)cout << ' ';
    cout << a[i];
  }
  cout << endl;
  cout << cnt << endl;
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<vector<int>> a(H, vector<int>(W));
    rep(i, H)rep(j, W) cin >> a[i][j], a[i][j] %= 2;

    vector<pair<P, P>> ans;
    rep(i, H)rep(j, W) {
        if (a[i][j]) {
            if (j+1 < W) {
                a[i][j] = 0;
                a[i][j+1] ^= 1;
                ans.emplace_back(P(i, j), P(i, j+1));
            } else if (i+1 < H) {
                a[i][j] = 0;
                a[i+1][j] ^= 1;
                ans.emplace_back(P(i, j), P(i+1, j));
            }
        }
    }

    cout << ans.size() << endl;
    for (auto &i : ans) cout << i.first.first+1 << " " << i.first.second+1 << " " << i.second.first+1 << " " << i.second.second+1 << endl;
}

Measured memory_bytes: 5232
import math

a,b,C=map(int,input().split())
C=math.radians(C)
S=a*b*math.sin(C)/2

c=math.sqrt(a*a+b*b-2*a*b*math.cos(C))
L=a+b+c

h=S*2/a

print(f'{S:.8f}')
print(f'{L:.8f}')
print(f'{h:.8f}')


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

int main(int argc, char const *argv[])
{
    int n,m;
    cin >> n >> m;
    int student[n][2],checkPoint[m][2];
    for(int i=0;i<n;++i)
        for(int j=0;j<2;++j)
            cin >> student[i][j];
    for(int i=0;i<m;++i)
        for(int j=0;j<2;++j)
            cin >> checkPoint[i][j];
    for(int i=0;i<n;++i) {
        int manHattan = INT_MAX;
        int index = INT_MAX;
        for(int j=0;j<m;++j) {
            int res = abs(student[i][0] - checkPoint[j][0]) + abs(student[i][1] - checkPoint[j][1]);
            if(manHattan > res)
            {
                manHattan = res;
                index = j+1;
            }
        }
        cout << index << endl;
    }
}

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

sum_B = sum(B)
for i in range(0,N-1):
  if A[i]+1 == A[i+1]:
    sum_B += C[A[i]-1]
    
print(sum_B)


Measured memory_bytes: 3060