akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<functional>
#include<cmath>
#include<vector>
//using namespace std;
using std::min;
using std::max;
using std::swap;
using std::sort;
using std::reverse;
using std::random_shuffle;
using std::lower_bound;
using std::upper_bound;
using std::unique;
using std::vector;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
void open(const char *s){
#ifndef ONLINE_JUDGE
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
int rd(){int s=0,c,b=0;while(((c=getchar())<'0'||c>'9')&&c!='-');if(c=='-'){c=getchar();b=1;}do{s=s*10+c-'0';}while((c=getchar())>='0'&&c<='9');return b?-s:s;}
void put(int x){if(!x){putchar('0');return;}static int c[20];int t=0;while(x){c[++t]=x%10;x/=10;}while(t)putchar(c[t--]+'0');}
int upmin(int &a,int b){if(b<a){a=b;return 1;}return 0;}
int upmax(int &a,int b){if(b>a){a=b;return 1;}return 0;}
const ll p=1000000007;
const int N=100010;
int cmp(pii a,pii b)
{
	if(a.first!=b.first)
		return a.first<b.first;
	return a.second>b.second;
}
int n,m,t,t2;
int a[N],b[N],d[N];
pii c[N];
ll e[N];
void add(int x,ll v)
{
	for(;x<=t2;x+=x&-x)
		e[x]=(e[x]+v)%p;
}
ll sum(int x)
{
	ll s=0;
	for(;x;x-=x&-x)
		s=(s+e[x])%p;
	return s;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=m;i++)
		scanf("%d",&b[i]);
	for(int i=1;i<=n;i++)
		if(a[i]>b[1]&&a[i]<b[m])
		{
			int x=lower_bound(b+1,b+m+1,a[i])-b;
			if(b[x]==a[i])
				continue;
			c[++t]=pii(a[i]-b[x-1],b[x]-a[i]);
			d[++t2]=b[x]-a[i];
		}
	sort(d+1,d+t2+1);
	t2=unique(d+1,d+t2+1)-d-1;
	for(int i=1;i<=t;i++)
		c[i].second=lower_bound(d+1,d+t2+1,c[i].second)-d;
	sort(c+1,c+t+1,cmp);
	t=unique(c+1,c+t+1)-c-1;
	ll ans=1;
	for(int i=1;i<=t;i++)
	{
		ll s=sum(c[i].second-1)+1;
		ans+=s;
		add(c[i].second,s);
	}
	ans%=p;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

vector<int> dy = { 0,0,1,-1 };
vector<int> dx = { 1,-1,0,0 };

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
	o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}

template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {
	o << "{" << obj.first << ", " << obj.second << "}"; return o;
}

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}

int main() {
	int N,cnt = 0; cin >> N;
	V<ll> a(N+1);
	FOR(i, 1, N + 1) cin >> a[i];
	FOR(i, 1, N + 1) if (a[a[i]] == i)cnt++;
	cout << cnt / 2 << endl;

	return 0;
}



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

vector<int> cliff_top;
vector<int> a;
int n;
long long int time1 = -1;

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int aho;
		cin >> aho;
		a.push_back(aho);
	}
	bool tf = true;
	
	int current = 0;
	
	for (int i = 0; i < n; ++i) {
		if (a[0] != 0) {
			tf = false;
			break;
		}
		else if (i == 0){}
		else if (a[i] == 0 && a[i - 1] == 0) {
			current = 0;
		}
		else if (a[i] == a[i - 1] + 1) {
			current = a[i];
			if (i == n - 1) {
				cliff_top.push_back(current);
			}
		}
		else if (a[i] <= a[i - 1]) {
			cliff_top.push_back(current);
			current = 0;
			if (a[i] > 0) {
				current = a[i];
				if (i == n - 1) {
					cliff_top.push_back(current);
				}
			}
		}
		else if (a[i] > a[i - 1] + 1) {
			tf = false;
			break;
		}
	}
	if (cliff_top.size() == 0 && tf == true) {
		time1 = 0;
	}
	else if (tf == true) {
		time1 = 0;
		for (int i = 0; i < cliff_top.size(); ++i) {
			time1 += cliff_top[i];
		}
	}
	cout << time1;
	
}


Measured memory_bytes: 2548
#include<iostream>
#include<stdio.h>
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,n) for(int i=1;i<=n;i++)
int main()
{
    char x;
    int num;
    int ans[26];

    rep(i,26) ans[i]=0;



while(1){
    cin >> x;
    if(cin.eof()) break;

    if(islower(x)){
        num = x -'a';
        ans[num]++;
    }else if(isupper(x)){
        num = x -'A';
        ans[num]++;
    }
}

    char letter = 'a';

    rep(i,26){
        cout << letter << " : " << ans[i] << endl;
        letter = letter + 1 ;
    }

    return 0;


}


Measured memory_bytes: 3100
import java.io.*;
import java.util.Random;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
        FastReader scan = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        Task solver = new Task();
        int t = 1;
        while (t --> 0) solver.solve(1, scan, out);
        out.close();
    }

    static class Task {

        public void solve(int testNumber, FastReader scan, PrintWriter out) {
            int n = scan.nextInt();
            int[][] point = new int[n][2];
            for(int i = 0; i < n; i++) {
                point[i][0] = scan.nextInt();
                point[i][1] = scan.nextInt();
            }
            double total = 0;
            long fact1 = 1, fact2 = 1;
            for(int i = 1; i <= n-2; i++) fact1 *= i;
            for(int i = 1; i <= n; i++) fact2 *= i;
            for(int i = 0; i < n; i++) {
                for(int j = i+1; j < n; j++) {
                    total += dist(point[i][0], point[i][1], point[j][0], point[j][1]);
                }
            }
            total *= 2*fact1*(n-1);
            out.println(total/fact2);
        }

        static double dist(int a, int b, int c, int d) {
            long x = Math.abs(a-c), y = Math.abs(b-d);
            return Math.sqrt(x*x+y*y);
        }
    }

    static void shuffle(int[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            int temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static void shuffle(long[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            long temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(new File(s)));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

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

int main()
{
    int n,i,x,minn=10001,maxx=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>x;
        if(minn>x) minn=x;
        if(maxx<x) maxx=x;
    }
    cout<<maxx-minn;
    return 0;
}


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

typedef long long ll;
const int mod=1e9+7;

inline ll qpow(ll a,ll n){
    ll res=1;
    while(n){
        if(n&1)res=res*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}

int n,m;
ll ans,f[500005]={1},inv[500005]={1};

int main(){

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

    for(int i=1;i<=5e5;i++){
        f[i]=f[i-1]*i%mod;
        inv[i]=qpow(f[i],mod-2);
    }
    cin>>n>>m;
    for(int i=0;i<=n;i++){
        ans=(ans+f[n]*inv[i]%mod*inv[n-i]%mod*((i&1)?-1:1)*f[m-i]%mod*inv[m-n]%mod)%mod;
    }
    for(int i=m-n+1;i<=m;i++)ans=ans*i%mod;
    cout<<(ans+mod)%mod<<endl;

    return 0;
}

Measured memory_bytes: 11372
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


signed main() {
  string s;cin>>s;
  int cnto = 0, cntz = 0;
  if(s[0] == '1')cnto++;
  else cntz++;

  int ans = 0;
  repd(i,1,s.length()){
    if(s[i] == '0'){
      if(cnto){
        ans++;cnto--;
      }else{
        cntz++;
      }
    }else{
      if(cntz){
        ans++;cntz--;
      }else{
        cnto++;
      }
    }
  }
  cout << ans * 2 << endl;
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N >> K;
	N = N % K;
	cout << min(N, abs(N - K)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std; typedef long long ll; const int INF=1e9; typedef pair<ll,ll> P; const ll mod=1e9+7;

int main() {
  ll n,m; cin>>n>>m;
  ll x[n], y[m];
  for(int i=0;i<n;i++) cin>>x[i];
  for(int i=0;i<m;i++) cin>>y[i];

  ll xx=0, yy=0;
  for(int i=0;i<n;i++) {
    xx+=x[i]*(i - (n-1-i));
  }
  xx%=mod;
  for(int j=0;j<m;j++) {
    yy+=y[j]*(j - (m-1-j));
  }
  yy%=mod;
  //cout<<xx<<" "<<yy<<endl;
  cout<<xx*yy%mod<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int r,g; cin >> r >> g;
    cout << 2*g-r << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	string s;
	cin>>s;
	for(int i=0;i<sz(s);i++)
		if(s[i]=='?')
			s[i]='D';
	cout<<s<<"\n";
	return 0;
}

Measured memory_bytes: 3772
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <cerrno>
#include <cfenv>
#include <cstring>
#include <bitset>

using namespace std;
int main()
{
    int H, N = 0, tmpA;
    string ans;
    cin >> H;
    cin >> N;
    vector<int> A(N);
    int allA = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> tmpA;
        allA = allA + tmpA;
    }

    if (allA >= H)
    {
        ans = "Yes";
    }
    else
    {
        ans = "No";
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int h, a;
    cin >> h >> a;

    int ans = (h + (a - 1)) / a;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int S;
	cin>>S;
	int h,m,s;
	h = S/3600;
	S %= 3600;
	m = S/60;
	S %= 60;
	s = S;
	cout<<h<<":"<<m<<":"<<s<<endl;
}


Measured memory_bytes: 3104
N,x=map(int,input().split())

ANS=[]
for i in range(1,2*N):
    ANS.append(i)

if x==1 or x==(N*2-1):
    print("No")
else:
    print("Yes")
    if x==N:
        for j in range(len(ANS)):
            print(ANS[j])
    elif x<N:
        for j in range(1,N):
            if ANS[j]==x:
                pass
            else:
                print(ANS[j])
        print(1)
        print(x)
        for k in range(N,N*2-1):
            print(ANS[k])
    elif x>N:
        for j in range(N-1):
            print(ANS[j])
        print(x)
        print(N*2-1)
        for k in range(N-1,N*2-2):
            if ANS[k]==x:
                pass
            else:
                print(ANS[k])
    

Measured memory_bytes: 12496
n=int(input())
s=list(input())
b=[]
b_num,r_num,g_num=0,0,0
r=[]
g=[]
for i in range(n):
    if s[i]=="R":
        r_num+=1
    elif s[i]=="B":
        b_num+=1
    else:
        g_num+=1
    b.append(b_num)
    g.append(g_num)
    r.append(r_num)
def c(al,j):
    global r,g,b,r_num,g_num,b_num
    if al=="R":
        return r_num-r[j]
    elif al=="B":
        return b_num-b[j]
    else:
        return g_num-g[j]
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        if j<=i:
            continue
        if s[i]==s[j]:
            continue
        a=[]
        a.append(s[i])
        a.append(s[j])
        #print(s[i]+s[j])
        sa=j-i
        if n-1<j+sa:
            if not "B" in a:
                ans+=(b_num-b[j])
            elif not "R" in a:
                ans+=(r_num-r[j])
            else:
                ans+=(g_num-g[j])
            continue
        else:
            if s[j+sa] in a: #入ってないやつを返す
                if not "B" in a:
                    ans+=(b_num-b[j])
                elif not "R" in a:
                    ans+=(r_num-r[j])
                else:
                    ans+=(g_num-g[j])
            else:
                ans+=c(s[j+sa],j)-1
print(ans)
#print(g)

Measured memory_bytes: 68936
n,q = map(int,input().split())
s = input()
ac = [0 for i in range(n+1)]
ans = []
for i in range(len(s)-1):
    if s[i:i+2]=="AC":
        ac[i+1] = ac[i] + 1
    else:
        ac[i+1] = ac[i]
 
for i in range(q):
    l,r = map(int,input().split())
    print(ac[r-1]-ac[l-1])

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

#define fi first
#define se second

const int N = 1000100;

using namespace std;

string s;
int d[N][2];
int shit[N];

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> s;

    int inf = 1e9;
    d[s.size()][1] = inf;
    for(int i = s.size() - 1; i >= 0; i--){
        int x = s[i] - '0';
        d[i][0] = d[i][1] = inf;

        for(int j = 0; j < 2; j++){
            int nx = x + j;

            if(nx < 10){
                d[i][0] = min(d[i][0], d[i + 1][j] + nx);
            }
            d[i][1] = min(d[i][1], d[i + 1][j] + 10 - nx);
        }
    }
    cout << min(d[0][0], d[0][1] + 1) << "\n";
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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

int bitcount(int bits) {
  int ret = 0;
  while (bits > 0) {
    if (bits & 1) ret++;
    bits = bits >> 1;
  }
  return ret;
}

signed main() {
  int N;
  cin >> N;
  vector<vector<P>> A(N);
  rep(i, N) {
    int a;
    cin >> a;
    rep(j, a) {
      P p;
      cin >> p.first >> p.second;
      p.first--;
      A[i].push_back(p);
    }
  }
  int ans = 0;
  rep(i, BIT(N)) {
    bool ok = true;
    rep(j, N) {
      rep(k, A[j].size()) {
        bool bTargetHonest = !!(BIT(A[j][k].first) & i);
        bool bTellingHonest = A[j][k].second;
        PRINT(bitset<4>(i))
        PRINT(bTargetHonest)
        PRINT(bTellingHonest)
        if (!(BIT(j) & i)) continue;

        if (bTargetHonest && !bTellingHonest) {
          ok = false;
        }
        if (!bTargetHonest && bTellingHonest) {
          ok = false;
        }
      }
    }
    if (ok) {
      chmax(ans, bitcount(i));
      PRINT(bitset<8>(i))
    }
  }
  cout << ans << endl;
}

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

typedef long long ll;
typedef pair<int, int> ii;

int main()
{
    ll n;
    scanf("%lld", &n);
    ll mn = LLONG_MAX;
    for (int i = 0; i < 5; i++) {
        ll num;
        scanf("%lld", &num);

        mn = min(mn, num);
    }

    ll group = (n + mn - 1) / mn;
    printf("%lld\n", 5 + group - 1);

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;
 
public class Main {

  static class FastReader {

    BufferedReader br; 
    StringTokenizer st; 

    public FastReader() { 
      br = new BufferedReader(new InputStreamReader(System.in)); 
    } 

    String next() { 
      while (st == null || !st.hasMoreElements()) { 
        try { 
          st = new StringTokenizer(br.readLine()); 
        } catch (IOException e) { 
          e.printStackTrace(); 
        } 
      } 
      return st.nextToken(); 
    } 

    int nextInt() { 
      return Integer.parseInt(next()); 
    } 

    long nextLong() { 
      return Long.parseLong(next()); 
    } 

    double nextDouble() { 
      return Double.parseDouble(next()); 
    } 

    String nextLine() { 
      String str = ""; 
      try { 
        str = br.readLine(); 
      } catch (IOException e) { 
        e.printStackTrace(); 
      } 
      return str; 
    } 
  }
 
  public static void main(String args[]) throws IOException {
    // try {
    //   FileOutputStream output = new FileOutputStream("temp.out");
    //   PrintStream out = new PrintStream(output);
    //   //Diverting the output stream into file "temp.out".Comment the below line to use console
    //   System.setOut(out);
  
    //   InputStream input = new FileInputStream("temp.in");
    //   //Diverting the input stream into file "temp.in".Comment the below line to use console
    //   System.setIn(input);
  
    // } catch (FileNotFoundException e) {
    //   e.printStackTrace();
    // }
  
    FastReader sc = new FastReader();
    PrintWriter wr = new PrintWriter(System.out);
 
    // int t = 1;
    // t = sc.nextInt();    //Comment this line if there is single test case
    
    // while((t--) != 0) {
  
    //   int x = sc.nextInt();
    //   int y = sc.nextInt();
      
    //   wr.println(x+y);
    // }

    String s = sc.nextLine();
    String t = sc.nextLine();

    int count = 0;

    for(int i = 0; i < s.length(); i++) {
      
      if(s.charAt(i) != t.charAt(i))
        count++;
    }

    wr.println(count);




    wr.flush();
    wr.close();
  }
}

Measured memory_bytes: 37112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
int N,K,a[5000];

bool test(int x) {
	bitset<5000> posi;
	posi[0] = 1;
	rep(i,N) if(i!=x) posi |= (posi<<a[i]);
	for(int i=max(K-a[x],0);i<K;i++) if(posi[i]) return true;
	return false;
}
 
int main() {
	cin>>N>>K;
	rep(i,N) cin>>a[i];
	sort(a,a+N);
	int l=0,r=N;
	while(l<r){
		int mid = (l+r)/2;
		if(test(mid)) r = mid;
		else l = mid+1;
	}
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }
        static void Solve()
        {
            (long a, long b, long c) = Slice3<long>();
            if (b - a == c - b)
                WriteLine("YES");
            else
                WriteLine("NO");
        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 27420
#include <iostream>
#include <math.h>
using namespace std;

int main(void) {
    
  int a;
  string hy9r;
  
  cin >> a;
  cin >> hy9r;
  
  if ( a < 3200 ) {
    cout << "red" << endl;
  }
  
  if ( a >= 3200 ) {
    cout << hy9r << endl;
  }
  return 0;
}



Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
const int N=2005;
int gcd(int a,int b)
{
	return a%b==0?b:gcd(b,a%b);
}
int n,A[N];
bool vis[N];
vector<int> adj[N],adj2[N];
int deg[N],ans[N];
priority_queue<int>Q;
void dfs(int u)
{
	vis[u]=true;
	for(int i=0;i<(int)adj[u].size();i++)
	{
		int v=adj[u][i];
		if(vis[v])
			continue;
		adj2[u].push_back(v);
		deg[v]++;
		dfs(v);
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&A[i]);
	sort(A+1,A+n+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(i!=j&&gcd(A[i],A[j])>1)
				adj[i].push_back(j);
	for(int i=1;i<=n;i++)
		if(!vis[i])
			dfs(i);
	for(int i=1;i<=n;i++)
		if(deg[i]==0)
			Q.push(i);
	int it=0;
	while(!Q.empty())
	{
		int u=Q.top();
		ans[++it]=A[u];
		Q.pop();
		for(int i=0;i<(int)adj2[u].size();i++)
		{
			int v=adj2[u][i];
			deg[v]--;
			if(deg[v]==0)
				Q.push(v);
		}
	}
	for(int i=1;i<n;i++)
		printf("%d ",ans[i]);
	printf("%d\n",ans[n]);
	return 0;
}

Measured memory_bytes: 16000
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main() {
	int n = 0;
	cin >> n;
	int i = n;
	int t, x, y;
	int pt = 0, px = 0, py = 0;
	bool isEnable = true;

	while (n--) {
		int nt, nx, ny = 0;
		cin >> nt >> nx >> ny;
		t = nt - pt;
		x = nx - px;
		y = ny - py;

		if ((abs(x) + abs(y)) % 2 != t % 2 || (abs(x) + abs(y)) > t) {
			isEnable = false;
		}

		pt = nt;
		px = nx;
		py = ny;
	}

	cout << (isEnable ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		long tmp=0L;
		long[] town =new long[N+1];
		for(int i=0; i<N+1; i++) {
			town[i]=sc.nextLong();
		}
		long[] sensi=new long[N];
		for(int i=0; i<N; i++) {
			sensi[i]=sc.nextLong();
		}
		for(int i=0; i<N; i++) {
			if(sensi[i]>=town[i]) {
				tmp+=town[i];
				sensi[i]-=town[i];
				if(sensi[i]>0) {
					if(sensi[i]>=town[i+1]) {
						tmp+=town[i+1];
						sensi[i]-=town[i+1];
						town[i+1]=0;
					}
					else {
						tmp+=sensi[i];
						town[i+1]-=sensi[i];
						sensi[i]=0;
					}
				}
			}
			else {
				tmp+=sensi[i];
				sensi[i]=0;
			}
		}
		tmp+=Math.min(town[N],sensi[N-1]);
		p(tmp);

	}
	public static void p(Object o) {
		System.out.println(o);
	}
}

Measured memory_bytes: 65060
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

ll m, a, r, c, h;

int main(void)
{
    ll n, ans;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ans = a[0];
    REP(i,1,n){
        ans = __gcd(ans,a[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4044
// 2017/07/21 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int h1, h2, k1, k2, a, b, c, d;
	cin >> h1 >> h2;
	cin >> k1 >> k2;
	cin >> a >> b >> c >> d;

	int hir = a*h1+b*h2+c*(h1/10)+d*(h2/20);
	int ken = a*k1+b*k2+c*(k1/10)+d*(k2/20);

	if(hir>ken){
		cout << "hiroshi" << endl;
	}
	else if(hir<ken){
		cout << "kenjiro" << endl;
	}
	else{
		cout << "even" << endl;
	}

	return 0;
}

Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		// ouput:1以上 N以下の整数のうち、各桁の和が A 以上 B 以下であるものの総和
		
		//input:
			//整数N
			//整数A
			//整数B
		
		//logic
		//approach1
		//文字列としてのNについて、各桁をそれぞれ「数字に変換」
		//A,Bは「数字」として変換
		
		//input
		int N=0;
		int A=0,B=0;
		int digit_sum = 0;
		int sum = 0;
		
		Scanner scan = new Scanner(System.in);
		N = scan.nextInt();
		
		A = scan.nextInt();
		B = scan.nextInt();
		
		
		//logic
		for(int i=1;i<N+1;i++) {
			String s_N = String.valueOf(i);
			
			for (int j = 0; j < s_N.length() ;j++) {
				//各桁の和
				int tmp = Character.getNumericValue(s_N.charAt(j));
				digit_sum = digit_sum + tmp;
				
				
			}
			if(digit_sum >= A && digit_sum <= B) sum = sum + i;
			//リセット
			digit_sum = 0;
		}
		
		System.out.println(sum);
	}

}

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

#include <vector>

using namespace std;
using ll = long long;

template <int MOD>
struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; }
    constexpr Fp operator+(const Fp& r) const noexcept {
        return Fp(*this) += r;
    }
    constexpr Fp operator-(const Fp& r) const noexcept {
        return Fp(*this) -= r;
    }
    constexpr Fp operator*(const Fp& r) const noexcept {
        return Fp(*this) *= r;
    }
    constexpr Fp operator/(const Fp& r) const noexcept {
        return Fp(*this) /= r;
    }
    constexpr Fp& operator+=(const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator-=(const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator*=(const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator/=(const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator==(const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator!=(const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator<<(ostream& os,
                                         const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD>& a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

const int MOD = 1000000007;
using mint = Fp<MOD>;

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

    if (S < 3) {
        cout << 0 << endl;
        return 0;
    }

    vector<mint> dp(S + 1);
    dp[0] = 0;
    dp[1] = 0;
    dp[2] = 0;
    dp[3] = 1;
    for (int i = 4; i < S + 1; i++) {
        dp[i] = dp[i - 1] + dp[i - 3];
    }

    cout << dp[S] << endl;

    return 0;
}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int d,t,s;
int main()
{
    scanf("%d%d%d",&d,&t,&s);
    if(t*s>=d)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
}


Measured memory_bytes: 3720
# -*- coding: utf-8 -*-
from operator import itemgetter
from heapq import heappop, heappush
def solve(): 
    N = int(input())
    E = [[] for i in range(N+1)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        E[a].append(b)
        E[b].append(a)
    C = list(map(int, input().split()))
    C.sort(reverse=True)
    D = ['' for i in range(N+1)]
    j = 1
    hq = [(0,1)]
    checked = []
    while hq:
        _j ,n = heappop(hq)
        checked.append(n)
        D[n] = str(C[_j])
        for m in E[n]:
            if not m in checked:
                heappush(hq, (j, m))
                j += 1
    res = str(sum(C[1:])) + '\n' +' '.join(D[1:])
    return str(res)

if __name__ == '__main__':
    print(solve())



Measured memory_bytes: 6504
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
string tostr(ll x){
    if(x  <= 0)return "";
    char c = '0'+x%10;
    return tostr(x/10) + c;
}
int main(){
    int h, w;
    cin >> h >> w;

    string ans="";
    rep(i, h)rep(j, w){
        string s;
        cin >> s;
        if(s=="snuke"){
            ans+='A'+j;
            ans+=tostr(i+1);
        }
    }
    cout << ans << endl;
}

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

int main()
{
	int n, k;
	cin >> n >> k;
	long double ans = 0;
	for (int i = 1; i <= n; i++)
	{
		long double t = 0;
		if (i < k)
			for (int j = 0; k > i * pow(2.0, j); j++)
				t = (long double)1.0 / (long double)pow(2, j + 1);
		else
			t = (long double)1.0;
		ans += t;
	}
	cout << setprecision(16) << ans / (long double)n << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

long fib(int ,int *,long *);


int main(){
	int i,n,m[50];
	long a[50];
	scanf("%d",&n);
	for(i=2;i<=n;i++){
		m[i]=0;
	}
	a[0]=1;m[0]=1;
	a[1]=1;m[1]=1;
	printf("%ld\n",fib(n,m,a));
        return 0;
}
	
long fib(int n,int *m,long *a){

  if(m[n]==0){
    a[n]=fib(n-1,m,a)+fib(n-2,m,a);
    m[n]=1;
  }

  return a[n];
}



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

int main() {
    int n;
    cin >> n;
    map<string,int> mp;
    rep(i,n){
        string s;
        cin >> s;
        mp[s]++;
    }
    priority_queue<pair<int,string>> pq;
    for(pair<string,int> p : mp){
        pq.push(make_pair(p.second,p.first));
    }
    vector<string> ans;
    int vmax = pq.top().first;
    while(!pq.empty() && pq.top().first == vmax){
        ans.push_back(pq.top().second);
        pq.pop();
    }
    sort(ans.begin(),ans.end());
    for(string s : ans){
        cout << s << endl;
    }
}

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

int main() {
  int a, b, d, r;
  double f;

  cin >> a >> b;
  d = a / b;
  r = a % b;
  f = 1.0 * a / b;

  cout << d << " " << r << " " << fixed << setprecision(8) << f << endl;
}


Measured memory_bytes: 3288
local a, b = io.read("*n", "*n")

local function getallxor(x)
  if(x <= 0) then return {} end
  local tmnt = false
  local ret = {}
  local div = 2
  while(not tmnt) do
    local quot = x // div
    if(quot == 0) then tmnt = true end
    local c = quot * div // 2
    local rem = x % div
    c = c + math.max(0, rem - div // 2 + 1)
    table.insert(ret, c % 2)
    div = div * 2
  end
  return ret
end

local left, right = getallxor(a - 1), getallxor(b)
local mul, step = 1, 1
local final = 0
while(step <= #right) do
  if(step <= #left) then
    final = final + mul * ((left[step] + right[step]) % 2)
  else
    final = final + mul * right[step]
  end
  mul, step = mul * 2, step + 1
end
print(final)


Measured memory_bytes: 508
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
        k:usize,
       s: String,
    }

    if s.len() <= k {
        echo!(s);
    } else {
        println!("{}{}", s[0..k].to_string(), "...");
    }
}


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

int main(){
    int mod=1000000007;
    int n,ans=0,tmp=0;
    scanf("%d",&n);
    vector<long long> a(n);
    for (auto&e:a) scanf("%d",&e);
    for (int i=0;i<n;i++) {
        tmp=0;
        long long k=a[i];
        for(;;) {
            if (k>=1 && k%2==0) {
                k/=2;
                tmp++;
            } else {
                break;
            }
        }
        ans+=tmp;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
  long long a,b,c=0;
  cin >> a;
  b=1;
  for(int i=0;i<60;i++){
    if(b>a)break;
    else{
      b*=2;
      c++;
    }
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 3104
today = input()
tommorow = ''
weather_list = ['Sunny', 'Cloudy', 'Rainy']

if today == weather_list[0]:
    tommorow = weather_list[1]
elif today == weather_list[1]:
    tommorow = weather_list[2]
elif today == weather_list[2]:
    tommorow = weather_list[0]

print(tommorow)



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }


int main(void){
    int n,m;
    cin >> n >> m;
    vector<int> imos(n+2);
    rep(i,m){
        int l,r;
        cin >> l >> r;
        imos[l]++;
        imos[r+1]--;
    }
    int cnt = 0;
    rep1(i,n){
        imos[i+1] += imos[i];
        if (imos[i]>=m) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 640
/*
*/

#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS

#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds

#define eps 1e-9
#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 350

using namespace std;

const int INF = 1e9;
const int N = 220031;

int w, h, p[N], q[N];
long long ans;
set<pair<int, int> > S;
set<pair<int, int> > ::iterator it;

int main(){
	//freopen("fabro.in","r",stdin);
	//freopen("fabro.out","w",stdout);
	//freopen("F:/in.txt", "r", stdin);
	//freopen("F:/output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin >> w >> h;
	for (int i = 0; i < w; i++)
	{
		cin >> p[i];
	}
	for (int i = 0; i < h; i++)
	{
		cin >> q[i];
	}

	for (int i = 0; i < w; i++)
	{
		S.insert(make_pair(p[i], i+1));
	}
	for (int i = 0; i < h; i++)
	{
		S.insert(make_pair(q[i], -i-1));
	}

	long long cnt_w = 0, cnt_h = 0;

	while (S.size())
	{
		it = S.begin();
		pair<int, int> P = (*it);
		S.erase(it);
		if (P.second>0)
		{
			ans += P.first*(h - cnt_h+1);
			++cnt_w;
		}
		else
		{
			ans += P.first*(w - cnt_w+1);
			++cnt_h;
		}
	}
	cout << ans << endl;

	cin.get(); cin.get();
	return 0;
}

Measured memory_bytes: 10496
# frozen_string_literal: true

_n = gets.to_i
as = gets.strip.split.map(&:to_i)

ans = Float::INFINITY

as.map do |a|
  count = 0
  while a.even?
    count += 1
    a /= 2
  end
  ans = count < ans ? count : ans
end

puts ans


Measured memory_bytes: 3836
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        d: u32,
    }
    match d {
        22 => println!("Christmas Eve Eve Eve"),
        23 => println!("Christmas Eve Eve"),
        24 => println!("Christmas Eve"),
        25 => println!("Christmas"),
        _  => panic!()
    };
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, k;
  cin >> n >> k;
  vector<int> vals(n);
  for(int & v : vals) cin >> v;
  sort(vals.begin(), vals.end());
  int ans = 1<<30;
  for(int i = 0; i <= n - k; i++) ans = min(ans, vals[i + k - 1] - vals[i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640