akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)

class RMQ {
public:
	vector<long long> dat;
	const long long MAX_VAL = (1LL << 31) - 1;
	int bekisize;

	RMQ(int sz) {
		bekisize = 1;
		while (bekisize < sz) bekisize *= 2;
		dat.resize(2 * bekisize - 1);
		for (int i = 0; i < 2 * bekisize - 1; i++) dat[i] = 0;
	}

	int datsize() {
		return bekisize;
	}

	void update(int k, int a) {
		k += (bekisize - 1);
		dat[k] = a;
		while (k > 0) {
			k = (k - 1) / 2;
			dat[k] = max(dat[k * 2 + 1], dat[k * 2 + 2]);
		}
	}
	//intial k=0,l=0,r=bekisize
    //call [a,b) getmin(a,b) 
	long long getmax(int a, int b, int k=0, int l=0, int r = -1) {
		if (r == -1) r = bekisize;
		if (r <= a || b <= l) return 0;
		if (a <= l && r <= b) return dat[k];
		else {
			int vl = getmax(a, b, k * 2 + 1, l, (l + r) / 2);
			int vr = getmax(a, b, k * 2 + 2, (l + r) / 2, r);
			return max(vl, vr);
		}
	}
};


int main(){
  int n,k;
  cin >> n >> k;
  vector<int> v(n);
  rep(i,n) cin >> v[i];
  int Max_A = 300005;
  RMQ dp(Max_A);
  for (int i = 0; i < n;i++){
     int x = v[i];
     int l = max(x-k,0);
     int r = min(Max_A,x+k+1);
     int now = dp.getmax(l,r) + 1;
     dp.update(x,now);
  }
  int ans = dp.getmax(0,Max_A);
  cout << ans << endl;

  
  return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pii;
typedef std::pair<long long, long long> pll;

using namespace std;

const long long mod = 1000000007;

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

	int n;
	cin >> n;
	int* l;
	l = new int[n];
	rep(i, n) cin >> l[i];

	sort(l, l + n);

	ll ans = 0;
	rep(i, n) {
		REP(j, i+1, n) {
			ans += (ll)(lower_bound(l, l + n, l[i] + l[j]) - (l + j + 1));
		}
	}

	cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
  ll n, k;
  cin >> n >> k;
  ll ans = n;
  ans = min(ans, n%k);
  if (n%k != 0) ans = min(ans, k-(n%k));
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
a = []
for i in range(n):
  x,y = map(int,input().split())
  a.append([x,y])
l = sorted(a,key=lambda x: -x[0])
r = sorted(a,key=lambda x: x[1])
left = 0
hi = 0
mi = 0
for i in range(n):
  hi += l[i][0]
  left = max(left,(hi-mi)*2)
  mi += r[i][1]
  left = max(left,(hi-mi)*2)
right = 0
hi = 0
mi = 0
for i in range(n):
  mi += r[i][1]
  right = max(right,(hi-mi)*2)
  hi += l[i][0]
  right = max(right,(hi-mi)*2)
print(max(right,left))

Measured memory_bytes: 25324
N = int(input())

for l in range(N):
    s = input()
    ans = s[0]
    s = s[1:]
    while s != "":
        dist = s[0:2]
        ss = s[2]
        if not ss in ans:
            if dist == "->":
                ans = ans + ss
            else:
                ans = ss + ans
        s = s[3:]
    print(ans)



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

int main() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  string ans = "";

  rep(i, n) {
    ans += s[i];
    ans += t[i];
  }

  cout << ans << endl;
  return 0;
}


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

#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#define endl "\n"
#define all(V) V.begin( ), V.end( )
#define Unique(V) sort( all( V ) ), V.erase( unique( all( V ) ), V.end() )
#define Check( N , p ) ( !( ( N & ( 1LL << p ) ) == 0 ) )
#define ON( N , p ) ( N = N | ( 1LL << p ) )
#define OFF( N , p ) ( N = N & ~( 1LL << p ) )
std::mt19937 rng( chrono::steady_clock::now().time_since_epoch().count() );
#define rnd(a, b) ((((rand() << 15) ^ rand()) % ((b) - (a) + 1)) + (a))
#define ran(a, b) rng() % ( (b) - (a) + 1 ) + (a)
#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template < typename Arg1 >
void __f( const char* name , Arg1&& arg1 ) { cerr << name << " : " << arg1 << "\n"; }
template < typename Arg1 , typename... Args >
void __f( const char* names , Arg1&& arg1 , Args&&... args ) {
const char* comma = strchr( names + 1 , ',' );
cerr.write( names , comma - names ) << " : " << arg1 << " , " ; __f( comma + 1 , args... ); }
typedef long long int LL;
typedef pair <int,int> pii;
typedef pair <long long,long long> pll;
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
const int N = 1e5 + 5;
const int inf = 1e9;
const long long INF = 1e18;

int black = 1 , white = 2;
int n;
vector <int> graph[ N ];
LL dp[ N ][ 5 ];

LL dfs( int s , int p , int col ) {
        if( dp[s][col] != -1 ) return dp[s][col];
        LL ret = 1;
        for( auto x : graph[s] ) {
                if( x != p ) {
                        LL sum = 0;
                        if( col == black ) {
                                sum += dfs( x , s , white ), sum %= MOD;
                        }
                        else {
                                sum += dfs( x , s , white ) , sum %= MOD;
                                sum += dfs( x , s , black ) , sum %= MOD;
                        }
                        ret = ( ret%MOD * sum%MOD )%MOD;
                }
        }
        return dp[s][col] = ret%MOD;
}
int main( int argc , char const *argv[] ) {
        ios_base::sync_with_stdio( false ); cin.tie( nullptr );
        cin >> n;
        for( int i = 1; i <= n - 1; i++ ) {
                int u , v;
                cin >> u >> v;
                graph[u].push_back( v );
                graph[v].push_back( u );
        }
        memset( dp , -1 , sizeof( dp ) );
        for( int i = 1; i <= 2; i++ ) dfs( 1 , 0 , i ); /// 1 - bl , 2 = wh
        cout << ( dp[1][1]%MOD + dp[1][2]%MOD )%MOD << endl;
        return 0;
}














Measured memory_bytes: 19456
#include <bits/stdc++.h>
#define ll long long int
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define inputv(a) forall(i,0,a.size()) cin>>a[i]
#define outputv(a) for(auto i:a) cout<<i<<" ";br;
#define fs first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define minv(a) *min_element(all(a))
#define maxv(a) *max_element(all(a))
#define br cout<<"\n"
using namespace std;
int dr[]={1,-1,0,0};
int dc[]={0,0,1,-1};
ll mod=1000000007;
ll po(ll x,ll n){
    ll res = 1;
    while(n>0){
        if(n%2==1)
            res = ((res)*(x));
        x = (x*x);
        n = n/2;
    }
    return res;
}
ll ceil(ll x,ll y)
{
    if(x%y==0)
        return x/y;
    else
        return(x/y)+1;
}
ll reverse(ll num)
{
     ll n, reversedNumber = 0, remainder;
     n=num;
    while(n != 0)
    {
        remainder = n%10;
        reversedNumber = reversedNumber*10 + remainder;
        n /= 10;
    }
    return reversedNumber;
}

int main(){
	 ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    ll a[n];
    map<ll,ll>jk;
    rep(i,0,n) {cin>>a[i]; jk[a[i]]++;}
    ll sum=accumulate(a,a+n,0ll);
    ll q;
    cin>>q;
    while(q--)
    {
        ll c,d;
        cin>>c>>d;
        if(jk.find(c)!=jk.end())
        {
            jk[d]+=jk[c];
            sum=sum-jk[c]*c;
            sum+=jk[c]*d;
            jk[c]=0;
        }
        cout<<sum; br;

    }


    return 0;
}


Measured memory_bytes: 9440
#include <iostream>
#include <vector>
#include <cmath>
#include <map>

using namespace std;

int main(int argc, char * argv[]) {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> P(M);
    for (auto & x : P) {
        cin >> x.first >> x.second;
        x.first -= 1;
        x.second -= 1;
    }

    vector<vector<int>> dir(N);
    for (auto & p : P) {
        dir[p.first].push_back(p.second);
    }

    vector<double> E(N);

    for (int i = N - 2; i >= 0; --i) {
        double sum = 0;
        for (int next : dir[i]) {
            sum += E[next] + 1;
        }
        E[i] = sum / dir[i].size();
    }

    double best_opt = 0;
    map<int, double> deps;
    deps[0] = 1.0;

    while (deps.size() > 0) {
        int i = deps.begin()->first;
        if (dir[i].size() > 1) {
            double sum = 0, worst = -1;
            int worst_at = -1;
            for (int j : dir[i]) {
                if (E[j] > worst) {
                    worst = E[j];
                    worst_at = j;
                }
                sum += E[j];
            }
            double sol2 = (sum - worst) / (dir[i].size() - 1) + 1;
            best_opt = std::max(best_opt, (E[i] - sol2) * deps[i]);
        }
        for (int j : dir[i]) {
            deps[j] += deps[i] / dir[i].size();
        }
        deps.erase(i);
    }

    cout.precision(10);
    cout << E[0] - best_opt << endl;

    return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <string>
#include <queue>

using namespace std;

int main()
{
	string s;
	queue<char> q[3];
	for (int i = 0; i < 3; i++) {
		cin >> s;
		for (int j = 0; j < s.length(); j++) {
			q[i].push(s[j]);
		}
	}
	char next = 'a';
	while (1) {
		switch (next){
		case 'a':
			if (!q[0].empty()) {
				next = q[0].front();
				q[0].pop();
			}
			else {
				cout << "A" << endl;

				return 0;
			}
			break;
		case 'b':
			if (!q[1].empty()) {
				next = q[1].front();
				q[1].pop();
			}
			else {
				cout << "B" << endl;

				return 0;
			}
			break;
		case 'c':
			if (!q[2].empty()) {
				next = q[2].front();
				q[2].pop();
			}
			else {
				cout << "C" << endl;

				return 0;
			}
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int x,y;
	cin>>x>>y;
	
	REP(i,x+1){
		if(2*i+4*(x-i)==y){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	
	cout<<"No"<<endl;
}

Measured memory_bytes: 3636
import random
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
ans = 0
a = []
last = [0]*26
for i in range(1,d+1):
    res = -float("inf")
    index = 0
    for k in range(26):
        x = k
        tnplast = last
        tnplast[x] = i
        tnp = 0
        tnp += s[i-1][x]
        for j in range(26):
            tnp -= c[j]*(i-last[j])
        if (tnp > res):
            res = tnp
            index = k+1
    ans += res
    a.append(index)

def rec(t,x,y,ans):
    ans -= s[x-1][t[x-1]-1]
    ans += s[x-1][y-1]
    ma = d+1
    mi = 0
    for j in range(x+1,d+1):
        if (t[j-1]==t[x-1]):
            ma = j
            break
    for j in range(x-1,0,-1):
        if (t[j-1]==t[x-1]):
            mi = j
            break
    ans -= c[t[x-1]-1]*(x-mi)*(ma-x)
    ma = d+1
    mi = 0
    for j in range(x+1,d+1):
        if (t[j-1]==y):
            ma = j
            break
    for j in range(x-1,0,-1):
        if (t[j-1]==y):
            mi = j
            break
    ans += c[y-1]*(x-mi)*(ma-x)
    return ans
    
for i in range(20000):
    x = random.randrange(1,d+1)
    y = random.randrange(1,27)
    t = a
    A = rec(t,x,y,ans)
    if (ans < A):
        t[x-1] = y
        a = t
        ans = A

print(*a ,sep="\n")

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

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

  int a[26] = {};
  for (int i = 0; i < w.size(); i++) {
    a[w[i] - 'a']++;
  }

  bool flag = true;
  for (int i = 0; i < 26; i++) {
    if(a[i] % 2 != 0){
      flag = false;
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}


Measured memory_bytes: 256
using System;

namespace B___Increment_Decrement
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            int res = 0, max = 0;

            for (int i = 0; i < N; i++)
            {
                res += S[i] == 'I' ? 1 : -1;
                max = Math.Max(res, max);
            }

            Console.WriteLine(max);
        }
    }
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b[n];
    REP(i, n) {
        cin >> a[i]; a[i]--;
        b[a[i]].push_back(i);
    }

    int ans = 0;
    REP(i, n) {
        REP(j, b[i].size()) {
            if(b[i][j] == a[i]) ans++;
        }
    }

    cout << ans / 2 << endl;

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    string s;
    int i;
    int num = 0;
    cin >> s;

    for(i=0;i<n-2;i++){
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
            num++;
        }
    }
    cout << num << endl;
    return 0;
}

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

const int N = 2e5+10;

deque<int> t;

int n,x;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if(i & 1) t.push_back(x);
		else t.push_front(x);
	}
	if(n & 1) reverse(t.begin(),t.end());
	for(deque<int>::iterator it=t.begin();it!=t.end();it++)
		printf("%d ",*it);
	puts("");
}

Measured memory_bytes: 2944
import java.util.*
 
fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    (1..n).map { Triple(sc.next(), sc.nextInt(), it) }
        .sortedWith(Comparator { o1, o2 ->
            if (o1.first == o2.first) o2.second - o1.second
            else o1.first.compareTo(o2.first)
        }).forEach { println(it.third) }
}

Measured memory_bytes: 36052
import itertools

N = int(input())

num_753 = [7,5,3]
anslist = []

keta = len(str(N))
for i in range(3, keta+ 1):
    tmp = list(itertools.product(num_753, repeat=i))
    for item in tmp:
        item = list(item)
        item = map(str, item)
        item = "".join(item)
        anslist.append(int(item))

anslist = [s for s in anslist if s <= N]
anslist.sort()

anslist2 = []

for ans in anslist:
    tmp = str(ans)
    if "3" not in tmp:
        continue
    elif "5" not in tmp:
        continue
    elif "7" not in tmp:
        continue
    else:
        anslist2.append(tmp)

# print(anslist2)a
print(len(anslist2))

Measured memory_bytes: 7692
### constant

COINS = [500, 100, 50, 10, 5, 1]

### main

loop do
  n = gets.strip.to_i
  break if n == 0

  change = 1000 - n
  total = 0

  for coin in COINS
    nc = change / coin
    change -= coin * nc
    total += nc
  end

  puts total
end

Measured memory_bytes: 6084
#ifndef TEMPLATE_HPP
#define TEMPLATE_HPP
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())
using namespace std;
using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename U> vector<U> make_vector(T&& n, U&& val) { return vector<U>(forward<T>(n), forward<U>(val)); }
template <typename T, typename... Args> decltype(auto) make_vector(T&& n, Args&&... args) { return vector<decltype(make_vector(forward<Args>(args)...))>(forward<T>(n), make_vector(forward<Args>(args)...)); }
const int INF = 1001001001;
const i64 LINF = 1001001001001001001ll;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
#endif

bool check(string s, char c) {
  rep(i, sz(s)) {
    if (s[i] != c) return false;
  }
  return true;
}

void solve() {
  string s;
  cin >> s;
  int n = sz(s);
  rep(i, n) s[i] -= 'a';
  int ans = INF;
  rep(i, 26) {
    string t = s;
    int cnt = 0;
    while (!check(t, i)) {
      string u;
      rep(j, sz(t) - 1) {
        if (t[j] == i || t[j+1] == i) u += i; else u += t[j];
      }
      swap(t, u);
      cnt += 1;
    }
    amin(ans, cnt);
  }
  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(16);
  cerr << fixed << setprecision(16);
  solve();
  return 0;
}

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

int pow5(int m){
	return m*m*m*m*m;
}

int main(){
	ll x,i,j;
	cin>>x;
	
	for(i=0;i<=5000;i++)
	for(j=-500;j<=5000;j++)
	if(pow5(i)-pow5(j)==x){
		cout<<i<<' '<<j;
		return 0;
	}
}

Measured memory_bytes: 3652
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;


int main(){
    vector<int> v{5,4,3,2};
    
    for (int i=0;i<4;i++) cin >> v[i];
    sort(v.begin(), v.end());
    
    if (v[0]==1 and v[1] == 4 and v[2] == 7 and v[3] == 9) {
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<iomanip>
#define BUG puts("no bug")
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define PER(a,b,c) for(int a=b;a>=c;a--)
#define lb(a) (a&(-a))
#define pp (p<<1)
#define ppp (p<<1|1)
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
using namespace std;
const int MAXN=1e6+5;
int n,m,t;
int v[MAXN];
char s[MAXN];
int main(){
    cin>>n>>m;
    int ans=n*(n-1)/2+m*(m-1)/2;
    cout<<ans;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define all(v) (v).begin(), (v).end()
#define io ios::sync_with_stdio(0)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rson rt << 1 | 1, mid + 1, r
#define lson rt << 1, l, mid
#define lll __int128
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eps 1e-12
#define int long long
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
    int ans = 1;
    for (; b; b >>= 1, a = a * a % mod)
        if (b & 1)
            ans = ans * a % mod;
    return ans;
}

signed main()
{
    io;
    string s;cin>>s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout<<"Yes"<<endl;
    }
    else 
    cout<<"No"<<endl;
    getchar(); //
    getchar();
}


Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)

nodes = Array.new(N + 1){[]}
M.times{
  a, b = gets.split.map(&:to_i)
  nodes[a] << b
  nodes[b] << a
}

$cnt = 0

def count_path(nodes, node, checked)
  if checked[node] == true
    return
  end
  checked[node] = true

  catch(:end){
    if checked.all?
      $cnt += 1
      throw :end
    end
    nodes[node].each{|to|
      count_path(nodes, to, checked)
    }
  }
  checked[node] = false
end

count_path(nodes, 1, [true, *([false] * N)])

p $cnt


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

int main()
{
    ll n;
    cin >> n;
    vector<int> a(100001);
    rep(i, 100001)
    {
        a[i] = 0;
    }
    ll sum = 0;
    rep(i, n)
    {
        int in;
        cin >> in;
        sum += in;
        a[in]++;
    }
    ll q;
    cin >> q;
    rep(i, q)
    {
        int b, c;
        cin >> b >> c;
        sum += (c - b) * a[b];
        a[c] += a[b];
        a[b] = 0;
        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 3780
from functools import reduce

N,M = map(int,input().split())
list_aaa = [ list(map(int,input().split()))  for i in range(N)]

list_ccc =[]

for i in range(N):
    list_bbb =[]
    for j in range(1,list_aaa[i][0]+1):
        list_bbb.append(list_aaa[i][j])
    list_ccc.append(set(list_bbb))

print(len(reduce(lambda a,b: a.intersection(b),list_ccc)))



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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

/**
 * 文字列sにtが含まれるかどうかを返します.
 */
bool contain(const string& s, const string t) {
  return s.find(t) != string::npos;
}

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

  string u = s + s;
  if (contain(u, t)) {
    py();
  } else {
    pn();
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int tem=b;
    while (tem>0)
    {
        a*=10;
        tem/=10;
    }
    a+=b;
    if ((int)sqrt(a)*(int)sqrt(a)==a)printf ("Yes\n");
    else printf ("No\n");
}

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

const int max_v = 1010;
int N,W;
int v[max_v], w[max_v];
int dp[110][10010];

signed main() {
    cin >> N >> W;
    for(int i = 1; i <= N; i++){
        cin >> v[i] >> w[i];
    }
    memset(dp,0, sizeof(dp));
    for(int i = 1; i <= N; i++){
        for(int j = 0; j <= W; j++){
            if(j - w[i] >= 0){
                dp[i][j] = max(dp[i][j], dp[i-1][j - w[i]] + v[i]);
            }
            dp[i][j] = max(dp[i][j], dp[i-1][j]);
        }
    }
    cout << dp[N][W] << endl;
}



Measured memory_bytes: 11724
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input()) - 1
print(l[K])

Measured memory_bytes: 3060
#include<stdio.h>

typedef struct{
  char name[10];
  int time;
}Process;

int main(){
  int head=0,tail,q,timesum=0,i,num;
  Process n[100000];
  scanf("%d%d",&num,&q);
  for(i=0;i<num;i++){
    scanf("%s",n[i].name);
    scanf("%d",&n[i].time);
  }
  
  tail=num;
  while(1){
    if(head==tail) {  break;}
   
    if(n[head].time>q){
      timesum+=q;
      n[head].time-=q;
      n[tail]=n[head];
      head++;
      tail++;
      if(head==100000)head=0;
      if(tail==100000)tail=0;
    }
    else if (n[head].time<=q){
  

      timesum+=n[head].time;
      
      
       printf("%s %d\n",n[head].name,timesum);
      head++;
      if(head==100000) head=0;
    }
  }
 
  return 0;
}
  
      
      
	
    



Measured memory_bytes: 3360
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define gcd(a,b) __gcd(a,b)
#define mem(z,i) memset(z,i,sizeof(z))
const int mod=(int)1e9+7;
int main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); 
   	int x,t;
   	cin>>x>>t;
   	if(t>=x) cout<<0;
   	else cout<<x-t;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define debug(x) { cout << #x << " = " << x << endl; }
typedef long long ll;
int main() { _
  int n;
  cin >> n;
  int dp[n],a[n];
  for(int i = 0;i < n;i++){
    cin >> a[i];
    dp[i] = 0;
  }
  dp[0] = 0;
  dp[1] = abs(a[0] - a[1]);
  for(int i = 2;i < n;i++){
    dp[i] += min(dp[i - 1] + abs(a[i] - a[i - 1]),dp[i - 2] + abs(a[i] - a[i - 2]));
  }
  cout << dp[n - 1];
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main{
	public static void main(String[] args)throws Exception{
		new Main().solve();
	}
	void solve(){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();//the number of test case
		for(int i=0;i<n;i++){
			int[] d=new int[10];
			for(int j=0;j<10;j++){
				d[j]=sc.nextInt();
			}
			int a=-999999;int b=-999999;
			//??????a<=b????????????????????????
			outside:for(int j=0;j<10;j++){
				if(d[j]>b)b=d[j];
				else if(d[j]>a)a=d[j];
				else{
					System.out.println("NO");
					break outside;
				}
				if(a>b){
					int dummy=b;
					b=a;
					a=dummy;
				}
				if(j==9)System.out.println("YES");
			}
		}
	}
}

Measured memory_bytes: 25964
import math
def stdinput():
    from sys import stdin
    return stdin.readline().strip()

def main():
    n = int(stdinput())
    nodes = [[0., 0.], [100., 0.]]

    for _ in range(n):
        next_nodes = []
        for s_node, e_node in zip(nodes[:], nodes[1:]):
            next_nodes.append(s_node)
            next_nodes += koch(s_node, e_node)
        next_nodes.append(nodes[-1])
        nodes = next_nodes

    for node in nodes:
        print(*map(lambda a: f'{round(a,8):.8f}', node))

def koch(start, end):
    nodes = []

    dx = (end[0] - start[0]) / 3
    dy = (end[1] - start[1]) / 3
    
    s = [start[0] + dx, start[1] + dy]
    t = [start[0] + 2 * dx, start[1] + 2 * dy]

    nodes.append(s)
    nodes.append(determine_koch(s, t))
    nodes.append(t)
    
    return nodes

def determine_koch(s, t):
    dx = (t[0] - s[0]) * math.sqrt(3) / 2
    dy = (t[1] - s[1]) * math.sqrt(3) / 2

    u0 = [s[0] - dy, s[1] + dx]
    u1 = [t[0] - dy, t[1] + dx]

    return [
        (u0[0] + u1[0]) / 2,
        (u0[1] + u1[1]) / 2
    ]

if __name__ == '__main__':
    main()
    # import cProfile
    # cProfile.run('main()')


Measured memory_bytes: 6492
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
using Int = int;
#define REP(i, n) for(Int i = 0; i < n; i++)

Int a[1000][999];
vector<pair<Int, Int>> g[1000][1000];
Int cnt[1000][1000] = {};
Int dp[1000][1000] = {};
bool used[1000][1000];

int main(void){
    Int n;
    scanf("%d", &n);
    REP(i, n){
        REP(j, n - 1){
            scanf("%d", &a[i][j]);
            a[i][j]--;
        }
    }
    REP(i, n){
        REP(j, n - 2){
            Int v1 = i, v2 = a[i][j], v3 = i, v4 = a[i][j + 1];
            if(v1 > v2) swap(v1, v2);
            if(v3 > v4) swap(v3, v4);
            auto &vec = g[v1][v2];
            vec.push_back({v3, v4});
        }
    }
    REP(i, n) REP(j, n) for(auto &next : g[i][j]){
        cnt[next.first][next.second]++;
    }
    auto dfs = [f = [&](auto f, pair<Int, Int> now) -> void {
        if(cnt[now.first][now.second] > 0) return;
        auto &used_tmp = used[now.first][now.second];
        if(used_tmp) return;
        used_tmp = true;
        for(auto &next : g[now.first][now.second]){
            auto &dp_next = dp[next.first][next.second];
            dp_next = max(dp_next, dp[now.first][now.second] + 1);
            cnt[next.first][next.second]--;
            f(f, next);
        }
    }](pair<Int, Int> now){ f(f, now); };
    REP(i, n){
        Int v1 = i, v2 = a[i][0];
        if(v1 > v2) swap(v1, v2);
        pair<Int, Int> v = {v1, v2};
        dfs(v);
    }
    REP(i, n) REP(j, n) for(auto &v : g[i][j]){
        if(!used[v.first][v.second]) {
            printf("-1\n");
            exit(0);
        }
    }
    Int ans = 0;
    REP(i, n) REP(j, n) ans = max(ans, dp[i][j]);
    printf("%d\n", ans + 1);
}


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

int main(){
  int n;
  cin >> n;
  int a,b,c;
  a=n%10,n/=10;
  b=n%10,n/=10;
  c=n%10;
  if(a==7 or b==7 or c==7)cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

/*
int vistd[10004];
vector<int>a[10004];
vector<int>dis(10004,0);
void dfs(int k){
   if(vistd[k]==0){
    vistd[k]=1;
    for(int i=0;i<a[k].size();i++){
        if(!vistd[a[k][i]]){
/// to find the distance between each node and their children dis[a[k][i]]=dis[k]+1;
            dfs(a[k][i]);
        }
    }
   }

}
int freq[2004];
*/
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);

int n;
cin>>n;
ll a[n];
for(int i=0;i<n;i++)
    cin>>a[i];
ll ans=0;
for(int i=1;i<n;i++){
    if(a[i]<a[i-1]){
            ll add=a[i-1]-a[i];
        a[i]+=add;
        ans+=add;
    }
}

cout << ans << endl;





/*
   int t;
   cin>>t;
   int hh=t;
   vector<string>last,f;
   while(t--){
    string s,m;
  cin>>s>>m;
    int countchar=0;
    for(int i=0;i<m.length();i++){
        if ((int(m[i])>=65 && int(m[i])<=90) || (int(m[i])>=97 && int(m[i])<=122))
           countchar++;
    }
    string tmp1="";
    for(int i=0;i<s.length();i++){
        if((int(s[i])>=65 && int(s[i])<=90) || (int(s[i])>=97 && int(s[i])<=122)){
            tmp1+=s[i];
        }
    }
    string tmp2="";
     if(countchar>1){
            int ff=0;
        for(int i=0;i<m.length();i++){
        if((int(m[i])>=65 && int(m[i])<=90) || (int(m[i])>=97 && int(m[i])<=122)){
                if(!ff){
                    m[i]=toupper(m[i]);
                    ff=1;
                }
            tmp2+=m[i];
        }
        last.push_back(tmp2);
        f.push_back(tmp1);
    }
     }
     else{
            tmp1[0]=toupper(tmp1[0]);
        last.push_back(tmp1);
        string c="";
        for(int i=0;i<m.length();i++){
            if((int(m[i])>=65 && int(m[i])<=90) || (int(m[i])>=97 && int(m[i])<=122)){
                    m[i]=toupper(m[i]);
            c+=m[i];
            c+=".";
            break;
        }
        }
        f.push_back(c);
     }
       sort(last.begin(),last.end());

   }
  for(int i=0;i<hh;i++)
    cout << last[i] << endl;
    */
}






Measured memory_bytes: 5224
# -*- coding:utf8 -*-

n = int(input())
l = list(map(int, input().split()))
for i in range(n):
    v = l[i]
    j = i - 1
    while j >= 0 and l[j] > v:
        l[j+1] = l[j]
        l[j] = v
        j -= 1
    print(' '.join(map(str, l)))



Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<int> A(m);
  for (int i = 0; i < m; i++) {
    cin >> A[i];
  }
  int studyDay = 0;
  for (int i = 0; i < m; i++) {
    studyDay +=A[i];
  }
  if (n - studyDay >= 0) {
    cout << n - studyDay << endl;
  } else {
    cout << "-1" << endl;
  }

  return 0;
}


Measured memory_bytes: 3632
#include<iostream>

using namespace std;

int main(){
    int a,b,k;
    cin>>a>>b>>k;
    int x=b-a+1;
    if((2*k)>=x){
        for(int i=a;i<=b;i++){
            cout<<i<<endl;
        }
    }
    else{
        for(int i=0;i<k;i++){
            cout<<a<<endl;
            a++;
        }
        b-=k;
        b++;
        for(int i=0;i<k;i++){
            cout<<b<<endl;
            b++;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<utility>
#include<tuple>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<queue>
#include<deque>
#include<bitset>
#include<cmath>
#include<map>
#include<iomanip>
using namespace std;
using ll = long long int;
const ll mod = 1e9 + 7;
#define rep(i, a, b) for(int i = a; i < b; i++)

int main() {
	
	int n, m, k = 0;
	cin >> n >> m;

	vector<int> s(m), c(m), t(4, -1);
	rep(i, 0, m) {
		cin >> s[i] >> c[i];
		if (t[s[i]] == -1) {
			t[s[i]] = c[i];
		}
		else if(t[s[i]] != c[i]) k = -1;
	}

	if (n == 1 && k != -1 && t[1] == 0) {
		cout << 0 << endl;
		return 0;
	}

	if (t[1] == 0 || k == -1) {
		cout << -1;
		return 0;
	}

	rep(i, 1, n + 1) {
		if (t[i] != -1) cout << t[i];
		else if (i == 1 && n != 1) cout << 1;
		else cout << 0;
	}

	cout << endl;

	return 0;
}

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

const int N = 25010;
const int M = 410;
const int mod = 1e9 + 7;

typedef long long LL;

inline int Pow(int x, int y) {
    int res = 1;
    for (; y; y >>= 1, x = (LL)x * x % mod) if (y & 1) res = (LL)res * x % mod;
    return res;
}

int n, k, f[N][M], g[N][M], p1[M], p2[M], frac[M], inv[M];

inline void Just_DOIT(int len = 1) {
    f[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        p1[0] = f[i - 1][0], p2[0] = g[i - 1][0];
        for (int j = 1; j <= min(i - 1, k - 1); j++) {
            p1[j] = (p1[j - 1] + f[i - 1][j]) % mod;
            p2[j] = (p2[j - 1] + g[i - 1][j]) % mod;
        }
        int A = p1[min(i - 1, k - 1)], B = p2[min(i - 1, k - 1)];
        for (int j = 1; j <= min(i, k - 1); j++) {
            f[i][j] = (LL)f[i - 1][j - 1] * (k - j + 1) % mod;
            g[i][j] = (LL)g[i - 1][j - 1] * (k - j + 1) % mod;
            f[i][j] = ((LL)f[i][j] + A - p1[j - 1] + mod) % mod, g[i][j] = ((LL)g[i][j] + B - p2[j - 1] + mod) % mod;
            if (j >= len) g[i][j] = (g[i][j] + f[i][j]) % mod;
        }
    }
}

inline int Make_Your_Dream_COMETRUE(int left, int len) {
    int res = 0, t = (LL)inv[k] * frac[k - len] % mod;
    for (int i = len; i < k; i++) {
        res = (res + (LL)f[left + len][i] * t) % mod;
    }
        
    return res;
}

int A[N], lst[M], hh[N];

int main() {
    int m; scanf("%d%d%d", &n, &k, &m), frac[0] = inv[0] = 1;
    for (int i = 1; i <= k; i++) frac[i] = (LL)frac[i - 1] * i % mod, inv[i] = Pow(frac[i], mod - 2);
    for (int i = 1; i <= m; i++) scanf("%d", &A[i]);
    int tmp = 0, mx = 0;
    for (int i = 1; i <= m; i++) {
        if (lst[A[i]]) tmp = max(tmp, lst[A[i]]);
        lst[A[i]] = i, mx = max(mx, i - tmp);
    }
    int all = (LL)(n - m + 1) * Pow(k, n - m) % mod;
    if (mx >= k) {
        printf("%d\n", all);
        return 0;
    }
    if (mx == m) {
        Just_DOIT(mx); int res = 0;
        for (int i = 1; i < k; i++) res = (res + g[n][i]) % mod;
        int tmp = (LL)frac[k] * inv[k - mx] % mod;
        res = (LL)res * Pow(tmp, mod - 2) % mod;
        printf("%d\n", (all - res + mod) % mod);
        return 0;
    }
    Just_DOIT(); int left = 0, right = 0;
    for (int i = 1; i <= m; i++) {
        bool flag = true;
        for (int j = 1; j < i; j++) 
            if (A[j] == A[i]) {
                flag = false; break;
            }
        if (!flag) {
            left = i - 1; break;
        }
    } 
    for (int i = 0; i + m <= n; i++) 
        hh[i] = Make_Your_Dream_COMETRUE(i, left);
    for (int i = 1; i <= m; i++) {
        bool flag = true;
        for (int j = m - i + 2; j <= m; j++)
            if (A[m - i + 1] == A[j]) {
                flag = false; break;
            }
        if (!flag) {
            right = i - 1; break; 
        }
    }
    int res = all;
    for (int i = 0; i + m <= n; i++) 
        res = (res - (LL)hh[i] * Make_Your_Dream_COMETRUE(n - i - m, right) % mod + mod) % mod;
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 80512
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(a*b > c*d) cout << a*b << endl;
	else if(a*b < c*d) cout << c*d << endl;
	else cout << a*b << endl;
 	return 0;
}

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

int main()
{
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int tot = 0;
    if(2*c <= a + b){
        tot += 2*c*min(x, y);
        if(x > y){
            x -= y;
            tot += min(2*c*x, a*x);
        }
        else if(y > x){
            y -= x;
            tot += min(2*c*y, b*y);
        }
    }
    else tot += a*x + b*y;
    cout << tot << endl;
    return 0;
}


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

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n, k;
    cin >> n >> k;
    int ans = 1;
    for (int i = 0; i < n; i++)
    {
        ans = min(ans + k, ans * 2);
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 256
from itertools import product
N,M=map(int, input().split())
inlist=[list(map(int, input().split())) for _ in range(N)]
res=0
for i,j,k in product([1, -1],[1, -1],[1, -1]): res = max(res, sum(sorted(map(lambda x: i*x[0]+j*x[1]+k*x[2], inlist), reverse=True)[:M]))
print(res)


Measured memory_bytes: 3384
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <string>
#include <stack>
#include <tuple>

using namespace std;
typedef long long ll;
ll MOD = 1e9 + 7;

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    vector<int> t(n);
    for (int i = 0; i < n; i++) cin >> t[i];
    int ans = 0;
    for (int i = 0; i < n; i++) if (t[i] < a || t[i] >= b) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
program main;
var
  n, i, t : longint;
  approved : boolean;

begin
  readln(n);
  approved := true;
  for i := 1 to n do begin
    read(t);
    if (t mod 2 = 0) and not((t mod 3 = 0) or (t mod 5 = 0)) then
      approved := false;
  end;
  readln;
  if approved then writeln('APPROVED')
  else writeln('DENIED');
 
end.

Measured memory_bytes: 1376
input = gets.chomp.split
n = input[0].to_i
k = input[1].to_i

sum = 0.0
for i in 1..n do
    if i >= k 
        sum += 1.0/n
    else
        e = Math.log2(k.to_f/i).ceil
        sum += 0.5**e /n
    end
end

puts sprintf("%.12f",sum)

Measured memory_bytes: 1788
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#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 <ctime>
#include <string>

typedef long long ll;
using namespace std;
const int MAX_N=1e5+1;
const int MAX_Q=1e5+1;
ll MAX_q=1e18+1;
ll a[MAX_N];
ll t[MAX_N];

int binsearch(vector<ll> x,ll y,int z){
    int l=-1,r=z,mid;
    while(r-l>1){
        mid=(l+r) / 2;
        if(y >= x[mid]) l=mid;
        else  r = mid;
    }
    return r;
}

int main(){
    int N;
    int Q;
    cin>>N>>Q;
    vector<ll> q;
    q.push_back(N);
    for(int i =0;i<Q;i++) {
        ll x;
        cin>>x;
        while(!q.empty() && q.back() >= x) q.pop_back();
        q.push_back(x);
    }

    int L = q.size() - 1;
    t[L] = 1;

    for(int i = L;i >0;i--){
        ll k=q[i];
        while(k>q[0]){
            int ind=lower_bound(q.begin(),q.end(),k)-q.begin()-1;
            t[ind]+=t[i]*(k/q[ind]);
            k=k%q[ind];
        }
        a[k-1]+=t[i];
    }
    a[q[0]-1] += t[0];
    for(int i=N-1;i>=0;i--) a[i]+=a[i+1];
    for(int i=0;i<N;i++) cout<<a[i]<<endl;    
    return 0;
};


Measured memory_bytes: 4212
//by kcz 1552920354@qq.com
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
using namespace std;

template <typename T> void chmin(T&x,const T &y)
{
	if(x>y)x=y;
}
template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
typedef long long s64;
typedef unsigned long long u64;
typedef unsigned int u32;
typedef pair<int,int> pii;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define pb push_back
#define gc (c=getchar())
int read()
{
	char c;
	while(gc<'-');
	if(c=='-')
	{
		int x=gc-'0';
		while(gc>='0')x=x*10+c-'0';
		return -x;
	}
	int x=c-'0';
	while(gc>='0')x=x*10+c-'0';
	return x;
}
#undef gc

int main()
{
	//freopen("1.in","r",stdin);//freopen("1.out","w",stdout);
	int n,k;
	cin>>n>>k;
	cout<<1+(n-k+k-2)/(k-1);
}



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

typedef long long ll;

int N;
ll A[202];
string s;

ll B[62];

void solve(){
	bool ret=true;
	for(int i=0;i<62;i++){
		B[i]=0;
	}
	for(int i=N-1;i>=0;i--){
		if(s[i]=='0'){
			for(int j=61;j>=0;j--){
				if((A[i]>>j)&1LL){
					if(B[j]==0){
						B[j]=A[i];
						break;
					}
					else A[i]^=B[j];
				}
			}
		}
		else {
			for(int j=61;j>=0;j--){
				if((A[i]>>j)&1LL){
					if(B[j]==0){
						ret=false;
						break;
					}
					else A[i]^=B[j];
				}
			}
		}
	}
	if(ret)puts("0");
	else puts("1");
}

int main(){
	int T;
	scanf("%d",&T);
	for(;T>0;T--){
		scanf("%d",&N);
		for(int i=0;i<N;i++)scanf("%lld",&A[i]);
		cin>>s;
		solve();
	}
}



Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
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; }
ll k;
ll mod_pow(ll x,ll n){
	ll res = 1;
	while(n > 0){
		if(n & 1){
			res = res * x %(k*9);
		}
		x = x * x %(k*9);
		n >>= 1;
	}
	return res;
}
int main(){
	cin>>k;
	for(int i = 1; i <= k; i++) {
		// cout << i << endl;
		if (7 * ((mod_pow(10,i) - 1)) % (9 * k) == 0){
			cout << i << endl;
			return 0;
		} 
	
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 3668
in_all = list(map(int, input().split()))

total = 0
for n in range(1, in_all[0]+1):
    tmp = str(n)
    all = 0
    for t in tmp:
        all += int(t)
    if all>=in_all[1] and all<=in_all[2]:
        total += int(tmp)

print(total)

Measured memory_bytes: 3060
// g++ -std=c++11 temp.cpp
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define EACH(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3

#define MAX_N 1000

int n;

int main(){
	cin>>n;
	cout<<n*(n+1)/2<<endl;
	return 0;
}




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

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'

int x;

int main()
{
	IOS;
	set<int> s;
	cin >> x;
	s.insert(x);
	for (int i = 0; i < 1e9; i++) {
		if (x % 2 == 0)
			x /= 2;
		else 
			x = 3 * x + 1;
		if (s.count(x)) {
			cout << i + 2 << endl;
			break;
		}
		else 
			s.insert(x);
	}
	return 0;
}



Measured memory_bytes: 256
#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 int 		long long
#define vi 			vector<int>
#define vec(x) 		vector<x>
#define matrix 		vector<vector<int>>
#define pii 		pair<int,int>
#define rep(i,s,e)  for(int i=s;i<e;i++)
#define rrep(i,e,s) for(int i=e;i>=s;i--)
#define MOD			1000000007
#define pb 			push_back
#define ff 			first
#define ss 			second		
#define w(x)		int x; cin>>x; while(x--)
const int INF=1e18;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
// find_by_order(k-1)  returns iterator to kth element starting from 0; Returns the kth smallest element
// order_of_key(k) returns count of elements strictly smaller than k;Returns the number of elements less than k
// erase,insert same as normal set


void solve(){
	int n,k;
	cin>>n>>k;
	int x=n;
	if(k<n){
		int val=ceil(double(n)/double(k));
		val-=1;
		x=n-val*k;
	}

	//trace(x,k);
	int ans=INF;
	for(int i=0;i<1000000;i++){
		ans=min(ans,abs(k-x));
		x=abs(k-x);
	}

	cout<<ans<<endl;
}
 
int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt","r",stdin);
// 	freopen("output.txt","w",stdout);
// #endif
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}


Measured memory_bytes: 384