akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

namespace
{
	map<ll, int> PrimeFactorization(ll x)
	{
		map<ll, int> ret;
		for (ll i = 2; i * i <= x; ++i)
		{
			while (x % i == 0)
			{
				x /= i;
				++ret[i];
			}
		}
		if (x > 1)
		{
			++ret[x];
		}
		return ret;
	}
}

void ABC169D()
{
	ll N;
	cin >> N;

	map<ll, int> pf = PrimeFactorization(N);
	int ct = 0;
	for (auto& x : pf)
	{
		int n = x.second;
		int i = 1;

		while (i <= n)
		{
			++ct;
			n -= i;
			++i;			
		}
	}
	cout << ct << endl;

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

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

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
 
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
int main(){
    int n,k,s;
    std::cin >>n>>k>>s;
    if(s==INF){
        rep(i,n){
            if(i<k)std::cout << INF << ' ';
            else std::cout << INF-1 << ' ';
        }
        
    }
    else{
        rep(i,n){
            if(i<k)std::cout << s << ' ';
            else std::cout << INF << ' ';
        }
    }
    std::cout  << std::endl;
}

Measured memory_bytes: 1280
import java.util.Scanner;
import java.util.HashMap;
import java.util.Map;

public class Main {

    public static final Map<Integer, String> alpMap = new HashMap<>();

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String c = sc.nextLine();
        sc.close();

        initMap();

        int val = 0;
        for (int i : alpMap.keySet()) {
            if (alpMap.get(i).equals(c)) {
                val = i;
                break;
            }
        }

        System.out.println(alpMap.get(val + 1));
    }

    private static void initMap() {
        alpMap.put(1, "a");
        alpMap.put(2, "b");
        alpMap.put(3, "c");
        alpMap.put(4, "d");
        alpMap.put(5, "e");
        alpMap.put(6, "f");
        alpMap.put(7, "g");
        alpMap.put(8, "h");
        alpMap.put(9, "i");
        alpMap.put(10, "j");
        alpMap.put(11, "k");
        alpMap.put(12, "l");
        alpMap.put(13, "m");
        alpMap.put(14, "n");
        alpMap.put(15, "o");
        alpMap.put(16, "p");
        alpMap.put(17, "q");
        alpMap.put(18, "r");
        alpMap.put(19, "s");
        alpMap.put(20, "t");
        alpMap.put(21, "u");
        alpMap.put(22, "v");
        alpMap.put(23, "w");
        alpMap.put(24, "x");
        alpMap.put(25, "y");
        alpMap.put(26, "z");
    }

}

Measured memory_bytes: 22996
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
#define pi 3.1415926535898
#define popcount __builtin_popcount //确定二进制中1的个数
using namespace std;

int main()
{
    int n;
    cin>>n;
    ll x[200],p[200],y[200];
    for(int i=0; i<n; i++)
    {
        cin>>x[i]>>y[i]>>p[i];
    }
    ll mnx[16][1<<15],mny[16][1<<15];
    for(int i=0; i<n; i++) //遍历所有情况
    {
        for(int j=0; j<(1<<n); j++)
        {
            if(j&(1<<i))
            {
                mnx[i][j]=0, mny[i][j]=0;
            }
            else
            {
                mnx[i][j]=abs(x[i]), mny[i][j]=abs(y[i]);
                for(int k=0; k<n; k++)
                {
                    if(j&(1<<k))
                    {
                        mnx[i][j]=min(mnx[i][j], abs(x[i]-x[k]));
                        mny[i][j]=min(mny[i][j], abs(y[i]-y[k]));
                    }
                }
            }
        }
    }
    ll ans[20];
    for(int i=0; i<=n; i++)
        ans[i]=1e18;
    for(int i=0; i<(1<<n); i++)
    {
        int c=popcount(i);
        for(int j=i; j>=0; j=(j-1)&i)
        {
            ll  s=0;
            for(int k=0; k<n; k++)
            {
                if(!(i&1<<k))
                {
                    s+=min(mnx[k][j], mny[k][i^j])*p[k];
                }
            }
            ans[c]=min(ans[c], s);
            if(j==0)
                break;
        }

    }
    for(int i=0; i<=n; i++)
        cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 11252
#include<bits/stdc++.h>
#define debug(x) cout<<#x<<"::"<<x<<endl;
using namespace std;
typedef long long ll;

void solve()
{
    int n;
    cin>>n;
    vector<int> height(n);
    for(int i=0;i<n;i++)
    {
        cin>>height[i];
    }
    vector<int>cost(n,0);cost[1]=abs(height[1]-height[0]);
    for(int i=2;i<n;i++)
    {
        cost[i]=min(cost[i-1]+abs(height[i]-height[i-1]),cost[i-2]+abs(height[i]-height[i-2]));
    }
    cout<<cost[n-1]<<'\n';

}

int main()
{
    int t;
    t=1;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 1024
import os
import math
import itertools
import numpy as np

N=int(input())
A=np.zeros((8,2)).astype(int)
for i in range(N):
  temp=list(map(int, input().split()))
  A[i,0]=temp[0]
  A[i,1]=temp[1]


  
def distance(x1,y1,x2,y2):
  return math.sqrt((x1-x2)**2+(y1-y2)**2)



order=list(itertools.permutations(range(N)))

tab=np.zeros((N,N))
for i in range(N):
  for j in range(i+1,N):
    tab[i,j]=distance(A[i,0],A[i,1],A[j,0],A[j,1])
    tab[j,i]=distance(A[i,0],A[i,1],A[j,0],A[j,1])
    
ret=0
C=math.factorial(N)      
for i in range(C):
  o=order[i]
  for j in range(1,N):
    ret+=tab[o[j],o[j-1]]
print(ret/C)
    

Measured memory_bytes: 19076
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll dp[100][100];

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

	ll p,n,i,d,c,e,ans = 0,j,k,l;
	string str;
	ld t;
	cin >> n;
	for(i=1;i<=n;++i)
	{
		cin >> str;
		l = str.size();
		d = 0;
		p = 0;
		c = e = 0;
		for(j=0;j<l;++j)
		{
			if(str[j] != '.')
				d = d*10+(str[j]-'0');
			else
				p = j;
		}
		if(p == 0)
			d = d*(ll)(1e9);
		else
		{
			for(j=0;j<9-(l-p-1);++j)
				d = d*10;
		}
		// cout << d << endl;
		while(d%2 == 0)
		{
			c++;
			d = d/2;
		}
		while(d%5 == 0)
		{
			e++;
			d = d/5;
		}
		// cout << c << " " << e << "\n";
		for(j=0;j<=50;++j)
		{
			for(k=0;k<=30;++k)
			{
				if(j>=18-c && k>=18-e)
				{
					// if(dp[j][k])
					// 	cout << i << " " << j << " " << k << " " << dp[j][k] << "\n";
					ans += dp[j][k];
				}
			}
		}
		dp[c][e]++;
	}

	cout << ans << "\n";
}

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

int main()
{

#ifdef _d
    freopen("input.txt", "r", stdin);
#endif

    int n;
    cin >> n;
    vector<int> a(n+1);
    vector<int> freq(100001, 0);
    long long sum = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        ++freq[a[i]];
        sum += a[i];
    }
    int q;
    cin >> q;
    for (int i = 1; i <= q; ++i) {
        int b, c;
        cin >> b >> c;
        sum += (c-b)*freq[b];
        cout << sum << "\n";
        freq[c] += freq[b];
        freq[b] = 0;
    }

    return 0;
}


Measured memory_bytes: 3964
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;
typedef long long int ll;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a,b,c;
    cin >> a >> b >> c;

    
    if(a == b && b == c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

// -------------------------------------------------------
string S;

int main() {
  cin >> S;

  set<char> st;
  for (auto c : S) {
    if (st.count(c) == 1) {
      cout << "no";
      return 0;
    }
    st.insert(c);
  }

  cout << "yes";
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

const int MAX_N=1<<17;
const ll INF=(1ll<<31)-1;
//Range Sum Query
class Lz_segtree{
public:
    int n;
    ll e=0;
    vector<ll> dat,lz;
    Lz_segtree(int n_):n(n_){
        n=1;
        while(n<n_) n*=2;
        dat.resize(n*2,e);
        lz.resize(n*2,e);
    }
    void update_f(ll& d,ll x){
        d+=x;
    }
    void dat_propergatef(ll& d,ll x){
        d=x;
    }
    void lz_propergatef(ll& l,ll& r,ll x){
        l+=x,r+=x;
    }
    ll q_func(ll l,ll r){
        return l+r;
    }
    void eval(int len,int k){
        if(lz[k]!=e) update_f(dat[k],lz[k]);//dat[k]+=lz[k];
        if(len>1){
            lz_propergatef(lz[k*2+1],lz[k*2+2],lz[k]/2);
            /*
            lz[k*2+1]+=lz[k]/2;
            lz[k*2+2]+=lz[k]/2;
            */
        }
        lz[k]=e;
    }
    //range [a,b)
    void update(int a,int b,int k,int l,int r,ll x){
        eval(r-l,k);
        if(r<=a||b<=l) return;
        if(a<=l&&r<=b){
            update_f(lz[k],(r-l)*x);
            //lz[k]+=(r-l)*x;
            eval(r-l,k);
        }
        else{
            update(a,b,k*2+1,l,(l+r)/2,x);
            update(a,b,k*2+2,(l+r)/2,r,x);
            dat_propergatef(dat[k],dat[2*k+1]+dat[2*k+2]);
            //dat[k]=dat[2*k+1]+dat[2*k+2];
        }
    }
    //range [a,b)
    ll query(int a,int b,int k,int l,int r){
        eval(r-l,k);
        if(r<=a||b<=l) return e;
        if(a<=l&&r<=b) return dat[k];
        else{
            ll vl=query(a,b,k*2+1,l,(l+r)/2);
            ll vr=query(a,b,k*2+2,(l+r)/2,r);
            return q_func(vl,vr);
            //return vl+vr;
        }
    }
    void update(int a,int b,ll x){
        return update(a,b,0,0,n,x);
    }
    ll query(int a,int b){
        return query(a,b,0,0,n);
    }
};

int main(){
    int n,q,c,s,t,x;
    cin>>n>>q;
    Lz_segtree seg(n);
    rep(i,q){
        cin>>c;
        if(c==0){
            cin>>s>>t>>x;
            seg.update(s-1,t,x);
        }
        else{
            cin>>s>>t;
            ll ans=seg.query(s-1,t);
            cout<<ans<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 7016
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    char[] str = sc.nextLine().toCharArray();
    long counter = sc.nextLong();
    
    int i = 0;
    while(str[i] == '1' && ++i<str.length);
    
    if(i>=counter) System.out.println(1);
    else System.out.println(str[i]);
  }
}

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

int main(void){
    long long a,b,x,r,aa,bb;
    
while(cin >> a >> b){
    
    if(a < b){
      x = a;
      a = b;
      b = x;
      }
    aa = a;
    bb = b;
    
    for(x = 0; b != 0; x++){
      r = a%b;
      a = b;
      b = r;
    }
    cout << a << " " << aa*bb/a << endl;
}

    return 0;
}


Measured memory_bytes: 3080
import bisect

n = int(input());
a = input().split(" ");
b = input().split(" ");
c = input().split(" ");
num_b = [0]*n;
for i in range(n) :
	a[i] = int(a[i]);
	b[i] = int(b[i]);
	c[i] = int(c[i]);
a.sort();
b.sort();
c.sort();
num_b = [0]*(n+1);
for i in range(n) :
	num_b[n-1-i] = n - bisect.bisect_right(c,b[n-1-i]) + num_b[n-i];
ans = 0;
for i in range(n) :
	ans += num_b[bisect.bisect_right(b,a[i])];
print(ans);

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

int main(){
  int a, b, x, t;
  
  cin >> a >> b;
  x = a * b;
  t = x/2;
  if((x-2*t)==1)
  	cout << "Odd" << endl;
  else
    cout << "Even" << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int r, c, tmp, sum;
    scanf("%d %d", &r, &c);
    int table[r+1][c+1], col[c+1];
    for (int i=0; i<c+1; i++) col[i] = 0;
    for (int i=0; i<r; i++){
        sum = 0;
        for (int j=0; j<c; j++){
            scanf("%d", &tmp);
            sum += tmp;
            col[j] += tmp;
            table[i][j] = tmp;
        }
        table[i][c] = sum;
        col[c] += sum;
    }
    for (int i=0; i<r; i++){
        for (int j=0; j<c+1; j++){
            printf("%d", table[i][j]);
            if (j < c) printf(" ");
        }
        printf("\n");
    }
    for (int i=0; i<c+1; i++){
        printf("%d", col[i]);
        if (i < c) printf(" ");
    }
    printf("\n");
    return 0;
}



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

#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) for(int i=int(n-1);i>=0;i--)
#define forn(i,n) for(int i=0;i<int(n);i++)
#define D(a) cerr << #a << " = " << a << endl
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
typedef pair<int,int> pii;
typedef long long int ll;
typedef vector<int> vi;
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    
    int n,m; cin >> n >> m;
    int l = 1;
    forn(i, n) l *= 10;
    int s = l / 10;
    if(s == 1) s = 0;
    int a[m], b[m], res = -1;
    forn(i, m) cin >> a[i] >> b[i], a[i]--;

    forsn(i, s, l) {
        vi d;
        int x = i;
        if(x == 0) d.pb(x);
        while(x) d.pb(x % 10), x /= 10;
        reverse(all(d));

        bool ok = true;
        forn(j, m)
            if(d[a[j]] != b[j]) ok = false;   
        if (ok) { res = i; break; }
    }
    
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
using namespace std;

int main(){
    int D;
    scanf("%d", &D);

    if(D == 25) printf("Christmas\n");
    if(D == 24) printf("Christmas Eve\n");
    if(D == 23) printf("Christmas Eve Eve\n");
    if(D == 22) printf("Christmas Eve Eve Eve\n");

    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		String str = stdIn.next();
		int size = str.length();
		for(int i = size - 1; i >= 0; --i)
		{
			System.out.print(str.charAt(i));
		}
		System.out.println("");
	}
}

Measured memory_bytes: 11000
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int n;
vector<int> vec;
/**********************************************/

int main(){
    cin >> n;
    vec.resize(n);

    REP(i, n) cin >> vec[i];

    VSORT(vec);
    if(n % 2 == 0){
        REP(i, n){
            if(vec[i] != 1 + (i / 2) * 2){
                cout << 0 << endl;
                return 0;
            }
        }
    }else{
        if(vec[0] != 0){
            cout << 0 << endl;
            return 0;
        }
        FOR(i, 1, n){
            if(vec[i] != ((i-1) / 2 + 1) * 2){
                cout << 0 << endl;
                return 0;
            }
        } 
    }
    
    int num = n/2;
    LL ans = 1;
    REP(i, num){
        ans = ans * 2 % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
n = int(input())
l = [0]

for i in range(1, n+1):
    a = 0
    b = 0
    while 6**(a+1) <= i: 
        a += 1
    while 9**(b+1) <= i:
        b += 1
    l += [min([l[i-6**p] for p in range(1, a+1)] + [l[i-9**q] for q in range(1, b+1)] + [l[i-1]]) + 1]

print(l[n])

Measured memory_bytes: 3860
#include <iostream>
using namespace std;
int main(void){
    int n,l[12];
    cin>>n;
    l[n]=l[n+1]=0;
    for(int i=0;i<n;i++){
        cin>>l[i];
        l[n]+=l[i];
        l[n+1]=max(l[n+1], l[i]);
    }
    if(l[n+1]*2<l[n]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import math

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

def roundUp(x):
    '''
    Takes integer x.
    Returns x rounded up to the next multiple of 10
    '''

    while x%10 != 0:
        x = x + 1
    return x

arounded = (a-1)%10
brounded = (b-1)%10
crounded = (c-1)%10
drounded = (d-1)%10
erounded = (e-1)%10
if min(arounded, brounded, crounded, drounded, erounded) == arounded:
    print(roundUp(b) + roundUp(c) + roundUp(d) + roundUp(e) + a)
elif min(arounded, brounded, crounded, drounded, erounded) == brounded:
    print(roundUp(a) + roundUp(c) + roundUp(d) + roundUp(e) + b)
elif min(arounded, brounded, crounded, drounded, erounded) == crounded:
    print(roundUp(b) + roundUp(a) + roundUp(d) + roundUp(e) + c)
elif min(arounded, brounded, crounded, drounded, erounded) == drounded:
    print(roundUp(b) + roundUp(c) + roundUp(a) + roundUp(e) + d)
else:
    print(roundUp(b) + roundUp(c) + roundUp(d) + roundUp(a) + e)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0; i<(long long)(n); i++)
#define REP(i, k, n) for(long long i=(long long)(k); i<(long long)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const ll inf = 1020304050607080910;
const int INF = 1073741823;
const ll mod = 1000000007;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x,ll y){if(x>y)swap(x, y);while(x!=0){y%=x;swap(x, y);}return y;}
ll mpow(ll x,ll r){if(r==0)return 1;if(r%2==1){return x*mpow(x,r-1)%mod;}else{ll aa=mpow(x,r/2);return aa*aa%mod;}}

const int MAX = 600002;

// fac[]・・・a! finv[]・・・(a!)^(-1) inv[]・・・a^(-1)

long long fac[MAX], finv[MAX], inv[MAX];

void pre_comb(void){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<MAX; i++){
		fac[i] = fac[i-1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod/i) % mod;
		finv[i] = finv[i-1] * inv[i] % mod;
	}
}

long long comb(int n, int k){
	if(n < k) return 0;
	if(n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}


int main(){
	pre_comb();
	ll N, M; cin >> N >> M;
	ll dp[N+1];
	dp[1] = M-N;
	for(int i=2; i<=N; i++){
		if(i==2){
			dp[i] = (M-N+1 + (M-N)*(M-N)%mod)%mod;
		}else{
			dp[i] = ((i-1)*(dp[i-1]+dp[i-2])%mod + (M-N)*dp[i-1])%mod;
		}
	}
	ll ans = 1;
	for(int i=M; i>=M-N+1; i--) ans = (ans * i)%mod;
	cout << ans*dp[N]%mod << endl;
	return 0;
}


Measured memory_bytes: 21520
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    final double EPS = 1.0e-10;
    final int INF = 1 << 28;
    boolean used[];
    int nums[];
    String[] strs;
    Character[] cs;
    int ans;
    int[] cf;
    boolean init[];

    void run() {
        Scanner sc = new Scanner(System.in);
        int[] pow10 = new int[8];
        pow10[0] = 1;
        for (int i = 1; i < pow10.length; i++) {
            pow10[i] = pow10[i - 1] * 10;
        }
        while (true) {
            int n = sc.nextInt();
            if (n == 0)
                break;
            strs = new String[n];
            Set<Character> set = new HashSet<Character>();
            for (int i = 0; i < n; i++) {
                strs[i] = sc.next();
                char[] tmp = strs[i].toCharArray();
                for (int j = 0; j < tmp.length; j++) {
                    set.add(tmp[j]);
                }
            }
            init = new boolean[256];
            for (int i = 0; i < n; i++) {
                if (strs[i].length() < 2)
                    continue;
                init[strs[i].charAt(0)] = true;

            }
            cs = new Character[set.size()];
            cs = set.toArray(cs);

            cf = new int[256];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < strs[i].length(); j++) {
                    if (i == n - 1) {
                        cf[strs[i].charAt(j)] -= pow10[strs[i].length() - 1 - j];
                    } else
                        cf[strs[i].charAt(j)] += pow10[strs[i].length() - 1 - j];
                }
            }
            nums = new int[cs.length];
            used = new boolean[10];
            ans = 0;
            permutation(0, 9, cs.length, 0);
            System.out.println(ans);
        }
    }

    void permutation(int pos, int n, int k, int sum) {
        if (pos == k) {
            if (sum == 0) {
                ans++;
            }
            return;
        }

        for (int i = 0; i <= n; i++) {
            if (used[i])
                continue;
            if (i == 0 && init[cs[pos]])
                continue;
            nums[pos] = i;
            used[i] = true;
            permutation(pos + 1, n, k, sum + i * cf[cs[pos]]);
            used[i] = false;
        }
        return;
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 12000
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

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

    switch(n % 10){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            break;
        case 3:
            cout << "bon" << endl;
            break;
    }

    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
typedef long long LL;
const LL mod = 1e9 + 7;
// head
const int maxn = 105;
int n, a[maxn], d, cnt[maxn];

int main() {
	cin>>n;
	rep(i, 1, n) cin>>a[i], d = max(a[i], d), cnt[a[i]]++;
	per(i, d, d/2 + 1) {
		if(cnt[i] < 2) {
			cout<<"Impossible"<<endl;
			return 0;
		}
		cnt[i] -= 2;
	}
	if(d%2 == 0) {
		if(cnt[d/2] != 1) {
			cout<<"Impossible"<<endl;
			return 0;
		} 
		cnt[d/2]--;
	}
	rep(i, 1, (d + 1)/2) 
	    if(cnt[i]) {
	    	cout<<"Impossible"<<endl;
	    	return 0;
	    }
	cout<<"Possible"<<endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  
  int x, n;
  cin >> x >> n;
  vector<int> a(n);
  int ans = 0;
  rep(i,n){
    cin >> a[i];
    if(a[i] == x) ans = 1;
  }
  
  if(ans){
    for(int i = 1; i<100; i++){
      ans = 0;
      int check1 = x-i;
      int check2 = x+i;

      rep(j, n){
        if(check1 == a[j]) ans += 1;
        if(check2 == a[j]) ans += 2;
      }
      
      if(ans == 0 || ans == 2){
        cout << check1 << endl;
        break;
      }
      else if(ans == 1){
        cout << check2 << endl;
        break;
      }
    }
  }
  else cout << x << endl;
  
return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
	int n,y;
	cin >> n >> y;
	for(int i=0;i*1000<=y;i++){
		for(int j=0;i*1000+j*5000<=y;j++){
			int k = n-i-j;
			if(i*1000+j*5000+k*10000==y){
				cout << k << " " << j << " " << i << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)

void add_mod(ll &a, ll b){
	a += b;
	a %= MOD;
}

void mul_mod(ll &a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	int n,k,a,p,i;
	cin >> n >> k;
	for(i=0; i<n; ++i){
		cin >> a;
		if(a == 1){
			p = i;
		}
	}
	cout << ((n-2)/(k-1)+1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;

int n;
ll a[300005];

int main(int argc, char const *argv[]) {
	cin >> n;
	FOR(i, 3*n) {
		cin >> a[i];
	}
	sort(a, a+3*n);
	ll ans = 0;
	FOR(i, n) ans += a[2*i+n];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
long long mod = 1e9 + 7;

long long mod_inv(long long x){
  long long k = mod - 2, ret = 1;
  while(k){
    if(k&1) ret *= x, ret %= mod;
    x *= x, x %= mod;
    k >>= 1;
  }
  return ret;
}

int main(){
  int N, X;
  cin >> N >> X;
  vector<int> S(N);
  for(int i = 0; i < N; ++i) cin >> S[i];
  sort(S.rbegin(), S.rend());
  vector<long long> DP(X+1,0);
  vector<long long> F(N+1,1), inv(N+1);
  for(int i = 0; i < N; ++i) F[i+1] = (F[i]*(i+1))%mod;
  for(int i = 0; i <= N; ++i) inv[i] = mod_inv(i);
  DP[X] = 1;
  for(int i = 0; i < N; ++i){
    vector<long long> DP_(X+1,0);
    for(int j = 0; j <= X; ++j){
      DP_[j%S[i]] += DP[j];
      DP_[j%S[i]] %= mod;
      DP_[j] += DP[j]*(N-i-1)%mod;
      DP_[j] %= mod;
    }
    DP = DP_;
    // cerr << "i = " << i << endl;
    // for(int j = 0; j <= X; ++j) cerr << j << " : " << DP[j] << endl;
  }
  long long ans = 0;
  for(int i = 0; i <= X; ++i){
    ans += DP[i]*i;
    ans %= mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
public class diverta2019PC2C {
    public static void Main() {
        int N, ApMin = 100000, AmMax = -100000, ApMinIndex = -1, AmMaxIndex = -1, ans = 100000, ansIndex = -1;
        List<int> Left = new List<int>(), Right = new List<int>();
        List<int> Ap = new List<int>(), Am = new List<int>();
        N = int.Parse(Console.ReadLine());
        string[] str = Console.ReadLine().Split(' ');
        int a;
        for (int i = 0; i < N; i++) {
            a = int.Parse(str[i]);
            if (a >= 0) {
                Ap.Add(a);
                if (ApMin > a) {
                    ApMin = a;
                    ApMinIndex = Ap.Count - 1;
                }
            } else {
                Am.Add(a);
                if (AmMax < a) {
                    AmMax = a;
                    AmMaxIndex = Am.Count - 1;
                }
            }
        }

        if (Ap.Count != 0) {
            if (Ap.Count == 1) {
                ans = Ap[0];
                ansIndex = 0;
            } else {
                if (ApMinIndex == 0) {
                    ans = Ap[1];
                    ansIndex = 1;
                } else {
                    ans = Ap[0];
                    ansIndex = 0;
                }
            }
        }

        for (int i = 0; i < Ap.Count; i++) {
            if (Am.Count != 0) {
                if (i == ansIndex) continue;
                Left.Add(Am[0]);
                Right.Add(Ap[i]);
                Am[0] -= Ap[i];
            } else {
                if (i == ansIndex || i == ApMinIndex) continue;
                Left.Add(ApMin);
                Right.Add(Ap[i]);
                ApMin -= Ap[i];
            }
        }
        if (Am.Count == 0) {
            Left.Add(ans);
            Right.Add(ApMin);
            ans -= ApMin;
        }

        if (Ap.Count != 0) {
            for (int i = 0; i < Am.Count; i++) {
                Left.Add(ans);
                Right.Add(Am[i]);
                ans -= Am[i];
            }
        } else {
            for (int i = 0; i < Am.Count; i++) {
                if (i == AmMaxIndex) continue;
                Left.Add(AmMax);
                Right.Add(Am[i]);
                AmMax -= Am[i];
            }
            ans = AmMax;
        }
        System.Console.WriteLine(ans);
        for (int i = 0; i < Left.Count; i++) {
            Console.WriteLine("{0} {1}", Left[i], Right[i]);
        }
    }
}


Measured memory_bytes: 30664
#include <algorithm>
#include <cmath>
#include <tuple>
#include <vector>

// T: sorted by x-axis
template<class T>
std::tuple<double, typename std::iterator_traits<T>::value_type, typename std::iterator_traits<T>::value_type>
closest_pair(T left, T right) {
    using V = typename std::iterator_traits<T>::value_type;

    const int N = std::distance(left, right);

    if (N == 1) {
        return std::make_tuple(std::numeric_limits<double>::max(), *left, *left);
    }

    T mid = std::next(left, N / 2);
    double x = std::get<0>(*mid);
    auto d = std::min(closest_pair(left, mid), closest_pair(mid, right));
    std::inplace_merge(left, mid, right,
                       [](const V &a, const V &b) { return std::get<1>(a) <= std::get<1>(b); });

    std::vector<V> b;
    b.reserve(N);
    for (T it = left; it != right; ++it) {
        if (fabs(std::get<0>(*it) - x) >= std::get<0>(d)) continue;

        for (auto jt = b.rbegin(); jt != b.rend(); ++jt) {
            if (fabs(std::get<0>(*it) - x) >= std::get<0>(d)) continue;
            double dx = std::get<0>(*it) - std::get<0>(*jt);
            double dy = std::get<1>(*it) - std::get<1>(*jt);
            if (dy >= std::get<0>(d)) break;
            if (sqrt(dx * dx + dy * dy) < std::get<0>(d)) {
                d = std::make_tuple(sqrt(dx * dx + dy * dy), *it, *jt);
            }
        }
        b.push_back(*it);
    }
    return d;
}

int main() {
    int n;
    scanf("%d", &n);
    std::vector<std::tuple<double, double>> v(n);
    for (int i = 0; i < n; ++i) {
        double a, b;
        scanf("%lf%lf", &a, &b);
        v[i] = std::make_tuple(a, b);
    }
    std::sort(v.begin(), v.end());
    auto ans = closest_pair(v.begin(), v.end());
    printf("%.7f\n", std::get<0>(ans));
}



Measured memory_bytes: 6376
N, K = map(int, input().split())
d = [0] * K
y = [0] * N
for i in range(K):
    d[i]=int(input())
    A= list(map(int, input().split()))
    for x in A:
        y[x-1]+=1
a=0
for ans in y:
    if ans==0:
          a+=1
print(a)

Measured memory_bytes: 67720
S = input()
i = 0
n = 0
while i < len(S) - 1:
        if S[i] != S[i + 1]:
                n += 2
                S = S[:i] + S[i + 2:]
                if i > 0:
                        i -= 1
        else:
                i += 1
print(n)

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

int main() {
  int N;
  cin >> N;
  int V[N],C[N];
  for(int i=0; i<N ; i++){
    cin >> V[i];
  }
  for(int i=0; i<N ; i++){
    cin >> C[i];
  }
  int ans=0;
  for(int i=0; i<N ; i++){
    if(V[i] - C[i] >0) ans += V[i] -C[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b>> c >> d;
 
  if (a+b > c + d) {
    cout << "Left" << endl;
  }else if (a+b == c + d) {
      cout << "Balanced" << endl;
  }else{
      cout << "Right" << endl;
  }
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

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

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

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

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

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  while(cin>>n&&n){
    string s = to_string((n % 39 ==0)?39 : n%39);
    while(s.size()<2){
      s = "0"+s;
    }
    cout << "3C"<<s<<endl;
  }
  return 0;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
typedef long long int lli;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define MAXN 100005
int dp[MAXN],h[MAXN];
int main(){__
	int n;
	cin >> n;
	for(int i=1; i <=n; i++){
		cin >> h[i];
		dp[i] = 1<<30;
	}
	dp[1] = 0;

	for(int i=2; i <=n; i++){
		if( i-1 >= 1){
			dp[i] = min(dp[i],dp[i-1] + abs(h[i] - h[i-1]));
		}
		if(i-2 >= 1){
			dp[i] = min(dp[i],dp[i-2] + abs(h[i] - h[i-2]));
		}
	}
	cout << dp[n] << endl;
}


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

int main(){
    int n,mx=0;
    map<string,int>mp;
    map<string,int>::iterator it;
    cin>>n;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        mp[s]++;
        mx=max(mx,mp[s]);
    }
    for(auto i: mp){
        if(i.second==mx){
            cout<<i.first<<"\n";
        }
    }
    return 0;
}


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

using namespace std;

int N, x[2], y[2], t[2], cur = 0, pre = 1;

int main() {
//	freopen("input.txt", "r", stdin);	
	
	cin >> N;
	while(N--) {
		cur ^= 1;
		pre ^= 1;
		scanf("%d%d%d", t + cur, x + cur, y + cur);
		int V = abs(x[cur] - x[pre]) + abs(y[cur] - y[pre]);
		if(V > t[cur] - t[pre] || (t[cur] - t[pre] - V) % 2 == 1) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;

int n, k, x;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> k;
    vector<ll> neg, pos;
    for (int i = 0; i < n; i++) {
        cin >> x;
        if (x == 0) k--; 
        else if (x < 0) neg.push_back(x);
        else pos.push_back(x);
    }
    
    if (!k) {
        cout << 0;
        return 0;
    }

    sort(neg.begin(), neg.end(), greater<ll>());

    ll ans = INF;
    int nt = min(k, (int)neg.size()), pt = k - nt;
    while (nt >= 0 && pt <= (int)pos.size()) {
        ll dist = 0;
        if (nt > 0) dist = abs(neg[nt - 1]);
        if (pt > 0) {
            if (pos[pt - 1] < dist) dist += pos[pt - 1] * 2;
            else {
                dist *= 2;
                dist += pos[pt - 1];
            }
        }
        
        ans = min(ans, dist);
        nt--;
        pt++;
    }
    cout << ans;
}


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

typedef long long ll;
const long long LINF = 1LL << 60;
const long long LMINF = 1LL << 63;
const int INF = 1 << 30;

#define REP(i,n) for(int i = 0;i < n;++i)
#define REPS(i,x) for(int i = 1;i <= (int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i >= 0;i--)
#define RREPS(i,x) for(int i=((int)(x));i > 0;i--)
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << x << "\n"

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 main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n,m,x;
    cin >> n >> m >> x;
    vector<int> a(m);
    REP(i,m)cin >> a[i];
    int cl = 0,ch = 0;
    for(int i = x - 1;i >= 0; i--){
        REP(j,m){
            if(i == a[j]){
                cl++;
            }
        }
    }
  
    for(int i = x + 1;i < n + 1; i++){
        REP(j,m){
            if(i == a[j]){
                ch++;
            }
        }
    }

    cout << min(cl,ch) << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
vector<P> v;
ll n,b[100000],c[100000],p,q,ans,rans,pp=1e9;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>p>>q;
        v.push_back({p,q});
        pp=min(pp,q);
    }
    sort(v.begin(),v.end());
    b[0]=v[0].S;
    c[n-2]=v[n-1].S;
    for(int i=1;i<n-1;i++){
        b[i]=min(b[i-1],v[i].S);
        c[n-i-2]=min(c[n-i-1],v[n-i-1].S);
    }
    for(int i=0;i<n-1;i++){
        rans=max(0LL,1+b[i]-v[i].F)+max(0LL,c[i]-v[n-1].F+1);
        rans=max(rans,max(0LL,pp-v[n-1].F+1)+v[i].S-v[i].F+1);
        ans=max(ans,rans);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3568
str1, str2 = input(), input()


def check(s1, s2):
    return s1 == s2


def move(s, i):
    n = len(s)
    temp = ""
    for j in range(n):
        temp += s[(j+i) % n]

    return temp


N = len(str1)

for i in range(N):
    temp = move(str1, i)
    if check(temp, str2):
        print("Yes")
        break
    if i == (N-1):
        print("No")


Measured memory_bytes: 39408
sieve = [True] * (10**6 + 1)
for i in range(2, 10**3):
  if sieve[i]:
    for j in range(i**2, 10**6, i):
      sieve[j] = False
sieve[0] = sieve[1] = False
x = int(input())
ind = x
while True:
  if sieve[ind]:
    print(ind)
    break
  ind += 1

Measured memory_bytes: 10868
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <utility>

#include <cassert>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define FOR(i,a,b) for(ll i=(a); i < (b); i++)
#define RFOR(i,a,b) for(ll i=(b)-1; i >= (a); i--)
#define rep(i,n) FOR(i,0,(n))
#define rrep(i,n) RFOR(i,0,(n))

ll S[1100];

int main() {
	ll N, K;
	cin >> N >> K;
	vector<ll> a(N), b;
	rep(i,N) {
		cin >> a[i];
		S[i+1] = S[i] + a[i];
	}

	rep(i,N)
		FOR(j,i,N)
			b.push_back(S[j+1] - S[i]);
	assert(b.size() == N*(N+1)/2);

	ll res = 0;
	for(ll i = 62; i >= 0; i--) {
		vector<ll > c;
		rep(j,b.size()) {
			if(b[j] & (1ll << i)) {
				c.push_back(b[j]);
			}
		}
		if(c.size() >= K) {
			res |= 1ll << i;
			b = c;
		}
	}
	/*
	for(int i  = 0; i < b.size(); i++)
		cout << b[i] << " ";
	cout << endl;
	// */

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 6536
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

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

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

string s;
int a[20];
int n;

int main() {
    //freopen("in.txt", "r", stdin);
    
    cin >> n;
    FOR (i,0,n) cin >> a[i];
    LL e1,e2;
    e1=1,e2=0;
    int T = 1;
    FOR (i,0,n) T*=3;
    FOR (i,0,T)
    {
        int ok = 1;
        int M = i;
        FOR (j,0,n)
        {
            int z = M%3;            M /= 3;
            if ((a[j]+1-z) % 2 == 0)
                ok = 0;
        }
        if (!ok) e2++;
    }
    cout << e2;
    
}




Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int a, b, h;
    scanf("%d %d %d", &a, &b, &h);
    printf("%d", (a+b)*h/2);
   
}


Measured memory_bytes: 3816
def main():
    S = list(input())
    a = S.count('a')
    b = S.count('b')
    c = S.count('c')
    if a == b and b == c:
        print('YES')
    elif abs(a - b) > 1 or abs(b - c) > 1 or abs(a-c) > 1:
        print('NO')
    else:
        print('YES')

if __name__ == '__main__':
    main()

Measured memory_bytes: 49136
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ull unsigned ll
#define pb push_back
#define popb pop_back
#define mt make_tuple
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define piii pair <pii,int>
#define piiii pair <pii,pii>
#define plll pair <pair <ll, ll>, ll>
#define rep0(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<=(ll)n;i++)
#define rep(i,x,y) for(ll i=(ll)x;i<=(ll)y;i++)
#define reprev(i,n) for(ll i=(ll)n;i>=0;i--)
#define all(c) c.begin(),c.end()
#define print(a) rep0(i,a.size()) cout << a[i] << " "
#define hi() cout << "\nHello, I am error. Can you find me? :):):)\n"
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_eppoch().count())
 
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>;

const int mod = 1e9+7;
const long double pi = acos(-1);

ll power(ll x, ll y){
	x %= mod;
	if(y == 0) return 1;
	if(y == 1) return x;
	ll num = power(x,y/2) % mod;
	if(y%2 == 0) return (num*num)%mod;
	else return (((num*num)%mod)*x)%mod;
}


void solve(){

	int a,b,c;
	cin >> a >> b >> c;
	cout << c << " " << a <<  " " << b;

	return;
}

int main(){

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

	int TC = 1,t = 0;
	// cin >> TC;
	while(t++ < TC){
		// cout << "Case #" << t << ": ";
		solve();
		// cout << "\n";
	}

	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

	return 0; 
}

Measured memory_bytes: 256
import numpy as np
k=input()
d=int(input())
m=10**9+7
t=np.zeros(d)
s=0
for i in k:
    p=np.zeros(d)
    for j in range(10):
        p+=np.hstack([t[-(j%d):],t[:-(j%d)]])
    for j in range(int(i)):
        p[(s+j)%d]+=1
    t=p[::]%m
    s+=int(i)
t[s%d]+=1
print((int(t[0])-1)%m)

Measured memory_bytes: 14420
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(){
    int A,X,N;
    scanf("%d",&N);
    if(N==25){
        printf("%s\n","Christmas");
    }else if(N==24){
        printf("%s\n","Christmas Eve");
    }else if(N==23){
        printf("%s\n","Christmas Eve Eve");
    }else{
        printf("%s\n","Christmas Eve Eve Eve");
    }
    return 0;
}

Measured memory_bytes: 128