akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    vector<string> ansv;
    cin >> s >> t;
    FORR(i, s.size() - t.size(), 0){
        string sub = s.substr(i, t.size());
        REP(j, sub.size()){
            if(sub[j] == '?' || sub[j] == t[j]){
                if(j == sub.size() - 1){
                    string ans = s;
                    REP(k, ans.size()){
                        if(i <= k && k < i + t.size()) ans[k] = t[k - i];
                        if(ans[k] == '?') ans[k] = 'a';
                    }
                    ansv.push_back(ans);
                }
            }else{
                break;
            }
        }
    }

    if(ansv.size() == 0){
        cout << "UNRESTORABLE" << "\n";
    }else{
        sort(ALL(ansv));
        cout << ansv.front() << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m,k = inpl()
a = inpl()
b = inpl()
A = [0]
B = [0]
for i in range(n):
    A.append(A[-1] + a[i])
for i in range(m):
    B.append(B[-1] + b[i])

res = 0
for i in range(n+1):
    rem = k-A[i]
    if rem < 0:
        break
    can = bisect_right(B,rem)
    # print(i,rem,can)
    res = max(res, can + i-1)
print(res)


Measured memory_bytes: 135808
import functools

import sys
import functools

sys.setrecursionlimit(100000)


def f(r, i):
    # return (r ** (i + 1) - r) / (r - 1)
    return r ** i


@functools.lru_cache(maxsize=None)
def solve(N, size):
    if size == -1:
        return N
    b = C[size]
    if N - b >= 0:
        return min(solve(N - b, size) + 1, solve(N, size - 1))
    else:
        return solve(N, size - 1)


if __name__ == "__main__":
    max_N = 10_0000
    N = int(input())

    A = [f(6, i) for i in range(1, 7) if f(6, i) <= N]
    B = [f(9, i) for i in range(1, 7) if f(9, i) <= N]
    C = A + B
    C.sort(reverse=True)
    print(solve(N, len(C) - 1))


Measured memory_bytes: 250244
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N = I()
s = str(input())

# 0:羊  1:狼
a = [-1]*N
A1,A2,A3,A4 = a[:],a[:],a[:],a[:]

def check(A):
    for i in range(1,N):
        now = 0 if s[i] == 'o' else 1
        temp = A[i-1] ^ A[i] ^ now
        if 1 <= i <= N-2:
            A[i+1] = temp
        else:
            if temp != A[0]:
                return
    now = 0 if s[0] == 'o' else 1
    if A[N-1] ^ A[0] ^ A[1] ^ now:
        return
    return A

A1[0],A1[1] = 0,0
A2[0],A2[1] = 0,1
A3[0],A3[1] = 1,0
A4[0],A4[1] = 1,1

ans = []
ans.extend([check(A1),check(A2),check(A3),check(A4)])
for x in ans:
    if x is not None:
        x = map(str,x)
        print(''.join(x).replace('0','S').replace('1','W'))
        exit()

print(-1)

Measured memory_bytes: 53488
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }

    if(n == 1) {
        cout << 1 << endl;
        return 0;
    }

    ll l = 0, r = 1;
    ll now = a[0];
    ll ans = 0;
    while(1) {

        if((now ^ a[r]) == (now + a[r])) {
            now += a[r];
            r++;
        }
        else {
            ans += r-l;
            now -= a[l];
            l++;
        }

        if(r == n) {
            ans += (n-l)*(n-l+1)/2LL;
            break;
        }
    }

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

Measured memory_bytes: 1024
n,d = map(int,input().split())
x = [list(map(int,input().split())) for i in range(n)]
ans = 0
for i in range(n):
    for j in range(n):
        if i == j: continue
        counter = 0
        for k in range(d):
            diff = abs(x[i][k] - x[j][k])
            counter += diff ** 2
        ok = False
        for k in range(10000):
            if k * k == counter: ok = True
        if ok: ans += 1
print(ans // 2)

Measured memory_bytes: 9144
import sys

if __name__ == '__main__':
    N, Y = list(map(int, sys.stdin.readline().split()))

    for i in range(N+1):
        for j in range(0, N+1):
            k = N - i - j
            if k < 0:
                continue
            sum = i * 10000 + j * 5000 + k * 1000
            if sum == Y:
                print(i, j, k)
                exit()
    print('-1 -1 -1')


Measured memory_bytes: 2940
N, M = map(int, input().split())
AB = []

for i in range(N):
    a,b = map(int, input().split())
    AB.append([a,b])

AB.sort()
ans = 0
count = 0

for i in range(N):
    count+=AB[i][1]
    if count > M:
        count-=AB[i][1]
        n = M-count
        ans += AB[i][0]*n
        break
    else:
        ans += AB[i][0]*AB[i][1]
    
print(ans)
    



Measured memory_bytes: 20064
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
ll INF = 10000000000 ;
//long double pie = acos(-1) ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

void bfs(vvc &g,vvll &cnt,int i,int j,queue<ll> &q){
	int d = cnt.at(i).at(j) ;
	if(cnt.at(i-1).at(j)>d+1&&g.at(i-1).at(j)=='.'){
		cnt.at(i-1).at(j) = d+1 ;
		q.push(i-1) ; q.push(j) ;
	}
	if(cnt.at(i+1).at(j)>d+1&&g.at(i+1).at(j)=='.'){
		cnt.at(i+1).at(j) = d+1 ;
		q.push(i+1) ; q.push(j) ;
	}
	if(cnt.at(i).at(j+1)>d+1&&g.at(i).at(j+1)=='.'){
		cnt.at(i).at(j+1) = d+1 ;
		q.push(i) ; q.push(j+1) ;
	}
	if(cnt.at(i).at(j-1)>d+1&&g.at(i).at(j-1)=='.'){
		cnt.at(i).at(j-1) = d+1 ;
		q.push(i) ; q.push(j-1) ;
	}
	if(q.empty()) return ;
	i = q.front() ; q.pop() ;
	j = q.front() ; q.pop() ;
	bfs(g,cnt,i,j,q) ;
}

int main(){
	ll h,w ;
	cin >> h >> w ;
	ll sub = 0 ;
	queue<ll> q ;
	vvc g(h+2,vc(w+2,'#')) ;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin >> g.at(i).at(j) ;
			if(g.at(i).at(j)=='#') sub++ ;
		}
	}
	vvll cnt(h+2,vll(w+2,INF)) ;
	cnt.at(1).at(1) = 0 ;
	bfs(g,cnt,1,1,q) ;
	if(cnt.at(h).at(w)==INF) cout << -1 << endl ;
	else cout << h*w-sub-cnt.at(h).at(w)-1 << endl ;
}


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

long long min(long long x,long long y){
	if(x<y)return x;
	return y;
}

long long C(long long p,long long q){
	if(q==0 || p==q)return 1;
	if(q>p/2)q=p-q;
	long long ans=1;
	for(long long i=1;i<=q;i++){
		ans*=p-i+1;
		ans/=i;
	}
	return ans;
}

int compare(const void *a, const void *b){
	long long int *A = (long long int *)a;
	long long int *B = (long long int *)b;
	if (*A < *B) return 1;
	if (*A > *B) return -1;
	return 0;
}

int main(){
	long long N,A,B,i,j,ans=0;
	scanf("%lld%lld%lld",&N,&A,&B);
	long long v[N];
	for(i=0;i<N;i++)scanf("%lld",&v[i]);
	long long max=0;
	
	qsort(v,N,sizeof(long long),compare);
	
	for(j=0;j<A;j++)max+=v[j];
	j--;
	
	long long req=A;
	long long count=0;
	for(i=0;i<N;i++){
		if(v[i]>v[j])req--;
		if(v[i]==v[j])count++;
	}
	
	if(v[0]==v[j]){
		B=min(B,count);
		for(i=A;i<=B;i++)ans+=C(count,i);
		printf("%lld\n%lld\n",v[0],ans);
		return 0;
	}
	
	
	ans+=C(count,req);
	
	long long ans1=max/A;
	long long ans2=max%A;
	int ans3=(int)ans2;
	double ans4=(double)ans3/A;
	long long ans5=ans1%10;
	int ans6=(int)ans5;
	ans4+=ans6%10;
	ans1-=ans1%10;
	ans1/=10;
	if(ans1==0)printf("%lf\n",ans4);
	else printf("%lld%lf\n",ans1,ans4);
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

int insertion_sort(vector<int> *vec, int n, int g)
{
	auto cnt = 0;
	for (int i=g; i<n; i++) {
		int v = (*vec)[i];
		int j = i - g;
		while (j >= 0 && (*vec)[j] > v) {
			(*vec)[j+g] = (*vec)[j];
			j -= g;
			cnt++;
		}
		(*vec)[j+g] = v;
	}
	return cnt;
}

void shell_sort(vector<int> vec, int n)
{
	int cnt=0, m = 1;
	vector<int> g = {1};
	while (2*g.back()+1 < n) {
		m++;
		g.push_back(2*g.back()+1);
	}

	for (int i=m-1; i>=0; i--)
		cnt += insertion_sort(&vec, n, g[i]);
	
	cout << m << endl;
	for (int i=m-1; i>0; i--)
		cout << g[i] << " ";
	cout << g[0] << endl
	     << cnt << endl;
	for (int i=0; i<n; i++)
		cout << vec[i] << endl;
}

int main(void)
{
	int n;
	vector<int> vec;
	cin >> n;
	for (int i=0; i<n; i++) {
		int x;
		cin >> x;
		vec.push_back(x);
	}

	shell_sort(vec, n);

	return 0;
}

Measured memory_bytes: 9132
#include <iostream>
#include <vector>
using namespace std;
 
int main(){
  int n, m; cin >> n >> m;
  double sum = 0;
  int a[n];
  for(int i=0; i< n; i++){
    cin >> a[i];
    sum += a[i];
  }
  int res = 0;
  for(int i=0; i<n; i++){
    if(a[i] >= sum/(4*m)) res++;
  }
  
  if(res >= m) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    string S, T;
    cin >> S >> T;

    int ans = 0;
    rep(i, S.size()) {
        if (S[i] != T[i]) ans++;
    }

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

Measured memory_bytes: 3912
#include<stdio.h>
#include<string.h>
#define MAX 1001

int max(int a,int b){
 if(a>b)return a;

return b;
}


int LCS(char X[],char Y[]){
int i,j;
int A[strlen(X)+1];
int B[strlen(X)+1];

for(i=0;i<strlen(X)+1;i++){A[i]=0;B[i]=0;}


for(i=0;i<strlen(Y);i++){

 if(i%2==0){
   for(j=0;j<strlen(X);j++){
     if(X[j]==Y[i])B[j+1]=A[j]+1;
     else B[j+1]=max(A[j+1],B[j]);
   }
 }

 if(i%2==1){
   for(j=0;j<strlen(X);j++){
     if(X[j]==Y[i])A[j+1]=B[j]+1;
     else A[j+1]=max(B[j+1],A[j]);
   }
 }


}

return max(A[strlen(X)],B[strlen(X)]);

}

int main(){
char X[MAX];
char Y[MAX];
int x;
int n,i;

scanf("%d",&n);

for(i=0;i<n;i++){

 scanf("%s",X);
 scanf("%s",Y);

 x=LCS(X,Y);

 printf("%d\n",x);

}

return 0;
}


Measured memory_bytes: 2100
#include<stdio.h>
static const int N=100;

int main(){
  int M[N][N];
  int n,u,k,v;

  scanf("%d",&n);
  
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      M[i][j]=0;
    }
  }
  

  for(int i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(int j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j)printf(" ");
      printf("%d",M[i][j]);
    }
    printf("\n");
  }
  
  return 0;
}



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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

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

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

int main(){
#define int ll
  while(1){
    int n; cin >> n; if(n == 0) break;
    
    int m; cin >> m;
    vector<vector<pii>> origin(8,vector<pii>(m));
    rep(i,m){
      cin >> origin[0][i].fst >> origin[0][i].snd;
    }
    rep(i,m-1){
      origin[0][i+1].fst -= origin[0][0].fst;
      origin[0][i+1].snd -= origin[0][0].snd;
    }
    vector<function<pii(pii)>> f(3);
    f[0] = [](pii p){ return pii(-p.snd, p.fst); };
    f[1] = [](pii p){ return pii(-p.fst, -p.snd); };
    f[2] = [](pii p){ return pii(p.snd, -p.fst); };
    rep(i,3) rep(j,m){
      origin[i+1][j] = f[i](origin[0][j]);
    }

    rep(i,n){
      int l; cin >> l;
      vector<pii> tmp1(l), tmp2(l);
      rep(j,l){
	cin >> tmp1[j].fst >> tmp1[j].snd;
	tmp2[l-1-j] = tmp1[j];
      }
      if(l != m) continue;
      rep(j,l-1){
	tmp1[j+1].fst -= tmp1[0].fst;
	tmp1[j+1].snd -= tmp1[0].snd;
	tmp2[j+1].fst -= tmp2[0].fst;
	tmp2[j+1].snd -= tmp2[0].snd;
      }
      bool flag1 = false;
      rep(j,4){
	bool flag2 = true;
	rep(k,l-1)
	  if(tmp1[k+1].fst != origin[j][k+1].fst or tmp1[k+1].snd != origin[j][k+1].snd) flag2 = false;
	if(flag2){
	  flag1 = true;
	  //cout << "1 " << j << endl;
	}
      }
      rep(j,4){
	bool flag2 = true;
	rep(k,l-1)
	  if(tmp2[k+1].fst != origin[j][k+1].fst or tmp2[k+1].snd != origin[j][k+1].snd) flag2 = false;
	if(flag2){
	  flag1 = true;
	  //cout << "2 " << j << endl;
	}
      }
      if(flag1) cout << i + 1 << endl;
    }
    cout << "+++++" << endl;
  }
}


Measured memory_bytes: 3096
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var r = n
    for (i in 0..n) {
        var count = 0

        var t = i
        while (t > 0) {
            count += t % 6
            t /= 6
        }

        t = n - i
        while (t > 0) {
            count += t % 9
            t /= 9
        }

        r = Math.min(r, count)
    }
    println(r)
}

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

int main() {
  int N;
  int M;

  cin >> N >> M;

  vector<int> a(M);
  vector<int> b(M);

  for (int i = 0; i < M; i++){
    cin >> a.at(i) >> b.at(i);
  }

  vector<int> count(N);
  for (int i = 0; i < M; i++){
    count.at(a.at(i)-1)++;
    count.at(b.at(i)-1)++;
  }

  for (int i = 0; i < N; i++){
    cout << count.at(i) << endl;
  }
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;

constexpr char newl = '\n';

ll calc(ll x) {
    ll res = 1;
    while (x % 2 == 0) {
        x /= 2;
        res *= 2;
    }

    while (x % 5 == 0) {
        x /= 5;
        res *= 5;
    }
    return res;
}

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

    int n;
    cin >> n;

    map<P, ll> cnt;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;

        ll a = 0, b = 1;
        bool f = false;
        for (char c : s) {
            if (c == '.') {
                f = true;
                continue;
            }

            a = 10 * a + (c - '0');
            if (f) b *= 10;
        }

        ll g = __gcd(a, b);
        a /= g;
        a = calc(a);
        b /= g;
        b = calc(b);
        ++cnt[P(a, b)];
    }

    vector<P> v;
    v.reserve(cnt.size());
    for (auto& p : cnt) {
        v.push_back(p.first);
    }
    int sz = v.size();

    ll ans = 0;
    for (int i = 0; i < sz; i++) {
        P p1 = v[i];
        for (int j = 0; j <= i; j++) {
            P p2 = v[j];
            if (p2.first % p1.second == 0 && p1.first % p2.second == 0) {
                ll tmp = cnt[p1] * cnt[p2];
                if (i == j) {
                    tmp -= cnt[p1];
                    tmp /= 2;
                }
                ans += tmp;
            }
        }
    }
    cout << ans << newl;
    return 0;
}

Measured memory_bytes: 3640
//*****Jai Mata di*****//

#include<bits/stdc++.h>
using namespace std;
#define Nitroboost  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int 
const int mod=1e9+7;
const int N=1e5+15;
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

vector<int>adj[N];
int d[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
int h[N];

int main()
{
    Nitroboost;
    int n;
    cin>>n;
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        if(i%2 && x%2)
            cnt++;
            
    }
    
    cout<<cnt;
}

Measured memory_bytes: 5808
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
 
using namespace std;
 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
 
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
 
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
 
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
 
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



int main(){
  int N,Q;
  string s;
  cin >> N >> Q >> s;
  int l[Q],r[Q];
  rep(i,Q) cin >> l[i] >> r[i];

  int cnt[N];
  cnt[0]=0;
  int ans = 0;
  for(int i = 1; i < N; i++){
    if(s.substr(i-1,2) == "AC") ans++;
    cnt[i] = ans;
  }
  
  rep(i,Q) cout << cnt[r[i]-1] - cnt[l[i]-1] << endl;
  
  return 0;
}

  
                           



Measured memory_bytes: 2176
import sys
from collections import deque

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() # input string
ni = lambda: int(readline().rstrip()) # input int
nm = lambda: map(int, readline().split()) # input multiple int 
nl = lambda: list(map(int, readline().split())) # input multiple int to list

ans = []
s = ns()
n = len(s) + 1
now = 0
min_now = 0

ri = deque()
le = deque()

now = 0
for i in range(n-1):
    if s[i] == '<':
        now += 1
    else:
        now = 0
    le.append(now)
now = 0
for i in range(n-1):
    if s[(n-2)-i] == '>':
        now += 1
    else:
        now = 0
    ri.appendleft(now)
le.appendleft(0)
ri.append(0)

for i in range(n):
    ans.append(max(le.popleft(), ri.popleft()))

print(sum(ans))

Measured memory_bytes: 96712
# -*- coding: utf-8 -*-
import sys
import math


def main():
    N,K = list(map(int, sys.stdin.readline().split()))
    A_list = list(map(int, sys.stdin.readline().split()))


    def check(length :int) -> bool:
        cnt = 0

        for a in A_list:
            if a >= length:
                divide = math.ceil(a / length)
                cnt += (divide - 1)
        
        return (True if cnt <= K else False)


    L = 0            # the minimum length
    R = max(A_list)  # the maximum length

    while (R - L) > 1:
        M = L + (R - L) // 2

        if check(M):
            R = M
        else:
            L = M


    print(R)


if __name__ == "__main__":
    main()


Measured memory_bytes: 30908
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
int main()
{
    int n;
    cin >> n;

    vector<double> v;
    for (int i=0; i < n; i++)
    {
        int val;
        cin >> val;
        v.push_back(val);
    }

    std::sort(v.begin(), v.end());
    auto value = std::accumulate(v.begin(), v.end(), v[0], [](double a, double b)
    {
        return a / 2 + b / 2;
    });

    cout << value << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i,j,k,l,n,cnt;
	while(scanf("%d",&n)!=EOF) {
		cnt=0;
		for(i=0;i<=9;i++) {
			for(j=0;j<=9;j++) {
				for(k=0;k<=9;k++) {
					for(l=0;l<=9;l++) {
						if(i+j+k+l == n) {
							cnt++;
						}
					}
				}
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	long long a, b;
	cin >> a >> b;
	for (int i = 1; i < n; i++) {
		long long x, y;
		cin >> x >> y;
		long long k = max((a + x - 1) / x, (b + y - 1) / y);
		a = x * k;
		b = y * k;
	}
	cout << a + b << endl;
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
using namespace std;
int main() {
    char ch;
    while(true) {
        scanf("%c", &ch);
        if(isalpha(ch)) {
            if(islower(ch)) printf("%c", toupper(ch));
            else if(isupper(ch)) printf("%c", tolower(ch));
        } else {
            printf("%c", ch);
        }
        if(ch == '\n') break;
    }
    return 0;
}


Measured memory_bytes: 2596
#include<bits/stdc++.h>
#define N 1005
using namespace std;

int n,m,d[35],x[N],y[N];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&x[i],&y[i]);
		if(((x[i]+y[i])&1)!=((x[1]+y[1])&1)){puts("-1");return 0;}
	}
	for(int i=30;~i;i--) d[++m]=1<<i;
	if(!((x[1]+y[1])&1)) d[++m]=1;
	printf("%d\n",m);
	for(int i=1;i<=m;i++) printf("%d ",d[i]);puts("");
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(abs(x[i])>abs(y[i]))
			{
				if(x[i]<0) x[i]+=d[j],putchar('L');
				else x[i]-=d[j],putchar('R');
			}
			else
			{
				if(y[i]<0) y[i]+=d[j],putchar('D');
				else y[i]-=d[j],putchar('U');
			}
		}
		puts("");
	}
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] abc = {111, 222, 333, 444, 555, 666, 777, 888, 999, 1111};
        for(int i=0; i<abc.length;i++){
            if(n <= abc[i]){
                System.out.println(abc[i]);
                return;
            }
        }
    }
}

Measured memory_bytes: 21716
n = gets.chomp
len = n.length

kouho_1 = Array.new(len,0).map.with_index{|n,i| i % 2 == 0? n = 1 : n = 0}
kouho_2 = Array.new(len,0).map.with_index{|n,i| i % 2 == 0? n = 0 : n = 1}

diff1 = 0
diff2 = 0

kouho_1.each_with_index do |a,i|
  if a.to_s != n[i]
    diff1 += 1
  end
end

kouho_2.each_with_index do |a,i|
  if a.to_s != n[i]
    diff2 += 1
  end
end

puts diff1 >= diff2 ? diff2 : diff1

Measured memory_bytes: 5116
import collections


for t in range(int(input())):
    res = collections.defaultdict(int)
    s = input()
    for i in range(len(s)-1):
        s1 = s[:i+1]
        s2 = s[i+1:]

        res[s1+s2] += 1
        res[s1[::-1]+s2] += 1
        res[s1+s2[::-1]] += 1
        res[s1[::-1]+s2[::-1]] += 1

        res[s2+s1] += 1
        res[s2[::-1]+s1] += 1
        res[s2+s1[::-1]] += 1
        res[s2[::-1]+s1[::-1]] += 1

    print(len(res))

Measured memory_bytes: 7996
#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()

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 N; cin >> N;
    pl data[N];
    set<pl> included;
    F0R(i, N) {
    	ll A, B; cin >> A >> B;
    	data[i] = mp(A, B);
    	included.insert(mp(A, B));
    }
    int ans = N;
    F0R(a, N) {
    	FOR(b, a+1, N) {
    		ll p = data[b].f - data[a].f; ll q = data[b].s - data[a].s;
    		int cur = 0;
    		//cout << "pq " << p << " " << q << endl;
    		F0R(i, N) {
    			//cout << data[i].f - p << " " << data[i].s - q << " " << included.count(mp(data[i].f-p, data[i].s-q)) << endl;
    			if (!included.count(mp(data[i].f - p, data[i].s - q))) {
    				cur++;
    			}
    		}
    		if (cur < ans) ans = cur;

    	}
    }

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

// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 256
use std::io::{stdin, Read};

fn main() {
    let mut input: String = String::new();
    stdin().read_line(&mut input).unwrap();
    let input = input.trim().parse::<i32>().unwrap();
    assert!(input >= 1 && input <= 32);
    let arr: [i32; 32] = [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];
    println!("{}", arr[input as usize-1]);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

tuple<string, int, string> d(const string& s) {
  int c = 0, n = s.size();
  for (int i = 0; i < n; ++i) {
    c += s[i] == '(';
    c -= s[i] == ')';
    if (!c) {
      int j = i;
      while (s[j] != ']') ++j;

      return make_tuple(s.substr(1, i - 1), stoi(s.substr(i + 2, j - i - 2)), s.substr(j + 2, n - j - 3));
    }
  }
}
string fn(const string& s, const string& t) {
  if (s.empty() or t.empty()) return "";
  string sl, sr, tl, tr;
  int sm, tm;
  tie(sl, sm, sr) = d(s);
  tie(tl, tm, tr) = d(t);
  return '(' + fn(sl, tl) + ")[" + to_string(sm + tm) + "](" + fn(sr, tr) + ')';
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  string s, t; cin >> s >> t;
  cout << fn(s, t) << '\n';
}


Measured memory_bytes: 3408
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int M = GetInt();
		int D = GetInt();
		
		int ans = 0;
		for(int i = 1; i <= M; i++)
		{
			for(int j = 1; j <= D; j++)
			{
				int d1 = j % 10;
				int d2 = j / 10;
				if(d1 >= 2 && d2 >= 2 && i == d1 * d2)
					ans++;
			}
		}
		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
}


Measured memory_bytes: 13140
import java.util.*;
 
public class Main {
  public static void main(String[] args ){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    if(N%2==0){
    System.out.println(N/2);
    }
   else{
     System.out.println(N/2+1);
   }
  }
}

Measured memory_bytes: 21972
n=int(input())
a=list(input())
r=[0]*n
g=[0]*n
b=[0]*n
for i in range(n):
  if i==0:
    if a[n-1-i]=='R':
      r[n-1-i]=1
    elif a[n-1-i]=='G':
      g[n-1-i]=1
    else:
      b[n-1-i]=1
  else:
    if a[n-1-i]=='R':
      r[n-1-i]=r[n-i]+1
      g[n-1-i]=g[n-i]
      b[n-1-i]=b[n-i]
    elif a[n-1-i]=='G':
      r[n-1-i]=r[n-i]
      g[n-1-i]=g[n-i]+1
      b[n-1-i]=b[n-i]
    else:
      r[n-1-i]=r[n-i]
      g[n-1-i]=g[n-i]
      b[n-1-i]=b[n-i]+1

count=0
if n==1:
  print(0)
elif n==2:
  print(0)
else:
  for i in range(n-2):
    for j in range(i+1,n-1):
      if a[i]!=a[j] and 2*j-i<n and a[i]!=a[2*j-i] and a[j]!=a[2*j-i]:
        if a[i]!='R' and a[j]!='R':
          count+=r[j+1]-1
        elif a[i]!='G' and a[j]!='G':
          count+=g[j+1]-1
        else:
          count+=b[j+1]-1
      elif a[i]!=a[j]:
        if a[i]!='R' and a[j]!='R':
          count+=r[j+1]
        elif a[i]!='G' and a[j]!='G':
          count+=g[j+1]
        else:
          count+=b[j+1]
  print(count)
      


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

using ll = long long;
using Pii = std::pair<int, int>;
using Pll = std::pair<ll, ll>;

const ll INF = (ll)1e11;

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    ll r, D, x;
    cin >> r >> D >> x;
    
    for (int i = 0; i < 10; ++i) {
        cout << (x = r * x - D) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
s = input()
c = set()
for i in range(len(s)):
  c.add(s[i])
c = list(c)
c.sort()
abc = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
ans = ''
for e in abc:
  if e not in c:
    ans = e
    break
if ans == '':
  ans = 'None'
print(ans)

Measured memory_bytes: 3188
n = int(input())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
cl = list(map(int, input().split()))

satis = 0
a_ = 0
for i in range(n):
    a = al[i]
    satis += bl[a-1]
    if i != 0:
        if a_ + 1 == a:
            satis += cl[a_-1]
    a_ = a

print(satis)

Measured memory_bytes: 3064
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	int ans = 0;
	int ac = 0;
	vector<int>v(N + 1);
	for (int i = 0; i < M; i++) {
		cin >> K;
		string s;
		cin >> s;
		if (v[K]<0)continue;
		if (s[0] == 'A') {
			ac++;
			ans += v[K];
			v[K] = -1;
		}
		else v[K]++;
	}
	cout <<ac<<" "<< ans << endl;
	return 0;
}

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

int main() {
	int tmp, n, t, a[100000], min_arr[100000];
	
	cin >> n >> t;

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

	tmp = a[0];
	min_arr[0] = a[0];
	for (int i = 1; i < n; i++) {
		min_arr[i]=min(tmp, a[i]);
		if (a[i] < tmp) { 
			tmp = a[i]; 
		}
	}

	
	for (int i = 0; i < n; i++) {
		a[i] = a[i] - min_arr[i];
	}
	
	
	int maxx = 0;
	for (int i = 0; i < n; i++) {
		maxx = max(maxx, a[i]);
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (maxx == a[i]) {
			ans++;
		}
	}

	cout << ans << endl;
	

	return 0;
}

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

int		main(void)
{
	vector<bool> check(26, false);
	string ABC = "abcdefghijklmnopqrstuvwxyz";
	string s;

	cin >> s;
	for (int i = 0; i < s.size(); i++)
	{
		int idx = s[i] - 97;

		check[idx] = true;
	}
	for (int i = 0; i < 26; i++)
	{
		if (check[i] == false)
		{
			cout << ABC[i] << endl;
			return (0);
		}
	}
	cout << "None" << endl;
}



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

int main() {
  string P, Q, R, A, ans;
  cin >> P >> Q >>R;
  A=Q.at(0);
  ans="A"+A+"C";
  cout << ans << endl;
}


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

int main() {
    long long r,d,x2,x;
    cin>>r>>d>>x2;x=x2;
    for(int i=1;i<=10;i++){
        long long ans=(r*x)-d;
        cout<<ans<<endl;
        x=ans;
    }
}

Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int main() {
   int K, X;
   cin >> K >> X;
   if (K> 100 or X > 100) cout << "Invalid Inputs";
   if (K<1 or X < 0) cout << "Invalid Inputs";
   for (int i=1; i<=K; i++) {
       cout << X-K +i;
       cout << " ";
   }
       for (int i=1; i<K; i++) {
       cout << X+i;
       cout << " ";
   }
   
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    ll r;

    cin >> r;

    cout << 3 * r * r << endl;
}

Measured memory_bytes: 256
result = 'NO'
 
nums_array = gets.split(' ')
if nums_array.size == 3 then
  nums_hash = nums_array.group_by(&:itself)
  if nums_hash['7'] != nil && nums_hash['7'].size == 1 then
    if nums_hash['5'] != nil && nums_hash['5'].size == 2 then
      result = 'YES'
    end
  end
end
puts result

Measured memory_bytes: 1788
from collections import defaultdict

n, m = map(int, input().split())
needs = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
usable = defaultdict(lambda: 0)
for a in map(int, input().split()):
    na = needs[a]
    usable[na] = max(usable[na], a)
use_keys = sorted(usable.keys())

dp = [-1] * (n + 8)
dp[0] = 0
for a in sorted(usable.values(), reverse=True):
    na = needs[a]
    for i in range(n + 1):
        if dp[i] == -1:
            continue
        dp[i + na] = max(dp[i + na], dp[i] * 10 + a)

print(dp[n])


Measured memory_bytes: 17008
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define M 1000000007

ll x[100010],y[100010];
ll n,m;
int main(){
	scanf("%lld%lld",&n,&m);
	rep(i,0,n)scanf("%lld",x+i);
	rep(i,0,m)scanf("%lld",y+i);

	ll xx=0,yy=0;
	rep(i,1,n)xx=(xx+(x[i]-x[i-1])*i%M*(n-i)%M)%M;
	rep(i,1,m)yy=(yy+(y[i]-y[i-1])*i%M*(m-i)%M)%M;
	
	printf("%lld\n",xx*yy%M);
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b+1;i++)
#define Per(i,b,a) for(int i=b;i>=a;i--)
int main(){
    int X,Y,A,B,C;
    cin>>X>>Y>>A>>B>>C;
    vector<ll> p,q,r;
    ll val;
    rep(i,A){
        cin>>val;
        p.push_back(val);
    }
    rep(i,B){
        cin>>val;
        q.push_back(val);
    }
    rep(i,C){
        cin>>val;
        r.push_back(val);
    }
    sort(p.begin(),p.end());
    sort(q.begin(),q.end());
    rep(i,X){
        r.push_back(p.back());
        p.pop_back();
    }
    rep(i,Y){
        r.push_back(q.back());
        q.pop_back();
    }
    sort(r.begin(),r.end());
    ll ans = 0;
    rep(i,X+Y){
        ans += r.back();
        r.pop_back();
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(void)
{
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	
	int n;
	cin >> n;
	
	int* h;
	h = new int[n];
	for(int i = 0, tmp; i < n; ++i){
		cin >> h[i];
	}
	
	int max = 0;
	int count = 0;
	for(int i = 0; i < n - 1; ++i){
		if(h[i] >= h[i+1]){
			++count;
		}else{
			if(max < count){
				max = count;
			}
			count = 0;
		}
	}
	if(max < count){ max = count; }
	
	cout << max << endl;
	
	return 0;
}

Measured memory_bytes: 640
import math

s = input().split(' ')
n = int(s[0])
d = int(s[1])

perP = 2 * d + 1
ans = n // perP
# print('{:1.0f}'.format(ans))
if(n % perP == 0):
    print(ans)
else:
    print(ans + 1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
/* 
*    coder :: ATUL_PANDEY_2608
*        >>> INDIA <<<
*/
using namespace std;

// #define  part ..
#define listi vector<int > 
#define listll vector<long long >
#define pii pair<int ,int > 
#define pll pair<long long ,long long >
#define heap priority_queue<long long >

#define pb(a) push_back(a)
#define mod 998244353
#define maxx 200006
#define ll long long 
#define quick   ios_base::sync_with_stdio(NULL),cin.tie(0);
#define rep(i,a,b) for(int i=a;i<b;i++)
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// #define test int t;cin>>t;while(t--)
// end of #define 

// define globals ...





int Main()
{

ll dp[3030][3030][3];
int a[3030];

    int n, k;
    cin >> n >> k;
    for(int i=0;i<n;i++)cin >> a[i];
    dp[0][0][0] = 1;
    for(int i=0;i<n;i++){
        for(int j=0;j<=k;j++){
            (dp[i+1][j][0] += dp[i][j][0]) %= mod;
            (dp[i+1][j][1] += dp[i][j][0] + dp[i][j][1]) %= mod;
            (dp[i+1][j][2] += dp[i][j][0] + dp[i][j][1] + dp[i][j][2]) %= mod;
            if(j + a[i] <= k){
                (dp[i+1][j+a[i]][1] += dp[i][j][0] + dp[i][j][1]) %= mod;
                (dp[i+1][j+a[i]][2] += dp[i][j][0] + dp[i][j][1]) %= mod;
            }
        }
    }
    cout << dp[n][k][2] << endl;







  
  return 0;
}























// main function..
int main(){

   
    Main();
    
    
}


Measured memory_bytes: 216604
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

    /*
    ||||||||||||||||||||||||||||||||||||||||||||||||
       |      |||         |      ||||    ||||  |   |
      | |     |   |      | |     |   |  |      |   |
     |   |    |    |    |   |    |   |  |      |   |
    |||||||   |    |   |||||||   |||     |||   |||||
    |     |   |   |    |     |   | |        |  |   |
    |     |   |||      |     |   |  ||  ||||   |   |
    ||||||||||||||||||||||||||||||||||||||||||||||||

    */
    using namespace std;
    //#include "testlib.h"
    #define ff first
    #define ss second
    #define mp make_pair
    #define all(v) v.begin(),v.end()
    #define int long long
    #define ll long long
    #define M 1000000007
    #define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
    #define GCD(m,n) __gcd(m,n)
    #define LCM(m,n) m*(n/GCD(m,n))
    #define mii  map<ll ,ll >
    #define msi  map<string,ll >
    #define mis  map<ll int, string>
    #define rep(a,b)    for(ll i=a;i<b;i++)
    #define rep0(n)    for(ll i=0;i<n;i++)
    #define repi(i,a,b) for(ll i=a;i<b;i++)
    #define pb push_back
    #define vi vector<ll>
    #define mp make_pair
    #define vs vector<string>
    #define ppb pop_back
    #define endl '\n'
    #define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define r0 return 0;
    #define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
    #define FORE(it, c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
    #define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    #define input freopen("input.txt", "r", stdin);
    #define Set(a, s) 4(a, s, sizeof (a))
    #define FOR repi
    #define pii pair<int,int>
    //#define float long double
    ll max(ll a, ll b) { return (a > b)? a : b;}
    int min(int a, int b) { return (a < b)? a : b;}


     int solve()
     {int count=1,ans=0,temp=10;
        int n;
        cin>>n;
        for(int i=1;i<=n;i++){
            if(i%temp==0) {count++;temp*=10;}
            if(count%2)  ans++;
        }
        cout<<ans;r0
         
     }
    signed main()
    {   
        asdf
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

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

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

    ll N;
    cin >> N;

    ll ans;

    for(ll i = 1; i * i <= N; i++) {
        ans = i;
    }

    cout << ans * ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N;
ll A[1001001];
ll L[1001001];
ll R[1001001];

void solve() {
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        ll l = i + A[i];
        if (l < N) L[l] += 1;
        ll r = i - A[i];
        if (0 < r) R[r] += 1;
    }
    ll ans = 0;
    for (ll i = 0; i < N; ++i) {
        ans += L[i] * R[i];
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 8256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

int main(){
  int h,w;
  cin >> h >> w;
  int n;
  cin >> n;
  int a[n];
  rep(i,n)cin >> a[i];
  int index=1;
  int cnt=0;
  vector<int> v;
  int c[h][w]={};
  rep(i,h){
    rep(j,w){
      c[i][j]=index;
      cnt++;
      if(cnt==a[index-1]){
        index++;
        cnt=0;
      }
    }
  }
  rep(i,h){
    if(i%2==0){
      rep(j,w){
        cout << c[i][j] << ' ';
        if(j==w-1)cout << endl;
      }
    }
    else{
      rep(j,w){
        cout << c[i][w-1-j] << ' ';
        if(j==w-1)cout << endl;
      }
    }
  }
return 0;}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		int input_a = scan.nextInt();
		int input_b = scan.nextInt();
		int input_c = scan.nextInt();
		
		if(input_a < input_b && input_b < input_c){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		
	}

}

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

int main(){
	int n, x, count;
	ostringstream ss;
 	while (1){
		cin >> n >> x;
		if (n == 0 && x == 0){
			break;
		}
		count = 0;
		for (int i = 1; i <= n-2; i++){
			for (int j = i+1; j <= n-1; j++){
				for (int k = j+1; k <= n; k++){
					if (i + j + k == x){
						count++;
					}
				}
			}
		}
		ss << count << "\n" << flush;
	}
	cout << ss.str() << flush;
	cin >> x;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
int main () {
    long long n,p,x=0;
    cin>>n;
    if(n%2==0 &&n!=0 &&n!=2){
        p=n/2;
        while(p>=5){
            p=p/5;
            x+=p;
            }
        cout<<x;
    }
    else{
        cout<<x;
    }
    return 0;
}

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

int main(){

	int n = 0;
	string s;
	cin>>s;
	int length = s.length();

	for(int i=0; i<length; i++){
		char m = s[i];
		int j = m - '0';

		n+=j;
	}

	if(stoi(s)%n==0){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}

	return 0;
}

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

long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}

bool match(char a, char b){
    return (a == '?' || b == '?' || a == b);
}

int main()
{
    string a, b, c; cin >> a >> b >> c;
    int A = a.length();
    int B = b.length();
    int C = c.length();
    bool ab[100000], ac[100000], bc[100000];
    REP(i, 100000){
        ab[i] = true;
        ac[i] = true;
        bc[i] = true;
    }

    REP(i, A) REP(j, B) if(!match(a[i], b[j])) ab[i-j+50000] = false; 
    REP(i, A) REP(j, C) if(!match(a[i], c[j])) ac[i-j+50000] = false; 
    REP(i, B) REP(j, C) if(!match(b[i], c[j])) bc[i-j+50000] = false;

    int ans = 6000;
    for(int i = -4000; i<=4000;i++)
        for(int j=-4000; j<=4000;j++) 
            if(ab[i+50000] && ac[j+50000] && bc[j-i+50000]){
                int L = min(0, min(i, j));
                int R = max(A, max(i+B, j+C));
                ans = min(ans , R-L);
            }
    cout << ans << endl;
    return 0;
    
}



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

int main() {
  int N,A,X,Y,Z;
  cin >> N >> A;
  X = N/500;
  Y = X*500;
  Z = N - Y;
  if (Z <= A) {
    cout << "Yes" << endl;
  }
  if (Z > A) {
    cout << "No" << endl;
  }
}


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

int main()
{
	int a, b;
	cin >> a >> b;
	if (a - b >= 0) {
		cout << a - b << endl;
	}
	else if (a - b < 0) {
		cout << 0 << endl;
	}
	else {
		cout << 0 << endl;
	}
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
int main() 
{
    int x, h;
    double S;
    while (1) {
        cin >> x;
        cin >> h;
        if (x == 0 && h == 0) {
            break;
        }
        S = x * x + 4 * 0.5 * x * sqrt(x * 0.5 * x * 0.5 + h * h);
        cout << fixed << setprecision(6) << S << endl;
    }
    
}



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

#define REP(i,n) for(int i=0;i<(n);i++)
#define int long long
#define ALL(x) (x).begin(),(x).end()
typedef pair<int, int> pii;


int imos[100010];
void solve() {
    int N;cin>>N;
    REP(i,N){
        int l,r;cin>>l>>r;
        l--;
        imos[l]++;
        imos[r]--;
    }
    REP(i,100009){
        imos[i+1]+=imos[i];
    }
    int ans = 0;
    REP(i,100010){
        if(imos[i]>=i)ans=i;
    }
    cout<<ans<<endl;
}

signed main() {
	solve();
}



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

int main()
{
	int n;
	cin>>n;
	vector<int> vec(n);
	for(auto&& e:vec)
	{
		cin>>e;
	}
	int min=vec[0],cnt=1;
	for (int i = 1; i < n; ++i)
	{
		if(vec[i]<=min) 
		{
			cnt++;
			min=vec[i];
		}
	}
	cout<<cnt;
}

Measured memory_bytes: 1024
from bisect import bisect
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a = [0]*N
for i in range(N):
    a[i] = A[i]+a[i-1]
b = [0]*M
for i in range(M):
    b[i] = B[i]+b[i-1]
a = [0]+a
b = [0]+b
ans = 0
for i in range(N+1):
    c = a[i]
    if K-c>=0:
        j = bisect(b,K-c)
        ans = max(ans,i+j-1)
print(ans)

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

int main()
{
	int N;
	cin >> N;
	vector<int> H(N + 1);
	for (int i = 1; i <= N; i++)
	{
		cin >> H[i];
	}
	int ans = 0;
	for (int i = 1; i <= N; i++)
	{
		bool view = true;
		for (int j = 1; j < i; j++)
		{
			if (H[j]>H[i])
			{
				view = false;
				break;
			}
		}
		if (view)
		{
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256