akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (unsigned int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    int N,A,B,ans;
    bool F=true;
int main(){
    cin>>N>>A>>B;
    ans=min(B,N*A);
    cout<<ans<<endl;
    return 0;

}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
class Main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    int k=sc.nextInt();
    int n=sc.nextInt();
    if(n==0)
       System.out.println(k);
    else
    {
      HashSet<Integer> s=new HashSet<Integer>();
      for(int i=0;i<n;i++)
        s.add(sc.nextInt());
      if(!s.contains(k))
      {
        System.out.println(k);
        return;
      }
      for(int d=1;true;d++)
      {
        if(!s.contains(k-d))
        {
          System.out.println(k-d);
          return;
        }
        if(!s.contains(k+d))
        {
          System.out.println(k+d);
          return;
        }
      }
    }
  }
}


Measured memory_bytes: 35880
MODE = "stdio"
#require 'matrix'
#include Math
line = Array.new

if(defined? MODE)
  line = STDIN.read.split("\n")
else
  tmp = '6
  5 6 4 2 1 3'.split("\n")
  tmp.each{|s|
    line << s.strip
  }
end

n = line[0].to_i

arr = line[1].split(" ").map(&:to_i)
cnt = 0
(0..n-1).each do |i|
  minj = i
  (i..n-1).each do |j|
    if arr[j]<arr[minj]
      minj = j
    end
  end
  if i!=minj
    arr[i],arr[minj] = arr[minj],arr[i]
    cnt += 1
  end
end

puts arr.join(" ")
puts cnt

Measured memory_bytes: 8720
'use strict';
(function(stdin) {
  var inputs  = stdin.toString();
  var S = parseInt(inputs.split('\n')[0],10);
  var h = Math.floor(S / 3600);
  var m = Math.floor((S % 3600) / 60);
  var s = S % 60;
//  console.log(h+':'+m+':'+s);
  console.log([h,m,s].join(':'));

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7640
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;

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

    vector<int> times(n+1);
    times[0] = 0;
    vector<pair<int, int>> places(n+1);
    places[0] = pair<int, int>(0, 0);
    repi(i, 1, n+1){
        int t, x, y;
        cin >> t >> x >> y;
        times[i] = t;
        places[i] = pair<int, int>(x, y);
    }

    bool success = true;
    repi(i, 1, n+1){
        int dist = abs(places[i].first - places[i-1].first) + abs(places[i].second - places[i-1].second);
        int dt = times[i] - times[i-1];

        if(dist > dt) success = false;
        if(dist % 2 != dt % 2) success = false;
    }

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

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
int main()
{
    int x, y;
    cin >> x >> y;
    for (int i = 0; i <= x; i++)
    {
        if (y == i * 2 + (x - i) * 4)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 2333333;
int n;char s[N],t[N];
int a[N],lzyp,lzyc,off,v[N];
char getc(int i){return lzyp<=i?lzyc:s[i];}
//inline int query(int p){int r=0;while(p)r+=v[p],p-=p&-p;return r;}
//inline void modify(int p, int x){while(p<=2*n+1)v[p]+=x,p+=p&-p;}
int main() {
	read(n);scanf("%s%s",s+1,t+1);lzyp=n+1;
	for(int i=n,j=n;i>=1;i--){
		s[i]=getc(i);//if(lzyp<=i)s[i]=lzyc;
		if(s[i]!=t[i]){
			j=min(j,i-1);while(j&&getc(j)!=t[i])j--;
		//	printf("find %d %d\n",i,j);
			if(!j){puts("-1");return 0;}
			lzyp=j;lzyc=s[j];
			
		//	printf("seg %d %d\n",j,i);
		//	int rec=query(off+i)+1;
			off++;int now=1-a[off+i];
			a[j+off]++;a[i+off]--;//modify(j+off,1);modify(i+off,-1);
			
			if(now){
			//	printf("upd %d\n",now);
				a[i+off]+=now;a[i+off+1]-=now;
			//	modify(i+off,now);modify(i+off+1,-now);
			}
		//	a[j+off]++;a[i+1+off]--;
			
			j--;
		}
	}
	rep(i,1,n*2+1)a[i]+=a[i-1];
	int mx=0;rep(i,1,n*2+1)umax(mx,a[i]);cout<<mx;
	return 0;
}


Measured memory_bytes: 14592
#include <iostream>
using namespace std;
int main(){
    int D,i;
    cin >> D;
    if(D==25){
        cout << "Christmas";
        }
    else if(D<=25&&D>=22){
        cout << "Christmas";
        for(i=1;i<=3;i++){
            cout << " Eve";
            if(D+i==25){
                break;
                }
            }
        }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
    #define pb push_back
    #define sz size()
     
    using namespace std;
    using ll = long long int;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
    using Vl = vector<ll>;
     
const int MOD = 1e9 + 7;
const ll ZER = 0;


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    set<int> st;

    rep(i, n){
        cin >> a[i];
        st.insert(a[i]);
    }
    if(st.size() == 1){
        if(a[0] == 0)cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    if(st.size() == 2){
        int x = 0, z = 0;
        rep(i, n){
            if(a[i] == 0)z++;
            else x++;
        }
        if(n % 3 == 0 && x == n / 3 * 2 && z == n / 3)cout << "Yes" << endl;
        else cout << "No" << endl;
        //cout << "hoge";
    }
    if(st.size() == 3){
        bool f = true;
        map<ll, int> mp;
        rep(i, n)mp[a[i]]++;
      	int x = 0;
        for(auto m : mp){
          	x ^= m.first;
            if(m.second * 3 != n)f = false;
        }
        if(f && n % 3 == 0 && x == 0)cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    if(st.size() > 3)cout << "No" << endl;
}



Measured memory_bytes: 7188
#include <cstdio>
using namespace std;
int N, M, H[100010], ans;
int main() {
  scanf("%d %d", &N, &M);
  for(int i = 1, L, R; i <= M; ++i) {
    scanf("%d %d", &L, &R);
    ++H[L]; --H[R+1];
  }
  for(int i = 1; i < N; ++i) {
    H[i+1] += H[i];
  }
  for(int i = 1; i <= N; ++i) {
    if(H[i] == M) ++ans;
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 512
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static double[][] A;
    static int N;

    static double bestXY(double x, double y) {
        double res = 0;
        for (int i = 0; i < N; i++) {
            double dx = A[i][0] - x;
            double dy = A[i][1] - y;
            double diff = dx * dx + dy * dy;
            res = Math.max(res, diff);
        }

        return res;
    }

    static double bestY(double x) {
        double l = 0, r = 1000;
        for (int i = 0; i < 100; i++) {
            double c1 = (2 * l + r) / 3;
            double c2 = (l + 2 * r) / 3;
            if (bestXY(x, c1) < bestXY(x, c2)) {
                r = c2;
            } else {
                l = c1;
            }
        }
        return bestXY(x, l);
    }

    static void solve(Scanner scanner) {
        N = Integer.parseInt(scanner.next());
        A = new double[N][2];
        for (int i = 0; i < N; i++) {
            A[i][0] = Integer.parseInt(scanner.next());
            A[i][1] = Integer.parseInt(scanner.next());
        }

        double l = 0, r = 1000;
        for (int i = 0; i < 100; i++) {
            double c1 = (2 * l + r) / 3;
            double c2 = (l + 2 * r) / 3;
            if (bestY(c1) < bestY(c2)) {
                r = c2;
            } else {
                l = c1;
            }
        }

        System.out.printf("%.10f\n", Math.sqrt(bestY(l)));
    }
}


Measured memory_bytes: 24020
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<ll, pair<int, int>> P;
int main()
{
    int N, M;
    cin >> N >> M;

    vector<vector<int>> G(N);
    rep(i, M) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        G[u].emplace_back(v);
    }

    int S, T;
    cin >> S >> T;
    S--; T--;

    vector<vector<ll>> d(3, vector<ll>(N, INF));
    priority_queue<P, vector<P>, greater<P>> que;
    d[0][S] = 0;
    que.push({0, {S, 0}});
    while (!que.empty()) {
        ll c = que.top().first;
        int v = que.top().second.first;
        int n = que.top().second.second;
        // cout << v << " " << n << " " << c << endl;
        que.pop();
        if (d[n][v] < c) continue;
        for (int to : G[v]) {
            if (d[(n + 1) % 3][to] > d[n][v] + 1) {
                d[(n + 1) % 3][to] = d[n][v] + 1;
                que.push({d[(n + 1) % 3][to], {to, (n + 1) % 3}});
            }
        }
    }

    ll ans = d[0][T];
    if (ans == INF) ans = -1;
    else ans /= 3;
    cout << ans << endl;
    return 0;
}

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

int main(){
  int N,A,B;
  cin >> N >> A >> B;
  if (A*N < B){
    cout << A*N << endl;
  }
  if (A*N == B){
    cout << B << endl;
  }
  if (A*N > B){
    cout << B << endl;
  }
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007
#define HMAX 50
#define WMAX 50

using namespace std;

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


int main()
{
    int H, W;
    cin >> H >> W;
    char grid[W][H];
    int countWhite = 0;
    REP(i, H)
    {
        REP(j, W)
        {
            cin >> grid[j][i];
            if (grid[j][i] == '.')
            {
                countWhite++;
            }
        }
    }

    map<P, vector<P>> G;
    map<P, int> dist;
    // グラフをつくる
    REP(i, H)
    {
        REP(j, W)
        {
            int x = j, y = i;
            P p(j, i);
            dist[p] = -1;
            // 右
            if (x + 1 <= W - 1 && grid[x + 1][y] == '.')
            {
                G[p].push_back(P(x + 1, y));
            }
            // 左
            if (x - 1 >= 0 && grid[x - 1][y] == '.')
            {
                G[p].push_back(P(x - 1, y));
            }
            // 下
            if (y + 1 <= H - 1 && grid[x][y + 1] == '.')
            {
                G[p].push_back(P(x, y + 1));
            }
            // 上
            if (y - 1 >= 0 && grid[x][y - 1] == '.')
            {
                G[p].push_back(P(x, y - 1));
            }
        }
    }

    queue<P> pointQ;
    P visitP(0, 0);
    pointQ.push(visitP);
    dist[visitP] = 1;

    while(!pointQ.empty())
    {
        P p = pointQ.front();
        pointQ.pop();
        
        for (auto itr = G[p].begin(); itr != G[p].end(); ++itr)
        {
            P nextP = *itr;
            if (dist[nextP] != -1) 
            {
                continue;
            }
            pointQ.push(nextP);
            dist[nextP] = dist[p] + 1;
        }
    }

    int ans = -1;
    P goal(W - 1, H - 1);
    if (dist[goal] != -1)
    {
        ans = countWhite - dist[goal];
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 768
import java.io.*;
import java.util.*;

public class Main {

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null; }
        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()); }
        public long nextLong() { return Long.parseLong(next()); }
        public double nextDouble() { return Double.parseDouble(next()); }
    }

    static InputReader r = new InputReader(System.in);
    static PrintWriter pw = new PrintWriter(System.out);

    public static void main(String[] args) {
        
        int a = r.nextInt();
        int b = r.nextInt();
        // each socket adds A-1;

        pw.println((int)Math.ceil((1.0 * b-1) / (a-1)));

        pw.close();
    }
}

/**
                _        _                 _                                                
               | |      | |               | |                                               
   ___ ___   __| | ___  | |__  _   _    __| | __ _ _ __ _ __ ___ _ __     _   _  __ _  ___  
  / __/ _ \ / _` |/ _ \ | '_ \| | | |  / _` |/ _` | '__| '__/ _ \ '_ \   | | | |/ _` |/ _ \ 
 | (_| (_) | (_| |  __/ | |_) | |_| | | (_| | (_| | |  | | |  __/ | | |  | |_| | (_| | (_) |
  \___\___/ \__,_|\___| |_.__/ \__, |  \__,_|\__,_|_|  |_|  \___|_| |_|   \__, |\__,_|\___/ 
                                __/ |                               ______ __/ |            
                               |___/                               |______|___/             
 */

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

using namespace std;

constexpr int MAXN=2e5+5,P=2019;
int n;
int pre_sum[MAXN],buc[2][P];
char s[MAXN];

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;++i)
		pre_sum[i]=(pre_sum[i-1]*10+(s[i]-'0'))%P;
	buc[0][0]=1;
	long long ans=0;
	for(int i=1;i<=n;++i){
		for(int j=0;j<P;++j)
			buc[i&1][j]=0;
		for(int j=0;j<P;++j)
			buc[i&1][j*10%P]+=buc[~i&1][j];
		ans+=buc[i&1][pre_sum[i]]++;
	}
	printf("%lld",ans);
}


Measured memory_bytes: 4804
from functools import reduce

# 入力
s = input()

# AA..ABC -> BCAA..A に変換するのを繰り返す
ans, _, _ = reduce(
    lambda acc, c:
        (acc[0], (1 - acc[2]) * acc[1] + 1, 0) if c == 'A' else
        (acc[0], (1 - acc[2]) * acc[1], 1 - acc[2]) if c == 'B' else
        (acc[0] + acc[2] * acc[1], acc[2] * acc[1], 0),
    s,
    (0, 0, 0)
)

# 出力
print(ans)


Measured memory_bytes: 4124
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> aList = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            aList.add(sc.nextInt());
        }

        int min = Collections.min(aList);
        int max = Collections.max(aList);
        long total = aList.stream().map(a -> (long) a).reduce((a, b) -> a + b).get();

        System.out.printf("%d %d %d\n", min, max, total);

        sc.close();
    }
}


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

int main(){

  int n, k, ans=0;

  cin >> n >> k;

  vector<int> l(n);

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

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

  for(int i=n-1; i>n-k-1; i--){
    ans+=l[i];
  }

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

Measured memory_bytes: 256
"use strict"
function consume(x, p){
  return Math.pow((x - p), 2);
}

function Main(input) {
  input = input.trim().split('\n');
  const N = Number(input[0]);
  const X = input[1].split(' ').map(Number);
  const M = X.length;

  let ret = [];
  for(let p=1; p<=101; p++){
    let tmp = 0;
    for(let i=0; i<M; i++){
      tmp += consume(X[i], p);
    }
    ret.push(tmp);
  }
  
  console.log(Math.min(...ret));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int getKey(const string &s){
  int res = 0;
  for(int i = 0; i < s.size(); i++){
    res *= 5;
    switch(s[i]){
      case 'A': res += 1; break;
      case 'C': res += 2; break;
      case 'G': res += 3; break;
      case 'T': res += 4; break;
    }
  }
  return res;
}

int main(){
  set<int> s;
  int n;
  cin >> n;

  for(int i = 0; i < n; i++){
    string op;
    string str;
    cin >> op >> str;

    if(op == "insert"){
      s.insert(getKey(str));
    }
    else if(s.find(getKey(str)) != s.end()){
      cout << "yes" << endl;
    }
    else{
      cout << "no" << endl;
    }
  }
}

Measured memory_bytes: 14128
#include <stdio.h>

int main()
{
	int i, N, A[100001];
	long long sum = 0;
	scanf("%d", &N);
	for (i = 0; i <= N; i++) {
		scanf("%d", &(A[i]));
		sum += A[i];
	}
	if (A[0] > 0) {
		if (N == 0 && A[0] == 1) printf("1\n");
		else printf("-1\n");
		fflush(stdout);
		return 0;
	}
	
	long long tmp = 1, ans = 1;
	for (i = 1; i <= N; i++) {
		tmp = (tmp * 2 < sum)? tmp * 2: sum;
		ans += tmp;
		if (A[i] <= tmp) {
			tmp -= A[i];
			sum -= A[i];
		} else break;
	}
	
	if (i > N) printf("%lld\n", ans);
	else printf("-1\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2116
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct node {
  int key;
  struct node *right, *left, *p;
 }node;
typedef struct node* Node;
Node root,NIL;

void insert(int);
void inorder(Node);
void preorder(Node);
int main(){
  int m, i, k;
  char string[8];
  scanf("%d",&m);
  for(i = 0; i < m; i++){
    scanf("%s",string);
    if(strcmp(string,"insert") == 0){
      scanf("%d",&k);
      insert(k);
    }
    else if(strcmp(string,"print") == 0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = (Node )malloc(sizeof(node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->p = y;
  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(Node r){
  if(r == NIL) return;
  inorder(r->left);
  printf(" %d",r->key);
  inorder(r->right);
}

void preorder(Node r){
  if(r == NIL) return;
  printf(" %d",r->key);
  preorder(r->left);
  preorder(r->right);
}

Measured memory_bytes: 24040
#include <bits/stdc++.h>
using namespace std;
#include <math.h> 
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,m;
	cin>>n>>m;
	if(n==m){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 10;
int a, b, c;

int main(){
    cin >> a >> b >> c;
    if(a == b){
        cout << c << "\n";
    }
    else if(a == c){
        cout << b << "\n";
    }
    else {
        cout << a << "\n";
    }
    return 0;
}


Measured memory_bytes: 384
import sys

N,Q=map(int,input().split())
s=[-1]
s+=list(map(lambda e:ord(e)-65,list(input())))
s+=[-1]
t=[]
d=[]
for i in range(Q):
    ti,di=sys.stdin.readline().rstrip().split()
    ti=ord(ti)-65
    di = -1 if di=='L' else +1
    t.append(ti)
    d.append(di)

def solve(n):
    for i in range(Q):
        if s[n]==t[i]:
            n+=d[i]
    return n

def find_match(x):
    f1 = 1
    f2 = N + 1
    while f1 != f2:
        f3 = (f1 + f2) // 2
        if solve(f3) == x:
            f1 = f3 + 1
        else:
            f2 = f3
    return f1

def find_notmatch(x):
    f1 = 1
    f2 = N + 1
    while f1 != f2:
        f3 = (f1 + f2) // 2
        #print(f1,f2,f3,solve(f3),x)
        if solve(f3) != x:
            f1 = f3 + 1
        else:
            f2 = f3
    return f1

#for i in range(1,N+1):
#    print(solve(i))

print(find_notmatch(N+1)-find_match(0))


Measured memory_bytes: 74140
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <tuple>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repdm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)

tuple<int, int> dfs(int depth, int score, int cnt, int pat, int p[], int c[])
{
  // Base Case
  if (depth == 0)
  {
    return forward_as_tuple(score, cnt);
  }

  if (pat & 1 << (depth - 1))
  {
    cnt += p[depth];
    score += p[depth] * 100 * depth + c[depth];
  }

  return dfs(depth - 1, score, cnt, pat, p, c);
}

int main()
{
  int D, G;
  cin >> D >> G;

  int p[D + 1], c[D + 1];

  repd(h, 1, D + 1)
  {
    cin >> p[h] >> c[h];
  }

  int ans = 1001;
  repd(pat, 1, pow(2, D) + 1)
  {
    int score = 0;
    int cnt = 0;
    tie(score, cnt) = dfs(D, score, cnt, pat, p, c);

    // 足りない点数分の問を解く
    if (G > score)
    {
      repdm(k, D, 0)
      {
        if ((pat & 1 << (k - 1)) == 0)
        {
          int remain = ceil((float)(G - score) / (float)(100 * k));
          if (remain <= p[k])
          {
            cnt += remain;
            score += remain * 100 * k;
          }
          else
          {
            cnt += p[k];
            score += p[k] * 100 * k;
          }
        }
        if (score >= G)
          break;
      }
    }
    if (ans > cnt)
      ans = cnt;
  }
  cout << ans;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


INF = 10**18


def main():

    N = in_n()
    H = in_nl()

    dp = [INF] * N
    dp[0] = 0

    for i in range(N):
        if i + 1 < N:
            dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i] - H[i + 1]))
        if i + 2 < N:
            dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i] - H[i + 2]))

    print(dp[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 18248
#include <bits/stdc++.h>
    using namespace std;
// #include "prettyprint.hpp"
typedef long long ll;
typedef double db;

#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, MOD = 1e9 + 7, N = 1e5 + 5, LG = 20;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);

void test() {
    int x, n; cin >> x >> n;
    set<int> st;
    if (n == 0) {
        cout << x << "\n";
        return;
    }
    while (n--) {
        int k; cin >> k;
        st.insert(k);
    }
    int l, r, k = x, m =x;
    while (1) {
        if (st.find(k) == st.end()) {
            l = k;
            break;
        }
        --k;
    }
    while (1) {
        if (st.find(m) == st.end()) {
            r = m;
            break;
        }
        ++m;
    }
    // debug(l, r);
    if (x - l <= r - x) {
        cout << l << "\n";
    } else {
        cout << r << "\n";
    }
}

int main() {
      fast_io();
      #ifdef HOME
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
      #endif
      cout << fixed << setprecision(15);
      int t = 1;
      // cin >> t;
      for (int i = 1; i <= t; ++i) {
          test();
      }
      #ifdef HOME
          cout << "Time: " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << "ms";
      #endif
      return 0;
}


Measured memory_bytes: 3660
'use strict'

const main = (INPUT) => {
  const N = INPUT.split('\n')[0]
  if (N == 25) {
    console.log('Christmas');
  } else if (N == 24) {
    console.log('Christmas Eve');
  } else if (N == 23) {
    console.log('Christmas Eve Eve');
  } else if (N == 22) {
    console.log('Christmas Eve Eve Eve');
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 22076
#include<stdio.h>
#include<stdlib.h>
#define MAX 101
#define INF 100008

void initializeSingleSource();
void dijkstra();

int i,j,n,w,U,u[MAX],k[MAX],result=0,mincost,pi[MAX],color[MAX],d[MAX],c[MAX][MAX],v[MAX][MAX];

int main(){
  scanf("%d",&n);
  for(i=0 ; i<n ; i++){
    scanf("%d %d",&u[i],&k[i]);
    for(j=0 ; j<k[i] ; j++){
      scanf("%d %d",&v[i][j],&c[i][j]);
    }
  }

  dijkstra();

  for(i=0 ; i<n ; i++){
    printf("%d %d\n",u[i],d[i]);
  }
  return 0;
}


void initializeSingleSource(){
  for(i=0 ; i<n ; i++){
    d[i]=INF;
    color[i]=0;
   
  }
  d[0]=0;
}
void dijkstra(){
  initializeSingleSource();
  while(1){
    mincost=INF;
    for(i=0 ; i<n ; i++){
      if(color[i] != 1 && d[i] < mincost){
	mincost=d[i];
	U=i;
      }
    }
      if(mincost == INF)break;
      color[U]=1;

      for(w=0 ; w<k[U] ; w++){
	if(color[v[U][w]] != 1 && (d[U]+c[U][w]) < d[v[U][w]]){
	
	  d[v[U][w]]=d[U]+c[U][w];
	  }
      }
  }
}
	  

	       	  
 

Measured memory_bytes: 680
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(std::vector<T>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}

void DFS(int V,vector<vector<int> >&GRAPH,vector<int>&dist,int depth)
{
  dist[V] = depth;
  for (int i = 0; i < GRAPH[V].size(); i++)
  {
    if(dist[GRAPH[V][i]] == -1)
    {
      DFS(GRAPH[V][i],GRAPH,dist,depth+1);
    }
  }
  return;
}
void solve(void)
{
  int N;
  cin>>N;
  cout<<"ABC"<<N<<endl;
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if(y<r||x<r||W-x<r||H-y<r){
    cout<<"No"<<endl;}
    else{
    cout<<"Yes"<<endl;}
}



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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

bool is_prime[2000000];
vector<ll> primes;
bool is_fox_number[11000000];
int cnt[11000000];

void Sieve(){
	fill_n(is_prime,2000000,true);
	is_prime[0]=is_prime[1]=false;
	for(int i=2; i<2000000; ++i){
		if(is_prime[i]){
			primes.push_back(i);
			for(int j=i*2; j<2000000; j+=i) is_prime[j]=false;
		}
	}
}

void Solve(){
	Sieve();
	ll a,b,l,h;
	cin >> a >> b;
	l=max(a-b,2LL);
	h=a+b+1;

	fill_n(is_fox_number,11000000,true);
	fill_n(cnt,11000000,INF);

	for(auto p:primes){
		ll x=(l+p-1)/p*p;
		//if(x*x>h) break;
		while(x<h){
			if(!is_fox_number[x-l]){
				x+=p;
				continue;
			}
			
			ll tmp=x;
			int c=0;
			while(tmp%p==0){
				tmp/=p;
				++c;
			}

			if(c>cnt[x-l]) is_fox_number[x-l]=false;

			cnt[x-l]=c;
			x+=p;
		}
	}

	int ans=0;
	rep(i,0,h-l) ans+=is_fox_number[i];

	cout << ans << endl;
}

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

Measured memory_bytes: 58160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  
  vector<int> vec(N);
for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
 }
  int count = 0;
  for (int i = 0; i < N; i++) {
 if ((i+1) % 2 == 1 && vec.at(i) % 2 == 1)
   count++;
 }
  cout << count << endl;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


int N, W;
ll dp[105][100005];

void solve() {
    cin >> N >> W;
    vec v(N), w(N);
    rep(i, N) cin >> v[i] >> w[i];
    memset(dp, 0, sizeof(dp));
    rep(i, N){
        Rep1(j, 0, W){
            if(j < w[i]){
                dp[i+1][j] = dp[i][j];
            }else{
                dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i]);
            }
        }
    }

    cout << dp[N][W] << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}



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

int main() {
  long a,b,k; cin >> a >> b >> k;
  if(a-k>=0) cout << a-k << " " << b << endl;
  else if (a+b-k>=0) cout << 0 << " " << a+b-k << endl;
  else cout << 0 << " " << 0 << endl;
}


Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main() {
	string s;
	cin >> s;
	reverse(s.begin(), s.end());
	vector<string> d = { "dream","dreamer","erase","eraser" };
	for (int i = 0; i < 4; i++) {
		reverse(d[i].begin(), d[i].end());
	}
	int i = 0;
	bool ans = false;
	while( i < s.size()) {
		ans = false;
		for (int j = 0; j < 4; j++) {
			if (s.substr(i, d[j].size()) == d[j]) {
				i += d[j].size();
				ans = true;
			}
		}
		if (!ans)break;
	}

	if (ans) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

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

void solve();

int main()
{
  solve();

  return 0;
}

void solve()
{

  long n;
  cin >> n;

  cout << ((n % 1000) == 0 ? 0 : (1000 - (n % 1000))) << '\n';
}

Measured memory_bytes: 3632
object Main {
  val Rooms: Int = 10
  val Floors: Int = 3
  val Buildings: Int = 4
  val Separator: String = "#" * 20

  def main(args: Array[String]): Unit = {
    val info = Array.ofDim[Int](Buildings, Floors, Rooms)

    val scanner = new java.util.Scanner(System.in)
    val n = scanner.nextInt()
    Iterator.from(0, 1)
      .takeWhile(_ < n)
      .map { _ => (
        scanner.nextInt() - 1,
        scanner.nextInt() - 1,
        scanner.nextInt() - 1,
        scanner.nextInt()
      )}
      .foreach { case (b, f, r, v) => info(b)(f)(r) += v }

    info
      .zipWithIndex
      .flatMap { case (floors, i) =>
        val rooms = floors.map(" " + _.mkString(" "))(collection.breakOut)
        if (i == 0)
          rooms
        else
          Separator +: rooms
      }
      .foreach(println)
  }
}

Measured memory_bytes: 47896
/*
AizuOnline A0221
Title Fizzbuzz
@kankichi573
*/
#include <stdio.h>
#include <string.h>
int m,n;
int alive[1001];
char buf[100];
//
main()
{
        int i,person,pc,spf;

        while(EOF!=scanf("%d %d",&m,&n) && (m||n))
        {
               
                for(i=1;i<=m;i++)
                        alive[i]=-1;
                person=0;
                pc=m;
                for(i=1;i<=n;i++)
                {
                        do
                        {
                                person++;
                                if(person>m)
                                        person=1;
                        }while(alive[person]==0);
                        scanf("%s",buf);
                        //printf("%d %s %d\n",i,buf,person);
                        if((i%15)==0)
                        {
                                if(strcmp("FizzBuzz",buf))
                                {
                                        pc--;
                                        alive[person]=0;
                                        continue;
                                }
                        }
                        else if((i%5)==0)
                        {
                                if(strcmp("Buzz",buf))
                                {
                                        pc--;
                                        alive[person]=0;
                                        continue;
                                }

                        }
                        else if((i%3)==0)
                        {
                                if(strcmp("Fizz",buf))
                                {
                                        pc--;
                                        alive[person]=0;
                                        continue;
                                }
                        }
                        else 
                        {
                                if(atoi(buf) != i)
                                {
                                        pc--;
                                        alive[person]=0;
                                        continue;
                                }

                        }
                        if(pc==1)
                                break;
                }
                for(i=i+1;i<=n;i++)
                {
                        scanf("%s",buf);
                        //printf("SKIP:%d\n",i);
                }
                spf=0;
                for(i=1;i<=m;i++)
                {
                        if(alive[i])
                        {
                                if(spf)
                                        printf(" ");
                                spf=1;
                                printf("%d",i);
                        }
                }               
                printf("\n");
        }
        return(0);
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 6;
typedef long long ll;
#define INF 0x3f3f3f3f;

int main(){
	int k, x;
	int a, b;
	cin>>k>>x;
	a = x + k - 1;
	b = x - k + 1;
	for(int i = b; i < a; i ++){
		cout<<i<<' ';
	}
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 256
export class Main {
  static main(input): string {
    const [n, a, b]: number[] = input.split("\n")[0].split(" ").map(a => parseInt(a));
    const t: number = n * a;
    return `${Math.min(t, b)}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 7372
A,B,C=map(int,input().split())
L=[]
for i in range (C):
	if A+i>=A and A+i<=B:
		L.append(A+i)
	if B-i>=A and B-i<=B:
		L.append(B-i)
X=sorted(set(L))
for i in range (len(X)):
	print(X[i])

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			int a = Integer.parseInt(br.readLine());
			int b = Integer.parseInt(br.readLine());
			int c = Integer.parseInt(br.readLine());
			int d = Integer.parseInt(br.readLine());
			System.out.println(Math.min(a, b)+Math.min(c, d));

		}
	}
}

Measured memory_bytes: 25300
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

int main(){
ll n;
ll d,x;
cin>>n>>d>>x;
ll a;
ll sum=0;
for(int i=0;i<n;i++){
    cin>>a;
    ll tmp=0;;
    ll j=0;
    ll cnt=0;
    while(tmp<=d){
    tmp=a*j+1;
     j++;
     cnt++;
    }
    sum+=cnt-1;
}
cout<<sum+x<<endl;
}












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

using namespace std;

int stack[100];
int tail = 0;

void push(int v) {
	stack[tail++] = v;
}

int pop() {
	tail--;
	return stack[tail];
}

int main() {
	int v = 0, x, y;
	char c;
	while (scanf("%c", &c)) {
		if (c == '\n')
			break;
		if ('0' <= c && c <= '9') {
			v = v * 10 + (c - '0');
		}
		if (c == ' ') {
			push(v);
			v = 0;
		}
		if (c == '+' || c == '-' || c == '*') {
			y = pop();
			x = pop();
			if (c == '+')
				push(x + y);
			if (c == '-')
				push(x - y);
			if (c == '*')
				push(x * y);
			scanf("%c", &c);
		}
		
	}
	cout << pop() << endl;

	return 0;
}


Measured memory_bytes: 3152
import java.util.*;
public class Main{
	public static void main(String args[]) throws Exception {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt(),M=sc.nextInt();
		Map<Integer,Integer> m= new HashMap();
		for(int ii=0;ii<M;ii++){
			int i=sc.nextInt(),j=sc.nextInt();
			m.put(i, m.getOrDefault(i, 0)+1);
			m.put(j, m.getOrDefault(j, 0)+1);
		}
		for(int i=1;i<=N;i++){
			System.out.println(m.getOrDefault(i, 0));
		}
	}
}

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

#define ll long long
#define rep(i,x,y) for(double i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    double n,k; cin >> n >> k;
    double ans;
    rep(i,1,n+1){
        double shift=0;
        double hikaku = 1;
        while(k-i*hikaku > 0){
            hikaku *= 2;
            shift++;
        }
        ans += 1.0/pow(2.0,shift);
    }
    cout << setprecision(11) << ans/n << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int 
#define pb push_back 
#define mp make_pair 
#define pii pair <int , int > 
#define pll pair < ll , ll >
int main(){
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL) ;
	char a ;
    cin >> a ;
    if(a - 'A' >= 0 && a - 'A' < 26) cout << "A" ;
    else cout << "a" ;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define repr(i, a, b) for (int i = (int)a; i > (int)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 4e18 + 5;
const char ENDL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
typedef pair<int, pll> ppll;
inline bool comp1(ppll a, ppll b) { return a.S.F < b.S.F; }
inline bool comp2(ppll a, ppll b) { return a.S.S < b.S.S; }
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<ppll> ball1(n),ball2(n);
    rep(i,n){
        ll a, b;
        cin >> a >> b;
        if (a>b)
            swap(a, b);
        ball1[i] = ball2[i] = mp(i, mp(a, b));
    }
    sort(all(ball1), comp1);
    sort(all(ball2), comp2);
    ll ans = (ball1[n - 1].S.F - ball1[0].S.F) * (ball2[n - 1].S.S - ball2[0].S.S);
    if (ball1[0].F==ball2[n-1].F){
        cout << ans << ENDL;
        return 0;
    }
    ll kotei = ball2[n - 1].S.S - ball1[0].S.F;
    multiset<ll> have;
    have.insert(ball1[0].S.S);
    repf(i,1,n){
        have.insert(ball1[i].S.F);
    }
    //.fを.sにしていく
    auto itr = have.begin(), ittr = have.end();
    ittr--;
    ans = min(ans, kotei * (*ittr - *itr));
    repf(i,1,n){
        if (ball1[i].F==ball2[n-1].F)
            continue;
        have.erase(have.lower_bound(ball1[i].S.F));
        have.insert(ball1[i].S.S);
        itr = have.begin();
        ittr = have.end();
        ittr--;
        ans = min(ans, kotei * (*ittr - *itr));
    }
    cout << ans << ENDL;
}

Measured memory_bytes: 19072
#include <stdio.h>

int main (void) {
    int a, b, i;
    scanf("%d%d", &a, &b);

    if ( a <= b ) {
        for ( i = 0; i < b; i++ ) {
            printf("%d", a);
        }
        printf("\n");
    }
    else {
        for ( i = 0; i < a; i++ ) {
            printf("%d", b);
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 128