akhauriyash/Code-Regression huggingface dataset:
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = InputNum();
            var a = InputNumList();
            a.Add(0);
            var h = Enumerable.Repeat(0, n + 1).ToList();
            var flag = false;
            var indexStr = 0; var indexEnd = 0; var ans = 0;

            for (int i = 0; i < a.Max(); i++)
            {
                for (int j = 0; j < n+1; j++)
                {
                    if(h[j]<a[j] &&flag == false)
                    {
                        flag = true;
                        indexStr = j;
                    }
                    else if(h[j]==a[j]&&flag == true)
                    {
                        flag = false;
                        indexEnd = j;
                        for (int k = indexStr; k < indexEnd; k++) h[k]++;
                        ans++;
                    }
                }
            }
            WriteLine(ans);
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}



Measured memory_bytes: 13396
N = int(input())
word = []
flag = True
word.append(input())
for _ in range(N - 1):
    w = input()
    if w in word:
        flag = False
    elif word[-1][-1] != w[0]:
        flag = False
    else:
        word.append(w)

if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;
typedef long long  ll;
typedef long double ld;
typedef pair<ll,ll> pp;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> super_set;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> multi_set;
#define x1 dfds
#define y1 dsfdsfe
#define pb push_back
#define forn(i,n) for(ll i = 1;i<=n;++i)
#define fi first
#define sc second
#define endl '\n'
#define po(x) (1ll<<x)
const ll DIM = 2E5+7;
const ll MOD = 1E9+7;
vector<ll> G[DIM];
ll ans[DIM],sz[DIM],met[DIM],fact[DIM],n;
ll binpow(ll x,ll power){
    ll mult = x;
    x = 1;
    while(power>0){
        if (power&1)x = (x*mult)%MOD;
        mult = (mult*mult)%MOD;
        power/=2;
    }
    return x;
}
ll rev(ll x){
    x%=MOD;
    return binpow(x,MOD-2);
}
void prep(ll v,ll par){
    met[v] = 1;
    for(ll to:G[v]){
        if (to==par)continue;
        prep(to,v);
        sz[v]+=sz[to];
        met[v] = (met[v]*met[to])%MOD;
        met[v] = ((fact[sz[v]]*rev(fact[sz[to]]*fact[sz[v]-sz[to]]))%MOD*met[v])%MOD;
    }
    sz[v]++;
}
void dfs(ll v,ll par){
    sz[v] = 0;
    met[v] = 1;
    met[v] = met[par];
    sz[v] = sz[par];
    for(ll to:G[v]){
        if (to==par)continue;
        sz[v]+=sz[to];
        met[v] = (met[v]*met[to])%MOD;
        met[v] = ((fact[sz[v]]*rev(fact[sz[to]]*fact[sz[v]-sz[to]]))%MOD*met[v])%MOD;
    }
    sz[v]++;
    ans[v] = met[v];
    for(ll to:G[v]){
        if (to==par)continue;
        ll om = met[v];
        ll osz = sz[v];
        met[v] = (met[v]*rev(met[to]))%MOD;
        sz[v]--;
        //cout<<(rev((fact[sz[v]]*rev(fact[sz[to]]*fact[sz[v]-sz[to]]))%MOD)*met[v])%MOD
        met[v] = (rev(fact[sz[v]]*rev(fact[sz[to]]*fact[sz[v]-sz[to]]))*met[v])%MOD;
        sz[v]-=sz[to];
        sz[v]++;
        dfs(to,v);
        sz[v] = osz;
        met[v] = om;
    }
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin>>n;
    forn(i,n-1){
        ll x,y;
        cin>>x>>y;
        G[x].pb(y);
        G[y].pb(x);
    }
    fact[0] = 1;
    forn(i,n)fact[i] = (fact[i-1]*i)%MOD;
    prep(1,1);
    dfs(1,1);
    forn(i,n)cout<<ans[i]<<endl;
    return 0;
}



Measured memory_bytes: 20976
#include<bits/stdc++.h>
#define INF 0x7fffffff
using namespace std;
typedef long long ll;
string s;
int w,len;
int main()
{
    cin>>s>>w;
    len=s.size();
    for(int i=0;i<len;i+=w)
        printf("%c",s[i]);
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=set()
b=[]
import collections
for i in range(n):
    s=input()
    s=sorted(s)
    a.add("".join(s))
    b.append("".join(s))
ans=0
a=list(a)
c=collections.Counter(b)
for i in range(len(a)):
    ans+=c[a[i]]*(c[a[i]]-1)//2
print(ans)

Measured memory_bytes: 29856
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    long long int a,b,c,n,ans;
    ans = 0;
    cin >> n;
    int p[n];
    for(int i=0;i<n;i++)cin >> p[i];
    for(int i=0;i<n-2;i++){
        int s[3] = {p[i],p[i+1],p[i+2]};
        sort(s,s+3);
        if(p[i+1]==s[1])ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int main(){
    int n,m=0,k;
    scanf("%d",&n);
    while(m*(m+1)/2<n)m++;
    k=m*(m+1)/2-n;
    for(int i=1;i<k;i++)printf("%d\n",i);
    for(int i=k+1;i<=m;i++)printf("%d\n",i);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#define M 103
#define Min 1000000000
void Matrix_Chain_Order(int p[],int n);
int main()
{
    int n;
    while(scanf("%d",&n) == 1){
        int p[M];
        memset(p,'0',M);
        int i;
        for(i = 0;i < n;i++)
            scanf("%d%d",&p[i],&p[i+1]);
        Matrix_Chain_Order(p,n);
    }

    return 0;
}

void Matrix_Chain_Order(int p[],int n)
{
    int m[n+1][n+1],s[n+1][n+1];
    //边界条件
    int i,j;
    for(i = 1;i <= n;i++)
        m[i][i] = 0;
    //计算每个子问题m[i,j]的解
    int l;
    for(l = 2;l <= n;l++){
        for(i = 1;i <= n-l+1;i++){
            j = i + l - 1;
            m[i][j] = Min;
            int k;
            for(k = i;k <= j-1;k++){
                int val;
                val = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
                if(m[i][j] > val){
                    m[i][j] = val;
                    s[i][j] = k;
                }
            }
        }
    }
    printf("%d\n",m[1][n]);
}



Measured memory_bytes: 2060
import sys
r,D,x = map(int,input().split())

if not ( 2 <= r <= 5 ): sys.exit()
if not ( 1 <= D <= 100 ): sys.exit()
if not ( D < x <= 200 ): sys.exit()

before_x = x
for I in range(10):
    print( r * before_x - D)
    before_x = r * before_x - D

Measured memory_bytes: 9192
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;


/** ワーシャル・フロイド法による全点対最短路探索

    経路を逐次最小化していく。

    頂点番号は0オリジン。

    知らないパスにはコスト大きめを設定しておくこと。
    その初期コストはすべての都市を回ってくるパスよりも大きくすべし。
    ただ、内部で加算するのでオーバーフローに注意。MAXダメ、絶対。
    std::fill(mat.data(), mat.data() + mat.num_elements(), MAXCOST+1);

    O(|V|^3)

    @note 反対方向もいれた？
    mat[a][b] = mat[b][a] = c;

    @note 自分自身へのルートはコスト0か？
    for (int i = 0; i < N; ++i) {
    mat[i][i] = 0;
    }

    @param[in] V  頂点数
    @param[in, out] distance[i][j]: 頂点i -> jのコスト
*/
template<typename T, typename M>
void warshall_floyd(T V, M& distance)
{
    for (T k = 0; k < V; ++k) {
        for (T i = 0; i < V; ++i) {
            for (T j = 0; j < V; ++j) {
                distance[i][j] = std::min(distance[i][j],
                                          distance[i][k] + distance[k][j]);
            }
        }
    }
}


int main()
{
    int64_t N, M;
    std::cin >> N >> M;

    boost::multi_array<int64_t, 2> mat(boost::extents[N][N]);

    std::fill(mat.data(), mat.data() + mat.num_elements(), 100*1000 +1);

    struct Path {
        int64_t a;
        int64_t b;
        int64_t c;
    };

    std::vector<Path> P;
    for (decltype(M) i = 0; i < M; ++i) {
        int64_t a, b, c;
        std::cin >> a >> b >> c;
        a--;
        b--;
        P.push_back({a, b, c});

        mat[a][b] = mat[b][a] = c;
    }

    for (int64_t i = 0; i < N; ++i) {
        mat[i][i] = 0;
    }

    warshall_floyd(N, mat);

    int64_t count = 0;
    for (auto p : P) {
        bool isRequired = false;
        for (int64_t A = 0; A < N; ++A) {
            for (int64_t B = 0; B < N; ++B) {
                auto d = mat[A][B];
                auto dd = mat[A][p.a] + p.c + mat[p.b][B];
                if (d == dd) {
                    isRequired = true;
                    break;
                }
            }
        }
        if (!isRequired) {
            count++;
        }
    }

    std::cout << count << std::endl;

    return 0;
}


Measured memory_bytes: 384
// ================
// Himanshu Lal
// MNIT Jaipur
// ================
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define TEZ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rf(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define INF 1e18
#define vi vector<pair<ll,ll>>
#define ff first
#define ss second
#define mp map<ll,ll>
#define test ll tp; cin>>tp; while(tp--)
#define srt(v) sort(v.begin(),v.end())
double pi=acos(-1);
void OJ(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif
}
int main(){
    ll a[6];
    f(i,1,6)
        cin>>a[i];
    f(i,1,6){
        if(a[i]==0){
            cout<<i;
        }
    }
}

Measured memory_bytes: 3592
A, B, C, K = (int(x) for x in input().split())

if A >= K:
  print(K)
elif A < K <= A + B:
  print(A)
elif A + B <= K < A + B + C:
  print(A-(K-A-B))
elif A + B + C <= K:
  print(A-C)
  


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

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

int popcnt(int x){
    return __builtin_popcount(x);
}

int f(int x){
    if (x == 0) return 0;
    return f(x%popcnt(x))+1;
}

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> x(n);
    rep(i,n) x[i] = s[i] - '0';

    int pCnt = 0;
    rep(i,n) pCnt += x[i];
    vector<int> ans(n);
    rep(b, 2){
        // 探索するビットの値によってpopcountを変更
        int pc = pCnt;
        if (b == 0) pc++;   // 0→1なのでpopcountを+1
        else pc--;          // 1→0なのでpopcountを-1
        if (pc <= 0) continue;

        // popcountでの余りを計算
        int r0 = 0;
        rep(i,n){
            r0 = (r0*2)%pc;
            r0 += x[i];
        }

        // 探索ビットと一致したらその値を加算 or 減算して余りが0になるまでの回数を計算
        // 1回目以降は2*10^5以下なので愚直に計算しても間に合う
        int r = 1;
        for(int i = n-1; i >= 0; i--){
            if (x[i] == b){
                int tmp;
                if (b == 0) tmp = (r0+r)%pc;    // 0→1になるから加算した余り
                else tmp = (r0-r+pc)%pc;        // 1→0になるから減算した余り  
                ans[i] = f(tmp)+1;              // 1回目の分を+1
            }
            r = (r*2)%pc;
        }
    }
    rep(i,n) cout << ans[i] << endl;
}

Measured memory_bytes: 5220
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int S = sc.nextInt();
    sc.close();
    int L = S/100;
    int R = S%100;
    if (L>=1 && L<=12){
      if (R>=1 && R<=12){
        System.out.println("AMBIGUOUS");
      }else{
        System.out.println("MMYY");
      }
    }else{
      if (R>=1 && R<=12){
        System.out.println("YYMM");
      }else{
        System.out.println("NA");
      }
    }
  }
}

Measured memory_bytes: 22608
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AX solver = new AX();
        solver.solve(1, in, out);
        out.close();
    }

    static class AX {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            out.println(Math.max(a + b, Math.max(a - b, a * b)));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 24788
(* 素集合データ構造 *)
module UnionFind : sig
  type t

  module Class : sig
    type t
    val to_int : t -> int
    val compare : t -> t -> int
  end

  (* n要素の素集合データ構造を作る *)
  val make : int -> t
  (* 要素がどの集合に属するか調べる *)
  (* 要素は0からn-1の整数である必要がある *)
  val find : t -> int -> Class.t
  (* 与えられた要素が属する集合同士を合併する *)
  val unite : t -> int -> int -> unit
end = struct
  type t = { rank : int array; parent : int array }

  module Class = struct
    type t = int
    let to_int c = c
    let compare = compare
  end

  let make n =
    { rank = Array.make n 0;
      parent = Array.init n @@ fun c -> c }

  let rec find uf x =
    if x = uf.parent.(x) then x
    else begin
      let y = find uf uf.parent.(x) in
      uf.parent.(x) <- y; y
    end

  let unite uf i j =
    let x = find uf i in
    let y = find uf j in
    if x <> y then begin
      if uf.rank.(x) < uf.rank.(y) then uf.parent.(x) <- y
      else begin
        uf.parent.(y) <- x;
        if uf.rank.(x) = uf.rank.(y) then
          uf.rank.(x) <- 1 + uf.rank.(x)
      end
    end
end


let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let abs = Array.init m @@ fun _ -> Scanf.scanf "%d %d\n" @@ fun a b -> a, b in
  let uf = UnionFind.make n in
  let cnt = Array.make n 1 in
  let ans = Array.make (m + 1) (n * (n - 1) / 2) in
  for i = m - 1 downto 0 do
    let ca = UnionFind.find uf (fst abs.(i) - 1) in
    let cb = UnionFind.find uf (snd abs.(i) - 1) in
    if UnionFind.Class.compare ca cb = 0
    then ans.(i) <- ans.(i + 1)
    else begin
      let cnta = cnt.(UnionFind.Class.to_int ca) in
      let cntb = cnt.(UnionFind.Class.to_int cb) in
      ans.(i) <- ans.(i + 1) - cnta * cntb;
      cnt.(UnionFind.Class.to_int ca) <- cnta + cntb;
      cnt.(UnionFind.Class.to_int cb) <- cnta + cntb;
      UnionFind.unite uf (fst abs.(i) - 1) (snd abs.(i) - 1)
    end
  done;
  for i = 1 to m do
    Printf.printf "%d\n" ans.(i)
  done



Measured memory_bytes: 10496
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
	while(1){
		int a[3], n;
		for(int i=0; i<3; ++i) scanf(" %d", &a[i]);
		sort(a, a+3);
		if(a[2]==0) break;
		
		scanf(" %d", &n);
		for(int i=0; i<n; ++i){
			int r;
			scanf(" %d", &r);
	
			if(a[0]*a[0]+a[1]*a[1]<4*r*r) printf("OK\n");
			else printf("NA\n");
		}	
	}

	return 0;
}

Measured memory_bytes: 1184
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from collections import Counter
from itertools import product
from math import factorial

# prime numbers
primes = list(range(int(10**5) + 1))
primes[1] = 0
for i in range(2, int(len(primes) ** 0.5) + 1):
    if primes[i]:
        for j in range(2 * i, len(primes), i):
            primes[j] = 0

def main():
    A, B, C, D = LI()
    return max(A * B, C * D)

print(main())

Measured memory_bytes: 7276
var M,D,ans,i,j,k:Longint;
begin
read(M,D);
for i:=1 to M do begin
	for j:=2 to 9 do begin
		for k:=2 to 9 do begin
			if j*10+k>D then continue;
			if i=j*k then inc(ans);
		end;
	end;
end;
writeln(ans);
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define MN 300000
#define P(x,y,z) (((y-1)*3+z)*n+x)
inline int read()
{
    int x=0,f=1;char c=getchar();
    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;
}
bool yes[2][1000005];
int n,m,Q,mod,xx[MN+5],yy[MN+5],vv[MN+5],G,GG,Z,s[MN+5];
inline int gcd(int x,int y){return y?gcd(y,x%y):x;}
inline int Abs(int x){return x<0?-x:x;}
inline int getfa(int x){return s[x]?s[x]=getfa(s[x]):x;}
inline void Merge(int x,int y){if(getfa(x)!=getfa(y))s[getfa(x)]=getfa(y);}
int main()
{
    n=read();m=read();Q=read();G=mod=read();
    for(int i=1;i<=m;++i) xx[i]=read(),yy[i]=read(),vv[i]=read();
    for(int i=2;i<=m;++i) G=gcd(G,Abs(vv[i]-vv[1]));
    GG=gcd(G*3,mod);Z=vv[1]%G;
    for(int i=1;i<=m;++i) for(int j=1;j<=2;++j) for(int k=0;k<=2;++k)
    {
        int ad=vv[i]/G;
        Merge(P(xx[i],j,k),P(yy[i],j^3,(k*2+ad)%3));
        Merge(P(yy[i],j,k),P(xx[i],j^3,(k*2+ad)%3));
    }
    for(int i=0,j=Z;i<=GG*2;++i,j=j*2%GG) yes[i&1][j]=1; 
    for(int i=1;i<=Q;++i)
    {
        int x=read(),y=read(),r=read(),ans=0;
        for(int j=1;j<=2;++j) for(int k=0;k<=2;++k)
            if(getfa(P(y,1,0))==getfa(P(x,j,k))&&yes[j-1][(r+Z+(3-k)*G)%GG]) ans=1;
        puts(ans?"YES":"NO");
    }
    return 0;
}

Measured memory_bytes: 6656
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

bool is_OK(vll& B, ll N, ll M, ll V, ll K) {
    ll X = K;
    ll limit = 0;
    REP(i, V, N) {
        limit += min(M, X - B[i]);
    }

    ll S = 0;
    rep(i, N) {
        if (B[i] > X) {
            S += B[i] - X;
        }
    }
    if (S <= limit) return true;
    return false;
}

ll calc_under(vll& A, ll N, ll M, ll V, ll P) {
    if (V < P) return A[P - 1];

    V -= (P - 1);
    N -= (P - 1);
    vll B(A.begin() + (P - 1), A.end());
    sort(B.begin(), B.end());
    rep(i, V) {
        B[i] += M;
    }
    ll L = B[N - 1] - 1;
    ll R = B[N - 1] + M;
    
    while (R - L > 1) {
        ll K = (L + R) / 2;
        if (is_OK(B, N, M, V, K)) {
            R = K;
        }
        else {
            L = K;
        }
    }
    return R;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N, M, V, P;
    cin >> N >> M >> V >>P;
    vll A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end(), greater<ll>());
    ll U = calc_under(A, N, M, V, P);
    ll ans = 0;
    rep(i, N) {
        if ((A[i] + M) >= U) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
N, M = gets.chomp.split(' ').map(&:to_i)
A = gets.chomp.split(' ').map(&:to_i)

sum_a = A.inject(&:+)
A.sort! {|x,y| y<=>x}

puts A[M - 1] < sum_a / 4.0 / M ? 'No' : 'Yes'


Measured memory_bytes: 3836
// atcoder/abc130/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli n, x;
  while (cin >> n >> x) {
    vector<lli> l(n);
    cin >> l;
    int cnt = 1;
    lli y = 0;
    each (i, l) {
      // cout << y << endl;
      y += i;
      if (x < y) break;
      ++cnt;
    }
    cout << cnt << endl;
    // cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin >> N;
    int x=(N+1)/2;
    cout << fixed << setprecision(14);
    cout << (double) x/N << endl;



}


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

int main(){
  int i, j, n, m;
  int a=0;
  int max=0;
  string s;
  cin >> n;
  vector<string> x(n);
  for(i=0;i<n;i++){
    cin >> x.at(i);
  }
  cin >> m;
  vector<string> y(m);
  for(i=0;i<m;i++){
    cin >> y.at(i);
  }
  
  for(i=0;i<n;i++){
    s=x.at(i);
    for(j=0;j<n;j++){
      if(s==x.at(j)){
        a++;
      }
    }
    for(j=0;j<m;j++){
      if(s==y.at(j)){
        a--;
      }
    }
    if(max<a){
      max=a;
    }
    a=0;
  }
  
  if(max>0){
    cout << max << endl;
  }
  else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,x,n) for(int i=x;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1005,INF=1<<29;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,M;cin>>N>>M;
    vector<int> A(N);
    int ac=0,wa=0;
    
    for(int i=0;i<M;i++){
        string S;int B;cin>>B>>S;
        B--;
        
        if(A[B]==-1) continue;
        
        if(S[0]=='A'){
            ac++;
            wa+=A[B];
            A[B]=-1;
        }else{
            A[B]++;
        }
    }
    
    cout<<ac<<" "<<wa<<endl;
}



Measured memory_bytes: 640
def shortest_tour(positions)
	positions.permutation(positions.size).map{|perm|
		([[0, 0]] + perm + [[0,0]]).each_cons(2).map{|p1, p2|
			x1, y1 = p1
			x2, y2 = p2
			(x1-x2).abs + (y1-y2).abs
		}.inject(:+)
	}.min
end

def unbounded_knapsack(items, budget)
	table = [0]
	for i in 1..budget
		table[i] = 0
		items.each{|c, v|
			next if c > i
			x = table[i-c] + v
			table[i] = x if x > table[i]
		}
	end
	table[budget]
end

n, m, w, t = gets.split.map &:to_i
items = {}
(1..m).each{ 
	name, weight, sale = gets.chomp.split
	items[name] = [weight.to_i, sale.to_i]
}

cities = (1..n).map{
	k, x, y = gets.split.map &:to_i
	city_items = {}
	(1..k).each{
		name, price = gets.chomp.split
		city_items[name] = price.to_i
	}
	[x, y, city_items]
}

time_profit = []
(1..(1<<n)-1).each{|x|
	idx = (0..n-1).select{|i| x[i] == 1}
	time = shortest_tour(idx.map{|i| cities[i][0..1]})
	available_items = Hash.new(0)
	idx.each{|i|
		city_items = cities[i][-1]
		city_items.each{|name, price|
			profit = items[name][1] - price
			available_items[name] = profit if profit > available_items[name]
		}
	}
	route_items = available_items.map{|name, profit| [items[name][0], profit]}
	total_profit = unbounded_knapsack(route_items, w)

	time_profit << [time, total_profit]
}

p unbounded_knapsack(time_profit, t)

Measured memory_bytes: 8636
# バブルソート

N = int(input())
A = list(map(int, input().split()))


def bubbleSort(A, N):
    isExist = True
    cnt = 0
    while isExist:
        isExist = False
        for i in range(1, N):
            j = N - i
            if A[j] < A[j - 1]:
                A[j], A[j - 1] = A[j - 1], A[j]
                isExist = True
                cnt += 1
    print(' '.join([str(i) for i in A]))
    print(cnt)


bubbleSort(A, N)



Measured memory_bytes: 5608
import java.util.AbstractMap.SimpleEntry;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try(Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] a = new int[n];
			int[] b = new int[n];
			PriorityQueue<SimpleEntry<Integer, Integer>> queue = new PriorityQueue<>((e1, e2) -> {
				return Integer.compare(e1.getValue(), e2.getValue());
			});
			for(int i = 0 ; i < n ; i++) {
				a[i] = sc.nextInt();
				b[i] = sc.nextInt();
				queue.add(new SimpleEntry<Integer, Integer>(a[i], b[i]));
			}
			SimpleEntry<Integer, Integer> entry;
			int current = 0;
			while((entry = queue.poll()) != null) {
				if(current + entry.getKey() > entry.getValue()) {
					System.out.println("No");
					System.exit(0);
				} else {
					current += entry.getKey();
				}
			}
			System.out.println("Yes");
		}

	}

}


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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#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 true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

int r, c;
set<P> st1;
set<P> st2;
set<P> st3, st4;

void merge(stack<int>& st, set<P>& se) {
  for(auto e: se) {
    if (st.empty()) {
      st.push(e.second);
    } else {
      int p = st.top();
      if (p == e.second) {
        st.pop();
      } else {
        st.push(e.second);
      }
    }
  }
}

bool check(int x, int y) {
  return (x == 0 || x == r || y == 0 || y == c);
}

void insert(int x, int y, int i) {
  if (x==0 && y != c) {
    st1.emplace(y, i);
  } else if (y==c && x != r) {
    st2.emplace(x, i);
  } else if (x==r && y != 0) {
    st3.emplace(-y, i);
  } else {
    st4.emplace(-x, i);
  }
}

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

  int n; cin >> r >> c >> n;

  rep(i, n) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    if (check(x1,y1) && check(x2,y2)) {
      insert(x1, y1, i);
      insert(x2, y2, i);
    }
  }

  stack<int> st;
  merge(st, st1);
  merge(st, st2);
  merge(st, st3);
  merge(st, st4);

  if (st.empty()) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

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

template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
typedef long long s64;
#define rep(i,l,r) for(int i=l;i<=r;++i)
const int N=1e5+5;
int a[N];
s64 s[N],s1[N];

int main()
{
	//freopen("1.in","r",stdin);
	int n,k;
	cin>>n>>k;
	rep(i,1,n)
	{
		scanf("%d",a+i);
		s[i]=s[i-1]+a[i];
		s1[i]=s1[i-1]+(a[i]>0?a[i]:0);
	}
	s64 ans=0;
	rep(i,1,n-k+1)chmax(ans,s1[i-1]+s1[n]-s1[i+k-1]+max((s64)0,s[i+k-1]-s[i-1]));
	cout<<ans;
}

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

using namespace std;

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

  int N,M,V,P; cin>>N>>M>>V>>P;
  vector<int> A(N); for (auto& a : A) cin>>a;
  sort(A.rbegin(), A.rend());
  vector<long> ds(N);
  for (long i = P; i < N; i++) {
    ds[i] = ds[i-1]+(A[P-1]-A[i]);
  }
  auto is_ok = [&](int i) {
    if (A[P-1] > M + A[i])
      return false;
    auto buf = long((P-1)+(N-i))*M + ds[i-1] + long(i-P+1)*(A[i]+M-A[P-1]);
    return buf >= (long)M*V;
  };
  int l = P, r = N-1;
  int ans = P;
  while (l <= r) {
    auto c = (l+r)/2;
    if (is_ok(c)) {
      ans = c+1;
      l = c+1;
    } else {
      r = c-1;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC049_C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] divide = { "dream", "dreamer", "erase", "eraser" };
            string[] divideReverse = new string[4];
            string input = Console.ReadLine();
            string inputReverse = string.Join("", input.Reverse());

            for (int i = 0; i < 4; i++)
            {
                divideReverse[i] = string.Join("", divide[i].Reverse());
            }

            bool can1 = true;
            for (int i = 0; i < input.Length;)
            {
                bool can2 = false;
                for (int j = 0; j < divideReverse.Length; j++)
                {
                    int divLength = divideReverse[j].Length;        //反転文字の文字数
                    if (i + divLength > inputReverse.Length)
                    {
                        continue;
                    }
                    if (inputReverse.Substring(i, divLength) == divideReverse[j])
                    {
                        can2 = true;
                        i += divLength;
                    }
                }
                if (!can2)
                {
                    can1 = false;
                    break;
                }
            }

            if (can1)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


Measured memory_bytes: 16352
abcd = list(map(int,input()))

def alsum(tmp,count,strs):
  if count == 4:
    
    if tmp ==7:
      print(strs+'=7')
      exit()
    else:
      return
    
  plus = alsum(tmp+abcd[count],count+1,strs+'+'+str(abcd[count]))
  minus = alsum(tmp-abcd[count],count+1,strs+'-'+str(abcd[count]))
  
alsum(abcd[0],1,str(abcd[0]))


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main(void) {
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    for(int i=0;i<n;i++){
        if(s.substr(i)==t.substr(0,n-i)){
           fin(2*i+s.substr(i).size());
           return 0;
        //    else fin(s.substr(0,i)+s.substr(i)+t.substr(i-1));
        }
    }
    fin(n*2);
}


Measured memory_bytes: 256
A,B,C,X = map(int, [input()for i in range(4)])
counter = 0

for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
           if 500*a + 100*b + 50*c  == X:
               counter += 1

print(counter)


Measured memory_bytes: 9160
#include <stdio.h>

int main()
{

    int i,N,M,p,q,ans;

    scanf ("%d %d", &N, &M);
  	
      p = N*(N-1)*0.5;
  	q = M*(M-1)*0.5;

  	ans = p + q;
  	
    printf("%d",ans);
return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
using namespace std;

int main()
{
    int n, wrong=0;
    cin >> n;
    int counter=0;
    vector<int> vt(n);
    for(int i=0; i<n; i++){
        cin >> vt[i];
    }
    sort(vt.begin(), vt.end());
    for(int i=0; i<n-1; i++){
        if(vt[i]==vt[i+1]){
            counter++;
        }else{
            wrong+=counter;
            counter=0;
        }
    }

    if(vt[n-2]==vt[n-1]){
        wrong+=counter;
    }
    if(wrong%2==1){
        wrong++;
    }
    cout << n-wrong;
    
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <stack>

typedef long long ll;

using namespace std;

int main() {
    long double w, h, x, y;
    cin >> w >> h >> x >> y;
    
    int num = 0;
    long double div = 2.0;
    if(x == w / div && y == h / div) {
        num = 1;
    }
    
    cout << setprecision(12) << (w * h) / div << " " << num << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }

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

    ll N; cin >> N;
    ll H[N]; REP(i, N) cin >> H[i];

    if (N==1) {
        cout << "Yes" << '\n';
        return 0;
    }

    ll now = H[0];
    REP (i, N-1) {
        if (H[i] > H[i+1]) {
            if (now < H[i]-1)
                now = H[i]-1;
        }
        if (now > H[i+1]) {
            cout << "No" << '\n';
            return 0;
        }
    }

    cout << "Yes" << '\n';
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_N = 1<<17;

class RSQ2{
public:
  ll n,dat[2*MAX_N-1],td[2*MAX_N-1];
  //?????????
  RSQ2(){n=MAX_N,memset(dat,0,sizeof(dat)),memset(td,0,sizeof(td));};
  RSQ2(int n_){
    n=1;
    while(n<n_)n*=2; //????´???°n???2???????????????
    for(int i=0;i<2*n-1;i++)dat[i]=td[i]=0;
  }
  
  //[a,b)????????????x???????????????,query(a,b,x);
  ll add(int a,int b,ll x,int k=0,int l=0,int r=-1){
    if(r==-1) r=n;
    if(r<=a||b<=l)return 0;
    if(a<=l&&r<=b){
      dat[k]+=(r-l)*x; 
      td[k]+=x;
      return dat[k];
    }
    dat[k]+=(min(r,b)-max(l,a))*x;
    ll kl=k*2+1,kr=k*2+2,t=td[k]*(r-l)/2;
    dat[kl] += t;
    dat[kr] += t;
    td[kl] += td[k];
    td[kr] += td[k];
    td[k]=0;
    ll vl=add(a,b,x,k*2+1,l,(l+r)/2);
    ll vr=add(a,b,x,k*2+2,(l+r)/2,r);
    return vl+vr;
  }
  
  //[a,b)??????????????????
  ll sum(int a,int b){return add(a,b,0);}
};

int main(){
  int n,q;
  cin>>n>>q;
  RSQ2 T(n);
  while(q--){
    int cmd,s,t,x;
    cin>>cmd>>s>>t;
    if(cmd) cout << T.sum(s-1,t)<<endl;
    else cin>>x,T.add(s-1,t,x);
  }
  return 0;
}

Measured memory_bytes: 7220
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream> 
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;

#define assert_range(x,a,b) assert((a) <= (x) and (x) <= (b))
using ll = long long;
const int INF = 1e9;

const int MAX_W = 1e5;
const int MAX_N = 100;

ll dp[MAX_N+1][MAX_W+1];

int main() {
    ios_base::sync_with_stdio(0);
    int n, W;
    cin >> n >> W;
    vector<int> w(n);
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> w[i] >> v[i];
    }
    for (int i = 1; i <= n; ++i) {
        for (int x = 0; x <= W; ++x) {
            dp[i][x] = dp[i-1][x];
            if (x >= w[i-1]) {
                dp[i][x] = max(dp[i][x], dp[i-1][x-w[i-1]] + v[i-1]);
            }
        }
    }
    ll res = 0;
    for (int x = 0; x <= W; ++x) {
        res = max(res, dp[n][x]);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 78336
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n, k; cin >> n >> k;
  vll a(n); REP(i, n) cin >> a[i];
  vll asum; asum.push_back(0);
  REP(i, n) asum.push_back(asum[i] + a[i]);
  vll cand;
  REP(i, n+1) rep(j, i+1, n+1) cand.push_back(asum[j] - asum[i]);
  ll ans = 0;
  for(ll i=40; i>=1; i--) {
    ll t = 1LL<<(i-1);
    ll tmp = 0;
    REP(i, cand.size()) {
      if ((cand[i] & (ans+t)) == ans+t) tmp++;
    }
    if (tmp >= k) ans += t;
  }
  cout << ans << endl;
  return 0;
}


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


ll gcd(ll a, ll b) {
    if (a % b == 0) return b;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}

signed main() {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  
  ll ans = (B - A+1) - ( B/C + B/D ) + ( (A-1)/C + (A-1)/D );
                                       
  //最小公倍数のところで二重にひいてしまってる分を足す
  ll kobai = lcm(C, D);
  ans += ( B/kobai - (A-1)/kobai );
  
  cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
A = [0] * N
B = list(map(int,input().split()))

for i in range(N-1):
    A[i] = B[i]
A[N-1] = B[N-2]

for i in range(N-2):
    if A[i+1] > B[i]:
        A[i+1] = B[i]

print(sum(A))

Measured memory_bytes: 3064
#include<math.h>
#include<map>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
#include <list>
#include<numeric>
//AtCoderC++.cpp

using namespace std;


inline int ceileing(int a, int b) {return a % b == 0 ? a / b : a / b + 1;}
int main() {
	int A, B; cin >> A >> B;
	if (A == 1) {
		if (B == 1) cout << "Draw" << endl;
		else cout << "Alice" << endl;		
	} else {
		if (B == 1)cout << "Bob" << endl;
		else if (A == B) cout <<"Draw" << endl;
		else cout << (A < B ? "Bob" : "Alice") << endl;
	}
}

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


void solve(long long a, long long b, long long c){
    set<long long> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    cout << s.size() << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long c;
    scanf("%lld",&c);
    solve(a, b, c);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int number,a,b;
	scanf("%d",&number);
	a=number/10;
	b=number%10;
	if(a == 9 || b==9)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;


int main() {
	int N; cin >> N;
	while (N--) {
		vector<long long>nums;
		for (int i = 0; i < 8; ++i) {
			long long a;
			cin >> hex >> a;
			nums.push_back(a);
		}
		long long sum;
		cin >> hex >> sum;
		unsigned int ans = 0;
		for (int i = 0; i < 32; ++i) {
			unsigned int nowsum = (accumulate(nums.begin(), nums.end(), 0ll)&0xffffffff);
			if ((sum^nowsum) & (1ll << i)) {
				ans += 1 << i;
				for_each(nums.begin(), nums.end(), [=](long long &a) {a ^= (1 << i); });
			}
		}
		cout << hex << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3112
require 'set'
def dictionary(orders)
  set = Set.new
  length = orders.length
  for i in 0..(length-1)
    if orders[i][0] == "insert"
      set.add(orders[i][1])
    elsif orders[i][0] == "find"
      if set.include?(orders[i][1]) == false
        puts "no"
      else
        puts "yes"
      end
    else
      puts "error!"
    end
  end
end

n = gets.chomp.to_i
orders = []
n.times do
  order = gets.chomp.split
  orders.push(order)
end
dictionary(orders)

Measured memory_bytes: 261524
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<bitset>
#include<tuple>
#include<time.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

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

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


int n, a[202020];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	sort(a,a+n);
	
	for(int i = 1; i < n; i++){
		if(a[i] == a[i-1]){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  printf("%lld",(a-c)*(b-d));
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
using namespace std;
vector<int> vec[10010],rvec[10010];
bool used[10010];
int cmp[10010]={};
stack<int> st;
void dfs(int a){
    used[a] = true;
    for(int i=0;i<vec[a].size();i++){
        if(used[vec[a][i]]) continue;
        dfs(vec[a][i]);
    }
    st.push(a);
}
void rdfs(int a,int k){
    used[a] = true;
    cmp[a] = k;
    for(int i=0;i<rvec[a].size();i++){
        if(used[rvec[a][i]]) continue;
        rdfs(rvec[a][i],k);
    }
}
int main()
{
    int n,m,s,t;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        cin >> s >> t;
        vec[s].push_back(t);
        rvec[t].push_back(s);
    }
    
    fill(used,used+n,false);
    for(int i=0;i<n;i++){
        if(!used[i]) dfs(i);
    }
    
    fill(used,used+n,false);
    int cnt = 0;
    while(!st.empty()){
        int a = st.top();
        st.pop();
        if(used[a]) continue;
        rdfs(a,cnt);
        cnt++;
    }
    
    int sum1 = cnt,sum2 = cnt;
    
    fill(used,used+n,false);
    for(int i=0;i<n;i++){
        for(int j=0;j<vec[i].size();j++){
            if(!used[cmp[i]] && cmp[i] != cmp[vec[i][j]]){
                used[cmp[i]] = true;
                sum1--;
            }
        }
    }
    
    fill(used,used+n,false);
    for(int i=0;i<n;i++){
        for(int j=0;j<rvec[i].size();j++){
            if(!used[cmp[i]] && cmp[i] != cmp[rvec[i][j]]){
                used[cmp[i]] = true;
                sum2--;
            }
        }
    }
    if(cnt == 1){
        sum1 = 0;
        sum2 = 0;
    }
    cout << max(sum1,sum2) << endl;
    
    return 0;
}



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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 1;i <= n; ++i){
		int x = i;
		int cnt = 0;
		while(x){
			cnt++;
			x/=10;
		}
		ans += cnt & 1;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 256