akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
int n;
int a[100005];
int b[100005];
int cnt,cnt2,cnt0;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		b[i]=a[i]%4;
		if (b[i]==0){
			cnt0++;
		}
		else if (b[i]==2){
			cnt2++;
		}
		else{
			cnt++;
		}
	}
	if (cnt2==0){
		if (cnt<=cnt0+1){
			cout<<"Yes";
		}
		else{
			cout<<"No";
		}
	}
	else{
		if (cnt<=cnt0){
			cout<<"Yes";
		}
		else{
			cout<<"No";
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int d,n;
  cin>>d>>n;
  if(d==0&&n<100){cout<<n;}
  else if(d==0&&n==100){cout<<101;}
  else if(d==1&&n==100){cout<<10100;}
  else if(d==1&&n<100){cout<<n*100;}
  else if(d==2&&n==100){cout<<1010000;}
  else{cout<<10000*n;}
}

Measured memory_bytes: 256
class Dice
  def dice_s(s)
    s[0],s[1],s[4],s[5] = s[4],s[0],s[5],s[1]
    return s
  end

  def dice_e(s)
    s[0],s[2],s[3],s[5] = s[3],s[0],s[5],s[2]
    return s
  end

  def dice_w(s)
    s[0],s[2],s[3],s[5] = s[2],s[5],s[0],s[3]
    return s
  end

  def dice_n(s)
    s[0],s[1],s[4],s[5] = s[1],s[5],s[0],s[4]
    return s
  end

  def dice_b(s)
    s[0],s[1],s[4],s[5] = s[5],s[4],s[1],s[0]
    return s
  end

  def dice_sp(s)
    s[1],s[2],s[4],s[3] = s[2],s[4],s[3],s[1]
    return s
  end
end

f  = gets.split.map(&:to_i)
s = gets.split.map(&:to_i)
dice = Dice.new()

case f[0]
when s[4]; dice.dice_s(s)
when s[3]; dice.dice_e(s)
when s[2]; dice.dice_w(s)
when s[1]; dice.dice_n(s)
when s[5]; dice.dice_b(s)
end

while f[1] != s[1]
  dice.dice_sp(s)
end

puts f == s ? "Yes" : "No"

Measured memory_bytes: 8612
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    string s;
    cin >> s;
    cout << s.substr(0, 3) << '\n';
    return 0;
}

Measured memory_bytes: 3596
import sys,os
from collections import defaultdict, deque
from math import ceil, floor
if sys.version_info[1] >= 5:
    from math import gcd
else:
    from fractions import gcd
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7

    N = II()
    robots = [0]*N
    for i in range(N):
        x, l = map(int,input().split())
        left = x-l
        right = x+l
        robots[i]=(right,left)
    robots.sort()
    dbg(robots)
    prev_right = robots[0][0]

    ans = 1
    for i in range(1,N):
        if prev_right <= robots[i][1]:
            prev_right = robots[i][0]
            ans += 1
    print(ans)



    

if __name__ == '__main__':
    main()

Measured memory_bytes: 72088
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = 2**40

dp = [0, 0]

flag = True
while b>0:
    dp2 = dp[:]
    c = 0
    d = 0
    for i in a:
        if (i & b) == 0:
            c += 1
        else:
            d += 1
    if (k & b) == 0:
        if not flag:
            dp[0] = dp2[0]+max(c, d) * b
            dp[1] += d * b
        else:
            dp[1] += d * b
    else:
        if not flag:
            dp[0] = max(dp2[0]+max(c, d) * b, dp2[1]+d * b)
            dp[1] += c * b
        else:
            dp[0] += d*b
            dp[1] += c * b
            flag = False
        
    b //= 2

print(max(dp))


Measured memory_bytes: 69136
program Project1;

    {$APPTYPE CONSOLE}

    uses
      SysUtils,math;
    var
      a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k:Integer;
      l:array of Integer;
      s,s123,s1,s2,s3:string;
      al:string = 'abcdefghijklmnopqrstuvwxyz';
      tf,tfl,tfr:Boolean;
    begin
      try
        { TODO -oUser -cConsole メイン : ここにコードを記述してください }

        Read(a);
        Readln(b);


        if b<>100 then
          Writeln(Trunc(power(100,a)*b))
        else
          Writeln(Trunc(power(100,a)*(b+1)));
        Readln;
      except
        on E: Exception do
          Writeln(E.ClassName, ': ', E.Message);
      end;
    end.

Measured memory_bytes: 128
import math

n = int(input())

def f(a, b):
    c = len(str(a))
    d = len(str(b))
    return c if c > d else d

ans = n
lim = math.floor(math.sqrt(n))

for i in range(1, lim + 1):
    if n % i == 0:
        temp = f(i, n // i)
        if temp < ans:
            ans = temp
    
print(ans)


Measured memory_bytes: 3060
#include<stdio.h>
  #include<string.h>
  #define p_x 100
  #define p_y 100
  int high[200][200];
  int deme[200][200];
  char* dtable[7][7]={{"none","none","none","none","none","none","none"},
       {"none","none","2354","3542","4235","5423","none"},
       {"none","1463","none","3146","4631","none","6314"},
       {"none","1265","2651","none","none","5126","6512"},
       {"none","1562","2156","none","none","5621","6215"},
       {"none","1364","none","3641","4136","none","6413"},
       {"none","none","2453","3245","4532","5324","none"}};
  int vector[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
       
  int judgefunc(char* a,char* b){
   return (*b)-(*a);
  }
  char selectway(int top,int front,int num){//num番目に大きな数の位置を返す
   char* i;
   char buf[5];
   strcpy(buf,dtable[top][front]);
   qsort(buf,4,sizeof(char),judgefunc);
  // puts(dtable[top][front]);
   i=strchr(dtable[top][front],buf[num-1]);
   return i-dtable[top][front];
  }
  int checkroll(int nx,int ny,int way){//nx,nyの位置からway方向へ落とせるかいなか
   return (high[nx][ny]>high[nx+vector[way][0]][ny+vector[way][1]]);
  }
  
  int diceroll(int top,int front,int px,int py){
  
   int i;
   int flag=0;
   for(i=1;i<5;i++){//i番目に大きな面へ転がせるかチェック]
    int way=selectway(top,front,i);
    if(dtable[top][front][way]>='4'&&checkroll(px,py,way)){
     //転がせる時
     flag=1;
    // printf("%d to turn\n",way);
     //次のtopとfrontを決める
     int ntop=7-(dtable[top][front][way]-'0');
     int nfront;
     if(way==0){
      nfront=top;
     }
     else if(way==2){
      nfront=7-top;
     }
     else {
      nfront=front;
     }   
     diceroll(ntop,nfront,px+vector[way][0],py+vector[way][1]);
     return 0;
     break;
    }
   }
   //もうころがれない
   
   if(flag==0){
    //puts("high++");
    high[px][py]++;
    deme[px][py]=top;
   }
   return 0;
  }
  int main(){
   int n;
   int i,j,k;
   int top,front;
   int ans[6];
   while(1){
    scanf("%d",&n);
    if(n==0)
     break;
    for(i=0;i<6;i++){//初期化
     ans[i]=0;
    }
    for(i=0;i<200;i++){
     for(j=0;j<200;j++){
      high[i][j]=0;
      deme[i][j]=0;
     }
    }
    for(i=0;i<n;i++){//入力
     scanf("%d %d",&top,&front);
     diceroll(top,front,p_x,p_y);
    }
    for(i=0;i<200;i++){
     for(j=0;j<200;j++){//答えを算出
      if(1<=deme[i][j]&&deme[i][j]<=6){
       ans[deme[i][j]-1]++;
      }
     }
    }
    printf("%d %d %d %d %d %d\n",ans[0],ans[1],ans[2],ans[3],ans[4],ans[5]);
   }
  
   return 0;
  }

Measured memory_bytes: 0
from collections import UserList
class Stack(UserList):
    def __init__(self):
        UserList.__init__(self)
        self.contains = set()
    def __contains__(self, x):
        return x in self.contains
    def __and__(self, x):
        return self.contains & x
    def push(self, x):
        if x in self.contains:
            return
        self.data.append(x)
        self.contains |= {x}
    def pop(self):
        x = self.data.pop()
        self.contains -= {x}
        return x

def search(g, g_dash,v):
    # search postorder
    visited = set()
    postorder = []
    for root in range(v):
        if root in visited:
            continue
        route = Stack()
        route.push(None)
        dfs_stack = [(root, None)]            
        while dfs_stack:
            u, prev = dfs_stack.pop()
            if u in visited:
                continue
            visited |= {u}
            dfs_stack.extend((v, u) for v in g[u] - visited)
            while route[-1] != prev:
                postorder.append(route.pop())
            route.push(u)
        while route[-1] is not None:
            postorder.append(route.pop())

    # reverse search lowest
    visited.clear()
    lowest = [None] * v
    for root in postorder[::-1]:
        if root in visited:
            continue
        dfs_stack = [root]
        while dfs_stack:
            u = dfs_stack.pop()
            if u in visited:
                continue
            visited |= {u}
            lowest[u] = root
            dfs_stack.extend(g_dash[u] - visited)
    return lowest

from sys import stdin
from collections import defaultdict
readline = stdin.readline

def main():
    v, e = map(int, readline().split())
    g = defaultdict(set)
    g_dash = defaultdict(set)

    for _ in range(e):
        s, t = map(int, readline().split())
        g[s] |= {t}        
        g_dash[t] |= {s}        
    
    lowest = search(g,g_dash, v)
    q = int(readline())
    for u, v in [map(int, readline().split()) for _ in range(q)]:
        print(1 if lowest[u] == lowest[v] else 0)
main()

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

int main()
{
    int N;
    cin >> N;
    vector<int> v(N);
    for (int i = 0; i < N; i++) {
        cin >> v.at(i);
    }

    // 大きい順にstackにpush
    // 小さい順に取り出される
    sort(v.begin(), v.end(), greater<int>());
    stack<double> s;
    for (auto x : v) {
        s.push((double)x);
    }

    while (s.size() > 1) {
        double a = s.top();
        s.pop();
        double b = s.top();
        s.pop();
        s.push((a + b) / 2);
    }

    double ans = s.top();
    cout << setprecision(16) << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
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; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    for (ll i = 1;i<=N;i++) {
        if (((i%3) != 0) && ((i%5 != 0))) {
            ans += i;
        }
    }
    cout << ans << endl;

}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

int main() {
    int n;cin>>n;
    vector<char>c(n);
    rep(i,n){
        cin>>c[i];
    }

    int cnt=1;
    rep2(i,1,n){
        if(c[i]!=c[i-1]){
            cnt++;
        }
    }
    cout<<cnt<<endl;
}



Measured memory_bytes: 384
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

int m, d;

int main(){
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> m >> d;

    int ans = 0;
    for(int mi = 1; mi <= m; mi++) for(int di = 1; di <= d; di++) {
        if (di >= 20 && di % 10 >= 2 && (di / 10) * (di % 10) == mi) ans++;
    }

    cout << ans << '\n';

    return 0;
}



Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 H, W;
  cin >> H >> W;
  vector<string> a(H);
  for (i64 i = 0; i < H; i++)
    cin >> a[i];
  vector<i64> cnt(26);
  for (i64 i = 0; i < H; i++)
    for (i64 j = 0; j < W; j++)
      cnt[a[i][j] - 'a']++;
  i64 t = 0;
  for (i64 i = 0; i < 26; i++)
    if (cnt[i] % 2 == 1)
      t++;
  if (1 < t)
  {
    cout << "No" << endl;
    return 0;
  }
  i64 tc = 0;
  for (i64 i = 0; i < 26; i++)
  {
    if (cnt[i] % 2 == 1)
      cnt[i]--;
    tc += cnt[i] / 4;
  }
  if ((H / 2) * (W / 2) <= tc)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
//BEGIN CUT HERE
struct RUP{
  int n;
  vector<int> dat,laz;
  const int def=INT_MAX;
  RUP(){}
  RUP(int n_){init(n_);}
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(2*n-1,def);
    laz.clear();
    laz.resize(2*n-1,-1);
  }
  inline void eval(int len,int k){
    if(laz[k]<0) return;
    if(k*2+1<n*2-1){
      laz[k*2+1]=laz[k];
      laz[k*2+2]=laz[k];
    }
    dat[k]=laz[k];
    laz[k]=-1;
  }
  int update(int a,int b,int x,int k,int l,int r){
    eval(r-l,k);
    if(r<=a||b<=l) return dat[k];
    if(a<=l&&r<=b) return laz[k]=x;
    eval(r-l,k);
    dat[k]=min(update(a,b,x,k*2+1,l,(l+r)/2),
	       update(a,b,x,k*2+2,(l+r)/2,r));
    return dat[k];
  }
  int query(int a,int b,int k,int l,int r){
    eval(r-l,k);
    if(r<=a||b<=l) return def;
    if(a<=l&&r<=b) return dat[k];
    int vl=query(a,b,k*2+1,l,(l+r)/2);
    int vr=query(a,b,k*2+2,(l+r)/2,r);
    return min(vl,vr);
  }
  void update(int a,int b,int x){
    update(a,b,x,0,0,n);
  }
  int query(int a,int b){
    return query(a,b,0,0,n);
  }
};
//END CUT HERE
signed main(){
  int n,q;
  cin>>n>>q;
  RUP rup(n);
  for(int i=0;i<q;i++){
    int f;
    cin>>f;
    if(!f){
      int s,t,x;
      cin>>s>>t>>x;
      rup.update(s,t+1,x);
    }else{
      int s,t;
      cin>>s>>t;
      cout<<rup.query(s,t+1)<<endl;
    }
  }
  return 0;
}

/*
verified on 2017/07/12
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_D
*/

Measured memory_bytes: 7076
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	lli n;
	cin >> n;

	vector<lli> a(n);
	vector<bool> b(1e9 + 1,false);
	rep(i, 0, n) {
		cin >> a.at(i);
		if(b.at(a.at(i))) {
			ou("NO");
			return 0;
		}
		else 
			b.at(a.at(i))=true;
	}
	/*-
	rep(i, 0, n - 1) {
		rep(j, i + 1, n) {
			if(a.at(i) == a.at(j)) {

			}
		}
	}*/
	ou("YES");
}

Measured memory_bytes: 123904
#include<stdio.h> 
#include<iostream> 
#include<string.h>
#include<cstring>
#include<string>
#include<math.h>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#define cuttime ios::sync_with_stdio(false)
#define swap(x, y) x ^= y, y ^= x, x^= y
#define INF 0x3f3f3f3f
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dep(i,a,b) for(int i=(a);i>=(b);--i)
#define scan1(x) scanf("%d",&x)
#define scan2(x,y) scanf("%d%d",&x,&y)
#define scan3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define scanll1(x) scanf("%lld",&x)
#define scanll2(x,y) scanf("%lld%lld",&x,&y)
#define scanll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define lowbit(x) (x&(-x))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define debug(x) cout <<#x<<": "<<x<<endl
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N=1e6+10;
const int MAX=10000007;
inline ll read() {
    char c=getchar();ll x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0',c=getchar();}
    return x*f;
}
inline void out(ll x) {   
    if(x>9) out(x/10);   
    putchar(x%10+'0'); 
}
const int mod=1e9+7;
ll a[200005],b[200005];
ll s[400005];
ll sum1[N];
ll sum2[N];
int main(){
    
    ll n,m,k;
    int cnt=0;
    scanll3(n,m,k);
    rep(i,1,n){
        a[i]=read();
      
    }
    rep(i,1,m){
        b[i]=read();
    }
    rep(i,1,n){
        sum1[i]=sum1[i-1]+a[i];
    }
    rep(j,1,m){
        sum2[j]=sum2[j-1]+b[j];
    }

    int maxx=0;
    rep(i,1,n){
        if(sum1[i]<=k){
            ll c=k-sum1[i];
            int pos=upper_bound(sum2+1,sum2+1+m,c)-sum2;
            pos--;
            maxx=max(maxx,pos+i);
        }
    }
    rep(i,1,m){
        if(sum2[i]<=k){
            ll c=k-sum2[i];
            int pos=upper_bound(sum1+1,sum1+1+n,c)-sum1;
            pos--;
            maxx=max(maxx,pos+i);
        }
    }
    out(maxx);
    return 0;
}

Measured memory_bytes: 9904
#include <iostream>
#include <cmath>
#include <map>
#include <utility>
#include <list>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

void print_vector(vector<int> v) {
    for (int i=0; i < v.size(); i++){
        cout << v[i] << endl;
    }
}

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

    vector<int> t;

    for (int i=0; i < n; i++){
        int a;
        cin >> a;
        t.push_back(a);
    }

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

    int min = 1000000000;
    for (int i=0; i < n - k + 1; i++){
        if (abs(t[i] - t[i + k - 1]) < min) {
            min = abs(t[i] - t[i + k - 1]);
        }
    }

    cout << min << endl;
    //print_vector(t);

    return 0;
}

Measured memory_bytes: 892
#テストファイルで実行する時
import sys
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')

n = int(input())
d,x = map(int,input().split())
a=[int(input()) for i in range(n)]

choco = x

for i in range(n):
	j = 0
	while a[i]*j+1 <= d:
		#print(j,a[i]*j+1)
		j = j + 1
		choco = choco + 1

print(choco)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define all(x) x.begin(), x.end()

using namespace std;

const int N = 2e5 + 101;

int n, m, b, c;
int a[N], cnt[N], dl[N];
int ans;

void inc(int num) {
	dl[num]++;
	int id = num - dl[num];
	if (id >= 0 && !cnt[id]) ans--;
	if (id >= 0) cnt[id]++;
}

void dec(int num) {
	int id = num - dl[num];
	if (id >= 0 && cnt[id] == 1) ans++;
	if (id >= 0) cnt[id]--;
	dl[num]--;
}

int main() {
	scanf ("%d%d", &n, &m);
	ans = n;
	rep(i, 1, n) {
		scanf ("%d", a + i);
		inc(a[i]);
	}
	rep(i, 1, m) {
		scanf ("%d%d", &b, &c);
		dec(a[b]);
		a[b] = c;
		inc(a[b]);
		printf ("%d\n", ans);
	}
	
	return 0;
}	


Measured memory_bytes: 3712
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[] cities = new int[n+1];
        for (int i = 0; i < m; i++) {
            cities[scanner.nextInt()]++;
            cities[scanner.nextInt()]++;
        }
        for (int i = 1; i < n+1; i++) {
            System.out.println(cities[i]);
        }
    }
}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};

int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int ddx[]={1,1,1,0,-1,-1,-1,0},ddy[]={1,0,-1,-1,-1,0,1,1};

ll mypow(ll x,ll n,ll m) {	//xのn乗をmで割った余り
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

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

int sx,sy,gx,gy,n;
vector<P> v;
const int inf=1.1e8;

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

	cin>>sx>>sy>>gx>>gy>>n;
	int t=0;
	if(sx>gx) swap(sx,gx),swap(sy,gy);
	if(sy>gy){ t=1,sy=inf-sy;gy=inf-gy; }
	REP(i,n) {
		int x,y;cin>>x>>y;
		if(t) y=inf-y;
		if(x<sx||x>gx||y<sy||y>gy) continue;
		v.pb(P(x,y));
	}
	sort(ALL(v));

	int sz=v.size();
	int dp[sz+1];
	fill(dp,dp+sz+1,inf*2);
	REP(i,sz) {
		*lower_bound(dp,dp+sz+1,v[i].se)=v[i].se;
	}
	int num=lower_bound(dp,dp+sz+1,inf*2)-dp;
	double ans=((gx-sx)+(gy-sy))*100.-num*20.+num*20*PI/4;
	if(num==(gx-sx)+1||num==(gy-sy)+1) ans+=20*PI/4;
	printf("%.15lf\n",ans);

	return 0;
}


Measured memory_bytes: 2800
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int M = scan.nextInt();
        int p = power(2, N);
        int[] dp = new int[p];
        for (int i=0; i < p; i++) {
            dp[i] = 1_000_000_000;
        }
        dp[0] = 0;

        for (int i=0; i < M; i++) {
            int a = scan.nextInt();
            int b = scan.nextInt();
            int[] c_list = new int[b];
            for (int j=0;  j < b; j++) {
                c_list[j] = scan.nextInt();
            }
            int c=0;
            for (int item : c_list) {
                c += power(2, item-1);
            }
            for (int k=0; k < p; k++) {
                if (dp[k|c] > dp[k] + a) {
                    dp[k|c] = dp[k] + a;
                }
            }
        }
        if (dp[dp.length - 1] == 1_000_000_000) {
            System.out.println(-1); 
        } else {
            System.out.println(dp[dp.length - 1]); 
        }
    }

    public static int power(int n, int m) {
        int res = 1;
        if (m == 0) {
            return 1;
        } else {
            if (n == 0) {
                return 0;
            } else {
                for (int i=0; i < m; i++) {
                    res = res*n;
                }
                return res;
            }
        }
    }
}


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

# In[20]:


S = input()


# In[21]:


mylist = [x for x in S]
if mylist[0] != "A":
    print("WA")
elif mylist[2:-1].count("C") != 1:
    print("WA")
else:
    C_idx = mylist[2:-1].index("C") + 2
    mylist.pop(C_idx)
    if str("".join(mylist[1:])).islower():
        print("AC")
    else:
        print("WA")


# In[ ]:






Measured memory_bytes: 3060
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
SIZE=4*10**5+1; MOD=10**9+7 #998244353 #ここを変更する
 
SIZE += 1
inv = [0]*SIZE  # inv[j] = j^{-1} mod MOD
fac = [0]*SIZE  # fac[j] = j! mod MOD
finv = [0]*SIZE # finv[j] = (j!)^{-1} mod MOD
inv[1] = 1
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2,SIZE):
    inv[i] = MOD - (MOD//i)*inv[MOD%i]%MOD
    fac[i] = fac[i-1]*i%MOD
    finv[i]= finv[i-1]*inv[i]%MOD
 
def choose(n,r): # nCk mod MOD の計算
    if 0 <= r <= n:
        return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
    else:
        return 0
def resolve():
    n, k = lr()
    ans = choose(2*n-1, n)
    if n-1 > k:
        for i in range(1, n-k):
            ans -= choose(n, i)*choose(n-1, n-i)
            ans %= MOD
    print(ans)
resolve()

Measured memory_bytes: 50520
#include <stdio.h>
#define H 5000000
 
int n;
int s[H];
 
void maxHeapify(int);
void buildMaxHeap();
 
int main()
{
  int i;
 
  scanf("%d", &n);
 
  for(i=1;i<=n;i++){
    scanf("%d", &s[i]);
  }
 
  buildMaxHeap();
 
  for(i=1;i<=n;i++)
    printf(" %d", s[i]);
  printf("\n");
 
  return 0;
}
 
void buildMaxHeap()
{
  int i;
  
  for(i=n/2;i>0;i--)
    maxHeapify(i);
}
 
void maxHeapify(int i)
{
  int j, k, max, tmp;
   
  j = i*2;
  k = i*2+1;
  if(j<=n && s[j]>s[i])
    max = j;
  else max = i;
  if(k<=n && s[k]>s[max])
    max = k;
  if(max!=i){
    tmp = s[i];
    s[i] = s[max];
    s[max] = tmp;
    maxHeapify(max);
  }
}

Measured memory_bytes: 2552
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int count = 0;
    boolean con;
    
    for(int i = 0; i < n; i++) {
      if(sc.nextInt() >= k) count++;
    }
        
    System.out.println(count);
  }
}


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

int main() {
	int n;
	cin >> n;
	
	int minn = INT_MAX;
	int ans = 0;
	for(int i = 0; i < n; i++){
		int x; cin >> x;
		if(x <= minn){
			ans++;
			minn = x;
		}
	}
	
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;
#define fori(i,a,b) for(int i=(a);i<(int)(b);i++)
#define repi(i,n) fori(i,0,n)
#define forr(i,a,b) for(int i=int(b-1);i>=int(a);i--)
#define repr(i,n) forr(i,0,n)
#define all(x) (x).begin(),(x).end()
#define fill(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define mp make_pair
#define pcnt __builtin_popcount
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;}

void solve(){
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans=0;
    repi(i,n){
        int t;
        cin>>t;
        if(t<a||b<=t)ans++;
    }
    cout<<ans<<endl;
}

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


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

using namespace std;

//----------------------- Print Function ----------------------//

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

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

//--------------------------- Solve ---------------------------//

void solve() {
    int N, M; cin >> N >> M;
    int time = 1900 * M + 100 * (N - M);
    cout << time * (1<<M) << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
 
using namespace std;
using LL = long long;
 
int main(void)
{
  string s;
  cin >> s;
  LL n = s.size();
  vector<LL> cnt(128);
  for(auto c:s) ++cnt[c];
  for(auto &x:cnt) x=x*(x-1)/2;
  LL sum = accumulate(cnt.begin(),cnt.end(),0ll);
  cout << 1+n*(n-1)/2-sum << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main{
    int high;
    int low;
    int sa;
    int a;
    
    public void solve(){
        Scanner sc = new Scanner(System.in);
		
        while(a < 7){
            high = sc.nextInt();
            low = sc.nextInt();
		    sa = high - low;
			System.out.println(sa);
		    a++;
        }
       
    }
    public static void main(String[] args){
        Main obj = new Main();
        obj.solve();
    }
    
}

Measured memory_bytes: 17364
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define REP(i, n) for(int i=0; i<n; i++)
#define RER(i, n) for(int i=n-1; i>=0; i--)
#define ALL(v) v.begin() v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int n;

int dfs(string s){
	if(atoi(s.c_str()) > n || s.size() > 9) return 0;
	if(s.find('7') != std::string::npos && s.find('5') != std::string::npos && s.find('3') != std::string::npos)
		return dfs(s + '7') + dfs(s + '5') + dfs(s + '3') + 1;
	else return dfs(s + '7') + dfs(s + '5') + dfs(s + '3');
}

signed main(){
	cin >> n;
	cout << dfs(string("")) << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;



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

	ll n;
	cin >> n;
	int ans = INF;
	int e = sqrt(n) + 1;
	repr(i, 1, e) {
		if (n%i == 0) {
			int a = i;
			int b = n / i;
			string ta = to_string(a);
			string tb = to_string(b);
			int t = max(ta.size(), tb.size());
			ans = min(t, ans);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    double r1,r2;
    cin>>r1>>r2;
    cout<<1/(1/r1+1/r2)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
ll ans=0;
ll f(string& s,int l,int r)
{
	ll res=0;
	for(int i=l;i<r;i++)
		res=res*10+(s[i]-'0');
	return res;
}
int main()
{
	cin>>s;
	int n=s.length();
	for(int i=0;i<(1<<(n-1));i++)
	{
		vector<int> v;
		v.push_back(0); 
		for(int j=0;j<n;j++)
			if(1&(i>>j))
				v.push_back(j+1);
		v.push_back(n);
		for(int j=0;j+1<v.size();j++)
			ans+=f(s,v[j],v[j+1]);
	}
	cout<<ans<<endl;
	return 0;
}

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

vector<int> dp(100000, -1);
int minCost(vector<int> &stones,int k, int dest){  
  if(dp[dest] !=-1){
    return dp[dest];
  }
  if(dest == 0){
    dp[dest] = 0;
  }
  else if(dest < k){
    dp[dest] = abs(stones[dest] - stones[0]);
  }
  else{
     int ans = INT_MAX;
     for(int i=1;i<=k;i++){
      if(dp[dest-i] == -1){
        dp[dest-i] = minCost(stones,k, dest -i);
      }
      ans = min(abs(stones[dest] - stones[dest-i]) + dp[dest-i], ans);
    }
    dp[dest] = ans;
  }
 
  return dp[dest];	
}



int main(){
  int n,k;
  cin>>n>>k;
  vector<int> vec;
  for(int i=0;i<n;i++){
    int temp;
    cin>>temp;
    vec.push_back(temp);
  }
  cout<<minCost(vec, k,vec.size()-1)<<endl;
  
}

Measured memory_bytes: 12060
import java.util.Scanner;

public class Main{
    static StringBuilder sb = new StringBuilder();
    
    static void printCard(char c, int[] array){
        for(int i = 0; i < array.length; i++){
            if(array[i] == 0){
                sb.append(c + " " + (i + 1) + "\n");
            }
        }
    }
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int[] s = new int[13];
        int[] h = new int[13];
        int[] c = new int[13];
        int[] d = new int[13];
        
        for(int i = 0; i < num; i++){
            String simbol = sc.next();
            int cardNum = sc.nextInt();
            switch(simbol){
                case "S": s[cardNum - 1] = 1 ; break;
                case "H": h[cardNum - 1] = 1 ; break;
                case "C": c[cardNum - 1] = 1 ; break;
                case "D": d[cardNum - 1] = 1 ; break;
            }
        }
        
        printCard('S', s);
        printCard('H', h);
        printCard('C', c);
        printCard('D', d);
        
        System.out.print(sb);
        
    }
}


Measured memory_bytes: 26404
import sys

def main():
    N = int(input())
    Vs = list(map(int, input().split()))

    new_Vs = sorted(Vs)

    sol = new_Vs[0]
    for i in range(N-1):
        sol = (sol + new_Vs[i+1]) / 2

    print(sol)

main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int x,y,z,n,i,c;
long long s,sum,dp[100010],ma;
priority_queue<int,vector<int>,greater<int> >q;
pair<int,int>v[100010];
bool cmp(pair<int,int> a,pair<int,int> b)
{
    if(a.first-a.second<b.first-b.second)return false;
    else if (a.first-a.second==b.first-b.second)
        return (a.first>a.second);
    return true;
}
int main()
{
    // freopen("a.in","r",stdin);
    //  freopen("a.out","w",stdout);
    scanf("%d%d%d",&x,&y,&z);
    n=x+y+z;
    for(i=1; i<=n; ++i)
    {
        scanf("%d%d%d",&v[i].first,&v[i].second,&c);
        v[i].first-=c;
        v[i].second-=c;
        s+=c;
    }
    sort(v+1,v+n+1,cmp);
    for(i=n; i>=n-y+1; --i)
    {
        sum+=v[i].second;
        q.push(v[i].second);
    }
    dp[n-y+1]=sum;
    for(i=n-y; i>=1; --i)
    {
        if(v[i].second>q.top())
        {
            sum-=q.top();
            q.pop();
            q.push(v[i].second);
            sum+=v[i].second;
        }
        dp[i]=sum;
    }
    while(!q.empty())q.pop();
    sum=0;
    for(i=1; i<=x; ++i)
    {
        sum+=v[i].first;
        q.push(v[i].first);
    }
    ma=sum+dp[x+1];
    for(i=x+1; i<=n-y; ++i)
    {
        if(v[i].first>q.top())
        {
            sum-=q.top();
            q.pop();
            q.push(v[i].first);
            sum+=v[i].first;
        }
        ma=max(ma,sum+dp[i+1]);
    }
    printf("%lld\n",ma+s);
    return 0;
}


Measured memory_bytes: 2428
N = int(input())
A = [list(map(int, input().split())) for i in range(N)]

INF = 10 ** 9 + 1
for i in range(N):
    A[i][i] = INF

ans = 0
for i in range(N):
    Ai = A[i]
    for j in range(i):
        d = min(map(sum, zip(Ai, A[j])))

        if A[i][j] > d:
            print('-1')
            exit()
        elif A[i][j] < d:
            ans += A[i][j]

print(ans)


Measured memory_bytes: 6644
import java.util.Scanner;
//import java.util.stream.IntStream;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String tenki = sc.nextLine();
    if (tenki.equals("Sunny")) {
      System.out.println("Cloudy");
    } else if (tenki.equals("Cloudy")) {
      System.out.println("Rainy");
    } else if (tenki.equals("Rainy")) {
      System.out.println("Sunny");
    }
  }
}

Measured memory_bytes: 21204
#include<iostream>
#include<cstdio>
#include<algorithm>
#define N (100009)
#define MOD (1000000007);
using namespace std;
long long n,a,b,r,sum,s[N],f[N];
int main()
{
	scanf("%lld%lld%lld",&n,&a,&b);
	if (a>b) swap(a,b);
	for (int i=1; i<=n; ++i)
		scanf("%lld",&s[i]);
	for (int i=3; i<=n; ++i)
		if (s[i]-s[i-2]<a){puts("0"); return 0;}
	f[0]=1; s[0]=-b; sum=0; r=0;
	for (int i=1; i<=n; ++i)
	{
		while (r<i && s[i]-s[r]>=b) sum=(sum+f[r++])%MOD;
		f[i]=sum;
		if (s[i]-s[i-1]<a) sum=0, r=i-1;
	}
	for (int i=r; i<=n; ++i)
		sum=(sum+f[i])%MOD;
	printf("%lld\n",sum);
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
ll A,B;
  cin>>A>>B;
  ll ans=0;
  for(ll i=A;i<=B;i++) {
string S=to_string(i);
    if(S[0]==S[4]&&S[1]==S[3]) {
ans++;
    }
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
#define endl '\n'
using namespace std;
using ll = long long int;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using graph = vector<vi>;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const int MAXN = 112345;
int main() {
    ll n, m, k;
    scanf("%lld", &n);
    m = INFL;
    for (ll i = 0, x; i<5LL; ++i) {
        scanf("%lld", &x);
        m = min(m, x);
    }
    m = (n+m-1LL)/m;
    printf("%lld\n", 4LL+m);
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>

#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
#ifdef local
#define dbg(a) cout << #a": " << a << endl;
#else
#define dbg(a)
#endif // loacl


using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const ll inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-6;
const int mod=998244353;
const int maxn=1e6+10;
const int N=2e5+10;
const int M=N<<1;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll MOD)
{
    ll ans=1;
    while(b)
    {
        if(b&1) ans=(ans*a)%MOD;
        b>>=1;
        a=(a*a)%MOD;
    }
    return ans;
}

int nex[N][30],last[200],vis[100];
char s[N],t[N];
int main()
{
#ifdef local
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif // local
    IOS;
    cin>>(s+1)>>(t+1);
    int n=strlen(s+1),m=strlen(t+1);
    for(int i=0;i<=100;++i) last[i]=n+1;
    for(int i=n;i>=1;--i)
    {
        for(int j=0;j<26;++j) nex[i][j]=last[j];
        last[s[i]-'a']=i;
        vis[s[i]-'a']=1;
    }
    for(int i=0;i<26;++i) nex[0][i]=last[i];
    ll ans=0,pos=0;
    for(int i=1;i<=m;++i)
    {
        if(!vis[t[i]-'a']) {
            puts("-1");return 0;
        }
        if(nex[pos][t[i]-'a']==n+1)
        {
            ans-=pos;ans+=n;
            pos=0;
            ans+=nex[pos][t[i]-'a']-pos;
            pos=nex[pos][t[i]-'a'];
        }else{
            ans+=nex[pos][t[i]-'a']-pos;
            pos=nex[pos][t[i]-'a'];
        }

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


Measured memory_bytes: 12416
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i)<(N);i++)
#define MAX_N 3000

int main(){
    int N;
    cin >> N;
    vector<long double> P(N);
    rep(i,N) cin >> P[i];


    vector<vector<long double>> dp(MAX_N,vector<long double>(MAX_N,0));
    dp[0][0] = 1.0;
    for(int i=1;i<=N;i++){
        for(int j=0;j<=i;j++){
            dp[i][j] += dp[i-1][j]*(1.0-P[i-1]);
            if(j != 0) dp[i][j] += dp[i-1][j-1]*P[i-1];
        }
    }

    long double ans = 0.0;
    for(int i=N/2+1;i<=N;i++) ans += dp[N][i];
    cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 141056
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))


x,k,d = l_in()

if x < 0:
    x = -x

if x - k*d > 0:
    print(x-k*d)
    exit()

k = k - x//d
r = x%d

if k%2 == 0:
    print(r)
else:
    print(d-r)


Measured memory_bytes: 61352
import math
from itertools import permutations
def distance(a,b):
    return math.sqrt(abs(a[0]-b[0])**2 + abs(a[1]-b[1])**2)
N = int(input())
cords = []
for i in range(N):
    a,b = map(int, input().split())
    cords += [[a,b]]

d = [[0 for i in range(N)] for i in range(N)]
for i in range(N-1):
    for j in range(i+1,N):
        d[i][j] = d[j][i] = distance(cords[i],cords[j])

whole = math.factorial(N)
distance = 0
ps = permutations([i for i in range(N)])
for perm in ps:
    dis = 0
    # print(perm)
    for way in range(1,len(perm)):
        # print(d[way-1][way])
        dis += d[perm[way-1]][perm[way]]
    # print(dis)
    distance += dis / whole
print(distance)

Measured memory_bytes: 3064
#include <cassert>
#include <iostream>
#include <functional>
#include <iomanip>
#include <set>
#include <unordered_map>
#include <queue>
#include <vector>
#include <deque>
#include <algorithm>
#include  <cstring>
#include <string>
#include <cmath> 
using namespace std;
typedef long long LL;
const int MAX = 110000;
const LL base = 1e9 + 7;


struct Node {
	int x, y, w;
};

LL dp[MAX];
LL acc[MAX];
void solve() {

	LL result = 0;
	int n,k;

	cin >> n>>k;
	dp[0] = 1;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		fill(acc, acc + MAX, 0);
		for (int j = 1; j <= k + 1; ++j) {
			acc[j] = acc[j - 1] + dp[j - 1];
		}
		dp[0] = 1;
		for (int j = 1; j <= k; ++j) {
			int t = j - a ;
			if (t < 0) t = 0;
			dp[j] = acc[j + 1] - acc[t];
			dp[j] %= base;
		}
	}
	result = dp[k];
	cout << result << endl;

}

int main() {
	const int inId = 0;
	const int outId = 0;
	if (inId>0) {
		cerr << "redirect stdin to input " << inId << endl;
		string s = "input";
		s += to_string(inId);
		s += ".txt";
		auto r = freopen(s.c_str(), "r", stdin);	
		if (r == nullptr) {
			cerr<< "invalid input file "<< s;
		}
	}
	if (outId>0) {
		cerr << "redirect stdout to stdout " << outId << endl;
		string s = "stdout";
		s += to_string(outId);
		s += ".txt";
		auto r = freopen(s.c_str(), "w", stdout);
		if (r == nullptr) {
			cerr<< "invalid output file "<< s;
		}		
	}
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // close sync between cout and printf
	cout.precision(10);
	solve();
}
 

Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

ll ans;

int main(void) {
    ll a;
    string b;
    cin >> a >> b;
    b.erase(1, 1);
    ll bb = stoll(b);
    
    ans = a*bb;
    ans /= 100;


  
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3628