akhauriyash/Code-Regression huggingface dataset:
// Problem : C - Skill Up
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_c
// 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/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    //int T; cin >> T;
    //while(T--) 
 	//{
  //    
  //  }
  	int N,M,X;
  	cin>>N>>M>>X;
  	vi v[N];
  	F0R(x,N)
  	{
  		F0R(y,M+1)
  		{
  			int nb;
  			cin>>nb;
  			v[x].pb(nb);
  		}
  	} 
  	ll ans=LLONG_MAX;
	for(ll x=0;x<1<<N;x++)
	{
		vi val(N);
		ll cpy=x,res=0;
		int sht=0;
		while(cpy>>sht)
		{
			if((cpy>>sht)&1)
			{
				res+=v[sht][0];
				F0R(y,M)
				{
					val[y]+=v[sht][y+1];
				}
			}
			sht++;
		}
		F0R(y,M)
		{
			if(val[y]<X)
				goto aa;
		}
		ans=min(ans,res);
		aa:;
	}
	if(ans==LLONG_MAX)ans=-1;
	cout<<ans<<endl;
	
	return 0;
}
 



Measured memory_bytes: 3664
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define lop(i, n) for(i=0; i<n; i++)

int main()
{
	int n, i;
	scanf("%d", &n);
	char s[n];
	scanf("%s", s);
	
	int cnt=n;
	for(i=1; i<n; i++){
		if(s[i-1]==s[i]){
			cnt--;
		}
		else{continue; }
	}
	
	printf("%d", cnt);
	
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int a, b, q;
  cin >> a >> b >> q;
  vll s(a+2), t(b+2);
  s[0] = -INFLL;
  t[0] = -INFLL;
  for (int i = 1; i < a+1; ++i) cin >> s[i];
  for (int i = 1; i < b+1; ++i) cin >> t[i];
  s[a+1] = INFLL;
  t[b+1] = INFLL;

  vll ans(q);
  rep(qi,q) {
    ll x;
    cin >> x;

    int b = lower_bound(rng(s),x) - s.begin();
    int d = lower_bound(rng(t),x) - t.begin();

    ll res = INFLL;

    vll sb = {s[b-1], s[b]};
    vll td = {t[d-1], t[d]};
    for (auto S : sb) {
      for (auto T : td) {
        ll d1 = abs(x - S) + abs(S - T);
        ll d2 = abs(x - T) + abs(T - S);
        res = min({res, d1, d2});
      }
    }
    ans[qi] = res;
  }

  rep(i,q) printf("%lld\n", ans[i]);

  return 0;
}

Measured memory_bytes: 3712
// 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)
template<typename T> ll min(ll a, const T&& b) { return a < b ? a : b; }
template<typename T> ll min(const T&& a, ll b) { return a < b ? a : b; }
template<typename T> ll max(ll a, const T&& b) { return a > b ? a : b; }
template<typename T> ll max(const T&& a, ll b) { return a > b ? a : b; }
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;
  ll ans = 0;
  while (n > 1) {
    n = (n + 2) / 3;
    ++ans;
  }
  cout << ans << endl;
}



Measured memory_bytes: 3220
/*
मनस्वी म्रियते कामं कार्पण्यं न तु गच्छति ।
अपि निर्वाणमायाति नानलो याति शीतताम् ॥
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define p2d(v) for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v) for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v) for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
#define test3(x,y,z) cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define test4(w,x,y,z) cout << #w " = " << w << " " << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

        
    ll n;
    cin>>n;

    ll ans = n+n*n+n*n*n;

    cout<<ans;
        
        












    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <cstdio>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdlib>
#include <cstdio>
using namespace std;

#define next '\n'
#define rep(i, n) for(int (i) = (0); (i) < (n); (i++))
using ll = long long;

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

    int r, d, x0, tmp;
    cin >> r >> d >> x0;
    tmp = x0;
    rep(i, 10){
        int ans = r * tmp - d;
        cout << ans << next;
        tmp = ans;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstdio>

using namespace std;

typedef pair<int, pair<int, pair<int, int> > > data;

#define f first
#define s second
#define ID s.s.f
#define AF s.s.s
#define SL f
#define PN s.f

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


int getInt(){
  int ret; scanf("%d", &ret);
  return ret;
}

int main(){
  while(int n = getInt()){
    vector<data> v(n);

    REP(i, n){
      v[i].ID = -getInt();
      v[i].AF = getInt();
      v[i].SL = getInt();
      v[i].PN = -getInt();
    }

    sort(v.rbegin(), v.rend());

    int all = 0;
    map<int, int> cnt;

    for(int i = 0; i < n; i++){
      int id = -v[i].ID;
      int af = v[i].AF;

      if(all < 10){
	if(cnt[af] < 3){
	  cnt[af]++;
	  cout << id << endl;
	  all++;
	}
      }else if(all < 20){
	if(cnt[af] < 2){
	  cnt[af]++;
	  cout << id << endl;
	  all++;
	}
      }else if(all < 26){
	if(cnt[af] < 1){
	  cnt[af]++;
	  cout << id << endl;
	  all++;
	}
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define REVE(x) reverse(ALL(x))
#define SZ(x) ((int)(x).size())
#define MP make_pair
#define PB push_back
#define INF 999999999

typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n, h, w,ans=0;
	cin >> n >> h >> w;
	VI a(n), b(n);
	REP(i, n) {
		cin >> a[i] >> b[i];
	}
	REP(i, n) {
		if (h <= a[i] && w <= b[i])ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace AtCoderBeginnerContest165A
{
    class Program
    {
        static void Main(string[] args)
        {
            int k = int.Parse(Console.ReadLine());
            int[] input = Console.ReadLine().Split(' ').AsEnumerable().Select(s => { return int.Parse(s); }).ToArray();

            var result = "NG";
            for (int i = input[0]; i <= input[1]; i++)
            {
                if (i % k == 0)
                {
                    result = "OK";
                    break;
                }
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 28252
while True:
    try:
        n = input()
        m = input()
        s = raw_input()
        graph = []
        for i in xrange(n):
            graph.append({"I":2*i+1,"O":0})
            graph.append({"I":1,"O":2*(i+1)})
        graph.append({"I":2*n+1,"O":0})
        graph.append({"I":1,"O":2*n})
        cur,score = 0,0
        for c in s:
            cur = graph[cur][c]
            if cur == 2*n+1:
                score += 1
        print score
    except:
        break

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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define umax(m, x) (m = max(m, x));
#define umin(m, x) (m = min(m, x));

#define rng(v) v.begin(), v.end()
#define rrng(v) v.rbegin(), v.rend()

#define debug(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

const int INF = 1e9;
const ll LINF = 1e18;


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

    if (s[2] == s[3] && s[4] == s[5])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


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

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;

const int mod = 1e9 + 7;


int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int n, k, q;
	cin >> n >> k >> q;
	vi a(q);
	vi p(n);
	rep(i, q){
		cin >> a[i];
	}

	rep(i, n){
		p[i] = k-q;
	}

	rep(i, q){
		p[a[i]-1]++;
	}


	rep(i, n){
		if(p[i] > 0){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}



    return 0;
}



Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys


def main():
    lines = sys.stdin.readlines()[0].split(' ')
    one_try = int(lines[0])
    money = int(lines[1])
    count = int(lines[2])
    n = 0
    while(True):
        if money >= one_try:
            money = money - one_try
            n = n + 1
        else:
            break
        if n == count:
            break
    print(n)


if __name__ == '__main__':
    main()
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

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

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

    return 0;
}


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

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

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t),weight(w){ }
};

typedef pair<int,int> P;
using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}


bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}

bool palin(string S){//回文判定
  int n = S.size();
  bool flag = true;
  if(n%2 == 0){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  else if(n%2 == 1){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  return flag;
}
int main(){
  int N;
  cin >> N;
  
 ll sum = 0;
  for(int i = 1; i <= N; i++) {
    if(i % 3 != 0 && i % 5 != 0) sum += i;
  }
  cout << sum << endl;
 }


Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;
int main()
{
    long long a, b, c, p, q;
    cin >> a >> b >> c;
    a = abs(a);
    if (abs(a / c) > b)
        cout << abs(a - (b * c));
    else
    {
        if (a < 0)
            a = -a;
        p = (a % c);
        q = abs(p - c);
        if ((b - (a / c)) % 2 == 0)
            cout << p;
        else
            cout << q;
    }
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int const N=52;
const ll MOD=1e9+7;
struct matrix
{
    int n;
    ll a[N][N];
    matrix operator *(const matrix mt)
    {
        matrix res;
        res.n=n;
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=n;j++)
            {
                res.a[i][j]=0;
                for(int k=1;k<=n;k++)
                {
                    res.a[i][j]=(res.a[i][j]+((a[i][k]%MOD)*(mt.a[k][j]%MOD))%MOD)%MOD;
                }
                //if (res.a[i][j]>MOD) res.a[i][j]=1;
            }
        }
        return res;
    }
} dp;
int n;
ll k;
matrix Pow(matrix m, ll x)
{
    if (x==1ll)
    {
        return m;
    }
    matrix p=Pow(m,x/2);
    if (x%2==0) return (p*p);
    else return ((m*p)*p);
}
int main()
{
    cin>>n>>k;
    dp.n=n;
    for(int i=1;i<=n;i++) for(int j=1;j<=n;j++)
        cin>>dp.a[i][j];
    matrix res=Pow(dp,k);
    ll ans=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            ans=(ans+res.a[i][j])%MOD;
    cout<<ans;
    return 0;
}


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

int a[100100];

int main(){
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    sort(a, a+n);
    int ans = 2*1e9;
    for(int i = 0; i+k-1 < n; ++i){
        int j = i+k-1;
        ans = min(ans, a[j] - a[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
from collections import deque

K = int(input())
d = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])

for i in range(K):
    x = d.popleft()
    if x%10 != 0:
        d.append(x*10+(x%10-1))
    d.append(x*10+x%10)
    if x%10 != 9:
        d.append(x*10+(x%10+1))

print(x)

Measured memory_bytes: 73848
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
#define M 2e5
using namespace std;
using ll = long long;
using ldb = long double;

void comb(vector<vector<ll>> &c) {
	int H = c.size(), W = c[0].size();
	for (int i = 0; i < H; i++) {
		c[i][0] = 1;
	}

	for (int n = 1; n < H; n++) {
		for (int r = 1; r < W; r++) {
			c[n][r] = c[n - 1][r] + c[n - 1][r - 1];
		}
	}

}

int main() {
	ldb N, A, B; cin >> N >> A >> B;
	vector<ll> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}

	sort(v.begin(), v.end(), greater<ll>());
	ll sum = 0, mi = 1e16;
	map<ldb, int> mp;
	int C = 0;
	for (int i = 0; i < N; i++) {
		if (i < A) {
			sum += v[i];
			mi = min(mi, v[i]);
		}
		mp[v[i]]++;
		if (i == A - 1) C = mp[mi];
	}

	ldb mean = (ldb)sum / A;
	printf("%.10Lf\n", mean);

	vector<vector<ll>> c(51, vector<ll>(51));
	comb(c);

	int D = mp[mi];
	if (C < A) {
		ll temp = c[D][C];
		cout << temp << endl;
	}

	else {
		ll ans = 0;
		for (int i = A; i <= B; i++) {
			ll temp = c[D][i];
			ans += temp;
			//cout << ans << endl;
		}
		cout << ans << endl;
	}

}

Measured memory_bytes: 3868
import java.util.Scanner;




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

		int a=sc.nextInt();
		int hour=(int)Math.floor(a/3600);
		a=a-hour*3600;
		int minute=(int)Math.floor(a/60);
		int second=a-minute*60;
		System.out.println(hour+":"+minute+":"+second);
	}
}


Measured memory_bytes: 26120
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
//#include<bits/stdc++.h>
#define int long long
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
#define puts(x) cout << (x) << "\n"
constexpr int mod = 1000000007;
using namespace std;
int input() { int t; cin >> t; return t; }
vector<int>v1, v2;
string map[10];
bool h1[10], w1[10]; int h, w, k, ans;
void f1(int i) {
	if (i == h + w) {
		int cnt = 0;
		for0(i, h)for0(j, w)if (h1[i] && w1[j] && map[i][j] == '#')cnt++;
		if (cnt == k)ans++;
		return;
	}
	f1(i + 1);
	if (i < h) {
		h1[i] = 1;
		f1(i + 1);
		h1[i] = 0;
	}
	else {
		w1[i-h] = 1;
		f1(i + 1);
		w1[i-h] = 0;
	}
}
signed main() {
	cin >> h >> w >> k;
	for0(i, h)cin >> map[i];
	f1(0); cout << ans << endl;
}

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

int main()
{   int a,b;
    while(1){
        cin >> a >> b;
        string s = string(b,'#');
        if (a == 0 && b ==0){
            break;
        }else{
            for (int i=0;i<a;i++){

                cout << s <<endl;
            }
            cout << endl;
        }
    }
}


Measured memory_bytes: 3168
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

unordered_map<long, unordered_set<long>> connection;
vector<long> values;
unordered_map<long, bool> visited;

void rec(long current) {
  visited[current] = true;
  for (long child: connection[current]) {
    if (visited[child]) continue;
    values[child] += values[current];
    rec(child);
  }
}

void solve() {
  long N, Q;
  cin >> N >> Q;
  values = vector<long>(N+1, 0);
  rep (i, N-1) {
    long a, b;
    cin >> a >> b;
    connection[a].insert(b);
    connection[b].insert(a);
  }
  rep (i, Q) {
    long p, x;
    cin >> p >> x;
    //cout << "p: " << p << ", x: " << x << endl;
    values[p] += x;
  }
  rec(1);
  bool flag = false;
  for (long i = 1; i <= N; i++) {
    if (flag) cout << " ";
    flag = true;
    cout << values[i];
  }
  cout << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if (s.back() == 's') s += "es"; else s.push_back('s');
    cout << s;
    return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int turn = 0;
    while(a > 0 && c > 0){
        if(!turn){
            c -= b;
            if(c <= 0){
                cout << "Yes\n";
                return 0;
            }
        }
        else{
            a -= d;
            if(a <= 0){
                cout << "No\n";
                return 0;
            }
        }
        turn ^= 1;
    }
}

Measured memory_bytes: 3648
/*Hey, What's up?*/

#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
multiset<long long>st;
multiset<long long>::iterator it;
int main()
{
    fastio;
    long long a=0,b=0,c,d,e,f=0,l,g,m,n,k,i,j,t,p,q;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a;
        if(st.size()==0)st.insert(a);
        else{
            it=st.lower_bound(a);
            if(it==st.begin()){
                st.insert(a);
            }
            else{
                it--;
                st.erase(it);
                st.insert(a);
            }
        }
    }
    cout<<st.size();

    return 0;
}


Measured memory_bytes: 4992
N,K = map(int,input().split())
mod = 10**9+7
def func(a,n):
    if n == 1:
        return a%mod
    elif n%2:
        return (a*func(a,n-1))%mod
    else:
        return ((func(a,n//2))**2)%mod
ans = 0
sum1 = 0
sum2 = 0
for i in range(1,N+2):
    if i == K:
        diff = ans
    sum1 = (sum1 + i-1)%mod
    sum2 = (sum2 + N-i+1)%mod
    ans = (ans + sum2 - sum1 + 1)%mod
print((ans-diff)%mod)

Measured memory_bytes: 9228
k, n = gets.split(" ").map(&:to_i)
ary = gets.split(" ").map(&:to_i).sort

max = ary[0] + k - ary[-1] 

(ary.size - 1).times do |i|
  if max < ary[i+1] - ary[i]
    max = ary[i+1] - ary[i]
  end
end

puts k - max


Measured memory_bytes: 20464
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  double ans=0;
  for(Int i=0;i<n;i++){
    double x;
    string s;
    cin>>x>>s;
    if(s=="JPY") ans+=x;
    if(s=="BTC") ans+=380000.0*x;
  }
  cout<<ans<<endl;
  return 0;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
// #define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int a, b, c; cin >> a >> b >> c;
    if((b*10+c)%4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7696
import sys
input=sys.stdin.readline

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

import math

gall=a[0]
for i in a:
    gall=math.gcd(gall,i)

M=10**6
if gall==1:
    check=True
    sa=set()
    for i in a:
        if not i in sa:
            sa.add(i)
        else:
            if not i==1:
                check=False
    for i in range(2,M+1):
        temp=i
        count=0
        while temp<=M:
            if temp in sa:
                count+=1
            temp+=i
        if count>=2:
            check=False

    if check:
        print('pairwise coprime')
    else:
        print('setwise coprime')

else:
    print('not coprime')

Measured memory_bytes: 212852
// ABC 81 B

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

typedef long long ll;

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; }
const long long INF = 1LL<<60;

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

  int ans = 0;
  rep(a, A + 1) {
    rep(b, B + 1) {
      rep(c, C + 1) {
        if (500 * a + 100 * b + 50 * c == X) {
          ans++;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int w,h;
char ma[100][100];
int sx,sy; 
int dx[] = {0,0,1,-1},dy[] = {1,-1,0,0};
int cnt;
int dfs(int px,int py){
  ma[py][px] = '#';
  cnt++;
  for(int i = 0 ; i < 4 ; i++){
    int nx = px + dx[i],ny = py + dy[i];
    if(0 <= nx && nx < w && 0 <= ny && ny < h &&
       ma[ny][nx] != '#'){
      if(ma[ny][nx] == '.')dfs(nx,ny);
    }
  }
  return cnt;
}

int main(){
  while( cin >> w >> h, w + h){
    cnt = 0;
    for(int i = 0 ; i < h ; i++){
      for(int j = 0 ; j < w ; j++){
	cin >> ma[i][j];
	if(ma[i][j] == '@'){sx = j;sy = i;}
      }
    }
    cout << dfs(sx,sy) << endl;
  }
}

Measured memory_bytes: 1168
n, q = map(int, input().split())
s = input()
ruisekiwa = [0]
for i in range(len(s)-1):
    if s[i:i+2] == 'AC':
        ruisekiwa += [ ruisekiwa[-1] + 1 ]
    else:
        ruisekiwa += [ ruisekiwa[-1] ]

ruisekiwa += [ ruisekiwa[-1] ]

for _ in range(q):
    l, r = map(int, input().split())
    l -= 1; r -= 1;
    print(ruisekiwa[r] - ruisekiwa[l])


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

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


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n,k;
    int r,s,p;
    string t;
    cin>>n>>k;
    cin>>r>>s>>p;
    cin>>t;
    vector<bool> v(n);
    ll ans=0;
    for (int i = 0; i < n; i++)
    {
        if(i<k || t[i]!=t[i-k] || v[i-k]==false)
        {
            char c=t[i];
            if(c=='r')
            {
                ans+=p;
            }
            else if(c=='s')
            {
                ans+=r;
            }
            else if(c=='p')
            {
                ans+=s;
            }
            v[i]=true;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 512
#include <math.h>
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX / 2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using psi = pair<string, int>;

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

  int N; cin >> N;
  vi A(N); REP(i, N) cin >> A[i];

  vector<pii> v;
  for(int i=0; i<N; i++) {
    v.push_back(pii(A[i], i+1));
  }
  sort(v.begin(), v.end());

  cout << v[0].second;
  FOR(i,1,N) {
    cout << " " << v[i].second;
  }
  cout << endl;

  return 0;
}

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

/////////////////////////////////////////////////////////

void Main(){
  int A, B;
  cin >> A >> B;
  int cur = 0;
  while(true){
    if(cur * (A - 1) + 1 >= B) break;
    else cur++;
  }
  cout << cur << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;

main(){
    int n;cin>>n;
    int temp = n%10;
    if(temp==2 || temp == 4 || temp==5 || temp == 7 || temp == 9) cout<<"hon";
    else if(temp == 0 || temp == 1 || temp == 6 || temp == 8) cout<<"pon";
    else cout<<"bon";
}

Measured memory_bytes: 3628
import sys
input = sys.stdin.readline

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

count_a = 0
count_b = 0
for i in range(n):
    if s[i] == "a":
        if count_a + count_b < a + b:
            print("Yes")
            count_a += 1
        else:
            print("No")
    elif s[i] == "b":
        if count_a + count_b < a + b and count_b < b:
            print("Yes")
            count_b += 1
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 4040
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<double> dp(n+1);
  dp[0]=1;
  for(int i=0;i<n;i++){
    double x;
    cin >> x;
    for(int j=i+1;j>=0;j--){
      dp[j]=(j==0 ? 0 : dp[j-1])*x + dp[j]*(1-x);
    }
    /*for(int j=0;j<=n;j++){
      cout << dp[j] << " ";
    }
    cout << "\n";*/
  }
  double sum = 0;
  for(int i=n;i>n/2;i--){
    sum = sum + dp[i];
  }
  printf("%.10lf",sum);
  return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int flag=1,count=0,x,y,minx=0,miny=0,maxx=0,maxy=0,flag2=0,falg3=0;
  int fi[1000000];
  cin>>x>>y;
  if(x==0 && y==0){
    cout<<1<<'\n';
    return(0);
  }
  fi[0]=1;
  while(true){
    if(count%4==0){
      if(count==0){
	maxx=1;
	fi[1]=1;
      }
      else{
	fi[count+1]=fi[count]+fi[count-1];
	maxx+=fi[count+1];
      }
    }
    if(count%4==1){
      fi[count+1]=fi[count]+fi[count-1];
      maxy+=fi[count+1];
    }
    if(count%4==2){
      fi[count+1]=fi[count]+fi[count-1];
      minx+=fi[count+1];
    }
    if(count%4==3){
      fi[count+1]=fi[count]+fi[count-1];
      miny+=fi[count+1];
    }
    count++;
    if(x>=0 && y>=0){
      if(maxy>=y && maxx>=x){
	cout<<count%3+1<<'\n';
	break;
      }
    }
    else if(y>=0 && x<=0){
      if(maxy>=y && minx+x>=0){
	cout<<count%3+1<<'\n';
	break;
      }
    }
    else if(y<=0 && x<=0){
      if(miny+y>=0 && minx+x>=0){
	cout<<count%3+1<<'\n';
	break;
      }
    }
    else if(y<=0 && x>=0){
      if(miny+y>=0 && maxx>=x){
	cout<<count%3+1<<'\n';
	break;
      }
    }      
  }
  return(0);
}





Measured memory_bytes: 3228
import math
def S(i):
    return ((i * (i+1)) // 2)

N = int(input())
ans = 0
sqrt_N = math.floor(math.sqrt(N))

for K in range(1, N+1, 1):
    if((N // K) < sqrt_N):
        break
    # 個別に足す
    ans += S(N // K) * K

for NdivK in range(1, sqrt_N, 1):
    # [N // K]が等しいKの区間を求める
    Kbegin = N // (NdivK + 1)
    Kend = N // NdivK
    ans += (S(NdivK) * (S(Kend) - S(Kbegin)))

print(ans)

Measured memory_bytes: 9088
#include <stdio.h>
#include <string.h>

int main() {

    //int x, y, z;
    //scanf("%d%d%d", &x, &y, &z);

    char s[4];
    scanf("%s",s);
    
    if(s[0]== '7' || s[1] == '7' || s[2] == '7'){
            printf("Yes");
    }else{
        printf("No");
    }
 


    return 0;

}


Measured memory_bytes: 1696
#include <bits/stdc++.h>
#include <atcoder/lazysegtree>
#include <atcoder/modint>

using namespace std;
#ifdef __DEBUG__
    void debug_out() { cerr << endl; } 
    template <typename Head, typename... Tail>
    void debug_out(Head H, Tail... T) {cerr << " " << H; debug_out(T...);}
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 
#endif

using mint = atcoder::modint998244353;
using F = pair<mint, mint>;
using S = pair<mint, int>;

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };

int N,Q;
vector<S> A;
inline void input(){
    // fast_io();
    cin >> N >> Q;
    for (int i = 0; i < N; i++)
    {
        int a; cin >> a;
        A.emplace_back(a,1);
    }
}

S op(S x, S y){ return S{x.first + y.first, x.second + y.second};}
S e(){ return S{0,0}; }
S mapping(F f, S x){ return S{f.first*x.first + f.second*x.second, x.second};}
F composition(F f, F g){ return F{f.first*g.first, f.first*g.second + f.second};}
F id(){ return F{1,0};}

inline int solve(){
    atcoder::lazy_segtree<S, op, e, F, mapping, composition, id > lsg(A);
    for (int i = 0; i < Q; i++)
    {
        int type; cin >> type;
        if(type==0){
            int l,r;
            int b,c;
            cin >> l >> r >> b >> c;
            lsg.apply(l,r,F{b,c});
        }
        else{
            int l,r;
            cin >> l >> r;
            cout << lsg.prod(l,r).first.val() << endl;
        }
    }
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 19436
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll x;
  cin >> x;
  ll dep = 100;
  ll ans = 0;
  while(dep < x) {
    dep = dep * 1.01;
    ans += 1;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    ll d, g;
    cin >> d >> g;
    vector<ll> p(d);
    vector<ll> c(d);
    rep(i, d) {
        cin >> p[i] >> c[i];
    }
    ll ans = 1e18;
    //cout << (1<<d) << endl;
    rep(i, 1<<d) {
        ll sum = 0;
        ll cnt = 0;
        rep(j, d) {
            if ((i>>j) & 1) {
                sum += p[j] * 100 * (j+1) + c[j]; 
                cnt += p[j];
            }
        }
        //cout << i << " " << sum << " " << cnt << endl;
        bool over = false;
        for (int j = d-1; j >= 0; --j) {
            if ((i>>j) & 1) continue;
            int tmp_cnt = 0;
            while(1) {
                if (sum >= g) {
                    over = true;
                    break;
                }
                if (tmp_cnt == p[j]) break;
                sum += 100 * (j+1);
                ++tmp_cnt;
                ++cnt;
                //cout << tmp_cnt << " " << p[j] << endl;
            }
            if (over) break;
        }
        ans = min(ans, cnt);
        //cout << ans << " " << cnt << endl;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int N, D, X; cin >> N >> D >> X;
    int A[N];
    int sum = 0;
    for (int i = 0 ; i < N; i++) {
        cin >> A[i];
        sum += (D + A[i] - 1) / A[i];
    }
    cout << sum + X << endl;
}


Measured memory_bytes: 3440
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define mod 1000000007
#define pb emplace_back
#define mp make_pair
#define fi first
#define sec second
typedef long long ll;
typedef long double  ld;
#define pii pair<ll,ll> 
#define vi vector< ll > 
#define vvi vector< vi > 
#define vpi vector< pii > 
#define vvpi vector< vpi > 
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define test(t) ll t;cin>>t;while(t--)
#define mem(a,b) memset(a,b,sizeof(a))
#define inn freopen("input.txt", "r", stdin)
#define outt freopen("output.txt", "w", stdout)
#define all(arr) arr.begin(),arr.end()
#define fr(i,n) for(ll i=0;i<(n);++i)
#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b)))
#ifndef ONLINE_JUDGE
#define debarr(a,n)cerr<<#a<<":";for(int i=0;i<n;i++)cerr<<a[i]<<" ";cerr<<endl;
#define debmat(mat,row,col)cerr<<#mat<<":\n";for(int i=0;i<row;i++){for(int j=0;j<col;j++)cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...)dbs(#__VA_ARGS__,__VA_ARGS__)
template<class S,class T>ostream &operator<<(ostream &os,const pair<S,T> &p){return os<<"("<<p.first<<","<<p.second<<")";}
template<class T>ostream &operator<<(ostream &os,const vector<T> &p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const set<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const multiset<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class S,class T>ostream &operator<<(ostream &os,const map<S,T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>void dbs(string str,T t){cerr<<str<<":"<<t<<"\n";}
template<class T,class...S>void dbs(string str,T t,S... s){int idx=str.find(',');cerr<<str.substr(0,idx)<<":"<<t<<",";dbs(str.substr(idx+1),s...);}
#else
#define pr(...){}
#define debarr(a,n){}
#define debmat(mat,row,col){}
#endif
ll power(ll x,ll y){ll res = 1;while(y){if(y&1) res = (res*x)%mod;y=y/2,x=(x*x)%mod;}return res%mod;}
signed main()
{
    fast;
    ll n;
    cin>>n;
    ll low = 1,high = n;
    ll ans = high;
    while(low<=high)
    {
        ll  mid = (low+high)/2;
        ll temp = (mid*(mid+1))/2;
        if(temp<=n)
        {
            ans = mid,low = mid+1;
        }
        else
            high = mid-1;
    }
    ll temp = (ans*(ans+1))/2;
    if(temp==n)
        cout<<ans;
    else
        cout<<ans+1;
    
}


Measured memory_bytes: 256
N,M,C = map(int, input().split())
blist = [int(x) for x in input().split()]
alist = []
for i in range(N):
    a = [int(x) for x in input().split()]
    alist.append(a)

score = 0
for a in alist:
    cache = 0
    for i,b in enumerate(blist):
        cache += a[i]*b
    if cache+C > 0:
        score += 1

print(score)


Measured memory_bytes: 3064
N=int(input())
A=list(map(int,input().split()))
from collections import defaultdict
d = defaultdict(int)

for a in A:
    d[a]+=1

ans=0
for k in d.keys():
    if d[k]>k:
        ans+=d[k]-k
    elif d[k]<k:
        ans+=d[k]
print(ans)


Measured memory_bytes: 68776
#include<iostream>
using namespace std;
int main()
{
	int N,K,X,Y,A,B;
	cin>>N>>K>>X>>Y;
	if(N>=K)
	{
		A=K*X+(N-K)*Y;
		cout<<A<<endl;
	}
	else if(N<K)
	{
		B=N*X;
		cout<<B<<endl;
	}
		return 0;
		}

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

using namespace std;

int a[21], num, m, q;

bool dfs (int n, int sum)
{
    bool ret;
    if (n==num && sum!=m) return false;
    if (sum==m) return true;
    if (sum>m) return false;
    if (sum<m)
    {
        for (int i=n+1; i<=num; i++)
        {
            ret=dfs(i,sum+a[i]);
            if (ret) return true;
        }
        return false;
    }
}

int main()
{
    cin>>num;
    for (int i=1; i<=num; i++) cin>>a[i];
    sort(a,a+num);
    cin>>q;
    bool ret[q];
    for (int i=0; i<q; i++)
    {
        cin>>m;
        ret[i]=dfs(0,0);
    }
    for (int i=0; i<q; i++) cout<<(ret[i] ? "yes\n" : "no\n");
    return 0;
}



Measured memory_bytes: 3140
H, W = map(int, input().split())
Inf = 10**9

S = [input() for i in range(H)]
dis = [[Inf]*(H*W) for i in range(H*W)]

for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            continue
        if i - 1 >= 0 and S[i-1][j] == ".":
            dis[i*W+j][(i-1)*W+j] = 1
        if i + 1 < H and S[i+1][j] == ".":
            dis[i*W+j][(i+1)*W+j] = 1
        if j - 1 >= 0 and S[i][j-1] == ".":
            dis[i*W+j][i*W+j-1] = 1
        if j + 1 < W and S[i][j+1] == ".":
            dis[i*W+j][i*W+j+1] = 1

for i in range(H*W):
    for j in range(H*W):
        for k in range(H*W):
            dis[j][k] = min(dis[j][i] + dis[i][k], dis[j][k])

max_ans = 0
for i in range(H*W):
    for j in range(H*W):
        if i == j or dis[i][j] == Inf:
            continue        
        max_ans = max(dis[i][j], max_ans)

print(max_ans)


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

#define ll long long int

using namespace std;

int main() {
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll z = min(x,y);

    cout << min(a *x + b *y, min(c * max(x,y) * 2,  c * z * 2 + ((x>y)?a:b) * abs(x-y))) << endl;
}


Measured memory_bytes: 3596