akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {


    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        long[] p = new long[n];
        long[] res = new long[n+1];
        Arrays.fill(res, Long.MAX_VALUE);
        for(int i=0; i<n; i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
            p[i] = sc.nextInt();
        }
        int pow = 1;
        for(int i=0; i<n; i++) {
            pow *= 3;
        }

        long[][] xmin = new long[n][1<<n];
        long[][] ymin = new long[n][1<<n];

        for(int i=0; i<(1<<n); i++) {
            for(int j=0; j<n; j++) {
                xmin[j][i] = Math.abs(x[j]) * p[j];
                ymin[j][i] = Math.abs(y[j]) * p[j];
                for(int k=0; k<n; k++) {
                    if((i>>k)%2==1) {
                        xmin[j][i] = Math.min(xmin[j][i], Math.abs(x[j]-x[k])*p[j]);
                        ymin[j][i] = Math.min(ymin[j][i], Math.abs(y[j]-y[k])*p[j]);
                    }
                }
            }
        }

        for(int i=0; i<pow; i++) {
            long sum = 0;
            int[] nums = new int[n];
            int ii = i;
            int xi = 0;
            int yi = 0;
            int bits = 0;
            for(int j=0; j<n; j++) {
                int num = ii%3;
                if(num == 1) {
                    xi += (1<<j);
                    bits++;
                } else if (num == 2) {
                    yi += (1<<j);
                    bits++;
                }
                ii/=3;
            }
            for(int j=0; j<n; j++) {
                sum += Math.min(xmin[j][xi], ymin[j][yi]);
            }
            res[bits] = Math.min(res[bits], sum );
        }

        for(int i=0; i<=n; i++) {
            System.out.println(res[i]);
        }


    }
}

Measured memory_bytes: 62836
#include "bits/stdc++.h"
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b;
  if (a>=13) {
      c=b;
  }else if(a>=6&&a<=12) {
      c=b/2;
  } else {
      c=0;
  }
  cout << c << endl;
  return 0;
}

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

int gcd(int x, int y)
{
    int r;
    if (x < y)
        swap(x, y);
    while (y > 0)
    {
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }

    //要素の数N+1、初期値を0に指定
    vector<int> left(N + 1, 0), right(N + 1, 0);
    //累積GCD(左と右)
    for (int i = 0; i < N; i++)
    {
        left[i + 1] = gcd(left[i], a[i]);
    }
    for (int i = N - 1; i >= 0; i--)
    {
        right[i] = gcd(right[i + 1], a[i]);
    }

    int res = 0;
    for (int i = 0; i < N; i++)
    {
        //左
        int l = left[i];
        //右
        int r = right[i + 1];
        //最大公約数の更新
        res = max(res, gcd(l, r));
    }
    cout << res << endl;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main()
{
int a, b, c;
 
scanf ("%d", &a);
printf ("%d", a/3600);
 
b = a%3600;
printf(":%d:", b/60);
 
c = b%60;
printf ("%d\n", c);
 
return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    string s;
    cin >> s;

    int x[3];
    rep(i, 3) {
        x[i] = s[i+1] - '0';
    }

    char op[3];
    for(int b = 0; b < (1 << 3); b++) {
        int num = s[0] - '0';

        rep(i, 3) {
            if( b & (1 << i) ) {
                op[i] = '+';
                num += x[i];
            }
            else {
                op[i] = '-';
                num -= x[i];
            }
        }

        if(num == 7) {
            cout << s[0];
            rep(i, 3) {
                cout << op[i] << s[i+1];
            }
            cout << '=' << '7' << endl;
            return 0;
        }
    }

}

Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}


a,b=map(int,input().split())
print(a*b-a-b+1)

Measured memory_bytes: 2940
using System;

namespace ABC177
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            if (int.Parse(input[0]) > int.Parse(input[1]) * int.Parse(input[2]))
                System.Console.WriteLine("No");
            else
                System.Console.WriteLine("Yes");
            Console.Read();
        }
    }
}


Measured memory_bytes: 27460
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	int ans=1;
	if(m%n==0){
		printf("%d\n",m/n);
	}else{
		int ans=1;
		int y=sqrt(m);
		for(int i=1;i<=y;i++){
			if(m%i==0){
				if(i>=n){
					ans=max(ans,m/i);
				}
				if(m/i>=n){
					ans=max(ans,i);
				}
			}
		}
		printf("%d\n",ans);
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
int main(){
    int A,B;
    cin >> A >> B;
    int ans = 0;
    for(int i=A; i<=B; i++){
        string S = to_string(i);
        bool flg = true;
        for(int i=0; i<S.size(); i++){
            if(S[i] != S[S.size()-i-1]) flg = false;
        }
        if(flg == true) ans++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
arr = [int(n) for n in input().split()]
n_operation = 0
possible = True
while possible:
    for i, n in enumerate(arr):
        if n % 2 == 1:
            possible = False
            break
        arr[i] /= 2
    else:
        n_operation += 1
print(n_operation)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
using namespace std;
using ll = long long;
struct Graph {
    Graph(const int n)
    {
        edge.resize(n);
    }
    void addEdge(const int from, const int to)
    {
        edge[from].push_back(to);
    }
    vector<vector<int>> edge;
};

constexpr ll MOD1 = 1e9 + 7;
constexpr ll MOD2 = 1e9 + 9;
constexpr ll BASE1 = 1e6 + 7;
constexpr ll BASE2 = 1e6 + 9;
using P = pair<ll, ll>;
map<P, int> num;

P dfs(const Graph& g, const int s, vector<bool>& used)
{
    used[s] = true;
    P ans = {1, 1};
    for (const int to : g.edge[s]) {
        if (not used[to]) {
            const P sub = dfs(g, to, used);
            (ans.first += sub.first * BASE1) %= MOD1;
            (ans.second += sub.second * BASE2) %= MOD2;
        }
    }
    num[ans]++;
    return ans;
}

int main()
{
    int N;
    cin >> N;
    Graph g(N);
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g.addEdge(a, b);
        g.addEdge(b, a);
    }
    vector<bool> used(N, false);
    dfs(g, 0, used);
    ll ans = 0;
    for (const auto& e : num) {
        const ll n = e.second;
        ans += (n * (n - 1)) / 2;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 22348
/* by Natsu Kinmoe */
#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define loop(i,n) for(int i=0;i<(n);i++)
#define cont(i,n) for(int i=1;i<=(n);i++)
#define circ(i,a,b) for(int i=(a);i<=(b);i++)
#define range(i,a,b,c) for(int i=(a);((c)>0?i<=(b):i>=(b));i+=(c))
#define foreach(it,v) for(__typeof((v).begin()) it=(v).begin(),_e_D_=(v).end();it!=_e_D_;it++)
#define y0 y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1 y1II11II11III11I1III11II111IIII1II1I1
#define pub push_back
#define pob pop_back
#define mak make_pair

typedef long long ll;
typedef long double lf;
const int Inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3fll;
/* Source code starts here */

struct BinIdxTree{
	ll dt[1<<18];
	void add(int a,ll x){
		while(a<(1<<18)){
			dt[a]+=x;
			a+=a&-a;
		}
	}
	ll sum(int a){
		ll res=0;
		while(a){
			res+=dt[a];
			a-=a&-a;
		}
		return res;
	}
}bit;

int n,d,a;
pair<ll,ll> g[1<<18];
ll ans=0;

int main(){
	scanf("%d%d%d",&n,&d,&a);
	cont(i,n)scanf("%lld%lld",&g[i].first,&g[i].second);
	sort(g+1,g+n+1);
	cont(i,n){
		ll tm=(g[i].second-bit.sum(i)+a-1)/a;
		if(tm<=0)continue;ans+=tm;
		ll lim=g[i].first+2ll*d;
		int rpos=upper_bound(g+1,g+n+1,mak(lim,INF))-g;
		bit.add(i,tm*a);
		bit.add(rpos,-tm*a);
	}
	return 0&printf("%lld\n",ans);
}

Measured memory_bytes: 8472
w, h, n = map(int, input().split())
nurie = [list(map(int, input().split())) for _ in range(n)]
ans = [0, w, 0, h]
for nu in nurie:
    if nu[2] == 1:
        ans[0] = max(ans[0], nu[0])
    elif nu[2] == 2:
        ans[1] = min(ans[1], nu[0])
    elif nu[2] == 3:
        ans[2] = max(ans[2], nu[1])
    else:
        ans[3] = min(ans[3], nu[1])
print(max(0, ans[1]-ans[0])*max(0, ans[3]-ans[2]))


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int tp=0;
  int xp=0;
  int yp=0;
  bool f=1;
  for(int _=0;_<n&&f;_++){
    int t,x,y;
    cin>>t>>x>>y;
    int dt=abs(t-tp);
    int dx=abs(x-xp);
    int dy=abs(y-yp);
    if(dx+dy>dt||(dx+dy)%2!=dt%2)
      f=0;
    tp=t;
    xp=x;
    yp=y;
  }
  cout<<(f?"Yes":"No")<<endl;
}

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

int main(){
  string s;
  cin>>s;
  int ans=0;
  rep(i,3)if(s[i]=='1')ans++;
  cout<<ans<<endl;
  return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
    string s;cin>>s;
    bool sw=false;
    REP(i,3)
    {
     if (s[i]==s[i+1])
     {
         /* code */
         sw=true;
     }
     
     
    }
    if (sw)
    {
        /* code */
        cout<<"Bad"<<endl;
    }
    else
    {
        cout<<"Good"<<endl;
    }
    
    
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};


int main(){
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i, m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    uf.unite(a, b);
  }
  int ans=0;
  rep(i, n){
    ans=max(ans, uf.size(i));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4052
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 2e5 + 5;
const ll MOD = 1e9 + 7;
int N, M, Q, T;
ll K;
ll A[MAXN], B[MAXN];

int main() {
	int i, j;
	scanf("%d%lld", &N, &K);
	for (i = 1; i <= N; ++i) {
		scanf("%lld", &A[i]);
	}
	for (i = 1; i <= N; ++i) {
		scanf("%lld", &B[i]);
	}
	sort(A + 1, A + 1 + N);
	sort(B + 1, B + 1 + N);
	reverse(B + 1, B + 1 + N);
	ll l = 0ll;
	ll h = A[N] * B[1];
	ll ans = -1ll;
	while (l <= h) {
		ll m = (l + h) >> 1;
		int j = 1;
		ll ck = 0ll;
		for (i = 1; i <= N; ++i, ++j) {
			if (B[i] > m) {
				ck += A[j];
			}
			else {
				if(A[j]*B[i] > m) ck += (ll)ceil(((double)A[j] - ((double)m/(double)B[i])));
			}
		}
		if (ck <= K) {
			ans = m;
			h = m - 1;
		}
		else l = m + 1;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 3328
//
// Created by Debajyoti Dasgupta on 11-04-2020.
//

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define fr(i, n) for(int i=0;i<n;i++)
#define frr(i, n) for(int i=n;i>=0;i--)
#define fra(i, a, n) for(int i=a;i<n;i++)
#define frra(i, a, n) for(int i=a;i>=n;i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define ff first
#define ss second
#define endl '\n'

typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef set<int> si;
typedef unordered_map<int, int> uii;
typedef unordered_set<int> usi;
typedef vector<int> vi;

const int mod = 1e9 + 7;
const int MAXN = 1e5 + 5;
const int inf = LONG_LONG_MAX;

using point = pair<pii, pii>;

void solve() {
    //CODE BEGIN
    int n;
    cin >> n;
    int x = n / 3, y = n / 5, z = n / 15;
    int ans = n * (n + 1) / 2 - 3 * x * (x + 1) / 2 - 5 * y * (y + 1) / 2 + 15 * z * (z + 1) / 2;
    cout << ans << endl;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
//    cin >> t;
    for (int i = 0; i < t; ++i) {
//        cout << "Case #" << i + 1 << ": " << endl;
        solve();
    }
    return 0;
}

Measured memory_bytes: 3612
H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))
ans = [[0]*W for _ in range(H)]
b = [0]*(H*W)
now = 0
for i in range(N):
  for j in range(A[i]):
    b[now+j] = i+1
  now += A[i]
for h in range(H):
  for w in range(W):
    if h%2==0:
      ans[h][w] = b[W*h+w]
    else:
      ans[h][w] = b[W*(h+1)-w-1]
for a in ans:
  print(*a)

Measured memory_bytes: 74460
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;


int n;
string s[300000];
int main()
{
    cin>>n;
    int res=0;
    for (int i=0; i<n; ++i)
        cin>>s[i];
    sort(s+0,s+n);
    if (n>0) res=1;
    for (int i=1; i<n; ++i)
        if (s[i]!=s[i-1])
            res++;
    cout<<res<<endl;
    return 0;
}



Measured memory_bytes: 12988
import re


S_ = input()
T = input()

S_ = S_[::-1]
T = T[::-1]

t = ''
for c in T:
    t += '[?' + c + ']'
regex = re.compile(t)

S, cnt = regex.subn(T, S_, count=1)
if cnt:
    S = S.replace('?', 'a')
    print(S[::-1])
else:
    print('UNRESTORABLE')


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

def f(b,n):
  if n < b:
    return n
  return f(b,n//b) + n%b


def solve(n,s):
  if s > n:
    return -1
  if s == n:
    return n+1
  nsq = int(n**0.5 + 1)
  for b in range(2,nsq+1):
    if f(b,n) == s:
      return b
  # 2桁で作れるかどうか
  # n = bx+y, s = x+y, x,y < b
  # n - s = (b-1)x, x < b
  m = n-s
  msq = int(m**0.5+1)
  for x in range(msq,0,-1):
    if m%x:
      continue
    b = m//x+1
    if f(b,n) == s:
      return b
  return -1
  
answer = solve(n,s)
print(answer)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#include<deque>
#include<tuple>
#include<stdio.h>
#include<iomanip>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;

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

int main(){
	int n;
	cin>>n;
	vector<int> v;
	int a, b=0;
	rep(i, n){
		cin>>a;
		v.push_back(a);
		b=max(a, b);
	}
	rep(i, v.size()){
		b=min(gcd(v[i], b), b);
	}
	cout<<b<<endl;
	return 0;
}

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main()
{
    int x, y;
    cin >> x >> y;

    if(x==2 && y==2) cout << "Yes" << endl;
    else if((x==4 || x==6 || x==9 || x==11 ) && (y==4 || y==6 || y==9 || y==11 )) cout << "Yes" << endl;
    else if((x==1 || x==3 || x==5 || x==7 || x==8 || x==10 || x==12) && (y==1 || y==3 || y==5 || y==7 || y==8 || y==10 || y==12)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
n,y=map(int,input().split())
y=y/1000
count=0
for i in range(min(int(y/10),n)+1):
    for j in range(min(int((y-10*i)/5),n-i)+1):
        if 10*i+5*j+n-i-j==y:
            print(str(i)+" "+str(j)+" "+str(n-i-j))
            count=1
            break
        elif 10*i+5*j+n-i-j>y:
            break
    if count==1:
        break
if count==0:
    print("-1 -1 -1")

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

const char fig[] = { 'm', 'c', 'x', 'i' };

int main() {

	int n;
	int mcxi[4] = { };
	string s;
	char c;
	int pos;

	cin >> n;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < 2; ++j) {
			cin >> s;
			for (int k = s.size() - 1; k >= 0; --k) {
				c = s.at(k);
				switch (c) {
				case 'm':
					mcxi[0]++;
					pos = 0;
					break;
				case 'c':
					mcxi[1]++;
					pos = 1;
					break;
				case 'x':
					mcxi[2]++;
					pos = 2;
					break;
				case 'i':
					mcxi[3]++;
					pos = 3;
					break;
				default:
					if (c != ' ') {
						mcxi[pos] += c - '1';
					}
					break;
				}
			}
		}
		// carry up
		for (int j = 3; j >= 0; --j) {
			if (mcxi[j] > 9) {
				mcxi[j] -= 10;
				mcxi[j - 1]++;
			}
		}
		// output
		for (int j = 0; j < 4; ++j) {
			if (mcxi[j] == 1) {
				cout << fig[j];
			} else if (mcxi[j] > 1) {
				cout << mcxi[j] << fig[j];
			}
			mcxi[j] = 0; // initialize
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,m,n) for (int i = m; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b;}
template<class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b;}
template<class T> void drop(const T &x) { std::cout<<x<<endl; exit(0);}
void debug_out() { std::cout << "\n";}
template<class T, class... Args> void debug_out(const T &x, const Args &... args) { std::cout<<x<< " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

struct InitIO{
  InitIO() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
  }
}init_io;

int main() {
  int n;
  cin >> n;
  vector<ll> cnt(n+1);
  rep2(i, 1, n+1) {
    for (int j = i; j <= n; j += i) cnt[j]++;
  }
  ll ans = 0;
  rep2(i, 1, n+1) {
    ans += cnt[i] * i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 81344
#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>

#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



#include <array>
#include <iterator>



using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl;
typedef pair < int, int> P;


int A, B;
int main() {
	cin >> A >> B;
	int tap = A - 1;
	int res = B;
	int ans = 1;
	res -= A;
	while (res > 0) {
		res -= tap;
		ans++;
	}
	if (B == 1) {
		cout << 0 << endl;
	}
	else {
		cout << ans << endl;
	}
	
}

Measured memory_bytes: 256
import sys
from operator import itemgetter

read = sys.stdin.read

N, M, *PY = map(int, read().split())
P = PY[::2]
Y = PY[1::2]

P, Y, I = zip(*sorted(zip(P, Y, range(M)), key=itemgetter(0, 1)))
P = list(map(str, P))
answer = []
prev_p = ''
n = 0
for p, i in zip(P, I):
    if prev_p == p:
        n += 1
    else:
        prev_p = p
        n = 1
    answer.append((p.zfill(6) + str(n).zfill(6), i))

answer.sort(key=itemgetter(1))
answer = [i for i, _ in answer]
print('\n'.join(answer))


Measured memory_bytes: 46044
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_ll.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Bll = mp::cpp_ll; //任意長整数 
using Real32 = mp::number<mp::cpp_dec_float<32>>;
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
using Rat = boost::rational<Bll>;//有理数*/
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
typedef pair<ll,ll> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);

// 各桁の和を計算する関数(drkenさんの)

ll fsd(ll n) {
  ll sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}


signed main(){
    ll k,sn=1,add=1;
    cin>>k;
    for (ll i = 1; i <= k; i++)
    {
        cout<<sn<<endl;

        if((double)sn/fsd(sn)<(double)(sn+add)/fsd(sn+add) && (double)(sn+add)/fsd(sn+add) > (double)(sn+2*add)/fsd(sn+2*add)){
            add*=10;
        }

        sn+=add;

    }
}
   

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e3 + 5;
ll f[N][N];
pair<int, int> p[N];
ll cal(int cnt, int l, int r) {
    if(l > r) return 0;
    if(~f[l][r]) return f[l][r];
    ll ans = 1LL * p[cnt].first * abs(p[cnt].second - l) + cal(cnt + 1, l + 1, r);
    ans = max(ans, 1LL * p[cnt].first * abs(p[cnt].second - r) + cal(cnt + 1, l, r - 1));
    return f[l][r] = ans;
}
int main() {
    int n;
    scanf("%d", &n);
    for(int i = 1, x; i <= n; i++) {
        scanf("%d", &x);
        p[i] = {x, i};
    }
    sort(p + 1, p + n + 1,[](pair<int, int> a, pair<int, int> b) {
        return a.first > b.first;
    });
    memset(f, -1, sizeof f);
    printf("%lld\n", cal(1, 1, n));
    return 0;
}


Measured memory_bytes: 35312
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
#define NUM 100000
#define INF 1000000000


int main(void){
    int n;
    int a[NUM];
    int length = 0;

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

    int A[NUM];
    for(int i = 0; i < n; i++){
        A[i] = INF;
    }

    for(int i = 0; i < n; i++){
        int* t = upper_bound(A, A + length, a[i] - 1);
        *t = a[i];
        if (A[length] != INF){
            length++;
        }
        /*
        for(int i = 0; i < length; i++){
            printf(" %d", A[i]);
        }
        printf("\n");
        */
            
    }
    
    printf("%d\n", length);
}



Measured memory_bytes: 3948
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;

const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};



int main(){
    string s;
    cin >> s;
    string S = s;
    reverse(s.begin(),s.end());
    int ans = 0;
    rep(i,S.length()){
        if (S[i]!=s[i]){
            ans++;
        }
    }
    cout << ans/2;
}































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

int main(){
  int n,k,a[8888],dp[8888];

  scanf("%d%d",&n,&k);
  for(int i=0;i<n;i++)scanf("%d",&a[i]);

  int ans = 0;
  for(int i=0;i<n;i++){
    if(a[i]<i)continue;
    for(int j=0;j<n;j++)dp[j] = 1e8;
    for(int j=i;j<a[i];j++){
      if(a[i]<a[j])*lower_bound(dp,dp+n+1,a[j]) = a[j];
    }
    ans = max(ans, (int)(lower_bound(dp,dp+n+1,1e8) - dp));
    if(ans+1+k>=n/2){ printf("%d\n",n/2); return 0; }
  }
  printf("%d\n",ans+1+k);
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

LL n;
vector<LL> a;
map<pair<LL,LL>,LL> dic;

LL solve(LL i, LL w, LL mode)
{
  if(dic.count(make_pair(i*mode,w))) return dic[make_pair(i*mode,w)];
  LL answer = mode*abs(w-a[n-1]);
  FOR(j,i,n-1) answer = max(answer, mode*solve(j+1,a[j],-mode));
  answer *= mode;
  dic[make_pair(i*mode,w)] = answer;
  return answer;
}

int main(void)
{
  LL z,w;
  cin >> n >> z >> w;
  a.resize(n);
  for(LL &x:a) cin >> x;
  cout << solve(0,w,1) << endl;
}


Measured memory_bytes: 768
import numpy as np

n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split()))

p = np.array(sorted(p))
n_under_a = len(p[p<=a]) #値がa以下の個数
n_under_b = len(p[p<=b])-n_under_a #a<x<=bの個数
n_over_b = len(p[p>b]) #x>bの個数

print(min(n_under_a, min(n_under_b, n_over_b)))




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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var sums = new Dictionary<long, long>();
            var tmp = (long)0;
            var result = (long)0;
            foreach (var i in Enumerable.Range(0, N))
            {
                tmp += A[i];
                if (tmp == 0) result++;
                long hoge;
                if(sums.TryGetValue(tmp, out hoge))
                {
                    sums[tmp] = hoge + 1;
                }
                else
                {
                    sums[tmp] = (long)1;
                }
            }

            foreach(var t in sums)
            {
                if (t.Value < 2) continue;
                result += t.Value * (t.Value - 1) / 2;
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 42540
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg,x.ed
#define rall(x) x.rbg,x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    ll n,m,k; cin >> n >> m >> k;
    vc<ll> a(n+1,0),b(m+1,0);
    rep(i,n){
        int x; cin >> x;
        a[i+1] = a[i]+x;
    }
    rep(i,m){
        int x; cin >> x;
        b[i+1] = b[i]+x;
    }
    ll ans = 0;
    rep(i,n+1){
        ll x = k-a[i];
        if(x < 0) break;
        ll num = upper_bound(all(b), x) - b.begin() - 1;
        chmax(ans,i+num);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int ans = 1;
  for (int i = 0; i < N; i++) {
    if (ans < K) ans *= 2;
    else ans += K;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long T = sc.nextLong();

        long sum = 0;
        long t0 = Long.MIN_VALUE;
        for (int i = 0; i < N; i++) {
            long t1 = sc.nextLong();
            if(t0 + T <= t1){
                sum += T;
            } else {
                sum += t1 - t0;
            }
            t0 = t1;
        }
        out.println(sum);
    }
}

Measured memory_bytes: 61456
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);
 
    private void solve(Scanner sc) {
        int N = sc.nextInt();
        int[] a = new int[3 * N];
        for (int i = 0; i < 3 * N; ++i) {
            a[i] = sc.nextInt();
        }
 
        Queue<Integer> q1 = new PriorityQueue<>();
        long[] sum1 = new long[N + 1];
        for (int i = 0; i < N; ++i) {
            q1.offer(a[i]);
            sum1[0] += a[i];
        }
 
        Queue<Integer> q2 = new PriorityQueue<>(Collections.reverseOrder());
        long[] sum2 = new long[N + 1];
        for (int i = 2 * N; i < 3 * N; ++i) {
            q2.offer(a[i]);
            sum2[0] += a[i];
        }
 
        for (int k = N; k < 2 * N; ++k) {
            q1.offer(a[k]);
            int t1 = q1.poll();
            sum1[k - N + 1] = sum1[k - N] + a[k] - t1;
 
            q2.offer(a[3 * N - k - 1]);
            int t2 = q2.poll();
            sum2[k - N + 1] = sum2[k - N] + a[3 * N - k - 1] - t2;
        }
 
        long max = Long.MIN_VALUE;
        for (int i = 0; i <= N; ++i) {
            max = Math.max(max, sum1[i] - sum2[N - i]);
        }
        _out.println(max);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 100092
#include <bits/stdc++.h>
using namespace std;
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define fr(i,n) for(int i=0;i<(n);++i)
#define frI(i,a,n) for(int i=a;i<=(n);++i)
#define frD(i,a,n) for(int i=a;i>=(n);--i)

//using namespace std;
using ll = long long;
using ld = long double;
#define len(x) ((int)x.length())
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
const int MOD = 1e9+7,inf = 1e9 , N = 2e5 + 1;
const ll INF = 1e18; ld tic,tac;
#define endl '\n'
ll dp[101][100001];
ll ans(ll w[],ll v[], int i, ll remsum,ll n)
{
    if(dp[i][remsum]!=-1)
    {
        return dp[i][remsum];
    }
    if(i>=n)
    {
        return dp[i][remsum]=0;
    }
    ll ans1,ans2;
    if(w[i]>remsum)
    ans1=0;
    else
    ans1=v[i]+ans(w,v,i+1,remsum-w[i],n);
    ans2=ans(w,v,i+1,remsum,n);
    return dp[i][remsum]=max(ans1,ans2);
}
void solve()
{
    ll n,totw;
    cin>>n>>totw;
    ll w[n],v[n];
    for(int i=0;i<n;i++)
    {
        cin>>w[i]>>v[i];
    }
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=totw;j++)
            dp[i][j]=-1;
    }
    ll a=ans(w,v,0,totw,n);
    cout<<a<<endl;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
   // cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 82496
#include <iostream>

using namespace std;


int main(){
    
    int n, m;
    int a[100][100], b[100];
    int c[100]={0};

    cin >> n >> m;

    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin >> a[i][j];
        }
    }
    for(int j=0; j<m; j++){
        cin >> b[j];
    }

    for(int row=0; row<n; row++){
        for(int col=0; col<m; col++){
            c[row]+=a[row][col]*b[col];
        }
    }

    for(int row=0; row<n; row++){
        cout << c[row] << endl;
    }

    return 0;
}




Measured memory_bytes: 3128
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <array>
#include <cmath>
#include <queue>
#include <stack>
#include <numeric>

using namespace std;


int main() {
	int x1,x2,x3,x4,x5;
	cin >> x1 >> x2 >> x3 >> x4 >> x5;
	if (x1 != 1)cout << 1;
	if (x2 != 2)cout << 2;
	if (x3 != 3)cout << 3;
	if (x4 != 4)cout << 4;
	if (x5 != 5)cout << 5;

}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1e09+7;



#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back




int main(){
  
  int n,x,y;
  cin>>n>>x>>y;
  
  vi cnt(n,0);
  
  for (int i=1;i<=n;i++){
    for (int j=i+1;j<=n;j++){
      int dis;
      if (i<=x and j<=x){
        dis=j-i;
        cnt.at(dis)++;
      }
      else if (i<=x and x<j and j<y){
        dis=(x-i)+min(j-x,1+y-j);
        cnt.at(dis)++;
      }
      else if (i<=x and j>=y){
        dis=(x-i)+1+(j-y);
        cnt.at(dis)++;
      }
      else if (x<i and i<y and x<j and j<y){
        dis=min(j-i,(i-x)+1+(y-j));
        cnt.at(dis)++;
      }
      else if (x<i and i<y and j>=y){
        dis=(j-y)+min(y-i,i-x+1);
        cnt.at(dis)++;
      }
      else if (i>=y and j>=y){
        dis=j-i;
        cnt.at(dis)++;
      }
    }
  }
  
  for (int i=1;i<=n-1;i++){
    cout<<cnt.at(i)<<endl;
  }

  
}




















Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    ll x, k, d;
    scanf("%lld%lld%lld", &x, &k, &d);

    double lim0 = (double)x - (double)k * d;
    double lim1 = (double)x + (double)k * d;
    if (lim0 > 0) {
        printf("%lld\n", x - k * d);
    }
    else if (lim1 <= 0) {
        printf("%lld\n", abs(x + k * d));
    }
    else {
        x = abs(x);
        if (k % 2) {
            k++;
            x += d;
        }

        ll tmp = x % (d * 2);
        ll tmp2 = tmp - (d * 2);
        if ((x-tmp2)/(d*2)<=k) {
            tmp = MIN(tmp, abs(tmp2));
        }
        printf("%lld\n", tmp);
    }

    return;
}

int main()
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for (t = 0; t < T; t++) {
        //printf("Case #%d: ", t + 1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 1736
#include <stdio.h>

int main()
{
    char a[5];
    scanf("%s", a);
    
    if(a[0]=='R'){ // R XX
        if(a[1]=='R'){  // RR X
            if(a[2]=='R'){  // RRR
                printf("3");
            }
            else    // RRS
                printf("2");
        }
        else{   // RS X
            if(a[2]=='R')   // RSR
                printf("1");
            else        // RSS
                printf("1");
        
        }
    }
    else{           // S XX
        if(a[1]=='R'){  // SR X
            if(a[2]=='R')   // SRR
                printf("2");
            else    // SRS
                printf("1");
        }
        else{   // SS X
            if(a[2]=='R')   // SSR
                printf("1");
            else    // SSS
                printf("0");
        }
    }
}

Measured memory_bytes: 1664
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

int n, a[100005], maxa, cnt[100005][2], mx[2], mx2[2];

int main(){
	getint(n), maxa = 0;
	for(register int i = 1; i <= n; i++) getint(a[i]), maxa = max(maxa, a[i]), cnt[a[i]][i & 1]++;
	for(register int k = 0; k <= 1; k++)
		for(register int i = 1; i <= maxa; i++)
			if(!mx[k] || cnt[i][k] > cnt[mx[k]][k]) mx[k] = i;
	if(mx[0] != mx[1]) return printf("%d\n", n - cnt[mx[0]][0] - cnt[mx[1]][1]), 0;
	for(register int k = 0; k <= 1; k++)
		for(register int i = 1; i <= maxa; i++)
			if(i != mx[k] && (!mx2[k] || cnt[i][k] > cnt[mx2[k]][k])) mx2[k] = i;
	printf("%d\n", n - max(cnt[mx[0]][0] + cnt[mx2[1]][1], cnt[mx2[0]][0] + cnt[mx[1]][1]));
	return 0;
}

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

int main()
{
int i;
int N;
int D;
int X;
int A;
int iSum;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	cin >> D;
	cin >> X;

	iSum = 0;
	for( i = 0; i < N; i++ )
	{
		cin >> A;
		iSum += ( ( D - 1 ) / A ) + 1;
	}

	cout << iSum + X << endl;

	return 0;
}






Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int x, y;
    while (true)
    {
        cin >> x >> y;
        if (x == 0 && y == 0)
            break;
        if (x < y)
        {
            cout << x << " " << y << endl;
        }
        else
        {
            cout << y << " " << x << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 2984
/*
 *
 * 線形探索
 * 番兵
 *
 *
 */
#include<stdio.h>

#define MAX_N 10000
#define MAX_Q 500

int main(void){

    int i, j, key, sum, s_n, t_n, s[MAX_N], t[MAX_Q];

    scanf("%d",&s_n);
    for(i=0; i<s_n;i++){
        scanf("%d", &s[i]);
    }

    scanf("%d",&t_n);
    for(i=0; i<t_n;i++){
        scanf("%d", &t[i]);
    }

    sum = 0;
    for(i=0;i<t_n;i++){
        key = t[i];
        for(j=0;j<s_n;j++){
            if(s[j] == key){
                sum++;
                break;
            }
        }
    }

    printf("%d\n", sum);
   
    return 0;
}



Measured memory_bytes: 2128
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;
 
 
const int MAX_N = int(1e6) + 10;
long long int MOD=1e9+7;
const long long int INF=1e18;
 
typedef long long int ll;
typedef unsigned long long int llu;
 
 
 
inline ll mul(ll a,ll b){
 
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll c=a*b;
    c=(c+MOD)%MOD;
    return c;
}
inline ll add(ll a,ll b){
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll ans=(a+b);
    ans=(ans+MOD)%MOD;
    return ans;
}
ll power(ll a,ll b,ll c=0){
    ll ans=1;
    while(b){
        if(b&1){
            ans=mul(ans,a);
        }
        a=mul(a,a);
        b=b/2;
    }
    return ans;
}
 
  
 
 
#define all(x) (x).begin(),(x).end()
 
 
 
 
//s.reserve(32768); //updated !
//s.max_load_factor(0.25);

const int N=1e5+5;







int main(){

    int n;
    ll D;
    cin>>n>>D;
    int cnt=0;
    for(int i=1;i<=n;i++){
        ll x,y;
        cin>>x>>y;
        if(x*x+y*y<=D*D){
            cnt++;
        }
    }

    cout<<cnt<<endl;


}
 
    
 
 
 
    
 
 
 
    
    
    
 
 
 
 
    
 
 
    
 
    
 
 
 
 
 
 
    
    
 
    
 
    
 
 
 
 
    
 


Measured memory_bytes: 3628
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
const int N = 1000000;
const ll INF = std::numeric_limits<long long>::max();
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define sz size
string YN(bool b) { return(b ? "YES" : "NO"); }
string yn(bool b) { return(b ? "Yes" : "No"); }
int main() {
	string s, ss, sss;
	cin >> s >> ss >> sss;
	cout<<YN(s[s.size()-1]==ss[0]&&ss[ss.size()-1]==sss[0])<<endl;
	return 0;
}

Measured memory_bytes: 256
X = int(input())
answer = 1
sq = []
for i in range(2, 32):
    for j in range(2, 11):
        if i**j <= 1000:
            sq.append(i**j)
sq.sort()
for i in range(2, X+1):
    if i in sq:
        answer = i
# print(sq)
print(answer)

Measured memory_bytes: 3060
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
#define LL long long
int h,w,n,cnt;
LL k,ans,p;
int ask(int a,int b,int c,int d){
	cout<<"? "<<a<<" "<<b<<" "<<c<<" "<<d<<"\n"<<flush;
	int res;
	cin>>res;
	return res;
}
int main() {
	cin>>h>>w>>n>>k;
	p=1;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			int flag=ask(i,j,i,j);
			cnt+=flag;
			if(flag)ans=(ans+p)%k;
			if(cnt==n)break;	
			p=p*2%k;
		}
	}
	cout<<"! "<<ans<<"\n"<<flush;
    return 0;
}

Measured memory_bytes: 720
def max(a,b); a > b ? a : b; end

N, C = gets.split.map(&:to_i)
I = N.times.map{gets.split.map(&:to_i)}

L = Array.new(N + 1, 0)
R = Array.new(N + 1, 0)

(1 .. N).inject(0) do |sum, n|
  d, v = I[n - 1]
  L[n] = max(sum + v - d, L[n - 1])
  sum + v
end

(1 .. N).inject(0) do |sum, n|
  x, v = I[N - n]
  d = C - x
  R[n] = max(sum + v - d, R[n - 1])
  sum + v
end

puts [  L[N], # 時計回り最大
        R[N], # 反時計回り最大
        (1 .. N).map{|n| L[n] + R[N - n] - I[n - 1][0] }.max, # 時計回り + 反転の最大
        (1 .. N).map{|n| R[n] + L[N - n] - (C - I[N - n][0]) }.max  # 反時計回り + 反転
      ].max


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int main(int argc, char **argv) {
	ll a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	cout << (abs(a-b) <= (v-w)*t ? "YES" : "NO") << endl;
	return 0;
}


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

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

int main() {
    int N;
    int tmp;
    long long sum=0;
    cin >> N;
    for (int i=1; i<=N; i++){
        for (int j=1; j<=N; j++){
            tmp = gcd(i,j);
            for (int r=1; r<=N; r++){
                sum = sum + gcd(tmp, r);
            }
        }
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
 
#define int long long
#define fs first
#define sc second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define len(v) ((int)v.size())
#define vc vector
#define pr pair
#define endl "\n"
#define endd "\n"; return 0;
#define all(v) v.begin(), v.end()
 
using namespace std;
 
const int MAXN = 1e5;
const int INF = 1e10;
const int MOD = 1e9 + 7;

main() {
    ios_base::sync_with_stdio(0);
    int a, b, c;
    cin >> a >> b >> c;
    //a = rand() % 10000;
    //b = rand() % 10000;
    //c = rand() % 10000;
    for (int i = 0; i < 10000000; i++){
        if ((a % 2 == 0) && (b % 2 == 0) && (c % 2 == 0)){
            int a1 = (b + c) / 2;
            int b1 = (a + c) / 2;
            int c1 = (a + b) / 2;
            swap(a, a1);
            swap(b, b1);
            swap(c, c1);
        }
        else{
            cout << i << endd;
        }
    }
    cout << -1;
}

Measured memory_bytes: 256
import numpy as np


# 約数の列挙
def make_divisors(n):
    divisors = set()
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.add(i)
            divisors.add(n // i)
    return sorted(list(divisors))


N, K, *A = map(int, open(0).read().split())

A = np.array(A, np.int64)
d = make_divisors(A.sum())

for i in d[::-1]:
    r = A % i
    r = r[r != 0]
    l = r.size
    if l == 0:
        print(i)
        exit()
    else:
        n = np.arange(l - 1, 0, -1)
    r.sort()
    np.cumsum(r, out=r)
    if np.any((r[:-1] == i * n - (r[-1] - r[:-1])) & (r[:-1] <= K)):
        print(i)
        exit()


Measured memory_bytes: 12516