akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;


int main(){
	int n, m;
	cin >> n >> m;
	vector<int> deg(n, 0);
	vector<vector<int> > edges(n);
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		a--; b--;
		deg[a]++; deg[b]++;
		edges[a].push_back(b);
		edges[b].push_back(a);
	}
	for(int i = 0; i < n; i++){
		if(deg[i] & 1){
			cout << "No" << '\n';
			exit(0);
		}
	}
	for(int i = 0; i < n; i++){
		if(deg[i] >= 6){
			cout << "Yes" << '\n';
			exit(0);
		}
	}
	int d4 = 0;
	for(int i = 0; i < n; i++){
		if(deg[i] >= 4) d4++;
	}
	if(d4 >= 3){
		cout << "Yes" << '\n';
		exit(0);
	} else if(d4 == 2){
		vector<int> d4s;
		for(int i = 0; i < n; i++) if(deg[i] == 4) d4s.push_back(i);
		int v = d4s[0];
		int w = d4s[1];
		int npaths = 0;
		for(int x : edges[v]){
			int cur = x;
			int p = v;
			while(cur != v && cur != w){
				assert(int(edges[cur].size()) == 2);
				p = edges[cur][0] + edges[cur][1] - p;
				swap(p, cur);
			}
			if(cur == w) npaths++;
		}
		if(npaths == 2){
			cout << "Yes" << '\n';
		} else if(npaths == 4){
			cout << "No" << '\n';
		}
	} else if(d4 <= 1){
		cout << "No" << '\n';
		exit(0);
	}
}

Measured memory_bytes: 6144
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func stringLineScan() string {
	sc.Scan()
	return sc.Text()
}

type SortName [][]int

func (x SortName) Len() int           { return len(x) }
func (x SortName) Less(i, j int) bool { return x[i][1] < x[j][1] }
func (x SortName) Swap(i, j int)      { x[i], x[j] = x[j], x[i] }

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(stringLineScan())
	s := stringLineScan()
	t := stringLineScan()
	ans := 3
	d := 1000000007
	f := true
	for i := 0; i < n; i++ {
		if i == 0 {
			if s[i] != t[i] {
				ans *= 2
				i++
				f = false
			}
			continue
		}
		if s[i] != t[i] && f {
			ans = ans * 2 % d
			i++
			f = false
		} else if s[i] != t[i] {
			ans = ans * 3 % d
			i++
		} else if s[i] == t[i] && f {
			ans = ans * 2 % d
		} else {
			f = true
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n,m) for(int i=n;i<m;i++)
int main()
{
    int H, W; cin >> H >> W;
    bool M[52*52] = {};
    auto YX = [&](int y, int x){ return y * (W + 2) + x; };
    FOR(y, 1, H+1) FOR(x, 1, W+1) {
        char c; cin >> c;
        if (c == '#') M[YX(y, x)] = true;
    }
    vector<int> v = { -W-3, -W-2, -W-1, -1, +1, W+1, W+2, W+3 };
    FOR(y, 1, H+1) {
        FOR(x, 1, W+1) {
            if (M[YX(y, x)]) cout << '#';
            else {
                int cnt = 0;
                for (int i : v) if (M[YX(y, x)+i]) cnt++;
                cout << cnt;
            }
        }
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
  int N;
  cin>>N; 
  vector<int> a(N);  
  for(int j=0; j<N;j++){
    cin>>a.at(j);
  }
  
  
  long to=0;
  for(int i=0; i<N-1;i++){
    to+=a.at(i);
  }
  to-=a.at(N-1);
  long ans=abs(to);
  for(int i=N-2; i>0;i--){
    ans=min(ans,abs(to-2*a.at(i)));
    to-=2*a.at(i);
  }
   
  cout<<ans<<endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    string s,t;
    cin>>n>>s>>t;
    int cnt=0,a=0;
    if(n==1){
        if(s==t) cout<<1;
        else cout<<2;
        return 0;
    }
    rep(a,n){
        int match=0;
        rep(i,n-a){
            if(s[i+a]==t[i]) match++;
        }
        if(match==n-a){
            cout<<n+a;
            return 0;
        }
    }
    cout<<2*n;
}

Measured memory_bytes: 3560
#include "bits/stdc++.h"
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  vector<int>v(N*2);
  for(auto &i:v)cin>>i;
  sort(v.begin(),v.end());
  int L=-1,R=N;
  while(R-L>1){
    int mid=(R+L)/2;
    bool flag=true;
    int index =mid*2;
    int rindex =2*N-1;
    while(index<rindex){
      if(v[index]+v[rindex]<M){
        flag=false;
        break;
      }
      index++;
      rindex--;
    }
    if(flag)R=mid;
    else L=mid;
  }
 // cout<<R<<endl;
  if(R==N){
    int ans=0;
    int index =0,rindex=N*2-1;
    while(rindex>index){
      ans=max(ans,v[index]+v[rindex]);
      index++;
      rindex--;
    }
    cout<<ans<<endl;
    return 0;
  }
  int ans=0;
  int index =0,rindex=R*2-1;
  while(rindex>index){
    ans=max(ans,v[index]+v[rindex]);
    index++,rindex--;
  }
  index=R*2,rindex=N*2-1;
  while(rindex>index){
    ans=max(ans,(v[index]+v[rindex])%M);
    index++,rindex--;
  }
  cout<<ans<<endl;
  return 0;
}

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

int main() {
  string s; cin >> s;
  int sn = s.size();
  int cnt = 0;
  rep(i,sn) {
    cnt++;
    while (i < sn && s[i] == s[i+1]) i++;
  }
  cout << cnt - 1 << endl;
  return 0;
}

Measured memory_bytes: 3756
tmp = input().split()
m = tmp[0]
d = tmp[1]

if 1 <= int(m) and int(m) <= 100:
    if 1 <= int(d) and int(d) <= 99:
        count = 0
        for i in range(1, int(d)+1):
            if len(str(i)) == 2:
                d1 = int(str(i)[0])
                d2 = int(str(i)[1])
                if d1 >= 2 and d2 >= 2:
                    tmp = d1 * d2
                    # print(tmp)
                    if tmp in range(1, int(m)+1):
                        # print(i)
                        count += 1
        print(count)

Measured memory_bytes: 3064
/*g++ file.cpp -o file.out*/
/*./file.out*/

#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define LL long long
#define Mod 1000000007
#define L_Mod 17100000013

int main()
{
    int K,S,sov=0,X,Y,Z;
    scanf("%d%d",&K,&S);
    for(X=0;X<=K;X++)
    {
        for(Y=0;Y<=K;Y++)
        {
            Z=S-X-Y;
            if(Z>=0&&Z<=K)
            {
                sov++;
            }
        }
    }
    printf("%d\n",sov);
    return 0;
}


Measured memory_bytes: 256
#include<iostream> 
#include<vector> 
#include<algorithm> 
#include<iomanip> 
#include<stack> 
#include<unordered_map>
#include<queue> 
#include<deque>
#include<map> 
#include<climits>
#include<set> 
#include<string> 
//#include<time.h>
//#include<bits/stdc++.h> 
using namespace std; 
#define lld long long int 
#define eb emplace_back
//to insert pair use eb
#define mp make_pair
#define fi first
#define se second
#define pb push_back

#define X 1000000007
#define Y 998244353
#define E4 10000
#define E5 100000
#define E6 1000000
#define inf 2001001001001001001
#define pi 3.1415926535

# define rec2(i,a,n) for(lld i=a;i<n;i++) 
#define rec(i,n) for(lld i=0;i<n;i++)
#define rev(i,a,n) for(lld i=n-1;i>=a;i--)
#define all(v) (v).begin(), (v).end()
#define large(v)  *max_element(all(v))
#define small(v)  *min_element(all(v)) 
#define v vector 
#define p(x,y)  pair<x,y> 
const double EPS = 1e-6;

void google(int i)
{  cout<<"Case #"<<i<<": "; }

//prime[i]==1 if it is prime 
lld prime[E6+1]; 
void sieve(lld n) 
{ rec(i,n+1) 
    prime[i]=1; 
   for(lld i=2;i*i<=n;i++) 
     { if(prime[i]!=1) 
          continue; 
         for(lld j=i*i;j<=n;j=j+i) 
          if(prime[j]==1)
           prime[j]=i; 
      }
}

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

//fermat a^(m-2)%mod
lld binarymul(lld a,lld n,lld m)
{  lld res=1; 
 while(n) 
  { if(n%2) 
      { res=(res*a)%m; 
         n--; 
      } 
     a=(a*a)%m; 
     n/=2; 
  }
  return res; 
}
/*
void complexity(time_t end,time_t start)
{ 
  double taken = double(end - start); 
    cout<<"Time : "; 
    cout<<fixed<<taken<<setprecision(8);         cout<<" sec "<<endl;
}
*/ 
void bfs(lld s,v<lld> g[],lld n)
{ 
   bool vis[n]; 
   rec(i,n) 
    vis[i]=false; 
    
   vis[s]=true; 
   deque<lld> q; 
   q.pb(s); 
   
   while(!q.empty()) 
   {  
      s=q.front(); 
     q.pop_front(); 
      
     for(lld i=0;i<g[s].size();i++) 
      {  
        if(!vis[g[s][i]])
         { vis[g[s][i]]=true; 
            q.pb(g[s][i]); 
         }
      }
   }
}

void dfs(lld u,v<lld> g[],bool *vis)
{ 

   vis[u]=true; 
   for(lld i=0;i<g[u].size();i++) 
     if(!vis[g[u][i]])
          dfs(g[u][i],g,vis); 
       
}
void contest(lld t); 
int main()
{   
    /*
    time_t start, end; 
    time(&start); 
    */
   ios_base::sync_with_stdio(false); 
   cin.tie(0);
     #ifdef PUNEET_GOEL
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif
   //sieve(E6); 
    lld T=1; 
    rec(t,T) 
    {
      contest(t); 
    }
    /*
     time(&end); 
    complexity(end,start);
    */
	return 0;
}

void contest(lld t)
{ 
  lld n; 
  cin>>n; 
  lld ans=0; 
  for(lld i=1;i<=n;i++) 
   { 
     lld j=0; 
    while(1) 
     { 
       j++; 
       if(i*j>=n) 
         break; 
        ans++; 
     }     
   }
   cout<<ans<<endl; 
}

Measured memory_bytes: 3652
n, k = map(int, input().split())
s = input()

cnt_1 = 0
cnt_2 = 0
res = 0
for i in range(n-1):
    if s[i] == 'L' and s[i+1] == 'R':
        cnt_1 += 1
    elif s[i] == 'R' and s[i+1] == 'L':
        cnt_2 += 1
    else:
        res += 1

if min(cnt_1, cnt_2) < k:
    res += min(cnt_1, cnt_2) * 2
    if cnt_1 != cnt_2:
        res += 1
else:
    res += k * 2

print(res)

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

#define int long long int
#define MOD 1000000007

void solve()
{
    int n ;
    cin >> n ;
    string s ;
    cin >> s ;
    string ans = "" ;
    for(int i = 0 ; i < n/2 ; i++)
    {
        ans += s[i] ;
    }
    ans += ans ;
    if(ans == s)
    {
        cout << "Yes\n" ;
    }
    else
    {
        cout << "No\n" ;
    }
}

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

    int t = 1 ;
    //cin >> t ;
    while(t--)
    {
        solve() ;
    }
    return 0 ;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
      
       Scanner scan = new Scanner(System.in);
       
       int S = scan.nextInt();
       
       System.out.print(S / 3600);
       System.out.print(":");
       System.out.print(S % 3600 / 60);
       System.out.print(":");
       System.out.println(S % 3600 % 60 );
   }
}


Measured memory_bytes: 26356
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_map>
# include <unordered_set>
# include <thread>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ui32 = unsigned int;
constexpr ll INFLL = 1e18;

#define CHECK_IMPL1(cond)              \
if (!(cond)) {                         \
    DEBUG("expected cond: " << #cond); \
    assert(cond);                      \
}

#define CHECK_IMPL2(cond, message)                                            \
if (!(cond)) {                                                                \
    DEBUG("expected cond: " << #cond << " failed with message: " << message); \
    assert(cond);                                                             \
}
#define CHECK_IMPL(_1, _2, NAME, ...) NAME
#define CHECK(...) CHECK_IMPL(__VA_ARGS__, CHECK_IMPL2, CHECK_IMPL1, CHECK_IMPL0)(__VA_ARGS__)

#ifdef __APPLE__
#define DEBUG(message) std::cerr << message << std::endl;
#else
#define DEBUG(message)
#endif

void solve() {
  int n;
  cin >> n;

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

  ll ans = 0;

  for (int i = 0; i < n; i++) {
    if (i > 0 && a[i - 1] && a[i]) {
      ++ans;
      --a[i - 1];
      --a[i];
    }
    ans += a[i] / 2;
    a[i] %= 2;
  }

  cout << ans << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
#ifdef __APPLE__
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
  int t = 1;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}


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

int compare_int(const void *a, const void *b){
    if ( *(int*)a > *(int*)b ) return 1;
    if ( *(int*)a < *(int*)b ) return -1;
    return 0;
}


int main(void){
    int n,i,j,temp;
    scanf("%d",&n);
    int a[n];
    for(i=0; i<n; i++){
        scanf("%d",&a[i]);
    }
    
    qsort(a, n, sizeof(int), compare_int);


    printf("%d\n",a[n/2] - a[n/2 - 1]);

    return 0;
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

 int main(){
   int N;
   cin >> N;
   if(0 < N && 1000 > N) print("ABC");
   if(999 < N && 1999 > N) print("ABD");

 }


Measured memory_bytes: 256
import sys
import math
from collections import Counter


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()
A = inintl()

C = Counter(A)
ans = 0

for c in C:
    if c > C[c]:
        ans += C[c]
    elif c < C[c]:
        ans += C[c] - c

print(ans)

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

void calc(vector<vector<int>> &T, vector<int> &ans, vector<bool> &isvisit, int parent, int cur){
    if(isvisit[cur]) return;
    else isvisit[cur] = true;
    ans[cur] += ans[parent];
    for(int i = 0; i < T[cur].size(); i++){
        calc(T, ans, isvisit, cur, T[cur][i]);
    }
}

int main(){
    int n, q;
    cin >> n >> q;
    vector<vector<int>> T(n+1);
    for(int i = 0; i < n-1; i++){
        int a, b;
        cin >> a >> b;
        T[a].push_back(b);
        T[b].push_back(a);
    }
    vector<int> ans(n+1, 0);
    vector<bool> isvisit(n+1, false);
    for(int i = 0; i < q; i++){
        int p, x;
        cin >> p >> x;
        ans[p] += x;
    }

    calc(T, ans, isvisit, 0, 1);
    for(int i = 1; i <= n; i++) cout << ans[i] << " ";
    return 0;
}

Measured memory_bytes: 27524
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (ll)1e9+7
#define LLINF (ll)1e30
// #define int ll
using namespace std;
const int MOD = 1e9 +7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,W;
    ll w[110],v[110],dp[110][101010];
    cin>>N>>W;
    rep(i,N){
        cin>>w[i]>>v[i];
    }
    dp[0][0]=0;
    rep2(i,1,101010) dp[0][i]=INF;
    rep(i,N){
        rep(j,N*1000+1){
            if(j<v[i]){
                dp[i+1][j]=dp[i][j];
            } else {
                dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
            }
        }
    }
    int ans=0;
    rep(i,N*1000+1){
        if(dp[N][i]<= W) ans=i;
    }
    cout<<ans<<endl;
    return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
const int MOD =  1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;


int main() {
    int n, k; cin >> n >> k;
    string s; cin >> s;

    int cnt = 1;
    V<int> v;
    if(s[0] == '0') v.push_back(0);
    for(int i = 0; i < n; i++){
        if(s[i] == s[i + 1]) cnt++;
        else{
            v.push_back(cnt);
            cnt = 1;
        }
    }

    V<int> w((int)v.size() + 1, 0);
    for(int i = 0; i < (int)v.size(); i++){
        w[i + 1] = w[i] + v[i];
    }

    int ans = 0;
    int m = w.size();
    for(int i = 0; i < m; i+=2){
        int j = i + k * 2 + 1;
        if(j >= m) j = m - 1;
        ans = max(ans, w[j] - w[i]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4208
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main()
{
    ll n,W;
    cin>>n>>W;
    vector<ll> w(n +1),v(n + 1);
    for(int i = 0 ;i < n ;i++)
        cin>>w[i  + 1] >> v[i + 1];
    
    vector<ll > d(100001,(int)10e12);
    d[0] = 0;
    for(int i = 1 ; i <= n ;i++)
    {
        for(int j = 100000 ; j >= v[i] ; j--)
        {
            d[j] =  min(d[j],d[j - v[i]] + w[i]);
        }
    }
    int ans = 0;
    for(int i = 0 ; i <= 100000 ; i++)
    {
        if(d[i] <= W)
        {
            ans = i;
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 1024
import java.util.*;

public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int M = sc.nextInt();
        double[][] D = new double[N][N];
        for(int i = 0; i < N; i++){
            Arrays.fill(D[i], Double.POSITIVE_INFINITY);
        }
        for(int i = 0; i < N; i++){
            D[i][i] = 0;
        }
        int[][] a = new int[2][M];
        for(int i = 0; i < M; i++){
            a[0][i] = sc.nextInt();
            a[1][i] = sc.nextInt();
            D[a[0][i]-1][a[1][i]-1] = 1;
            D[a[1][i]-1][a[0][i]-1] = 1;
        }
        sc.close();
       

        int count = 0;
        for(int l = 0; l < M; l++){
            int start = a[0][l];
            int end = a[1][l];
            D[start-1][end-1] = Double.POSITIVE_INFINITY;
            D[end-1][start-1] = Double.POSITIVE_INFINITY;
            double[][] D1 = new double[N][N];
            for(int x = 0; x < N; x++){
                for(int y = 0; y < N; y++){
                    D1[x][y] = D[x][y];
                }
            }
            for(int k = 0; k < N; k++){
                for(int i = 0; i < N; i++){
                    for(int j = 0; j < N; j++){
                        D1[i][j] = Math.min(D1[i][j], D1[i][k]+D1[k][j]);
                    }
                }
            }
            
            if(!(isLink(D1)))
                count++;
            D[start-1][end-1] = 1;
            D[end-1][start-1] = 1;
        }

        System.out.println(count);
    }

    static boolean isLink(double[][] a){
        for(int i = 0; i < a.length; i++){
            for(int j = 0; j < a[i].length; j++){
                if(a[i][j] == Double.POSITIVE_INFINITY)
                    return false;
            }
        }
        return true;
    }
}

Measured memory_bytes: 24856
n = int(input())
f_inf = float('inf')
dp = [f_inf]*(n+1)
dp[0] = 0
for i in range(1,n+1):
  for j in range(7):
    if i-pow(6,j) >= 0:
      dp[i] = min(dp[i], dp[i-pow(6,j)]+1)
  for k in range(6):
    if i-pow(9,k) >= 0:
      dp[i] = min(dp[i], dp[i-pow(9,k)]+1)
print(dp[-1])

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll m,d; cin>>m>>d;
  ll ans=0;
  
  for(ll i=1; i<=m; i++){
    for(ll j=0; j<=d; j++){
      ll d1=j%10, d2=j/10%10;
      if(d1<2 || d2<2) continue;
      if(d1*d2==i) ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const int N = 5e5+200;
#define ll long long
#define rep(i,n) for(int i = 0; i < n; i++)
const int INF = 0x3f3f3f;
int main(){
	int a1,b;
	int n,m;
	cin>>n>>m;
	int sum = 0;
	int t = 1;
	rep(i,n){
		int x;
		cin>>x;
		sum +=x;
		if(sum <= m){
			t++;
		}
	}
	cout<<t<<endl;
}


Measured memory_bytes: 256
s=input()
ans=0
for i in range(2**(len(s)-1)):
  x=''
  x=s[0]
  for j in range(len(s)-1):
    if (i>>j)&1:
      x+='+'
    x+=s[j+1]
  ans+=sum(map(int,x.split('+')))
print(ans)

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

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int h,w,times=0;
    cin>>h>>w;
    int coin[h+1][w+1]={},coin1[h+1][w+1]={};
    for (int i = 1; i <= h; i++) for (int j = 1; j <= w; j++){
            cin>>coin[i][j];
            coin1[i][j]=coin[i][j];
        }

    for (int i = 1; i <= h; i++) for (int j = 1; j < w; j++){
            if(coin[i][j]%2==1){
                times++;
                coin[i][j+1]+=coin[i][j];
            }
        }
    for (int i = 1; i < h; i++) if(coin[i][w]%2==1){
        times++;
        coin[i+1][w]+=coin[i][w];
    }
    cout<<times<<'\n';
    for (int i = 1; i <= h; i++) for (int j = 1; j < w; j++){
            if(coin1[i][j]%2==1){
                cout<<i<<' '<<j<<' '<<i<<' '<<j+1<<'\n';
                coin1[i][j+1]+=coin1[i][j];
            }
        }
    for (int i = 1; i < h; i++) if(coin1[i][w]%2==1){
        cout<<i<<' '<<w<<' '<<i+1<<' '<<w<<'\n';
        coin1[i+1][w]+=coin1[i][w];
    }
}

Measured memory_bytes: 4096
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long K = long.Parse(str[0]);
		long A = long.Parse(str[1]);
		long B = long.Parse(str[2]);
		long ans = 0;
		if(A+2>=B){
			ans = 1+K;
		} else if(A>K+1){
			ans = 1+K;
		} else {
			long a1 = K-(A-1);
			ans = A+a1/2*(B-A)+a1%2;
		}
		Console.WriteLine(ans);
	}
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second

typedef int def; //default parameter for loops

#define fori(a) for(def i=0; i<(a); i++)
#define fori1(a) for(def i=1; i<=(a); i++)
#define fori_(a) for(def i=(a)-1; i>=0; i--)
#define fori1_(a) for(def i=(a); i>0; i--)
#define forii(a, b) for(def i=(a); i<(b); i++)
#define forii_(a, b) for(def i=(b)-1; i>=(a); i--)

#define forj(a) for(def j=0; j<(a); j++)
#define forj1(a) for(def j=1; j<=(a); j++)
#define forj_(a) for(def j=(a)-1; j>=0; j--)
#define forj1_(a) for(def j=(a); j>0; j--)
#define forjj(a, b) for(def j=(a); j<(b); j++)
#define forjj_(a, b) for(def j=(b)-1; j>=(a); j--)

#define fork(a) for(def k=0; k<(a); k++)
#define fork1(a) for(def k=1; k<=(a); k++)
#define fork_(a) for(def k=(a)-1; k>=0; k--)
#define fork1_(a) for(def k=(a); k>0; k--)
#define forkk(a, b) for(def k=(a); k<(b); k++)
#define forkk_(a, b) for(def k=(b)-1; k>=(a); k--)

#define forl(a) for(def l=0; l<(a); l++)
#define forl1(a) for(def l=1; l<=(a); l++)
#define forl_(a) for(def l=(a)-1; l>=0; l--)
#define forl1_(a) for(def l=(a); l>0; l--)
#define forll(a, b) for(def l=(a); l<(b); l++)
#define forll_(a, b) for(def l=(b)-1; l>=(a); l--)

#define forg(a) for(def g=0; g<(a); g++)
#define forg1(a) for(def g=1; g<=(a); g++)
#define forg_(a) for(def g=(a)-1; g>=0; g--)
#define forg1_(a) for(def g=(a); g>0; g--)
#define forgg(a, b) for(def g=(a); g<(b); g++)
#define forgg_(a, b) for(def g=(b)-1; g>=(a); g--)

#define forf(a) for(def f=0; f<(a); f++)
#define forf1(a) for(def f=1; f<=(a); f++)
#define forf_(a) for(def f=(a)-1; f>=0; f--)
#define forf1_(a) for(def f=(a); f>0; f--)
#define forff(a, b) for(def f=(a); f<(b); f++)
#define forff_(a, b) for(def f=(b)-1; f>=(a); f--)

#define forh(a) for(def h=0; h<(a); h++)
#define forh1(a) for(def h=1; h<=(a); h++)
#define forh_(a) for(def h=(a)-1; h>=0; h--)
#define forh1_(a) for(def h=(a); h>0; h--)
#define forhh(a, b) for(def h=(a); h<(b); h++)
#define forhh_(a, b) for(def h=(b)-1; h>=(a); h--)

#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

template <typename T>
std::ostream& operator<< (std::ostream& out, const std::vector<T>& v) {
  if ( !v.empty() ) {
    std::copy (v.begin(), v.end(), std::ostream_iterator<T>(out, " "));
  }
  return out;
}
template <typename T>
std::ostream& operator<< (std::ostream& out, const std::set<T>& v) {
  if ( !v.empty() ) {
    std::copy (v.begin(), v.end(), std::ostream_iterator<T>(out, " "));
  }
  return out;
}

const int N = 1e5+10;
const ll M = 1e9+7;

int main(){
	fastIO;
	int a, b;
	cin>>a>>b;
	cout<<a*b-a-b+1;
}


Measured memory_bytes: 256
import sys, math


if(__name__ == "__main__"):
    """

    元の数biを求めるにはxor_all= a1^a2^a3^...^an
    を求め、
    b1=xor_all^a1, b2 = xor_all^a2, ...とする。Nが偶数なので
    xor_all = b1^b2^...^bnと等しい(xorの性質よりx^a^a = xとなるので)
    xor_allにaiをかけるとちょうどbiだけ残る
    """
    N = int( input().strip() )
    xors = [0] * N
    Str = input().strip().split()
    for i in range(N):
        xors[i] = int( Str[i] )
    xor_all = xors[0]
    for i in range(1, N):
        xor_all = xor_all ^ xors[i]
    nums = [0] * N

    Str = ""
    for i in range(N):
        nums[i] = xor_all^xors[i]
        Str += str(nums[i]) + " "
    
    print(Str)


Measured memory_bytes: 32396
#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

const int N=1e3+5;

double store;
vector<int> red, v;

int sum(int k)
{
	int cur=0;
	while(k>0)
	{
		cur+=(k%10);
		k/=10;
	}
	return cur;
}

double get(int k)
{
	return (double)k/sum(k);
}

int32_t main()
{
	IOS;
	int cur=999999999999999LL;
	int put=1;
	red.push_back(put);
	store=(double)cur/sum(cur);
	for(int i=1;i<=15;i++)
	{
		put*=10;
		red.push_back(put);
	}
	while(cur!=1)
	{
		v.push_back(cur);
		for(auto it:red)
		{
			int nxt=cur-it;
			if(nxt<=0)
				break;
			if(get(nxt)<=get(cur))
			{
				cur=nxt;
				break;
			}
		}
	}
	v.push_back(1);
	reverse(v.begin(), v.end());
	int k;
	cin>>k;
	for(int i=0;i<k;i++)
		cout<<v[i]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

class solver {
    static constexpr int M = 1e5 + 10;
    vector<bool> prime;
    vector<int> c;
public:
    solver() : prime(M + 1, true), c(M + 1, 0) {
        eratosthenes();

        REP(i, M) {
            if (i % 2 == 0) continue;
            if (prime[i] && prime[(i + 1) / 2]) {
                c[i]++;
            }
        }

        REP(i, M) c[i + 1] += c[i];
    }

    int query(int l, int r) {
        return c[r] - c[l];
    }

private:
    void eratosthenes() {
        prime[0] = prime[1] = false;

        FOR(i, 2, M + 1) {
            if (prime[i]) {
                for (int j = 2; i * j < M; j++) {
                    prime[i * j] = false;
                }
            }
        }
    }
};

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

    solver s;

    REP(_, q) {
        int l, r; cin >> l >> r;
        cout << s.query(l - 1, r) << endl;
    }

    return 0;
}


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

int main(void) {
    int N;
    cin >> N;
    vector< int > W(N);
    int sum = 0;
    for (int i = 0; i < N; ++i) {
        cin >> W[i];
        sum += W[i];
    }
    int s1 = 0, s2 = sum;
    int ans = sum;
    for (int i = 0; i < N; ++i) {
        s1 += W[i];
        s2 -= W[i];
        ans = min(ans, abs(s2 - s1));
    }
    printf("%d\n", ans);
    return 0;
}


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

using namespace std;

# define ll long long
# define pll pair<ll,ll>
# define F first
# define S second
# define pb push_back
# define ld long double
ll mod=1000000007;

int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        ll t=1;
        //cin>>t;
        while(t--)
        {
            ll n,i,j,k=0;
            cin>>n>>k;
           vector<ll>v(n);
           for(i=0;i<n;i++)
           cin>>v[i];
           vector<ll>dp(n,INT_MAX);
           dp[0]=0;
          for(i=1;i<n;i++)
          {
              for(j=i-1;j>=i-k;j--)
              {
                  if(j<0)
                  break;
                  dp[i]=min(dp[i],dp[j]+abs(v[i]-v[j]));
              }
          }
          cout<<dp[n-1];
          
            
        }
        
    }

Measured memory_bytes: 1792
using System;
using System.Linq;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        long x = Math.Abs(sc.NextLong());
        long k = sc.NextLong();
        long d = sc.NextLong();

        // +側最小
        // x%d
        var p = x % d;
        var m = p - d;

        // pまでの移動何回か?
        long c = (x - p) / d;

        if (k < c)
        {
            Console.WriteLine(x - d * k);
        }
        else if (c % 2 == k % 2)
        {
            Console.WriteLine(p);
        }
        else
        {
            Console.WriteLine(Math.Abs(m));
        }
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 27540
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int n, m; cin >> n >> m;
    ll ans = 0;
    vector<int> a(n);
    vector<ll> s(n+1, 0LL);
    map<ll, ll> mp;
    ++mp[0]; //s[0]
    REP(i, n){
        cin >> a[i];
        s[i+1] = (s[i] + a[i]) % m;
        ++mp[s[i+1]]; // 剰余で場合分け
    }
    
    for(auto it: mp){
        ans += (it.second - 1) * it.second / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5376
from heapq import heappop, heappush

sx, sy, tx, ty = map(int, input().split())
n = int(input())
barriers = [tuple(map(int, input().split())) for _ in range(n)]
barriers.append((tx, ty, 0))
barriers.append((sx, sy, 0))
s = n + 1
t = n
q = [(0., s)]
visited = [False] * (n + 2)
while q:
    cost, v = heappop(q)
    if v == t:
        print(cost)
        break
    if visited[v]:
        continue
    visited[v] = True
    vx, vy, vr = barriers[v]
    for u in range(n + 1):
        if visited[u]:
            continue
        ux, uy, ur = barriers[u]
        new_cost = max(0, ((vx - ux) ** 2 + (vy - uy) ** 2) ** 0.5 - vr - ur)
        heappush(q, (cost + new_cost, u))


Measured memory_bytes: 75424
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var (N, M) = ReadLine().Split(' ').Select(int.Parse).ToArray();
        var AB = Enumerable.Range(0, M).Select(i => ReadLine().Split(' ').Select(int.Parse).Select(x => x - 1).ToArray());
        
        var uf = new UnionFind(N);

        foreach (var (A, B) in AB)
            uf.Unite(A, B);

        var ans = Enumerable.Range(0, N).Select(i => uf.Size(i)).Max();

        WriteLine(ans);
    }
}
class UnionFind
{
    private int[] d;
    public UnionFind(int n) => d = Enumerable.Repeat(-1, n).ToArray();
    public int Find(int x) => (d[x] < 0) ? x : d[x] = Find(d[x]);
    public bool Unite(int x, int y)
    {
        (x, y) = (Find(x), Find(y));
        if (x == y)
            return false;
        if (-d[x] < -d[y])
            (x, y) = (y, x);
        (d[x], d[y]) = (d[x] + d[y], x);
        return true;
    }
    public bool Same(int x, int y) => Find(x) == Find(y);
    public int Size(int x) => -d[Find(x)];
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 47820
#include<iostream>
#include<vector>
using namespace std;
int main(void){
  int H,W;
  cin >> H >> W;
  vector<vector<char> > data(H, vector<char>(W));
  
  //入力
  for (int i = 0; i < H;i++){
    for (int j = 0; j < W;j++){
      cin >> data.at(i).at(j);
    }
  }


  //処理
  for (int i = 0; i < H;i++){
    int count =0;
    int count2 = 0;
    for (int j = 0; j < W; j++)
    {
      if(data.at(i).at(j)=='.')
        count++;
      // else
      //   count2++;
    }
    if(count==W){
      for (int j = 0; j < W;j++){
        data.at(i).at(j) = '0';
      }
    }
  }

//処理

  for (int i = 0; i < W;i++){
    int count = 0;
    int count2 = 0;
    for (int j = 0; j < H; j++)
    {
      if(data.at(j).at(i)=='.'||data.at(j).at(i)=='0')
        count++;
      // else
      //   count2++;
    }
    if(count==H){
      for (int j = 0; j < H;j++){
        data.at(j).at(i) = '0';
      }
    }
  }

//cout << "AAAAAAAAA" << endl;

//出力
for (int i = 0; i < H; i++)
{
  int count = 0;
  for (int j = 0; j < W; j++)
  {
   if (data.at(i).at(j) != '0')
    {
      cout << data.at(i).at(j);
      count++;
    }
  }
  //cout << count;
  if (count != 0)
  {
    cout << endl;
  }
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=200000000000000;
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
}

	
int main(){
	init();
	ll X;
	cin>>X;
	for(int a=0;a*100<=X;a++){
		for(int b=0;b*101<=X;b++){
			if(a*100+b*101>X)break;
		for(int c=0;c*102<=X;c++){
			if(a*100+b*101+c*102>X)break;
		for(int d=0;d*103<=X;d++){
			if(a*100+b*101+c*102+d*103>X)break;
		for(int e=0;e*104<=X;e++){
			if(a*100+b*101+c*102+d*103+e*104>X)break;
		for(int f=0;f*105<=X;f++){
			if(a*100+b*101+c*102+d*103+e*104+f*105>X)break;
			if(a*100+b*101+c*102+d*103+e*104+f*105==X){
				cout<<1<<endl;
				return 0;
			}
		}
		}
				}
			}
		}
	}
	cout<<0<<endl;
}


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

int n, m, k;
string a[2];
set<int> s[2];

/*
012
110
101
*/

void jump(int x, int y)
{
	int p0 = *s[0].lower_bound(x);
	int p1 = *s[1].lower_bound(x);
	int p = min(p0, p1);
	if(x + k - y < p)
	{
		s[0].insert(x + k - y);
		s[1].insert(x + k - y);
		return;
	}
	int v = p, t = (p == p1);
	s[t ^ 1].insert(v);
	while(s[t].find(v) != s[t].end())
	{
		s[t].erase(v);
		++v;
	}
	if(s[t ^ 1].find(v) != s[t ^ 1].end())
	{
		s[t ^ 1].erase(v);
		jump(v, y + p - x);
	}
	else s[t].insert(v);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n >> m >> k >> a[0] >> a[1];
	reverse(a[0].begin(), a[0].end());
	reverse(a[1].begin(), a[1].end());
	while(a[0].size() < m) a[0].push_back('0');
	while(a[1].size() < n) a[1].push_back('0');
	s[0].insert(1e9); s[1].insert(1e9);
	for(int i = max(n, m) - 1; ~i; --i)
	{
		if(a[0][i] == '1' && a[1][i] == '0') s[0].insert(i);
		if(a[0][i] == '0' && a[1][i] == '1') s[1].insert(i);
		if(a[0][i] == '1' && a[1][i] == '1') jump(i, 0);
	}
	s[0].insert(-1); s[1].insert(-1);
	for(int i = 0; i < 2; ++i)
	{
		set<int>::iterator it = --s[i].end();
		for(int j = *--it; ~j; --j)
		{
			if(j == *it) --it, cout << "1";
			else cout << "0";
		}
		cout << "\n";
	}
	return 0;
}

Measured memory_bytes: 40516
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: i64, m: i64, d: i64,
    };

    let mut res = 0_f64;
    for _ in 0..m - 1 {
        res += if d == 0 {
            1.0 / n as f64
        } else {
            ((n - d).max(0) * 2) as f64 / (n * n) as f64
        };
    }
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2300
#include<bits/stdc++.h>
using namespace std;
int n, a[100009], f[100009];
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    cin >> n;
    a[0] = 0;
    for(int i = 1; i <= n; ++ i)
    {
        cin >> a[i];
    }
    fill(f + 1, f + 1 + n, LONG_MAX);
    f[0] = 0;
    f[1] = 0;
    f[2] = abs(a[1] - a[2]);
    for(int i = 3; i <= n; ++ i)
    {
        f[i] = min(f[i - 1] + abs(a[i - 1] - a[i]), f[i - 2] + abs(a[i - 2] - a[i]));
    }
    cout << f[n];
}


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

using namespace std;

int main()
{
  	string s;
  	cin >> s;
  	
  	if(s[0]==s[1] && s[1]==s[2])
      	cout << "No" << endl;
 	else
      	cout << "Yes" << endl;
  	return 0;
}

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

int main() {
  int a,b,c;
  int x,y,z,count;
  count = 0;
  cin >> a >> b >> c;
  while(true){
    if(a%2==1 || b%2==1 || c%2==1){
      cout << count << endl;
      break;
    }
    else if(a==b && b==c && c==a){
      cout << -1 << endl;
      break;
    }
    x = b/2 + c/2;
    y = a/2 + c/2;
    z = a/2 + b/2;
    count++;
    if(x%2==1 || y%2==1 || z%2==1){
      cout << count << endl;
      break;
    }
    else{
      a = y/2 + z/2;
      b = x/2 + z/2;
      c = x/2 + y/2;
      count++;
    }
  }
}

Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <vector>
#include <queue>

using namespace std;

pair<int, int> dir[2] = { {1, 0}, {0, 1} };

class info
{
public:
	int y;
	int x;
	char curr;
	int flip;

public:
	info(int _y, int _x, char _curr, int _flip)
		: y(_y), x(_x), curr(_curr), flip(_flip)
	{}
};

int H, W;

vector<string> mapinfo;

int process1()
{
	int result = 1000;

	vector<vector<vector<bool>>> visited(H, vector<vector<bool>>(W, vector<bool>(101, false)));

	queue<info> q;
	q.push(info(0, 0, mapinfo[0][0], mapinfo[0][0] == '#'));
	while (!q.empty())
	{
		info c = q.front();
		q.pop();

		if (c.y == H - 1 && c.x == W - 1)
		{
			result = min(result, c.flip);
			continue;
		}

		for (int i = 0; i < 2; i++)
		{
			int ny = c.y + dir[i].first;
			int nx = c.x + dir[i].second;

			if (ny >= H || nx >= W) continue;

			int need_flip = 0;
			if (mapinfo[ny][nx] != c.curr && c.curr == '.') need_flip = 1;
			if (visited[ny][nx][c.flip + need_flip]) continue;

			q.push(info(ny, nx, mapinfo[ny][nx], c.flip + need_flip));
			visited[ny][nx][c.flip + need_flip] = true;
		}
	}

	return result;
}

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

	cin >> H >> W;

	for (int i = 0; i < H; i++)
	{
		string line;
		cin >> line;

		mapinfo.push_back(line);
	}

	cout << process1();

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

long long int N, A, B;

int main() {
	cin >> N >> A >> B;
	if ((B - A) % 2 == 1) {
		cout << "Borys" << endl;
	}
	else {
		cout << "Alice" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n; cin >> n;
    vector<string> s(n);
    vector<ll> t(n);
    rep(i,n)cin >> s[i] >> t[i];
    ll sum = 0;
    rep(i,n)sum += t[i];
    string x ;
    cin >> x;
    ll ans = 0;
    ll temp = 0;
    rep(i,n){
        if(s[i] == x){
            temp += t[i];
            ans = sum - temp;
            break;
        }
        else temp += t[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String D = sc.nextLine();
		if(D.equals("25")) {
		System.out.println("Christmas");
		} else if(D.equals("24")){
			System.out.println("Christmas Eve");
		} else if(D.equals("23")) {
			System.out.println("Christmas Eve Eve");
		} else {
			System.out.println("Christmas Eve Eve Eve");
		}
	}
}


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

using namespace std;

int main(){
#ifdef LOCAL
	freopen("input", "r", stdin);
#endif
	
	string s, t;

	cin >> s >> t;

	int ans = 100005;

	for (int i = 0; i < (int)s.size(); i++){
		int k = 0, dif = 0;
		if (i+(int)t.size() > (int)s.size()) continue;
		for (int j = i; j < i+(int)t.size(); j++){
			if (s[j] != t[k]){
				dif++;
			}
			k++;
		}
		ans = min(ans, dif);
	}

	printf("%d\n", ans);

	return 0;
}

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

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


Measured memory_bytes: 256
#!/usr/bin/env python3

a, b = map(int, input().split())

a_str = ''
for i in range(b):
    a_str += str(a)

b_str = ''
for i in range(a):
    b_str += str(b)

# print(a_str, b_str)

if a_str == b_str:
    print(a_str)
elif a_str > b_str:
    print(b_str)
else:
    print(a_str)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n);
	
	printf("%d\n", (n + 999) / 1000 * 1000 - n);
	return 0;
}


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

int main() {
 int n,a,b;
  cin >> n >> a >> b;
  int sum=0;
  for(int i=0; i<10; i++){
  	for(int j=0; j<10; j++){
      for(int k=0; k<10; k++){
 		for(int l=0; l<10; l++){
           if(1<=i*1000+j*100+k*10+l && i*1000+j*100+k*10+l <=n && a<=i+j+k+l && i+j+k+l<=b ){
    		sum += i*1000+j*100+k*10+l;
           }
        }
      }
    }
  }
  if(n==10000){
  	sum+=10000;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
num = int(input())
 
A = []
B = []
for i in range(num):
    x,y = map(int,input().split())
    A.append(x)
    B.append(y)
 
val = 0
for i in range(num-1,-1,-1):
    if (A[i]+val)%B[i] == 0:
        pass
    elif A[i] + val > B[i]:
        val += B[i]-((A[i]+val)%B[i])
    else:
        val += B[i]-(A[i]+val)  
print(val)

Measured memory_bytes: 16764