akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#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 <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
   ll dp[2000000];
 int gcd(int a, int b)
{
  if (a%b == 0)
{
return(b);
}
else
{
return(gcd(b,a%b));
}
}
int main(){
  ll a,b;cin>>a>>b;
  vector<ll>c(a);
  rep(i,a)cin>>c[i];
  rep(i,a-b){
    if(c[i]<c[i+b])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    //cout<<c[i+b];
  }
}



Measured memory_bytes: 28260
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int H;
  int W;
  int h;
  int w;
  cin >>H >>W>>h>>w;
  int F=H*W;
  int Subt=H*w+h*W;
  int Multi=h*w;
  int x=F-Subt+Multi;
  cout << x << endl;
  
}

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

// Implementaci??n did??ctica
class SegmentTreeRMQ {
    // st es el arreglo de nodos del segment tree
    vector<long long> arr, st;
    // leaf guarda la ubicaci??n de cada hoja en st
    vector<int> leaf; int n;

    // construir nodo u, que representa al rango [i,j]
    void build(int u, int i, int j) {
        // caso de que el rango representa una hoja
        if (i == j) {
            leaf[i] = u;
            st[u] = arr[i];
            return;
        }
        // l y r son los hijos izquierdo y derecho de u
        int m = (i+j)/2, l = u*2+1, r = u*2+2;
        build(l, i, m);
        build(r, m+1, j); // es importante el +1
        st[u] = min(st[l], st[r]); // range min. query
    }

    // query en el rango [a,b], considerando que nos
    // encontramos en el nodo u que representa a [i,j]
    long long query(int a, int b, int u, int i, int j) {
        // nodo fuera del rango [a,b], retornar neutro
        if (j < a or b < i)
            return 1e18; //infinito = neutro del m??n.
        // nodo totalmente contenido en [a,b]
        if (a <= i and j <= b)
            return st[u]; // responder directamente
        // si no, componer queries de ambos hijos
        int m = (i+j)/2, l = u*2+1, r = u*2+2;
        long long x = query(a, b, l, i, m);
        long long y = query(a, b, r, m+1, j); // +1 !!
        return min(x, y);
    }

    // actualizar nodo u considerando que uno de sus
    // hijos fue actualizado antes (o es una hoja)
    void update(int u) {
        int l = u*2+1, r = u*2+2;
        st[u] = min(st[l], st[r]); // actualizar info
        // si no es la ra??z (nodo 0) actualizar padre
        if (u != 0) update((u-1)/2);
    }

public:
    // construir segment tree a partir de un vector
    SegmentTreeRMQ(vector<long long>& v) {
        arr = v;
        n = v.size();
        leaf.resize(n);
        // reservar tama?±o para el peor caso, 4*N
        st.resize(n*4+5);
        // construir desde la ra??z
        build(0, 0, n-1);
    }

    // [a,b] es inclusivo inclusivo, indexado desde 0
    long long query(int a, int b) {
        // responder query procesando desde la ra??z
        return query(a, b, 0, 0, n-1);
    }

    // setea un valor en cierto ??ndice del arreglo
    void update(int index, long long value) {
        int u = leaf[index];
        arr[index] = value;
        st[u] = arr[index];
        // chequea si la hoja es ra??z por si N = 1
        if (u != 0) update((u-1)/2);
    }
};

int main(){
    int A,B;
    cin >> A >> B;
        vector <long long> v(A);
        for (int i=0;i<A;i++){
            v[i]=2147483647;
        }
        SegmentTreeRMQ S(v);
        for (int i=0; i<B; i++){
            int c;
            int a,b;
            cin >> c >> a >> b;
            if (c==0){
                S.update(a,b);
            }
            else if (c==1){
                cout << S.query(a,b) << "\n";
            }
        }

}

Measured memory_bytes: 7852
import copy
S=list(input())
S1 = "".join(S)
T=list(input())
T1 = "".join(T)
F = ["?"]*len(T)
F1 = "".join(F)
l =[]
M =[]
index =[]
B = copy.deepcopy(S)
for i in range(len(S)-len(T)+1):
    A = copy.deepcopy(S)
    c = A[i:len(T)+i]
    while "?" in c:
        c[c.index("?")] = T[c.index("?")]
    if c==T:
        A = copy.deepcopy(S)
        A[i:len(T)+i] = c
        while "?"in A:
            A[A.index("?")]="a"
        M.append(A)
if 0<len(M):
    M.sort()
    print("".join(M[0]))
else:
    print("UNRESTORABLE")

Measured memory_bytes: 3444
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

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

        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i=0; i<n; i++) a[i] = sc.nextInt();

        long ans = 0;

        Arrays.sort(a);

        Map<Long, Long> map = new HashMap<>();

        for (int i=0; i<n; i++){
            if (map.containsKey(a[i])){
                long c = map.get(a[i]);
                map.put(a[i], ++c);
            }else {
                map.put(a[i], 1l);
            }
        }

        for (Long key: map.keySet()){
            if (key!=map.get(key)){
                if (key<map.get(key)){
                    ans += (map.get(key)-key);
                }else if (key>map.get(key)){
                    ans += map.get(key);
                }
            }
        }
//        System.out.println(map);
        System.out.println(ans);

    }
}


Measured memory_bytes: 62960
while True:
    col, row = map(int, input().split())
    if col == 0:
        break
    else:
        robot = [1, 1]
        direction = "up"
        while True:
            str = input()
            if str == "STOP":
                print(robot[0], robot[1])
                break
            elif str == "LEFT":
                if direction == "up":
                    direction = "left"
                elif direction == "left":
                    direction = "down"
                elif direction == "down":
                    direction = "right"
                else:           # right
                    direction = "up"
            elif str == "RIGHT":
                if direction == "up":
                    direction = "right"
                elif direction == "left":
                    direction = "up"
                elif direction == "down":
                    direction = "left"
                else:           # right
                    direction = "down"
            else:
                di, step = str.split()
                step = int(step)
                if direction == "up":
                    if di == "FORWARD":
                        robot[1] = min(robot[1] + step, row)
                    else:
                        robot[1] = max(robot[1] - step, 1)
                elif direction == "left":
                    if di == "FORWARD":
                        robot[0] = max(robot[0] - step, 1)
                    else:
                        robot[0] = min(robot[0] + step, col)
                elif direction == "down":
                    if di == "FORWARD":
                        robot[1] = max(robot[1] - step, 1)
                    else:
                        robot[1] = min(robot[1] + step, row)
                else:           # right
                    if di == "FORWARD":
                        robot[0] = min(robot[0] + step, col)
                    else:
                        robot[0] = max(robot[0] - step, 1)


Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
int main(){
  double W,H,x,y;
  cin>>W>>H>>x>>y;
  bool t = 0;
  if(W == 2*x&&H == 2*y){
    t = 1;
  }
  cout << W*H/2 << " " << t << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;long long n,aa,i,j,b,f[5005],pos[5005],ans,a[5005],c[5005];int main(){ans=12345678912345678ll;cin>>n>>aa>>b;for (i=1;i<=n;i++) f[i]=ans;for (i=1;i<=n;i++){	cin>>a[i];pos[a[i]]=i;	}	for (i=1;i<=n;i++){		c[i]=c[i-1]+(i<a[i]?aa:b);	}	for (i=1;i<=n;i++){		long long s=0;		for (j=i-1;j>=0;j--){			if (a[j]<a[i]){				f[i]=min(f[i],f[j]+s);			}			if (a[j]<a[i]){				s+=b;			} else {				s+=aa;			}		}		ans=min(ans,f[i]+(n-i)*b);	}	cout<<ans<<endl;return 0;}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int N,M;
VVI Z(100100);
VI ans(100100,-1);

void solve(int A){
  if(ans[A]!=-1) return;
  if(Z[A].size()){
    rep(i,Z[A].size()){
      solve(Z[A][i]);
      if(ans[A]==-1) ans[A]=ans[Z[A][i]]+1;
      else ans[A]=max(ans[A],ans[Z[A][i]]+1);
    }
  }else ans[A]=0;
}

int main(){
  cin>>N>>M;
  VI X(M),Y(M);
  rep(i,M) cin>>X[i]>>Y[i];
  rep(i,M) Z[X[i]-1].pb(Y[i]-1);
  rep(i,N) solve(i);
  int tmp=0;
  rep(i,N) tmp=max(tmp,ans[i]);
  cout<<tmp<<endl;
}

Measured memory_bytes: 8320
void main() {
    int n = readln.chomp.to!int;
    int[] a = readln.split.to!(int[]);
    writeln(a.reduce!max - a.reduce!min);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.uni;

Measured memory_bytes: 256
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

def factorial(number)
  (1..number).inject(1,:*)
end

def factorial2(n)
  arr = [*1..n]
  loop do
    return arr[0] if arr.length == 1
    arr = arr.each_slice(2).map { |a, b| b ? a * b : a }
  end
end

N, M = gets_i_list
MOD = 10**9 + 7

if N != M && N - 1 != M && N != M - 1
  puts 0
  exit
end

if N == M
  puts (factorial2(N) * factorial2(M) * 2) % MOD
else
  a, b = 0, 0
  if N > M
    a = N
    b = M
  else
    a = M
    b = N
  end
  puts (factorial2(b)**2 * a) % MOD
end


Measured memory_bytes: 12864
COL = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def main(argv)
  (h, w) = gets.chomp.split(' ').map(&:to_i)
  
  py = -1
  px = -1

  s = [nil] * h
  h.times do |y|
    s[y] = gets.chomp.split(' ')
    w.times do |x|
      if s[y][x] == 'snuke' then
        py = y
        px = x
      end
    end
  end

  puts COL[px] + (py + 1).to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60
#define MOD 1000000007

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j
#define fix(i) fixed << setprecision(i)


template<class T> inline bool chMax(T& a, T b){ if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chMin(T& a, T b){ if (a > b) { a = b; return true; } return false; }
template<class T> inline ll gcd(T a, T b){ if (a % b == 0){ return b; } else{ return gcd(b, a%b); } }
template<class T> inline ll lcm(T a, T b){ return a * b / gcd(a, b); }
template<class T> inline ll fact(T a){ if (a <= 1){ return 1; } else{ return a * fact(a - 1); } }
template<class T> inline ll comb(T a, T b){ return a == 0 ? 0 : fact(a) / fact(b) / fact(a - b); }

int main(){
    ll N, K;
    vector<ll> H;
    cin >> N >> K;
    rep(i, 0, N){
        ll temp;
        cin >> temp;
        H.push_back(temp);
    }
    sort(begin(H), end(H), greater<>());
    ll ans = 0;
    rep(i, K, N){
        ans += H[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 2420
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
const int ININF = 1000000;
const int MOD = 1000000007;
int main() {
    long long N, K;
    cin >> N >> K;
    long long res = 1;
    vector<long long> ruiL(N + 1);
    vector<long long> ruiR(N + 1);
    ruiL[0] = 0;
    ruiR[0] = N;
    rep(i, 1, N + 1) {
        ruiL[i] = ruiL[i - 1] + i;
        ruiR[i] = ruiR[i - 1] + N - i;
    }
    rep(i, 0, N) {
        int t = N - i;
        if(t < K) {
            break;
        }
        long long s = ruiL[i];
        long long u = ruiR[i];
        res += u - s + 1;
        res = res % MOD;
    }
    cout << res << endl;
}


Measured memory_bytes: 6376
#include<stdio.h>
int main()
{
int a,b,c,d,e,f;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  
  if(a>b) e=b;
  else e=a;
  
 if(c>d) f=d;
 else f=c;


printf("%d",e+f);

return 0;
}

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

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

  vector<long long> A(N + 1);
  for (int i = 0; i < N + 1; i++) cin >> A.at(i);
  vector<long long> B(N);
  for (int i = 0; i < N; i++) cin >> B.at(i);

  long long tot = 0;
  for (int i = 0; i < N; i++) {
    tot += min(A.at(i), B.at(i));
    tot += min(A.at(i + 1), B.at(i) - min(A.at(i), B.at(i)));
    A.at(i + 1) -= min(A.at(i + 1), B.at(i) - min(A.at(i), B.at(i)));
  }

  cout << tot << endl;
}

Measured memory_bytes: 1792
function Main(input) {
	input = input.split("\n");
    a = input[1].split(" ");

    const N = parseInt(input[0]);
    var n = 0;

    for (let i=1; i<(N+1) ; i++) {

        if(i%2 == 1) {

            var tmp = parseInt(a[i-1]);

            if (tmp%2 == 1) {

                n++;

            }
        }
    }

    console.log( '%d', n);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29664
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll sum=0,res=0,x=0;
    int l=0,r=0;
    for(;r<n;r++){
        x^=a[r];
        sum+=a[r];
        for(;sum!=x;l++){
            x^=a[l];
            sum-=a[l];
        }
        res+=r-l+1;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n, k) for (int i = n; i < k; i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v)                      \
    for (int i = 0; i < v.size(); i++) \
        P(v[i]);
#define printt(a, b) cout << a << " " << b << endl;
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int MOD = 1e9 + 7;

void solve()
{
    int n;
    cin >> n;
    ll t = 1;
    vector<ll> v;
    rep(i, n)
    {
        ll a;
        cin >> a;
        v.push_back(a);
        if (a == 0)
        {
            P(0);
            return;
        }
    }
    rep(i, n)
    {
        if (t > 1000000000000000000LL / v[i])
        {
            P(-1);
            return;
        }
        else
        {
            t *= v[i];
        }
    }
    P(t);
}

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


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

typedef struct{
  double x,y;
} P;

void p(int,P,P);
int main(){
  P p1,p2;
  int n;
  scanf("%d",&n);
  p1.x=0;
  p1.y=0;
  p2.x=100;
  p2.y=0;
  printf("%.8f %.8f\n",p1.x,p1.y);
  p(n,p1,p2);
  printf("%.8f %.8f\n",p2.x,p2.y);
  return 0;
}

void p(int n,P p1,P p2){
  P a,b,c;
  double k=60.0*(acos(-1)/180.0);
  if(n==0){
    return;
  }
  a.x=(2.0*p1.x+p2.x)/3.0;
  a.y=(2.0*p1.y+p2.y)/3.0;
  b.x=(p1.x+2.0*p2.x)/3.0;
  b.y=(p1.y+2.0*p2.y)/3.0;
  c.x=(b.x-a.x)*cos(k)-(b.y-a.y)*sin(k)+a.x;
  c.y=(b.x-a.x)*sin(k)+(b.y-a.y)*cos(k)+a.y;
  p(n-1,p1,a);
  printf("%.8f %.8f\n",a.x,a.y);
  p(n-1,a,c);
  printf("%.8f %.8f\n",c.x,c.y);
  p(n-1,c,b);
  printf("%.8f %.8f\n",b.x,b.y);
  p(n-1,b,p2);
}



Measured memory_bytes: 2096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)

template<class T> struct LSMIN{
    int n;
    T e;
    vector<T> dat,lazy;
    vector<bool> vis;

    LSMIN(T n_,T e_){
        n=1;e=e_;
        while(n<n_) n*=2;
        dat.resize(2*n-1,e);
        lazy.resize(2*n-1,e);
        vis.resize(2*n-1);
    }

    void prop(int k,int l,int r){
        if(!vis[k]) return;
        dat[k]=lazy[k];
        if(r-l>1){
            lazy[2*k+1]=lazy[2*k+2]=lazy[k];
            vis[2*k+1]=vis[2*k+2]=1;
        }
        vis[k]=0;
        lazy[k]=e;
    }

    void ud(int be,int en,T t,int k,int l,int r){
        prop(k,l,r);
        if(r<=be||en<=l) return;
        if(be<=l&&r<=en){
            lazy[k]=t;
            vis[k]=1;
            prop(k,l,r);
            return;
        }
        ud(be,en,t,k*2+1,l,(l+r)/2);
        ud(be,en,t,k*2+2,(l+r)/2,r);
        dat[k]=min(dat[2*k+1],dat[2*k+2]);
    }

    void ud(int be,int en,T t){
        ud(be,en,t,0,0,n);
    }

    T gt(int be,int en,int k,int l,int r){
        if(r<=be||en<=l) return e;
        prop(k,l,r);
        if(be<=l&&r<=en) return dat[k];
        return min(gt(be,en,k*2+1,l,(l+r)/2),gt(be,en,k*2+2,(l+r)/2,r));
    }

    T gt(int be,int en){
        return gt(be,en,0,0,n);
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,q,s,t,x;
    bool f;
    cin>>n>>q;
    LSMIN<int> sg(n,INT_MAX);
    fr(i,q){
        cin>>f;
        if(f){
            cin>>s>>t;
            cout<<sg.gt(s,++t)<<endl;
        }
        else{
            cin>>s>>t>>x;
            sg.ud(s,++t,x);
        }
        //fr(j,sg.n*2-1) cout<<"["<<sg.dat[j]<<","<<sg.lazy[j]<<"] ";
        //cout<<endl;
    }
}


Measured memory_bytes: 5148
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var X = int.Parse(Console.ReadLine());
            var yen500 = X / 500;
            var yen5 = (X - (500 * yen500)) / 5;
            Console.WriteLine(yen500*1000+yen5*5);
        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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

double N,X,cnt,su;
int K;

int main(){
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    cin>>N>>K;
    X=pow(2.0,17);
    repi(i,1,N+1){
        int tmp=i;
        cnt=0;
        while(tmp<K){
            tmp*=2;
            cnt++;
        }
        // out(cnt);
        su+=pow(2.0,17-cnt);
    }
    printf("%.10f\n",su/(N*X));

    
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();

        boolean WOK = x - r >= 0 && x + r <= W;
        boolean HOK = y - r >= 0 && y + r <= H;

        System.out.println(WOK && HOK ? "Yes" : "No");
        sc.close();
    }
}



Measured memory_bytes: 26320
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<=n;i++)
int main()
{
	int N, Y;
	cin >> N >> Y;
	rep(x,N)
	{
		rep(y,N-x)
		{
			int z = N - x - y;
			if (10000 * x + 5000 * y + 1000 * z == Y)
			{
				cout << x << " " << y << " " << z << endl;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
	return 0;
}

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

int main(){
    int n,m;

    scanf("%d %d",&n,&m);
    int A[n][m], b[m];
    for(int i=0;i<n;++i){
        for(int j=0;j<m;++j){
            scanf("%d",&A[i][j]);
        }
    }
    for(int i=0;i<m;++i){
        scanf("%d",&b[i]);
    }

    for(int i=0;i<n;++i){
        int ans = 0;
        for(int j=0;j<m;++j){
            ans += A[i][j] * b[j];
        }
        printf("%d\n",ans);
    }

    return 0;
}


Measured memory_bytes: 1224
a = list(map(int, input().split()))

if a[0] % 2 == 1 and a[3] % 2 == 1 and a[4] % 2 == 1:
    ans = ((a[0] // 2) * 4 + a[1] * 2 + (a[3] // 2) * 4 + (a[4] // 2) * 4) // 2
    print(ans + 3)
elif a[0] % 2 == 1 and a[3] % 2 == 1 and a[4] % 2 == 0 and a[4] > 0:
    ans = ((a[0] // 2) * 4 + a[1] * 2 + (a[3] // 2) * 4 + (a[4] // 2 - 1) * 4) // 2
    print(ans + 3)
elif a[0] % 2 == 1 and a[3] % 2 == 0 and a[4] % 2 == 1 and a[3] > 0:
    ans = ((a[0] // 2) * 4 + a[1] * 2 + (a[3] // 2 - 1) * 4 + (a[4] // 2) * 4) // 2
    print(ans + 3)
elif a[0] % 2 == 0 and a[3] % 2 == 1 and a[4] % 2 == 1 and a[0] > 0:
    ans = ((a[0] // 2 - 1) * 4 + a[1] * 2 + (a[3] // 2) * 4 + (a[4] // 2) * 4) // 2
    print(ans + 3)
else:
    ans = ((a[0] // 2) * 4 + a[1] * 2 + (a[3] // 2) * 4 + (a[4] // 2) * 4) // 2
    print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long
#define rgi register int
#define rgl register ll
#define int ll
#define maxn 200005
#define mod 1000000007LL
#define inf 1000000007LL
namespace lib
{
	using namespace std;
	class fastio
	{
		private:
			#define _NUMLEN 111
			char _num[_NUMLEN],_ch;
			int _f,_head;
			bool _useSTD;
		public:
			inline void ioSTD()
			{
				_useSTD=1;
				ios::sync_with_stdio(false);
				cin.tie(0),cout.tie(0);
			}
			inline void gc(char & _c)
			{
				if(_useSTD)cin>>_c;
				else _c=getchar();
			}
			inline void pc(char _c)
			{
				if(_useSTD)cout<<_c;
				else putchar(_c);
			}
			template<typename _T> inline fastio & operator - (_T & _x)
			{
				if(_useSTD)cin>>_x;
				else
				{
					_x=0;
					while(!isdigit(_ch)) _f|=_ch=='-',gc(_ch);
					while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),gc(_ch);
					_f&&(_x=-_x,_f=0);
				}
				return *this; 
			}
			template<typename _T> inline fastio & operator + (_T _x)
			{
				if(_useSTD)cin>>_x;
				else
				{
					_T _k;
					if(_x==0) {pc('0'),pc(' ');return *this;}
					if(_x<0) pc('-'),_x=-_x;
					while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
					while(_head>0) pc(_num[_head]),--_head;
					pc(' ');
				}
				return *this; 
			}
			template<typename _T> inline fastio & operator >> (_T & _x) {cin>>_x;return *this;}
			template<typename _T> inline fastio & operator << (_T _x) {cout<<_x;return *this;}
			#define endln pc('\n')
		fastio() {_f=0,_head=0,_useSTD=0,_ch=' ';}
	}io;
	inline void fileio(string _r,string _w)
	{
		if(_r[0]!='-')freopen(_r.c_str(),"r",stdin);
		if(_w[0]!='-')freopen(_w.c_str(),"w",stdout);
	}
	#define mem(_x,_set) memset(_x,_set,sizeof(_x))
}using namespace lib;

inline ll powm(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1) (res*=a)%=mod;
		(a*=a)%=mod;
		b>>=1;
	}
	return res;
}
ll c[maxn],ans=0,nps;
signed main()
{
	// fileio("tt.in","tt.out");
	// io.ioSTD();
	ll n;
	io-n;
	for(rgi i=1;i<=n;++i)io-c[i];
	sort(c+1,c+1+n,greater<int>());
	for(rgi i=1;i<=n;++i)
	{
		if(i==1)nps=1;
		else nps=(nps*2%mod+powm(2,i-2))%mod;
		(ans+=c[i]*nps%mod*powm(2,n)%mod*powm(2,n-i)%mod)%=mod;
		// cout<<nps<<" "<<ans<<endl;
	}
	io+ans;
	return 0;
}

Measured memory_bytes: 1792
#新しい値が最小なら追加，そうでなければそれを超えない最大の値を書き換え
#降順なので，10**10から引くことで逆転させておく
#→新しい値が最大なら追加，そうでなければそれを超える最小の値を書き換え
import bisect

N=int(input())
A=[10**10-int(input()) for _ in range(N)]

b=[]
b.append(A[0])

for i in range(1,N):
    index=bisect.bisect_right(b,A[i])
    if index==len(b):
        b.append(A[i])
    else:
        b[index]=A[i]
print(len(b))

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

using namespace std;

#define int long long 
#define F first 
#define S second 
#define pii pair<int,int> 
#define mpr make_pair

typedef long long ll;

const int maxn = 1e6+10;
const int mod = 998244353;
const int inf = 1e9+10;

int n, k, l;
int a[maxn];
vector<int> g[maxn], asc;
bool mark[maxn];

void dfs(int v)
{
	mark[v] = 1;
	for(auto u : g[v])
		if(!mark[u])
			dfs(u);
}

signed main()
{
//	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);	
	
	deque<pii> mx, mn;
	int ans = 0;
	cin>> n >> k;
	
	int tool = 0;
	for(int i = 1; i <= n; i++)
	{
		cin>> a[i];
			
		while(mx.size())
		{
			if(a[i] > mx.back().F) mx.pop_back();
			else break;
		}		
		mx.push_back({a[i],i});
			
		while(mn.size())
                {
                	if(a[i] < mn.back().F) mn.pop_back();
                        else break;
                }
                mn.push_back({a[i],i});
		
		if(i > k) 
		{
			int l = i-k, r = i;
			while(mx.size())
			{
				if(mx.front().S < l) mx.pop_front();
				else break;
			}	
			while(mn.size())
                        {
                                if(mn.front().S < l) mn.pop_front();
                                else break;
                        }
			
			if(mn.front().S == l && mx.front().S == r)	
			{
			//	cout<< l <<" "<< r <<"\n";
				g[l].push_back(l+1);
				g[l+1].push_back(l);
			}
		}
		
		if(i == 1 || a[i] > a[i-1]) tool++;
		else tool = 1;
		if(tool >= k) 
			asc.push_back(i-k+1);
	}

	int m = asc.size()-1;	
	for(int i = 0; i < m; i++)
	{
		//cout<< asc[i] <<" "<< asc[i+1] <<"\n";
		g[asc[i]].push_back(asc[i+1]);
		g[asc[i+1]].push_back(asc[i]);
	}	

	for(int i = 1; i <= n-k+1; i++)
		if(!mark[i])
		{
			ans++;	
			dfs(i);
		}

	cout<< ans;
}

















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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> d(k);
    for(int i=0; i<k; i++){
        cin >> d[i];
    }
    int ans = n;
    while(1){
        bool flag = true;
        for(int i=0; i<to_string(ans).size(); i++){
            for(int j=0; j<k; j++){
                if(to_string(ans)[i] - '0'== d[j]){
                    flag = false;
                    break;
                }
            }
            if(flag == false){
                break;
            }
        }
        if(flag){
            break;
        }else{
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 1010
using namespace std;
int n;
double ansx,ansy,ans;
double totx=0,toty=0;
double t;
double delta=0.999;
struct node{
	double x,y,w;
};node f[N];
double check(double x,double y) {
	double dx,dy,ret=0;
	for(int i=1;i<=n;i++) {
		dx=x-f[i].x;
		dy=y-f[i].y;
		ret=max(sqrt(dx*dx+dy*dy),ret);
	}
	return ret;
}
void sa() {
	t=45000;
	while(t>1e-18) {
		double tx=ansx+(rand()*2-RAND_MAX)*t;
		double ty=ansy+(rand()*2-RAND_MAX)*t;
		double a=check(tx,ty);
		double an=a-ans;
//		printf("%lf %lf %lf\n",tx,ty,a);
		if(an<0) ansx=tx,ansy=ty,ans=a;
		else if(exp(-an/t)*RAND_MAX>rand()) ansx=tx,ansy=ty;
		t*=delta;
	}
}
int main() {
	srand(1960);
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		cin>>f[i].x>>f[i].y;
		totx+=f[i].x;
		toty+=f[i].y; 
	}
	ansx=totx/n;
	ansy=toty/n;
	ans=check(ansx,ansy);
	for(int i=1;i<=10;i++) sa();
	double dx,dy,ret;
	for(int i=1;i<=n;i++) {
		dx=ansx-f[i].x;
		dy=ansy-f[i].y;
		ret=max(sqrt(dx*dx+dy*dy),ret);
	}
	cout<<fixed<<setprecision(7)<<ret;
	return 0;
}

Measured memory_bytes: 768
n, a, b = map(int, input().split())
mod = 7+10**9
def comb(n,c,mod):
  x = 1
  y = 1
  for i in range(n-c+1,n+1):
    x = x*i%mod
  for j in range(1,c+1):
    y = y*j%mod
  return (x * pow(y, mod-2, mod)) % mod
c_a = comb(n,a,mod)
c_b = comb(n,b,mod)
print((pow(2,n,mod)-1 -(c_a+c_b))%mod)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;


const int maxn = 1e6+5;
int main(){
    string s;
    cin >> s;
    if(s[2]==s[3]&&s[4]==s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long int a,b,c,d;
  cin >> a >> b >> c >> d;
  long int x=a*c,y=a*d,z=b*c,w=b*d;
  cout << max(max(x,y),max(z,w)) <<endl;
}

Measured memory_bytes: 3636
//https://atcoder.jp/contests/dp/tasks/dp_i

#include <bits/stdc++.h>
#include <limits.h>
#include <algorithm>  


#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;


using namespace std;

typedef long long int ll;

const int precision = 16;
const int modulo =  1000000007; // 10^9 + 7
using ll = long long;
const double EPS = 1e-9;


double solveCoins() {
	int n; cin >> n;
	vector<double> p(n);
	for(auto & c : p) cin >> c;

	vector<double> dp(n + 1);
	dp[0] = 1;

	for(auto coin = 0; coin < n; ++coin) {
		auto prob = p[coin];
		for(int i = coin + 1; i >= 0; --i) {
			dp[i] *= (1 - prob);
			if(i != 0) dp[i] += dp[i - 1] * prob;
		}
	}

	double ans = 0;
	for(int heads = 0; heads <= n; ++heads) {
		int tails = n - heads;
		if(heads > tails) {
			ans += dp[heads];
		}
	}
	return ans;
}

double solveCoinsDp2() {
	int n; cin >> n;
	vector<double> coins(n);

	vector<vector<double>> dp(n + 1, vector<double> ( n + 1));
	
	dp[0][0] = 1;
	for(auto r = 0; r < n; ++r) {
		double p; cin >> p;
		for(auto c = 0; c <= r; ++c) {
			dp[r + 1][c + 1] += dp[r][c] * p;
			dp[r + 1][c] += dp[r][c] * (1 - p);
		}
	}

	// std::cout.precision(2);
	// for(auto i : dp) {
	// 	for(auto j : i) {
	// 		cout << j << "    "; 
	// 	}
	// 	cout <<endl;
	// }

	double ans = 0;
	for(int heads = 0; heads <= n; ++heads) {
		int tails = n - heads;
		if(heads > tails) {
			ans += dp[n][heads];
		}
	}
	return ans;

}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(precision);
	cout.setf(ios_base::fixed);

	//auto ret = solveCoins();
	auto ret = solveCoinsDp2();
	cout << ret << endl;
	return 0;
}




Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    ll h;
    cin >> h;
    int ans=0;
    while(true){
        if(h==1){
            ans++;
            break;
        } 
        else{
            h/=2;
            ans++;
        }
    }
    ll ans2=1;
    ll ans3=1;
    rep(i,ans-1){
        ans3*=2;
        ans2+=ans3;
    }
    cout << ans2 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int x,max=1,i,j,tem=1;
  scanf("%d",&x);
  if(x>1){
    for(i=2;i<=x;i++){
      tem=i*i;
      while(tem<=x){
        tem*=i;
        if(tem>x){
          tem/=i;
          if(tem>max){
            max=tem;
          }
          break;
        }
      }
    }
  }
  printf("%d\n",max);
  return 0;
}


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

#define rep(i, l, r) for (ll i = (l); i <= (r); i++)
#define irep(i, r, l) for (ll i = (r); i >= (l); i--)
#define vec(t) vector<t>

using namespace std;
using ll = long long;
using vecint = vec(int);
using vecll = vec(ll);
using pii = pair<int,int>;
using pll = pair<ll,ll>;
const ll MOD=1e9+7;

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

    // cin....


    string s[3];

    cin >> s[0] >> s[1] >> s[2];
    int turn=0;
    while(true) {
        if (s[turn].size() == 0) {
            cout << char('A' + turn) << endl;
            return 0;
        }
        char c = *(s[turn].begin());
        s[turn].erase(s[turn].begin());
        turn = c-'a';
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define fo(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define MAXN 1000002
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod=1e9+7;

void solve()
{
    int n;
    cin>>n;
    string str;
    cin>>str;
    ll r=0,g=0,b=0;
    for(int i=0;i<n;i++)
    {
      if(str[i]=='R')
      r++;
      else if(str[i]=='G')
      g++;
      else
      b++;
    }
    ll cnt=0;
    ll tot=r*g*b;
    for(int i=0;i<n;i++)
    {
      for(int j=0;j<n-2*(i+1);j++)
      {
        string res="";
        int k=i+1;
        char ch1=str[j],ch2=str[j+k],ch3=str[j+2*k];
        res=res+ch1+ch2+ch3;
        sort(res.begin(),res.end());
        //cout<<res<<" ";
        if(res=="BGR")
        cnt++;
      }
    }
    ll ans=tot-cnt;
    cout<<ans;
}

int main()
{
  fastio
  solve();
}


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

int main(){
	int n;
	int num,max1=-2000000000,min1=2000000000;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> num;
		max1 = max(max1,(num-min1));
		min1 = min(min1,num);
	}
	cout << max1 << endl;
	return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

vector<ll> ans;

void dfs(ll x, int depth) {
    ans.push_back(x);
    if (depth == 10) return;
    int m = x % 10;
    if (m > 0) dfs(x * 10 + m - 1, depth + 1);
    dfs(x * 10 + m, depth + 1);
    if (m < 9) dfs(x * 10 + m + 1, depth + 1);
}


int main() {
    int k;
    cin >> k;
    for (ll i = 1; i <=9; i++) dfs(i, 1);
    sort(all(ans));
    cout << ans[k - 1] << endl;
    return 0;
}


Measured memory_bytes: 2420
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool in_range(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool in_range(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

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};
const double EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//



int main() {
	int A, B;
	cin >> A >> B;
	if (A <= 9 && B <= 9) cout << A * B << endl;
	else cout << -1 << endl;
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int N;
	int W;
	cin>>N>>W;
	int w[N];
	int v[N];
	for(int i=0;i<N;i++)
		cin>>v[i]>>w[i];
	int DP[N+1][W+1];
	for(int j=0;j<=W;j++)
		DP[0][j]=0;
	for(int i=1;i<=N;i++)
		for(int j=0;j<=W;j++)
			if(j<w[i-1])
				DP[i][j]=DP[i-1][j];
			else{
				if(DP[i-1][j]>DP[i-1][j-w[i-1]]+v[i-1])
					DP[i][j]=DP[i-1][j];
				else
					DP[i][j]=DP[i-1][j-w[i-1]]+v[i-1];
			}
			cout<<DP[N][W]<<endl;
		return 0;
}

Measured memory_bytes: 5108
from itertools import combinations as comb

def count(x1,y1,x2,y2):
    res = 0
    for x,y in point:
        if x1 <= x <= x2 and y1 <= y <= y2:
            res += 1
    return res 
    
N,K = map(int,input().split())

x = []
point = []
y_dict = {}

for i in range(N):
    a,b = map(int,input().split())
    x.append(a)
    point.append((a,b))
    y_dict[a] = b#yの値はxの値と紐づけしておく

x = sorted(x)
ans = 10**20

number = [i for i in range(N)]
C = list(comb(number,2))

for i,j in C:#組合せで調べる
    y_list = []

    for k in range(i,j+1):#xの指定区間内にある点のy座標を取得しy_listに入れる
        y_list.append(y_dict[x[k]])
        
    y_list = sorted(y_list)
        

    if 2 <= len(y_list):
        number2 = [i for i in range(len(y_list))]
        C_2 = list(comb(number2,2))

        for l,m in C_2:        
                x1 = x[i]
                y1 = y_list[l]
                x2 = x[j]
                y2 = y_list[m]
                n = count(x1,y1,x2,y2)#区間内の点の数
                   
                if K <= n :
                    ans = min(ans,(x2-x1)*(y2-y1)) 
               
print(ans) 








Measured memory_bytes: 3444
/**Bismillahir Rahmanir Rahim**/


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

#define pb push_back
#define io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define clr(v) v.clear()
vector<ll>v;
pair<ll,ll>p;
map<ll,ll>mp;
set<ll>st;
deque<ll>dq;
priority_queue<ll>pq;
#define f(i,b) for(i=0;i<b;i++)
#define f1(i,b) for(i=1;i<=b;i++)
#define fr(i,b)for(i=b-1;i>=0;i--)
ll mn=INT_MAX,mx=INT_MIN;
ll n,m,tc,i,j,tmp,sum,cn,ans,res,pos,flag,l,x,k,dif;

string s,str;


ll a[200007],b[200007];
int main()
{

   io;
ll a,b,c,d;
cin>>a>>b>>c;
//cout<<min(a,b)+min(c,d)<<endl;
a-=b;
cout<<a%c;
return 0;
}





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

int main(void){
    double w,h,x,y;
    cin >> w >> h >> x >> y;
    double cal;
  	cal  = w*h/2.0;
    
    cout << cal << " ";
  	if(x==w/2.0 && y==h/2.0){
      cout << 1;
    }
  	else{
      cout << 0;
    }
  
    return 0;
}
























Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int k, x;
    cin >> k >> x;
    int start, finish;
    start = x-k+1;
    finish = x+k-1;
    FOR(i, start, (finish+1)){
        cout << i << " ";
    }

    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

## DFS

N, M = mi()
memo = []
rel = [[] for i in range(N)]

for i in range(M):
    s, t = mi()
    s, t = s-1, t-1
    memo.append((s, t))
    rel[s].append(t)
    rel[t].append(s)

def dfs(v):
    for nv in rel[v]:
        if not used[nv]:
            used[nv] = 1
            dfs(nv)
            if sum(used) == N:
                global flag
                flag = 1
                return

cnt = M
for x in range(M):
    s, t = memo[x][0], memo[x][1]
    rel[s].remove(t)
    rel[t].remove(s)
    flag = 0
    used = [0]*N
    dfs(0)
    if flag:
        cnt -= 1
    rel[s].append(t)
    rel[t].append(s)

print(cnt)

Measured memory_bytes: 3064
N,Q,S,*L = open(0).read().split()
N,Q = int(N),int(Q)
ans = N
l = -1
r = N
while l+1<r:
  s = (l+r)//2
  i = s
  p = S[i]
  for t,d in zip(*[iter(L)]*2):
    if p!=t:
      continue
    if d=='L':
      if i==0:
        l = s
        break
      i -= 1
      p = S[i]
    else:
      if i==N-1:
        r = s
        break
      i += 1
      p = S[i]
  else:
    r = s
ans -= r
l = -1
r = N
while l+1<r:
  s = (l+r)//2
  i = s
  p = S[i]
  for t,d in zip(*[iter(L)]*2):
    if p!=t:
      continue
    if d=='L':
      if i==0:
        l = s
        break
      i -= 1
      p = S[i]
    else:
      if i==N-1:
        r = s
        break
      i += 1
      p = S[i]
  else:
    l = s

ans -= N-r  
print(ans)


Measured memory_bytes: 94108
#include <stdio.h>
#include <math.h>
 
int keta(int a,int count){
  int s = a/10;
  count ++;
  if(s==0){
    return count;
  }
  keta(s,count);
}
 
  
int main(void){
  long n;
  scanf("%ld",&n);
  
  long meyasu = (int)sqrt(n);
  
  for(long i = meyasu;i > 0; i --){
    if(n%i==0){
      printf("%d",keta(n/i,0));
      return 0;
    }
  }
      return 0;
}

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


int n, m, q;
vector<int> a, b, c, d;
int ans;
 
void dfs(vector<int> A) {
  if (A.size() == n+1) {
    int now = 0;
    rep(i,q) {
      if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
    }
    ans = max(ans, now);
    return;
  }
 
  A.push_back(A.back());
  while (A.back() <= m) {
    dfs(A);
    A.back()++;
  }
}
 
int main() {
  cin >> n >> m >> q;
  a=b=c=d= vector<int> (q);
  rep(i,q) {
    cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
  }
  dfs(vector<int>(1,1));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3556
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    int N;
    cin >> N;
    lint A[N];
    rep(i,N) cin >> A[i];
    lint sum1=0,sum2=0,ans1=0,ans2=0;
    rep(i,N){
        sum1+=A[i];
        if(i%2==0){
            if(sum1<=0){
                ans1+=-sum1+1;
                sum1=1;
            }
        }
        else{
            if(sum1>=0){
                ans1+=sum1+1;
                sum1=-1;
            }
        }
    }
    rep(i,N){
        sum2+=A[i];
        if(i%2==1){
            if(sum2<=0){
                ans2+=-sum2+1;
                sum2=1;
            }
        }
        else{
            if(sum2>=0){
                ans2+=sum2+1;
                sum2=-1;
            }
        }
    }
    cout << min(ans1,ans2) << endl;
}

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

int main()
{
	double r;
	cin >> r;
	cout.setf(ios::fixed);
	cout.precision(5);
	cout << r * r * M_PI << " " << r * 2 * M_PI << endl;
	return 0;
}

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

#define debug(x) cerr << #x << " = " << x << endl;
using namespace std;

const int MAX = 3e3 + 10;
double p[MAX], memo[MAX][MAX];

double dp_solve(int n, int h)
{
	if(n == 0 && h == 1)
		return p[0];
	if(n == 0 && h == 0)
		return 1 - p[0];
	if(h == -1)
		return 0;
	if(h > n + 1)
		return 0;
	double &ans = memo[n][h];
	if(ans != -1.0) return ans;
	assert(n >= 0);
	assert(h >= 0);
	return ans = dp_solve(n - 1, h - 1) * p[n] + dp_solve(n - 1, h) * (1 - p[n]);
}

int main()
{
	int n;
	cin >> n;
	vector<double> v = {1};
	for(int i = 0; i < n; i++)
		cin >> p[i];

	double ans = 0;
	for(int i = 0; i < MAX; i++)
		for(int j = 0; j < MAX; j++)
			memo[i][j] = -1.0;
	for(int i = (n + 2) / 2; i <= n; i++)
		ans += dp_solve(n - 1, i);
	cout << fixed << setprecision(10) << ans << endl;

	return 0;
}


Measured memory_bytes: 71296
#include<stdio.h>
#include<string.h>

#define M 1046527
#define N (-1)
#define L 14

char H[M][L];

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

long long getKey(char str[])
{
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ )
  {
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }

int find(char str[])
{
  long long key, i, h;
  key = getKey(str);
  for ( i = 0;; i++)
  {
    h = (h1(key)+i*h2(key))%M;
    if( strcmp(H[h],str) == 0 ) return 1;
    else if ( strlen(H[h]) == 0 ) return 0;
  }
  return 0;
}

int insert(char str[])
{
  long long key, i, h;
  key = getKey(str);
  for ( i = 0; ; i++ )
  {
    h = (h1(key)+i*h2(key))%M;
    if( strcmp(H[h],str) == 0 ) return 1;
    else if ( strlen(H[h]) == 0 ){
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
  scanf("%d", &n);
  for ( i = 0; i < n; i++ )
  {
    scanf("%s %s", com, str);

    if ( com[0] == 'i' ){
      if (insert(str)){

      }
    } else {
      if (find(str) ){
	printf("yes\n");
      } else {
	printf("no\n");
      }
    }
  }
  return 0;
}



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

def f(b, n):
    if n<b:
        return n
    else:
        return f(b, n//b)+n%b
if n == s:
    print(n+1)
    exit()
if (n+1)//2 < s:
    print(-1)
    exit()

ans = float("inf")
i = 1
q = 0
while s >= i:
    if i*i >= n:
        break
    q, m = divmod(n-(s-i), i)
    if i > q:
        break
    if s-i >= q:
        break
    if m == 0:
        ans = q
    i += 1
i = 2
while i*i <= n:
    if f(i, n) == s:
        ans = i
        break
    i += 1
print(ans)


Measured memory_bytes: 3064