akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

string s;

ll a[128];
ll ans;

int main()
{
    cin>>s;
    ll n = s.size();
    for(ll i = 0; i < n; i++)
    {
        a[s[i]]++;
    }
    for(ll i = 'a'; i <= 'z'; i++)
    {
        ans -= a[i] * (a[i] - 1) / 2;
    }
    ans += n * (n - 1) / 2;
    printf("%lld\n", ans + 1);
    return 0;
}


Measured memory_bytes: 640
#include <atcoder/convolution>
#include <atcoder/modint>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define INF_LL 1000000000000000000LL
#define INF 200000000
#define MOD 998244353
#define ll long long
#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
// typedef float double;
// typedef priority_queue prique;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
typedef vector<vi> matrix;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};
template <class T> bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll modpow(ll a, ll b, ll m) {
    if(b == 0)
        return 1;
    ll t = modpow(a, b / 2, m);
    if(b & 1) {
        return (t * t % m) * a % m;
    } else {
        return t * t % m;
    }
}

struct edge {
    int to;
    ll cost;
    edge(int t, ll c) { to = t, cost = c; }
};

using mint = modint998244353;

mint fac[100002];
mint dfac[100002];

mint comb(int n, int r) { return fac[n] / (fac[n - r] * fac[r]); }

int main() {
    fac[0] = 1;
    dfac[0] = 1;
    dfac[1] = 1;
    rep(i, 100001) {
        fac[i + 1] = fac[i] * (i + 1);
        dfac[i + 2] = dfac[i] * (i + 2);
    }
    int n;
    cin >> n;
    vector<int> a(100000, 0);
    rep(i, 2 * n) {
        int h;
        cin >> h;
        a[h - 1]++;
    }
    vector<vector<mint>> p;
    priority_queue<P, vector<P>, greater<P>> q;
    rep(i, 100000) {
        vector<mint> t;
        t.push_back(1);
        for(int k = 2; k <= a[i]; k += 2) {
            t.push_back(comb(a[i], k) * dfac[k - 1]);
        }
        if(a[i] >= 1) {
            q.push({t.size(), p.size()});
            p.push_back(t);
        }
    }
    while(q.size() >= 2) {
        P a = q.top();
        q.pop();
        P b = q.top();
        q.pop();
        q.push({a.first + b.first - 1, p.size()});
        p.push_back(convolution(p[a.second], p[b.second]));
    }
    auto res = p[p.size() - 1];
    //包除
    mint ans = 0;
    rep(i, res.size()) {
        // cout << dp[i].val() << endl;
        if(i & 1) {
            ans -= res[i] * dfac[max(0, 2 * (n - i) - 1)];
        } else {
            ans += res[i] * dfac[max(0, 2 * (n - i) - 1)];
        }
    }
    cout << ans.val() << endl;
    return 0;
}


Measured memory_bytes: 16000
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int l = scanner.nextInt();
			int sum = (l + l + n - 1) * n / 2;
			int eated = 0;
			if (l < 0 && l + n - 1 > 0) {
				eated = 0;
			} else if (l >= 0) {
				eated = l;
			} else if (l + n - 1 <= 0) {
				eated = l + n - 1;
			}
			System.out.println(sum - eated);
		}
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
#define RET(ans) {cout<<ans<<endl;return 0;} 

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    string s; cin >> s;
    rep(i,s.size()-8){
        cout << s[i];
    }
    cout << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A = [[0, 0, 0],[0, 0, 0],[0, 0, 0]]

N = int(input())

# 印の箇所を1とする
for i in range(N):
    b = int(input())
    if b in A1:
        A[0][A1.index(b)] = 1
    elif b in A2:
        A[1][A2.index(b)] = 1
    elif b in A3:
        A[2][A3.index(b)] = 1

# ビンゴの有無を判定
ans = "No"
a = max(sum(A[0]), sum(A[1]), sum(A[2]), (A[0][0] + A[1][0] + A[2][0]), (A[0][1] + A[1][1] + A[2][1]), (A[0][2] + A[1][2] + A[2][2]), (A[0][0] + A[1][1] + A[2][2]), (A[0][2] + A[1][1] + A[2][0]))
if a == 3:
    ans = "Yes"

print(ans)

Measured memory_bytes: 3188
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  n,x=pM(split(readline()))
  a=sort(pM(split(readline())))
  ans=0
  while x>0 && length(a)!=1
    v=splice!(a,1)
    if x>=v; ans+=1; end
    x-=v
  end
  if a[1]==x; ans+=1; end
  println(ans)
end
main()
if isdefined(Base, :mystdin);close(mystdin);end

Measured memory_bytes: 167264
n = int(input())
d = [[] for i in range(n)]
for i in range(n-1):
    u,v,w = map(int,input().split())
    d[u-1].append([v-1,w])
    d[v-1].append([u-1,w])
ans = [-1]*n
ans[0]=0
q = [0]
cnt = 0

while q:
    u = q.pop()
    for v,w in d[u]:
        if ans[v]==-1:
            if w%2==0:
                ans[v]=ans[u]
            else:
                ans[v]=(ans[u]+1)%2
            q.append(v)
for i in ans:
    print(i)

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

int main() {
  int k, a, b;
  cin >> k >> a >> b;

  bool flag = false;
  for (int i = a; i <= b; i++) {
    if (i % k == 0) {
      flag = true;
      break;
    }
  }

  if (flag) {
    cout << "OK" << endl;
  } else {
    cout << "NG" << endl;
  }
  return 0;
}

Measured memory_bytes: 3620
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int ans = 0;
		for (int i = 0; i < n; i++) {
			int a = scanner.nextInt();
			if (slove(a))
				ans++;
		}
		System.out.println(ans);
	}

	private boolean slove(int a) {
		for (int i = 1; i * i <= a; i++) {
			if ((a - i) % (2 * i + 1) == 0)
				return false;
		}
		return true;
	}
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

int n, x, y;

void read() {
	cin >> n >> x >> y;
}

int calc(int a, int b) {
	int ans = abs(a - b);
	chkmin(ans, abs(a - x) + abs(b - y) + 1);
	chkmin(ans, abs(a - y) + abs(b - x) + 1);
	return ans;
}

vector<int> ans;

void run() {
	ans.resize(n - 1);
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			ans[calc(i, j) - 1]++;
		}
	}
}

void write() {
	for (auto i : ans)
		cout << i << "\n";
	//cout << endl;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	write();
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
vector<int> E[201010];
int C[201010];
const ll mo=1000000007;
ll ret;

ll modpow(ll a, ll n = mo-2) {
	ll r=1;a%=mo;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

int dfs(int cur,int pre) {
	C[cur]=1;
	vector<ll> B;
	FORR(e,E[cur]) if(e!=pre) {
		
		B.push_back(dfs(e,cur));
		C[cur]+=B.back();
	}
	if(C[cur]<N) B.push_back(N-C[cur]);
	
	ll P[3]={(mo+1)/2,0,0};
	FORR(b,B) {
		ll w=modpow((mo+1)/2,b);
		b=(1+mo-w)%mo;
		ll Q[3]={};
		Q[0]=P[0]*w%mo;
		Q[1]=(P[1]*w+P[0]*b)%mo;
		Q[2]=(P[2]+P[1]*b)%mo;
		swap(P,Q);
	}
	
	ret+=P[2];
	
	return C[cur];
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N-1) {
		cin>>x>>y;
		E[x-1].push_back(y-1);
		E[y-1].push_back(x-1);
	}
	dfs(0,-1);
	cout<<ret%mo<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 36992
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << endl
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
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;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };


int main()
{
  ll s;
  //まず一点目は原点で固定して問題ない、あとは残りの二点なんだけど、(a,b),(c,d)は外積の公式から、S=ca-bdになり、
  //Sのとりえる範囲は1<=S<=10^18なのでどうすればこのすべてを手に入れられるか考えると、まず最小と最大を(a,b)に入れてしまう、
  //そうすると10^18c-1dで1~10^18すべてが取れるので、二点目も固定していい、あとは与えられたSから残り一点を求めるだけ
  
  ll a,b,c,d;
  cin >> s;
  a=1e9;b=1;
  d=ceil((long double)s/(double)a),c=a*d-s;
  cout << 0 << " " << 0 << " "<< a << " " << b << " "<< c<<" "<< d << endl;

}



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

int main() {
    int A,B,C,X;
    cin>>A>>B>>C>>X;
    int check=0;
    
    for (int i=0; i<=A; i++) {
        for(int j=0;j<=B;j++){
            for (int l=0; l<=C; l++) {
              int total=500*i+100*j+50*l;
                if(total==X){
                    ++check;
                }
            }
        }
    }
    cout<<check<<endl;
    return 0;
}


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

int main(){
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> A(N);
  rep(i, Q) {
    int tmp;
    cin >> tmp;
    A[--tmp]++;
  }
  rep(i, N) {
    if(K-Q+A[i] > 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}

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

typedef long long Int;
typedef pair<Int,Int> PII;
typedef vector<int> VInt;
 
#define FOR(i, a, b) for(i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(i = (a) - 1; i >= (b); --i)
#define EACH(it, a) for(auto it = (a).begin(); it != (a).end(); ++it)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
#define MP make_pair

int add(int a, int b)
{
	return abs(a - b);
}

int count2(int a)
{
	if(a < 2) return 0;
	return a/2 + count2(a/2);
}

int f(VInt& v)
{
	int i;
	int res = 0;
	int n = SIZE(v);
	FOR(i, 0, n)
		if(count2(n - 1) == count2(n - 1 - i) + count2(i)) 
			res = add(res, v[i] & 1);

	if(res == 1) return res;
	FOR(i, 0, n) if(v[i] == 1) return res;

	FOR(i, 0, n)
		if(count2(n - 1) == count2(n - 1 - i) + count2(i)) 
			res = add(res, v[i] >> 1);

	return res << 1;
}

int main()
{
	int n;
	string s;
	cin >> n >> s;
	int i;
	VInt v(n);
	FOR(i, 0, n) v[i] = s[i] - '1';

	cout << f(v) << endl;
	return 0;
}

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

int N;
int A[100002];

int main() {
    cin >> N;
    for (int i = 1; i <= N; i++)
        cin >> A[i];

    long long res = 0;
    for (int i = 1; i <= N; i++) {
        if ((A[i] & 1) && A[i+1] > 0) {
            A[i]++;
            A[i+1]--;
        }
        res += A[i] / 2;
    }
    cout << res << endl;
}


Measured memory_bytes: 640
def main():
    n,a,b=map(int, input().split())
    x=[int(i) for i in input().split()]
    res=0
    for i in range(n-1):
        if((x[i+1]-x[i])*a > b):
            res+=b
        else:
            res+=((x[i+1]-x[i])*a)

    print(res)
if __name__ == '__main__':
    main()


Measured memory_bytes: 20160
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ld long double
#define ull unsigned long long int
#define ll long long int
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007ll
#define rep(i,L,R) for(ll i=L;i<R;i++)
#define f(n) rep(i,0,n)
#define DEBUG
#ifdef DEBUG
#define deb2(args...) {dbg,args; cerr<<endl;}
#else
#define deb2(args...)
#endif
struct debb{template<typename T> debb& operator,(const T &v){cerr<<v<<" ";return *this;}}dbg;
#define deb1(args...) do {cerr << #args << " : "; dbg,args; cerr << "\n";} while(0)
#define printa(a,L,R) rep(i,L,R) cout << a[i] <<' ';cout<<"\n";
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
template<typename T>T gcd(T a,T b){if(b==0)return a;else return gcd(b,a%b);}
template<typename T>T lcm(T a,T b){return a/gcd(a,b)*b;}
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=((res%p)*(x%p))%p;y=y>>1;x=(x*x)%p;}return res;}
ll pow1(ll x,ll y){ll res=1;while(y>0){if(y&1)res=(res*x);y=y>>1;x=x*x;}return res;}
const ll INF = 1e18l+10,N = 2e5+10,MAX = 5000000;
#define sq(X) ((X)*(X))
#define PI 3.141592653589

int main()
{
    ll n,i,j;
    cin>>n;
    ll a[n+1]={0};
    for(i=0;i<n-1;i++)
    {
        cin>>j;
        a[j]++;
    }
    for(i=1;i<=n;i++)
    cout<<a[i]<<"\n";
}

Measured memory_bytes: 5132
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    std::string S;
    std::cin >> S;

    const int N = S.size();

    std::map<char, int> dist;
    std::map<char, int> lastpos;

    // 文字種毎に、一番離れている距離を得る。
    for (int i = 0; i < N; ++i) {
        char c = S[i];
        if (lastpos.count(c) == 0) {
            dist[c] = i;
        }
        else {
            dist[c] = std::max(dist[c], i - lastpos[c] -1);
        }
        lastpos[c] = i;
    }

    // 最後に現れた場所から後ろの距離も考慮
    for (auto& d : dist) {
        auto c = d.first;
        d.second = std::max(d.second, N-1 - lastpos[c]);
    }

    // 距離の最大値が一番短い文字の最大距離が答え
    std::cout
        << std::min_element(dist.begin(), dist.end(),
                            [](auto a, auto b) {
                                return a.second < b.second;
                            })->second
        << std::endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string S; cin >> S; 
	reverse(S.begin(), S.end()); 
	int A[500010] = {}; // Nが下の位から入ってる
	int B[500010] = {}; // 9Nが下の位から入ってる 
	for(int i = 0; i < S.size(); i++){
		A[i] = S.at(i) - '0'; 
		B[i] = A[i] * 9; 
	} 
	for(int i = 0; i < S.size(); i++){
		B[i+1] += B[i] / 10; 
		B[i] %= 10; 
	}
	int ng = 0; int ok = 4545454; 
	while(ok - ng > 1){
		int mid = (ng + ok) / 2; 
		int tmp = mid;
		int C[500010] = {}; // 9N + mid が下の位から入ってる
		for(int i = 0; i < S.size() + 1; i++){
			C[i] = B[i]; 
		}
		int now = 0; 
		while(tmp > 0){
			C[now] += tmp % 10; 
			tmp /= 10; now ++; 
		}
		for(int i = 0; i < S.size() + 1; i++){
			if(C[i] >= 10){
				C[i] -= 10; C[i+1] += 1; 
			}
		}
		int sum = 0; 
		for(int i = 0; i < S.size() + 2; i++){
			sum += C[i]; 
		}
		if(sum <= (mid + 8) / 9 * 9) ok = mid; 
		else ng = mid; 
	}
	cout << (ok + 8) / 9 << endl; 
}

Measured memory_bytes: 4740
use v5.18;
use warnings;
use utf8;
use List::Util qw( sum );
use Data::Dumper;
sub line { chomp(my $str = <>); $str; }
sub split_line { (split / /, line) }

main();

sub main {
  line;
  say solve([split_line]);
}

sub solve {
  my $ary = shift;
  my %count;
  for my $n (@$ary) {
    $count{$n} = exists $count{$n} ? $count{$n} + 1 : 1;
  }
  sum( map {
    my ($key, $val) = ($_, $count{$_});
    if ($key > $val) {
      $val
    } elsif ($key < $val) {
      $val - $key
    } else {
      0
    }
  } keys %count );
}


Measured memory_bytes: 39756
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
vector<int> dx = {-1, -1, -1, 0, 0, 1, 1, 1};
vector<int> dy = {-1, 0, 1, -1, 1, -1, 0, 1};

int main () {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = 0;
    rep(i, n) {
        if (i % 2 == 0 && a[i] % 2 == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();

		int S = Integer.parseInt(line);

		int a = 0;
		int b = 0;
		int c = 0;

		if (S / 3600 > 0) {
			a = S / 3600;
		}

		if (S / 60 > 0)
			b = (S - S / 3600 * 3600) / 60;

		if (S > 0) {
			c = S - a * 3600 - b * 60;
		}

		System.out.println(a + ":" + b + ":" + c);

	}

}



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

int main(){
  ll n,k;
  cin>>n>>k;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  vector<int> came(n,-1);
  int now=1;
  int fir,cyc,move;
  came[0] = 0;
  for(int i=1;i<=n;i++){
    now = a[now-1];
    if(came[now-1]==-1){
      came[now-1]=i;
    }else{
      fir = came[now-1];
      cyc = i - fir;
      break;
    }   
  }
  if(k<=fir){
    move = k;
  }else{
    move = fir + (k-fir)%cyc;
  }
  now = 1;
  for(int i=0;i<move;i++){
    now = a[now-1];
  }
  cout<<now<<endl;
  return 0;
}

Measured memory_bytes: 4844
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, [ $t:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn dfs(v: usize, adj: &Vec<Vec<usize>>, color: &mut Vec<i8>, current: i8) {
  if color[v] != 0 {
    return;
  }
  color[v] = current;
  for &u in &adj[v] {
    dfs(u, adj, color, 3 - current);
  }
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    es: [(usize1, usize1); n-1],
  }
  let mut adj = vec![vec![]; n];
  for &(a, b) in &es {
    adj[a].push(b);
    adj[b].push(a);
  }
  let mut color = vec![0; n];
  dfs(0, &adj, &mut color, 1);
  let mut c1 = color.iter().filter(|&&c| c == 1).count();
  let mut c2 = n - c1;
  if c2 > c1 {
    for i in 0 .. n {
      color[i] = 3 - color[i];
    }
    std::mem::swap(&mut c1, &mut c2);
  }
  // dbg!()
  // let n1 = (n + 2) / 3;
  let n2 = (n + 1) / 3;
  // let n3 = n / 3;
  let mut p = vec![0; n];
  let mut m1 = 1;
  let mut m2 = 2;
  let mut m3 = 3;
  if n2 <= c2 {
    for i in 0 .. n {
      if color[i] == 1 {
        if m1 <= n {
          p[i] = m1;
          m1 += 3;
        } else {
          p[i] = m3;
          m3 += 3;
        }
      } else {
        if m2 <= n {
          p[i] = m2;
          m2 += 3;
        } else {
          p[i] = m3;
          m3 += 3;
        }
      }
    }
  } else {
    for i in 0 .. n {
      if color[i] == 1 {
        if m1 <= n {
          p[i] = m1;
          m1 += 3;
        } else if m2 <= n {
          p[i] = m2;
          m2 += 3;
        } else {
          p[i] = m3;
          m3 += 3;
        }
      } else {
        p[i] = m3;
        m3 += 3;
      }
    }
  }
  for &x in &p {
    puts!("{} ", x);
  }
  puts!("\n");
}


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

int main(){
  int N,M,Q; 
  scanf("%d%d%d",&N,&M,&Q);
  
  int a[N+1]={},b[N+1][N+1]={},L,R;
  REP(_,M){
    scanf("%d%d",&L,&R);
    a[R]++;
    REP(i,R-L){
      b[L+i+1][R]++;
    }
  }
  REP(i,N) a[i+1]=a[i]+a[i+1];
  REP(i,N) REP(j,N) b[i+1][j+1]=b[i+1][j]+b[i+1][j+1];
  
  int p,q;
  REP(_,Q){
    scanf("%d%d",&p,&q);
    printf("%d\n",a[q]-a[p-1]-b[p][q]);
  }
}

Measured memory_bytes: 4704
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int N;
    vector<int>v;
    cin>>N;
    v.push_back(0);
    for(int i=0;i<N;i++){
        int x;
        cin>>x;
        v.push_back(x);
    }
    v.push_back(0);
    int sum=0;
    for(int i=0;i<N+1;i++){
        sum+=abs(v[i+1]-v[i]);
    }
    for(int i=1;i<N+1;i++){
        cout<<sum-abs(v[i]-v[i-1])-abs(v[i+1]-v[i])+abs(v[i+1]-v[i-1])<<endl;
    }

    return 0;
}

Measured memory_bytes: 1784
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
#define endl "\n"
#define c0 ios_base :: sync_with_stdio(0); cin.tie (0);
#define s second
#define f first
#define ll long long
#define ull unsigned ll
using namespace std;

const int MaxN = 4e5 + 17;
//const ll INF = 1e9 + 17;
//const int MOD = 1e9 + 7;
//const double eps = 1e-3;
//const double pi = 3.14159265359;


int n, Sum;
string s, S, SS, SQ;

int main()
{
    #ifdef DEBUG
        freopen (".in", "r", stdin);
        freopen (".out", "w", stdout);
    #endif
    cin >> n >> s;
    for (int i = 0; i < s.size(); ++ i)
    {
        if (s[i] == '(')
        {
            while (Sum < 0)
                SS += '(', ++ Sum;
            ++ Sum;
        }
        if (s[i] == ')')
        {
            -- Sum;
        }
        S += s[i];
    }
    while (Sum < 0)
        SS += '(', ++ Sum;
    while (Sum --)
        S += ')';
    cout << SS + S;
    return 0;
}

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

using namespace std;
typedef long long ll;
const int maxn=1e4+7;


int main() {
	int n,m,k,t;
	
	scanf("%d",&n);
	char s[10];
	int cntt=0,cnta=0,cntw=0,cntr=0;
	for(int i=0;i<n;i++){
		scanf("%s",s);
		if(s[0]=='A') cnta++;
		else if(s[0]=='T') cntt++;
		else if (s[0]=='W') cntw++;
		else if(s[0]=='R') cntr++;
	}
	printf("AC x %d\n",cnta);
	printf("WA x %d\n",cntw);
	printf("TLE x %d\n",cntt);
	printf("RE x %d\n",cntr);
	return 0;
}


Measured memory_bytes: 3824
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, l;
    cin >> n >> m >> l;
    vvi dist(n, vi(n, l+1));
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        --a; --b;
        chmin(dist[a][b], c);
        chmin(dist[b][a], c);
    }
    rep(k, n) rep(i, n) rep(j, n) {
        chmin(dist[i][j], dist[i][k]+dist[k][j]);
    }
    vvi ddist(n, vi(n, INF));
    rep(i, n) rep(j, n) {
        if(dist[i][j] <= l) ddist[i][j] = 1;
    }
    rep(k, n) rep(i, n) rep(j, n) {
        chmin(ddist[i][j], ddist[i][k]+ddist[k][j]);
    }
    int q;
    cin >> q;
    while(q--) {
        int s, t;
        cin >> s >> t;
        --s; --t;
        if(ddist[s][t] == INF) cout << -1 << '\n';
        else cout << ddist[s][t]-1 << '\n';
    }
}

Measured memory_bytes: 3976
fn main() {
    let v = read_vec::<usize>();
    let n = v[0];
    let m = v[1];

    let mut ks = vec![];
    for _ in 0..m {
        let mut vv = read_vec::<u32>();
        vv.remove(0);
        ks.push(vv);
    }

    let ps = read_vec::<u32>();

    let mut ans = 0;
    for i in 0..1 << n {
        let mut f = true;
        for j in 0..m {
            let mut count = 0;
            for k in &ks[j] {
                if (1 << (k - 1)) & i != 0 {
                    count += 1;
                }
            }
            if count % 2 != ps[j] {
                f = false;
                break;
            }
        }
        if f {
            ans += 1;
        }
    }
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
n = int(input())
val = [0] * n
maxdiff = [0] * n
for i in range(n):
    val[i] = int(input())
maxdiff[0] = 0
maxdiff[1] = val[1] - val[0]
minval = min(val[0:2])
for i in range(2, n):
    maxdiff[i]= max(maxdiff[i - 1], val[i] - minval)
    minval = min(minval, val[i])
print(maxdiff[-1])



Measured memory_bytes: 15132
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0
s = 0
t = []
for i in range(n):
    if a[i] >= b[i]:
        t.append(a[i]-b[i])
    else:
        ans += 1
        s += b[i] - a[i]
m = len(t)
t.sort(reverse=True)
j = 0
while s > 0 and j < m:
    s -= t[j]
    j += 1
if s > 0:
    print(-1)
else:
    print(ans + j)

Measured memory_bytes: 24096
#if defined(LOCAL)
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) (debug(x, #x))
#define I(x, ...) (x)
#define C(x...) CHECK(x)
#else
#define L(x, ...) (x)
#define I(x, ...) (x)
#define C(x, ...) ;
#endif
#include <math.h>
#include <algorithm>
#include <bitset>
#include <chrono>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ii = pair<int, int>;
using lu = unsigned long long;
using l = long long;
using vs = vector<string>;
using vii = vector<ii>;
using vl = vector<l>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vlu = vector<lu>;
using ll = pair<l, l>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vd = vector<double>;
using vvd = vector<vd>;
using mll = unordered_map<l, l>;
using sl = unordered_set<l>;
const l      INF = numeric_limits<l>::max();
const double EPS = 1e-10;
const double PI = 3.14159265358979323846;
const l      e0 = 1, e3 = 1000, e5 = 100000, e6 = 10 * e5, e7 = 10 * e6,
        e8 = 10 * e7, e9 = 10 * e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a, b, c) for (l a = l(b); a < l(c); a++)
#define B(a, b, c) for (l a = l(c) - 1; a >= l(b); a--)
#define VVL(x, a, b, i) vvl x(a, vl(b, l(i)));
#define VVVL(x, a, b, c, i) vvvl x(a, vvl(b, vl(c, l(i))));

void solve(istream &in, ostream &out);
void solve_brute(istream &, ostream &);
bool interactive_judge(istream &, istream &, ostream &);
bool generate_random(l, ostream &);
bool solution_checker(istream &, istream &, istream &, ostream &);
int  main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  tst::test_init(argc, argv);
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _judge = interactive_judge;
  // _custom_solution_checker = solution_checker;
  tst::maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}
const l MOD = e9 + 7;  // end of template

void solve(istream &in, ostream &out) {
  l n;
  in >> n;
  vl v(n);
  F(i, 0, n) in >> v[i];
  vl z(n);
  B(i, 0, n) {
    l k = -1;
    F(j, 0, v.size()) {
      if (v[j] == j + 1) k = j;
    }
    if (k == -1) {
      out << -1 << lf;
      return;
    }
    z[i] = k + 1;
    vl c;
    F(j, 0, v.size()) if (j != k) c.emplace_back(v[j]);
    swap(c, v);
  }
  F(i, 0, n) out << z[i] << lf;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {

	void solve() {
		int n = in.nextInt(), m =in.nextInt(), k = in.nextInt();
		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= m; j++) {
				long res = n * m - i * j - (n - i) * (m - j);
				if (res == k) {
					out.println("Yes");
					return;
				}
			}
		}
		out.println("No");
	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public String nextToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextToken());
		}

		public long nextLong() {
			return Long.parseLong(nextToken());
		}

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

	public static void main(String[] args) {
		new Main().run();
	}
}


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

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

    bool judge=false;
    bool exist=false;
    char i='a';
    char result;

    while(judge==false && i<='z'){
        for(int j=0; j<s.size(); j++){
            if(s.at(j)==i){
                exist=true;
                break;
            }
        }
        if(exist==false){
            judge=true;
            cout<<i<<endl;
            break;
        }
        exist=false;
        i++;
    }

    if(judge==false){
        cout<<"None"<<endl;
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define MAX 10000007
#define PI acos(-1)
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)
#define debug(x) cout<<x<<endl;
#define endl "\n"
#define MEM(a,x) memset(a,x,sizeof(a))

using namespace std;
typedef long long ll ;
const int INF= 1e9+7;

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<long long,null_type,less<long long>, rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
*/
/*
bool sortbysec(const pair<int,int>&a, const pair<int,int>&b)
{
    return (a.second<b.second);
}
*/
int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.tie(NULL);
    int y,m,d;
    char c1;

    cin>>y>>c1>>m>>c1>>d;

    if(m<=4 && d<=30)
        cout<<"Heisei"<<endl;
    else
        cout<<"TBD"<<endl;



    return 0;
}


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

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

return 0;
}


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

using namespace std;

int main()
{
	int x, y, z;
	
	cin >> x >> y;
	
	while (y > 0){
		if (x < y) swap(x, y);
		
		z = x % y;
		x = y;
		y = z;
	}
	
	cout << x << "\n";
	
	return (0);
}


Measured memory_bytes: 3108
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::cout << (N <= 999 ? "ABC" : "ABD") << std::endl;
  return 0;
}

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

typedef struct {
    int num;
    int p;
    long long y;
    char id[13];
} city_t;

int compare_num(const void *a, const void *b)
{
    return ((city_t*)a)->num - ((city_t*)b)->num;
}

int compare_p(const void *a, const void *b)
{
    return ((city_t*)a)->p - ((city_t*)b)->p;
}

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

int main (void)
{
    int N, M;
    city_t city[(int)1e5];
    int i, start = 0, end = 0, x = 1;

    scanf("%d %d", &N, &M);

    for (i = 0; i < M; i++) {
        city[i].num = i;
        scanf("%d %lld", &city[i].p, &city[i].y);
    }

    qsort(city, M, sizeof(city_t), compare_p);

    while (start < M) {
        for (end = start; end < M; end++) {
            if (city[end].p != city[end + 1].p) break;
        }
        qsort(&city[start], end - start + 1, sizeof(city_t), compare_y);
        start = end + 1;
    }

    for (i = 0; i < M; i++) {
        sprintf((char*)&city[i].id, "%06d%06d", city[i].p, x++);
        if (city[i].p != city[i + 1].p) x = 1;
    }

    qsort(city, M, sizeof(city_t), compare_num);

    for (i = 0; i < M; i++) {
        puts(city[i].id);
    }
}


Measured memory_bytes: 7756
using System;

class main
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();
		
        if(s.Length <= N){
          Console.WriteLine(s);
        }else{
   	     Console.WriteLine(s.Substring(0, N) + "...");
          
        }
    }
        
}



Measured memory_bytes: 27332
def isPrime(num):
	flag = True
	if(num==1):
		return False
	for i in range(2,int(num**0.5)+1):
		if(num%i==0):
			flag = False
			break
	return flag

a = []
temp = 0
n = int(input().strip())
for i in range(n):
	temp = int(input().strip())
	if isPrime(temp):
		a.append(temp)
print(len(a))

Measured memory_bytes: 8044
import math
N = int(input())
h = list(map(int,input().split())) + [0] * 2
cost = [float("inf")] * (N+2)
cost[0] = 0
for i in range(N):
    cost[i+1] = min(cost[i+1], cost[i] + abs(h[i]-h[i+1]))
    cost[i+2] = min(cost[i+2], cost[i] + abs(h[i]-h[i+2]))
print(cost[N-1])


Measured memory_bytes: 14104
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  int n;
  char str[10],com[13];
  map<string,bool> mp;
  cin >> n;
  rep(i,n){
    cin >> com >> str;
    if(com[0] == 'i') mp[str] = true;
    //cout << string(str) << endl;}
    else {
      if(mp[string(str)]) cout << "yes" << endl;
      else cout << "no" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 47432
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
 
#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)
 
int h, w, n;
int a[10000];
int res[100][100];
 
int main(int argc, char **argv) {
	cin >> h >> w >> n;
	REP(i, n) cin >> a[i];
	int k = 0;
	REP(y, h) REP(x, w) {
		res[y % 2 == 0 ? x : w - 1 - x][y] = k + 1;
		--a[k];
		if (a[k] <= 0) ++k;
	}
	REP(y, h) {
		REP(x, w) {
			if (x != 0) cout << ' ';
			cout << res[x][y];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 384
// 2020-08-07 09:38:47
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  ll a, b, c;
  cin >> a >> b >> c;
  if(c - a - b <= 0) {
    cout << "No" << '\n';
  } else if(4 * a * b < (c - a - b) * (c - a - b)) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> c(4, 0);

  rep(i, n) {
    string s;
    cin >> s;
    if (s[0] == 'A') c[0]++;
    else if (s[0] == 'W') c[1]++;
    else if (s[0] == 'T') c[2]++;
    else if (s[0] == 'R') c[3]++;
  }

  cout << "AC x " << c[0] << endl;
  cout << "WA x " << c[1] << endl;
  cout << "TLE x " << c[2] << endl;
  cout << "RE x " << c[3] << endl;

  return 0;
}

/*
*/


Measured memory_bytes: 3628