akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define eb emplace_back
#define v(t) vector<t>
#define vv(t) vector<vector<t>>
#define vn(t,n,val) vector<t>(n,val)
#define vvn(t,r,c,val) vector<vector<t>>(r, vector<t>(c,val))
#define vvv(t) vector<vector<vector<t>>>
#define vvvn(t,l,b,h,val) vector<vector<vector<t>>>(l,vector<vector<t>>(b,vector<t>(h)))
#define bc(x) __builtin_popcountll(x)


v(int) get_row_groups(int b, int h){
	v(int) row_groups = {0};
	for(int i = 0; i < h; i++){
		if(b&1) row_groups.eb(i+1);
		b >>= 1;
	}
	row_groups.eb(h);
	return row_groups;
}

bool sum_col_ok(v(string)& a, v(int)& row_groups, int ci, v(int)& col_sum, int limit){
	int gs = row_groups.size();
	for(int i = 0; i < gs-1; ++i){
		for(int ri = row_groups[i]; ri < row_groups[i+1]; ri++){
			if(a[ri][ci] & 1){
				col_sum[i] += 1;
			}
			if(col_sum[i] > limit) return false;
		}
	}
	return true;
}

int main() {
	sp;

	////////////////To Remove//////////////
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	///////////////////////////////////////

	int h,w,k;
	cin>>h>>w>>k;

	v(string) a(h);

	for(int i=0; i < h; ++i) cin>>a[i];

	int h_split_ways = 1<<(h-1);

	int min_lines = 1e9;
	int current_lines;

	for(int i=0; i < h_split_ways; ++i){
		current_lines = bc(i);
		v(int) row_groups = get_row_groups(i, h);

		v(int) col_groups = {0};
		bool possible = true;
		v(int) col_sum(row_groups.size(), 0);
		for(int ci = 0; ci < w; ci++){
			if(!sum_col_ok(a, row_groups, ci, col_sum, k)){
				if(col_groups.back() == ci){
					possible = false;
					break;
				}
				col_groups.eb(ci);
				ci--;
				col_sum = vn(int, row_groups.size(), 0);
			}
		}
		if(possible){
			min_lines = min(min_lines, bc(i) + (int)col_groups.size() - 1);
		}
	}

	cout<<min_lines;

  	return 0;
}

Measured memory_bytes: 256
(* quite naive implementation *)
let rec dikjstra ( +. ) ( < ) q edge d =
  match q with
  | [] -> ()
  | u :: q ->
      let u, q = 
        List.fold_left (fun (u, q') u' ->
          if d.(u) < d.(u') then (u, u' :: q')
          else (u', u :: q')) (u, []) q in
      List.iter (fun (v, c) ->
        if c +. d.(u) < d.(v) then
          d.(v) <- c +. d.(u)) (edge u);
      dikjstra ( +. ) ( < ) q edge d

let () =
  let h, w = Scanf.scanf "%d %d\n" (fun h w -> h, w) in
  let css =
    Array.init 10 (fun _ ->
      Array.init 10 (fun i ->
        Scanf.scanf "%d " (fun c -> c))) in
  let css' =
    Array.init 10 (fun i ->
      Array.to_list @@ Array.init 10 (fun j -> (j, css.(j).(i)))) in
  let ass =
    Array.init h (fun _ ->
      Array.init w (fun _ ->
        Scanf.scanf "%d " (fun a -> a))) in
  let cost = Array.make 10 1145141919 in
  cost.(1) <- 0;
  dikjstra ( + ) ( < ) [1; 2; 3; 4; 5; 6; 7; 8; 9; 0] (fun i -> css'.(i)) cost;
  Printf.printf "%d\n" @@ Array.fold_left ( + ) 0 @@ Array.map (fun as_ ->
    Array.fold_left ( + ) 0 @@ Array.map (function -1 -> 0 | n -> cost.(n)) as_) ass


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


using namespace std;
double pi=3.14159265358979323846264338;


inline void ex(){cout<<"Yes"<<endl;exit(0);}
long long a,b,c,d;
const long long N=1000000007;

long long n;
bool ok[1000001];
long long arr[1000001];
long long arr2[2][4];
long long calc(long long a,long long b){
	long long cnt=1;
	while(b%a==0){
		b=b/a;
		cnt++;
	}
	return cnt;
}
int main(){
	ok[1]=true;
	for(int i=1;i<1000001;i++)arr[i]=1LL;
	for(long long i=2;i<1000001;i++){
		if(ok[i])continue;
		for(long long j=i;j<1000001;j+=i){
			arr[j]*=calc(i,j);
			ok[j]=true;
		}
	}
	
	cin>>n;
	long long cnt=0;
	for(long long i=1;i<n;i++){
		cnt+=arr[n-i];
	}
	cout<<cnt<<endl;
	return 0;
			
}

Measured memory_bytes: 12424
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
# debug = lambda *a, **kw: print(*a, **kw, file=sys.stderr)

X, N = inm()
P = inl()


def solve():
    ps = set(P)
    if X not in ps:
        return X

    mv = 1000
    my = 10000
    for y in range(-1, 102):
        if y in ps:
            continue
        if abs(y - X) < mv or abs(y - X) == mv and y < my:
            mv = abs(y - X)
            my = y
    return my


print(solve())


Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

int main(){
	int H1,M1,H2,M2,K;
	cin>>H1>>M1>>H2>>M2>>K;
	int x=(H2-H1)*60;
	int y=M2-M1;
	cout<<max(x+y-K,0)<<endl;
	return 0;
}

Measured memory_bytes: 3636
S = int(input())

A = S//100
B = S%100

if A >= 13 or A == 0:
    if B >= 13:
        print('NA')
    elif B <13:
        if B != 0:
            print('YYMM') 
        else:
            print('NA')
elif A < 13:
    if B >= 13:
            print('MMYY')
    elif B < 13:
        if B != 0:
            print('AMBIGUOUS')
        else:
            print('MMYY')


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

#define MAX_N 300

int n, a[MAX_N];

double dp[MAX_N + 1][MAX_N + 1][MAX_N + 1];
double rec(int i, int j, int k) {
  if(dp[i][j][k] >= 0) return dp[i][j][k];
  if(i == 0 && j == 0 && k == 0) return 0.0;

  double res = 0.0;
  if(i > 0) res += i * rec(i - 1, j, k);
  if(j > 0) res += j * rec(i + 1, j - 1, k);
  if(k > 0) res += k * rec(i, j + 1, k - 1);
  res += n;
  res /= (double)(i + j + k);

  dp[i][j][k] = res;
  return res;
}

int main() {
  std::cin >> n;
  for(int i = 0; i < n; ++i) {
    std::cin >> a[i];
  }
  std::memset(dp, -1, sizeof(dp));

  int i = 0, j = 0, k = 0;
  for(int t = 0; t < n; ++t) {
    if(a[t] == 1) ++i;
    else if(a[t] == 2) ++j;
    else ++k;
  }

  std::cout << std::fixed << std::setprecision(10) << rec(i, j, k) << std::endl;
}


Measured memory_bytes: 213376
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define oo 0x3f3f3f3fLL
#define sz(s) (int)(s.size())
#define RT(s) return cout<<s,0
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

void read(vector<int> &r, int a) {
	r = vector<int>(a);
	for (auto &it : r)
		cin >> it;
	sort(all(r));
	reverse(all(r));
}

int main() {
	run();
	int red, green, a, b, c;
	vector<int> r, g, col;
	cin >> red >> green >> a >> b >> c;
	int cnt = red + green;
	read(r, a);
	read(g, b);
	read(col, c);
	for (int i = 0; i < red; i++)
		col.push_back(r[i]);
	for (int i = 0; i < green; i++)
		col.push_back(g[i]);
	sort(all(col));
	reverse(all(col));
	ll ans = 0;
	for (int i = 0; i < cnt; i++)
		ans += col[i];
	cout << ans << endl;
}


Measured memory_bytes: 2552
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
 
void read (int&a) {
	a = 0; char k = getchar(); int f = 1;
	for(;!isdigit(k); k = getchar()) if (k == '-') f = -1;
	for(; isdigit(k); k = getchar()) a = a * 10 + k - '0';
	a *= f;
}

int main ()
{
	double k, pi = acos(-1);
	scanf ("%lf", &k);
	printf ("%.10lf\n", 2 * pi * k);
	return 0;
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long 
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define REP(i,n) for (int i=0; i<(n); i++)
#define RREP(i,n) for (int i=(n-1); i>=0; i--)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define SQ(x) (x)*(x)
#define MN(a,b) a = min(a,(__typeof__(a))(b))
#define MX(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define bug(x) cerr<<#x<<" is "<<x<<endl

using namespace std;

#define int ll

const int iinf = 1<<29;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;


void GG(){cout<<"NO\n"; exit(0);}

ll mpow(ll a, ll n){ // a^n % mod
    ll re=1;
    while (n>0){
        if (n&1) re = re*a %mod;
        a = a*a %mod;
        n>>=1;
    }
    return re;
}

ll inv (ll b){
    if (b==1) return b;
    return (mod-mod/b) * inv(mod%b) % mod;
}

const int maxn = 1e5+5;

main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n; cin>>n;
    vector<int> a(n);
    int S = 0;
    ll ss = n * (ll)(n+1) / 2;
    REP(i,n) {
        cin>>a[i]; S += a[i]; 
    }
    if (S%ss != 0){
        GG();
    }
    S/=ss;
    int tt = 0;
    int nat = 0;
    REP(i,n){
        int d = a[(i+1)%n] - a[i] - S;
        if (d > 0 || d%n != 0){
            GG();
        }
        nat -= d/n;
    }
    if (nat != S) GG();
    cout<<"YES\n";
    
} 



Measured memory_bytes: 1024
n,q = map(int,input().split())
s = input()
lr = [list(map(int,input().split())) for i in range(q)]

aclist = [0,0]
acsum = 0

for i in range(1,n):
    if s[i-1] == "A" and s[i] == "C":
        acsum += 1
    aclist.append(acsum)

for i in range(q):
    if aclist [lr[i][0]] - aclist [lr[i][0]-1] != 0:
        ans = aclist[lr[i][1]] - aclist[lr[i][0]-1] - 1 
    else:
        ans = aclist[lr[i][1]] - aclist[lr[i][0]-1]
    print(ans)


Measured memory_bytes: 30704
import java.util.*;

public class Main{

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

	 int a=sc.nextInt();
	 int b=sc.nextInt();
	 int c=sc.nextInt();
	 int x=sc.nextInt();
	 int count=0;
	 int xx=x;
	 int cc=0;



	 for(int i=0;i<=x/500;i++){
		 for(int k=0;k<=x/100;k++){
			 xx=x;
			 xx-=500*i+100*k;
			 if(xx>=0){
				 cc=xx/50;
					if(i<=a && k<=b && cc<=c){
						count++;
					}
			 }
		 }
	 }

	 System.out.println(count);




	}
}


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

using ll=long long;

int main() {
  int N; cin >>N;
  string S; cin >>S;
  int K; cin >>K;
  char a=S[K-1];
  rep(i,0,N) {
    if (S[i]!=a) {
      S[i]='*';
    }
  }
  cout <<S <<endl;
  return 0;
}


Measured memory_bytes: 3636
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        s: chars
    }
    let n = s.len();
    let mut blacks = vec![0u64;n + 1];
    for i in 0..n {
        blacks[i+1] = blacks[i] + (s[i] == 'B') as u64;
    }

    let mut ret = 0;
    for i in 0..n {
        if s[i] == 'W' {
            ret += blacks[i];
        }
    }
    println!("{}", ret);
}


Measured memory_bytes: 6396
N = int(input())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))

k = 2**N
totallist = [0]*k
for b in range(k):
    total = 0
    for i in range(N):
        if b >> i & 1 == 1:
            total += A[i]
    totallist[b] = total

for m in M:
    print('yes') if m in totallist else print('no')


Measured memory_bytes: 42964
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
#define DIV0 1000000007
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
int main()
{
    int N;
    cin >> N;
    ll A[N];
    ll total = 0;
    REP(i,N){
        cin >> A[i];
        total ^= A[i];
    }
    REP(i,N){
        cout << (total ^ A[i]) << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4716
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <float.h>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

// Q1
int main()
{
	char szY[10];
	memset(szY, NULL, sizeof(szY));
	cin >> szY;
	int nRet = 0;
	if (0 == strcmp("SUN", szY))
		nRet = 7;
	else if (0 == strcmp("MON", szY))
		nRet = 6;
	else if (0 == strcmp("TUE", szY))
		nRet = 5;
	else if (0 == strcmp("WED", szY))
		nRet = 4;
	else if (0 == strcmp("THU", szY))
		nRet = 3;
	else if (0 == strcmp("FRI", szY))
		nRet = 2;
	else if (0 == strcmp("SAT", szY))
		nRet = 1;

	cout << nRet;
	return 0;
}



Measured memory_bytes: 256
from fractions import gcd
from functools import reduce
n=int(input())
l=[int(input()) for i in range(n)]
def lcm(x,y):
  return x*y//gcd(x,y)
def lcm_list(numbers):
  return reduce(lcm,numbers,1)
ans=lcm_list(l)
print(ans)

Measured memory_bytes: 5076
#include <bits/stdc++.h>
#include <numeric>
#include <iomanip>
#define ll long long
#define intm INT_MAX
#define llm LLONG_MAX

using namespace std;
typedef pair<int,int> P;
const int MOD = 998244353;
const ll mod = 1e9 + 7;
const int mxN = 1e6 + 9;


int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
    int n,d,x,y;
    cin >> n >> d;
    int ans = 0;
    ll bound = 1LL*d*d;
    for(int i=1; i <= n; i++){
        cin >> x >> y;
        if( 1LL*x*x + 1LL*y*y <= bound ) ++ans;
    }
    cout << ans;

}




Measured memory_bytes: 3648
N = int(input())
H = list(map(int, input().split()))

if sum(H) == 0:
    print(0)
    exit()

for _ in range(100000):
    status = 0
    for i, x in enumerate(H):

        if x != 0:
            H[i] = x - 1
            status = 1
        elif ((x == 0) and (status == 1)):
            break
        else:
            pass
    if sum(H) == 0:
        break

print(_ + 1)


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

int main(){
 int n;
  cin >> n;
  vector<long> a(n);
  long sum=0;
  for(int i=0;i<n;i++){
   cin >> a[i];
    sum+=a[i];
  }

  if(sum%2==0) cout << "YES" << endl;
  else cout << "NO" << endl;  
}

Measured memory_bytes: 1024
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String A = sc.next();
        String B = sc.next();
        String C = sc.next();
        StringBuilder sb = new StringBuilder();
        sb.append((char)(A.charAt(0)+'A'-'a'));
        sb.append((char)(B.charAt(0)+'A'-'a'));
        sb.append((char)(C.charAt(0)+'A'-'a'));
        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 20688
s = input()
ans = 10 ** 10
for i in range(26):
    c = chr(ord("a") + i)
    s_c = list(s)
    cnt = 0
    while len(set(s_c)) != 1:
        t = ""
        for i in range(len(s_c) - 1):
            if s_c[i + 1] == c:
                t += c
            else:
                t += s_c[i]
        cnt += 1
        s_c = t
    ans = min(ans, cnt)

print(ans)

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new AOJ1024().doIt(in.nextInt());
		while(in.hasNext()){
			int n =in.nextInt();
			if(n==0)return;
			System.out.println();
			new AOJ1024().doIt(n);
		}
	}

	class AOJ1024{
		void doIt(int n){
			if(n==0)return;
			ArrayList<Team> list = new ArrayList<Main.AOJ1024.Team>();
			for(int i=0;i<n;i++){
				list.add(new Team(in.next()));
				list.get(i).addPoint(in.nextInt()*3+in.nextInt()*0+in.nextInt());
			}
			Collections.sort(list);
			for(int i=0;i<n;i++)System.out.println(list.get(i));
		}

		class Team implements Comparable<Team>{
			String name;
			int point;
			public Team(String name){
				this.name = name;
				point = 0;
			}
			void addPoint(int p){
				this.point += p;
			}
			public int compareTo(Team o) {
				return o.point - point;
			}
			public String toString(){
				return name+","+point;
			}
		}

	}

}

Measured memory_bytes: 20656
#include<iostream>
#include<vector>
#define MAX 1000000
using namespace std;
static const int N = 100;
int A[N][N],d[N],p[N],color[N]={0};
void algo(int);
void print(int);
int main(void){
    int n,u,k,v,c;
    cin >> n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            A[i][j] = -1;
        }
    }
    for(int i=0;i<n;i++){
        cin >> u >> k;
        if(k!=0){
            for(int j=1;j<=k;j++){
                cin >> v >> c;
                A[u][v] = c;
            }
        }
    }
    for(int i=0;i<n;i++){
        d[i] = MAX;
        p[i] = 0;
    }
    d[0] = 0;
    algo(n);
    print(n);
    return 0;
}
void algo(int n){
    vector<int> S;
    while(S.size()!=n){
        int min = MAX,u =-1;
        for(int i=0;i<n;i++){
            if(min>d[i] && color[i]!=1){
                min= d[i];
                u= i;
            }
        }
        color[u] = 1;
        S.push_back(u);
        for(int v=0;v<n;v++){
            if(d[u]+A[u][v]<d[v] && A[u][v]!=-1){
                d[v] = d[u] + A[u][v];
                p[v] = u;
            }
        }
    }
}
void print(int n){
    for(int i=0;i<n;i++){
        cout << i << ' ' << d[i] << endl;
    }
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int h, w, d;
    cin >> h >> w >> d;
    VVI a(h, VI(w));
    rep(i,h)rep(j,w) cin >> a[i][j];

    VP c(h * w + 1);
    rep(i,h) rep(j,w){
        P p = P(i, j);
        c[a[i][j]] = p;
    }

    VL cost(h * w + 1, -1);
    for(int i = 0; i <= h * w; i++){
        if (cost[i] != -1) continue;
        cost[i] = 0;
        P pre = c[i];
        for(int j = i+d; j <= h * w; j += d){
            P now = c[j];
            cost[j] = cost[j-d] + abs(now.first - pre.first) + abs(now.second - pre.second);
            pre = now;
        }
    }

    int q;
    cin >> q;
    rep(i,q){
        int l, r;
        cin >> l >> r;
        ll ans = cost[r] - cost[l];
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 5040
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int a,b,n;
	cin >> n >> a >> b;
	cout << min(n * a,b) << endl;
	return 0;
}

Measured memory_bytes: 768
import java.util.*;

class Main {
	Scanner sc = new Scanner(System.in);

	public void run() {
		int n = sc.nextInt();
		while (n-- != 0) {
			double xa = sc.nextDouble(), ya = sc.nextDouble(), ra = sc.nextDouble();
			double xb = sc.nextDouble(), yb = sc.nextDouble(), rb = sc.nextDouble();

			double d = Math.sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb));
			if (ra + rb < d) {
				ln("0");
			} else if (ra > rb + d) {
				ln("2");
			} else if (rb > ra + d) {
				ln("-2");
			} else {
				ln("1");
			}
		}
	}

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

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

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

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 12000
/* ex 7_1
   ruuu0048 */

#include <stdio.h>

//点の構造体
typedef struct point{
    int x_elem;
    int y_elem;
}point;

//点を移動したものを返す関数
point shift_point(point point_base,int delta_x,int delta_y){
    point_base.x_elem += delta_x; //xの変位だけ移動
    point_base.y_elem += delta_y; //yの変位だけ移動
    return point_base;
}

int main(void){
    point point1,point2,point3,point4;

    scanf("%d %d %d %d",&point1.x_elem,&point1.y_elem,&point2.x_elem,&point2.y_elem);

    //点1と点2から点3を導く
    point3 = shift_point(point2,point1.y_elem - point2.y_elem,point2.x_elem - point1.x_elem);

    //点2と点3から点4を導く
    point4 = shift_point(point3,point2.y_elem - point3.y_elem,point3.x_elem - point2.x_elem);

    //答えを出力
    printf("%d %d %d %d\n",point3.x_elem,point3.y_elem,point4.x_elem,point4.y_elem);

    return 0;
}

Measured memory_bytes: 1732
# coding: utf-8
# Your code here!
N,K=map(int,input().split())
S=list(input())

l=[]
count=1
for i in range(N-1):
    if S[i]!=S[i+1]:
        l.append(count)
        count=1
    else:
        count+=1
l.append(count)

flag=False
ans=0
idx=0
time=0
while idx<len(l):
    if time<K:
        time+=1
        ans+=(l[idx]+l[idx+1] if idx!=(len(l)-1) else l[idx])
        idx+=1
    else:
        flag=True
        ans+=(l[idx]-1)
        
    idx+=1

if flag:
    print(ans)
else:
    print(ans-1)




Measured memory_bytes: 4772
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        char[] S = sc.next().toCharArray();
        int N = S.length;

        int[] ans = new int[N+1];
        ans[0]=0;
        int min = 0;
        for (int i = 0; i < N; i++) {
            char ch = S[i];
            if (ch == '<') ans[i+1]=Math.max(ans[i+1], ans[i]+1);
        }

       for (int i = N - 1; i >= 0; i--) {
            char ch = S[i];
            if (ch == '>') ans[i]=Math.max(ans[i], ans[i + 1]+1);
        }

        long sum = 0;
        for (int a : ans) {
            sum += a;
        }

        System.out.println(sum);
        
        return;
    }

}

Measured memory_bytes: 32720
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
inline int Rand(){return rand()*32768+rand();}
string s;
int suf[1000005],pref[1000005];
int solve(int x){
	string ss=s;
	int add=0,sum=0;
	for(int i=0;i<s.size();i++){
		if(s[i]!='?'){
			sum+=(s[i]=='1'?1:-1);
			continue;
		}
		if(add+sum+suf[i]<=x-2){
			add+=2;s[i]='1';
		}else s[i]='0';
		sum-=1;
	}
	pref[0]=s[0]=='1'?1:-1;
	for(int i=1;i<s.size();i++)pref[i]=pref[i-1]+(s[i]=='1'?1:-1);
	int mx=max(0,*max_element(pref,pref+s.size())),mn=min(0,*min_element(pref,pref+s.size()));
	s=ss;
//	cerr<<x<<" "<<mx<<" "<<mn<<endl;
	return mx-mn;
}
int main(){
	cin>>s;
	int f=0,g=0; 
	for(int i=0;i<s.size();i++)f+=(s[i]=='1'?1:-1),g=max(g,f);
	int cur=0;
	for(int i=s.size()-1;i>=0;i--){
		cur+=(s[i]=='1'?1:-1);
		suf[i]=cur;
		if(cur<0)cur=0;
	} 
	cout<<min(solve(g),solve(g+1))<<endl;
	return 0;
}

Measured memory_bytes: 13216
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (k, x) = (v[0], v[1]);
    let mut ans = vec![];
    for i in x - k + 1..x + k {
        ans.push(i);
    }
    print_array(&ans);
}

fn print_array<T: std::string::ToString>(array: &Vec<T>) {
    println!(
        "{}",
        array
            .iter()
            .map(|ref x| x.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    );
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
# -*- coding: utf-8 -*-
"""
AtCoder A
"""

import sys, math, random
import numpy as np

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column
# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']
# S.replace('ABC','X') # "testABCABC" -> "testXX"
 
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
 
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    N, X = list(map(int,input().split()))
    L=LI()
    L1=0
    out=1
    for l in L:
        D=L1+l
        # print(D)
        if D<X+1:
            out+=1
        L1=D
    print(out)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 24384
#include<bits/stdc++.h>
using namespace std;
int main()
{
     long n,i,ans,maxx=0;
     char ch;
     maxx=0;ans=0;
      cin>>n;
    for(long i=1;i<=n;i++)
     {
     	cin>>ch;
       if(ch=='I')ans++;
        else ans--;
        maxx=max(maxx,ans);
     }
       cout<<maxx<<endl;
       return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する
int tle = 1900;
int N;
int M;
double calc(int a){
    double ret = a * tle;
    if(a > 1) {
        ret *= pow(1.0 - (1.0 / pow(2.0, M)), a - 1) * (1.0/pow(2.0, M));
    }else{
        ret *= 1.0/pow(2.0, M);
    }
    return ret;
}

int main() {
    cin >> N >> M;
    double ans = 0.0;

    int cnt = 1;
    tle = 1900 * M + (N - M )* 100;
    while(true){
        double add = calc(cnt++);
        if(add < 0.001) break;
        ans += add;
    }
//    ans += 100 * (N - M);
    cout << round(ans) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
	#define SAY(X) cout << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

void solve() {
	auto str = fetch<string>();
	int n = len(str);
	vector<int> arr;

	for(int i = 0; i < n; ++i) {
		if(str[i] == 'A') {
			arr.push_back(0);	
		} else if(i != n - 1 && str[i] == 'B' && str[i + 1] == 'C') {
			arr.push_back(1);
			++i;
		} else {
			arr.push_back(NIL);
		}
	}

	DBG(arr);
	ll answ = 0;
	int m = len(arr);

	for(int i = 0; i < m;) {
		if(arr[i] == NIL) {
			++i;
			continue;
		}

		int j = i;

		while(j + 1 < m && arr[j + 1] != NIL) {
			++j;
		}

		int cur = 0;

		for(int k = i; k <= j; ++k) {
			if(arr[k] == 0) {
				++cur;
			} else {
				answ += cur;
			}
		}

		i = j + 1;
	}

	cout << answ << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 1680
#include <stdio.h>

int main (void) {

  int N, H[20], i, j, k, ans;

  ans = 1;

  scanf ("%d", &N);

  for (i = 0; i < N; i++) {
    scanf ("%d", &H[i]);
  }

  for (i = 1; i < N; i++) {
    k = 0;
    for (j = 0; j < i; j++) {
      if (H[i] >= H[j]) {
        k++;
      }
    }
    if (k == i) {
      ans++;
    }
  }

  printf ("%d", ans);
  
    return 0;
}

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

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

  int ans = R;
  if (N < 10) {
    ans += 100 * (10 - N);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

using ll = int64_t;

int main(int, const char**)
{
    int n;
    cin >> n;
    ll ans = 0;
    rep(i, n - 1)
    {
        auto a = i + 1;
        auto c = (n - 1) / a;
        ans += c;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#include<cmath>
#include<numeric>
using namespace std;


int main(void) {

  int n, m, l;
  cin >> n >> m >> l;

  vector< vector<int> > a(n, vector<int>(m));
  vector< vector<int> > b(m, vector<int>(l));

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

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

  for(int i=0; i<n; i++){
    for(int j=0; j<l; j++){
      long long int tmp = 0;
      for(int k=0; k<m; k++){
        tmp += a[i][k] * b[k][j];
      }
      if( j != l-1 ) cout << tmp << " ";
      else cout << tmp << endl;
    }
  }


  return 0;
}

Measured memory_bytes: 3196
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int main(int argc, char** argv){
    int N;
    cin >> N;
    vector<pair<int, int>> v(0);
    for (int i=1; i<=N; i++){
        int A;
        cin >> A;
        v.push_back(make_pair(A, i));
    }
    sort(v.begin(), v.end());
    for (int i=0; i<N; i++){
        cout << v[i].second;
        if (i == N-1) cout << "\n";
        else cout << " ";
    }
    return 0;
}


Measured memory_bytes: 1780
import math

n = int(input())

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
    
def lcm(x,y):
	return (x * y) // gcd(x, y)

ct = 1
for _ in range(n):
	t = int(input())
	ct = lcm(ct,t)
	
print(ct)


Measured memory_bytes: 3060
#include<iostream>

using namespace std;

class Point{
public:
	double x,y;
	bool isRight(Point p){
		if( p.x >= x ) return true;
		else return false;
	}
	bool isLeft(Point p){
		if( p.x <= x ) return true;
		else return false;
	}
	bool isUp(Point p){
		if( p.y >= y ) return true;
		else return false;
	}
	bool isDown(Point p){
		if( p.y <= y ) return true;
		else return false;
	}
};
class Rectangle{
public:
	Point dl,ur;
	Point dr,ul;
	bool isInside(Point p){
		if( dl.isRight( p ) && ur.isLeft( p ) && dl.isUp( p ) && ur.isDown( p ) ) return true;
		else return false;
	}
	bool isIntersected(Rectangle r){
		if( isInside(r.dl) || isInside(r.dr) || isInside(r.ul) || isInside(r.ur) ) return true;
		else if( r.dl.isLeft( dl ) && r.dr.isRight( dr ) && r.ur.isDown( dl ) && r.dl.isUp( dl ) ) return true;
		else return false;
	}
	void Complement(void){
		dr.x = ur.x;
		dr.y = dl.y;
		ul.x = dl.x;
		ul.y = ur.y;
	}
};

int main(void){
	while( true ){
		Rectangle rA, rB;

		cin >> rA.dl.x >> rA.dl.y >> rA.ur.x >> rA.ur.y >> rB.dl.x >> rB.dl.y >> rB.ur.x >> rB.ur.y;
		rA.Complement();
		rB.Complement();
		if( cin.eof() )break;
		if( rA.isIntersected(rB) || rB.isIntersected(rA) )
			cout<<"YES"<<endl;
		else cout <<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
def gcd(x, y):
    if y == 0:
        return x
    while y != 0:
        x, y = y, x % y
    return x


def main():
    N, X = (int(i) for i in input().split())
    A = [int(i) for i in input().split()] + [X]
    A.sort()
    diff = [A[i+1] - A[i] for i in range(N)]
    ans = diff[0]
    for d in diff:
        ans = gcd(ans, d)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 64360
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>

using namespace std;

int main() {

int a[]={0,1,3,1,2,1,2,1,1,2,1,2,1};
int b,c;
cin >> b >> c;
if(a[b]==a[c]){
  cout << "Yes" << endl;
}
else{
  cout << "No" << endl;
}
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>

#define loop(i, num)  for (lint i = 0; i < num; i++)
#define l  first
#define r  second
#define lint  long long

using namespace std;

lint n, ans;

int upp[100000], mid[100000], low[100000];

int main() {
    
    ios_base::sync_with_stdio(0);
    
    cin >> n;
    
    loop (i, n)  cin >> upp[i];
    
    loop (i, n)  cin >> mid[i];
    
    loop (i, n)  cin >> low[i];
    
    lint up = 0, lw = 0;
    
    sort(upp, upp + n);
    
    sort(mid, mid + n);
    
    sort(low, low + n);
    
    loop (md, n) {
        
        while (up < n && upp[up] < mid[md])  ++up;
        
        while (lw < n && mid[md] >= low[lw])  ++lw;
        
        ans += up * (n - lw);
        
    }
    
    cout << ans << endl;
    
    return 0;
    
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int INF = 1LL << 60;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
string grid[100];
int cnt(int h,int w){
    int res=0;
    int dx[4] = {-1,0,1};
    int dy[4] = {0,-1,1};
    if(grid[h][w] == '#'){
        return -1;
    }

    REP(i,3){
        REP(j,3){
            int x = dx[i];
            int y = dy[j];
            res += (grid[h+x][w+y]=='#');
        }
    }

    return res;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W;
    cin >> H >> W;
    grid[0] = string(W+2,'.');
    grid[H+1] = string(W+2,'.');
    string s;
    REP(i,H){
        cin >> s;
        grid[i+1] = "."+s+".";
    }
    
    REP(h,H){
        REP(w,W){
            int res = cnt(h+1, w+1);
            if( res == -1){
                cout << "#";
            }else cout << res;
        }
        cout << "\n";
    }
}


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

using namespace std;

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

long long x, y;
scanf ("%lld %lld", &x, &y);
long long maxVal = y / x;
int ans = 0;
while (maxVal)
    ans ++, maxVal >>= 1LL;
printf ("%d\n", ans);
return 0;
}


Measured memory_bytes: 768
N = int(input())

ans = (N // 11) * 2
res = N % 11

if res == 0:
    pass
elif res == 1 or res == 3 or res == 4 or res == 6 or res == 2 or res == 5:
    ans += 1
else:
    ans += 2

print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <vector>
#include <iostream>
#include <cmath>
#include <set>
#include <string>
#include <list>
using namespace std;
int calcdigit(int n)
{
	int d = 0;
	while (n > 0)
	{
		n = n/10;
		d++;
	}
	return d;

}


int main()
{
	int n;
	cin >> n;
	bool flg = false;
	int d = pow(10,calcdigit(n));


	while (d > 0)
	{
		if (n / d == 7)
		{
			flg = true;
			break;
		}
		n = n%d;
		d /= 10;
	}

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

Measured memory_bytes: 4028
//
//  main.cpp
//  ABC124
//
//  Created by hiroaki on 2019/05/07.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <map>
#include <iterator>
#include <set>
#include <cmath>
#include <algorithm>
#include <locale>

//pair sort firstに揃う

#define int long long
#define pb(n) push_back(n)
#define For(n,i) for(int (i)=0;(i)<(n);(i)++)
#define Pr(n) cout<<n<<endl;
#define F first
#define S second
#define vector2 vector<vector<int> >
#define ELM 100001 //問題によっては1000000001に変更
using namespace std;

signed  main(){
    int n,d;
    cin >> n>>d;
    if (n%(2*d+1)==0) {
        Pr(n/(2*d+1));
    }else{
        Pr(n/(2*d+1)+1);
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <unordered_map>
#define int long long int
#define double long double
#define endl "\n"
#define PI 3.141592653589793238462643383279502884
#define sum_up(x)  (x*(x+1))/2
#define sp(x)   setprecision(x)
#define ceil(a,b)   (a+(b-1))/b
#define mp(a,b)   make_pair(a,b)
#define LCM(a,b)    (a*b)/__gcd(a,b)
#define all(v)  v.begin(),v.end()
#define alls(s,v)  s.begin(),s.end(),v
#define gena(arr,n,nxt)  generate(arr,arr+n, nxt)
#define genv(v,nxt)  generate(v.begin(),v.end(), nxt)
#define BSv(v,a) binary_search(v.begin(),v.end(), a)
#define BSa(v,n,a) binary_search(v,v+n, a)

using namespace std;

void base()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

bool prime[100001];
void sieve(int n)
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
int power(int x, int y)
{
    int res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x*x;
    }
    return res;
}

double float_sq(double n)
{
    double x = n;
    double y = 1;
    double e = 0.000001;
    while (x - y > e)
    {
        x = (x + y) / 2;
        y = n / x;
    }
    return x;
}

int int_sq(int x)
{
    if (x == 0 || x == 1)
        return x;
    int start = 1, end = x, ans;
    while (start <= end)
    {
        int mid = (start + end) / 2;
        if (mid*mid == x)
            return mid;
        if (mid*mid < x)
        {
            start = mid + 1;
            ans = mid;
        }
        else
            end = mid-1;
    }
    return ans;
}

int nxt()
{
    int x;
    cin >> x;
    return x;
}

set<int>s;
void printArray(vector<int> arr, int n)
{
    int cnt=0;
    for (int i = 0; i < n; i++)
        cnt+=arr[i] ;
    if(cnt%2==0)
        s.insert(cnt);
}
void printSubsequences(vector<int> arr, int index,
                       vector<int> subarr)
{
    if (index == arr.size())
    {
        int l = subarr.size();
        if (l != 0)
            printArray(subarr, l);
    }
    else
    {
        printSubsequences(arr, index + 1, subarr);
        subarr.push_back(arr[index]);
        printSubsequences(arr, index + 1, subarr);
    }
    return;
}

bool palindrome(string s){
    string test=s;
    reverse(all(test));
    return s== test;
}

int32_t main()
{
    base();
    string s;
    cin>>s;
    string s1=s.substr(0,((s.size()-1)/2)),s2=s.substr(((s.size()+3)/2)-1,s.size()-1);
    if(palindrome(s)&&palindrome(s1)&&palindrome(s2)) cout<<"Yes";
    else cout<<"No";
    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  if ((n / 100 == 0 || n / 100 > 12) && (n % 100 == 0 || n % 100 > 12)) cout << "NA\n";
  else if (n / 100 == 0 || n / 100 > 12) cout << "YYMM\n";
  else if (n % 100 == 0 || n % 100 > 12) cout << "MMYY\n";
  else cout <<"AMBIGUOUS\n";
}


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

int main() {
    int a,b,ans=0;cin>>a>>b;
    string str;cin>>str;
    for(int i=0;i<a+b+1;++i){
        if(i!=a && str[i]=='-')ans=1;
        if(i==a && str[i]!='-')ans=1;
    }
    if(ans==1)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next().replace(".", ""));
        System.out.println(a*b/100);
    }
}

Measured memory_bytes: 35676
import sys


Sp = [c for c in input()]
T = [c for c in input()]

sn = len(Sp)
tn = len(T)

match_i = 51
for i in range(sn - tn + 1):
    partial = Sp[i:i+tn]
    for j in range(len(partial)):
        if partial[j] == '?':
            partial[j] = T[j]
    if partial == T:
        match_i = i

if match_i > 50:
    print('UNRESTORABLE')
    sys.exit()

Sp[match_i:match_i+tn] = T
for i in range(sn):
    if Sp[i] == '?':
        Sp[i] = 'a'
S = ''.join(Sp)

print(S)

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

int main(){
	int n,k=0,flag=0;
	int a[100005];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]>k){
			k=a[i];
		}
		if(k-a[i]>=2){
			flag=1;
			break;
		}
	}
	if(flag){
		cout<<"No";
	}
	else{
		cout<<"Yes";
	}
} 

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
using namespace std;
typedef long long int ll;

int n,k;
vector<int> G[2100];

int dfs(int t,int f,int k,int depth=0){
	int cnt=0;
	if(depth>=k)cnt++;
	for(auto d:G[t]){
		if(d==f)continue;
		cnt+=dfs(d,t,k,depth+1);
	}
	return cnt;
}

int main(){
	cin >> n >> k;
	for(int i=0;i<n-1;i++){
		int a,b; cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int ans=n;
	for(int i=0;i<n;i++){
		int cnt=0;
		for(int t:G[i]){
			cnt+=dfs(t,i,k/2);
		}
		ans=min(ans,cnt);
	}
	for(int i=0;i<n;i++){
		for(int t:G[i]){
			int cnt=dfs(t,i,(k+1)/2)+dfs(i,t,(k+1)/2);
			ans=min(ans,cnt);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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() {
  int N, K;
  cin >> N >> K;

  string S;
  cin >> S;

  vector<int> A(0);

  char now = '1';
  int cnt = 0;
  rep(i, S.size()) {
    if (now == S[i])
      cnt++;
    else {
      A.pb(cnt);
      now = S[i];
      cnt = 1;
    }
  }
  if (cnt != 0) A.pb(cnt);
  if (S[S.size() - 1] == '0') A.pb(0);
  // rep(i, A.size()) { cout << A[i] << endl; }

  int w = 2 * K + 1;
  int l = 0;
  int r = 0;
  int temp = 0;
  int ans = 0;

  for (int i = 0; i < A.size(); i += 2) {
    int nl = i;
    int nr = min(i + w, (int)A.size());

    while (l < nl) temp -= A[l++];
    while (r < nr) temp += A[r++];

    chmax(ans, temp);
  }

  cout << ans << endl;
}

Measured memory_bytes: 1020