akhauriyash/Code-Regression huggingface dataset:
import java.io.*
import java.util.*

const val YES = "Yes"
const val NO = "No"

fun solve(H: Int, W: Int, s: Array<String>) {
    for (h in 0 until H) {
        for (w in 0 until W) {
            if (s[h][w] == '.') { continue }
            val adjacents = listOf(
                s.getOrDefault(h + 1, w, '.'),
                s.getOrDefault(h, w + 1, '.'),
                s.getOrDefault(h - 1, w, '.'),
                s.getOrDefault(h, w - 1, '.')
            )
            if (adjacents.count { it == '.' } == 4) {
                println(NO)
                return
            }
        }
    }
    println(YES)
    return
}

fun Array<String>.getOrDefault(i: Int, j: Int, default: Char): Char = when {
    (0 <= i && i < size) -> this[i].getOrElse(j) { default }
    else -> default
}

fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val H = sc.next().toInt()
    val W = sc.next().toInt()
    val s = StringArray(H)
    for (i in 0 until H) {
        s[i] = sc.next()
    }
    solve(H, W, s)
}


Measured memory_bytes: 35748
#!/usr/bin/env python3
import numpy as np


DEBUG = True
dprint = print if DEBUG else lambda *x : x

N, K = [int(str) for str in input().strip().split()]
H = [int(str) for str in input().strip().split()]

if K == 0:
    print(sum(H))
elif K >= len(H):
    print(0)
else:
    H.sort(reverse=True)
    print(sum(H[K:]))


Measured memory_bytes: 43192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

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


int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> a(n);
    
    rep(i,n){
        cin>>a[i];
        a[i]/=2;
    }

    ll lc=1;
    rep(i,n) lc=lcm(lc,a[i]);

    rep(i,n){
        if((lc/a[i])%2==0){
            cout<<0<<endl;
            return 0;
        }
    }

    ll ans=m/lc;
    ans=(ans+1)/2;
    cout<<ans<<endl;
}


Measured memory_bytes: 4044
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e15;
using Graph = vector<vector<int>>;

signed main(){
  int A, B, C, D, K;
  cin >> A >> B >> C >> D >> K;
  
  int oki = (C-A)*60 - B + D;
  cout << max(0LL, oki-K) << endl;
  
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const double pi=3.1415926535;

int main()
{
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    h=h+m*1.0/60;
	m=m*1.0/5;
    double num=fabs(h-m);
    if(num>6.0)num=12.0-num;
    double theta=num*pi/6.0;
    double tot=sqrt(a*a+b*b-2*a*b*cos(theta));
    cout<<fixed<<setprecision(9)<<tot<<endl;
    return 0;
}

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


using namespace std;
struct node{
  char name;
  int win,lost;
  node(char n,int w, int l): name(n),win(w), lost(l){}
  bool operator <(const node &e) const{
    if(win == e.win)
	return lost < e.lost;
    else
      return win > e.win;
  }

  bool operator >(const node &e) const{
    if(win == e.win)
      return lost > e.lost;
    else
      return win < e.win;
      }
};


int main()
{
  int n;
  for(;cin>>n,n;)
    {
      vector<node> data;
      for(int i=0;i<n;i++)
	{
	  char t;
	  cin>>t;
	  int win=0;
	  int lost=0;
	  for(int i=1;i<n;i++)
	    {
	      int tmp;
	      cin>>tmp;
	      if(tmp==0)
		win++;
	      else if(tmp==1)
		lost++;
	    }
	  data.push_back(node(t,win,lost));
	}
      sort(data.begin(),data.end());
      for(int i=0;i<n;i++)
	cout<<data[i].name<<endl;
    }
  
}

Measured memory_bytes: 1192
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize ("Ofast,unroll-loops,-ffloat-store,no-stack-protector")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")

#include <bits/stdc++.h>
using namespace std;

string to_string(const string& s) { return '"' + s + '"'; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cout << "#" << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif
 
#define cin_exception cin.exceptions(cin.failbit);
#define cout_precision cout.setf(ios::fixed); cout.precision(15);
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using ld = long double;  using ui = uint_fast32_t;
using ll = int_fast64_t; using ul = uint_fast64_t;

// -----------------------------------------------------------------------------

void solve() {
    string n; cin >> n;
    int re = 0;
    if (n[0] == '7') re = 1;
    if (n[1] == '7') re = 1;
    if (n[2] == '7') re = 1;
    if (re) cout << "Yes\n";
    else cout << "No\n";
}

// -----------------------------------------------------------------------------

int main() {
    fast_io;
#ifdef LOCAL
    cin_exception;
#endif
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>

#define rep(i,m,n) for(unsigned long long int i=(m);i<(n);++i)
#define rem(i,m,n) for(int i=(m);i>(n);--i)
#define MOD 1000000007

using namespace std;

using ll = long long int;
using std::swap;

vector<long long int> v;
vector<long long int> w;

int main() {
	int a, b;
	cin >> a >> b;
	if (b == 1) { cout << 0 << '\n'; return 0; }

	int ans = 1;
	b -= a;
	while (b > 0) {
		b -= a - 1;
		++ans;
	}
	cout << ans << '\n';

	return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m,x; cin>>n>>m>>x;
  vll c(n);
  vvll a(n, vll(m));
  rep(i,n){
    cin>>c[i];
    rep(j,m){
      cin>>a[i][j];
    }
  }
  
  ll ans=LINF;
  for(ll bit=0; bit<(1<<n); bit++){
    ll tmp=0;
    vll b(m);
    rep(i,n){
      if(bit>>i&1){
        tmp+=c[i];
        rep(j,m){
          b[j]+=a[i][j];
        }
      }
    }
    bool ok=true;
    rep(i,m){
      if(b[i]<x) ok=false;
    }
    if(ok){
      chmin(ans,tmp);
    }
  }
  
  if(ans!=LINF)cout<<ans<<endl;
  else cout<<-1<<endl;
}

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

/*alias*/
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
using ll=long long;

using namespace std;

/*funcs*/

/*input*/

ll n;
ll a[5];

/*main*/
int main(){
    cin>>n>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
    sort(a,a+5);
  ll p=(n-(n%a[0]))/a[0];
  	if(a[0]==1){
      cout<<p+4;
    }else if(a[0]>=n){
      cout<<5;
    }else{
      cout<<p+5;
    }
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)998244353
ll N;
ll D[101010];

ll i, j, k, l;

int main(){
    scanf("%lld", &N);
    fornum(i,0,N){
        scanf("%lld", &D[i]);
    }
    if(D[0]>0){
        printf("0");
        return 0;
    }
    sort(D + 1, D + N);
    if(D[1]==0){
        printf("0");
        return 0;
    }
    j = 0;
    k = 1;
    ll ans = 1;
    fornum(i,1,N){
        if(D[i]-D[i-1]>1){
            ans = 0;
            break;
        }else if(D[i]!=D[i-1]){
            j = k;
            k = 1;
        }else{
            k++;
        }
        ans = (ans * j) % MOD;
        //printf("%lld\n", j);
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int n,a,b,sum_a,sum_b;

int main(void){
  
  while( cin >> n , n ){
    
    sum_a = sum_b = 0;
    for( int i = 0 ; i < n ; i++ ){
      cin >> a >> b;
      if( a > b ) sum_a += a + b;
      if( a < b ) sum_b += a + b;
      if( a == b ){
	sum_a += a;
	sum_b += b;
      }
    }
    cout << sum_a << " " << sum_b << endl;    
  }
  return 0;
}

Measured memory_bytes: 1160
/// Thank you tanakh!!!
///  https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(q: usize, ab: [(usize, usize); q]);
    for &(a, b) in ab.iter() {
        let (a, b) = if a > b { (b, a) } else { (a, b) };
        if a == b {
            println!("{}", 2 * a - 2);
        } else if a + 1 == b {
            println!("{}", 2 * a - 2);
        } else {
            println!("{}", solve2(a, b));
        }
    }
}

fn solve2(a: usize, b: usize) -> usize {
    let mut x = (((a * b) as f64).sqrt() * 2.0) as usize - a - 1;
    let t = if x > a { (x - a - 1) / 2 } else { 0 };
    if (x - t) * (a + 1 + t) >= a * b {
        x -= 1;
    } else if (x - (t + 1)) * (a + 1 + (t + 1)) >= a * b {
        x -= 1;
    }
    a - 1 + x
}


Measured memory_bytes: 4352
#include <iostream>

int main(){
  int A = 0, B = 0, C = 0, K = 0;
  
  std::cin>>A>>B>>C>>K;
  
  if(A > K){
    std::cout<<K;
  }
  else if(A + B >= K){
    std::cout<<A;
  }
  else if(A + B + C >= K){
    std::cout<<2 * A + B - K;
  }
  else{
    std::cout<<A - C;
  }
  
  return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

//昇順
int asc(const void* a, const void* b){
    return *(int*)a-*(int*)b;
}

//降順
int desc(const void* a, const void* b){
    return *(int*)b-*(int*)a;
}

int main(void){
    int H,W;
    scanf("%d%d",&H,&W);

    //map[i][j]には、H=i,W=jのコイン枚数を格納
    int map[H+1][W+1];
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++) scanf("%d",&map[i][j]);
    }

    int N=0;
    int ans[H*W+1][4];

    //奇数枚のコインになる場所を最終列に固める
    for(int i=1;i<=H;i++){
        for(int j=1;j<W;j++){
            if(map[i][j]%2==1){
                N++;

                map[i][j]--;
                map[i][j+1]++;

                ans[N][0]=i;
                ans[N][1]=j;
                ans[N][2]=i;
                ans[N][3]=j+1;
            }
        }
    }

    //最終列に関しても同じことをする
    for(int i=1;i<H;i++){
        if(map[i][W]%2==1){
            N++;

            map[i][W]--;
            map[i+1][W]++;

            ans[N][0]=i;
            ans[N][1]=W;
            ans[N][2]=i+1;
            ans[N][3]=W;
        }
    }

    printf("%d\n",N);
    for(int i=1;i<=N;i++){
        printf("%d %d %d %d\n",ans[i][0],ans[i][1],ans[i][2],ans[i][3]);
    }

    return 0;
}

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

using namespace std;
using ll = long long;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}
int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    int d, e, f;
    d = a + b;
    e = b + c;
    f = c + a;

    cout << min(d, min(e, f)) << endl;

}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        int k = sc.nextInt();
        sc.nextLine();
        int[] x = new int[n];
        int answer = 0;
        for(int i = 0;i<n;i++){
            x[i] = sc.nextInt();
            if(x[i] <Math.abs(k-x[i])){
                answer += x[i]*2;
            }else{
                answer += Math.abs(k-x[i])*2;
            }
        }
        System.out.println(answer);

    }
}

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

#define rp(i, k, n) for (int i = k; i < n; i++)
#define ll  long long

int main() {
    int n;
    cin >> n;
    string s = to_string(n);
    rp (i, 0, 3) {
        if (s.at(i) == '1') {
            s.at(i) = '9';
        } else {
            s.at(i) = '1';
        }
    }
    n = stoi(s);
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			String s = sc.nextLine();
			ArrayDeque<Double> list = new ArrayDeque<Double>();
			
			int i=0;
			int start = 0;
			double p = 0;
			double q = 0;
			String t = "";
			while(true){
				start = i;
				while(s.codePointAt(i)!=32){
					i++;
					if(i==s.length())break;
				}
				t = s.substring(start, i);
				i++;
				if(t.compareTo("+")==0){
					p = list.pop();
					q = list.pop();
					list.push(q+p);
				}else if(t.compareTo("-")==0){
					p = list.pop();
					q = list.pop();
					list.push(q-p);
				}else if(t.compareTo("*")==0){
					p = list.pop();
					q = list.pop();
					list.push(q*p);
				}else if(t.compareTo("/")==0){
					p = list.pop();
					q = list.pop();
					list.push(q/p);
				}else{
					list.push(Double.valueOf(t));
				}
				
				if(i>=s.length())break;
			}
			
			System.out.println(list.pop());
		}
	}	
}

Measured memory_bytes: 17348
h, w = map(int, input().split())
s = [[] for i in range(h+2)]
s[0] = '.'*(w+2)
for i in range(1, h+1):
    s[i] = '.' + input() + '.'
s[h+1] = '.'*(w+2)
s2 = [[False for j in range(w)] for i in range(h)]
judge = True
for i in range(1, h+1):
    for j in range(1, w+1):
        if s[i][j] == "#":
            if [s[i+1][j], s[i-1][j], s[i][j-1], s[i][j+1]] \
            == ['.', '.', '.', '.']:
                judge = False

        else:
            continue
        if not judge:
            break
    if not judge:
        break
if judge:
    print('Yes')
else:
    print('No')

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


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

	switch (N)
	{
	case 1:
		cout << "Hello World" << endl;
		break;
	case 2:
		int A, B;
		cin >> A >> B;
		cout << (A + B) << endl;
		break;
	}

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

int main() {
    int x,y,z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<climits>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<queue>
#include<math.h>

int main(){
	std::string s, t;
	std::cin>>s;
	std::cin>>t;

	int ans=0;

	for(int i=0; i<s.size(); i++)
		if(s[i]==t[i])
			ans++;

	std::cout<<ans<<std::endl;

	return 0;
}

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

int main(void) {
  char a;
  cin >> a;
  if (a == 'A') {
    cout << 'T' << endl;
  } else if (a == 'T') {
    cout << 'A' << endl;
  } else if (a == 'C') {
    cout << 'G' << endl; 
  } else if (a == 'G') {
    cout << 'C' << endl; 
  }return 0;
}

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

const ll maxs = 2e5+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'

void pre(){
    
}

void solve(){
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n+1),b;
    for(ll i=0;i<n;i++){
        cin >> a[i];
        a[i]--;
    }
    bool visited[n+1];
    memset(visited,false,sizeof visited);

    ll ind = 0;
    ll curr = 0;
    map<ll,ll> MAP;
    while(1){
        if(visited[ind]){
            break;
        }
        b.pb(ind);
        MAP[ind] = curr;
        visited[ind] = true;
        ind = a[ind];
        curr++;
    }
    ll sz = curr - MAP[ind];

   if( k < MAP[ind] ){
       cout << b[k] + 1; // +1 for 1 base
   }
   else{
       k -= MAP[ind];
       k %= sz;
       cout << b[MAP[ind] + k] + 1; //+1 for 1 base
   }
}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 18680
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = (ll)1e9;
auto x = vector<double>();
auto y = vector<double>();
auto c = unordered_map<string,double>();
int n;

void dfs(string used){
	if(used.size()>n) return;
	for(int i=0;i<n;i++){
		int num = count_if(used.begin(),used.end(),[i](char x){
			return (int)(x-'0')==i; 
		});
		if(num >1) return;
	}

	if(used.size()==n){
      	if(c[used]==0){
			double sum = 0;
			for(int i=0;i<n-1;i++){
              	int nei = used[i+1]-'0';
				int cui = used[i]-'0';
              	double xx = (x[nei]-x[cui])*(x[nei]-x[cui]);
				double yy = (y[nei]-y[cui])*(y[nei]-y[cui]);
				sum +=sqrt(xx+yy);
              	
			}
          	c[used]=sum;
		}else return;
	}


	for(int i=0;i<n;i++){
		dfs(used+to_string(i));
	}
}


int main(){
	cin >> n;
	x.resize(n,0);
	y.resize(n,0);
	
	for(int i=0;i<n;i++){
		cin >> x[i] >> y[i];
	}
	dfs("");
  	
  	double ans =0;
	for(auto i:c){
    	ans +=i.second/c.size();
    }
    cout << setprecision(10) << fixed <<ans << endl;
    
  	return 0;
}

Measured memory_bytes: 4492
N= int(input())
#hn=list(map(lambda i:int(i),input().split()))
hn=list(map(int,input().split()))

inf = 10**10
dp = [inf]*N #dpを初期化

def checkMin(a,b):
    if a>b:
        return b
    else:
        return a

dp[0]=0
dp[1]=abs(hn[0]-hn[1])
for i in range(2,N):
    doubleStep= dp[i-2]+abs(hn[i]-hn[i-2])
    singleStep= dp[i-1]+abs(hn[i]-hn[i-1])
    dp[i]= checkMin(doubleStep,singleStep)

print(dp[N-1])


Measured memory_bytes: 13924
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var N = int.Parse(input[0]);
        var A = int.Parse(input[1]);

        var S = new List<string>();
        for (var i = 0; i < N; i++)
        {
            S.Add(Console.ReadLine());
        }
        
        S.Sort(string.CompareOrdinal);
        
        Console.WriteLine(string.Join("", S));
    }
}


Measured memory_bytes: 27504
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

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

    int r = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        
        r += min(x, k - x);
    }

    cout << r * 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;

ll distance2(int x, int y)
{
	return (ll)x * (ll)x + (ll)y * (ll)y;
}

int main()
{
	int n;
	cin >> n;
	vector<char> ar(n);

	for (int i = 0; i < n; i++) {
		cin >> ar[i];
	}
	int left = 0;
	int right = n - 1;
	int ans = 0;

	while (true) {
		//printf("[%d:%d]->", left + 1, right + 1);
		while (left < n && ar[left] == 'R')left++;
		while (right >= 0 && ar[right] == 'W')right--;
		//printf("[%d:%d]\n", left + 1, right + 1);
		if (left < right) {
			ans++;
			left++;
			right--;
		} else {
			break;
		}
	}

	printf("%d", ans);



	return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>

int main(void){

  int sum=100000,add=0,i,j;

  scanf("%d",&j);

  for(i=0;i<j;i++){
    sum*=1.05;
    if( (add=sum%1000)>0 ){
      sum-=add;
      sum+=1000;
    }
    
  }
  printf("%d\n",sum);

  return 0;
}

Measured memory_bytes: 592
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 #include<memory>
 
 using namespace std;

 int main()
 {
   int a,b; 
   while(cin>>a>>b)
   {
     cout<<(2*b-a)<<endl;  
   } 
   return 0;
 }
 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int n,m[100],a[100],b[100];
bool ans;

int main(void){

  while( cin >> n , n ){

    for( int i = 0 ; i < n ; i++ ){
      cin >> m[i] >> a[i] >> b[i];
    }

    ans = false;
    for( int i = 0 ; i < n ; i++ ){
      int c = m[i]; 
      for( int j = 0 ; j < n ; j++ ){
	if( i == j ) continue;
	if( a[j] <= a[i] && a[i] < b[j] ) c+= m[j];
      }
      // 時間ないのところ全てに m を加えていく
      if( c > 150 ){
	ans = true;
	break;
      }
    }
    if( ans ) cout << "NG" << endl;
    else cout << "OK" << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>H(N);
  for (int i=0;i<N;++i){
    cin>>H[i];
  }
  vector<int>c(N,0);
  for (int i=1;i<N;++i){
    if (i==1){
      c[i]=c[i-1]+abs(H[i]-H[i-1]);
    } else{
      c[i]=min(c[i-1]+abs(H[i]-H[i-1]),
               c[i-2]+abs(H[i]-H[i-2]));
    }
  }
  cout<<c[N-1]<<endl;
}                                    
                                    


Measured memory_bytes: 1024
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<int> a(n + 1), res(n + 1);
	for (int i = 1; i <= n; ++i)cin >> a[i];
	int cnt = 0;
	for (int i = n; i > 0; --i)
	{
		int one = a[i];
		for (int j = i + i; j <= n; j += i)
		{
			if (res[j])one = 1 - one;
		}
		res[i] = one;
		if (one)++cnt;
	}
	cout << cnt << endl;
	for (int i = 1; i <= n; ++i)if (res[i])cout << i << " ";
}

Measured memory_bytes: 4632
K = int(input())
s = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
p = [int(x) for x in s.split(',')]
print(p[K-1])

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 61)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



i64 h,w,k, a,b,c,d;
string s[1010101];
void solve(){
	cin >> h >> w >> k;
	cin >> a >> b >> c >> d;
	a--; b--; c--; d--;
	for(int i = 0; i < h; i++){
		cin >> s[i];
	}
	
	vector<vector<int>> v(h,vector<int>(w,INF));
	queue<pair<P,int>> q;
	q.push(make_pair(P(a,b),0));
	v[a][b] = 0;
	int dx[4] = {0,-1,0,1}, dy[4] = {1,0,-1,0};
	while(!q.empty()){
		auto p = q.front(); q.pop();
		int x = p.first.first, y = p.first.second, cnt = p.second;
		if(v[x][y] != cnt) continue;
		if(x == c && y == d){
			cout << cnt << endl;
			return;
		}
		for(int i = 0; i < 4; i++){
			for(int j = 1; j <= k; j++){
				int nx = x+dx[i]*j, ny = y+dy[i]*j;
				if(nx<0||ny<0||nx>=h||ny>=w) break;
				if(v[nx][ny] < cnt+1) break;
				if(s[nx][ny] == '@') break;
				if(chmin(v[nx][ny], cnt+1)){
					q.push(make_pair(P(nx,ny),cnt+1));
				}
			}
		}
	}
	cout << -1 << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 43740
// In The Name Of God
/*
ID: alimora2
LANG: C++11
TASK: PROB
*/
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int n, a;
	cin >> n >> a;
	return cout << n * n - a << endl, 0;
}

Measured memory_bytes: 256
import copy

cards = list(map(int, input().split()))
k = int(input())

ans = set()
for i in range(3**k):
    n = i
    s = []
    while n:
        s.append(n % 3)
        n //= 3
    m = len(s)
    res = 0
    cards_copy = copy.deepcopy(cards)
    for j in range(m):
        cards_copy[s[j]] *= 2
    a, b, c = cards_copy
    if a < b < c:
        print("Yes")
        exit()
print("No")


Measured memory_bytes: 9340
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int d[maxn],f,n;
vector <int> mp[maxn];

inline void dfs(int u,int fa)
{
	for(int i=0;i<mp[u].size();i++)
	{
		int v=mp[u][i]; if(v==fa) continue;
		d[v]=d[u]+1; dfs(v,u);
	}
}

int main()
{
	n=read();
	rep(i,1,(n-1))
	{
		int u=read(),v=read();
		mp[u].pb(v); mp[v].pb(u);
	}
	dfs(1,0); int mx=0;
	rep(i,1,n) if(d[i]>mx) {mx=d[i]; f=i;}
	rep(i,1,n) d[i]=0; dfs(f,0);
	rep(i,1,n) mx=max(mx,d[i]); mx++;
	if(mx%3==2) puts("Second"); else puts("First");
	return 0;
}

Measured memory_bytes: 46568
#include<stdio.h>
#include<string.h>
int main(){
	char input[3][30];
	int panjang[3];
	for(int i=0; i<3;i++){
	scanf("%s", input[i]);
	panjang[i]=strlen(input[i]);
	}
	
	if(input[0][panjang[0]-1]==input[1][0] &&input[1][panjang[1]-1]==input[2][0] ){
		puts("YES");
	}
	else{
		puts("NO");
	}
	
	return 0;
}

Measured memory_bytes: 1632
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000


int main(){
	
	int A,B;
	cin>>A>>B;
	
	int now = 1;
	
	for(int i=0;true;i++){
		if(now>=B){
			cout<<i<<endl;
			return 0;
		}
		
		now--;
		now+=A;
	}
		
	
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int, bool> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n;

vector<p> G[100000];
bool ans[100000];
bool used[100000];
void add_edge(int u, int v, bool w)
{
    G[u].push_back(make_pair(v, w));
    G[v].push_back(make_pair(u, w));
}
void dfs(int u, bool c)
{
    bool c1 = c;
    used[u] = true;
    if (G[u].size() == 0)
    {
    }
    else
    {
        for (int i = 0; i < G[u].size(); i++)
        {
            if (used[G[u][i].first] == true)
                continue;
            if (G[u][i].second == c)
            {
                c1 = false;
                ans[G[u][i].first] = false;
            }
            else
            {
                c1 = true;
                ans[G[u][i].first] = true;
            }
            dfs(G[u][i].first, c1);
        }
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n - 1; i++)
    {
        int u, v;
        ll w1;
        bool w;
        cin >> u >> v >> w1;
        if (w1 % 2 == 0)
            w = false;
        else
            w = true;
        add_edge(u - 1, v - 1, w);
    }
    for (int i = 0; i < n; i++)
    {
        used[i] = false;
    }
    ans[0] = false;
    dfs(0, false);
    for (int i = 0; i < n; i++)
    {
        if (ans[i] == false)
        {
            cout << 0 << "\n";
        }
        else
        {
            cout << 1 << "\n";
        }
    }
}

Measured memory_bytes: 8192
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int s;
int D[10] ={0,1,2,3,4,5,6,7,8,9};
int ans;

void dfs(int sum,int i,int n){
  if(sum ==s&& n==0){
    ans++;
    return;
  }
  if(i ==10||n==0)return;
  dfs(sum+i,i+1,n-1);//足す
  dfs(sum,i+1,n);//足さない
}

int main()
{
  int n;
  while(cin>>n>>s,n||s){
    ans = 0;
    dfs(0,0,n);
    cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif
#define rep(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
typedef long long ll;

signed main() {
    int X, Y;
    cin >> X >> Y;
    if (X % Y == 0) {
        cout << -1 << endl;
    } else {
        cout << X << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Harshad
 */

#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
typedef long long int ll;
using namespace std;

class a1 {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n,x; in>>n>>x;
        int arr[n]; f(i, n) in>>arr[i];
        ll res=0;
        rep(i, 1, n-1){
            if(arr[i]+arr[i-1]>x){
                int remove = (arr[i]+arr[i-1]-x);
                res+=remove;
                if(remove<arr[i]) arr[i]-=remove;
                else{
                    remove-=arr[i];
                    arr[i]=0;
                    arr[i-1]-=remove;
                }
            }
        }
        out<<res;

	}
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	a1 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'

int n, m;
int a[500];

int main()
{
	IOS;
	cin >> n >> m;
	int c = 0;
	for (int i = 1; i <= n; i++) {
		c += (m + i - 1);
	}
	int ans = 1000000, p;
	for (int i = 1; i <= n; i++) {
		if (abs(c - c - (m + i - 1)) < ans) {
			ans = abs(c - c - (m + i - 1));
			p = c - (m + i - 1);
			//db(ans, p);
		}
	}
	cout << p << endl;
	return 0;
}



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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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() {
  string S; cin >> S;
  int ans = 0;
  REP(i, 4) {
      if(S[i] == '+') ans++;
      else ans--;
  }
  cout << ans << endl;
}

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


void solve(long long a, long long b){
    cout<<(a<10&&b<10?a*b:-1)<<endl;
}

int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    solve(a, b);
    return 0;
}


Measured memory_bytes: 256
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Data.Tuple.Extra

main = do
  let readInt = fmap (second B.tail) . B.readInt
  n <- readLn
  xs <- VU.unfoldrN n readInt <$> B.getLine
  print $ solve n xs

solve n xs = VU.foldl (+%) 0 ys
  where
    (+%) x y = (x + y) `mod` (10^9 + 7)

    (*%) x y = (x * y) `mod` (10^9 + 7)

    ss = VU.scanl (+%) 0 xs

    ys = VU.generate n $ \i ->
      (xs VU.! i) *% ((ss VU.! n) - (ss VU.! (i+1)))


Measured memory_bytes: 29048
#include <bits/stdc++.h>
#define rg register
#define us unsigned
#define ll long long
#define ui <int>
#define pi <int, int>
#define tmpl template <typename typ>
#define oprt operator
#define sp putchar(32)
#define el putchar(10)
#define flin(x) freopen(x, "r", stdin)
#define flout(x) freopen(x, "w", stdout)
#define flio(x) flin(x".in"), flout(x".out")
#define ms(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define itrt iterator
using namespace std;
tmpl inline bool up(typ &x, const typ &y) { return x < y ? x = y, 1 : 0; }
tmpl inline bool dn(typ &x, const typ &y) { return y < x ? x = y, 1 : 0; }
tmpl inline bool inr(const typ &x, const typ &l, const typ &r) { return !(x < l) && !(r < x); }
namespace orh {
inline void useios() { ios_base::sync_with_stdio(false); cin.tie(0); }
inline char rc() { rg char ch; while (!isgraph(ch = getchar())); return ch; }
tmpl typ ri() {
	rg typ x = 0; rg bool neg = false; rg char ch;
	while (!inr(ch = getchar(), '0', '9')) neg |= ch == '-';
	do x = (x << 1) + (x << 3) + (ch ^ 48); while (inr(ch = getchar(), '0', '9'));
	return neg ? -x : x;
}
tmpl typ ru() {
	rg typ x = 0; rg char ch;
	while (!inr(ch = getchar(), '0', '9'));
	do x = (x << 1) + (x << 3) + (ch ^ 48); while (inr(ch = getchar(), '0', '9'));
	return x;
}
tmpl void wi(rg typ x) {
	if (x < 0) { putchar('-'); x = -x; }
	static int sta[42]; rg int top = 0; rg typ t;
	do t = x / 10, sta[top++] = x - (t << 1) - (t << 3), x = t; while (x);
	while (top) putchar(sta[--top] ^ 48);
}
tmpl void wu(rg typ x) {
	static int sta[42]; rg int top = 0; rg typ t;
	do t = x / 10, sta[top++] = x - (t << 1) - (t << 3), x = t; while (x);
	while (top) putchar(sta[--top] ^ 48);
}
}

ll n;

ll dfs(ll x) {
	if (x == 1) return 1;
	ll t = dfs(x / 2ll);
	return t + t + 1;
}

signed main() {
	orh::useios();
	
	cin >> n;
	
	cout << dfs(n) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <set>

using namespace std;

int main(void) {
  int n;
  cin >> n;
  set<int> st;
  for (int i = 0; i < n; i++) {
    int ai;
    cin >> ai;
    auto itr = st.find(ai);
    if (itr == st.end()) {
      st.insert(ai);
    } else {
      st.erase(itr);
    }
  }

  cout << st.size() << endl;
  return EXIT_SUCCESS;
}


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

int main(){

    string a, b, c;

    cin >> a >> b >> c;

    if(a[a.length() -1] == b[0] && b[b.length() -1] == c[0]){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

    return 0;

}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//

ll comb(ll x) {
  ll res = x*(x-1)/2;
  return res;
}

int main() {
  int n;
  cin >> n;
  vector<ll> d(n);
  rep(i, n) {
    ll a;
    cin >> a;
    if (i == 0) d[i] = a;
    else d[i] = d[i-1] + a;
  }
  sort(ALL(d));
  ll ans = 0;
  ll now = d[0];
  ll c = 1;
  if (d[0] == 0) ans++; 
  rrep(i, n-1) {
    if (d[i] == 0) ans++;
    if (d[i] == now) c++;
    else {
      ans += comb(c);
      now = d[i];
      c = 1;
    }
  }
  ans += comb(c);
  
  cout << ans << endl;
}

Measured memory_bytes: 4820
def main():
    import sys
    from collections import deque
    input = sys.stdin.readline

    H, W = map(int, input().split())
    grid = []
    for _ in range(H):
        line = input().rstrip('\n')
        grid.append(line)

    d = [(0, 1), (0, -1), (1, 0), (-1, 0)]
    ans = 0
    for i in range(H):
        for j in range(W):
            if grid[i][j] == '#':
                continue
            ans_new = 0
            seen = [[-100] * W for _ in range(H)]
            seen[i][j] = 0
            que = deque()
            que.append(i*W+j)
            while que:
                v = que.popleft()
                y, x = divmod(v, W)
                for dx, dy in d:
                    x_new = x+dx
                    y_new = y+dy
                    if 0 <= y_new < H and 0 <= x_new < W:
                        if seen[y_new][x_new] == -100:
                            if grid[y_new][x_new] == '.':
                                que.append(y_new * W + x_new)
                                seen[y_new][x_new] = seen[y][x] + 1
                                if ans_new < seen[y_new][x_new]:
                                    ans_new = seen[y_new][x_new]
            ans = max(ans, ans_new)

    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

int main()
{
    string S;
    int flag = 1;
    vector<char> v;
    cin >> S;

    for (int i = 0; i < S.length(); i++)
    {
        v.push_back(S[i]);
    }

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

    for (int i = 0; i < v.size(); i++)
    {
        if (v[i] == v[i + 1])
        {
            cout << "no";
            flag = 1;
            break;
        }
        flag = 0;
    }

    if (flag == 0)
    {
        cout << "yes";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int N, M, X;
    cin >> N >> M >> X;
    vector<vector<ll>> a(N, vector<ll>(M));
    vector<int> c(N);
    rep(i, N){
        cin >> c[i];
        rep(j, M){
            cin >> a[i][j];
        }
    }
    ll ans = INF;
    for(int bit = 0; bit < (1<<N); bit++){
        bitset<12> s(bit);
        vector<ll> algo(M, 0);
        ll tmp = 0;
        rep(i, N){
            if(s.test(i)){
                rep(j, M) algo[j] += a[i][j];
                tmp += c[i];
            }
        }
        bool flag = true;
        rep(i, M){
            if(algo[i] < X){
                flag = false;
                break;
            }
        }
        if(flag == true) ans = min(ans, tmp);
    }
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3636
N = int(input())
c = [int(input()) for _ in range(5)]

key = min(c)

ans = 0

if N % key == 0:
    ans = N / key
else:
    ans = N // key + 1

print(int(ans + 4))

#anss = 4 + int((N+key-1)/key)
#print(anss)

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int a, b, k;
  cin >> a >> b >> k;
  set<int> s;
  for (int i = a; i <= min(a + k - 1, b); i++) s.insert(i);
  for (int i = max(b - k + 1, a); i <= b; i++) s.insert(i);
  for (auto i : s) cout << i << '\n';
}


Measured memory_bytes: 3508
/*
#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  red(i,n) for(li i=n-1;i>=0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;

const li INF = 1001001001;

int main()
{
    li n,m;
    cin>>n>>m;
    li a[n],b[n],c[m],d[m];
    rep(i,n) cin>>a[i]>>b[i];
    rep(i,m) cin>>c[i]>>d[i];
    rep(i,n) {
        li mij=0,mi=INF;
        rep(j,m) if(abs(a[i]-c[j])+abs(b[i]-d[j])<mi) mi=abs(a[i]-c[j])+abs(b[i]-d[j]),mij=j;
        cout<<mij+1<<endl;
    }
    return 0;
}

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

int main(){
	int a,b,x;cin >> a >> b >> x;
  	if(a+b<x){
    	cout << "NO";
    }else if(a>x){
    	cout << "NO";
    }else{
    	cout << "YES";
    }
  	return 0;
}


Measured memory_bytes: 256
N=int(input())
a,b,c,d=0,0,0,0
for i in range(N):
  A=input()
  if A=="AC":
    a+=1
  elif A=="WA":
    b+=1
  elif A=="TLE":
    c+=1
  else:
    d+=1
print("AC x",a)
print("WA x",b)
print("TLE x",c)
print("RE x",d)

Measured memory_bytes: 9204
#python3
from heapq import heappop
from heapq import heappush
def main():
    n, m = map(int, input().split())
    works = [[] for _ in range(m)]
    for _ in range(n):
        a, b = map(int, input().split())
        if a > m:
            continue
        works[m-a].append(b)
    s = 0
    h = [] 
    for i in reversed(range(m)):
        for b in works[i]:
            heappush(h, -b)
        if len(h) != 0:
            s += -heappop(h)
    print(s)
main()


Measured memory_bytes: 18484