akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl
#define isort(a) sort(a.begin(),a.end())

using namespace std;

#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

typedef pair<ll,ll> Pair;
const ll inf =1000000007;

void solve(){
    ll n;
    cin >> n;
    vector<ll> x(5,0);

    rep(i,n){
        string s;
        cin >> s;
        if(s[0]=='M') x[0]++;
        if(s[0]=='A') x[1]++;
        if(s[0]=='R') x[2]++;
        if(s[0]=='C') x[3]++;
        if(s[0]=='H') x[4]++;
    }

    ll ans=0;
    for(ll i=0;i<5;i++){
        for(ll j=i+1;j<5;j++){
            for(ll k=j+1;k<5;k++){
                ans+=x[i]*x[j]*x[k];
            }
        }
    }
    kaku(ans);
}

int main(){
    solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
using namespace std;

#define ll long long
//#define int long long
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

#define dump(x)  cerr << #x << " = " << (x) << endl; 
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 


typedef pair<int, int> P;
struct Point{
	int x, y;
};
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = {1,0,-1,0};

string S, T, S1, T1;
int s[200001], t[200001];
set<char> sset, tset;

int main(){

	cin >> S >> T;

	S1 = S; T1 = T;

	for (int i = 0; i < S.length(); i++){
		// S[i]が初めて出てきた
		if (sset.find(S[i]) == sset.end()){
			sset.insert(S[i]);
			for (int j = 0; j < S.length();j++)
				if(S[j]==S[i]) S1[j] = sset.size();
		}
	}
	for (int i = 0; i < T.length(); i++){
		if (tset.find(T[i]) == tset.end()){
			tset.insert(T[i]);
			for (int j = 0; j < T.length(); j++)
				if (T[j] == T[i]) T1[j] = tset.size();
		}
	}

	for (int i = 0; i < S.length(); i++){
		if (S1[i] != T1[i]){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 1160
n,w,i,m,a,v;main(){
scanf("%d%d",&n,&w);
m=1e3*n;
int*dp=(int*)calloc(m+1,sizeof(int));
for(i=1;i<=m;i++)dp[i]=w+1;
while(n--){scanf("%d%d",&a,&v);for(i=m;i>=v;i--)dp[i]=(dp[i]>dp[i-v]+a?dp[i-v]+a:dp[i]);}
for(i=m;dp[i]>w;i--);
printf("%d",i);
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args)
	{
		new Main().run();		
	}
	
	public void run()
	{
		//max stickers
		//then max sticker-toys
		//then max toys
		
		Scanner file = new Scanner(System.in);
		int untasty = file.nextInt();
		int tasty = file.nextInt();
		int poison = file.nextInt();
		int ans = Math.min(poison, untasty);
		poison -= Math.min(poison, untasty);
		if(poison <= tasty) {
			ans += poison + tasty;
		}else {
			ans += tasty*2+1;
		}
		System.out.println(ans);
	}
	
}

Measured memory_bytes: 22868
import numpy as np

MOD=998244353
N=int(input())
A=np.array([int(input()) for _ in range(N)],dtype=np.int64)

TOTAL=pow(3,N,MOD)
ASum=np.sum(A)

# dp=[[0 for _ in range(ASum+1)] for _ in range(2)]
dp=np.zeros((2,ASum+1),dtype=np.int64)
dp[0][0] = 2
dp[0][A[0]] = 1

# dpOther=[[0 for _ in range(ASum+1)] for _ in range(2)]
dpOther=np.zeros((2,ASum+1),dtype=np.int64)
dpOther[0][0] = 1
dpOther[0][A[0]] = 1

prev=0
current=1
curMax=A[0]
# for n in range(1,N):
for n, a in enumerate(A):
	if n==0:
		continue
	# curMax += a
	current = n % 2
	prev = (n+1) % 2
	# for e in range(curMax+1):
	dp[current,:] = dp[prev,:]*2 % MOD
	dp[current,a:] += dp[prev,:-a] % MOD

	if ASum %2 == 0:
		dpOther[current,:] = dpOther[prev,:] % MOD
		dpOther[current,a:] += dpOther[prev,:-a] % MOD

sumStart = 0
plus = 0

if ASum % 2 == 0:
	# 合計が偶数
	sumStart=ASum//2
	plus = (dpOther[current][ASum//2]*3) % MOD
else:
	# 合計が奇数の場合、ceil
	sumStart=ASum//2+1

exceptCnt=0
for s in range(sumStart,ASum+1):
	exceptCnt = (exceptCnt + dp[current][s]*3) % MOD

exceptCnt -= plus

print((TOTAL - exceptCnt) % MOD )



Measured memory_bytes: 16684
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  vector<vector<pair<int, bool>>> vec;
  rep(i, 3) {
    vector<pair<int, bool>> r;
    rep(j, 3) {
      int x;
      cin >> x;
      r.push_back(make_pair(x, false));
    }
    vec.push_back(r);
  }
  int n;
  cin >> n;
  rep(i, n) {
    int x;
    cin >> x;
    rep(j, 3) {
      rep(k, 3) {
        if (vec[j][k].first == x) vec[j][k].second = true;
      }
    }
  }
  rep(i, 3) {
    bool rs = true;
    rep(r, 3) {
      if (!vec[i][r].second) rs = false;
    }
    if (rs) {
      cout << "Yes" << endl;
      return 0;
    }
    bool cs = true;
    rep(c, 3) {
      if (!vec[c][i].second) cs = false;
    }
    if (cs) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  bool l = true;
  bool r = true;
  rep(i, 3) {
    if (!vec[i][3-(i+1)].second) l = false;
    if (!vec[3-(i+1)][i].second) r = false;
  }
  if (l || r) {
    cout << "Yes" << endl;
    return 0;
  }
  r = true;
  repr(i, 2) {
    if (!vec[i][i].second) r = false;
  }
  if (r) {
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3632
#coding:utf-8

import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    from collections import defaultdict
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]


    P1 = 2**127-1
    P2 = 2**31-1
    base = 26
    N = II()
    S = list(map(ord,list(input())))
    pow1 = [1]*N
    pow2 = [1]*N
    for i in range(N-1):
        pow1[i+1] = pow1[i]*base%P1
        pow2[i+1] = pow2[i]*base%P2
    hash1 = [0]*(N+1)
    hash2 = [0]*(N+1)
    hash1[1] = hash2[1] = S[0]
    for i in range(2,N+1):
        hash1[i] = (hash1[i-1]*base + S[i-1]) % P1
        hash2[i] = (hash2[i-1]*base + S[i-1]) % P2
    
    def f(x):
        hashes = defaultdict(lambda : -1)
        for i in range(N-x+1):
            #S[i:i+x]
            h1 = (hash1[i+x] - hash1[i] * pow1[x]) % P1
            h2 = (hash2[i+x] - hash2[i] * pow2[x]) % P2
            if hashes[(h1,h2)] == -1:
                hashes[(h1,h2)] = i
            elif hashes[(h1,h2)] + x <= i:
                return True
        # print(hashes)
        return False
    
    ok = -1
    ng = N//2+1
    while ng-ok > 1:
        
        m = (ok+ng)//2
        # print(m)
        if f(m):
            ok = m
        else:
            ng = m
    print(ok)

if __name__ == '__main__':
    main()

Measured memory_bytes: 76816
a,b,c,d=map(int,input().split())

if c-b>=0 or a-d>=0:
  print(0)
elif (c-a>=0 and b-d>=0):
  print(d-c)
elif (a-c>=0 and d-b>=0):
  print(b-a)
elif c-a>=0:
  print(b-c)
elif a-c>=0:
  print(d-a)

Measured memory_bytes: 3060
n,d=map(int,input().split())
D=[list(map(int,input().split())) for _ in range(d)]
cost=[[0]*d for _ in range(3)]
c=[list(map(int,input().split())) for _ in range(n)]
for i in range(n):
    for j in range(n):
        cost[(i+j)%3][c[i][j]-1]+=1
import itertools
ans=10**18
s=0
for p in itertools.permutations(range(1,d+1),3):
    for i in range(3):
        for j in range(d):
            s+=D[j][p[i]-1]*cost[i][j]
    if s<ans:
        ans=s    
    s=0
print(ans)

Measured memory_bytes: 45660
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main()
{
	int a, b;
	cin >> a >> b;
	if (a > 8 || b > 8) {
		cout << ":(" << endl;
	}
	else cout << "Yay!" << endl;
	return 0;
}



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

#define int long long

signed main() {
	int h, w, k, ans = 0;
	cin >> h >> w >> k;
	vector <string> s(h);
	for(int i = 0; i < h; i++){
		cin >> s[i];
	}
	for(int mask = 0; mask < 1 << (h + w); mask++){
		vector <string> t = s;
		for(int i = 0; i < h; i++){
			if(mask & (1<<i)){
				for(int j = 0; j < w; j++){
					t[i][j] = 'p';
				}
			}
		}
		for(int i = 0; i < w; i++){
			if(mask & (1<<(i + h))){
				for(int j = 0; j < h; j++){
					t[j][i] = 'p';
				}
			}
		}
		int xxx = 0;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				xxx += t[i][j] == '#';
			}
		}
		ans += xxx == k;
	}
	cout << ans << '\n';
}

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

using namespace std;

typedef long long ll;

double getTime() { 
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

int dp[1 << 18][51];
int n;
vector <int> a, b;

int go(int mask, int last) {
  if(mask == (1 << n) - 1) return 0;
  if(dp[mask][last] != -1) return dp[mask][last];
  int ans = 1e9 + 10;
  int idx = 0; int cur = __builtin_popcount(mask);
  for(int i = 0; i < n; i++) {
    if((mask >> i) & 1) {
      cur++;
      continue;
    }
    if((cur + idx) & 1) {
      if(b[i] >= last) ans = min(ans, idx + go(mask | (1 << i), b[i]));
    }
    else {
      if(a[i] >= last) ans = min(ans, idx + go(mask | (1 << i), a[i]));
    }
    idx++;
  }
  return dp[mask][last] = ans;
}

int main() {
  read(n);
  a.resize(n), b.resize(n);
  for(int i = 0; i < n; i++) {
    read(a[i]);
  }
  for(int i = 0; i < n; i++) {
    read(b[i]);
  }
  memset(dp, -1, sizeof dp);
  int ans = go(0, 0);
  if(ans >= 1000000000) ans = -1;
  print(ans);
}

Measured memory_bytes: 52480
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
ll n;
cin>>n;

ll n1=n;

int c=0;

while(n1)
{
	c++;
	n1/=10;
}

ll kk=1;

rep(i,1,c-1)kk*=1ll*10;

ll s=0,su=0;

rep(i,1,c-1)s=s*10+9,su+=9;

ll ans=su;

rep(i,0,9)
{
	if(kk*1ll*i+s<=n)ans=i+su;
}

ol(ans);

return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#define int long long
#define uint unsigned long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
using namespace std;

vector<int> node[100001];
int col[100001] = { 0 };
int memo_turn[100001] = { 0 };
int memo_dis[100001] = { 0 };

int cmd_v[100001] = { 0 };
int cmd_d[100001] = { 0 };
int cmd_c[100001] = { 0 };

int N, M;

void nuri(int q, int v, int d, int c)
{
	if (d < 0)
	{
		return;
	}

	if (memo_turn[v] >= q && memo_dis[v] >= d)
	{
		return;
	}

	if (memo_turn[v] < q)
	{
		col[v] = c;
		memo_turn[v] = q;
	}

	if (memo_dis[v] < d)
	{
		memo_dis[v] = d;
		for (int next : node[v])
		{
			nuri(q, next, d - 1, c);
		}
	}
}

signed main()
{
	cin >> N >> M;
	for (int i = 0; i < M; i++)
	{
		int a, b;
		cin >> a >> b;
		node[a].push_back(b);
		node[b].push_back(a);
	}

	memset(col, 0, sizeof(col));
	memset(memo_turn, -1, sizeof(memo_turn));
	memset(memo_dis, -1, sizeof(memo_dis));

	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++)
	{
		int v, d, c;
		cin >> cmd_v[i] >> cmd_d[i] >> cmd_c[i];
	}

	for (int i = Q - 1; i >= 0; i--)
	{
		nuri(i, cmd_v[i], cmd_d[i], cmd_c[i]);
	}

	for (int i = 1; i <= N; i++)
	{
		cout << col[i] << endl;
	}
}


Measured memory_bytes: 11636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    vector<int> c(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        c[i]--;
    }
    vector<int> l(q), r(q), order(q);
    iota(order.begin(), order.end(), 0);
    for (int i = 0; i < q; i++) {
        cin >> l[i] >> r[i];
        l[i]--, r[i]--;
    }
    vector<int> a(n);
    int b = 0;
    int width = 700;
    sort(order.begin(), order.end(), [&](int i, int j) {
        return (l[i] / width == l[j] / width ? r[i] < r[j] : l[i] < l[j]);
    });
    vector<int> ans(q);
    int x = 0, y = -1;
    auto add = [&](int i) {
        if (a[c[i]] == 0) {
            b++;
        }
        a[c[i]]++;
    };
    auto del = [&](int i) {
        a[c[i]]--;
        if (a[c[i]] == 0) {
            b--;
        }
    };
    for (int i : order) {
        while (y < r[i]) {
            y++;
            add(y);
        }
        while (l[i] < x) {
            x--;
            add(x);
        }
        while (r[i] < y) {
            del(y);
            y--;
        }
        while (x < l[i]) {
            del(x);
            x++;
        }
        ans[i] = b;
    }
    for (int i : ans) {
        cout << i << '\n';
    }
    return 0;
}

Measured memory_bytes: 15492
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

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


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N, M; std::cin >> N >> M;
  std::vector<int> s(N+1, -1);
  rep(i,M) {
    int t, c; std::cin >> t >> c;
    if ( s[t] != -1 && s[t] != c ) {
      std::cout << -1 << std::endl;
      return 0;
    }
    s[t] = c;
  }

  //for(int j=1; j<=N; j++) std::cout << j << " , " << s[j] << std::endl;

  for(int i=0; i<=999; i++) {
    std::string n = std::to_string(i);
    if ( int(n.size()) != N ) continue;
    bool judge = true;
    for(int j=1; j<=N; j++) {
      if ( s[j] == -1 ) continue;
      if ( s[j] != (n[j-1]-'0') ) judge = false;
    }
    if ( judge ) {
      std::cout << i << std::endl;
      return 0;
    }
  }
  std::cout << -1 << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ARC080D - Grid Coloring
  int H, W; cin >> H >> W;
  int N; cin >> N;
  vector<int> a(N, 0);
  REP(i, N){
    cin >> a[i];
  }
  
  vector<vector<int> > ans(H, vector<int>(W, 0));
  int tmpH = 0, tmpW = 0;
  REP(i, N){
    REP(j, a[i]){
      ans[tmpH][tmpW] = i + 1;
      if(tmpH%2 == 0 && 0 <= tmpW && tmpW <= W-1){
        tmpW++;
      }
      if(tmpH%2 == 1 && 0 <= tmpW && tmpW <= W-1){
        tmpW--;
      }
      if(tmpW == W){
        tmpH++;
        tmpW--;
      }
      if(tmpW == -1){
        tmpH++;
        tmpW++;
      }
    }
  }
  
  REP(i, H){
    REP(j, W){
      cout << ans[i][j] << " ";
    }
    cout << endl;
  }
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
        int x,y;
        int ans;
        cin >> x >> y;
        if(x<y)
                ans=x;
        else ans=y;
        cin >> x >> y;
        if(x<y)
                ans+=x;
        else    ans+=y;
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define ll long long
#define ull unsigned long long
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define eps 1e-9
#define P pair<int, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES\n"; }
void NO() { cout << "NO\n"; }
void Yes() { cout << "Yes\n"; }
void No() { cout << "No\n"; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }

int n, m;
vector<vector<int>> g;
int color[100000];

void dfs(int s, int col) {
	if (color[s] > 0)
		return;
	color[s] = col;

	for (int i = 0; i < g[s].size(); ++i) {
		dfs(g[s][i], col);
	}
}

int main() {
	int q, s, t;
	cin >> n >> m;
	g.resize(n);
	while (m--) {
		cin >> s >> t;
		g[s].push_back(t);
		g[t].push_back(s);
	}

	int col = 1;
	for (int i = 0; i < n; ++i) {
		dfs(i, col++);
	}

	cin >> q;
	while (q--) {
		cin >> s >> t;
		if (color[s] == color[t])
			yes();
		else
			no();
	}

	return 0;
}

Measured memory_bytes: 11768
#include<bits/stdc++.h>
using namespace std;
#define all(v)   v.begin(),v.end()
#define all(v) v.begin(),v.end()
#define meow ios::sync_with_stdio(0);cin.tie(0);

typedef long long int ll;
typedef unsigned long long int ull;

int main()
{
    ll a,b,c,d;
    ll m,n,o,p;
    /*cin>>a;
    if(a==1)
    cout<<0<<endl;
    else{
        cout<<1<<endl;
    }*/
    cin>>a>>b>>c>>d;
    m=a*c;
    n=a*d;
    o=b*c;
    p=b*d;
    cout<<max(max(max(m,n),o),p)<<endl;

}


Measured memory_bytes: 3564
n = int(input())
a = [0] + list(map(int, input().split()))

from itertools import accumulate
acc_a = list(accumulate(a))
from collections import Counter
count_a = Counter(acc_a)

count = 0
for i in count_a.values():
    count += i * (i-1) // 2

print(count)

Measured memory_bytes: 41752
package main

import "fmt"

var (
	n, m int
)

func main() {
	fmt.Scan(&n, &m)

	fmt.Println(abs((n * m) - (2 * m) - (2 * n) + 4))
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}


Measured memory_bytes: 512
///
// File:  1369.cpp
// Author: ymiyamoto
//
// Created on Sun Dec 31 19:24:47 2017
//

#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

struct pos_t {
  uint32_t x;
  uint32_t y;
  bool operator<(const pos_t &p)
  {
    if (x == p.x) {
      return y < p.y;
    }
    return x < p.x;
  }
};

int32_t main()
{
  uint32_t n, m;
  cin >> n >> m;

  vector<pos_t> arms(m);
  for (uint32_t i = 0; i < m; i++) {
    cin >> arms[i].x >> arms[i].y;
  }

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

  vector<pair<uint32_t, uint32_t>> sets(n);
  for (uint32_t i = 0; i < sets.size(); i++) {
    sets[i] = {i, i};
  }

  for (auto arm : arms) {
    uint32_t y = arm.y;
    sets[y - 1].second = max(sets[y - 1].second, sets[y].second);
    sets[y].first = min(sets[y].first, sets[y - 1].first);
  }

  for (uint32_t i = 0; i < n; i++) {
    if (i != 0) cout << " ";
    cout << sets[i].second - sets[i].first + 1;
  }
  cout << endl;

  return 0;
}

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

using namespace std;

int C(int A, int B) {
	vector<int> p;
	for (int i = ceil(A / 0.08); int(i * 0.08) == A; i++)
		p.push_back(i);
	for (int i: p)
		if (int(i * 0.1) == B)
			return i;
	return -1;
}

int main() {
	int A, B;
	cin >> A >> B;
	cout << C(A, B);
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
F - LCS
https://atcoder.jp/contests/dp/tasks/dp_f

"""
import sys


def solve(s, t):
    n, m = len(s), len(t)
    dp = [[0] * (m + 1) for _ in range(n + 1)]
    for i in range(n):
        for j in range(m):
            if s[i] == t[j]:
                dp[i+1][j+1] = dp[i][j] + 1
            else:
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])
    ans = []
    y, x = n, m
    lcs = dp[y][x]
    while x > 0 or y > 0:
        if y-1 >= 0 and dp[y-1][x] == lcs:
            y -= 1
        elif x-1 >= 0 and dp[y][x-1] == lcs:
            x -= 1
        else:
            y -= 1
            x -= 1
            ans.append(s[y])
            lcs -= 1
    return ''.join(ans[::-1])


def main(args):
    s = input()
    t = input()
    ans = solve(s, t)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 112220
N,K =map(int,input().split())
def tasu(n,m):
    return((n-m+1)*m+m*(m+1)/2)

answer = 0
for i in range(K,N+2):
    maxsum = tasu(N,i)
    minsum = tasu(i-1,i)
    answer += maxsum-minsum+1
    answer = answer%(10**9+7)
print(int(answer))

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

template<typename Monoid>
struct SegmentTree {
    using F = function<Monoid(Monoid, Monoid)>;
    vector<Monoid> data;
    int n;
    const F f;
    const Monoid M;
    SegmentTree(int x, const F f, const Monoid &M) : f(f), M(M) {
        n = 1;
        while(n<x) n <<= 1;
        data.resize(2*n,M);
    }
    void set(int k, const Monoid &p) {
        data[k+n] = p;
    }
    void build() {
        for(int k = n-1; k > 0; --k) {
            data[k] = f(data[2*k + 0], data[2*k + 1]);
        }
    }
    void update(int k, const Monoid &p) {
        k += n;
        data[k] = p;
        while (k >>= 1) {
            data[k] = f(data[k*2 + 0], data[k*2 + 1]);
        }
    }
    Monoid query(int a, int b) {
        Monoid L = M, R = M;
        for(a += n, b += n; a<b; a >>= 1, b >>= 1) {
            if(a&1) L = f(L, data[a++]);
            if(b&1) R = f(data[--b], R);
        }
        return f(L,R);
    }
    Monoid operator[](const int &k) const {
        return data[k+n];
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,q; cin >> n >> q;
    SegmentTree<int> seg(n, [](int a,int b){return min(a,b);}, INT_MAX);
    int ans;
    REP(i,q) {
        int c,x,y; cin >> c >> x >> y;
        if(c==0) seg.update(x,y);
        else {
            ans = seg.query(x,y+1);
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3888
#include "bits/stdc++.h"

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

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

long long stoi(string str) {
	long long ret;
	stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

ull gcd(ull a, ull b) {
	if (b > a)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a%b);
}

void solve() {
	int n;
	cin >> n;
	string s1, s2;
	cin >> s1 >> s2;
	ll ans = 1;
	int pt = -1;
	int pos = 0;
	if (s1[pos] == s2[pos]) {
		ans *= 3;
		pos++;
		pt = 0;
	}
	else {
		ans *= 6;
		pos += 2;
		pt = 1;
	}
	REP(i, pos, n) {
		if (pt == 0) {
			if (s1[i] == s2[i]) {
				pt = 0;
				ans = (ans * 2) % MOD;
			}
			else {
				pt = 1;
				ans = (ans * 2) % MOD;
				i++;
			}
		}
		else {
			if (s1[i] == s2[i]) {
				pt = 0;
				ans = (ans * 1) % MOD;
			}
			else {
				pt = 1;
				ans = (ans * 3) % MOD;
				i++;
			}
		}
	}
	P(ans);
}

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


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

int main(void) {
  double a, b, x;
  double ans;
  cin >> a >> b >> x;
  if (a * a * b / 2.0 > x) {
    ans = atan(a * b * b / (2.0 * x)) * 180.0 / M_PI;
  } else {
    ans = atan(2 * (b / a - x / (a * a * a))) * 180.0 / M_PI;
  }
  cout << fixed << setprecision(6) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = []
y = 0
for i in range(n):
    x = int(input())
    a.append(x)
    if y <= x:
        y = x
        m = i

a.sort(reverse = True)
a_1 = a[0]
a_2 = a[1]

if a_1 == a_2:
    for i in range(n):
        print(a_1)

else:
    for i in range(m):
        print(a_1)

    print(a_2)

    for j in range(m+1,n):
        print(a_1)

Measured memory_bytes: 12532
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <bitset>
#include <climits>
#define DIVCEIL(A,B) ((A+(B-1))/B)
using namespace std;

int main(){
    unsigned long long N;
    cin >> N;

    vector<bitset<10>> F(N);
    for(int j=0; j<N; j++) {
        for (int i = 0; i < 10; i++) {
            int tmp;
            cin >> tmp;
            F[j][i]=tmp;
        }
    }

    int P[N][11];
    for(int i=0; i<N; i++)for(int j=0; j<=10; j++)cin >> P[i][j];

    int ans=INT_MIN;

    for(unsigned int i=1; i<pow(2,10); i++){
        bitset<10> days(i);
        int tmp=0;
        for(int j=0; j<N; j++)tmp += P[j][(days & F[j]).count()];
        ans = max(tmp, ans);
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s, t;
	bool flag = true;
	cin >> s >> t;
	if (s.size() + 1 == t.size()) {
		for (int i = 0; i < s.size(); i++) {
			if (s.at(i) != t.at(i)) {
				flag = false;
				break;
			}
		}
	} else {
		flag = false;
	}
	if (flag) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3596
use num::integer::gcd;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        a: i128,
        b: i128,
        n: i128,
    }

    //    for x in 0..(n + 1) as usize {
    //        let x = x as i128;
    //        let l = (a * x) / b;
    //        let r = a * (x / b);
    //        let d = l - r;
    //        eprintln!("{} : {} - {} = {}", x, l, r, d);
    //
    //        let h = (a * x) % b;
    //        let k = (x) % b;
    //        dbg!(a * k - h);
    //        dbg!((a * k - h) / b);
    //    }

    // let g = gcd(a % b, b);
    // let aa = (a % b) / g;

    let y = (b - 1).min(n);
    println!("{}", (a * y) / b - a * (y / b));
}


Measured memory_bytes: 2164
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long  a,b,k;
    cin>>a>>b>>k;
    for(int i=0;i<k;i++)
    {
        if(i%2==0)
        {
        if(a%2!=0){
            a=a-1;
        }
        b=b+a/2;
        a=a-a/2;
        }
        else
        {
            if(b%2!=0){
            b=b-1;
            }
            a=a+b/2;
            b=b-b/2;
        }

    }
cout<<a<<' '<<b<<endl;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000010;
constexpr ll INF= 1000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

ll RS(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P < 0) {
        return 0;
    }
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    int N;
    cin >> N;
    if(N % 1000 == 0) {
        cout << 0 << endl;
        return 0;
    }
    cout << 1000 - N % 1000 << endl;
}

Measured memory_bytes: 3616
using System;
using System.Linq;
using System.Collections.Generic;

class Plogram
{
    static void Main()
    {
        int num = int.Parse(Console.ReadLine());
        var W = new List<string>();
        string str;
        string ans = "Yes";

        for(int i = 0; i < num; i++)
        {
            str = Console.ReadLine();
            if (W.Contains(str))
            {
                ans = "No";
            }
            W.Add(str);
        }

        for(int i = 0; i < num-1; i++)
        {
            if (W[i].Last() != W[i + 1].First())
            {
                ans = "No";
                break;
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13152
#include <cstdlib>
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<cmath>
#define ll long long
const ll INF=0x3f3f3f3f;
#define mod 1000000007
#define mem(a,b) memset(a,b,sizeof(a))
#define  INF 0x3f3f3f3f
//__builtin_popcount
using namespace std;
//priority_queue
const ll MAX=100000;
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
ll kc(ll a,ll b)
{
    ll c=1;
    while(b)
    {
        if(b&1)c=(c*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return c;
}

ll F[100003];
ll Find(ll a)
{
    return F[a]<0?a:F[a]=Find(F[a]);
}
ll same(ll a,ll b)
{
    if(Find(a)==Find(b))return 1;
    return 0;
}
void up(ll a,ll b)
{
    ll x,y;
    x=Find(a);
    y=Find(b);//cout<<F[x]<<" "<<F[y]<<endl;
    if(x!=y)
        F[y]+=F[x],F[x]=y;


}
int main()
{
  int a,b;
  cin>>a>>b;
  cout<<(a)/(1+2*b)+(a%(1+2*b)?1:0);
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

int main(){
    int N;
    int K;
    cin>>N>>K;
    bool D[10];
    FOR(i, 0, 10) D[i] = false;
    FOR(i, 0, K){
        int d;
        cin>>d;
        D[d] = true;
    }
    //全探索
     FOR(i, 0, 10*N){
        if(N<=i){
            int check = true;
            string s = to_string(i);
            FOR(j, 0, s.length()){
                if(D[s[j]-'0']) check = false;
            }
            if(check){
                cout << i << endl;
                return 0;
            }
        }
     }
}

Measured memory_bytes: 256
def main():
    n, w = map(int, input().split())
    weight = [0 for _ in range(110)]
    value = [0 for _ in range(110)]

    for i in range(n):
        x, y = map(int, input().split())
        weight[i] = x
        value[i] = y

    
    dp = [[0 for _ in range(110000)] for i in range(110)]

    for i in range(n):
        for sum_w in range(w+1):
            if sum_w - weight[i] >= 0:
                dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i])
            
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])

    print(dp[n][w]) 

main()


Measured memory_bytes: 203964
#include<bits/stdc++.h>
using namespace std;
#define lson now<<1
#define rson now<<1|1
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int mod=1e9+7;
const double eps = 1e-10;
const double pi=acos(-1.0);
const int maxn=2e5+10;
const ll inf=0x3f3f3f3f;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n;cin>>n;
    bool f=0;
    for(int i=1,x;i<=n;i++){
        cin>>x;
        if(x%2==0){
            if(x%3==0||x%5==0)continue;
            else {f=1;break;}
        }
    }
    if(f)cout<<"DENIED"<<endl;
    else cout<<"APPROVED"<<endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <vector>
#include <cassert>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
ll D;
ll a[200005];
struct segtree{
	pair<ll,int> x[(1<<19)];
	void init(){
		for(int i=0;i<(1<<19);i++) x[i] = make_pair(1e18,INF);
	}
	void update(int i,ll a){
		i += (1<<18)-1;
		x[i] = make_pair(a,i-(1<<18)+1);
		while(i){
			i = (i-1)/2;
			x[i] = min(x[i*2+1],x[i*2+2]);
		}
	}
	pair<ll,int> query(int a,int b,int k,int l,int r){
		if(r<a || b<l || a>b) return make_pair(1e18,INF);
		if(a<=l && r<=b) return x[k];
		pair<ll,int> L = query(a,b,k*2+1,l,(l+r)/2);
		pair<ll,int> R = query(a,b,k*2+2,(l+r)/2+1,r);
		return min(L,R);
	}
}seg_plus,seg_minus;
struct union_find{
	int par[200005],ran[200005];
	void init(){ for(int i=0;i<200005;i++) par[i] = i; }
	int find(int x){ if(x == par[x]) return x; else return par[x] = find(par[x]); }
	void unite(int x,int y){
		x = find(x); y = find(y); if(x==y) return;
		if(ran[x] < ran[y]) par[x] = y;
		else{
			par[y] = x;
			if(ran[x] == ran[y]) ran[x]++;
		}
	}
	bool same(int x,int y){ return find(x)==find(y); }
}uf;
vector<pair<ll,int> >vec;
vector<pair<ll,P> >edge;
int main(){
	scanf("%d%lld",&n,&D);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		vec.push_back(make_pair(a[i],i));
	}
	sort(vec.begin(),vec.end());
	seg_plus.init();
	seg_minus.init();
	for(int i=0;i<vec.size();i++){
		ll val = vec[i].first;
		int x = vec[i].second;
		pair<ll,int>w = seg_minus.query(1,x-1,0,0,(1<<18)-1);
		if(w.first <= 1e17 && w.second <= n){
			ll cs = w.first+1LL*x*D+val;
			edge.push_back(mp(cs,mp(w.second,x)));
		}
		w = seg_plus.query(x+1,n,0,0,(1<<18)-1);
		if(w.first <= 1e17 && w.second <= n){
			ll cs = w.first-1LL*x*D+val;
			edge.push_back(mp(cs,mp(w.second,x)));
		}
		seg_minus.update(x,val-1LL*D*x);
		seg_plus.update(x,val+1LL*D*x);
	}
	SORT(edge);
	uf.init();
	ll ans = 0;
	int cnt = 0;
	for(int i=0;i<edge.size();i++){
		if(uf.same(edge[i].second.first,edge[i].second.second) == false){
			uf.unite(edge[i].second.first,edge[i].second.second);
			ans += edge[i].first;
			cnt ++;
		}
	}
	assert(cnt == n-1);
	printf("%lld\n",ans);
}

Measured memory_bytes: 32364
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    int n;
    cin >> n;
    int copy=n;
    int cnt=0;
    while(copy>0){
        copy/=10;
        cnt++;
    }
    int ans=0;
    if(cnt==1){
        ans=n;
    }
    else if(cnt<3){
        ans=9;
    }
    else if(cnt==3){
        ans+=9;
        ans+=(n-99);
    }
    else if(cnt<5){
        ans+=9;
        ans+=900;
    }
    else if(cnt==5){
        ans+=9;
        ans+=900;
        ans+=(n-9999);
    }
    else {
        ans+=90909;
    }
    cout << ans << endl;
}


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

int main(){
	int N;
  cin >>N;
  int res=0;
  int ans=1;
  for (int i=1;i<=N;i++){
    int cnt=0;
    int j=i;
    
    while(true){
      if(j%2==0){
        j/=2;
        cnt++;
      }else{
        break;
      }
    }  
    if(res<cnt){
      res=cnt;
      ans=i;
    }
  }
    cout <<ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair

using namespace std;
//map <ll,ll> fc;
ll ans(ll x){
	if(x==1)return 1;
	else return 2ll*ans((x/2ll))+1ll;
}

void run(){
ll h,n;
cin>>h>>n;
ll d=h/n+1;
if(h%n==0)d--;
cout<<d<<endl;

}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)run();
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n, k = ns()
    
    if n>k:
        print(0)
        exit()
    
    a = math.factorial(k)
    b = math.factorial(k - n)
    ans = a // b  % MOD
    print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 7300
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vaector<long>
#define vll vector<long long int>
#define vC  vector<char>
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
ll pow(ll x, ll y,ll m) { ll res = 1;x=x%m; while (y > 0) { if (y & 1) res = ((res%m) * (x%m))%m; y = y >> 1; x = ((x%m) * (x%m))%m; } return res%m; }
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
const ll INF = 0xFFFFFFFFFFFFFFFL;
clock_t time_p=clock();
void abhigyan10()
{time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}
ll seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline ll rnd(ll l=0,ll r=INF){return uniform_int_distribution<ll>(l,r)(rng);}
#define clrbuf cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define preciset(x) cout<<setprecision(x)<<fixed;
const ll mod =1000000007;
int main()
{
        FastIO

        string s;
        cin>>s;
        if(s[2]==s[3] && s[5]==s[4])
        	cout<<"Yes";
        else
        	cout<<"No";
        return 0;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lp3(i,a,b) for(int i=a;i<b;i++)
#define lp2(i,n) for(int i=0;i<n;i++)
#define ll long long
#define W 1000000007
using namespace std;

int main(){
	int num=0;
	string s;
	cin>>s;
	if(s[0]=='A')num++;
	lp2(i,s.size()-1){
		if(s[i]>=s[i+1])num++;
	}
	cout<<num<<endl;
	return 0;
}



Measured memory_bytes: 3236
#include <stdio.h>
#include <stdlib.h>

int main()
{
    long long a,b,c,k;
    scanf("%lld %lld %lld %lld",&a,&b,&c,&k);
    if(k<=a) printf("%lld",k);
    else if(k>a&&k<a+b) printf("%lld",a);
    else printf("%lld",a-(k-(a+b)));
    return 0;
}


Measured memory_bytes: 1708
# A - Colorful Transceivers
# A さんと C さんが会話できるなら　YES!!!!
# 条件1： A さんと C さんの距離が d 以下
# 条件2： A さんと B さんの距離が d 以下　∧ B さんと C さんの距離が d 以下


# A さん a [m]
# B さん b [m]
# C さん c [m]
# D さん d [m]

# 標準入力 a b c d
a, b, c, d = map(int, input().split(maxsplit=4))
# print(a)
# print(b)
# print(c)
# print(d)


# A さんと C さんの距離を計算
distance_ac = abs(a - c)
# print(distance_ac)

# A さんと B さんの距離を計算
distance_ab = abs(a - b)
# print(distance_ab)

# B さんと C さんの距離を計算
distance_bc = abs(b - c)
# print(distance_bc)

# 条件1 条件2に分けて Yes No を代入
if distance_ac <= d:    # 条件1
    # print('Yes')
    answer = 'Yes'
elif distance_ab <= d:  # 条件2
    if distance_bc <= d:
        # print('Yes')
        answer = 'Yes'
    else:
        # print('No')
        answer = 'No'
else:
    # print('No')
    answer = 'No'

# 結果の出力
print(answer)

Measured memory_bytes: 9152
H, W, D = map(int,input().split())
dist = [0]*(H*W+1)#dist[i]はiからi+Dまでの距離
pos = [[0,0] for i in range(H*W+1)]
for i in range(H):
  A = list(map(int,input().split()))
  for j in range(W):
    pos[A[j]] = [i+1, j+1]
for i in range(H*W+1-D):
  dist[i] = abs(pos[i][0]-pos[i+D][0])+abs(pos[i][1]-pos[i+D][1])
distances = [[] for i in range(D)]#あまりがiの距離
for i in range(1,H*W+1-D):
  d = dist[i]
  distances[i%D]+=[d]
distances2 = [[0] for i in range(D)]#累積和に直す
for i in range(D):
  for j in range(len(distances[i])):
    distances2[i]+=[distances2[i][-1]+distances[i][j]]
Q = int(input())
for i in range(Q):
  L, R = map(int, input().split())
  q = L%D
  l, r = (L-1)//D, (R-1)//D
  print(distances2[q][r]-distances2[q][l])

Measured memory_bytes: 29616
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> VI;
typedef vector<long long int> VLLI;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> graph(n+1);
    int u, v;
    for (int i = 0; i < m; i++) {
        cin >> u >> v;
        graph[u].pb(v);
        graph[v].pb(u);
    }

    vector<int> sign(n+1);
    vector<bool> vi(n+1, false);
    queue<int> q;
    q.push(1);
    vi[1] = true;

    while (!q.empty()) {
        auto top = q.front();

        q.pop();

        for (auto x : graph[top]) {
            if (!vi[x]) {
                sign[x] = top;
                vi[x] = true;
                q.push(x);
            }
        }
    }

    cout << "Yes" << "\n";
    for (int i = 2; i <= n; i++)
        cout << sign[i] << "\n";


}



Measured memory_bytes: 10080
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int sosu(int n);

int main(){
	// sengen
	int x,y;
	
	// nyuryoku
	cin >> x;

	// keisan
	for(int j=x;j<10000000;j++){
		if(sosu(j)){
			cout << j << endl;
			break;
		}
	}
}



int sosu(int n){
	if(n == 2) return 1;
	else if(n%2 == 0) return 0;

	double a = sqrt(n);
	for(int i = 3;i<=a;i +=2){
		if(n % i == 0){
			return 0;
		}
	}
	return 1;
}

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

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < n / 2; i++){
        if(s[i] != s[n / 2 - 1 - i] || s[i] != s[n / 2 + 1 + i] || s[i] != s[n - 1 - i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin >> a;
  int b = a / 10;
  int c = a % 10;
  if (b == 9 || c == 9) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
int n;
const int N= 1e6+5;
int32_t main()
{
    IOS;
    int n;
    cin>>n;
    vector<int>a(n+1,0);
    vector<int>b(n+1,0);
    for(int i=1;i<=n;i++){
        cin>>a[i]>>b[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    int l= (n%2==0)? ((a[n/2]+a[n/2+1])) : (a[(n+1)/2]);
    int r= (n%2==0)? ((b[n/2]+b[n/2+1])) : (b[(n+1)/2]);
    int l1= min(l,r);
    int l2= max(l,r);
    cout<<(l2-l1+1)<<endl;
    return 0;
}




Measured memory_bytes: 6348