akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
//#define mod 998244353

int N,M;
int A[100005];
signed main(){
    scanf("%lld",&N);
    int ans=1;
    rep(i,N){
        scanf("%lld",&A[i]);
        if(A[i]==0){
            printf("0\n");
            return 0;
        }
    }
    rep(i,N){
        if(ans>(int)1000000000000000000/A[i]){
            ans=-1;
            break;
        }
        ans*=A[i];
    }
    if(ans<=(int)1000000000000000000){
        printf("%lld\n",ans);
    }else{
        printf("-1\n");
    }
    return 0;
}


Measured memory_bytes: 2516
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
using namespace std;


int main() {
	long long int a=0,b=0,c=0,memo=1;
	string stra, strb, strc;
	cin >> stra >> strb >> strc;
	while (1) {
		if (memo == 1) {
			if (a == stra.length()) { cout << "A"; return 0; }
			a++;
			memo=stra[a-1]-'a'+1;
		}

		if (memo == 2) {
			if (b == strb.length()) { cout << "B"; return 0; }
			b++;
			memo = strb[b-1] - 'a' + 1;
		}

		if (memo == 3) {
			if (c == strc.length()) { cout << "C"; return 0; }
			c++;
			memo = strc[c-1] - 'a' + 1;
		}

		if (memo != 1 && memo != 2 && memo != 3) {
			cout << "ERROR!!"; return 0;
		}
	}
}


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

int n, pos;
vector<int> pre, in, post;

void rec(int l, int r){
  if(l >= r) return;
  int root = pre[pos++];
  int m = distance(in.begin(), find(in.begin(), in.end(), root));
  rec(l, m);
  rec(m + 1, r);
  post.push_back(root);
}

void solve(){
  pos = 0;
  rec(0, pre.size());
  for(int i = 0; i < n; i++){
    if(i) cout << " ";
    cout << post[i];
  }
  cout << endl;
}

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

  for(int i = 0; i < n; i++){
    cin >> k;
    pre.push_back(k);
  }

  for(int i = 0; i < n; i++){
    cin >> k;
    in.push_back(k);
  }

  solve();
  return 0;
}

Measured memory_bytes: 1220
#include<cctype>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define REP(a,b,c) for(int a=b;a<=c;++a)
#define RREP(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define N 100005
using namespace std;

template<class T> inline
void read(T &x) {
	x=0; char c=getchar(); while(!isdigit(c)) c=getchar();
	while(isdigit(c)) {x=x*10+c-'0'; c=getchar();}
}


LL x[N],y[N],z[N],p[N];
int n,k,j;
LL a,b;

inline bool cmp(int a,int b) {return x[a]<x[b]||x[a]==x[b]&&a<b;}

int main() {
	scanf("%d",&n); 
	REP(i,1,n) scanf("%lld",&x[i]),y[i]=i;
	sort(y+1,y+n+1,cmp);
	p[k=1]=1; j=n; a=0; b=0;
	REP(i,2,n) if(x[p[k]]<x[i]) p[++k]=i;
	while(k) {
		z[p[k]]=a*(b-x[p[k-1]]); b=x[p[k-1]];
		while(j&&x[y[j]]>x[p[k-1]]) {
			z[p[k]]+=x[y[j]]-x[p[k-1]];
			++a; --j;
		} --k;
	}
	REP(i,1,n) printf("%lld\n",z[i]);
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define il inline
#define ri register int
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define mid ((l+r)>>1)
#define MAXN 
#define MAXM
#define mod
#define inf (1<<25)
#define eps (1e-6)
#define alpha 0.75
#define rep(i, x, y) for(ri i = x; i <= y; ++i)
#define repd(i, x, y) for(ri i = x; i >= y; --i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, int> pli;
typedef pair <int, ll> pil;
typedef pair <ll, ll> pll;
template <typename T> inline bool chkmin(T &x, T y) {return x > y ? x = y, 1 : 0;}
template <typename T> inline bool chkmax(T &x, T y) {return x < y ? x = y, 1 : 0;}
il void read(int &x) {
	char ch = getchar(); int f = 1; x = 0;
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = x*10+ch-'0', ch = getchar();
	x *= f;
}
int k, a, b;
ll ans;
int main() {
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	read(k), read(a), read(b);
	if(b-a <= 2 || k <= a-1) return cout<<(k+1), 0;
	else {
		ans = a;
		ans += 1ll * (k-a+1)/2 * (b-a);
		ans += (k-a+1)&1;
		cout<<ans;
	}
	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int v[100];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;
  cin >> n >> m;
  int a,b;
  rep(i,m){
    cin >> a >> b;
    v[a]++;
    v[b]++;
  }
  rep(i,n){
    cout << v[i+1] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
//mod
template <typename T> class ModUtil {
public:
  ModUtil(int N, T mod)
      : N(N), mod(mod), inv(N + 1), fact(N + 1), inv_fact(N + 1) {
    calc();
  }
  //
  T get_inv(int n) { return inv[n]; }
  T get_fact(int n) { return fact[n]; }
  T get_inv_fact(int n) { return inv_fact[n]; }
  T get_P(int n, int k) {
    if (n < k)
      return 0;
    return fact[n] * inv_fact[n - k] % mod;
  }
  T get_C(int n, int k) {
    if (n < k)
      return 0;
    return get_P(n, k) * inv_fact[k] % mod;
  }

private:
  vector<T> inv, fact, inv_fact;
  int N;
  T mod;
  // O(N)
  void calc() {
    // cout << N << " " << mod << endl;
    inv[1] = 1;
    for (int i = 2; i <= N; i++) {
      inv[i] = inv[mod % i] * (mod - mod / i) % mod;
    }
    fact[0] = 1;
    for (int i = 1; i <= N; i++) {
      fact[i] = i * fact[i - 1] % mod;
    }
    inv_fact[0] = 1;
    for (int i = 1; i <= N; i++) {
      inv_fact[i] = inv[i] * inv_fact[i - 1] % mod;
      // cout << i << " " << inv_fact[i] << endl;
    }
  }
};

int N, A, B, C, D;
const int MAX_N = 1010;
ModUtil<ll> mod_util(MAX_N, MOD);

ll dp[MAX_N][MAX_N];
ll memo(int n, int a) {
  if (n == 0) {
    return 1;
  }
  if (a > B){
    return 0;
  }
  ll &res = dp[n][a];
  if (res >= 0) {
    return res;
  }
  res = 0;
  res += memo(n, a + 1);
  ll f = 1;
  int cnt = 0;
  while (true){
    if (n - a < 0)
      break;
    f *= mod_util.get_C(n, a);
    f %= MOD;
    n -= a;
    cnt++;
    if (cnt > D)break;
    if (cnt >= C){
      res += memo(n, a + 1) * f % MOD * mod_util.get_inv_fact(cnt);
      res %= MOD;
    }
  }
  return res;
}

int main() {
  cin >> N >> A >> B >> C >> D;
  memset(dp, -1, sizeof(dp));
  cout << memo(N, A) << endl;

  return 0;
}


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

int main() {
  long long H, W;
  cin >> H >> W;
  long long table = H * W;
  if (H == 1 || W == 1) cout << 1;
  else {
    if (table % 2 == 0) cout << table / 2;
    else cout << (table + 1) / 2;
  }
}


Measured memory_bytes: 3576
// I am Nothing, You Are Nothing!
// Krishna is Everything ...
// Jai Shree Krishna

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 5, mod = 1e9 + 7;


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	cin >> n;
	vector<int> a(n + 1), dp(n + 1);

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

	dp[1] = 0;
	dp[2] = abs(a[2] - a[1]);

	for (int stone = 3; stone <= n; stone++) {
		int op1 = dp[stone - 1] + abs(a[stone] - a[stone - 1]);
		int op2 = dp[stone - 2] + abs(a[stone] - a[stone - 2]);
		dp[stone] = min(op1, op2);
	}
	cout << dp[n] << endl;

	return 0;
}


Measured memory_bytes: 4672
#include <iostream>

using namespace std;

int main()
{
    long long N,sum=100000000000000;
    int i;
    cin>>N;
    for(i=1; i<=N/i; i++)
        if(N%i==0)
        {
            if(i+(N/i)-2<sum)
                sum=i+(N/i)-2;
        }
    cout<<sum<<endl;
    return 0;
}


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

int main()
{
    int N, K, R, S, P;
    cin >> N >> K >> R >> S >> P;
    string T;
    cin >> T;
    map<char, int> score = {
        {'r', P},
        {'s', R},
        {'p', S},
    };
    vector<char> dp(K, 0);
    int res = 0;
    for(int i=0;i<N;i++){
        if(dp[i%K] != T[i]){
            res += score[T[i]];
            dp[i%K] = T[i];
        }else{
            dp[i%K] = 0;
        }
    }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
typedef long long ll;

int main(void) {
  int i, j, k, n, a, b, c, max, maxn = 0, ans;
  scanf("%d%d%d%d", &a, &b, &c, &k);
  max = a;
  if(max < b) max = b, maxn = 1;
  if(max < c) max = c, maxn = 2;
  if(!maxn) ans = b + c + a * (int)pow(2, k);
  else if(maxn == 1) ans = a + c + b * (int)pow(2, k);
  else ans = b + a + c * (int)pow(2, k);
  printf("%d", ans);
  return 0;
}

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

bool isPalindrome(string S) {
    string T = S;
    reverse(S.begin(), S.end());
    return S == T;
}

int main() {
    string S;
    cin >> S;
    bool ans = isPalindrome(S) && isPalindrome(S.substr(0, S.size() / 2));
    puts(ans ? "Yes" : "No");
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

ll en[9];

ll input(){
	string in;
	cin >> in;
	int n=in.size();
	ll res=0;
	rep(i,n){
		res*=16;
		if(isdigit(in[i]))
			res+=(in[i]-'0');
		else
			res+=(in[i]-'a'+10);
	}
	return res;
}


int main(void){
	int n;
	cin >> n;
	rep(loop,n){
		rep(i,9) en[i]=input();
		ll k=0;
		rep(i,32){
			ll mask=(1LL<<(i+1))-1LL;
			ll sum=0;
			rep(j,8) sum+=((en[j]^k)&mask);
			if(((en[8]^k)&mask)!=(sum&mask))
				k|=(1LL<<i);
		}
		cout << hex << k << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  ll x;
  cin >> x;

  int flag = 0;
  REP(i,130){
    REP(j,i+1){
      ll y = i*i*i*i*i;
      ll z = j*j*j*j*j;

      if(y-z==x){
        cout << i << " " << j;
        flag = 1;
        break;
      }else if(y+z==x){
        cout << i << " " << (-1)*j;
        flag = 1;
        break;
      }
    }
    if(flag == 1){
      break;
    }
  }
  cout << endl;
}


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

int main() {
  int n, nl, nr;
  cin >> n;
  nl = n / 10;
  nr = n - (n / 1000) * 1000;
  cout << ((nl % 111 == 0 || nr % 111 == 0) ? "Yes" : "No") << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector <int> v(n);
  int v_max = 0;
  int ans = 0;
  for (int i = 0; i < n; i++){
    cin >> v.at(i);
    if (v.at(i) >= v_max){
      v_max = v.at(i);
      ans += 1;
    }
  }
  cout << ans << endl;
}
 

Measured memory_bytes: 256
from fractions import gcd
from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7


def main():
    n = int(input())
    s = input()
    black = s.count("#")
    white = len(s) - black
    ans = min(black, white)
    
    b,w = 0,0
    for i in range(len(s)):
        if s[i] == "#":
            b += 1
        else:
            w += 1
        
        ans = min(ans, b + (white - w))
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5856
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

// 数値を受け取り素因数分解の結果を返す
// 計算量はおおよそO(√N)
// 形式：12 -> [[2, 2], [3, 1]]
map<int, int> factorization(ll num)
{
    map<int, int> mp;

    int tmp = num;
    for (int i = 2; i * i <= num; i++)
    {
        while (tmp % i == 0)
        {
            mp[i]++;
            tmp /= i;
        }
    }
    if (tmp != 1)
    {
        mp[tmp]++;
    }

    return mp;
}

ll comb(int n, int r)
{
    if (n < r)
        return 0;
    ll bunshi = 1;
    ll bunbo = 1;
    for (int i = 1; i <= r; ++i)
    {
        bunshi *= (n - i + 1);
        bunbo *= i;
    }
    return bunshi / bunbo;
}

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

    vector<int> cnts(n + 1, 1);
    int three = 0;
    int five = 0;
    int fifty = 0;
    int twentyFive = 0;
    int seventyFive = 0;

    for (int i = 2; i <= n; ++i)
    {
        auto fac = factorization(i);
        for (auto f : fac)
        {
            if (cnts[f.first] < 3 && cnts[f.first] + f.second >= 3)
                ++three;
            if (cnts[f.first] < 5 && cnts[f.first] + f.second >= 5)
                ++five;
            if (cnts[f.first] < 15 && cnts[f.first] + f.second >= 15)
                ++fifty;
            if (cnts[f.first] < 25 && cnts[f.first] + f.second >= 25)
                ++twentyFive;
            if (cnts[f.first] < 75 && cnts[f.first] + f.second >= 75)
                ++seventyFive;
            cnts[f.first] += f.second;
        }
    }
    int ans = 0;
    // 5 * 5 * 3
    ans += comb(five, 2) * (three - 2);
    ans += fifty * (five - 1);
    ans += twentyFive * (three - 1);
    ans += seventyFive;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3616
// author:  Harsh Nema
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 10000000000000;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;

//ll modexp(ll x, ll y, ll p)
//{
//	ll res = 1;
//	x = x % p;
//	while (y > 0)
//	{
//		if (y & 1)
//			res = (res * x) % p;
//		y = y >> 1;
//		x = (x * x) % p;
//	}
//	return res;
//}

//ll mulmod(ll a, ll b,ll m)
//{
//	return ((a % m) * (b % m)) % m;
// }

// ll sub_mod(ll a, ll b, ll m){
//    if (a >= b)
//        return a - b;
//    else
//        return m - b + a;
// }

// ll add_mod(ll a, ll b){
//    if (0 == b)
//        return a;

//    b = mod - b;
//    if (a >= b)
//        return a - b;
//    else
//        return mod - b + a;
// }

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

// ll modInv(ll a)
// {
//     ll g = gcd(a, mod);
//     if (g != 1)
//         return -1;
//     else
//         return modexp(a, mod-2, mod);
// }

int main()
{
	fastio;
    ll a=0,b=0;
    cin>>a>>b;
    if(a<=9 && b<=9)
        cout<<a*b;
    else
        cout<<"-1";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll  long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define per(i,a,b)  for(ll i=b-1;i>=a;i--)
#define pb push_back
#define Max(x,y,z) max(x,max(y,z))
#define f first
#define s second
#define lbd lower_bound
#define sz(x)       (ll)x.size()
#define pi 3.1415926536
#define mod 1000000007
#define MOD 998244353
using namespace std;
/*bool isprime(ll x)
{
    for(ll i=2;(i*i)<=x;i++)
    {
        if(x%i==0) return 0;
    }
    return 1;
}
ll power(ll x,ll n)
{
    ll res=1;
    while(n>0){
    if(n%2) res=(res*x)%mod;
    x=(x*x)%mod;
    n=n/2;}
    return res;
}*/
void solve()
{
            ll n,m,k,l=0,r=0,z,sum1=0,h,res=0,a,b,c,d,x=0,y=0;
            cin>>n;
            string s;
            cin>>s;
            if(n<3200) cout<<"red";
            else cout<<s;

            }

        int main()
        {
            speed_up
            ll t=1;
            //cin>>t;
            while(t--)
                solve();
        }


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
      cout << "Bad" << '\n';
    } else {
      cout << "Good" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
#include<iomanip>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef vector<string> vstring;
typedef vector<vector<string>> vvstring;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<long double> vdouble;
typedef vector<vector<long double>> vvdouble;
typedef vector<vector<vector<long double>>> vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define LLONG_MAX 9223372036854775807
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define DIVIDER 1000000007


//
// struct Node{
//   vint children;
//   ll index;
//   ll prop;
// };
// struct edge{ll to; ll cost;};



int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0,};

// ll X,Y,Z,K;
// ll pmax = 30000000000;
// vint A,B,C;




// struct UnionFind {
//     vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
//
//     UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
//         for(int i = 0; i < N; i++) par[i] = i;
//     }
//
//     int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
//         if (par[x] == x) return x;
//         return par[x] = root(par[x]);
//     }
//
//     void unite(int x, int y) { // xとyの木を併合
//         int rx = root(x); //xの根をrx
//         int ry = root(y); //yの根をry
//         if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
//         par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
//     }
//
//     bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };
//
// vint divisor(ll n){ // nの約数
//   vint ret;
//   for(ll i=1;i*i<=n;i++){
//     if(n%i == 0){
//       ret.pb(i);
//       if(i*i!=n) ret.pb(n/i);
//     }
//   }
//   vsort(ret);
//   return ret;
// }
//
// ll get_digits_num(ll n){
//   ll ret=0;
//   while(n){
//     n/=10;
//     ret++;
//   }
//   return ret;
// }



int main() {
  cout<<fixed<<setprecision(10);

  ll N;cin>>N;
  vint C(N-1), S(N-1), F(N-1);

  rep(i,N-1){
    cin>>C[i]>>S[i]>>F[i];
  }

  vint ans(N,0);

  rep(i,N-1){
    ll t=0;
    for(ll j=i;j<N-1;j++){
      if(S[j]-ans[i]>=0){
        ans[i]=S[j];
      }else{
        if((ans[i]-S[j])%F[j]!=0){
          ans[i]+=(F[j]-(ans[i]-S[j])%F[j]);
        }
      }
      ans[i]+=C[j];
    }
  }

  for(auto e:ans)cout<<e<<endl;

}

















//


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

def main():
    h, w, n = map(int, input().split())
    ab = []
    for i in range(n):
        a, b = map(int, input().split())
        ab.append((a, b))

    di = {}
    for a, b in ab:
        for dx in [-1, 0, 1]:
            for dy in [-1, 0, 1]:
                x = b + dx
                y = a + dy
                if (2 <= x <= w - 1) and (2 <= y <= h - 1):
                    p = (x, y)
                    if p in di:
                        di[p] += 1
                    else:
                        di[p] = 1

    cnt = [0 for j in range(10)]
    for p in di:
        cnt[di[p]] += 1
    cnt[0] = (h - 2) * (w - 2) - sum(cnt[1:])

    for j in range(10):
        print(cnt[j])

main()


Measured memory_bytes: 179984
#include <bits/stdc++.h>
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;
using namespace std;

int main(){
    int N;
    ll ai;
    set<ll> A;
    cin >> N;
    REP(int,i,0,N){
        cin >> ai;
        A.insert(ai);
    }

    if(A.size()==N) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

ll A,B;
ll ans = 0LL;

ll f(ll a){
  ll u = a%4;
  if(u==0){
    return 0LL;
  }else if(u==1){
    return a-1LL;
  }else if(u==2){
    return 1LL;
  }else return a;
}

int main(){
  cin >> A >> B;
  cout << (f(A) ^ f(B+1)) << endl;

  return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    lst = [int(_) for _ in input().split()]
    last = lst[0]
    A = [last]
    for i in range(1, N):
        if lst[i] == last: continue
        last = lst[i]
        A.append(lst[i])
    left = right = output = 0
    while left < len(A):
        if left == len(A)-1:
            output += 1
            break
        if A[left+1] - A[left] > 0:
            while right < len(A)-1 and A[right] < A[right+1]:
                right += 1
        elif A[left+1] - A[left] < 0:
            while right < len(A)-1 and A[right] > A[right+1]:
                right += 1
        output += 1
        left = right + 1
        right = left
    print(output)
    return

if __name__ == '__main__':
    main()


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

int main()
{
	long long n,a,b;
	cin>>n>>a>>b;
	
	long long s=n/(a+b)*a,c=n%(a+b);
	if(c>=a)
		cout<<s+a;
	else
		cout<<s+c;
	return 0;
}

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

ll N, X;

int main(void) {
  cin >> N >> X;

  if(X == 1 || X == 2 * N - 1) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;

    vector<ll> a(2 * N - 1);
    REP(i, 0, 2 * N - 1) a[i] = i + 1;
    ll d = X - N;
    REP(i, 0, 2 * N - 1) cout << a[(i + d + 2 * N - 1) % (2 * N - 1)] << endl;
  }
}


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

int main(){
    int N, T;
    cin >> N >> T;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    
    int dist = 0;
    int min = A[0];
    for (int i = 1; i < N; i++) {
        if (A[i] - min > dist) dist = A[i] - min;
        if (A[i] < min) min = A[i];
    }
    
    min = A[0];
    int cnt = 0;
    for (int i = 1; i < N; i++) {
        if (A[i] - min == dist) cnt++;
        if (A[i] < min) min = A[i];
    }
    cout << cnt << endl;
}

Measured memory_bytes: 640
#include <stdio.h>

#define M_MAX         10000
#define N_MAX         1000
#define r_MAX         1000
#define q_MAX         50
#define DATASET_MAX   10
#define TS_MIN        540
#define TE_MAX        1260
#define USETIME_MAX   TE_MAX-TS_MIN

struct LogInfo{
    int PCNum;
    int LogInTime;
    int LogOutTime;
};

int LogInCnt[M_MAX];
struct LogInfo LogInfoData[M_MAX][r_MAX];
int UsePCTime[DATASET_MAX];

void VarInit( void ){
    int i;
    int j;
    
    for( i=0; i<M_MAX; i++ ){
        LogInCnt[i] = 0;
        for( j=0; j<r_MAX; j++ ){
            LogInfoData[i][j].PCNum = 0;
            LogInfoData[i][j].LogInTime = 0;
            LogInfoData[i][j].LogOutTime = 0;
        }
    }
}


void RecLogInInfo( int t, int n, int m ){
    LogInfoData[m][LogInCnt[m]].PCNum = n;
    LogInfoData[m][LogInCnt[m]].LogInTime = t;
    LogInCnt[m]++;
}

void RecLogOutInfo( int t, int n, int m ){
    int i;
    
    for( i=0; i<LogInCnt[m]; i++ ){
        if( (LogInfoData[m][i].PCNum == n) && (LogInfoData[m][i].LogOutTime == 0)){
            LogInfoData[m][i].LogOutTime = t;
        }
    }
}

int CalcUsePCTime( int ts, int te, int m ){
    int i,j,t1,t2,Time;
    int Work[USETIME_MAX+1];
    Time = 0;
    
    for( i=0; i<USETIME_MAX+1; i++){
        Work[i] = 0;
    }
    
    for( i=0; i<LogInCnt[m]; i++ ){
        t1 = LogInfoData[m][i].LogInTime-TS_MIN;
        t2 = LogInfoData[m][i].LogOutTime-TS_MIN;
        for( j=t1; j<t2; j++){
            Work[j] = 1;
        }
    }
    
    for( i=ts; i<te; i++){
        if(Work[i-TS_MIN] == 1){
        Time++;
        }
    }
    
    return Time;
}


int main( void ){
    int i,N,M,r,q,t,n,m,s,ts,te;
    int qNum;
    int UseTime;
    
    qNum = 0;
    for( i=0; i<DATASET_MAX; i++ ){
        UsePCTime[i] = 0;
    }
    while( 1 ){
        scanf( " %d %d", &N, &M );
        if( N == 0 ){
            break;
        }
        VarInit();
        scanf( " %d", &r );
        for( i=0; i<r; i++ ){
            scanf( " %d %d %d %d", &t, &n, &m, &s );
            if( s == 1 ){
                RecLogInInfo( t, n, m );
            }else{
                RecLogOutInfo( t, n, m );
            }
        }
        
        scanf( " %d", &q );
        for( i=0; i<q; i++ ){
            scanf( " %d %d %d", &ts, &te, &m );
            UseTime = CalcUsePCTime( ts, te, m );
            printf("%d\n",UseTime);
        }
    }
}




Measured memory_bytes: 118912
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_f) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n=gi
t=n.times.map{gi}
g=t[0]
t.each do |tt|
  g=g.lcm tt
end
puts g

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

ll n;
vector<ll> p(5);
const int M = 5;
vector<ll> q(6,0); 

ll maxll(ll x,ll y){
    if(x>y) return x;
    else return y;
}
ll minll(ll x, ll y){
    if(x>y) return y;
    else return x;
}

ll ceil(ll x,ll y){
    if(x%y==0) return x/y;
    else return x/y + 1;
}

int main(){
    cin >> n;
    ll min = 10e15 + 1;
    for(int i=0;i<M;i++){
        cin >> p[i];
        min = minll(min,p[i]);
    }

    cout << ceil(n , min) + 4 << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
#include <queue>
using namespace std;


int main(){
    long long n, m, c = 0, sum = 0;
    cin >> n >> m;
    vector<long long> a(n);
    for(int i = 0; i < n; ++i){
      cin >> a[i];
      sum += a[i];
    }

    for(int i = 0; i < n; ++i){
        if(a[i] >= (double)sum / (4 * m)) c++;
    }
    cout << (c >= m?"Yes":"No");
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main(){
    string str;
    cin >> str;
    int q, a, b;
    string p, o, tmp, ttmp;
    cin >> q;
    for(int i=0;i<q;i++){
        cin >> o;
        if(o=="replace"){
            cin >> a >> b >> p;
            str = str.replace(a, p.size(), p);
        }else{
            cin >> a >> b;
            if(o=="reverse"){
                tmp = str.substr(a, b-a+1);
                ttmp = "";
                for(int j=0;j<b-a+1;j++){
                    ttmp += tmp[b-a-j];
                }
                str = str.replace(a, b-a+1, ttmp);
            }else if(o=="print"){
                cout << str.substr(a, b-a+1) << endl;
            }
        }
    }
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a,b,c[100001],d,n,m,x,y,k,h,w,sum,mi,ma,ans,s,t,l,r,res,tmp;
bool flag;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dx8[8]={1,1,0,-1,-1,-1,0,1},dy8[8]={0,1,1,1,0,-1,-1,-1};
char cha;
string st;
typedef map<int, int> imap;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pair<int,int> > VP;

int main(){
    cin>>n;
    imap mp;
    rep(i,n){
        cin>>tmp;
        auto itr = mp.find(tmp);
        if(itr == mp.end())mp[tmp]=1;
        else mp[tmp]=mp[tmp]+1;
    }
    ll key,value;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        key=itr->first;
        value=itr->second;
        if(key<=value)sum+=(value-key);
        else sum+=value;
    }
    p(sum);
    return 0;
}


Measured memory_bytes: 4736
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n; cin >> n;
  vector<ll> a(n), b(n); cin >> a >> b;
  ll suma = 0, sumb = 0;
  rep(i, n) suma += a[i], sumb += b[i];
  if (sumb > suma) {
    cout << -1 << endl;
    return;
  }
  ll ans = 0, need = 0;
  vector<ll> v;
  rep(i, n) {
    if (a[i] < b[i]) {
      ++ans;
      need += b[i] - a[i];
    }
    else {
      v.pb(a[i] - b[i]);
    }
  }
  sort(all(v), greater<ll>());
  ll sum = 0, pos = 0;
  while (sum < need) {
    assert(pos < v.size());
    sum += v[pos];
    ++pos;
    ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 2932
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        String S = sc.next();
        String N = "";
        int count = 0;

        if (S.contains("ABC")) {
            N = S.replace("ABC", "1");
        }

        for (char cha : N.toCharArray()) {
            if (cha == '1') {
                count += 1;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21972
n=int(input())
l=[input() for i in range(n)]
import collections
c=collections.Counter(l)
ll=c.most_common()
tmp=ll[0][1]
ans=[]
for i,j in ll:
    if tmp==j:
        ans.append(i)
    else:
        break
ans.sort()
print('\n'.join(map(str,ans)))


Measured memory_bytes: 50308
<?php
  fscanf(STDIN,"%s",$s);
  fscanf(STDIN,"%s",$t);
  $scnt=strlen($s);
  $tcnt=strlen($t);
  $place_cnt_box=[];

  for($i=0;$i<$scnt-$tcnt+1;$i++){
    $place_cnt=0;
    for($h=0;$h<$tcnt;$h++){
      if($s[$i+$h]==$t[$h]) $place_cnt++;
    }
    $place_cnt_box[]=$place_cnt;
  }

  echo $tcnt-max($place_cnt_box)."\n";

Measured memory_bytes: 16200
/* tempate
 *
 *
 */

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b; cin >> n >> a >> b;
    cout << (n * a < b ? n * a : b);
    cout << endl;
    return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

ll A,B,P;
ll dp[100002];

ll loc(int num){
	return num-A;
}

ll get_digit_max(ll num){

	ll ret = 10;

	while(ret <= num)ret *= 10;

	return ret-1;
}

ll uniformity[270000],partial[270000];
ll N;

void init(ll first_N){
	while(N < first_N)N *= 2;
}

void add_and_updateNodes(ll left,ll right,ll value,ll node_id,ll node_left,ll node_right){

	if(right < node_left || left > node_right)return;
	else if(left <= node_left && right >= node_right){
		uniformity[node_id] += value;
		uniformity[node_id] %= P;
	}else{
		partial[node_id] += (min(right,node_right)-max(left,node_left)+1)*value;
		add_and_updateNodes(left,right,value,2*node_id+1,node_left,(node_left+node_right)/2);
		add_and_updateNodes(left,right,value,2*node_id+2,(node_left+node_right)/2+1,node_right);
	}
}

ll getSum(ll left,ll right,ll node_id,ll node_left,ll node_right){
	if(right < node_left || left > node_right)return 0;
	else if(left <= node_left && right >= node_right){
		return ((node_right-node_left+1)*uniformity[node_id]+partial[node_id])%P;
	}else{
		ll sum = (min(right,node_right)-max(left,node_left)+1)*uniformity[node_id];
		sum += getSum(left,right,2*node_id+1,node_left,(node_left+node_right)/2);
		sum += getSum(left,right,2*node_id+2,(node_left+node_right)/2+1,node_right);
		return sum%P;
	}
}


void func(){

	N = 1;

	ll first_N = B-A+1;

	init(first_N);

	for(int i = 0; i <= 2*N-2; i++){
		uniformity[i] = 0;
		partial[i] = 0;
	}

	add_and_updateNodes(loc(A),loc(B),1,0,0,N-1);

	ll left,right,add;
	bool FLG;


	for(int i = A; i <= B; i++){

		left = i;
		FLG = true;

		add = getSum(loc(i),loc(i),0,0,N-1);

		while(FLG){
			right = get_digit_max(left);
			if(right >= B){
				right = B;
				FLG = false;
			}

			if(left == i){

				if(left == right){
					//Do nothing
				}else{
					add_and_updateNodes(loc(left+1),loc(right),add,0,0,N-1);
				}
			}else{
				add_and_updateNodes(loc(left),loc(right),add,0,0,N-1);
			}
			left *= 10;
			if(left > B)break;
		}
	}

	ll ans = getSum(loc(A),loc(B),0,0,N-1);

	printf("%lld\n",ans%P);
}

int main(){

	while(true){
		scanf("%lld %lld %lld",&A,&B,&P);
		if(A == 0 && B == 0 && P == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 7256
//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++){cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++){for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>vector<vector<T>>vec(ll x, ll y, T w){vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<typename T1, typename T2>ostream &operator<<(ostream &os, const pair<T1, T2>&p){return os << p.first << " " << p.second;}
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v){for(auto &z:v)os << z << " ";cout<<"|"; return os;}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll a,b,c,d;cin>>a>>b>>c>>d;
  vector<ll>x,y;
  x.PB(a);
  x.PB(b);
  if(a<=0&&b>=0)x.PB(0);
  y.PB(c);
  y.PB(d);
  if(c<=0&&d>=0)x.PB(0);
  res=-2*INF;
  for(auto z:x)for(auto zz:y)chmax(res,z*zz);
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
int main() {
    int ans = 1e7, N;
    string s;
    cin >> s;
    N = s.size();
    reverse(WHOLE(s));
    for(char c = 'a'; c <= 'z'; c++) {
        int j = -1;
        int k = -1;
        for (int i = 0; i < N; i++) {
            if(s[i] == c) j = i;
            k = max(k, i - j);
        }
        ans = min(ans, k);
    }
    cout << ans << endl;
    return 0;
}

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

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

    int count_minus = 0;
    int a[n];
    long total = 0;
    int min = 1e9;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] < 0) {
            count_minus++;
        }
        total += abs(a[i]);
        min = std::min(min, abs(a[i]));
    }

    if (count_minus % 2 == 0) {
        cout << total << endl;
        return 0;
    }

    cout << total - min * 2 << endl;

    return 0;
}


Measured memory_bytes: 640
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt64(scanner)
	fmt.Fprintln(writer, (n-1)*n/2)
	writer.Flush()
}


Measured memory_bytes: 640