akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#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(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#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 show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//inline int in() { int x; scanf("%d",&x); return x;}
template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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, p;
  cin >> n >> p;
  string s;
  cin >> s;
  if (10%p == 0) { // 2, 5
    ll ans = 0;
    rep(r,n) {
      if ((s[r]-'0')%p == 0) {
        ans += r+1;
      }
    }
    cout << ans << endl;
    return 0;
  }

  vi d(n+1);
  int ten = 1;
  drep(i,n) {
    int a = (s[i]-'0') * ten % p;
    d[i] = (d[i+1]+a) % p;
    ten *= 10; ten %= p;
  }
  vi cnt(p);
  ll ans = 0;
  for (int i = n; i >= 0; --i) {
    ans += cnt[d[i]];
    cnt[d[i]]++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1412
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	ll n; cin >> n;
	bool ok=1;
	int cnt=0;
	while(n>9){
		if(n%10!=9)ok=0;
		cnt++;
		n/=10;
	}
	if(!ok)n--;
	cout << n+cnt*9 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int main() {
	in(int, N);
	in_v(ll, L, 2*N);
	sort_v(L);
	ll cnt = 0;
	loop(i, N)
		cnt += L[2 * i];
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);
map<pair<int, int>, int> ans;

void dfs(int s, int prev, vector<vector<int> > &G, vector<int> &col, vector<int> &vis) {
  vis[s] = 1;
  rep(i, G[s].size()) {
    int v = G[s][i];
    if (vis[v] == 1) continue;

    col[s]++;
    if (col[s] == prev) col[s]++;

    ans.insert(make_pair(make_pair(s,v), col[s]));
    ans.insert(make_pair(make_pair(v,s), col[s]));
    dfs(v, col[s], G, col, vis);
  }
}

int main() {
  int N; cin >> N;
  vector<vector<int> > G(N+1);
  vector<int> vis(N+1, 0);
  vector<pair<int, int> > edge(N-1);

  rep(i, N-1) {
    int a, b; cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
    edge[i] = make_pair(a, b);
  }

  vector<int> col(N+1, 0);

  dfs(1, 0, G, col, vis);

  int colMax = 0;
  rep(i, N+1) colMax = max(colMax, col[i]);

  cout << colMax << endl;
  rep(i, N-1) {
    cout << ans[edge[i]] << endl;
  }

  return 0;
}


Measured memory_bytes: 20096
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long LL;
typedef pair<int, int> pii;

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }

template <typename T> inline T read(){
    T sum = 0;
    int fl = 1,ch = getchar();
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') fl = -1;
    for(; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
    return sum * fl;
}

const int maxn = 2e5 + 5;

int n,k,ans = 1e12;
int a[maxn],f[maxn];

inline bool check(int x){
	int sum = 0;
	for(int i = 1; i <= n; i++){
		if(a[i] * f[i] > x){
			int res = (a[i] * f[i] - x) / f[i];
			int s = a[i] * f[i] - f[i] * res;
			if(s > x) res++;
			sum += res;
			if(sum > k) return false;
		}
	}
	return true;
}

inline void Solve (){
	sort(a + 1,a + n + 1);
	sort(f + 1,f + n + 1,greater<int>());
	int l = 0,r = 1e12;
	while(l <= r){
		int mid = (l + r) >> 1;
		if(check(mid)){
			r = mid - 1;
			Chkmin(ans,mid);
		}else l = mid + 1;
	}
	printf("%lld\n",ans);
}

inline void Input (){
	n = read<int>();
	k = read<int>();
	for(int i = 1; i <= n; i++){
		a[i] = read<int>();
	}
	for(int i = 1; i <= n; i++){
		f[i] = read<int>();	
	}
}

signed main(){
	Input();
	Solve();
	return 0;
}

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

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

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

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

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



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll x,k,d; cin>>x>>k>>d;
  
  ll cnt=abs(x)/d;
  if(cnt>k){
    cout<<abs(x)-d*k<<endl;
    return 0;
  }
  
  if(x>=0) x-=cnt*d;
  else x+=cnt*d;
  k-=cnt;
  
  ll ans=abs(x);
  if(k%2) ans=abs(d-ans);
  cout<<ans<<endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double PI = 3.14159265358979323846;
typedef long long ll;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) for (ll i = 0; i < (n); ++i)

int main() {
  ll x[3] = {0}, ans = 0;
  REP(i, 3) cin >> x[i];
  sort(x, x + 3);
  if (x[2] - x[1] >= 2) {
    ll count = (x[2] - x[1]) / 2;
    x[1] += count * 2;
    ans += count;
  }
  if (x[2] - x[0] >= 2) {
    ll count = (x[2] - x[0]) / 2;
    x[0] += count * 2;
    ans += count;
  }
  sort(x, x + 3);
  if (x[2] - x[0] + x[1] - x[0] == 2) {
    ans += 2;
  } else if (x[2] - x[0] + x[1] - x[0] == 1) {
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    string a, b;

    cin >> a >> b;
    int num = stoi(a + b);

    for(int i =0; i < 330; i++){
        if( (i+1) * (i+1) == num) {
            cout << "Yes" << endl;
            return 0;
        }
    } 
    cout << "No" << endl;
    return 0;

}


Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in(gcu());}
_sc(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename H,typename... T> _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
template <typename T>
_vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for (char c: s) pcu(c);}
template <typename H,typename... T> _vo(H&& h, T&&... t){out(h);out(move(t)...);}
//template <typename T> _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
_vl(){out('\n');}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	unordered_map<int, int> m;
	map<int, int> r;
	for (int p, s; p = in(), s = in(), p || s;)
		m[p] = s;
	for (auto p: m)
		r[p.second]++;
	int i = r.size();
	for (auto &p: r)
		p.second = i--;
	for (int q; scan(q);)
		outl(r[m[q]]);
}


Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  if(k<=a){
    cout << a - k << " " << b << endl;
  }
  else if(k<=a+b){
    cout << 0 << " " << b - (k - a) << endl;
  }
  else{
    cout << 0 << " " << 0 << endl;
  }
}

Measured memory_bytes: 256
// Problem : A - Strings
// Contest : AtCoder - AtCoder Beginner Contest 149
// URL : https://atcoder.jp/contests/abc149/tasks/abc149_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    string s,t;
    cin>>s>>t;
    cout<<t+s<<endl;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t=1;
    // cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        int mod=0;
        for(auto ch:s)
        {
            mod = ((ch-'0')%9+mod%9)%9;
        }
        if(mod) cout<<"No\n"; else cout<<"Yes\n";
    }
	return 0;
}

Measured memory_bytes: 3716
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#include <random>
#define INF 1000000007
using namespace std;

int main(void){
	int d,n;
	cin >> d >> n;
	int ans=n;
	for(int i=0; i<d; i++)ans*=100;
	if(n==100)ans+=ans/100;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
 
using namespace std;
int MOD = 1000000007;

signed main(){
    int a,b,c;
    cin >> a >> b >> c;
    int cnt = 0;
    while(cnt != c && b >= a){
        cnt++;
        b -= a;
    }
    cout << cnt << endl;

    

    
    return 0;   
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://arc059.contest.atcoder.jp/tasks/arc059_a
// rm -r -f test;oj dl http://yahoo-procon2017-qual.contest.atcoder.jp/tasks/yahoo_procon2017_qual_c

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  string n;
  cin >> n;
  bool flag = false;
  rep(i,n.length()){
    if(n[i] == '7') flag = true;
  }
  cout << (flag ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3628
n = int(input())
S = [input() for i in range(n)]
A = [0, 0, 0, 0, 0]
B = ["M", "A", "R", "C", "H"]

for i in range(n) :
    for j in range(5) :
        if S[i][0] == B[j] :
            A[j] += 1

#print(A)

ans = 0
for i in range(5) :
    for j in range(i+1, 5) :
        for k in range(j+1, 5) :
            ans += A[i]*A[j]*A[k]

print(ans)


Measured memory_bytes: 9752
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	cout << N*N*N << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 1000000;
const int INF = 1e9;
const double pi=acos(-1);


int main(){
  int n;
  cin >> n;
  ll T,A;
  rep(i,n){
    if(i==0){
      cin >> T;
      cin >> A;
    }
    else{
      ll nt,na;
      cin >> nt >> na;
      if(nt>=T && na >=A){
        T=nt;
        A=na;
        continue;
      }
      else{
        ll p=nt,q=na;
        ll r=max((T+nt-1)/nt,(A+na-1)/na);
        T=r*p;
        A=r*q;
      }
    }
  }
  cout <<T+A<<endl;
    
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const double EPS = 1e-9;
const int maxA = 30;

ll occ[maxA], memo[maxA][maxA];
int n;
string s;

void read(){
  cin >> n;
  cin >> s;
}

ll dp(int i, int rem){
  if(i >= maxA){
    if(rem == 0)
      return 1;
    return 0;
  }

  if(memo[i][rem] != -1)
    return memo[i][rem];

  ll ans0 = 1, ans1 = 1;
  ans0 = (ans0 * dp(i + 1, rem)) % MOD;
  ans1 = (((ans1 * dp(i + 1, rem - 1)) % MOD) * occ[i]) % MOD;
  return (memo[i][rem] = (ans0 + ans1) % MOD);
}

void solv(){
  for(int i = 0; i < n; i++)
    occ[s[i] - 'a']++;

  for(int i = 0; i < maxA; i++)
    fill_n(memo[i], maxA, -1);

  ll fres = 0;
  for(int i = 1; i < maxA; i++){
    fres = (fres + dp(0, i)) % MOD;
  }

  cout << fres << '\n';
}

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

  #ifdef DEBUG
    freopen("in.txt", "r", stdin);
  #endif

  read();
  solv();

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll x,a;
	cin>>x>>a;
	if(x<a){
		cout << 0;
	}
	else{
		cout << 10;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;
    
#define EPS (1e-7)
#define INF (1<<30)
#define LLINF (1LL<<60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll> h(n);
    for(ll i=0;i<n;i++){
        cin>>h[i];
    }
    ll r=0;
    ll ans=0;
    for(ll l=0;l<n;l++){
        while(r+1<n&&h[r]>=h[r+1]){
            r++;
        }
        chmax(ans,r-l);
        if(r==l){
            r++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
N, K = map(int, input().split())
S = input()
A = ["N"]*N
base = S[0]
cnt = 0
comp = False
i=0
while i < N:
    if not comp and S[i]!=base:
        if cnt < K:
            comp = True
            cnt+=1
    if comp and S[i]==base:
        comp = False
    if not comp:
        A[i] = S[i]
    else:
        A[i] = base
    i+=1

ans = 0
for i in range(1,N):
    ans += A[i-1] == A[i]
print(ans)

Measured memory_bytes: 4084
#include<stdio.h>
int main(void)
{
	int n;
	int i;
	int s;
	s=100000;

	while(scanf("%d",&n)!=EOF){
		for(i=0;i<n;i++){
			s=s*1.05;
			if(s%1000!=0){
				s=s-s%1000;
				s=s+1000;
			}
		}
		printf("%d\n",s);
	}
	return 0;
}

Measured memory_bytes: 1020
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
	private StringTokenizer st;
	private BufferedReader bf;
	private int w;
	
	Main() {
//		readData();
		
		Scanner sc = new Scanner(System.in);
		
		while (sc.hasNext()){
			int m = sc.nextInt();
			int n = sc.nextInt();
			System.out.println(Integer.toString(m+n).length());
		}
		sc.close();
	}
	

	private void readData() {
		try {
			bf = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(bf.readLine());
			
			int m = nextInt();
			int n = nextInt();
			System.out.println(Integer.toString(m+n).length());

			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
	
	
	private String next() throws IOException {
		if (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(bf.readLine());
		return st.nextToken();
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Main m = new Main();
	}

}

Measured memory_bytes: 20452
#include <iostream>

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

  if(A == B && B != C && C!=A){
    std::cout << "Yes" << std::endl;
    return 0;
  }
  if(B == C && C != A && A!=B){
    std::cout << "Yes" << std::endl;
    return 0;
  }

  if(C == A && A != B && B!=C){
    std::cout << "Yes" << std::endl;
    return 0;
  }

  std::cout << "No" << std::endl;


  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String args[]){
        Scanner sn = new Scanner(System.in);
        int A = sn.nextInt();
        int B = sn.nextInt();
        int C = sn.nextInt();
        int K = sn.nextInt();
        int flag = 1;
        int ans = 0;

        for(int i=0; i<A; i++){
            if(K == 0) {
                break;
            }
            ans = ans + 1;
            K = K - 1;
        }

        for(int i=0; i<B; i++){
            if(K == 0) {
                break;
            }
            K = K - 1;
        }

        for(int i=0; i<C; i++){
            if(K == 0) {
                break;
            }
            ans = ans - 1;
            K = K - 1;
        }

        System.out.println(ans);

    }
}

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




int main(){
      int n;
      int ans =0;
      cin >> n;
      vector<int> v(n);
      for(int i=0;i<n;i++){
            cin >> v[i];
            int s=sqrt(v[i]);
            int f=0;
            for(int p=2;p<=s;p++){
                  if(v[i]%p==0) f=1;
            }
            if(f==0){
                  ans ++;
            }
      }
      cout<< ans<<endl;

}


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

using namespace std;
using ll = long long;

int main() {
    int n,k;
    cin>>n>>k;
    vector<pair<ll,ll>> d;
    set<ll> xs,ys;
    for(int i = 0; i < n; ++i){
        ll a,b;
        cin>>a>>b;
        d.emplace_back(a,b);
        xs.insert(a);
        ys.insert(b);
    }
    auto itxl=xs.begin();
    ll ans=5000000000000000000LL;
    while(itxl!=xs.end()) {
        auto itxr=itxl;
        ++itxr;
        while(itxr!=xs.end()) {
            auto ityl=ys.begin();
            while(ityl!=ys.end()) {
                auto ityr=ityl;
                ++ityr;
                while(ityr!=ys.end()) {
                    ll xl=*itxl,xr=*itxr,yl=*ityl,yr=*ityr;
                    int cnt=0;
                    for(int i = 0; i < n; ++i){
                        if(xl<=d[i].first&&d[i].first<=xr&&yl<=d[i].second&&d[i].second<=yr)++cnt;
                    }
                    if(cnt>=k) {
                        ans=min(ans,(xr-xl)*(yr-yl));
                        break;
                    }
                    ++ityr;
                }
                ++ityl;
            }
            ++itxr;
        }
        ++itxl;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;
ll max(ll a, ll b){ return (a>b)?a:b;}
int main(void){
    // Your code here!
    int a, b;
    scanf("%d %d",&a,&b);
    printf("%d\n",max(a-b,max(a+b,a*b)));
}


Measured memory_bytes: 128
import Control.Monad
import Data.List

main = do
    [n,k] <- map read . words <$> getLine
    hs <- replicateM n readLn
    let sHs = sort hs
    print $ minimum $ zipWith (-) (tailN (k-1) sHs) sHs

tailN :: Int -> [Int] -> [Int]
tailN n (x:xs) 
    | n == 1 = xs  
    | otherwise = tailN (n-1) xs


-- fold or zipwithで書きたい

Measured memory_bytes: 65916
const { listenerCount } = require("process");

function main(input = "") {
    const WALL = -1, ROAD = 99999999;
    const lines = input.split("\n");
    const header = lines.slice(0, 3).map((line) => (line.split(" ").map((v) => (Number(v)))));
    const H = header[0][0], W = header[0][1];
    const Ch = header[1][0] - 1, Cw = header[1][1] - 1;
    const Dh = header[2][0] - 1, Dw = header[2][1] - 1;
    const Dest = Dh * W + Dw;
    const GRID = lines.slice(3).map((line) => (line.split("").map((v) => (v === "#" ? WALL : ROAD))))
    const MAZE = new Int32Array(Array().concat(...GRID));

    let fill = (h = 0, w = 0, v = 0, arr = []) => {
        let id = h * W + w;
        if (MAZE[id] > v) {
            MAZE[id] = v;
            arr.push(id)
            if (0 <= h - 1) fill(h - 1, w, v, arr);
            if (h + 1 < H) fill(h + 1, w, v, arr);
            if (0 <= w - 1) fill(h, w - 1, v, arr);
            if (w + 1 < W) fill(h, w + 1, v, arr);
        }
    }

    let getWarpList = (area = [0]) => {
        let set = new Set();
        area.forEach((v) => {
            let ih = 0 | v / W;
            let iw = v - ih * W;
            _warpList(ih, iw, set);
        })
        return set;
    }

    let _warpList = (h = 0, w = 0, set = new Set([0])) => {
        let v = MAZE[h * W + w];
        for (let ih = -2; ih <= 2; ih++) {
            let th = h + ih;
            if (0 <= th && th < H) {
                for (let iw = -2; iw <= 2; iw++) {
                    let tw = w + iw;
                    if (0 <= tw && tw < W) {
                        let toId = th * W + tw
                        if (MAZE[toId] > v) {
                            set.add(toId);
                        }
                    }
                }
            }
        }
    }

    let area = [];
    let ch = Ch, cw = Cw;
    let color = 1;
    fill(ch, cw, color, area);
    while (true) {
        color++;
        let lst = getWarpList(area)
        area.length = 0;
        for (const v of lst) {
            let ih = 0 | v / W;
            let iw = v - ih * W;
            fill(ih, iw, color, area);
        }
        if (area.length === 0) {
            break;
        }
    }

    return MAZE[Dest] === ROAD ? -1 : MAZE[Dest] - 1;
}


//******************************
exports.main = main;

function Main(input) {
    console.log(main(input.trim()));
}

if (process.argv[2] !== "test") {
    Main(require("fs").readFileSync("/dev/stdin", "utf8"));
}

Measured memory_bytes: 87064
N = int(input())
D = {}
for i in range(1, N+1):
    str_i = str(i)
    if (str_i[-1], str_i[0]) not in D:
        D[(str_i[-1], str_i[0])] = 1
    else:
        D[(str_i[-1], str_i[0])] += 1

ans = 0
for j in range(1, N+1):
    str_j = str(j)
    if (str_j[0], str_j[-1]) in D:
        ans += D[(str_j[0], str_j[-1])]

print(ans)


Measured memory_bytes: 3064
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    V = list(map(int, input().split()))
    C = list(map(int, input().split()))
    
    #差分
    sa = [ V[i] - C[i] if V[i] - C[i] > 0 else 0 for i in range(N) ]
    
    #昇順
    sa.sort()
    
    print(sum(sa))
    
if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

int main() {
    int W, a, b;

    cin >> W >> a >> b;

    int A = a + W;
    int B = b;
    int C = a;
    int D = b + W;

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

    return 0;    
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<vector>
#include<map>
#include<queue> 
#include<algorithm>
using namespace std;
#define maxn
#define ll long long
int read(){
    int x=0,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();}
    return x*f;
}
int n,m;
int main(){
	int x=read(),y=read();
	printf("%d\n",max(x-y,0));
}

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

int main(){
  long long N, P;
  cin >> N >> P;
  map<long long, int> M;
  for(long long i = 2; i <= (1e6); ++i){
    if(P == 1) break;
    while(not (P%i)) ++M[i], P /= i;
  }
  if(P > 1) ++M[P];
  long long ans = 1;
  for(auto itr = M.begin(); itr != M.end(); ++itr){
    for(int i = 0; i < itr->second/N; ++i)
      ans *= itr->first;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    string s;
    cin>>s;
    int ans=0;
    int n=(int)s.size();
    for(int i=n-3;i>=0;i-=2){
        int f=i,b=i/2;
        bool ok=false;
        while(s[f]==s[b]){
            if(b==0)ok=true;
            f--;
            b--;
            
        }
        if(ok){
            ans=i+1;
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
  ll h;
  ll now = 1;
  ll ans = 0;

  cin >> h;

  for(;;){ 

    if( h == 0 ) break;

    ans += now;

    h /= 2;
 
    now *= 2;
  
  }

  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 256
from functools import reduce

n, k = map(int, input().split())
a = list(map(int, input().split()))

a.sort(key=lambda v: abs(v), reverse=True)
mod = 10 ** 9 + 7
if n == k:
    print(reduce(lambda ac, v: ac * v % mod, a, 1))
    exit()
elif len(list(filter(lambda v: v < 0, a))) == n and k % 2 == 1:
    print(reduce(lambda ac, v: ac * v % mod, a[n - k :], 1))
    exit()

ans = 1
mn = 0
for v in a[:k]:
    if v < 0:
        mn += 1
    ans *= abs(v)
    ans %= mod

if mn % 2 == 0:
    print(ans)
    exit()

mnp, mnn = 0, 0
for v in a[k - 1 :: -1]:
    if mnp != 0 and mnn != 0:
        break
    elif mnp == 0 and v > 0:
        mnp = v
    elif mnn == 0 and v < 0:
        mnn = v
mxp, mxn = 0, 0
for v in a[k:]:
    if mxp != 0 and mxn != 0:
        break
    elif mxp == 0 and v > 0:
        mxp = v
    elif mxn == 0 and v < 0:
        mxn = v
x, y = mxp, mnn
if mnp != 0 and mxn * mnn > mxp * mnp:
    x, y = mxn, mnp
ans *= pow(abs(y), mod - 2, mod)
ans %= mod
ans *= abs(x)
ans %= mod
print(ans)


Measured memory_bytes: 116228
def solve():
    mod = 10**9+7
    L = input()
    N = len(L)
    dp = [0]*2
    dp[0] = 1
    dp[1] = 2
    for i in range(1, N):
        if L[i]=='0':
            dp[0], dp[1]=dp[0]*3%mod, dp[1]
        else:
            dp[0], dp[1]=(dp[0]*3+dp[1])%mod, dp[1]*2%mod
    print((dp[0]+dp[1])%mod)
solve()


Measured memory_bytes: 39408
def main():
    n = int(input())
    a = []
    for i in range(n):
        a.append(int(input()))

    flag = False
    on = 0
    cnt = 0
    for i in range(n):
        if a[on] == 2:
            cnt += 1
            flag = True
            break
        else:
            cnt += 1
            on = a[on] - 1

    if flag:
        print(cnt)
    else:
        print(-1)



if __name__ == '__main__':
    main()

Measured memory_bytes: 12960
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x[] = new int[n];
		long a2 = 0;
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			a2 += 2 * x[i] * Math.pow(-1, i);
		}
		a2 = a2 / 2;
		for (int i = 0; i < n; i++) {
			System.out.print(a2);

			a2 = 2 * (x[i] - a2 / 2);
			if (i != n - 1) {
				System.out.print(" ");
			}
		}
	}
}

Measured memory_bytes: 61640
#include<map>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int h,i,j;
  int a[300],b[300],c[300],d[300],n;
  map<int,int> z;
  while(cin>>n&&n){
    for(i=0;i<n;i++)
      cin>>a[i]>>b[i]>>c[i]>>d[i];
    h=1;
    for(i=0;h;i++){
      h=0;
      for(j=1;j<n-i;j++){
	if(0){
	}else if(c[j-1]<c[j]){
	  swap(a[j-1],a[j]);
	  swap(b[j-1],b[j]);
	  swap(c[j-1],c[j]);
	  swap(d[j-1],d[j]);
	  h=1;
	}else if(c[j-1]==c[j]){
	  if(0){
	  }else if(d[j-1]>d[j]){
	    swap(a[j-1],a[j]);
	    swap(b[j-1],b[j]);
	    swap(c[j-1],c[j]);
	    swap(d[j-1],d[j]);
	    h=1;
	  }else if(d[j-1]==d[j]){
	    if(a[j-1]>a[j]){
	      swap(a[j-1],a[j]);
	      swap(b[j-1],b[j]);
	      swap(c[j-1],c[j]);
	      swap(d[j-1],d[j]);
	      h=1;
	    }
	  }
	}
      }
    }
    z.clear();
    j=0;
    for(i=0;i<n;i++){
      if(0){
      }else if(j<10){
	if(z[b[i]]<3){
	  cout<<a[i]<<endl;
	  j++;
	  z[b[i]]++;
	}
      }else if(j<20){
	if(z[b[i]]<2){
	  cout<<a[i]<<endl;
	  j++;
	  z[b[i]]++;
	}
      }else if(j<26){
	if(z[b[i]]<1){
	  cout<<a[i]<<endl;
	  j++;
	  z[b[i]]++;
	}
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int aPos = sc.nextInt();
    int aSpeed = sc.nextInt();
    int bPos = sc.nextInt();
    int bSpeed = sc.nextInt();
    double time = sc.nextDouble();

    int diffSpeed = aSpeed - bSpeed; //if +, a is faster; if -, b is faster
    int diffPos = Math.abs( aPos - bPos );

    if( diffSpeed <= 0 ){ //if same speed or b is faster
      System.out.println("NO");
    }else{ //if a is faster
      if( (diffPos / time) <= diffSpeed ){ //if change in difference is greater than or equal to intial difference
        System.out.println("YES");
      }else{
        System.out.println("NO");
      }
    }

  }
}


Measured memory_bytes: 28956
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>

#define rep(i, n) for(ll (i) = 0;(i) < (n);(i)++)
#define mp(a, b) make_pair((a),(b))
#define bs(n) ((ull)1<<(ull)n)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

constexpr ll inf = INT64_MAX / 4;
constexpr double pi = asin(1) * 2;
constexpr ll mod = 1000000007;
constexpr double eps = 0.000000001;

bool ok(int n) {
    if (n % 2 == 0)return false;
    int c = 0;
    for (int i = 1; i <= n; i++)if (n % i == 0)c++;
    return c == 8;
}

int main() {
    int n, c = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        if (ok(i))c++;
    }
    cout << c << endl;
}

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

const int Max = 100005;
const int NIL = -1;

typedef struct{ int parent, left, right; }Node;
Node T[Max];
int D[Max];
int H[Max];
int D_CNT[Max] = {0};

void setDepth(int u, int d){
    D[u] = d;
    D_CNT[d]++;
    if (T[u].left != NIL) setDepth(T[u].left, d+1);
    if (T[u].right != NIL) setDepth(T[u].right, d+1);
}

int setHeight(int u){
    int h1 = 0, h2 = 0;
    if (T[u].left != NIL) h1 = setHeight(T[u].left) + 1;
    if (T[u].right != NIL) h2 = setHeight(T[u].right) + 1;
    return H[u] = max(h1 , h2);
}

void printNode(int u){
    int id = u;                     /* ID */
    int depth = D[u];               /* 深さ */
    int parent = T[u].parent;       /* 節点uの親 */
    int height = H[u];              /* 高さ */
    int sibling;                    /* 兄弟 */
    char type[15];                  /* 節点の種類 */
    int degree = 0;                 /* 子の数 */

    /* 兄弟の取得 */
    if (parent == NIL) sibling = NIL;
    else if (T[parent].left != u) sibling = T[parent].left;
    else sibling = T[parent].right;

    /* 節点の種類 */
    if (parent == NIL) strcpy(type, "root");
    else if (T[u].left == NIL && T[u].right == NIL) strcpy(type, "leaf");
    else strcpy(type, "internal node");

    /* 子の数 */
    if (T[u].left != NIL) degree++;
    if (T[u].right != NIL) degree++;

    char info[200];
    sprintf(info, "node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s", id, parent, sibling, degree, depth, height, type);
    cout << info << endl;
}

int main(void)
{
    int n;
    cin >> n;
    rep(i,n) {T[i].parent = T[i].left = T[i].right = NIL;}

    rep(i,n){
        int id, left, right;
        cin >> id >> left >> right;

        /* 左右の子のID設定 */
        T[id].left = left;
        T[id].right = right;

        /* 親の設定 */
        if (left != NIL) T[left].parent = id;
        if (right != NIL) T[right].parent = id;

    }
    /* 根のID取得 */
    int root_id;
    rep(i,n){
        if (T[i].parent == NIL) root_id = i;
    }

    /* 深さの設定 */
    setDepth(root_id, 0);
    /* 高さの設定 */
    setHeight(root_id);

    /* 表示 */
    rep(i,n) printNode(i);
    return 0;
}


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

int main()
{
    long long h, w;
    cin >> h >> w;

    if (h == 1 || w == 1)
        cout << 1 << endl;
    else
        cout << (h * w + 1) / 2 << endl;
}


Measured memory_bytes: 3532
// {{{
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

typedef long int i32;
typedef unsigned long int u32;
typedef long long int i64;
typedef unsigned long long int  u64;
typedef pair<i32, i32> PII;
typedef vector<i32> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<i32, i32> MPII;
typedef set<i32> SETI;
typedef multiset<i32> MSETI;
#define IN(x) cin >> x;
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define BTW(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define PF push_front
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
// }}}

const u32 MAX_N = 300;
u32 A[MAX_N][MAX_N];
int main() {
    int N;
    IN(N);
    REP(i, N)REP(j, N) {
        IN(A[i][j]);
    }
    REP(k, N)REP(i, N)REP(j, N) {
        if(A[i][j] > A[i][k] + A[k][j]) {
            cout << -1 << endl;
            return 0;
        }
    }
    u64 ans = 0;
    REP(i, N)FOR(j, i+1, N, 1){
        bool isNeighbor = true;
        REP(k,N) {
            if(i == k || j == k) {
                continue;
            }
            if(A[i][j] == A[i][k] + A[k][j]) {
                isNeighbor = false;
            }
        }
        if(isNeighbor) {
            ans += A[i][j];
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 896
#include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;

const int maxn = 1e5 + 10;
vector <int> g[maxn];
int num[maxn], num1[maxn];
int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= m; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		g[a].push_back(b);
		num[i] = a;
		num1[i] = b;
	}
	for(int i = 1; i <= n; i++){
		sort(g[i].begin(), g[i].end());
	}
	for(int i = 1; i <= m; i++){
		int y = num1[i], z = num[i];
		int x = upper_bound(g[z].begin(), g[z].end(), y) - g[z].begin();
		printf("%06d%06d\n", z, x);
	}
	return 0;
}//1212232123

Measured memory_bytes: 7808
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <fstream>

#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

ll GCD(ll a, ll b) {
    if(b==0) return a;
    else return GCD(b, a%b);
}

ll LCM(ll a, ll b) {
    return a/GCD(a,b)*b;
}

class AConnectionAndDisconnection {
public:
    ll COUNT(string s){
        ll cnt=0;
        for(int i=1; i<s.size(); ++i){
            if(s[i]==s[i-1]) {
                s[i]='1';
                ++cnt;
            }
        }
        return cnt;
    }
	void solve(std::istream& in, std::ostream& out) {
        string s;ll k;in >> s >> k;
        if(s==string(s.size(),s[0])) {
            out<<s.size()*k/2<<endl;
        } else {
            ll a = COUNT(s);
            ll d = COUNT(s+s)-COUNT(s);
            out<<a+(k-1)*d<<endl;
        }
	}
};


int main() {
	AConnectionAndDisconnection solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<functional>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef queue<P> Q;

int main(){
    LL K,A,B;
    cin>>K>>A>>B;
    LL ans=0;
   
    if(B-A > 2){
        LL temp=0;
        LL k=K;
        temp+=B;
        k-=A+1;
        if(k<0){
            cout<<K+1;
            return 0;
        }
        temp+=k/2*(B-A)+k%2;
        if(temp < K+1 ){
            cout<<K+1;
            return 0;
        }else{
            cout << temp;
            return 0;
        }
    }else{
        cout<<K+1;
        return 0;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mpr make_pair
#define fi first
#define se second
using ll=long long int;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

//LIS,最長増加部分列
template<typename T>
T LIS (T N){
	T INF = numeric_limits<T>::max();
	vector<T>a(N);
	for (long long i = 0; i < N;++i){
		cin >> a[i];
		a[i]=-a[i];
	}
	vector<T>dp(N, INF);//最後がaiの最長増加部分列の長さ
	for (long long i = 0; i < N;++i) {
		*upper_bound(dp.begin(), dp.end(), a[i]) = a[i];
	}
	return lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
}

int main(){
	ll n;
	cin>>n;
	ll cnt=1;
	vector<ll>a(n);
	ll maxv=0;
	cout<<LIS<ll>(n)<<endl;
	
	return 0;
}




Measured memory_bytes: 2560
#include <iostream>
using namespace std;
bool BinarySearch(int a[],int n,int key)
{
    int l=0,r=n,mid;
    while(l<r)
    {
        mid = (l+r)/2;
        if(a[mid]>key)
            r = mid;
        else if(a[mid]<key)
            l = mid+1;
        else
            return true;
    }
    return false;
}
int main()
{
    int s[100000];
    int n,q,i,j,c=0,t;
    cin>>n;
    for(i=0;i<n;i++)
        cin>>s[i];
    cin>>q;
    for(i=0;i<q;i++)
    {
        cin>>t;
        if(BinarySearch(s,n,t))
            c++;
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 3356
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    string s;
    cin >> s;
    int ans = 0, cnt = 0, cntt = 0;
    bool f = false;
    bool g = false;
    for (int i = 0; i < s.size() - 1; i++)
    {
        if (s[i] == 'A')
        {
            cnt++;
            f = true;
        }
        else if (s[i] == 'B' && s[i + 1] == 'C' && f)
        {
            ans += cnt;
            i++;
        }
        else
        {
            f = false;
            cnt = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 720
#include<iostream>

using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	int x,y;
	cin>>x>>y;

	for(int i=0;i<x+1;i++)
	{
		int a=i;
		int b=x-a;
		if(2*a+4*b==y)
		{
			cout<<"Yes";
			return 0;
		}
	}

	cout<<"No";	



	return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>

int main(){

  int r,c,s;
  int a[101][101];
  int i,k;

  scanf("%d%d",&r,&c);

  for(i=0; i<r; ++i){
    s=0;
    for(k=0; k<c; ++k){
      scanf("%d",&a[i][k]);
      s+=a[i][k];
      if(k==c-1){
	a[i][k+1]=s;
      }
    }
  }

  for(i=0; i<c+1; ++i){
    s=0;
    for(k=0; k<r; ++k){
      s+=a[k][i];
      if(k==r-1){
	a[k+1][i]=s;
      }
    }
  }

  for(i=0; i<r+1; ++i){
    for(k=0; k<c+1; ++k){
      printf("%d",a[i][k]);
      if(k!=c){
	printf(" ");
      }
    }
    printf("\n");
  }


  return 0;
}



Measured memory_bytes: 2696
n = int(input())
s = []
for _ in range(n):
    s.append(int(input()))

if all((i % 10 == 0 for i in s)):
    print(0)
else:
    s.sort()
    ans = sum(s)
    if ans % 10 != 0:
        print(ans)
    else:
        for i in s:
            if i % 10 != 0:
                print(ans - i)
                exit()


Measured memory_bytes: 9120
#include <bits/stdc++.h>
 using namespace std;
int main(){
  long n,m,j,ans,c;
  long long k,s;
  cin >> n;
  n %= 1000;
  if (n != 0)
    cout << (1000-n) << endl;
  else
  	cout << 0 << endl;
}

Measured memory_bytes: 3592