akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+5;
ll n,m,a[15],s,c,num[10],f=1;

int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++) a[i]=-1;
    for(int i=0;i<=9;i++) num[i]=0;
    for(int i=1;i<=m;i++){
        cin>>s>>c;
        if(a[s]==-1) {
            if(s==1 && c==0 && n!=1) f=0;
            a[s]=c;
            num[c]=1;
        }
        else{
            if(a[s]!=c) f=0;
        }
    }
    if(f==0) {
        cout<<"-1"<<endl;
        return 0;
    }
    else if(n==1 && a[1]==-1){
        cout<<"0"<<endl;
        return 0;
    }
    else{
        for(int i=1;i<=n;i++){
            if(a[i]==-1){
                if(i==1) a[i]=1;
                else a[i]=0;
            }
        }
        for(int i=1;i<=n;i++) cout<<a[i];
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
template<class T=ll> 
T in(){T x;cin>>x;return (x);}
template<class T> 
void print(T &x){cout<<x<<"\n";}
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cerr << #x"="<< (x) << "\n"
#define dbgv(x) cerr<<#x<<"\n";reps(y,x){cerr<<y<<" ";}cerr<<"\n"

int main(){
  ll n=in(),a=in(),b=in(),ans=1e9;
  vector<ll> h(n);
  rep(i,n){
    scanf("%lld",&h[i]);
  }
  sort(all(h));
  ll left=1,right=1e9,mid,cnt=0;
  while (right!=left+1) {
    mid =(right+left)/2;
    cnt=0;
    rep(i,n){
      ll temp=h[i]-b*mid;
      if(temp>0){
        cnt+=ceil(1.0*temp/(a-b));
      }
    }
    bool flg=cnt<mid;
    if(flg){
      right=mid;
    }else left=mid;
  }
  cnt=0;
  rep(i,n){
    ll temp=h[i]-b*left;
    if(temp>0){
      cnt+=ceil(1.0*temp/(a-b));
    }
  }
  ans=min(ans,max(cnt,left));
  cnt=0;
  rep(i,n){
    ll temp=h[i]-b*right;
    if(temp>0){
      cnt+=ceil(1.0*temp/(a-b));
    }
  }
  ans=min(ans,max(cnt,right));
  cout<<ans<<endl;
  return 0;
}

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

int main()
{
    int N,K,c,a[200010]={0};
    cin >> N >> K;
    for(int i=0; i<N; i++){
        cin >> c;
        a[c]++;
    }
    sort(a,a+N+1);
    bool f = true;
    int start;
    int value = 0;
    for(int i=0; i<=N; i++){
        if(a[i] !=0){
            if(f){
                start = i;
                f = false;
            }
            value++;
        }
    }
    int ans = 0;
    while(1){
        for(int i=start; i<=N; i++){
            if(value<=K){
                cout << ans << endl;
                return 0;
            }
            ans += a[i];
            a[i] = 0;
            value--;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <iomanip>
#define F first
#define S second
#define PB push_back
#define PF push_front
#define MP make_pair
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int maxn = 1e5 + 10;
const int maxm = 1e5 + 10;
const int mod = 1e9 + 7;
const int inf = 1e9;

vector <int> v, g;

int main() {
    ios_base::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x < 0)
            v.PB (x);
        else
            g.PB (x);
    }
    reverse (v.begin(), v.end());
    int ans = inf;
    for (int i = 0; i < min ((int)g.size(), k); i++) {
        if (k - i - 2 < v.size() and k - i - 2 >= 0) {
            ans = min (ans, 2 * g[i] - v[k - i - 2]);
            ans = min (ans, -2 * v[k - i - 2] + g[i]);
        }
    }
    if (v.size() >= k)
        ans = min (ans, -v[k - 1]);
    if (g.size() >= k)
        ans = min (ans, g[k - 1]);
    cout << ans << endl;
}

Measured memory_bytes: 1020
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define LOG(x) if(DEBUG) cerr << x << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	int n,k;
	cin >> n >> k;

	int t = 0;

	while(n > 0)
	{
		n /= k;
		t++;
	}

	cout << t << endl;
}

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

string strs[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

int main() {
    string s;
    cin >> s;
    for(int i = 0; i < 7; ++i) {
        if(s == strs[i]) {
            cout << 7-i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    int n;
    cin >> n;
    vector<int>x(n);
    vector<int>y(n);
    rep(i,n) {
        cin >> x[i] >> y[i];
    }
    vector<int>p(n);
    rep(i,n) p[i] = i;
    double len = 0;
    int num = 0;
    
    do
    {
        rep(i,n-1) {
            double dx = x[p[i]]-x[p[i+1]];
            
            double dy = y[p[i]]-y[p[i+1]];
            
            double dist = sqrt(dx*dx+dy*dy);
            
            len += dist;
        }   
        num++; 
    } while (next_permutation(p.begin(),p.end()));
    double ans = len/num;
    printf("%.10f\n",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define siz         200009
#define inf         1e9+8
#define mp          make_pair
#define rep(i,n)    for(int i=0;i<n;i++)
#define repo(i,m,n) for(int i=m;i<=n;i++)
#define ll          long long
#define pii         pair<ll,ll >
#define sc(n)       scanf("%d",&n)
#define sc2(m,n)    scanf("%d%d",&m,&n);
#define MOD         4294967296
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define mem(x,i)    memset(x,i,sizeof x)
#define PI          acos(-1.0)
#define ff          x
#define ss          y
using namespace std;



int main()
{
    int n,k;
    cin>>n>>k;
    char arr[n+5];
    cin>>arr;
    arr[k-1]=arr[k-1]+32;
    cout<<arr<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Text;
using System.Collections;
using System.Collections.Generic;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			long k = ReadLineLong();
			long sum = 0;
			for (long a = 1; a <= k; a++)
			{
				for (long b = 1; b <= k; b++)
				{
					for (long c = 1; c <= k; c++)
					{
						var n = Gcd(a, b);
						sum += Gcd(n, c);
					}
				}
			}
			Console.WriteLine(sum);
		}

		public static long Gcd(long a, long b)
		{
			if (a < b) return Gcd(b, a);
			while (b != 0)
			{
				var remainder = a % b;
				a = b;
				b = remainder;
			}
			return a;
		}

		public static int nCm(int n, int m)
		{
			if (n == 0) return 0;
			if (m == 0) return 1;
			return n * nCm(n - 1, m - 1) / m;
		}

		public static string ReadLine()
		{
			return Console.ReadLine();
		}

		public static int ReadLineInt()
		{
			return int.Parse(ReadLine());
		}

		public static long ReadLineLong()
		{
			return long.Parse(ReadLine());
		}

		public static string[] ReadLineStringSplit(char s = ' ')
		{
			return ReadLine().Split(s).ToArray();
		}

		public static int[] ReadLineIntSplit(char s = ' ')
		{
			return ReadLine().Split(s).Select(x => int.Parse(x)).ToArray();
		}

		public static long[] ReadLineLongSplit(char s = ' ')
		{
			return ReadLine().Split(s).Select(x => long.Parse(x)).ToArray();
		}
	}
}

Measured memory_bytes: 17596
/*#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;*/
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define f first
#define s second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);   cout.tie(NULL);
#define mod (ll)1e18
#define pb push_back
#define N 100000 + 5
#define N 100000 + 5
# define deb(x) cout<<#x<<" "<<x<<endl;
//   cout << fixed << setprecision(12);
#define forab(i, a, b, c) for (ll(i) = a; (i) <= (b); (i) += (c))
#define forabr(i, a, b, c) for (ll(i) = a; (i) >= (b); (i) -= (c))
void arrinitialize(ll n,ll a[],ll x){
    forab(i,0,n-1,1){
        a[i]=x;
    }
}
void start(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
int main(){
    fastio;
   // start();
    ll n;cin>>n;ll a[n];forab(i,0,n-1,1)cin>>a[i];ll b[n]={0};
    arrinitialize(n,b,1000000000000000000);ll s=0;b[0]=0;
    forab(i,1,n-1,1){
        b[i]=min(b[i],abs(a[i]-a[i-1])+b[i-1]);
        if(i>=2)
        b[i]=min(b[i],abs(a[i]-a[i-2])+b[i-2]);

    }
    cout<<b[n-1];
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>

using namespace std;

const int INF = 1 << 29;
typedef pair<int, int> P;

int n, w;
int dp[1001][1001];//お宝の番号、重さ
int main(void)
{
	int caseCount = 0;
	while(cin >> w && w)
	{
		cin >> n;
		vector<int> ps(n), ws(n);
		memset(dp, 0, sizeof(dp));
		char c;
		for (int i = 0; i < n; i++)
		{
			cin >> ps[i] >> c >> ws[i];
		}

		if(ws[0] <= w) dp[0][ws[0]] = ps[0];
		for (int i = 1; i < n; i++)
		{
			for (int j = 0; j <= w; j++)
			{
				if(ws[i] <= j)
					dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - ws[i]] + ps[i]);
				/*if(j + ws[i] <= w)
					dp[i][j + ws[i]] = max(dp[i - 1][j + ws[i]], dp[i - 1][j] + ps[i]);*/
				else dp[i][j] = max(dp[i - 1][j], dp[i][j]);
			}
		}

		cout << "Case " << ++caseCount << ":" << endl;
		int ansp = 0, answ = INF;
		for (int i = 0; i <= w; i++)
		{
			if(ansp < dp[n - 1][i])
			{
				ansp = dp[n - 1][i];
				answ = i;
			}
		}
		cout << ansp << endl << answ << endl;
	}
	return 0;
}

Measured memory_bytes: 5128
#include <bits/stdc++.h>
using namespace std;
using lint = long long;

lint X;
int K;
vector<int> r;
int Q;
vector<pair<int, int> > query;

int main()
{
    cin >> X >> K;
    r = vector<int>(K+1, 0);
    for (int i=1; i<=K; i++) cin >> r[i];
    cin >> Q;
    query.resize(Q);
    for (auto &q : query) cin >> q.first >> q.second;

    vector<pair<lint, lint> > limits(K+1);
    limits[0].first = 0; limits[0].second = X;
    vector<lint> sum(K+1, 0);
    for (int i=1; i<=K; i++)
    {
        if (i&1)
        {
            sum[i] = sum[i-1] - (r[i] - r[i-1]);
            limits[i].first = max(limits[i-1].first - r[i] + r[i-1], 0LL);
            limits[i].second = max(limits[i-1].second - r[i] + r[i-1], 0LL);
        }
        else
        {
            sum[i] = sum[i-1] + r[i] - r[i-1];
            limits[i].first = min(limits[i-1].first + r[i] - r[i-1], X);
            limits[i].second = min(limits[i-1].second + r[i] - r[i-1], X);
        }
    }

    for (auto q : query)
    {
        lint t = q.first, a = q.second;
        if (t == 0)
        {
            cout << a << endl;
            continue;
        }
        int where = lower_bound(r.begin(), r.end(), t) - r.begin() - 1;
        lint tmp = min(max(a + sum[where], limits[where].first), limits[where].second);
        if (where & 1)
        {
            cout << min(X, tmp+t-r[where]) << endl;
        }
        else
        {
            cout << max(0LL, tmp-t+r[where]) << endl;
        }
    }
    return 0;
}

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

int main(){
  double n;
  cin >> n;
  n /= 3;
  double ans = n * n * n;
  cout << fixed << setprecision(12) << ans << endl;
  return 0;
}


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

using ll = long long;

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

int main(){
    int k;
    cin >> k;
    ll sum = 0;
    for(int a = 1; a <= k; a++){
        for(int b = 1; b <= k; b++){
            int abgcd = gcd(a,b);
            for(int c = 1; c <= k; c++){
               sum += gcd(abgcd,c);
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
string s;
int K;
int main(){
	cin>>s>>K;
	set<string> st;
	REP(i,(int)s.size()){
		REP(j,min(K,(int)s.size()-i)){
			st.insert(s.substr(i,j+1));
			if ((int)st.size()>K){
				auto ite=st.end();
				ite--;
				st.erase(ite);
			}
		}
	}
	auto ite=st.begin();
	REP(i,K-1){
		ite++;
	}
	cout<<*ite<<endl;
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn binary_search_recrusive(array: Vec<i32>, key: i32, low: i32, high: i32) -> i32 {
    let mid = (low + high) / 2;

    if low > high {
        -1
    } else if array[mid as usize] == key {
        mid
    } else if key < array[mid as usize] {
        binary_search_recrusive(array, key, low, mid - 1)
    } else {
        binary_search_recrusive(array, key, mid + 1, high)
    }
}

fn binary_search(array: Vec<i32>, key: i32) -> i32 {
    let len = array.len() as i32;
    binary_search_recrusive(array, key, 0, len - 1)
}

fn main() {
    let n: usize = read();
    let mut s_array: Vec<i32> = (0..n).map(|_| read::<i32>()).collect();
    let q: usize = read();
    let t_array: Vec<i32> = (0..q).map(|_| read::<i32>()).collect();

    s_array.sort();

    let mut cnt = 0;

    for t in t_array {
        let res = binary_search(s_array.clone(), t);
        if res != -1 {
            cnt += 1;
        }
    }

    println!("{}", cnt);
}



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

using namespace std;
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
#define mod 1000000007
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll tot=b-a+1;
    ll lcm=c*d/gcd(c,d);
    ll div1=b/c-(a-1)/c;
    ll div2=b/d-(a-1)/d;
    ll both=b/lcm-(a-1)/lcm;
    ll b1=div1+div2-both;
    tot-=b1;
    cout<<tot<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>
int main()
{
    char s[12],t[15];
    scanf("%s %s",s,t);
    int a=strlen(s);
    int b=strlen(t),flag=0;
    if(a+1==b)
    {
        for(int i=0;i<a;i++)
        {
            if(s[i]!=t[i])
            {
                flag=1;
                break;
            }
        }
        if(flag)
        printf("No\n");
        else
        printf("Yes\n");
    }
    else
    printf("No\n");
}


Measured memory_bytes: 1656
#include<bits/stdc++.h>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MOD 1000000007
 
using namespace std;
 
bool cmpf(const pair<lli, lli> left, const pair<lli, lli> right) {
  	return left.first< right.first;
}
bool cmps(const pair<lli, lli> left, const pair<lli, lli> right) {
  	return left.second < right.second;
}
 
void dfs(lli ed, lli num, vector<map<lli,lli>>& vec){
    lli n=1;
    for(auto e: vec[num]){
        if(n == ed)n++;
        if(e.second != -1)continue;
        vec[num][e.first] = n;
        vec[e.first][num] = n;   
        dfs(n, e.first, vec);
        n++;
    }
}
 
lli gcd(lli a, lli b){
    if(a < b)return gcd(b, a);
    lli temp;
    while((temp = a%b)){
        a=b;
        b=temp;
    }
    return b;
}

struct nCr{
  vector<lli> f, rf;
  lli count=0;
  nCr(lli num): f(num), rf(num){
      count = num;
      f[0] = 1;
      rep1(i, num) f[i] = (f[i - 1] * i) % MOD;
      rep0(i, num+1) rf[i] = inv(f[i]);
  }
    
  lli inv(lli x) {
      lli res = 1;
      lli k = MOD - 2;
      lli y = x;
      while (k) {
          if (k & 1) res = (res * y) % MOD;
          y = (y * y) % MOD;
          k /= 2;
      }
      return res;
  }
  lli C(lli n, lli k) {
      lli a = f[n];
      lli b = rf[n-k];
      lli c = rf[k];
   
      lli bc = (b * c) % MOD;
   
      return (a * bc) % MOD;
  }
};

struct UF{
    vector<int> par,size;

    UF(int N) : par(N), size(N, 1){
        rep0(i,N)par[i] = i;
    }

    int root(int x){
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] = ry;
        size[rx] += size[ry];
    }

    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int getSize(int x){
        return size[x];
    }
};
int main(){
  lli n;
  cin >>n;
  cout << n/500*1000 + n%500/5*5;
}


Measured memory_bytes: 384
while 1:
	a,b,c,d,e = map(int,raw_input().split())
	if a == 0: break
	na,nb,nc = map(int,raw_input().split())
	ans = a*na + b*nb + c*nc
	if nc >= d:
		ans = a*na + b*nb +e*nc
	else:
		nd = d; d -= nc
		t = nb if nb < d else d
		nb -= t; d -= t
		t = na if na < d else d
		na -= t; d -= t
		ans = min(ans,a*na + b*nb + e*nd)
	print ans

Measured memory_bytes: 4228
import sys 
import math
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
a,b,c,d = map(int,readline().split())
T = int(math.ceil(a / d))
A = int(math.ceil(c / b))
if A > T:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 9136
#include<bits/stdc++.h>
using namespace std;
 
/*
*****************code written By**********************
..................Marajul islam.......................
...................BSMRSTU,CSE........................
*/ 
 
int sc1() {int x; scanf("%d", &x); return x;}
 
long long sc2() {long long x; scanf("%lld", &x); return x;}
 
 
 
#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  Int              sc1()
#define  LL               sc2()
#define  For(n)           for(int i=0;i<n;i++)
#define  Forj(n)          for(int j=0;j<n;j++)
#define  Fork(n)          for(int k=0;k<n;k++)
#define  For1(n)          for(int i=1;i<=n;i++)
#define  ll               long long
#define  vi               std::vector<int>
#define  vll              std::vector<ll>
#define  qui              qu
#define  pb               push_back
#define  mpsi             std::map<string, int>
 
 
const int mod           = 1e9 + 7;
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)1e18 + 5;
const int N             = 5e6 + 5;
 
inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (ll)a * b % mod;}
 

 
 
int solve() {
	int h,a;
	cin>>h>>a;
	int ans=h/a;
	if(h%a) ans++;
	cout<<ans<<endl;
 

 
	return 0;
}
 
 
 
 
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
 
	int test = 1, tc = 0;
	//scanf("%d", &test);
	//cin >> test;
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
 
	return 0;
 
 
 
 
}




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

struct UnionFind {
	vector<int> par;
	
	UnionFind(int n) : par(n) {
		for (int i = 0; i < n; i++) par[i] = i;
	}
	
	int root(int x) {
		return par[x] == x ? x : par[x] = root(par[x]);
	}
	
	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x != y) par[x] = y;
	}
	
	bool same(int x, int y) {
		return root(x) == root(y);
	}
};

struct Cell { double x, y, z, r; };

struct Edge {
	int from, to;
	double cost;
	bool operator <(const Edge &e) { return cost < e.cost; }
};

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) break;
		vector<Cell> cells(n);
		rep(i, n) {
			double x, y, z, r;
			cin >> x >> y >> z >> r;
			cells[i] = {x, y, z, r};
		}
		vector<Edge> edges;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				double dx = cells[i].x - cells[j].x;
				double dy = cells[i].y - cells[j].y;
				double dz = cells[i].z - cells[j].z;
				double dr = cells[i].r + cells[j].r;
				double cost = max(0.0, sqrt(dx * dx + dy * dy + dz * dz) - dr);
				edges.push_back({i, j, cost});
			}
		}
		sort(edges.begin(), edges.end());
		UnionFind uf(n);
		double ans = 0;
		for (auto a : edges) {
			if (!uf.same(a.from, a.to)) {
				uf.unite(a.from, a.to);
				ans += a.cost;
			}
		}
		printf("%.3f\n", ans);
	}
	return 0;
}


Measured memory_bytes: 3400
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a; 
  int count = 0;
 
  cin >> a;
  
  for(int i = 0; i < 3; i++){
   if(a[i] == '1')
     count++;
  }
  
  cout << count << endl;
}

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

namespace program
{
    class Program
    {
        static void Main()
        {
          Console.WriteLine($"{Input.ScanStr()[0]}{Input.ScanStr()[1]}{Input.ScanStr()[2]}");
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		int i = sc.nextInt();
		
		System.out.print("Christmas");
		
		for(int x = i; x < 25; x++)
		{
			System.out.print(" Eve");
		}

	}

}


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

using ll = long long;

int main() {
    ll N, M;
    cin >> N >> M;
    cout << (1 << M) * (1800 * M + 100 * N) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    long int x,y,a,s=1;
    cin>>x>>y;
    a=x;
    while(2*a<=y){
        a*=2;
        s++;
    }
    cout<<s;
    return 0;
}


Measured memory_bytes: 256
fun main(arr:Array<String>) {
    val (n,k) = readLine()!!.split(" ").map { it.toInt() }
    val balls = readLine()!!.split(" ").map { it.toInt() }
    val ballCount = mutableMapOf<Int, Int>()
    balls.forEach{
        if(ballCount.containsKey(it)) {
            ballCount[it] = ballCount[it]!!+1
        } else {
            ballCount[it] = 1
        }
    }
    val ans = ballCount.toList().sortedBy { it.second }.take(Math.max(0, ballCount.size - k)).sumBy { it.second }
    println(ans)
}


Measured memory_bytes: 85996
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30));
const ll linf = (1LL<<60);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll ans = 0;
    int b=0;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i] == 'B') b++;
        else ans += b;
    }
    cout << ans << endl;
    return 0;
}



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

int ctoi(char c){
    int i = c - '0';
    return i;
}
int main(){
    string s;
    cin >> s;
    int n = stoi(s), sum = 0;
    for(int i = 0; i < s.size(); i++){
        sum += ctoi(s[i]);
    }
    if(n % sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

const long MOD = 998244353;
const long INF = 1L << 59;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto K = s[1];
    auto A = readln.split.map!(x => x.to!int-1).array;
    auto Q = readln.split.map!(x => x.to!int-1).array;

    if (N == 1) {
        1.writeln;
        return;
    }

    int front = A.front;
    int back = A.back;
    auto prev = new int[](N);
    auto next = new int[](N);
    foreach (i; 0..N) {
        prev[A[i]] = i == 0 ? -1 : A[i-1];
        next[A[i]] = i == N-1 ? -1 : A[i+1];
    }

    foreach (q; Q) {
        int f = front;
        int b = back;
        int cur = q;
        int p = prev[q];
        int n = next[q];
        if (p == -1) {
            prev[cur] = back;
            next[cur] = -1;
            prev[n] = -1;
            next[back] = cur;
            front = n;
            back = cur;
        } else if (n == -1) {
            prev[cur] = -1;
            next[cur] = front;
            prev[front] = cur;
            next[p] = -1;
            front = cur;
            back = p;
        } else {
            prev[n] = -1;
            next[p] = -1;
            prev[cur] = b;
            next[cur] = f;
            prev[f] = cur;
            next[b] = cur;
            front = n;
            back = p;
        }
    }

    int[] ans;
    for (int a = front; a != -1; a = next[a]) {
        ans ~= a + 1;
    }
    ans.map!(to!string).join(" ").writeln;
}



Measured memory_bytes: 11548
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;
import java.util.List;
import java.awt.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    /* 変数宣言 */
    int A,B;

    AtCoder(FastScanner sc) {
        A = sc.nextInt();
        B = sc.nextInt();
    }

    void solve(PrintWriter out) {
        out.println(A*B);
    }
}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 32460
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

vector<int> solve(int n){
	vector<int> d;
	for(int i=1;i*i<=n;i++){
		if(n%i) continue;
		d.push_back(i);
		if(n!=i*i) d.push_back(n/i);
	}
	return d;
}

signed main(){
	int n;
	cin>>n;
	vector<int> d(n);
	rep(i,0,n) cin>>d[i];
	
	map<int,int> mp;
	rep(i,0,n){
		vector<int> y=solve(d[i]);
		rep(j,0,y.size()){
			mp[y[j]]++;
		}
	}
	for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++){
		if(it->se==n) cout<<it->fi<<endl; 
	}
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int h[n],a[m],b[m];
    for(int i=0;i<n;i++)cin>>h[i];
    vector<vector<int>>pas(n);
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        pas[a[i]-1].push_back(b[i]-1);
        pas[b[i]-1].push_back(a[i]-1);
    }
    int good=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<pas[i].size();j++){
            if(h[i]<=h[pas[i][j]]){
                good--;
                break;
            }
        }
        good++;
    }
    cout<<good<<endl;
    return 0;
}

Measured memory_bytes: 9596
using System;

class Program
    {
        static void Main(string[] args)
        {
            string[] nums = Console.ReadLine().Split();

            int K = int.Parse(nums[0]);
            int X = int.Parse(nums[1]);

            var numlen = ((K - 1) * 2) + 1;
            var val = new int[numlen];

            for (int i = 0; i < numlen; i++)
            {
                if (i == 0)
                {
                    val[i] = X - (K - 1);
                }
                else
                {
                    val[i] = val[i - 1] + 1;
                }
            }

            for (int i = 0; i < numlen; i++)
            {
                Console.Write(val[i].ToString() + " ");
            }

        }
    }

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

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

    for(char c = 'a'; c <= 'z'; c++) {
        if(count(s.begin(), s.end(), c) == 0) {
            cout << c << endl;
            return 0;
        }
    }
    cout << "None" << endl;

    return 0;
}

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

vector<int> lcm(vector<int> a, vector<int> b) {
    vector<int> ret;
    int n = a.size(), m = b.size();
    int i = 0, j = 0;
    for (; i < n && j < m; ) {
        if (a[i] == b[j]) {
            ret.push_back(a[i]);
            i += 1;
            j += 1;
        } else if (a[i] < b[j]) {
            ret.push_back(a[i]);
            i += 1;
        } else {
            ret.push_back(b[j]);
            j += 1;
        }
    }

    while (i < n) {
        ret.push_back(a[i++]);
    }

    while (j < m) {
        ret.push_back(b[j++]);
    }

    return ret;
}

vector<int> pr(int a) {
    vector<int> ret;
    for (int i = 2; i * i <= a; i += 1) {
        while (a % i == 0) {
            ret.push_back(i);
            a /= i;
        }
    }
    if (a > 1) ret.push_back(a);
    return ret;
}

ll powmod(ll a, ll x, ll m) {
    ll ret = 1;
    while (x) {
        if (x % 2) ret = ret * a % m;
        a = a * a % m;
        x /= 2;
    }
    return ret;
}


const ll MOD = 1000000007;
int A[10101];

void solve() {
    int N; cin >> N;
    REP(i, N) cin >> A[i];

    if (N == 1) {
        cout << 1 << endl;
        return;
    }

    auto lm = lcm(pr(A[0]), pr(A[1]));
    REP2(i, 2, N) lm = lcm(lm, pr(A[i]));

    ll x = 1;
    for (const auto a: lm) x = x * a % MOD;

    ll s = 1;
    REP(i, N) s = s * A[i] % MOD;

    ll ans = 0;
    REP(i, N) (ans += s * powmod(A[i], MOD-2, MOD) % MOD) %= MOD;

    ans = ans * x % MOD;
    ans = ans * powmod(s, MOD-2, MOD) % MOD;


    cout << ans << endl;
}

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


Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,f,n) for(int i=f; i<(n); i++)
int m_x[4] = { 0, 0,-1, 1};
int m_y[4] = {-1, 1, 0, 0};

int main()
{
  int ans = 0, cnt = 0;
  int n;
  cin >> n;
  REP(i,0,n){
    int a, b;
    cin >> a >> b;
    if(a==b)cnt++;
    else cnt=0;
    if(cnt>=3)ans=1;
  }

  if(ans==1)cout << "Yes" << endl;
  else cout << "No" << endl;

  //--debug : end_stoper
  //string end_stoper; cin >> end_stoper;

  return 0;
}

Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////

ll dp[200][5][2];
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string S; cin >> S;
    int N = S.size();
    int K; cin >> K;

    dp[0][0][0] = 1;
    rep(i,N) {
        int n = S[i] - '0';
        rep(j,5) {
            if (n) {
                if (j > 0) dp[i+1][j][0] += dp[i][j-1][0];
                dp[i+1][j][1] += dp[i][j][1] + dp[i][j][0];
                if (j > 0) dp[i+1][j][1] += dp[i][j-1][1]*9 + dp[i][j-1][0]*(n-1);
            } else {
                dp[i+1][j][0] += dp[i][j][0];
                dp[i+1][j][1] += dp[i][j][1];
                if (j > 0) dp[i+1][j][1] += dp[i][j-1][1]*9;
            }
        }
    }

    cout << dp[N][K][0] + dp[N][K][1] << endl;
}

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

int main()
{
	int n;
	cin >> n;
	vector<vector<pair<int,int>>> tree(n + 1);
	for (int i = 1; i <= n - 1; ++i) {
		int u, v, w;
		cin >> u >> v >> w;
		tree[u].push_back({ v, w });
		tree[v].push_back({ u, w });
	}

	vector<int> ret(n + 1, -1);
	queue<pair<int, int>> q;
	q.push({1,0});
	ret[1] = 0;

	while (!q.empty())
	{
		pair<int,int> f = q.front();
		for (auto& cand : tree[f.first]) {
			if (ret[cand.first] != -1) {
				continue;
			}

			if (cand.second % 2 == 0) {
				ret[cand.first] = ret[f.first];
			}
			else {
				ret[cand.first] = ret[f.first] ^ 1;
			}

			q.push(cand);
		}

		q.pop();
	}

	for (int i = 1; i <= n; ++i) {
		cout << ret[i] << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 6784
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

long long  mod = 1000000007;

int p[200010];


int main(){
	int n,k;
	cin >> n >> k;
	for(int i=0;i<n;i++){
		int tmp;
		cin >> tmp;
		p[tmp] += 1;
	}
	vector<int> v;
	for(int i=1;i<=n;i++){
		if(p[i]!=0){
			v.PB(p[i]);
		}
	}
	sort(v.begin(),v.end(),greater<int>());
	int ans = 0;
	bool flag = 0;
	for(int i=0;i<k;i++){
		if(i==v.size()-1){
			flag = 1;
			break;
		}
		ans +=v[i];
	}
	if(flag)cout << 0 << endl;
	else 	cout << n-ans << endl;
	return 0;
}

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

int main(void) {

    int N, M; cin >> N >> M;
    vector<string> A(N), B(M);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < M; i++) cin >> B[i];

    bool flag = false;
    for (int i = 0; i < N-M+1; i++) {
        for (int j = 0; j < N-M+1; j++) {
            flag = true;
            for (int k = 0; k < M; k++) {
                for (int l = 0; l < M; l++) {
                    if (A[i+k][j+l] != B[k][l]) flag = false;
                }
            }
            if (flag) break;
        }
        if (flag) break;
    }

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

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string s;
  cin >> s;
  cout << (s<="2019/04/30"?"Heisei":"TBD") << endl;
}


Measured memory_bytes: 256
#Dequeを用いたBFS
from collections import deque

N,M = map(int,input().split())

r = [[] for i in range(N+1)] #ノードの初期化

for i in range(M):
    a,b = map(int,input().split())
    r[a].append(b)
    r[b].append(a)

miteru = deque([1]) #見てる要素
mita = {1} #見た要素
res = [-1]*(N+1)

while  miteru: 
    now = miteru.popleft()
    x =set( r[now])
    x = x - mita
    for i in x:
        miteru.append(i)
        if res[i] == -1:res[i] =now
        mita.add(i)
    
print("Yes")
for i in res[2:]:
    print(i)
#print("\n".join(res))


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

int main(){
  int N;
  cin >> N;
  int v[N];
  for(int i = 0; i < N; i++){
    cin >> v[i];
  }
  for(int i = 0; i < N - 1; i++){
    for(int j = i + 1; j < N; j++){
      if(v[j] < v[i]){
        int temp = v[j];
        v[j] = v[i];
        v[i] = temp;
      }
    }
  }
  double sum = 0;
  sum += v[0] / pow(2, N - 1);
  for(int i = 1; i < N; i++){
    sum += v[i] / pow(2, N - i);
  }
  cout << fixed << setprecision(10);
  cout << sum << endl;
}

Measured memory_bytes: 512
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const int inf=1e18,M=1e9+7;
const int N=1e6+10;

int dp[N][2];
vector<int> v;

int rec(int n,int car)
{
    if(n==0)
        return car;

    if(dp[n][car]!=-1)
        return dp[n][car];

    int res=0;

    if(v[n]==9 && car)
        res=rec(n-1,1);
    else
    {
        int x=v[n];
        x+=car;

        res=min(x+rec(n-1,0),(10-x)+rec(n-1,1));
    }

    return (dp[n][car]=res);
}

void solve()
{
    mem(dp,-1);

    string s;
    cin>>s;

    int n=s.length();
    v.resize(n+1);
    fill(all(v),0);

    for(int i=0;i<n;++i)
        v[i+1]=(s[i]-'0');

    int ans=rec(n,0);
    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




Measured memory_bytes: 71708
#include <bits/stdc++.h>
#define rep(i , n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main (){
    int a;
    cin >> a;
    int L = a / 100;
    int R = a % 100;
    if(1 <= L && L <= 12){
        if(1 <= R && R <= 12){
            cout << "AMBIGUOUS" << endl;
        }
        else{
            cout << "MMYY" << endl;
        }
    }
    else{
        if(1 <= R && R <= 12){
            cout << "YYMM" << endl;
        }
        else{
            cout << "NA" << endl;
        }
    }
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;

int main(){
    int A, B, C; cin >> A >> B >> C;

    if(A > B + C) {
        cout << 0 << endl;
    } else {
        cout << C - (A - B) << endl;
    }
}

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

// 三項演算子で1行で最大公約数を返す
ll gcd(ll x, ll y){ return y ? gcd(y, x%y) : x;}

vector<pair<ll,int>> factorize(ll n){
  vector<pair<ll, int>> res;
  for(ll i = 2; i*i <= n; ++i){
    if(n%i) continue;
    res.emplace_back(i,0);
    while(n%i == 0){
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n,1);
  return res;
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  auto f = factorize(g);
  int ans = f.size() + 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <numeric> 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define int long long int
#define mod 1000000007
#define INT_BITS 16
#define INF 10000000
#define pi 3.141592
#define watch(x) cout<<(#x)<<"="<<(x)<<"\n" 
#define pb push_back
//__builtin_popcount

#ifndef ONLINE_JUDGE
    #include "debug.cpp"
#endif

int power(int x,int y)
{
    int sum=1;
    for(int i=0;i<y;i++)
        sum=(sum*x)%mod;
    return sum;
}

int32_t main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    // fast;

   int n;
   cin>>n;

   if(n==1)
    cout<<0<<endl;
    else
    {
        int sum=power(10,n)-power(9,n)-power(9,n);
        sum=(sum+power(8,n))%mod;
        if(sum<0)
            sum+=mod;
        cout<<sum<<endl;
    }


    
 return 0;

}


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

int main(){
	string input;
	
		while(cin>>input){
			string ans;
			for(int i=0;i<input.size();i++){
				if(input.substr(i,1)!="@") ans+=input.substr(i,1);
				else{
					int n=atoi(input.substr(i+1,1).c_str());
					for(int j=0;j<n;j++)ans+=input.substr(i+2,1);
					i+=2;
				}
			}
			cout<<ans<<endl;
		}
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define li long long
#define itn int
 
using namespace std;
 
inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

template <typename T>
ostream& operator <<(ostream& ostr, const vector<T>& a) {
	ostr << "(";
	for (size_t i = 0; i < a.size(); ++i) {
		if (i) {
			ostr << ", ";
		}
		ostr << a[i];
	}
	ostr << ")";
	return ostr;
}

const int N = 100;
int a[N][N];

int main() {
	string s;
	cin >> s;
	cout << s.substr(0, s.length() - 8);

	return 0;
}

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


long long N;
pair<long long, int> AB[200000];


int main(){
    cin >> N;
    long long sum_a = 0, sum_b = 0;
    for(int i = 0; i < N; i++){
        int a, b;
        cin >> a >> b;
        AB[2*i] = make_pair(a, i);
        AB[2*i+1] = make_pair(b, i);
        sum_a += a;
        sum_b += b;
    }

    long long ans = min(sum_a, sum_b);

    sort(AB, AB + 2 * N);

    bool check[100000] = {}, easy_case = false;
    long long first_sum = 0;
    for(int i = 0; i < N; i++){
        int p = AB[i].second;
        if(check[p]){
            easy_case = true;
        }
        check[p] = true;
        first_sum += AB[i].first;
    }

    if(easy_case){
        ans = min(ans, first_sum);
    }else{
        if(AB[N-1].second != AB[N].second){
            ans = min(ans, first_sum - AB[N-1].first + AB[N].first);
        }else{
            ans = min(ans, first_sum - AB[N-2].first + AB[N].first);
            ans = min(ans, first_sum - AB[N-1].first + AB[N+1].first);
        }
    }

            
    
    cout << ans << endl;
}



Measured memory_bytes: 3456