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


#define file "file"
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef complex<double> point;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define DEBUG 0
#define dout if(DEBUG) cout

const int MAXN = 50 + 5;

ll a[MAXN];

bool check(ll k, int n){
    while(k > 0){
        int id = 0;
        for(int i = 0; i < n; i++){
            if(a[i] > a[id]) id = i;
        }
        ll mul = a[id] / n;
        a[id] -= mul * n;
        k -= mul;
        if(!mul) return k;
        for(int i = 0; i < n; i++){
            if(i == id) continue;
            a[i] += mul;
        }
    }
    for(int i = 0; i < n; i++){
        if(a[i] >= n){
            cout << "\nBAD " << a[i] << endl;
            return k;
        }
    }
    return k;
}

void solve(){
   ll k;
   ll k2;
   cin >> k;
   k2 = k;
   int n = 50;
   cout << n << endl;
   ll add;
   ll LIM = 10000000000001000;
   ll mul = k / n;
   k -= mul * n;
   add = mul;
   for(int i = 0; i < n; i++){
        a[i] = n - 1;
        a[i] += add;
   }
   for(int i = 0; i < k; i++){
        a[i] += n;
        for(int j = 0; j < n; j++){
            if(j == i) continue;
            a[j]--;
        }
   }

   ll mn = 0;
   for(int i = 0; i < n; i++){
    mn = min(mn, a[i]);
   }
   for(int i = 0; i < n; i++){
        a[i] -= mn;
   }

   for(int i = 0; i < n; i++){
    cout << a[i] << " ";

   }

//    cout << "\n" << check(k2, n) << endl;
//    for(int i = 0; i < n; i++){
//    cout << a[i] << " ";
//   }
}

int main() {
    #ifdef NASTYA
        assert(freopen("input.txt", "r", stdin)); assert(freopen("output.txt", "w", stdout));
    #else
    // assert(freopen(file".in", "r", stdin)); assert(freopen(file".out", "w", stdout));
    #endif
    int t = 1;
    while(t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define ri register int
#define il inline
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define all(x) x.begin(),x.end() 
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define per(i,a,b) for(ri i=(a);i>=(b);--i)
#define ls (x<<1)
#define rs (x<<1|1)
#define mid (l+r>>1)
#define de(x) cout << #x << " = " << x << endl
#define dd() cout << "Out Put!\n"
const int mod= 1e9+7,maxn=1000010;
const double eps = 1e-8,PI = acos(-1.0);
const int inf=0x7f7f7f7f;
using namespace std;
int a[maxn],b[maxn],v[maxn];
string s;
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	rep(i,1,100)
		rep(j,1,100)
			rep(k,1,100)
			{
				if(i*i+j*j+i*j+j*k+k*i+k*k>10000)
					break;
				a[i*i+j*j+i*j+j*k+k*i+k*k]++;
			}
	rep(i,1,n)
		cout << a[i] << endl;
	return 0;
}

Measured memory_bytes: 3660
using System;
class Hello{
	public static void Main(){
		string md = Console.ReadLine();
		string[] mdarray = md.Split(' ');
		int[] mdint = new int[2];
		for(int i = 0;i < 2;i++){
			mdint[i] = Int32.Parse(mdarray[i]);
		}
		if(mdint[0] <= mdint[1]){
			Console.WriteLine(mdint[0]);
		}
		else{
			Console.WriteLine(mdint[0] - 1);
		}
	}
}

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

long long INF = 1LL<<60;

int F[110][11];
long long P[110][11];

int main() {

  int N;
  cin >> N;

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

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

  long long answer = 0 - INF;

  for(int bits = 1; bits < (1 << 10); bits++) {

    long long answer_ = 0;

    for (int i = 0; i < N; i++) {
      int count_ = 0;
      for (int j = 0; j < 10; j++) {
        if (bits >> j & 1) {
          if (F[i][j] == 1) {
            count_++;
          }
        }
      }
      answer_ += P[i][count_];
    }

    answer = max(answer, answer_);
    
  }

  cout << answer << endl;

  return 0;

}

Measured memory_bytes: 256
(function() {
  var isInRange, isNum, reader;

  isNum = function(n) {
    return n.match(/(-|)\d{1,3}/);
  };

  isInRange = function(n) {
    return n >= 0 && n <= 100;
  };

  reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
  });

  reader.on('line', function(line) {
    var a, b, c, sp;
    sp = line.split(/\s/);
    a = isNum(sp[0]) ? parseInt(sp[0], 10) : void 0;
    b = isNum(sp[1]) ? parseInt(sp[1], 10) : void 0;
    c = isNum(sp[2]) ? parseInt(sp[2], 10) : void 0;
    if (isInRange(a) && isInRange(b) && isInRange(c)) {
      if ((a < b && b < c)) {
        return console.log("Yes");
      } else {
        return console.log("No");
      }
    }
  });

}).call(this);

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9

using namespace std;
typedef long long int lli;
typedef long long ll;

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

    cout << (s[0] == s[2] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  int res=0;
  rep(i,n)
  {
    int a;
    cin>>a;
    while(a%2==0)
    {
      a>>=1;
      res++;
    }
  }
  cout<<res<<endl;
  return 0;

}


Measured memory_bytes: 256
main :: IO ()
main = do
  [n,k] <- map (read :: String -> Integer) . words <$> getLine
  mapM_ print $ [ans (n-k) k i | i <- [1..k]]

ans :: Integer -> Integer -> Integer -> Integer
ans r b i = if r < i-1 then 0
  else ((b-1) `c` (i-1)) * ((r+1) `c` (i)) `mod` 1000000007

c :: Integer -> Integer -> Integer
c n 0 = 1
c n k = (`mod` 1000000007) $ product [n-k+1..n] `div` product [1..k]

Measured memory_bytes: 1148
N, M = map(int, input().split())
if N%2==0:
    r = N
    f = True
    for i in range(M):
        if f and i*4+2 >= N:
            r -= 1
            f = False
        print(1+i, r)
        r -= 1
else:
    for i in range(M):
        print(1+i, N-i)


Measured memory_bytes: 9088
N,A,B,C=map(int,input().split());a=[[0,0,0,-30]]
for i in range(N):l=int(input());a=[[p[j]+l*(i==j)for j in[0,1,2]]+[p[3]+(i<3)*10]for i in range(4)for p in a]
print(min(abs(p[0]-A)+abs(p[1]-B)+abs(p[2]-C)+p[3]for p in a if min(p[:3])>0))

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

int main(){
  int n;
  cin >> n;
  long long now=0,ans=0;
  for(int i=0;i<n;i++){
    int x;
    cin >> x;
    now+=x;
    if(x==0){
      ans+=(now/2);
      now=0;
    }
  }
  ans+=now/2;
  cout << ans << endl;
}

Measured memory_bytes: 3588
#include<iostream>
#include <algorithm>
#define syso(s) std::cout<<s<<endl;
#define sc(i) std::cin>>i;
using namespace std;
int main() {
	int a, b, c;
	sc(a)
		sc(b)
		sc(c)
		if (a + b == c || a + c == b || b + c == a) {
			syso("Yes")
		}
		else
		{
			syso("No")
		}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
int n;
char s[10];
int main() {
//	freopen("1.txt","r",stdin);
	scanf("%s",s+1);
	n=strlen(s+1);
	for (int i=1;i<=n;i++) if (s[i]=='7') { printf("Yes\n"); return 0; }
	printf("No\n");
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/


Measured memory_bytes: 3724
#include<iostream>
    #include<string.h>
    using namespace std;
    long long a[100]={0};
    int main()
    {
        int i,d;
        scanf("%d",&d);
        a[0]=2;a[1]=1;
        if(d==1)
            printf("%d",1);
        else
        {
            for(i=2;i<=d;i++)
                a[i]=a[i-1]+a[i-2];
            printf("%lld",a[d]);
        }
        return 0;
    }

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

int main()
{
    int x;
    cin >> x;
    int m;
    int ans = 0;
    for (int i = 1; i < 32; i++)
    {
        m = i;
        for (int j = 0; j < 12; j++)
        {
            if (m * i > x)
            {
                break;
            }
            else
            {
                m = m * i;
            }
            ans = max(ans, m);
        }
        
    }
    cout << ans << endl;
}


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

int main()
{
	vector<string> s;
	s.push_back("dream");
	s.push_back("dreamer");
	s.push_back("erase");
	s.push_back("eraser");

	string input;
	cin >> input;

	while(!input.empty()){
		bool found = false;
		for(int i = 0; i < s.size(); i++){
			for(int j = 0; j < s.size(); j++){
				if(input.substr(0, s[i].length()) == s[i] && 
					(input.substr(s[i].length(), s[j].length()) == s[j] || input.substr(s[i].length(), 1) == "")){
					input.erase(0, s[i].length());
					found = true;
				}
				if(found) break;
			}
			if(found) break;
		}
		if(!found){
			// cout << input << endl;
			cout << "NO" << endl;
			break;
		}
	}
	if(input.empty()){
		cout << "YES" << endl;
	}

	return 0;
}

Measured memory_bytes: 512
#ifdef Dhiraj
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
    #define cerr if(0) cerr
#endif

// Macro --------------------------------------------------------------------

#define ll                  long long int
#define FOR(i, a, b, s)     for(ll i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define FOR1(b)             FOR(i, 0, b, 1)
#define FOR2(i, b)          FOR(i, 0, b, 1)
#define FOR3(i, a, b)       FOR(i, a, b, (a) <= (b) ? 1 :-1)
#define FOR4(i, a, b, s)    FOR(i, a, b, s)
#define GET5(a, b, c, d, e, ...) e
#define FORC(...)           GET5(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)
#define loop(...)           FORC(__VA_ARGS__)(__VA_ARGS__)
#define all(x)              (x).begin(), (x).end()
#define rall(x)             (x).rbegin(), (x).rend()
#define endl                '\n'

// Template -----------------------------------------------------------------

// multiple input
template <typename... T> 
inline void inp(T&... args) {
    ((cin >> args), ...);
}
// scan vector
template <typename T> 
inline istream& operator >>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U> 
inline istream& operator >>(istream &in, pair<T, U> &a) {
    in >> a.first >> a.second; 
    return in;
}

// Solve --------------------------------------------------------------------

void solve(int &T)
{
    ll n;
    cin >> n;

    ll ans = 0;
    loop(a, 1, n) {
        ans += ((n - 1) / a);
    }
    cout << ans << endl;
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt", "r", stdin);
        freopen("D:/dhiraj/Programming/o1.txt", "w", stdout);
        // freopen("D:/dhiraj/Programming/e1.txt", "w", stderr);
    #endif

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

    int t = 1;
    for(int i = 1; i <= t; i++) {
        cerr << "Case #" << i << "\n";
        solve(i);
    }
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(...) recursive_debug(#__VA_ARGS__, __VA_ARGS__)

void recursive_debug(string) { cerr << endl; }

template<class H,class... T>
void recursive_debug(string s, H h, T... t) {
    int comma = s.find(',');
    cerr << s.substr(0,comma) << " = " << h << ", ";
    recursive_debug(s.substr(comma+1), t...);
}

template<class T,class U>
ostream& operator<<(ostream& ost, const pair<T,U> &p) {
    ost << "(" << p.first << ", " << p.second << ")";
    return ost;
}

template<class T>
ostream& operator<<(ostream &ost, const vector<T> &v) {
    ost << "[";
    for(T t : v) ost << t << ",";
    ost << "]";
    return ost;
}

struct State {
    ll score;
    vector<int> last;
    vector<int> types;
    bool operator<(const State& rhs) const {
        return (score < rhs.score);
    }
    bool operator>(const State& rhs) const {
        return (score > rhs.score);
    }
};


int main(void){
    int D, M = 26;
    cin >> D;
    vector<ll> c(M);
    rep(m,M) cin >> c[m];
    vector<vector<ll>> s(D, vector<ll>(26));
    rep(d,D) rep(m,M) cin >> s[d][m];

    vector<State> cur_states = {{0, vector<int>(M, -1), {}}};
    size_t SIZE = 100;

    rep(d,D) {
        vector<State> nxt_states;
        for (State &state : cur_states) {
            rep(m,M) {
                State nxt_state;
                nxt_state.score = state.score + s[d][m];
                nxt_state.last = state.last;
                nxt_state.last[m] = d;
                nxt_state.types = state.types;
                nxt_state.types.push_back(m);

                rep(i,M) {
                    nxt_state.score -= c[i] * (d - nxt_state.last[i]);
                }
                nxt_states.push_back(nxt_state);
            }
        }
        sort(all(nxt_states), greater<State>());
        if (nxt_states.size() > SIZE) {
            nxt_states.resize(SIZE);
        }
        cur_states = std::move(nxt_states);
    }

    for (int t : cur_states[0].types) {
        cout << t+1 << endl;
    }
    // debug(cur_states[0].score);

    return 0;
}


Measured memory_bytes: 8488
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
  int n = 0;
  cin >> n;
  int big = 0;
  bool can = true;
  for(int i = 0;i <= n - 1;i++){
    int num = 0;
    cin >> num;
    big = max(num,big);
    if(big - num >= 2)can = false;
  }
  if(can)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
n=input()
if len(n)%2==0:
    m=int(len(n)/2)
else:
    m=int((len(n)-1)/2)

a=0

for i in range(m):
    if n[i]==n[-1*(i+1)]:
       continue
    else:
        a+=1

if a==0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
 int n,m,x;
 cin>>n>>m>>x;
 vector<int> a(n+1,0);
 for(int i=0;i<m;i++){
     int b;
     cin>>b;
     a.at(b)++;
 }
 int left=0,right=0;
 for(int i=1;i<x;i++){
     left+=a.at(i);
 }
 for(int i=x+1;i<n;i++){
     right+=a.at(i);
 }
 cout<<min(left,right)<<endl;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

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

  int ans = (n - 1) * (m - 1);
  cout << ans << endl;
  return 0;
}


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

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

using namespace std;

string w;
int c[26];

int main(){
	cin >> w;
	for(char v: w){
		++c[v - 'a'];
	}
	cout << (none_of(c, c + 26, [](int x){return x & 1;}) ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
 int A1,A2,A3;
 scanf("%d %d %d",&A1,&A2,&A3);
 if(A1+A2+A3 >= 22) printf("bust\n");
 else if (A1+A2+A3 <=21) printf("win\n");
 return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
ll mod =1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

template<class T> T maxt(T x,T y) {if (x>y) return x;else return y;}
template<class T> T mint(T x,T y) {if (x>y) return y;else return x;}
//sort(v.begin(), v.end(), [](auto& x, auto& y){return x[1] < y[1];});


//小数出力
double print_double(double d){printf("%.15lf\n", d);}

//約数列挙
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}



// ll combination_mod(int n, int k) {
//   k = mint(k,n-k);
//   ll ans = 1;
//   if (n==0 || k ==0) return ans;
//   rep(i,k) {
//     ans = ans*(n-i)%mod;
//     ans = ans*modinv(i+1)%mod;
//   }
//   return ans;
// }

struct edge {
  int from; //出発点
  int to;   //到達点
  ll cost; //移動コスト
};

//ベルマンフォード法
vector<ll> bellman_ford (vector<edge> edges, int V, int E, int r, ll INF = 100000000000) {  
  vector<ll> cost_to(V,INF);
  cost_to[r] = 0;
  rep(i,V) {
    rep(j,E) {
      edge e = edges[j];
      if (cost_to[e.from]==INF) continue;
      if (cost_to[e.to] > cost_to[e.from] + e.cost) {
        cost_to[e.to] = cost_to[e.from] + e.cost;
        if (i==V-1) {
          printf("NEGATIVE CYCLE\n");
          return {};
        }
      }

    }
  }
  return cost_to;
}

// combination
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}


// 木上の探索
vector<int> cnt;
void dfs(const vector<vector<int>> &G, int v, int p) {
    for (auto nv : G[v]) {
        if (nv == p) continue; // nv が親 p だったらダメ
        dfs(G, nv, v);
    }

    // 帰りがけ時に、部分木サイズを求める
    cnt[v] = 1; // 自分自身
    for (auto c : G[v]) {
        if (c == p) continue;
        cnt[v] += cnt[c]; // 子のサイズを加える
    }
}


int main() {
  int N,M;
  cin >> N >> M;
  int k = (N-1)/2;
  int la = 0, lb = k,ra = k+1, rb = 2*k;
  while (M && lb>la) {
    cout << la+1 << ' ' << lb+1 << endl;
    la++;lb--;
    M--;
  }
  while (M && rb>ra) {
    cout << ra+1 << ' ' << rb+1 << endl;
    ra++;rb--;
    M--;
  }
}


Measured memory_bytes: 3640
N = int(input())
S  = input()

INF = 10**10
dp = [-INF] * (N+1)
dp[0] = 0
prev = S[0]
for i in range(N):
    # i = 0のときここを通ることはないのでOK
    if S[i] != prev:
        dp[i+1] = dp[i-1] + 1
    else:
        dp[i+1] = dp[i]
    prev = S[i]
print(dp[N])


Measured memory_bytes: 9648
n = input()
if n[len(n)-1] == "2" or n[len(n)-1] == "4"or n[len(n)-1] == "5"or n[len(n)-1] == "7" or n[len(n)-1] == "9":
  print("hon")
elif n[len(n)-1] == "3":
  print("bon")
else:
  print("pon")

Measured memory_bytes: 9120
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,a[200001],sum=0,mmax;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
	}
	mmax=a[0];
	for(int i=1;i<n;i++)
	{
		if(a[i]>mmax){
			mmax=a[i];
		}
		else sum+=mmax-a[i];
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 5176
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
string s;
int n;
inline int dfs(int x,bool op){
	int res=0;
	if(x==n)return 0;
	if(!op)return 9*(n-x);
	if(s[x]=='0')
		return dfs(x+1,1);
	return max(dfs(x+1,1)+s[x]-'0',dfs(x+1,0)+s[x]-'0'-1);
}
int main(){
	i64 x;cin>>x;s=to_string(x);
	n=s.length();
	cout<<dfs(0,1);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
const int L = 100010;
char a[L];
int n;
int r[L],l[L];
int ans[L];
int main(){
	scanf("%s",a);
	n=strlen(a);
	int last=0;
	for(int i=0; i<n; i++){
		if(a[i]=='L'){
			for(int j=last; j<=i-1; j++){
				r[j]=i;
			}
			last=i+1;
		}
	}
	last=n-1;
	for(int i=n-1; i>=0; i--){
		if(a[i]=='R'){
			for(int j=i+1; j<=last; j++){
				l[j]=i;
			}
			last=i-1;
		}
	}
	for(int i=0; i<n; i++){
		if(a[i]=='R'){
			int dis=r[i]-i;
			if(dis & 1){
				ans[r[i]-1]++;
			}
			else{
				ans[r[i]]++;
			}
		}
		else{
			int dis=i-l[i];
			if(dis & 1){
				ans[l[i]+1]++;
			}
			else{
				ans[l[i]]++;
			}
		}
	}
	for(int i=0; i<n; i++){
		printf("%d ",ans[i]);
	}
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
const ll inf=1LL<<60;
ll n,V;
ll gg(pii p){
    return p.first+p.second*n;
}
struct edge{
	ll to, cost;
};
vector<vector<edge> > g;
vector<ll> d;
void gao(ll s){
    priority_queue<pii,vector<pii>,greater<pii> > q;
    d=vector<ll>(V,inf);
    d[s]=0;
    q.push(pii(0,s));
    while(!q.empty()){
        pii p=q.top();q.pop();
        ll v=p.second;
        if(d[v]<p.first)continue;
		for(int i=0;i<g[v].size();i++){
			edge e=g[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                q.push(pii(d[e.to],e.to));
            }
        }
    }
}
int main(){
	n=read();
    ll m=read(),s=read();
    s=min(s,5000LL);
    V=n*6001;
    g=vector<vector<edge> >(n*6001);
    for(int i=0;i<m;i++){
        ll u=read()-1,v=read()-1,a=read(),b=read();
        for(int j=a;j<6001;j++){
            g[gg({u,j})].push_back({gg({v,j-a}),b});
            g[gg({v,j})].push_back({gg({u,j-a}),b});
        }
    }
    for(int i=0;i<n;i++){
        ll c=read(),d=read();
        for(int j=0;j<6001-c;j++)
            g[gg({i,j})].push_back({gg({i,j+c}),d});
    }
    gao(gg({0,s}));
    for(int i=1;i<n;i++){
        ll ans=inf;
        for(int j=0;j<6001;j++)
            ans=min(ans,d[gg({i,j})]);
        cout << ans << endl;
    }
	return 0;
}

Measured memory_bytes: 51684
#include<iostream>
#include<string>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<functional>
#include<cmath>
#include<unordered_map>

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

using namespace std;

int to_int(string s) {
  return atoi(s.c_str());
}

int main() {
  string s;
  ll k;
  cin >> s >> k;
  int i = 0;
  while(s[i] == '1') {
    i++;
  }
  if(k <= i) {
    cout << 1 << endl;
  } else {
    cout <<s[i] << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    cin >>S;
    int count0=0;
    int count1=0;
    for(int i=0;i<S.size();i++){
      if(S.at(i)=='0'){
          count0++;
      }
      else if(S.at(i)=='1'){
          count1++;
      }
    }
    int aaa=min(count0,count1);
    cout <<aaa*2<<endl;
}

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

int main(){
    int i, x = 0;
    string s;
    cin >> s;
    for(i=0; i<4; i++){
        if(s[i] == '+'){
            x++;
        }else{
            x--;
        }
    }
    cout << x;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class program{
  static void Main(string[] args){
    program p = new program();
    p.Run();
  }
  void Run(){
	int[] inp = Readint();
    int res = inp[0]-inp[1]+1;
    WriteLine(res.ToString());
  }

  int[] Readint(){
    string[] s = ReadLine().Split();
    int[] res=new int[s.Length];
    Parallel.For(0,s.Length,i=>{
      res[i]=int.Parse(s[i]);
    });
    return res;
  }
}




Measured memory_bytes: 13652
def m():
    n, k = map(int, input().split())
    half = k // 2
    odd = 0
    even = 0
    even_half = 0
    for i in range(1, n+1):
        if k % 2 == 0:
            if i % k == 0:
                even += 1
            if i % k == half:
                even_half += 1
        else:
            if i % k == 0:
                odd += 1
    ans = max(odd ** 3, even ** 3 + even_half ** 3)
    return ans
print(m())

Measured memory_bytes: 3064
import java.util.*;
import static java.lang.System.out;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] nArray = new int[n];
        int[] mArray = new int[m];

        for(int i=1;i<=n; i++) {
            nArray[i-1] = i*2;
        }
        for(int i=0;i<m; i++) {
            if(i==0) {
                mArray[i] = 1;
            } else {
                mArray[i] = n*2+1;
            }
        }
        int count=0;
        int[] array = new int[n+m];
        System.arraycopy(nArray, 0, array, 0, n);
        System.arraycopy(mArray, 0, array, n, m);

        for(int i=0;i<array.length ;i++) {
            for(int j=i+1; j<array.length; j++) {
                if((array[i]+ array[j])%2==0) {
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 21716
while True:
    H, W = [int(i) for i in input().split()]
    if H == W == 0:
        break
    for h in range(H):
        for w in range(W):
            if h == 0 or h == H - 1 or w == 0 or w == W - 1:
                print('#', end='')
            else:
                print('.', end='')
        print()
    print()

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

int main(){
    //input
    int n,m;
    cin >> n >> m;
    int c[m];
    int i,j;
    for(i=1; i<=m; i++){
        cin >> c[i];
    }

    //calc
    int dp[m+1][n+1];
    for(i=0; i<=m; i++){
        dp[i][0]=0;
    }
    for(j=0; j<=n; j++){
        dp[1][j]=0;
    }
    for(i=2; i<=m; i++){
        for(j=1; j<=n; j++){
            if(j-c[i]<0){
                dp[i][j]=dp[i-1][j];
            }else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-c[i]]+(c[i]-1));
            }
        }
    }

    //answer
    cout << n-dp[m][n] << endl;
    return 0;
}


Measured memory_bytes: 7024
n,k=map(int,input().split())
m=[]
for i in range(n):
  m.append(list(map(int,input().split())))
m=sorted(m, key=lambda thing: thing[0])
total=0
for i in range(n):
  total+=m[i][1]
  if total>=k:
    ans=m[i][0]
    break
print(ans)

Measured memory_bytes: 29912
#include<algorithm>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;
#define ll long long
//{{{ read()
inline ll read(){
	register ll x=0,f=1;
	register char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')	f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')	x=x*10+(ch^48),ch=getchar();
	return x*f;
}
//}}}
const int P=1e9+7;
const int N=1e7+5;
ll ans,fac[N],iac[N],inv[N];
ll C(int n,int m){
	if(n<m)	return 0;
	return fac[n]*iac[m]%P*iac[n-m]%P;
}
int calc(int a,int b,int c){
	return fac[a+b+c]*a%P*inv[a+c]%P;
}
int n,m;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),m=read(),inv[1]=iac[0]=fac[0]=1;
	for(int i=1;i<=n;i++)	fac[i]=fac[i-1]*i%P;
	for(int i=2;i<=n;i++)	inv[i]=(P-P/i)*inv[P%i]%P;
	for(int i=1;i<=n;i++)	iac[i]=iac[i-1]*inv[i]%P;
	for(int i=0;i<=m;i++){
		if(i&1)	ans=(ans-C(m,i)*calc(m-i,0,n-m)%P+P)%P;
		else	ans=(ans+C(m,i)*calc(m-i,0,n-m))%P;
	}
	for(int i=1;i<=m;i++)
		for(int j=0;j<i;j++){
			if(j&1)	ans=(ans-C(i-1,j)*calc(i-j-1,m-i,n-m)%P+P)%P;
			else	ans=(ans+C(i-1,j)*calc(i-j-1,m-i,n-m))%P;
		}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 238068
import re

s = input()
k = int(input())

if k < 100:
    oneLst = ["1"]*k
else:
    oneLst = ["1"]*100
oneStr = ''.join(oneLst)
if int(s) >= k and s[:k] == oneStr:
    print(1)
else: 
    res = re.search(r"[2-9]|0",s)
    print(res.group(0))

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int N = int.Parse(ReadLine());
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();

            int ans = int.MaxValue;
            for (int t = 0; t < N; t++)
            {
                int s1 = 0;
                int s2 = 0;

                for (int i = 0; i < t; i++)
                {
                    s1 += s[i];
                }
                s2 = s.Sum() - s1;
                ans = Min(ans, Abs(s1 - s2));
            }
            WriteLine(ans);

        }
    }
}


Measured memory_bytes: 13396
using System;
using System.Collections.Generic;

class ABC_142_D
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        long A = long.Parse(input[0]);
        long B = long.Parse(input[1]);

        long gcd = GCD(A, B);
        List<long> Div = new List<long>();
        Div.Add(1);

        long c = gcd;
        double limit = Math.Sqrt(c);

        if (c%2==0) Div.Add(2);
        while (c%2==0) c/=2;

        long d = 3;
        while (c>1)
        {
            if(c%d==0)
            {
                Div.Add(d);
                while(c%d==0) c/=d;
            }

            d+=2;

            if (limit < d)
            {
                if(!Div.Contains(c)) Div.Add(c);
                break;
            }
        }

        Console.WriteLine(Div.Count);
    }

    static long GCD(long a, long b)
    {
        if (b == 0) return a;
        return GCD(b, a % b);
    }
}


Measured memory_bytes: 13148
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
using namespace std;
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

template <int32_t MOD>
struct mint {
    int64_t data;
    mint() = default;
    mint(int64_t value) : data(value) {}
    inline mint<MOD> operator + (mint<MOD> other) const { int64_t c = this->data + other.data; return mint<MOD>(c >= MOD ? c - MOD : c); }
    inline mint<MOD> operator * (mint<MOD> other) const { int64_t c = this->data * int64_t(other.data) % MOD; return mint<MOD>(c < 0 ? c + MOD : c); }
    inline mint<MOD> & operator += (mint<MOD> other) { this->data += other.data; if (this->data >= MOD) this->data -= MOD; return *this; }
    inline mint<MOD> & operator *= (mint<MOD> other) { this->data = this->data * int64_t(other.data) % MOD; if (this->data < 0) this->data += MOD; return *this; }
    mint<MOD> pow(uint64_t k) const {
        mint<MOD> x = *this;
        mint<MOD> y = 1;
        for (uint64_t i = 1; i and (i <= k); i <<= 1) {
            if (k & i) y *= x;
            x *= x;
        }
        return y;
    }
};

constexpr int MOD = 1e9 + 7;

mint<MOD> solve(int n, int k) {
    auto dp = vectors(k + 1, n + 1, mint<MOD>());
    dp[0][0] = 1;
    REP (i, k) {
        mint<MOD> acc = 0;
        REP3 (j, 1, n + 1) {
            acc += dp[i][j - 1];
            dp[i + 1][j] += acc;  // extend the primary chain
            if (j > i and j != n) {
                dp[i + 1][j] += dp[i][j];  // extend the secondary chain
            }
        }
    }
    return dp[k][n] * (k < n ? mint<MOD>(2).pow(n - k - 1) : 1);
}

int main() {
    int n, k; cin >> n >> k;
    cout << solve(n, k).data << endl;
    return 0;
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

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

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    for (int i = sx; i < tx; ++i)
        cout << 'R';
    for (int i = sy; i < ty; ++i)
        cout << 'U';
    for (int i = sx; i < tx; ++i)
        cout << 'L';
    for (int i = sy; i < ty; ++i)
        cout << 'D';
    cout << 'D';
    for (int i = sx; i < tx + 1; ++i)
        cout << 'R';
    for (int i = sy - 1; i < ty; ++i)
        cout << 'U';
    cout << "LU";
    for (int i = sx - 1; i < tx; ++i)
        cout << 'L';
    for (int i = sy; i < ty + 1; ++i)
        cout << 'D';
    cout << 'R' << endl;
    return 0;
}


Measured memory_bytes: 256
class union_find():
    __slots__ = ["par", "rank", "size"]
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [1 for i in range(n + 1)]
        self.size = [1 for i in range(n + 1)]

    def find(self, c):
        if self.par[c] == c:
            return c

        ret = self.find(self.par[c])
        self.par[c] = ret
        return ret

    def union(self, x, y):

        xr = self.find(x)
        yr = self.find(y)
        if xr == yr:
            return

        if self.rank[yr] > self.rank[xr]:
            self.par[xr] = yr
            self.size[yr] += self.size[xr]
        else:
            self.par[yr] = xr
            self.size[xr] += self.size[yr]
            if self.rank[xr] == self.rank[yr]:
                self.rank[xr] += 1

    def size_belong(self, i):
        return self.size[self.find(i)]

    def mass_size(self):
        return [i == v for i, v in enumerate(self.par)].count(True) - 1

    def show(self):
        print('parent', self.par[1:])
        print('rank', self.rank[1:])

def main():
    from collections import defaultdict

    dicf = defaultdict(lambda :[])
    dicb = defaultdict(lambda :[])

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

    uf = union_find(N)
    for i in range(M):
        a, b = map(int, input().split())
        dicf[a].append(b)
        dicf[b].append(a)
        if a > b:
            a, b = b, a
        uf.union(a, b)

    for i in range(K):
        c, d = map(int, input().split())
        dicb[c].append(d)
        dicb[d].append(c)

    ans = []
    for i in range(1, N + 1):
        x = uf.size_belong(i) - len(dicf[i]) - 1
        m = 0
        for b in dicb[i]:
            if uf.find(b) == uf.find(i):
                m += 1

        ans.append(x - m)


    print(' '.join(map(str, ans)))




if __name__ == '__main__':
    main()

Measured memory_bytes: 65412
#include<stdio.h>
int main(){
	int a[150000];
	int i, j, size;
	for (i = 0; i < 150000; i++){
		scanf("%d", &a[i]);
		if (a[i] == 0){
			size = i;
			break;
		}
	}
	for (i = 0; i < size; i++)printf("Case %d: %d\n", i + 1, a[i]);
	return 0;
}

Measured memory_bytes: 644
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n,k;
	cin >> n >> k;
	vector<int> a(n+1);
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}

	int p = -1,m = INF;
	for(int i = 1; i <= n; i++){
		if(a[i]<m){
			m = a[i];
			p = i;
		}
	}

	int ans = INF;
	
	for(int i = 0; i < k; i++){
		int res = ceil((double)max(p+i-k,0) / (k-1))+1;
		res += ceil((double)max(n-p-i,0)/(k-1));
		if(res<ans) ans = res;
	}
	//if(n==k) ans = 1;

	cout << ans << endl;

	return 0;
}

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


int main() {
    int A, B, C, D, N;

    cin >> N;

    A = int(N/1000);
    B = int((N%1000)/100);
    C = int((N%100)/10);
    D = N%10;

    if (A==B && A==C )
        cout << "Yes" << endl;
    else if (C==B && B==D)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


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

main()
{
  string s,t;

  cin >> s >> t;
  int slen=s.size();
  int tlen=t.size();
  int cnt=0;
  char a;
  char slatest=0;
  char sfastest='z';
  
  char tlatest=0;
  char tfastest='z';
  for(int i=0;i<tlen;i++){
    if(tlatest<t[i]){
      tlatest=t[i];
    }
    if(tfastest>t[i])
      tfastest=t[i];
  }

  for(int i=0;i<slen;i++){
    if(sfastest>s[i])
      sfastest=s[i];
    if(slatest<s[i])
      slatest=s[i];
  }
  //cout << fastest << latest;

  if(tlatest>sfastest)
    cout << "Yes" << endl;
  else if(sfastest==tlatest&&tfastest==slatest&&slen<tlen)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return (0);
}

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

typedef long long i64;
const int MAX_N = 100005;

i64 f[MAX_N][3];

inline void update(i64 &x, i64 y) {
  if (x < y) x = y;
}

int main() {
  int N, A;
  scanf("%d", &N);
  memset(f, -0x3f, sizeof f);

  scanf("%d", &A), f[0][0] = A;
  
  for (int i = 1; i < N; ++i) {
    static char op[10];
    scanf("%s", op);
    scanf("%d", &A);
    for (int j = 0; j < 3; ++j) {
      int val = (j & 1) ? 1 : 0, w;
      if (*op == '-') val ^= 1;
      w = A * (val & 1 ? -1 : 1);
      if (*op == '-' && j < 2) update(f[i][j + 1], f[i - 1][j] + w);
      if (j > 0) update(f[i][j - 1], f[i - 1][j] + w);
      update(f[i][j], f[i - 1][j] + w);
    }
  }

  printf("%lld\n", f[N - 1][0]);
  return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
#include<string.h>
using namespace std;
#define ll long long
int main()
{
    double ans;
    int n,i,x=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        if(i%2==1)
            x++;
    }
    ans=(double)x/n;
    printf("%lf\n",ans);
    return 0;
}


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let K: i32 = iter.next().unwrap().parse().unwrap();
    let S: i32 = iter.next().unwrap().parse().unwrap();

    let mut result = 0;
    for x in 0..K + 1 {
        for y in 0..K + 1 {
            let z = S - x - y;
            if z >= 0 && z <= K {
                result += 1;
            }
        }
    }
    println!("{}", result);
}


Measured memory_bytes: 4352
from collections import defaultdict

s = input()

n = len(s)
inf = 10**6
d = defaultdict(lambda : inf)
d[0] = 0

a = ord('a')
now = 0
for i in range(n):
    si = ord(s[i]) - a
    now = now^(1<<si)
    for j in range(26):
        d[now] = min(d[now], 1+d[now^(1<<j)])

print(max(1,d[now]))

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

namespace AtCoder
{
	class MainClass
	{

		public static void Main (string[] args)
		{
			Console.ReadLine ();
			var line = Console.ReadLine ().Split (' ').Select (n => long.Parse (n)).ToList ();

			var res = Gcd (line);
			Console.WriteLine ("{0}", res);
		}

		public static long Gcd (List<long> list)
		{
			return list.Aggregate (0L, (a, b) => a == 0L ? b : Gcd (a, b));
		}

		public static long Gcd (long a, long b)
		{
			if (a < b)
				Gcd (b, a);

			while (b != 0) {
				long rem = a % b;
				a = b;
				b = rem;
			}

			return a;
		}
	}
}

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

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

    string s;
    cin >> s;

    if(s.size() > k){
        for(int i=0;i<k;i++){
            cout << s[i];
        }
        cout << "..." <<endl;
    }else{
        cout << s << endl;
    }

    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >> a>>b>>c>>d;
  if(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d))
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;

}



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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int

using namespace __gnu_pbds;

typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;


#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
#define mod 1000000007
/* Precode Start Here *\


power of 2 less than or equal to N

ll largest_power(ll N)
{
    //changing all right side bits to 1.
    N = N (N>>1);
    N = N| (N>>2);
    N = N| (N>>4);
    N = N| (N>>8);


//as now the number is 2 * x-1, where x is required answer, so adding 1 and dividing it by
 2.
            return (N+1)>>1;

}


     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);

 ll n,sum=0;
 cin>>n;
 for(int i=1;i<=n;i++)
 {
     cin>>A[i];
     myMap[A[i]]++;
     mySet.insert(A[i]);
 }
 for(auto i:mySet)
 {
     ll d=myMap[i]-1;
     ll alt=(d*(d+1))/2;
     sum+=alt;
     d--;
     myMap[i]=alt-(d*(d+1))/2;
 }
 for(int i=1;i<=n;i++)
 {
     cout<<sum-myMap[A[i]]<<endl;
 }
return 0;
}



Measured memory_bytes: 17536
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int n,t;
	cin >> n >> t;

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

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

	vector<vector<ll>> dp(n+1,vector<ll>(t+1,0));
	//t-1までからは遷移出来る.
	for(int i = 0;i < n;i++){
		int a = ab[i].first;
		int b = ab[i].second;
		for(int j = 0;j <= t;j++){
			dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
			if(j <= t-1)dp[i+1][min(t,j+a)] = max(dp[i+1][min(t,j+a)],dp[i][j]+b);
		}
	}

	cout << dp[n][t] << endl;
}


Measured memory_bytes: 70784
#include<bits/stdc++.h>
#define pb push_back
#define sz(v) (v).size()
#define all(v) (v).begin(),(v).end()
#define inf 1000000007
#define mod inf
using namespace std;
template <typename T> void chmax(T &x,T y){x=x>y?x:y;return;}
template <typename T> void chmin(T &x,T y){x=x<y?x:y;return;}
typedef long long ll;
typedef unsigned long long ull;

int n,k;
ll ans,f[100005];

ll fpow(int x,int y)
{
	if(y==0) return 1;
	ll ret=fpow(x,y/2);
	ret*=ret,ret%=mod;
	if(y%2==1) ret*=x,ret%=mod;
	return ret;
}

int main()
{
	cin>>n>>k;
	for(int i=k;i>=1;i--)
	{
		f[i]=fpow(k/i,n);
		for(int j=i+i;j<=k;j+=i) f[i]-=f[j],f[i]+=mod,f[i]%=mod;
		ans+=ll(i)*f[i],ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4372
#include<iostream>
#include<stdlib.h>
using namespace std;

#define r(a) for(int a=0;a<10;a++)

int N,x[15],y[15],s[15],c[10][10];

bool paint(int i,int j,int s,int x,int v){
    if(s==1)
        for(int p=i-1;p<=i+1;p++)
            for(int q=j-1;q<=j+1;q++){
                if(abs(p-i)+abs(q-j)==2)continue;
                if(v==0){ if(!c[p][q])return 0; }
                else c[p][q]+=x;
            }
    if(s==2)
        for(int p=i;p<=i+2;p++)
            for(int q=j;q<=j+2;q++){
                if(v==0){ if(!c[p][q])return 0; }
                else c[p][q]+=x;
            }
    if(s==3)
        for(int p=i-2;p<=i+2;p++)
            for(int q=j-2;q<=j+2;q++){
                if(abs(p-i)+abs(q-j)>2)continue;
                if(v==0){ if(!c[p][q])return 0; }
                else c[p][q]+=x;
            }
    return 1;
}
bool dfs(int n){
    if(n==N){
        r(i)r(j)
            if(c[i][j])return 0;
        for(int i=0;i<n;i++)
            cout<<x[i]<<" "<<y[i]<<" "<<s[i]<<endl;
        return 1;
    }
    r(i)r(j){
        if(!c[i][j])continue;
        if(j>0&&j<9&&i<8)
            if(paint(i+1,j,1,0,0)){
                paint(i+1,j,1,-1,1);
                x[n]=j,y[n]=i+1,s[n]=1;
                if(dfs(n+1))return 1;
                paint(i+1, j, 1, 1,1);
            }
        if(i<8&&j<8)
            if(paint(i,j,2,0,0)){
                paint(i,j,2,-1,1);
                x[n]=j+1,y[n]=i+1,s[n]=2;
                if(dfs(n+1))return 1;
                paint(i, j, 2, 1,1);
            }
        if(j>1&&j<8&&i<6)
            if(paint(i+2,j,3,0,0)){
                paint(i+2,j,3,-1,1);
                x[n]=j,y[n]=i+2,s[n]=3;
                if(dfs(n+1))return 1;
                paint(i+2, j, 3, 1,1);
            }
        return 0;
    }
    return 0;
}
int main(){
    cin>>N;
    r(a)r(b)cin>>c[a][b];
    dfs(0);
}

Measured memory_bytes: 1164