akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef tuple<int, int, int, int, int, int> Tp;
#define at(t, i) get<i>(t)
const int INF = 1 << 28;
const int dy[] = {0, 0, 1};
const int dx[] = {-1, 1, 0};

int H, W, F, M, O;
int cost[10][10];
int o2[10][10];
int dist[10][10][10][10][51];

bool ok(int x)
{
	return x >= 0 && x < W;
}

int solve()
{
	if (O <= 1) return INF;
	
	priority_queue<Tp, vector<Tp>, greater<Tp>> pq;
	
	for (int i = 0; i < W; i++){
		pq.push( Tp(cost[0][i], 0, i, i, i, min(O + o2[0][i] - 1, M)) );
	}
	
	while (pq.size()){
		Tp tp = pq.top(); pq.pop();
		int y = at(tp, 1);
		int x = at(tp, 2);
		int lx = at(tp, 3);
		int rx = at(tp, 4);
		int o = at(tp, 5);
		int sum = at(tp, 0);
		if (dist[y][x][lx][rx][o] < sum) continue;
		if (y == H - 1) return sum;
		if (o <= 1) continue;
		
		for (int dir = 0; dir < 2; dir++){
			int ny = y;
			int nx = x + dx[dir];
			if (!ok(nx)) continue;
			int nlx = min(nx, lx);
			int nrx = max(nx, rx);
			int no = o - 1;
			int nsum = sum;
			if (nx < lx || rx < nx){
				no = min(no + o2[y][nx], M);
				nsum += cost[y][nx];
			}
			if (dist[ny][nx][nlx][nrx][no] > nsum){
				dist[ny][nx][nlx][nrx][no] = nsum;
				pq.push( Tp(nsum, ny, nx, nlx, nrx, no) );
			}
		}
		
		int ny = y + 1;
		int nx = x;
		int nlx = x;
		int nrx = x;
		int no = min(o - 1 + o2[ny][nx], M);
		int nsum = sum + cost[ny][nx];
		if (dist[ny][nx][nlx][nrx][no] > nsum){
			dist[ny][nx][nlx][nrx][no] = nsum;
			pq.push( Tp(nsum, ny, nx, nlx, nrx, no) );
		}
	}
	
	return INF;
}

int main()
{
	while (scanf("%d %d", &W, &H), W){
		scanf("%d %d %d", &F, &M, &O);
		
		fill_n(*cost, 100, 0);
		fill_n(*o2, 100, 0);
		fill_n(****dist, 510000, INF);
		
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				int g;
				scanf("%d", &g);
				if (g < 0) cost[i][j] = -g;
				else o2[i][j] = g;
			}
		}
		
		int res = solve();
		if (res <= F) printf("%d\n", res);
		else puts("NA");
	}
}

Measured memory_bytes: 3300
#include<bits/stdc++.h>
using namespace std;
template<class T>
using PAIR = pair<T,T>;
template<class T>
using vec = vector<T>;
template<class T>
using maps = map<string, T>;
template<class T>
using mapi = map<int, T>;
using ll = long long;
int main(){
    int n;
    vec<ll> H;
    cin >> n;
    for(int i = 0;i < n;i++){
        ll x;
        cin >> x;
        H.push_back(x);
    }
    ll ans = 0;
    bool flg = false;
    for(int i = 0;i < n-1;i++){
        ans+=H[i+1]-H[i];
        if(ans > 0){
            ans = 0;
        }
        else if (ans <= -2){
            flg = true;
            break;
        }
    }
    if(flg){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 1400
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc=new Scanner(System.in);
    	int n=sc.nextInt();
    	String a=sc.next(),b=sc.next();
    	for(int i=0;i<n;i++) {
    		System.out.print(a.charAt(i));
    		System.out.print(b.charAt(i));
    	}
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

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

  cout << (n >= 10 ? r : r + 100 * (10 - n)) << endl;


  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  bool flag = true;
  vector<int> backet(1000);
  for (int i = 0; i < s.size(); i++) {
    backet.at(s[i])++;
  }
  for (int i = 0; i < 1000; i++) {
    if (backet.at(i) != 0 && backet.at(i) % 2 != 0) flag = false;
  }
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

// Problem https://atcoder.jp/contests/abc070/tasks/abc070_b

int solver(int ASTART,int ASTOP,int BSTART,int BSTOP){
    int result;
    result = 0;
    int startmax,stopmin,switchingtime;
    startmax = max(ASTART,BSTART);
    stopmin = min(ASTOP,BSTOP);
    switchingtime = stopmin-startmax;
    if(0 < switchingtime){
        result = switchingtime;
    }
    return result;
}

int main(void){
    int tmp;
    int answer;
    int A,B,C,D;
    tmp = scanf("%d%d%d%d",&A,&B,&C,&D);
    answer = solver(A,B,C,D);
    printf("%d\n",answer);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

/*
問題文
高橋君は九九を覚えたので、1 以上 9 以下の 2 つの整数の積を計算することができます。
それ以外の計算はできません。

2 つの整数 A,B が与えられます。
高橋君が A×B を計算できるならその結果を、できないなら代わりに -1 を出力してください。

制約
1≤A≤20
1≤B≤20
入力中のすべての値は整数である。
*/

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

        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();
        
        if (a >= 10 || b >= 10) {
          System.out.println(-1);
        } else {
          System.out.println(a*b);
        }
    }
}

Measured memory_bytes: 23124
#include "bits/stdc++.h"
#define int long long int
using namespace std;
const int N = 1e6 + 2; 

int32_t main() {
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);    
    int n;
    cin >> n;
    int a[n];
    int ans = 0;
    for(int i = 0 ; i < n ; i++){
      cin >> a[i];

    }
    for(int i = 0 ; i < n ; i++){
      for(int j = i + 1 ; j < n ; j++){
        ans+=a[i] * a[j];
      }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int h,n,a;
  scanf("%d",&h);
  scanf("%d",&n);
  for(;n>0;n--){
  	scanf("%d",&a);
    h-=a;
  }
  if(h<=0){
  	printf("Yes");
  }else{
  	printf("No");
  }
  return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef unsigned long long ll;
typedef pair<ll,int> P;

int dp[11000];

int main(){
  int N,count=0;
  ll K,A[110000],hantei=1099511627776,ans=0,sum=0,B[110000];

  cin>>N>>K;

  for(int i=0;i<N;i++){
    cin>>A[i];
    B[i]=A[i];
  } 

  for(int i=0;i<41;i++,count=0,hantei/=2){
    //cout<<hantei<<endl;
    for(int j=0;j<N;j++){
      if(A[j]>=hantei){
        //cout<<j<<" "<<A[j]<<" "<<A[j]-hantei<<endl;
        count++;
        A[j]-=hantei;
      }
    }
    if(count*2<N && ans+hantei<=K) ans+=hantei; 
  }
  for(int i=0;i<N;i++) sum+=ans^B[i];
  cout<<sum<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

template<int mod>
struct ModInt {
    int x;

    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }

    ModInt pow(int e){
        long long a = 1, p = x;
        while(e > 0) {
            if(e%2 == 0) {p = (p*p) % mod; e /= 2;}
            else {a = (a*p) % mod; e--;}
        }
        return ModInt(a);
    }

    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

const int mod = 1e9 + 7;
using modint = ModInt<mod>;
modint fact[2000010];
modint nCr(int n, int r){
    return fact[n]/(fact[n-r]*fact[r]);
}

int main(){
    fastcin();

    int x, y;
    cin >> x >> y;
    fact[0] = 1;
    for(LL i=1; i<=2000000; i++){
        fact[i] = (fact[i-1] * i);
    }

    if(2*x < y || 2*y < x){
        cout << 0 << endl;
        return 0;
    }
    if((x+y)%3 != 0){
        cout << 0 << endl;
        return 0;
    }
    int X = (x+y)/3, Y = X*2;
    int n = (x+y)/3;
    rep(i, n+1){
        if(X == x && Y == y){
            cout << nCr(n, i) << endl;
            break;
        }
        X += 1;
        Y -= 1;
    }
}

Measured memory_bytes: 8064
import numpy as np
import time
import random
import collections
import bisect  
  
def insert(list, n): 
    bisect.insort(list, n)  
    return list
    
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

start = time.time()


c = np.array(c)
s = np.array(s)
d = np.zeros(26, dtype=np.int64)
tests = np.argmax(s, axis=1)

def get_dates_for_tests(tests):
  dates_for_tests = [list([0]) for _ in range(26)]
  for i, t in enumerate(tests):
    dates_for_tests[t].append(i)
  for t in range(26):
    dates_for_tests[t].append(D-1)
  return dates_for_tests

dates_for_tests = get_dates_for_tests(tests)

def score_diff(date, test):
  before = tests[date]
  if test == before:
    return 0, None, None
  pos_diff = s[date, test] - s[date, before]
  new_index = bisect.bisect_left(dates_for_tests[test], date, 1)
  new_diff = c[test] * (dates_for_tests[test][new_index] - date) * (date - dates_for_tests[test][new_index-1])

  old_index = bisect.bisect_left(dates_for_tests[before], date, 1)
  #print(dates_for_tests[test])
  #print(dates_for_tests[before])
  old_diff = c[before] * (dates_for_tests[before][old_index+1] - date) * (date - dates_for_tests[before][old_index-1])
  
  total_diff = pos_diff - new_diff + old_diff
  #print(test, total_diff, pos_diff, new_diff, old_diff)
  return total_diff, new_index, old_index

while time.time() < start + 1.8:
  for date in range(D):
    for test in range(26):
      total_diff, new_index, old_index= score_diff(date, test)
      if total_diff > 0 :
        del dates_for_tests[tests[date]][old_index]
        insert(dates_for_tests[test], date)
        tests[date] = test
        #assert(dates_for_tests == get_dates_for_tests(tests))
        
for t in tests:
  print(t+1)


Measured memory_bytes: 27312
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
typedef pair<int,pint> tint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
priority_queue<pint> q;
int dp[1001001];
bool sumi[1001001];
string ma[1001001];
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
void aedge(int x,int y){
	if(dp[x]<=y) return;
	dp[x]=y;q.push(mp(-y,x));
}
int main()
{
	int h,w,K,sx,sy,gx,gy,inf=1001001001;cin>>h>>w>>K;
	cin>>sx>>sy>>gx>>gy;
	sx--;sy--;gx--;gy--;
	rep(i,h) cin>>ma[i];
	rep(i,1001001) dp[i]=inf;
	memset(sumi,false,sizeof(sumi));
	aedge(sx*w+sy,0);
	while(!q.empty()){
		pint p=q.top();q.pop();
		int v=-p.fi,x=p.se/w,y=p.se%w;
		//cout<<x<<' '<<y<<' '<<v<<endl;
		if(sumi[p.se]) continue;sumi[p.se]=true;
		rep(i,4){
			REP(j,1,K+1){
				int nx=x+dx[i]*j,ny=y+dy[i]*j;
				if(nx<0 || ny<0 || nx>=h || ny>=w) break;
				if(ma[nx][ny]=='@') break;
				if(dp[nx*w+ny]<=v) break;
				aedge(nx*w+ny,v+1);
			}
		}
	}
	if(dp[gx*w+gy]>=inf) cout<<-1<<endl;
	else cout<<dp[gx*w+gy]<<endl;
}


Measured memory_bytes: 41820
#include <stdio.h>

int gcd(int a, int b) {
    int tmp;

    while (b!=0) {
        tmp=b;
        b=a%b;
        a=tmp;
    }
    return a;
}

int main(void) {
	int a, b, tmp, x, y, i;

    while (scanf("%d %d", &a,&b)!=EOF) {
        if (a<b) tmp=a, a=b, b=tmp;
        x=gcd(a, b);
        for (i=1;;i++) {
            y=a*i;
            if (y%b==0) break;
        }
        printf("%d %d\n", x, y);
    }
	return 0;
}



Measured memory_bytes: 2064
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

int n, m;
int a[200009], cnt[200009], pos[200009];
int ans;

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

    cin >> n >> m;
    ans = n;
    FOR(i, 1, n + 1) {
        cin >> a[i];
        if(a[i] - ++cnt[a[i]] >= 0) ans -= !(pos[a[i] - cnt[a[i]]]++);
    }

    while(m--) {
        int x, y;
        cin >> x >> y;
        if(a[x] - cnt[a[x]] >= 0) ans += !--pos[a[x] - cnt[a[x]]];
        cnt[a[x]]--;
        a[x] = y;
        if(y - ++cnt[y] >= 0) ans -= !pos[y - cnt[y]]++;
        cout << ans << "\n";
    }

    return 0;
}

Measured memory_bytes: 3840
#      
import collections, atexit, math, sys, bisect 

sys.setrecursionlimit(1000000)
def getIntList():
    return list(map(int, input().split()))    

try :
    #raise ModuleNotFoundError
    import numpy
    def dprint(*args, **kwargs):
        #print(*args, **kwargs, file=sys.stderr)
        # in python 3.4 **kwargs is invalid???
        print(*args,  file=sys.stderr)
    dprint('debug mode')
except Exception:
    def dprint(*args, **kwargs):
        pass



inId = 0
outId = 0
if inId>0:
    dprint('use input', inId)
    try:
        f = open('input'+ str(inId) + '.txt', 'r')
        sys.stdin = f #标准输出重定向至文件
    except Exception:
        dprint('invalid input file')
if outId>0:
    dprint('use output', outId)
    try:
        f = open('stdout'+ str(outId) + '.txt', 'w')
        sys.stdout = f #标准输出重定向至文件
    except Exception:
        dprint('invalid output file')
        
    atexit.register(lambda :sys.stdout.close())     #idle 中不会执行 atexit
    
N,A,B = getIntList()
#print(N)
print(min(A,B),  max(A+B-N,0) )







Measured memory_bytes: 38384
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define OPR 100
#define ENZ 99

int stack[OPR+ENZ],pointer;

void push(int op){
  stack[++pointer]=op;
}
int pop(void){
  pointer--;
  return stack[pointer+1];
}

int main(){
  int x,y;
  pointer=0;
  char data[OPR];
  while(scanf("%s",data)!=EOF){
    switch(data[0]){
    case '+':
      x = pop();
      y = pop();
      push(x+y);
      break;
    case '-':
      x = pop();
      y = pop();
      push(y-x);
      break;
    case '*':
      x = pop();
      y = pop();
      push(x*y);
      break;
    default :
      push(atoi(data));
      break;
    }
  }
  printf("%d\n",pop());
  return 0;
}



Measured memory_bytes: 2128
#include<bits/stdc++.h>
using namespace std;
main()
{
    int n;
    cin>>n;
    int d=n%10;
    if(d==2||d==7||d==4||d==5||d==9)
    cout<<"hon"<<endl;
    else if(d==0||d==1||d==6||d==8)
    cout<<"pon"<<endl;
    else
    {
        cout<<"bon"<<endl;
    }
    
}

Measured memory_bytes: 3636
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N = getN()
S = defaultdict(int)
alta = [input() for i in range(N)]
for i in alta:
    if i == "AC":
        S[i] += 1
for i in alta:
    if i == "WA":
        S[i] += 1
for i in alta:
    if i == "TLE":
        S[i] += 1
for i in alta:
    if i == "RE":
        S[i] += 1

print('AC x ' + str(S["AC"]))
print('WA x ' + str(S["WA"]))
print('TLE x ' + str(S["TLE"]))
print('RE x ' + str(S["RE"]))

Measured memory_bytes: 84668
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
typedef long long ll;
typedef long double ld;

ll gi() {
	ll x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

struct point {
	int x;ll y;
	point() {}
	point(int x,ll y):x(x),y(y) {}
	point operator-(const point &A) const {
		return point(x-A.x,y-A.y);
	}
	ll operator%(const point &A) const {
		return 1ll*x*A.y-1ll*y*A.x;
	}
} st[N];

ll a[N],c[N];
int n,b[N],tp;

void insert(point p) {
	while(tp>1&&(st[tp]-st[tp-1])%(p-st[tp-1])>=0) --tp;
	st[++tp]=p;
}

int main() {
	cin>>n;
	for(int i=1;i<=n;i++) a[i]=gi();
	for(int i=1;i<=n;i++) b[i]=gi();
	int p=max_element(a+1,a+n+1)-a;
	rotate(a+1,a+p,a+n+1);rotate(b+1,b+p,b+n+1);
	++n;a[n]=a[1];b[n]=b[1];
	for(int i=1;i<n;i++) c[i+1]=2*b[i]-c[i-1]+2*c[i];
	for(int i=1;i<=n;i++) insert(point(i,a[i]-c[i]));
	ld ans=0;
	for(int i=1;i<tp;i++) ans+=0.5*(st[i].y+st[i+1].y)*(st[i+1].x-st[i].x-1)+st[i].y;
	for(int i=1;i<n;i++) ans+=c[i];
	ans/=(n-1);
	cout<<setprecision(15)<<fixed<<ans;
	return 0;
}


Measured memory_bytes: 10708
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        double r,area,length;
    	//?¨??????\??????????????????????????§????????????
		Scanner scanner = new Scanner(System.in);

		r = scanner.nextDouble();

    	area = r*r*Math.PI;
    	length = 2*r*Math.PI;
    	//println?????¨??¨??????1.0E9??¨????????????AOJ??????????????¨
    	//??????????????????????????§printf????????¨???
    	System.out.printf("%f %f",area,length);
    	scanner.close();
    }
}

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

ll gcd(ll x,ll y)
{
    if(y==0) return x;
    return gcd(y,x%y);
}

ll lcd(ll x,ll y)
{
    return (y/gcd(x,y))*x;
}

ll a[105];

bool cmp(ll x,ll y)
{
    return x<y;
}

int main()
{
    int i,k,m;
    while(~scanf("%d",&m))
    {
        for(i=0;i<m;i++)
            scanf("%lld",a+i);
        sort(a,a+m,cmp);
        ll s=1;
        for(i=0;i<m;i++){
            s=lcd(a[i],s);
            //cout<<s<<endl;
        }
        printf("%lld\n",s);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{
    ve<vi> A(3,vi(3));
    rep(i,3) rep(j,3) cin >> A[i][j];
    int N;
    cin >> N;
    
    set<int> b;
    rep(i,N) {
        int a;
        cin >> a;
        b.insert(a);
    }

    
    rep(i,3) {
        int c = 0;
        rep(j,3) if(b.count(A[i][j])) c++;
        if(c == 3){
            cyes;
            return 0;
        }
    }
    rep(i,3) {
        int c = 0;
        rep(j,3) if(b.count(A[j][i])) c++;
        if(c == 3){
            cyes;
            return 0;
        }
    }

    int c = 0;
    rep(i,3) {
        if(b.count(A[i][i])) c++;
        if(c == 3){
            cyes;
            return 0;
        }
    }
    c = 0;
    rep(i,3) {
        if(b.count(A[i][2-i])) c++;
        if(c == 3){
            cyes;
            return 0;
        }
    }
    
    cno;
    
    

    return 0;
}


Measured memory_bytes: 256
#D問題

#factorial(階乗)
def factorial(facn):
    ret=1
    for i in range(facn):
        ret*=(i+1)
    return ret
#combination(組み合わせC)
def comb(comb1,comb2):
    x=min(comb1,comb2)
    y=max(comb1,comb2)
    bunshi=factorial(y)
    bunbo=factorial(x)*factorial(y-x)
    return int(bunshi/bunbo)

N,A,B=map(int,input().split())
v=list(map(int,input().split()))
v.sort(reverse=True)
dp=[0 for i in range(N)]
for i in range(A):
    if i == 0:
        dp[0]=v[0]
    else:
        dp[i]=dp[i-1]+v[i]
MAX=dp[A-1]/A
V=v[A-1]
left=v[:A]
right=v[A:]
LV=left.count(V)
RV=right.count(V)
if V == v[0]:
    Vsum=LV+RV
    com=0
    for i in range(A,min(B+1,Vsum+1)):
        com+=comb(Vsum,i)        
else:
    com=comb(LV+RV,LV)
print(MAX)
print(com)


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

int main() {
	ll n, m;
	cin >> n >> m;
	if(n < m) swap(n, m);
	ll ans = 0;
	if(n == 1 && m == 1) {
		ans = 1;
	} else if(m == 1) {
		ans = n-2;
	} else {
		ans = (n-2) * (m-2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
#define MM 1000000007
using namespace std;
int dp[100001][13];
int main(void)
{
	char s[100001];
	int i,j,k,x,len,y;
	scanf("%s",s);
	len=strlen(s);
	for(i=0;i<=len;i++)	{
		for(j=0;j<13;j++)	{
			dp[i][j]=0;
		}
	}
	if(s[0]=='?')	{
		for(i=0;i<10;i++)	dp[0][i]=1;
	}
	else {
		x=s[0]-'0';
		dp[0][x]=1;
	}
	for(i=1;i<len;i++)	{
		for(j=0;j<13;j++)	{
			if(s[i]=='?')	{
				for(k=0;k<10;k++)	{
					x=j*10+k;
					x=x%13;
					dp[i][x]+=dp[i-1][j];
					dp[i][x]%=MM;
				}
			}
			else {
				y=s[i]-'0';
				x=j*10+y;
				x=x%13;
				dp[i][x]+=dp[i-1][j];
				dp[i][x]%=MM;
			}
		}
	}
	printf("%d\n",dp[len-1][5]);
	return 0;
}

Measured memory_bytes: 5376
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

const int maxn = 1e7+10;
const int maxm = 210;

int p[4100000],pri;
bool v[maxn];

void pre()
{
    for(int i=2;i<maxn;i++)
    {
        if(!v[i]) p[++pri]=i;
        for(int j=1,k=i*p[j];j<=pri;j++,k=i*p[j])
        {
            if(k>=maxn) break;
            v[k]=true;
            if(i%p[j]==0) break;
        }
    }v[1]=v[2]=true;
}

int n,m;
int a[maxm],b[maxm];
bool s[maxn];
int p1[maxm],p2[maxm];
int p1n,p2n;

bool mp[maxm][maxm],ev[maxm];
int match[maxm],bel[maxm];
bool Find(const int x)
{
    if(ev[x]) return false;
    ev[x]=true;
    for(int i=1;i<=p2n;i++) if(mp[x][i])
    {
        if(!bel[i]||Find(bel[i])) { bel[i]=x; return true; }
    }
    return false;
}

int main()
{
    pre();
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]),s[a[i]]=true;
    for(int i=1;i<maxn;i++)
        if(s[i]!=s[i-1]) b[++m]=i;

    for(int i=1;i<=m;i++)
    {
        if(b[i]&1) p1[++p1n]=b[i];
        else p2[++p2n]=b[i];
    }
    for(int i=1;i<=p1n;i++)
    {
        for(int j=1;j<=p2n;j++) if(!v[abs(p1[i]-p2[j])]) mp[i][j]=true;
    }
    int k=0;
    for(int i=1;i<=p1n;i++) if(!match[i])
    {
        for(int j=1;j<=p1n;j++) ev[j]=false;
        if(Find(i)) k++;
    }
    p1n-=k; p2n-=k;
    int re=k;
    re+=p1n/2*2+p2n/2*2;
    re+=p1n%2*3;
     printf("%d\n",re);
    return 0;
}


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

int main() {
	long long N, A, B;
	cin>>N>>A>>B;
	long long arr[N];
	for (int i=0; i<N; i++){
		cin>>arr[i];
	}
	long long sum=0;
	for (int i=0; i<N-1; i++){
		if (A*(arr[i+1]-arr[i])>B){
			sum += B;	
		}
		else sum += A*(arr[i+1]-arr[i]);
	}
	cout << sum << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define lli long long int
#define llu long long unsigned int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FOR(i,s,e) for(i=s; i<e; i++)
#define mod 998244353
#define F first
#define S second
#define plli pair<lli,lli>
#define pqlli priority_queue<lli>
#define test(t) cin>>t; while(t--)
using namespace std;
 
lli power(lli a, lli b, lli M = mod)
{
	lli result = 1;
    for (;;)
    {
        if (b & 1)
            result = (result*a)%M;
        b >>= 1;
        if (!b)
            break;
        a = (a*a)%M;
    }
    return result;
}
 
int main()
{
    IOS;
    lli n;
    cin>>n;
    string s;
    cin>>s;
    lli dp[3][n+1];
    memset(dp, 0, sizeof(dp));
    for(lli i = 1; i<n+1; i++)
    dp[0][i] = dp[0][i-1] + (s[i-1] == 'R'), dp[1][i] = dp[1][i-1] + (s[i-1] == 'G'), dp[2][i] = dp[2][i-1] + (s[i-1] == 'B');
	lli ans = 0;
    for(lli i = 0; i<n; i++)
    {
		for(lli k = i+3; k<n; k++)
		{
			if(s[i] != s[k])
			{
				if(s[i]!='R' and s[k]!='R')
				{
					ans += dp[0][k] - dp[0][i+1];
					if((k-i-1)%2 and (s[(k+i)/2] == 'R'))
					ans--;
				}
				else if(s[i]!='G' and s[k]!='G')
				{
					ans += dp[1][k] - dp[1][i+1];
					if((k-i-1)%2 and (s[(k+i)/2] == 'G'))
					ans--;
				}
				else
				{
					ans += dp[2][k] - dp[2][i+1];
					if((k-i-1)%2 and (s[(k+i)/2] == 'B'))
					ans--;
				}
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3684
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

#define ketasitei setprecision(15) //15桁表示



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

	ll n;
	cin >> n;
	vector<ll> p(n);
	rep(i, n)
	{
		cin >> p[i];
	}
	vector<ll> ma(n,0);
	ma[0] = p[0];
	for (int i = 1; i <n; i++)
	{
		ma[i] = min(ma[i - 1], p[i]);
	}
	ll ans = 0;
	for (int i = 0; i< n; i++)
	{
		if (ma[i]>=p[i])
			ans++;
	}

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

Measured memory_bytes: 3456
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    cin >> n;
    akari<int> cnt(26, 100000);
    for (int i = 0; i < n; i++)
    {
        seika s;
        cin >> s;
        akari<int> t(26);
        for (char c : s)
        {
            t[c - 'a']++;
        }
        for (int j = 0; j < 26; j++)
        {
            cnt[j] = min(cnt[j], t[j]);
        }
    }
    for (int i = 0; i < 26; i++)
    {
        for (int j = 0; j < cnt[i]; j++)
        {
            cout << char('a' + i);
        }
    }
    cout << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll cnt[31];

int main() {
    init();
    ll N, C;
    cin >> N >> C;

    vc<tuple<ld, ll, ll>> A(2 * N);
    rep(i,N){
        ld s, t;
        ll c;
        cin >> s >> t >> c;
        s -= 0.5, t -= 0.1;
        A[2 * i] = make_tuple(s, 1, c), A[2 * i + 1] = make_tuple(t, 0, c);
    }
    sort(all(A));

    ll now = 0, ans = 0;
    rep(i,2*N){
        ld s;
        ll p, c;
        tie(s, p, c) = A[i];
        if(p){
            cnt[c]++;
            if (cnt[c] == 1) now++;
        }
        else{
            cnt[c]--;
            if (cnt[c] == 0) now--;
        }
        chmax(ans, now);
    }

    cout << ans << endl;
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define cinv(n,vec) VL (vec)(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t make_tuple
#define eb emplace_back
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (ll)(a.size())
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define cont const auto
#define fi first
#define se second
#define V vector
#define P pair
#define T tuple
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
#define PQ priority_queue
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<pair<ll,ll>> VP;
typedef tuple<ll,ll,ll> T3;
typedef tuple<ll,ll,ll,ll> T4;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin>>n;
  VL a(n);
  rep(i,n)cin>>a[i];
  int res=0;
  rep(i,n){
    while(i<n-1 && a[i]==a[i+1])i++;
    if(i<n-1 && a[i]<a[i+1])
      while(i<n-1 && a[i]<=a[i+1])i++;
    else if(i<n-1 && a[i]>a[i+1])
      while(i<n-1 && a[i]>=a[i+1])i++;
    res++;
  }
  out(res);


  
  
  return 0;
}



Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  int cnt = 0;
  while (1) {
    if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
      cout << cnt << endl;
      break;
    }

    int tmpA = (B + C) / 2;
    int tmpB = (A + C) / 2;
    int tmpC = (A + B) / 2;
    cnt++;

    if (A == tmpA && B == tmpB && C == tmpC) {
      cout << -1 << endl;
      break;
    }

    A = tmpA;
    B = tmpB;
    C = tmpC;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std; typedef long long ll; const int INF=1e9;
typedef pair<int,int> P;
int main() {
  int n,m; cin>>n>>m;
  int m2=m; vector<int> yk={1,m};
  for(int i=2;i*i<=m;i++) {
    if (m2%i==0) yk.push_back(i), yk.push_back(m2/i);
  }
  int an=1;
  for(int x:yk) {
    if (m/x>=n) an=max(an,x);
    //cout<<x<<" ";
  }
  cout<<an<<endl;
}

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

using namespace std;

int main(void){
	long A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	if(A + B < C*2){
		cout << A*X + B*Y << endl;
	}else{
		long min;
		long money = 0;
		long rest = 0;
		// 最小の数数だけABピザを買う
		if(X > Y){
			min = Y;
			if(A > C*2){
				rest = C * (X-Y)*2;
			}else{
				rest = A * (X-Y);
			}
		}else{
			min = X;
			if(B > C*2){
				rest = C * (Y-X)*2;
			}else{
				rest = B * (Y-X);
			}
		}
		money += min * C*2;
		cout << money + rest << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		if(n%10==7 || n/100==7 || (n/10)%10==7) System.out.println("Yes");
		else System.out.println("No");
		sc.close();
	}
}

Measured memory_bytes: 35832
#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    ll N, W;
    cin >> N >> W;
    const ll INF = 1e18;
    vector<vector<ll>> dp(N + 1, vector<ll>(1e5 + 1, INF));
    dp[0][0] = 0;
    REP(n, N) {
        ll w, v;
        cin >> w >> v;

        REP(sum_v, 1e5 + 1) {
            auto before_v = sum_v - v;
            if (before_v >= 0 && dp[n][before_v] + w <= W) {
                dp[n + 1][sum_v] = min(dp[n + 1][sum_v],
                                       dp[n][before_v] + w);
            }
            dp[n + 1][sum_v] = min(dp[n + 1][sum_v],
                                   dp[n][sum_v]);
            // cout << "n, sum_v, dp = " << n << ", " << sum_v << ", " << dp[n + 1][sum_v] << endl;
        }
    }

    ll ans = 0;
    REP(sum_v, 1e5 + 1) {
        if (dp[N][sum_v] != INF) {
            ans = max(ans, (ll)sum_v);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 80256
#!/usr/bin/env python3
import sys
import itertools
import collections
import functools
import math
from queue import Queue
# import numpy as np
INF = float("inf")


def yes():
    print("Yes")  # type: str


def no():
    print("No")  # type: str


def solve(N: int):
    for i in range(26):
        for j in range(15):
            if i*4+j*7 == N:
                yes()
                return
    no()

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4064
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });

            var H = Sarray()[0];
            var ans = 0L;
            for (var i = 0; H != 0; ++i)
            {
                ans += (long)Pow((double)2, (double)i);
                H = H / 2;
            }
            WriteLine(ans);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
ll dp[400][400];
ll a[400];
ll s[400];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> a[i];
	fill((ll*)dp, (ll*)(dp + 400), 1LL << 60);
	for (int i = 0; i < N; i++) dp[i][i] = 0;
	for (int i = 0; i < N; i++) s[i] = a[i];
	for (int i = 1; i < N; i++) s[i] += s[i - 1];
	for (int len = 2; len <= N; len++) {
		for (int i = 0; i + len <= N; i++) {
			ll t = s[i + len - 1];
			if (i > 0) t -= s[i - 1];
			for (int j = i; j + 1 < i + len; j++) {
				dp[i][i + len - 1] = min(dp[i][i + len - 1], dp[i][j] + dp[j + 1][i + len - 1] + t);
			}
		}
	}
	cout << dp[0][N - 1] << endl;
}

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

int main(){
    int n,m,l;
    cin >> n >> m >> l;
    vector<vector<int>> A(n, vector<int>(m)), B(m, vector<int>(l));
    for(int i=0; i<A.size(); i++){
        for(int j=0; j<A.at(0).size(); j++){
            cin >> A.at(i).at(j);
        }
    }
    for(int i=0; i<B.size(); i++){
        for(int j=0; j<B.at(0).size(); j++){
            cin >> B.at(i).at(j);
        }
    }
    vector<vector<int64_t>> C(n, vector<int64_t>(l));
    for(int i=0; i<C.size(); i++){
        for(int j=0; j<C.at(0).size(); j++){
            for(int k=0; k<A.at(0).size(); k++){
                C.at(i).at(j)+=A.at(i).at(k)*B.at(k).at(j);
            }
            cout << C.at(i).at(j);
            if(j < C.at(0).size()-1) cout << " ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3276
n, x = map(int, input().split())
if x == 1 or x == n * 2 - 1:
    print('No')
else:
    print('Yes')
    ans = [0] * (n * 2 - 1)
    used = [False] * (n * 2)
    mid = n - 1
    ans[mid] = x
    used[x] = True
    if x == 2:
        ans[mid - 1] = 3
        ans[mid + 1] = 1
        used[1] = used[3] = True
    else:
        ans[mid - 1] = 1
        ans[mid + 1] = n * 2 - 1
        ans[mid + 2] = 2
        used[1] = used[2] = used[n * 2 - 1] = True

    num = 1
    for i in range(n * 2 - 1):
        while num < n * 2 and used[num]:
            num += 1
        if ans[i] == 0:
            ans[i] = num
            used[num] = True

    print(*ans)


Measured memory_bytes: 20088
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

ll gcd(ll a,ll b) { return b ? gcd(b, a%b) : a; }

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using graph = vector<vector<ll>>;
pair<pair<ll,ll>,ll> p[100010];

vec<ll> dp;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    
    if(s[0]=='0') dp.pb(0);
    ll count=1;
    rrep(i,s.size()-1){
        if(s[i]==s[i-1]) count++;
        else{
            dp.pb(count);
            count=1;
        }
    }
    dp.pb(count);
    if(s.back()=='0') dp.pb(0);
    
    vec<ll> sum(dp.size()+1,0);
    rep(i,dp.size()) sum[i+1]=sum[i]+dp[i];
    
    ll res = 0;
    for (ll left=0; left<sum.size(); left+=2) {
        ll right = left + 2*k+1;
        if (right >= sum.size()) right=(ll)sum.size()-1;
        res = max(res, sum[right]-sum[left]);
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 2116
n,k=map(int,input().split())
ans=0
for i in range(1,min(n+1,k)):
    for j in range(20):
        if i*(2**j)>=k:
            ans+=(1/n)*0.5**j
            break
if n>=k:
    ans+=(n-k+1)/n
print(ans)


Measured memory_bytes: 39024
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 998244353

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	ll N, K; cin >> N >> K;
	vector<ll> a(N);
	for (int i = 0; i < N; i++)
		cin >> a[i];	
	if (N <= K) {
		for (int i = 0; i < N; i++) {
			cout << N<<" ";
		}
		cout << endl;
	}
	else {
		for (int i = 0; i < min(K,(ll)100); i++) {
			vector<ll> im(N);
			for (int j = 0; j < N; j++) {
				im[max((ll)0, j - a[j])]++;
				if (j + a[j] + 1 < N) im[j + a[j] + 1]--;
			}
			ll temp = 0;
			for (int k = 0; k < N; k++) {
				//cout << im[k] << endl;
				temp += im[k];
				a[k] = temp;
			}
		}
		for (int i = 0; i < N; i++)
			cout << min(N,a[i]) << " ";
		cout << endl;
	}
}

Measured memory_bytes: 6348
#include<bits/stdc++.h>
using namespace std;
int n,k,ar[100005];
bool f(int a){
	return a>=k;
}
int main(){
	cin>>n>>k;
  	for(int i=1;i<=n;i++){
    	cin>>ar[i];
    }
  	cout<<count_if(ar+1,ar+n+1,f);
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"math"
	"os"
)

type IOTp struct {
	iBuffer []byte
	iPos int
}
func (this *IOTp) GetChar() byte {
	res:=this.iBuffer[this.iPos]
	this.iPos++
	return res
}
func (this *IOTp) ReadInt() int {
	res:=0
	k:=1
	for ch:=this.iBuffer[this.iPos]; !(ch>='0' && ch<='9'); ch=this.iBuffer[this.iPos]{
		if ch=='-' {
			k=-1
		}
		this.iPos++
	}
	for ch:=this.iBuffer[this.iPos]; ch>='0' && ch<='9'; ch=this.iBuffer[this.iPos]{
		res=res*10+int(ch-'0')
		this.iPos++
	}
	res*=k
	return res
}
func NewIOTp() *IOTp {
	now:=new(IOTp)
	//inputFile,_:=os.Open("in.txt")
	inputFile:=os.Stdin
	now.iBuffer,_=ioutil.ReadAll(inputFile)
	now.iBuffer=append(now.iBuffer, '\n')
	now.iPos=0
	return now
}
var cin *bufio.Reader
var cout *bufio.Writer
func min(a,b int) int {
	if a<=b {
		return a
	} else {
		return b
	}
}
func max(a,b int) int {
	if a>=b {
		return a
	} else {
		return b
	}
}
func gcd(a,b int) int {
	for b!=0 {
		a,b=b,a%b
	}
	return a
}
func abs(x int) int {
	if x>=0 {
		return x
	} else {
		return -x
	}
}
func main() {
	IO:=NewIOTp()
	cout=bufio.NewWriter(os.Stdout)
	n,m:=IO.ReadInt(),IO.ReadInt()
	const MAXN=300
	var a [MAXN+10][MAXN+10]int
	for i:=1; i<=n; i++ {
		for j:=1; j<=m; j++ {
			a[i][j]=IO.ReadInt()
		}
	}
	var b [MAXN+10]bool
	var c [MAXN+10]int
	ans:=math.MaxInt64
	for i:=range b {
		b[i]=true
	}
	for i:=1; i<=m; i++ {
		for j:=range c{
			c[j]=0
		}
		for j:=1; j<=n; j++ {
			for k:=1; k<=m; k++ {
				if b[a[j][k]] {
					c[a[j][k]]++
					break
				}
			}
		}
		mx:=0
		for j:=1; j<=m; j++ {
			if c[j]>c[mx] {
				mx=j
			}
		}
		ans=min(ans,c[mx])
		b[mx]=false
	}
	fmt.Println(ans)
	cout.Flush()
}


Measured memory_bytes: 2432