akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

const int D=365;
int csum;
int c[26];
int s[D][26];
int last[26];

set<int>se[26];

int ans[D];

int cur_score;

int score(){
	memset(last,-1,sizeof(last));
	int sum=0;
	int diff=0;
	rep(i,D){
		sum+=s[i][ans[i]];
		diff+=csum;
		diff-=(i-last[ans[i]])*c[ans[i]];
		sum-=diff;
		last[ans[i]]=i;
	}
	cur_score=sum;
	return sum;
}

int SUM(int b,int n){
	return (b*(n-1))*n/2;
}
int update(int pos,int d){
	int x=ans[pos];
	//~ cerr<<"update!"<<endl;
	assert(se[x].count(pos));
	auto it=se[x].find(pos);
	int diff=0;
	diff-=s[pos][x];
	diff+=s[pos][d];
	
	diff+=SUM(c[x],*it-*prev(it));
	diff+=SUM(c[x],*next(it)-*it);
	diff-=SUM(c[x],*next(it)-*prev(it));

	se[x].erase(it);
	ans[pos]=d;

	it=se[d].lower_bound(pos);
	diff+=SUM(c[d],*it-*prev(it));
	diff-=SUM(c[d],pos-*prev(it));
	diff-=SUM(c[d],*it-pos);
	se[d].insert(pos);

	cur_score+=diff;
	return cur_score;
}

int main(){
	rep(i,26){
		se[i].insert(-1);
		se[i].insert(D);
	}
	scanf("%*d");
	rep(i,26)scanf("%d",&c[i]),csum+=c[i];
	rep(i,D)rep(j,26)scanf("%d",&s[i][j]);
	rep(i,D){
		ans[i]=max_element(s[i],s[i]+26)-s[i];
		se[ans[i]].insert(i);
	}
	random_device rnd;
	mt19937 mt(rnd());
	uniform_real_distribution<double>Real(0,1);
	int Max=score();
	double stmp=10000,etmp=0;
	int upd=0;
	int LOOP=6000000;
	rep(loop,LOOP){
		int pos=mt()%D;
		int sum=0;
		rep(i,26)sum+=s[pos][i];
		int ch=mt()%sum;
		int d=-1;
		rep(i,26){
			ch-=s[pos][i];
			if(ch<0){d=i;break;}
		}
		assert(d!=-1);
		int old=ans[pos],old_score=cur_score;
		int nx=update(pos,d);
		//~ cerr<<old_score<<' '<<nx<<' '<<score()<<endl;
		//~ assert(nx==score());
		double tmp=stmp+(etmp-stmp)/LOOP*loop;
		double p=exp(-double(abs(Max-nx))/tmp);
		if(Max<nx||Real(mt)<p){
			Max=nx;upd++;
		}
		else{
			se[d].erase(pos);
			se[old].insert(pos);
			ans[pos]=old;
			cur_score=old_score;
		}
	}
	cerr<<upd<<endl;
	rep(i,D){
		cout<<ans[i]+1<<endl;
	}
	cerr<<"score: "<<Max<<' '<<score()<<endl;
}

Measured memory_bytes: 4460
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
template<class T> bool chmax(T &a,const T &b) {if(a<b) {a=b;return 1;} return 0;}
template<class T> bool chmin(T &a,const T &b) {if(b<a) {a=b;return 1;} return 0;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n,m;
    cin>>n>>m;
    map<pii,vector<pair<pii,int>>> exg;
    REP(i,m) {
        int a,b,c;
        cin>>a>>b>>c;
        a--,b--;
        exg[{a,-1}].push_back({{a,c},1});
        exg[{a,c}].push_back({{a,-1},0});
        exg[{b,-1}].push_back({{b,c},1});
        exg[{b,c}].push_back({{b,-1},0});
        exg[{a,c}].push_back({{b,c},0});
        exg[{b,c}].push_back({{a,c},0});
    }
    
    heap<pair<int,pii>> hp;
    map<pii,int> dist;
    dist[{0,-1}]=0;
    hp.push({0,{0,-1}});
    while(!hp.empty()) {
        pii v=hp.top().second; hp.pop();
        FORE(e,exg[v]) {
            if(!CONTAIN(dist,e.first)) dist[e.first]=INF;
            if(dist[e.first]>dist[v]+e.second) {
                dist[e.first]=dist[v]+e.second;
                hp.push({dist[e.first],e.first});
            }
        }
    }
    if(!CONTAIN(dist,pii(n-1,-1))) cout<<-1<<endl;
    else cout<<dist[{n-1,-1}]<<endl;
    return 0;
}


Measured memory_bytes: 113836
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: usize,
        s: [String; n],
    }

    let mut march = [0_u64; 5];
    for x in s {
        let name: Vec<char> = x.chars().collect();
        match name[0] {
            'M' => march[0] += 1,
            'A' => march[1] += 1,
            'R' => march[2] += 1,
            'C' => march[3] += 1,
            'H' => march[4] += 1,
            _ => {},
        }
    }
    let mut ans = 0;
    for i in 0..5 {
        for j in i + 1..5 {
            for k in j + 1..5 {
                ans += march[i] * march[j] * march[k]
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 8316
#include <stdio.h>
#include <math.h>
#define ll long long
ll f(ll a,ll b)
{
	return b==0?a:f(b,a%b);
}
int main()
{
	ll m,n,i,j,k,a,b,c,d;
	while(~scanf("%lld%lld%lld%lld",&a,&b,&c,&d))
	{
		m=f(c,d);
		m=c*d/m;
		a-=1;
		n=b-a-(b/c-a/c+b/d-a/d-(b/m-a/m));
		printf("%lld\n",n);
	}
	return 0;
}

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

int main(void){
    string s;
    string ans = "";
    cin >> s;
    
    for(int i=0;i<s.length();i++){
        if(s[i] == '0'){
            ans += "0";
        }else if(s[i] == '1'){
            ans += "1";
        }else if(s[i] == 'B' && ans.length() > 0){
            ans.pop_back();
        }
    
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD=1e9+7;
/*
【解法】
A = [1, 2, ..., n] と固定する（求める場合の数は、固定した場合の数の mPn 倍）。B を長さ n の数列とする

ある集合 S \subset {1, ..., n} の上で値が一致する（そのほかにも一致する値のある可能性がある）ような B の場合の数は g(S) = (m-|S|)P(n-|S|) 通り
（まだ決まっていない n-|S| 箇所の値を、使っていない m-|S| 個の値から重複しないように決める）

ある集合 S \subset {1, ..., n} の上でちょうど値が一致する（ S に属さない点 i ではA[i] != B[i] となる）ような
B の場合の数を f(S) 通りとすると、g(S) = \sum_{S\subset T} f(T) となる。

F(S) = f({1, ..., n} \setminus S), G(S) = g({1, ..., n} \setminus S) とおくと、
G(S) = \sum_{T\subset S} F(S) なので、包除原理から F(S) = \sum_{T\subset S} (-1)^|S\setminus T| G(T) が成り立つ。

求めるのは f(\emptyset)
= F({1, ..., n})
= \sum_{T\subset {1, ..., n}} (-1)^|{1, ..., n}\setminus T| G(T)
= \sum_{T\subset {1, ..., n}} (-1)^|{1, ..., n}\setminus T| g({1, ..., n} \setminus T)
= \sum_{T\subset {1, ..., n}} (-1)^|T| g(T)
（ T -> T\setminus {1, ..., n} で置換）
ここで g は size の関数なので g(T) = g(|T|) とおくと、 k 元集合の選び方が nCk 通りなので 
= \sum_{k=0}^n (-1)^k nCk g(k)
= \sum_{k=0}^n (-1)^k n! / (n-k)! / k! * (m-k)! / (m-n)!
となる。

これを高速に計算する。 k == 0 のとき m! / (m-n)! で、

    n! (m-k)!             n! (m-(k-1))!          n-k+1
---------------- == ------------------------ * ---------
(n-k)! k! (m-n)!    (n-(k-1))! (k-1)! (m-n)!   (m-k+1) k

なので、 k がふえるたびに (n-k+1) / (m-k+1) / k 倍すればよい
*/
ll inv_table[500001] = {};
void make_inv_table(int n){
    inv_table[1] = 1;
    for (int i=2; i<=n; ++i){
        // (MOD / i) * i + MOD % i = 0 なので
        // (MOD / i) * i = - (MOD % i)
        // - (MOD / i) * (MOD % i)^(-1) = i^(-1)
        inv_table[i] = inv_table[MOD%i] * (MOD - MOD / i) % MOD;
    }
}

ll npr(ll n, ll r){
    ll ans = 1;
    for(ll i=n-r+1; i<=n; ++i)ans = (ans * i) % MOD;
    return ans;
}

int main()
{
    ll n, m;
    cin >> n >> m;

    const ll mpn = npr(m, n);
    ll tmp = mpn;
    ll sum = tmp;
    const ll sign[2] = {1, MOD-1};
    make_inv_table(m);
    for(int k=1; k<=n; ++k){
        tmp = ((tmp * inv_table[m-k+1]) % MOD * (inv_table[k] * (n-k+1) % MOD)) % MOD;
        sum = (sum + sign[k%2] * tmp) % MOD;
    }
    cout << (sum * mpn) % MOD;
    return 0;
}


Measured memory_bytes: 7440
Imports System.Collections.Generic
Imports System.Console
Imports System.Math

Module Program
    Sub Main()
        Dim N As Integer = NextInt()
        Dim M As Integer = NextInt()

        Dim students As Integer(,) = New Integer(N - 1, 1) {}
        Dim checkPoints As Integer(,) = New Integer(M - 1, 1) {}

        For i As Integer = 0 To N - 1
            students(i, 0) = NextInt()
            students(i, 1) = NextInt()
        Next

        For j As Integer = 0 To M - 1
            checkPoints(j, 0) = NextInt()
            checkPoints(j, 1) = NextInt()
        Next

        For i As Integer = 0 To N - 1
            Dim index As Integer = -1
            Dim value As Integer = Integer.MaxValue
            For j As Integer = 0 To M - 1
                Dim x1 As Integer = students(i, 0)
                Dim y1 As Integer = students(i, 1)
                Dim x2 As Integer = checkPoints(j, 0)
                Dim y2 As Integer = checkPoints(j, 1)
                Dim Calc_result As Integer = Calc(x1, x2, y1, y2)

                If Calc_result < value Then
                    index = j
                    value = Calc_result
                End If
            Next
            WriteLine(index + 1)
        Next
    End Sub

    Function Calc(x1 As Integer, x2 As Integer,
                  y1 As Integer, y2 As Integer) As Integer
        Return Abs(x1 - x2) + Abs(y1 - y2)
    End Function

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 19920
#include <string>
#include <algorithm>
#include <vector> 
#include <math.h>
#include <iostream>
using namespace std;


int main()
{
	int s;
	cin >> s;
	int f = s;
	while (1) {
		if (f % 111 == 0) {
			break;
		}
		else {
			f = f + 1;
		}
	}
	cout << f << endl;
	return 0;

}

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

int main(){
  ll n; 
  cin>>n;
  string s = to_string(n);
  int sum(0);
  for (int i(0);i<s.size();i++){
    sum+=(s[i]-'0');
  }
  if (n%sum==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> row;
typedef vector<row> matrix;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
int main() {
	//file();
	fast();
	string str; cin >> str;
	if (str == "Sunny")
		cout << "Cloudy" << endl;
	else if (str == "Cloudy")
		cout << "Rainy" << endl;
	else
		cout << "Sunny" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 5 //整数の入力回数は必ず5

void func_sort(int array[]);
void func_output(int array[]);

main()
{
	int array[5] = {0, 0, 0, 0, 0};
	int i = 0;
	for(i = 0; i < MAX; i++)
	{
		scanf("%d", &array[i]);
	}
	
	func_sort(array);
	func_output(array);
	return 0;
}
void func_sort(int array[])
{
	int i = 0, j = 0;
	for(i = 0; i < MAX; i++)
	{
		for(j = i + 1; j < MAX; j++)
		{
			if(array[i] < array[j])
			{
				int temp = array[j];
				array[j] = array[i];
				array[i] = temp;
			}
		}
	}
}
void func_output(int array[])
{
	int i = 0;
	for(i = 0; i < MAX; i++)
	{
		if(i < MAX - 1)
		{
			printf("%d ", array[i]);
		}
		else
		{
			printf("%d\n", array[i]);
		}
	}
}

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

using namespace std;

int main(){

	int x = 0, y = 0, c = 0, n;
	scanf("%d", &n);

	while(n--){
		int u, v, t;
		scanf("%d%d%d", &t, &u, &v);

		int len = abs(x - u) + abs(y - v);


		if(t - c < len || (t - c) % 2 != len % 2) {
			cout << "No";
			return 0;
		}
	}

	cout << "Yes";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  if(n>=1800)
    cout<<1;
  else if(n>=1600 && n<=1799)
    cout<<2;
  else if(n>=1400 && n<=1599)
    cout<<3;
  else if(n>=1200 && n<=1399)
    cout<<4;
  else if(n>=1000 && n<=1199)
    cout<<5;
  else if(n>=800 && n<=999)
    cout<<6;
  else if(n>=600 && n<=799)
    cout<<7;
  else if(n>=400 && n<=599)
    cout<<8;
  return 0;
}

Measured memory_bytes: 3620
/*
    NEVER GIVE UP!
    THE EXPERT IN ANYTHING WAS ONCE A BEGINNER
*/
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e7+5,INF=1e18;

void solve()
{
    string s,r="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    ll k;
    cin >> k >> s;

    f(i,0,sz(s)-1)
        s[i] =  r [ ( s[i] - 'A' + k ) % 26 ] ;
    
    cout << s ;
}

int32_t main()
{
    FIO
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long maxn,a,b;
	cin>>maxn>>a>>b;
	long long kkk=maxn/(a+b),lll=maxn%(a+b);
	kkk=kkk*a;
	if(lll>a){
		kkk=kkk+lll-(lll-a);
	}else{
		kkk=kkk+lll;
	}
	cout<<kkk<<endl;
	return 0;
}

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

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

int compare_array(vector<int> a1, vector<int>a2) {
  if (a1.size() != a2.size()) {
    return a1.size() - a2.size();
  }
  for (int i=0; i<a1.size(); i++) {
    if (a1.at(i) != a2.at(i)) {
      return a1.at(i) - a2.at(i);
    }
  }
  return 0;
}

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

char int_to_char(int a) {
  if (a == -1) {
    return 'z';
  }
  else {
    return 'a' + a;
  }
}

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int divide_count(int a, int divider) {
  int r = 0;
  while(a % divider == 0) {
    a /= divider;
    r++;
  }
  return r;
}

bool is_prime(int a) {
  int i = 2;
  while(i * i <= a) {
    if(a % i == 0) {
      return false;
    }
    i++;
  }
  return true;
}

int main() {
  std::cout << std::setprecision(9);
  int n;
  cin >> n;

  vector<long> a(n);
  long stock = 0;
  long money = 1000;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    if(i > 0) {
      if(stock == 0 && a[i] > a[i - 1]) {
        stock = money / a[i - 1];
        money -= stock * a[i - 1];
      }
      else if(stock > 0 && a[i] < a[i - 1]) {
        money += stock * a[i - 1];
        stock = 0;
      }
    }
  }
  if (stock > 0) {
    money += stock * a[n - 1];
    stock = 0;
  }

  cout << money << endl;
}

Measured memory_bytes: 3636
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        mut a: [u64;n]
    }
    a.sort();
    a.reverse();
    let mut res = a[0];
    let mut i = 1;
    while i < n/2 {
        res += a[i] * 2;
        i += 1;
    }
    if n % 2 == 1 {
        res += a[i];
    }
    println!("{}", res);
}


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

int main() {
	string X, Y;
	cin >> X >> Y;
	
	bool l = X[0] == Y[2];
	bool m = X[1] == Y[1];
	bool n = X[2] == Y[0];
	
	if(l && m && n) cout << "YES";
	else cout << "NO";
	
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
using ll = long long;

int main(){
    ll n,ans=0;
    cin >> n;
    vector<ll> p(n);
    for(ll i=0;i<n;i++)    cin >> p[i];
    sort(p.begin(),p.end());
    cout << p[n/2]-p[n/2-1];
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include<cstring>

using namespace std;


int main(){
	
	char a[25];
	cin>>a;
	//cout<<a;
	
	if(!strcmp(a,"Sunny")){
		printf("Cloudy");
	}
	if(!strcmp(a,"Cloudy")){
		printf("Rainy");
	}
	if(!strcmp(a,"Rainy")){
		printf("Sunny");
	}
	
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    ll N;
    cin >> N;

    ll Ntmp = N;
    vector<int> cnt;
    for (ll i = 2; i * i <= Ntmp; ++i) {
        int tmp = 0;
        while (!(N % i)) {
            N /= i;
            tmp++;
        }
        cnt.push_back(tmp);
    }
    if (N > 1)
        cnt.push_back(1);

    int ans = 0;
    for (auto i : cnt) {
        for (int j = 1; j <= i; ++j) {
            ans++;
            i -= j;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int m;
    map<int, int> freq;
    cin >> m;
    for(int i = 0; i < m; i++) {
        int a;
        cin >> a;
        freq[a]++;
    }
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if(freq[a] == 0) {
            cout << "NO";
            return 0;
        }
        freq[a]--;
    }
    cout << "YES";
}

Measured memory_bytes: 13016
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            String S = in.next();
            if (S.length() % 2 != 0) {
                out.println("No");
                return;
            }
            for (int i = 0; i < S.length(); i += 2) {
                if (!"hi".equals(S.substring(i, i + 2))) {
                    out.println("No");
                    return;
                }
            }
            out.println("Yes");
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

    }
}



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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

struct Dist{
    double x;
    double y;
};
signed main()
{   
    gearup;
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) a[i]=i;
    vector<Dist> d(n);
    rep(i,n) cin >> d[i].x >> d[i].y;
    double res = 0.0;
    int count = 0;
    do{
        double ans = 0.0;
        rep(i,n-1){
            ans+= sqrt((d[a[i+1]].x - d[a[i]].x)*(d[a[i+1]].x - d[a[i]].x) + 
            (d[a[i+1]].y - d[a[i]].y)*(d[a[i+1]].y - d[a[i]].y));
        }
        count++;
        res += ans;
    }while(next_permutation(all(a)));
    cout << fixed << setprecision(10) << res/count << endl;
}


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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<vector<int>> s(M);
    vector<int> p(M);

    for (int i = 0; i < M; i++)
    {
        int k;
        cin >> k;
        s[i].resize(k);
        for (int j = 0; j < k; j++)
        {
            cin >> s[i][j];
        }
    }

    for (int i = 0; i < M; i++)
        cin >> p[i];

    int sum = 0;
    for (int bit = 0; bit < (1 << N); ++bit)
    {
        for (int i = 0; i < M; i++)
        {
            int count = 0;
            for (int j : s[i])
            {
                if (bit & (1 << (j - 1)))
                    count++;
            }
            if (count % 2 != p[i])
            {
                goto last;
            }
        }
        sum++;
    last:
        continue;
    }

    cout << sum << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)

/*
*/

bool ok=true;
ll n,a[100010],id=0,cnt=0;

void init(){
	cin>>n;
	reg(i,1,n)cin>>a[i];
	reg(i,1,n){
		if(a[i]!=i){
			if(id==0){
				id=i;
			}else{
				if(a[i]==id && a[id]==i){
					cnt++;
					id=0;
				}else{
					ok=false;
				}
			}
		}
	}
	if(cnt>1)ok=false;
	if(id!=0)ok=false;
}

int main(void){
	init();
	cout<<(ok?"YES":"NO")<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(i >= k){
            if(a[i] - a[i-k] > 0) cout << "Yes" << endl;
            else cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 4408
class Dice:
    def __init__(self,numbers):
        self.surface=numbers

    def find_right_side(self,top,flont):
        tf=str(self.surface.index(top))+str(self.surface.index(flont))
        if tf in '12431':
            return int(self.surface[0])
        elif tf in '03520':
            return int(self.surface[1])
        elif tf in '01540':
            return int(self.surface[2])
        elif tf in '04510':
            return int(self.surface[3])
        elif tf in '02530':
            return int(self.surface[4])
        else:
            return int(self.surface[5])

dice=Dice(input().split())
q=int(input())
for i in range(q):
    top,flont=input().split()
    print(dice.find_right_side(top,flont))


Measured memory_bytes: 5600
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define show(x) cout<<#x<<"="<<x<<"\n"
using namespace std;

int n;
ll f[101][11];
ll p[101][12];
const ll inf=9999999999;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
   cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
 cin>>n;
 for(int i=0;i<n;i++){
  for(int j=0;j<10;j++){
   cin>>f[i][j];
  }
 }
 for(int i=0;i<n;i++){
  for(int j=0;j<11;j++){
   cin>>p[i][j];
  }
 }
 ll ans=-inf;
 //cout<<ans<<endl;
 for(int i=1;i<(1<<10);i++){
  ll sum=0;
  for(int j=0;j<n;j++){
   int cont=0;
   for(int k=0;k<10;k++){
    if(!f[j][k])continue;
    if(i&(1<<k)){
     cont++;
    }
   }
   sum+=p[j][cont];
  }
  ans=max(ans,sum);
 }
 cout<<ans<<endl;
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

void solve()
{
        int n = 5;
        vector<pair<int, int>> a(n);
        for (int i = 0; i < n; ++i)
        {
                int x; cin >> x;
                a[i] = {x % 10, x};
        }
        sort(all(a));
        ll t = 0;
        ll ind = 0;
        while (a[ind].first == 0)
        {
                //cout << "t = " << t << endl;
                t += a[ind].second;
                a[ind].second = 0;
                ind++;
        }
        sort(rall(a));
        for (int i = 0; i < n; ++i)
        {
                //cout << "t = " << t << endl;
                t += a[i].second;
                if ((a[i].second % 10 != 0) && (i + ind != n - 1)) t += (10 - (t % 10));
        }
        cout << t << endl;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    rep(i,s.size()){
        int a = (s[i]-'A'+n)%26;
        s[i] = 'A'+a;
    }

    cout << s << "\n";
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	_, k := r.nextInt(), r.nextInt()
	r.Scan(true)
	h := r.nextStringArray().toInts()

	ans := 0
	for i := range h {
		if h[i] >= k {
			ans++
		}
	}

	fmt.Fprintln(stdout, ans)
}


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

  int main() {
 int a,b,c;
    cin >> a >> b >> c;
    if(a != b && a == c) {
 cout << "Yes" << endl;
    }
    else if(a != c && a == b) {
      cout << "Yes" << endl;
    }
    else if(b != a && b == c){
      cout << "Yes" << endl;
    }
else{
  cout << "No" << endl;
}
}

Measured memory_bytes: 3608
n, m = map(int, input().split())
ans = []
if n % 2 == 1:
    for i in range(m):
        ans.append((i+1, n-i))


else:
    for i in range(m):
        if i <= (m+1)//2-1:
            ans.append((i+1, n-i))
        else:
            ans.append((i+1, n-i-1))

for a, b in ans:
    print(a, b)


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

int main()
{
	int q1, b, c1, c2, q2;

	while( cin >> q1 && q1 ){
		cin >> b >> c1 >> c2 >> q2;
		int a1, a2;
		a1 = b / c1;
		if( a1 > q2 ){
			a1 = q2;
		}
		a2 = ( b - c1 * a1 ) / c2;
		if( a1 + a2 < q1 ){
			int s = q1 - ( a1 + a2 );
			int cc = c1 - c2;
			if( cc > 0 ){
				double cb = static_cast< double >( cc ) / c2;	// can buy:１個交換するとc2がcb個買えるようになる
				double swtmp = s / cb;
				int sw = static_cast<int>( swtmp );
				int swn = static_cast<int>( sw * cb );
				a1 -= ( swn - 1 );
				do{
					--a1;
					a2 = ( b - c1 * a1 ) / c2;
				}while( a1 > 0 && a1 + a2 < q1 );
				if( a1 > 0 ){
					a2 = ( b - c1 * a1 ) / c2;
				}else{
					a1 = a2 = -1;
				}
			}else{
				a1 = a2 = -1;
			}
		}
		if( a1 == 0 || ( a1 == -1 && a2 == -1 ) ){
			cout << "NA" << endl;
		}else{
			cout << a1 << " " << a2 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1160
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
  
ll N;
vector<ll> vals;
ll val;
  
int main() {
	scanf("%lld", &N);
	for(ll i = 0; i < N; i++) {
		scanf("%lld", &val);
		vals.push_back(val);
	}
	sort(vals.begin(),vals.end());
	int l = vals[vals.size()-1]; 
	int r = l;             
	int i = 0,j = vals.size()-2;
	long long int sum=0;
	while(i < j){
	        int li = abs(l-vals[i]);
	        int ri = abs(r-vals[i]);
	        int lj = abs(l-vals[j]);
	        int rj = abs(r-vals[j]);
	        if(li > ri || lj > rj) { 
	                if(li > lj){
	                        sum+=li;
	                        l=vals[i++];
	                }
	                else {
	                        sum += lj;
	                        l = vals[j--];
	                }
	        }else{
	                if(ri > rj){
	                        sum += ri;
	                        r = vals[i++];
	                }
	                else{
	                        sum += rj;
	                        r = vals[j--];
	                }
	        }
	}
	sum += max(abs(l - vals[i]), abs(r - vals[i]));
	cout<< sum << endl;
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

int main() {
  char C;
  cin >> C;
  
  if (C == 'a' ) {
      cout << "vowel" << endl;
  }
  else if (C == 'i' ) {
      cout << "vowel" << endl;
  }
  else if (C == 'u' ) {
      cout << "vowel" << endl;
  }
  else if (C == 'e' ) {
      cout << "vowel" << endl;
  }
  else if (C == 'o' ) {
      cout << "vowel" << endl;
  }  
  else {
      cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n= scan.nextInt();
		int xy[][]= new int[n][2];
		for(int i=0;i<n;i++) {
			xy[i][0] = scan.nextInt();
			xy[i][1] = scan.nextInt();
		}
		scan.close();
		double ans =0;
		for(int i=0;i<n;i++) {
			for(int j=i+1;j<n;j++) {
				ans += Math.sqrt((xy[i][0]-xy[j][0])*(xy[i][0]-xy[j][0])+(xy[i][1]-xy[j][1])*(xy[i][1]-xy[j][1]))*2;
			}
		}
		System.out.println(ans/n);
	}
}

Measured memory_bytes: 21972
n,m = map(int,input().split())
L = []
for i in range(m):
    L.append(list((map(int,input().split()))))

for i in range(1000):
    p = str(i)
    flag = False
    for j in range(m):
        if len(p) >= L[j][0]:
            if int(p[L[j][0]-1]) != L[j][1]:
                break
    else:
        if len(p) == n:
            flag = True

    if flag:
        print(i)
        exit()
print(-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll h, w, n;
  cin >> h >> w >> n;

  ll ans = 1000000;
  rep(i, h+1) {
    rep(j, w+1) {
      if (i*w+j*h-i*j >= n) {
        cmin(ans, i+j);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long m = long.Parse(Console.ReadLine());
            long[] list = new long[1000000];
            for (int i = 0; i < 1000000; i++)
            {
                if (i == 0)
                {
                    list[i] = m;
                }
                else
                {
                    if (list[i - 1] % 2 == 0)
                    {
                        long add = list[i - 1] / 2;
                        if (list.Contains(add))
                        {
                            Console.WriteLine(i + 1);
                            return;
                        }
                        list[i] = add;
                    }
                    else
                    {
                        long add = list[i - 1] * 3 + 1;
                        if (list.Contains(add))
                        {
                            Console.WriteLine(i + 1);
                            return;
                        }
                        list[i] = add;
                    }
                }
                
            }
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


//Console.WriteLine(ans);


Measured memory_bytes: 28076
#include <iostream>

 
using namespace std;


int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if(a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
    else if(b <= c && c <= a)
        cout << b << " " << c << " " << a << endl;
    else if(b <= a && a <= c)
        cout << b << " " << a << " " << c << endl;
    else if(c <= a && a <= b)
        cout << c << " " << a << " " << b << endl;    
    else
        cout << c << " " << b << " " << a << endl;
}



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

typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; (i) < int(n); ++(i))

char maze[50][50];
int N, M;
int sx, sy;
int gx, gy;
const int INF = 100000000;
int b = 0;

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

int dfs(){
	queue<P> que;

	rep(i, N){
		rep(j, M){
			d[i][j] = INF;
		}
	}

	que.push(P(sx, sy));
	d[sx][sy] = 0;

	while(que.size()){
		P p = que.front(); que.pop();
		if(p.first == gx && p.second == gy){
			break;
		}

		rep(i, 4){
			int nx = p.first + dx[i], ny = p.second + dy[i];

			if(nx >= 0 && nx < N && ny >= 0 && ny < M){
				if(maze[nx][ny] != '#' && d[nx][ny] == INF){
					que.push(P(nx, ny));
					d[nx][ny] = d[p.first][p.second] + 1;
				}
			}
		}
	}

	return d[gx][gy];
}

int main(void){

	cin >> N;
	cin >> M;
	rep(i, N){
		rep(j, M){
			cin >> maze[i][j];
			if(maze[i][j] == '#'){
				b++;
			}
		}
	}
	sx=0; sy=0;
	gx=N-1; gy=M-1;

	int res = dfs();
	if(res == INF){
		cout << -1 << endl;
		return 0;
	}
	int ans = N*M - b - res - 1;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説どおりに実装したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] t = new int[n];
			IntStream.range(0, n).forEach(i -> t[i] = scanner.nextInt());
			// 時間制限区間の開始時間と終了時間
			int[] l = new int[n + 2], r = new int[n + 2];
			l[0] = r[0] = l[1] = 0;
			IntStream.range(0, n).forEach(i -> r[i + 1] = l[i + 2] = l[i + 1] + t[i]);
			r[n + 1] = l[n + 1];
			// 各区間の最大速度
			int[] v = new int[n + 2];
			v[0] = v[n + 1] = 0;
			IntStream.range(0, n).forEach(i -> v[i + 1] = scanner.nextInt());
			// 各時刻の最大速度(0.5秒刻み)
			double[] d = new double[r[n + 1] * 2 + 1];
			d[0] = 0.0d;
			System.out.println(IntStream.range(1, d.length).mapToDouble(i -> {
				d[i] = calcF(i, n, l, r, v);
				return (d[i - 1] + d[i]) / 4.0d;
			}).sum());
		}
	}

	/**
	 * 指定された時刻における走行可能の最大速度を取得する
	 * 
	 * @param index 時刻x2の値
	 * @param n     N
	 * @param l     時間帯のスタート時点
	 * @param r     時間帯のエンド時点
	 * @param v     時間帯の最大速度
	 * @return 指定された時刻における走行可能の最大速度
	 */
	private static double calcF(int index, int n, int[] l, int[] r, int[] v) {
		double time = index / 2.0d;
		return IntStream.range(0, n + 2).mapToDouble(i -> {
			if (time < l[i]) {
				return v[i] + (l[i] - time);
			} else if ((l[i] <= time) && (time <= r[i])) {
				return (double) v[i];
			} else {
				return v[i] + (time - r[i]);
			}
		}).min().getAsDouble();
	}
}


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

int main(){
int buf[3][3] = {};
for(int i =0; i < 3; ++i){
for(int j = 0; j < 3; ++j){
cin >> buf[i][j];
}
}
for(int i = 0; i < 3; ++i){
for(int i_ = i+1; i_ < 3; ++i_){
for(int j = 0; j < 3; ++j){
for(int j_ = j+1; j_ < 3; ++j_){
if(buf[i][j] + buf[i_][j_] != buf[i][j_] + buf[i_][j]){
cout << "No" << endl;
return 0;
}
}
}
}
}
cout << "Yes" << endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    ll x;
    cin >> x;
    int i = 1;
    for (; i < x; i++) {
        ll t = i * (i + 1) / 2;
        if (t >= x) break;
    }
    cout << i << endl;
}

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

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

    string ans;
    if (s == "Sunny") ans = "Cloudy";
    else if (s == "Cloudy") ans = "Rainy";
    else ans = "Sunny";
    
    cout << ans << endl;
}



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

int main() {
	int H, W;
	cin >> H >> W;
	for (int i = 1; i <= H; ++i) {
		for (int j = 0; j < W; ++j) {
			string S;
			cin >> S;
			if ("snuke" == S) printf("%c%d", 'A' + j, i);
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for(const auto& e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void yn(bool j){cout << (j ? "Yes" : "No") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> long long bcount(T1 v, T2 a){return upper_index(v, a) - lower_index(v, a);} 
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}

int main(){
    ll A, B, C, K; cin >> A >> B >> C >> K;
    ll a; 
    if (K <= A){
        a = K;
    }else if(K <= A + B){
        a = A;
    }else if(K <= A + B + C){
        a = A - (K - A - B);
    }else{
        a = A - C;
    }
    pt(a);
}

Measured memory_bytes: 3624
# = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
# = list(input())
# = [tuple(map(int, input().split())) for _ in range(n)]

h = int(input())
d = 1
while h > 1:
    h //= 2
    d += 1
print(2 ** d - 1)

Measured memory_bytes: 2940
X = int(input())
list = []

if X == 1:
  list.append(1)

elif X == 2 or X == 3:
  list.append(2)
  
else:
  for b in range(2, X):
    p = 2
    while b ** p <= X:
      list.append(b ** p)
      p += 1
      
print(max(list))
  

Measured memory_bytes: 3060