akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define show(x) cerr << #x << " = " << (x) << endl
using namespace std;
string S;
int pos;
string Cipher();
int PM()
{
    int ans = 0;
    for (; pos < S.size() and (S[pos] == '+' or S[pos] == '-'); pos++) { ans += (S[pos] == '+' ? 1 : -1); }
    return (26 + ans % 26) % 26;
}
string Letter()
{
    string ans;
    for (int sf = 0; pos < S.size() and (isalpha(S[pos]) or S[pos] == '+' or S[pos] == '-'); pos++) { sf = PM(), ans.push_back('A' + (S[pos] - 'A' + sf) % 26); }
    return ans;
}
string String()
{
    if (S[pos] == '[') {
        string ans;
        return pos++, ans = Cipher(), reverse(ans.begin(), ans.end()), pos++, ans;
    } else {
        return Letter();
    }
}
string Cipher()
{
    string ans;
    for (; pos < S.size() and S[pos] != ']'; ) { ans += String(); }
    return ans;
}
int main()
{
    while (true) {
        cin >> S;
        string s;
        if (S == ".") { break; }
        for (int i = S.size() - 1, hatena = false; i >= 0; i--) {
            if (S[i] == '?') {
                hatena = true, s.push_back('A');
            } else if (not hatena or not(S[i] == '+' or S[i] == '-')) {
                hatena = false, s.push_back(S[i]);
            }
        }
        reverse(s.begin(), s.end());
        S = s;
        pos = 0;
        cout << Cipher() << endl;
    }
    return 0;
}



Measured memory_bytes: 3192
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <bitset>
#include <string>
#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define REP(i, x, y) for(int i = (int)x; i <= (int)y; i ++)
#define FOR(i, x, y) for(int i = (int)x; i <  (int)y; i ++)
#define PER(i, x, y) for(int i = (int)x; i >= (int)y; i --)
#define trace(x) cerr << #x << " " << x << endl;
#define dprintf(...) fprintf(stderr, __VA__ARGS__)
#define dln()        fprintf(stderr, "\n")
using namespace std;
typedef double db;
typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VII;
typedef vector<PII> VPI;
typedef vector<long long> VL;
const	int N = 100005;
const	int P = 1e9 + 7;
const	int inf = 1e9;
const	LL Inf = 1e18;

inline int IN(){
	char ch = getchar(); int x = 0, f = 0;
	while(ch < '0' || ch > '9') ch = getchar(), f = (ch == '-');
	while(ch >= '0' && ch <= '9'){
		x = (x << 1) + (x << 3) + ch - 48;
		ch = getchar();
	}
	return f ? (-x) : x;
}

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

void renew(int &x, int y){
	x += y;
	if(x < 0) x += P;
	else if(x >= P) x -= P;
}

void setIO(string a){
#ifndef LOCAL
	freopen((a + ".in").c_str(), "r", stdin);
	freopen((a + ".out").c_str(), "w", stdout);
#endif
}

template<typename T> inline void chkmin(T &a, const T &b) {if(a > b) a = b;}
template<typename T> inline void chkmax(T &a, const T &b) {if(a < b) a = b;}

char s[15],A[15][15],C[15][15];
int n;
string B="AAKIHABARA";

void dfs(int n){
	if(n>9)return;
	if(n==9){
		REP(i,1,n) if(B[i]!=s[i])return;
		puts("YES");
		exit(0);
	}
	REP(y,1,n) C[n][y]=s[y];
	REP(x,1,n+1){
		FOR(y,1,x) A[n][y]=s[y];
		A[n][x]='A';
		REP(y,x+1,n+1) A[n][y]=s[y-1];
		REP(t,1,n+1) s[t]=A[n][t];
		dfs(n+1);
		REP(t,1,n+1) s[t]=C[n][t];
	}
}

int main(){
#ifdef LOCAL
	freopen("1.in", "r", stdin);
//	freopen("1.out", "w", stdout);
#endif
	
	scanf("%s",s+1);
	n=strlen(s+1);
	dfs(n);

	puts("NO");

	return 0;
}






















Measured memory_bytes: 256
n_data = gets.to_i

n_data.times do
  last_a = 0
  last_b = 0
  is_possible = true

  nums = gets.split.map(&:to_i)
  nums.each{|n|
    if n > last_a
      last_a = n
      next
    end

    if n > last_b
      last_b = n
      next
    end

    is_possible = false
    break
  }

  puts is_possible ? "YES" : "NO"
end

Measured memory_bytes: 8588
#include<iostream>
#include<string>
#include <numeric>
#include <algorithm>
#include<queue>
#include<vector>
using namespace std;
typedef pair<int, int> P;

int main(){
  int x, n, min=100, num;
  cin >> x >> n;
  vector<int> p(n);
  for(int i=0; i<n; i++){
    cin >> p[i];
  }
  for(int i=0; i<=2*x; i++){
    if(find(p.begin(), p.end(), i) != p.end()) continue;
    if(abs(x-i) < min){
      min = abs(x-i);
      num = i;
    }else if(abs(x-i) == min){
      if(i < num) num = i;
    }
  }
  cout << num << endl;
  return 0;
}

Measured memory_bytes: 3652
N = int(input())
a_list = list(map(int, input().split()))
plus = True
minus = True

for a in a_list:
    if a > 0:
        minus = False

    if a < 0:
        plus = False

if plus:
    result = []
    for i in range(N - 1):
        if a_list[i] > a_list[i + 1]:
            result.append((i + 1, i + 2))
            a_list[i + 1] += a_list[i]
    print(len(result))
    for v1, v2 in result:
        print(v1, v2)
    exit()

if minus:
    result = []
    for i in reversed(range(N - 1)):
        if a_list[i] > a_list[i + 1]:
            result.append((i + 2, i + 1))
            a_list[i] += a_list[i + 1]
    print(len(result))
    for v1, v2 in result:
        print(v1, v2)
    exit()

max_num = max(a_list)
min_num = min(a_list)
result = []
if abs(max_num) >= abs(min_num):
    max_index = a_list.index(max_num)
    for i, a in enumerate(a_list):
        if a < 0:
            a_list[i] += max_num
            result.append((max_index + 1, i + 1))

    for i in range(N - 1):
        if a_list[i] > a_list[i + 1]:
            result.append((i + 1, i + 2))
            a_list[i + 1] += a_list[i]
    print(len(result))
    for v1, v2 in result:
        print(v1, v2)

else:
    min_index = a_list.index(min_num)
    for i, a in enumerate(a_list):
        if a > 0:
            a_list[i] += min_num
            result.append((min_index + 1, i + 1))
            
    for i in reversed(range(N - 1)):
        if a_list[i] > a_list[i + 1]:
            result.append((i + 2, i + 1))
            a_list[i] += a_list[i + 1]
    print(len(result))
    for v1, v2 in result:
        print(v1, v2)
    exit()


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

int main() {

	int n, m; cin >> n >> m;
	vector<vector<int>> s(m);
	for (int i = 0; i < m; i++) {
		int k; cin >> k;
		for (int j = 0; j < k; j++) {
			int x; cin >> x;
			x--;
			s[i].push_back(x);
		}
	}
	vector<int> p(m);
	for (int i = 0; i < m; i++) {
		cin >> p[i];
	}
	int ans = 0;
	for (int bit = 0; bit < (1 << n); ++bit) {
		vector<bool> switchOn(n, false);
		for (int i = 0; i < n; ++i) {
			if (bit & (1 << i)) {
				switchOn[i] = true;
			}
		}		
		int onCnt = 0;
		for (int i = 0; i < m; i++) {
			int tmpCnt = 0;
			for (auto u : s[i]) {
				if (switchOn[u]) tmpCnt++;
			}
			if (tmpCnt % 2 == p[i]) onCnt++;
		}
		if (onCnt == m) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int dfs(vector<int> edge[], int vertex, vector<int>& maximum){
    if(edge[vertex].size()==0) return 0;

    if(maximum[vertex]!=-1) return maximum[vertex];
    int ans = 0;
    for(int i=0;i<edge[vertex].size();i++){
        ans = max(ans, dfs(edge, edge[vertex][i], maximum));
    }
    maximum[vertex] = ans+1;
    return maximum[vertex];
}

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> edge[100001];
    int v1, v2;
    vector<int> maximum(100001, -1);
    for(int i=0;i<m;i++){
        cin >> v1 >> v2;
        edge[v1].push_back(v2);
    }
    for(int i=1;i<=n;i++){
        if(maximum[i]==-1) maximum[i] = dfs(edge, i, maximum);
    }
    int ans = 0;
    for(int i=1;i<=n;i++) ans = max(ans, maximum[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11360
//stringray

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

/*#ifndef __LOCAL__ 
#pragma comment(linker,"/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif*/ 

using namespace std;
using namespace __gnu_pbds;
 
//#define int int64_t

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ost;

typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<set<int>> vsi;

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define F first
#define S second
#define fore(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define debug(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(0)


const int N1=100*1000;
const int N2=1000*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T>
istream& operator >> (istream& is,vector<T>& vec){
  for(T &x:vec)is>>x;
  //for(int i=0;i<vec.size();++i)is>>x[i];
  return is;
}

template<typename T>
ostream& operator << (ostream& os,vector<T>& vec){
  for(int i=0;i<vec.size();++i){
    os<<vec[i]<<(i+1==vec.size()?"":" ");
  }
  return os;
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll FIXED_RANDOM=chrono::steady_clock::now().time_since_epoch().count();

struct chash {
    static unsigned long long hash_f(unsigned long long x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    static unsigned hash_combine(unsigned a, unsigned b) { return a * 31 + b; }
    int operator()(int x) const { return hash_f(x); }
};
//unordered_map <int, int, chash> m; way to use this 
//the way you're supposed to do is it by initializing FIXED_RANDOM with something like chrono::steady_clock::now().time_since_epoch().count()(current time in microseconds or something like that) and instead of hash_f(x) do hash_f(FIXED_RANDOM^x) 

int getRand(int l, int r)
{
	uniform_int_distribution<int> uid(l, r);
	return uid(rng);
}

ll mpow(ll a, ll b){
  ll ret=1;
  while(b>0){
    if(b&1LL)(ret*=a)%=mod;
    (a*=a)%=mod;
    b>>=1LL;
  }
  return ret;
}

void solve(){

  int n;cin>>n;
  string s;cin>>s;
  stack<char>st;
  for(char c:s){
    if(st.size()==0){st.push(c);continue;}
    else{
      if(st.top()==c)continue;
      else st.push(c);
    }
  }
  cout<<st.size()<<endl;
}
int32_t  main(){
  IOS;
  cout<<(fixed)<<setprecision(6);
  solve();
  return 0;
}



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

int main(){
    int A,B,C;
    cin >> A >> B >> C;

    if((A == B and B == C) or (A != B and B != C and C != A)) cout << "No" << endl;
    else cout << "Yes" << endl;


    return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll D;
        cin >> D;
        string ans;
        if (D == 25) ans = "Christmas";
        if (D == 24) ans = "Christmas Eve";
        if (D == 23) ans = "Christmas Eve Eve";
        if (D == 22) ans = "Christmas Eve Eve Eve";
        cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

string devide[4] = {"dream", "dreamer", "erase", "eraser"};

string cut_word(string base_word);

int main() {
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    //cout << S << endl;
    for (int i = 0; i < 4; i++) {
        reverse(devide[i].begin(), devide[i].end());
    }
    // 単語で切り取る
    while(1) {
      //cout << "1 times" << endl;
      string before_S = S;
      S = cut_word(S);
      //cout << "-------------------" << endl;
      //cout << before_S.size() << endl;
      //cout << S.size() << endl;
      if (before_S.size() == S.size()) {
        //cout << "same=============" << endl;
        break;
      }

    }

    if (S.size() == 0) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
}

string cut_word(string base_word) {
  for (int i = 0; i < 4; i++) {
    bool is_ok = true;
    for (int j = 0; j < devide[i].size(); j++) {
      if (base_word[j] != devide[i][j]) {
        is_ok = false;
      }
    }
    //cout << "-------------------" << endl;
    //cout << devide[i] << endl;
    // 実際に切り取る
    if (is_ok) {
      for (int j = 0; j < devide[i].size(); j++) {
        base_word.erase(base_word.begin());
      }
      //cout << "OK" << endl;
    } else {
      //cout << "NG" << endl;
    }
  }
  return base_word;
}


Measured memory_bytes: 604
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <cassert>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1000000007;

ll H;
ll W;
vector<ll> R;
vector<ll> C;


void fail() {
    cout << 0 << endl;
    exit(0);
}

bool v_unlocked[1010];
bool h_unlocked[1010];

set<int> v_free_count[1010];
set<int> h_free_count[1010];
set<pair<int, int> > free_count;

void add(ll r, ll c) {
    free_count.insert({r, c});
    v_free_count[c].insert(r);
    h_free_count[r].insert(c);
}

void dec(ll r, ll c) {
    h_free_count[r].erase(c);
    v_free_count[c].erase(r);
    assert(free_count.erase({r, c}));
}

ll dec_h(ll r) {
    ll res = h_free_count[r].size();
    if( res == 0 ) return 0;
    ll c = *h_free_count[r].begin();
    dec(r, c);
    return res;
}

ll dec_v(ll c) {
    ll res = v_free_count[c].size();
    if( res == 0 ) return 0;
    ll r = *v_free_count[c].begin();
    dec(r, c);
    return res;
}

ll dec_any() {
    ll res = free_count.size();
    if( res == 0 ) return 0;
    int r, c;
    tie(r, c) = *free_count.begin();
    dec(r, c);
    return res;
}

void unlock_v(ll c) {
    if (v_unlocked[c]) return;
    v_unlocked[c] = true;
    for (int r = 0; r < H; r++) {
        if (h_unlocked[r] == 1) {
            add(r, c);
        }
    }
}

void unlock_h(ll r) {
    if (h_unlocked[r]) return;
    h_unlocked[r] = true;
    for (int i = 0; i < W; i++) {
        if (v_unlocked[i] == 1) {
            add(r, i);
        }
    }
}


ll ans = 1;

void mult(ll x) {
    ans *= x;
    ans %= MOD;
}

void solve() {
    R.push_back(-1);
    C.push_back(-1);
    sort(R.begin(), R.end());
    sort(C.begin(), C.end());
    for (int i = H * W; i > 0; i--) {
        if (R.back() > i) fail();
        if (C.back() > i) fail();

        if (R.back() == i && C.back() == i) {
            unlock_h(R.size() - 2);
            unlock_v(C.size() - 2);
            dec(R.size() - 2, C.size() - 2);
            R.pop_back();
            C.pop_back();
        } else if (R.back() == i) {
            unlock_h(R.size() - 2);
            mult(dec_h(R.size() - 2));
            R.pop_back();
        } else if (C.back() == i) {
            unlock_v(C.size() - 2);
            mult(dec_v(C.size() - 2));
            C.pop_back();
        } else {
            mult(dec_any());
        }
    }
    cout << ans << endl;

}

void input() {
    H = ll();
    scanf("%lld", &H);
    W = ll();
    scanf("%lld", &W);
    R = vector<ll>(H);
    for (int i = 0; i < H; i++) {
        scanf("%lld", &R[i]);
    }
    C = vector<ll>(W);
    for (int i = 0; i < W; i++) {
        scanf("%lld", &C[i]);
    }
}

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


Measured memory_bytes: 140288
#include<iostream>
#include<iomanip>
using namespace std;
#define Pi 3.14159265358979323846
int main(){
	long double a;
	cin >>a;
	cout << fixed << setprecision(6) <<  a*a*Pi <<' ' <<fixed << setprecision(6) << 2*a*Pi << endl;
	return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[200005];
pll T[200005];

int main() {
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }

    ll s = 0, x = 0;
    ll si = 0;
    ll ans = 0;
    T[0] = pll(0, 0);
    REP(i, N) {
        s += A[i];
        x ^= A[i];
        T[i + 1] = pll(s, x);
        while (s - T[si].first != (x ^ T[si].second))
            si++;
        ans += i + 1 - si;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
import math
n, p = list(map(int, input().split()))
li = []
box = []
m = 1
k = 1
q = p

while True:
    for i in range(2,int(math.sqrt(q)) + 1):
        if p % i == 0:
            p = p // i
            li.append(i)
            k = i
            break
        else:
            continue
    else:
        break

for i in range(2,k+1):
    if i in li:
        box.append(i)

box = sorted(box, reverse = True)

if n > len(li):
    print(m)
elif n == 1:
    print(q)
else:
    for j in box:
        if li.count(j) // n > 0:
            m *= j ** (li.count(j) // n)
    print(m)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
    fio();
    ll n;
    cin >> n;
    vi cnts;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            int cnt = 0;
            while (n % i == 0) {
                n /= i;
                cnt++;
            }
            cnts.push_back(cnt);
        }
    }
    if (n > 1) cnts.push_back(1);


    int ans = 0;
    rep (i, cnts.size()) {
        int k = 1;
        while (cnts[i] >= k) {
            ans++;
            cnts[i] -= k;
            k++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3660
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

h,w = MAP()
s = [STR() for _ in range(h)]
ii = [-1, 1, 0, 0]
jj = [0, 0, -1, 1]
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            flag = [False for _ in range(4)]
            for k in range(4):
                iii = i + ii[k]
                jjj = j + jj[k]
                if 0 <= iii < h and 0 <= jjj < w and s[iii][jjj] == '#':
                    flag[k] = True
            if not sum(flag):
                print('No')
                exit()
print('Yes')


Measured memory_bytes: 63208
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <utility>
#include <vector>

using namespace std;

typedef long long Long;
#define whole(xs) xs.begin(), xs.end()

struct Circle {
    int x, y, r, c;
};
istream& operator>>(istream& is, Circle& c) {
    is >> c.x >> c.y >> c.r >> c.c;
    return is;
}

struct Point {
    int x, y;
    Point(int x = 0, int y = 0) : x(x), y(y) {}
};
#define Pow2(x) ((x) * (x))
int Dist2(const Point& a, const Point& b) {
    return Pow2(a.x - b.x) + Pow2(a.y - b.y);
}

int N;
vector<Circle> Cs;
bool input() {
    cin >> N;
    if (N == 0) return false;
    Cs.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> Cs[i];
    }
    return true;
}

bool Overlap(const Circle& a, const Circle& b) {
    return Pow2(a.r + b.r) > Dist2(Point(a.x, a.y), Point(b.x, b.y));
}

bool IsTop(int used, int index) {
    for (int i = 0; i < index; i++) {
        if (used & (1 << i)) continue;
        if (Overlap(Cs[i], Cs[index])) return false;
    }
    return true;
}

char Cache[1 << 24];
int dfs(int used) {
    int Ret = 0;
    if (Cache[used] >= 0) return Cache[used];
    for (int i = 0; i < N; i++) {
        if (used & (1 << i)) continue;
        if (!IsTop(used, i)) continue;
        for (int j = i + 1; j < N; j++) {
            if (used & (1 << j)) continue;
            if (!IsTop(used, j)) continue;
            if (Cs[i].c == Cs[j].c) {
                Ret = max(Ret, dfs(used | (1 << i) | (1 << j)) + 2);
            }
        }
    }
    return Cache[used] = Ret;
}

void solve() {
    memset(Cache, -1, sizeof(Cache));
    cout << dfs(0) << endl;
}

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

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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int k;
    cin>>k;
    string s;
    cin>>s;
    int n=s.length();
    if(k>=n){
        cout<<s<<endl;
    }
    else{
        s=s.substr(0,k);
        s+="...";
        cout<<s<<endl;
    }
}


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

int main()
{
    int H,W;
    for(int r=0; ; r++){
        cin >> H >> W;
        if(H==0 && W==0)
            break;
        for(int i=0; i<H; i++){
            if(i==0 || i==H-1){
                for(int j=0; j<W; j++)
                    cout << '#';
            }
            else
                for(int r=0; r<W; r++)
                    if(r==0 || r==W-1)
                        cout << '#';
                    else
                        cout << '.';
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3056
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define pii pair<int, int> 
#define mod 1000000007
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a);
        b/=2;
    }
    return res;
}
ll ncr(ll n,ll k){
    if(k==0||k==n) return 1ll;
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i));
        pro/=(i+1);
    }
    return pro;
}
int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string str,num="753";
    cin>>str;
    int minn=INT_MAX;
    for(int i=0;i+3<=str.size();i++){
        string temp=str.substr(i,3);
        int a=stoi(temp);
        int b=stoi(num);
        minn=min(minn,abs(a-b));
    }
    cout<<minn;
    return 0;
}


Measured memory_bytes: 256
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

n = int(arr_data[0][0])
m = int(arr_data[0][1])


print((n-1) *(m-1))

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define puts(x) cout << x << ' ';
#define putln(x) cout << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;

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

void solve(void){
	ll N, X;
	cin >> N >> X;
	putln((N / gcd(N, X) -1) * gcd(N, X) * 3);
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
//#include <cstdio>
#include <iostream>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

#define MAXN 100004
int N, MOD;
VI adj[MAXN];

inline int add(int x, int y) {
   return (x + y) % MOD;
}

inline int mult(int x, int y) {
   return (x * 1LL * y) % MOD;
}

llong dp_down[MAXN];
vector<llong> prefix_dp_down[MAXN];
vector<llong> suffix_dp_down[MAXN];
void dfs1(int u, int p = 0) {
   FOR(j, 1, SZ(adj[u])-1) {
      int v = adj[u][j];
      if (v == p) {
         // place parent as first adjacent... the rest with be children
         if (adj[u].front() != v)
            swap(adj[u].front(), adj[u][j]);
         break;
      }
   }

   dp_down[u] = 1 % MOD;
   FOR(j, 1, SZ(adj[u])-1) {
      int v = adj[u][j];
      dfs1(v, u);
      dp_down[u] = mult(dp_down[u], add(1, dp_down[v]));
   }
   
   prefix_dp_down[u].push_back(1);
   for(int j = 1; j < SZ(adj[u]); ++j) {
      int v = adj[u][j];
      prefix_dp_down[u].push_back(
         mult(prefix_dp_down[u].back(), add(1, dp_down[v]))
      );
   }
   suffix_dp_down[u].push_back(1);
   for (int j = SZ(adj[u])-1; j >= 1; --j) {
      int v = adj[u][j];
      suffix_dp_down[u].push_back(
         mult(suffix_dp_down[u].back(), add(1, dp_down[v]))
      );
   }
}

llong ans[MAXN];
void dfs2(int u, int p = 0, llong up_factor = 1) {
   ans[u] = mult(up_factor, dp_down[u]);

   for(int j = 1; j < SZ(adj[u]); ++j) {
      int v = adj[u][j];
      dfs2(v, u,
           add(1,
               mult(up_factor,
                    mult( prefix_dp_down[u][j-1],
                          suffix_dp_down[u][ SZ(adj[u])-j-1  ] ) )
           )
      );
   }
   
}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   cin >> N >> MOD;
   REP(j, N-1) {
      int u, v;
      cin >> u >> v;
      adj[u].push_back(v);
      adj[v].push_back(u);
   }

   // 0 is fake root
   adj[1].push_back(0);

   dfs1(1);

   /*
   FOR(u, 1, N) {
      cerr << u << ": " << dp_down[u] << '\n';
      cerr << "prefix: ";
      for (int x : prefix_dp_down[u])
         cerr << x << ' ';
      cerr << endl;
      cerr << "suffix: ";
      for (int x : suffix_dp_down[u])
         cerr << x << ' ';
      cerr << endl;
   }
   */

   dfs2(1);

   FOR(u, 1, N) {
      cout << ans[u] << '\n';
   }

   return 0;
}


Measured memory_bytes: 25088
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

using namespace std;

int main(){
  int a,b,c,d;
  string s;
  cin>>a>>b;



  if(a == 0){
    if(b==100){
      cout<<"101"<<endl;
    }else{
      cout<<b<<endl;
    }

  } else {
    if(a==1){
      if(b==100){
        cout<<"10100"<<endl;
      }else{
      cout<<(b*100)<<endl;
      }

    }else {
      if(b==100){
        cout<<"1010000"<<endl;
      }else{
      cout<<(b*10000)<<endl;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 256
/* 162-B.cpp
 *     Created on : Apr 12, 2020 
 *     Time       : 6:03:19 PM
 *     Author     : null_ptr
 */
#include<bits/stdc++.h>

using namespace std;

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

	long long sum=0;
	for(int i=1;i<=n;++i)
	{
		if(i%3==0 || i%5==0)continue;
		sum+=i;
	}
	cout<<sum;
}





Measured memory_bytes: 3640
N, M = map(int,input().split())

ab_list = []
c_list = []
for i in range(M):
    ab_list.append(list(map(int,input().split())))
    c_list.append(list(map(int,input().split())))
    
cost = [float("inf")]*(2**N)
cost[0] = 0

movement = []
for i in range(M):
    move = 0
    for j in c_list[i]:
        move += 2**(j-1)
    movement.append(move)

for i in range(2**N):
    for j in range(M):
        move2 = movement[j]
        if cost[i|move2] > cost[i]+ab_list[j][0]:
            cost[i|move2] = cost[i]+ab_list[j][0]

if cost[2**N-1] == float("inf"):
    print(-1)
    
else:
    print(cost[2**N-1])


Measured memory_bytes: 3552
def partition(ary, p, r)
  x = ary[r][1]
  i = p-1
  (p...r).each{ |j|
    if ary[j][1] <= x
      i = i+1
      tmp = ary[i]
      ary[i] = ary[j]
      ary[j] = tmp
    end
  }
  tmp = ary[i+1]
  ary[i+1] = ary[r]
  ary[r] = tmp
  i+1
end

def quicksort(ary, p, r)
  if p < r
    q = partition(ary, p, r)
    quicksort(ary, p, q-1)
    quicksort(ary, q+1, r)
  end
end

def stable?(in_ary, out, n)
  (0...n).each{ |i|
    (i...n).each { |j|
      if in_ary[i][1] == out[j][1]
        (i...n).each { |a|
          if out[j] == in_ary[a]
            (j...n).each { |b|
               if in_ary[i] == out[b] && i != a && j != b
                return false
              end
            }
          end
        }
      end
    }
  }
  true
end

# main
n = gets.to_i
ary = []
(0...n).each{ |n|
  c, n = gets.split(' ')
  ary << [c, n.to_i]
}

org_ary = ary.dup

quicksort(ary, 0, ary.size-1)

if stable?(org_ary, ary, n)
  puts "Stable"
else
  puts "Not stable"
end

(0...n).each{ |n|
  puts "#{ary[n][0]} #{ary[n][1]}"
}

Measured memory_bytes: 22280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int s[(1 << 24)] = {0};
ll F[(1 << 24)];
void merg(int a[2], int b[2]){
  int arr[4] = {a[0], a[1], b[0], b[1]};
  sort(arr, arr + 4);
  a[0] = arr[2];
  a[1] = arr[3];
}
int main(){
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int n;
  cin >> n;
  int len = (1 << n);
  int a[len];
  for(int i = 0;i < len;i++)
    scanf("%d", a + i);
  int two[len][2];
  for(int i = 0;i < len;i++)
    two[i][0] = -1, two[i][1] = a[i];
  for(int i = 0;i < n;i++)
    for(int j = 0;j < len;j++)
      if(j & (1 << i))
        merg(two[j], two[j ^ (1 << i)]);
  int res[len];
  res[1] = two[1][0] + two[1][1];
  cout << res[1]<< endl;
  for(int i = 2;i < len;i++){
    res[i] = max(res[i - 1], two[i][0] + two[i][1]);
    cout << res[i]<< endl;
  }
  return 0;

}


Measured memory_bytes: 7168
#include <stdio.h>

int main(void) {
	double W,H,x,y,ans;
	scanf("%lf%lf%lf%lf",&W,&H,&x,&y);
	ans=W*H/2;
	printf("%lf ",ans);
	if(x==W/2&&y==H/2)
	printf("%d",1);
	else
	printf("%d",0);
	return 0;
}


Measured memory_bytes: 128
n,k=gets.split.map(&:to_i)
barray=[]
n.times.each do
    v=gets.split.map(&:to_i)
    barray<<v


end



barray=barray.sort{|x,y|x[0]<=>y[0]}
count=0
#p barray
for i in 0..barray.length-1
    v=barray[i][1]
    count+=v
    if count>=k
        p barray[i][0]
        exit
    end
end

Measured memory_bytes: 22356
#include <stdio.h>

int div(int n)
{
  int i,c=0;
  for(i=1;i<=n/2;++i)
  {
         if(n%i==0)
             c++;
  }
  
  c+=1;
  if(c==8)
      return 1;
  
  else
     return 0;
}




int main()
{
  int n;
  scanf("%d",&n);
  if(n<105)
      printf("0");
  
  else if(n==105)
      printf("1");
  
  else
  {
    int i,cnt=0;
    for(i=106;i<=n;++i)
    {
       if(i%2!=0)
       {
         if(div(i)==1)
             cnt++;
       }
    }
    printf("%d",cnt+1);
  }
}

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

template <typename T> inline void rd(T& x) {
	int si = 1; char c = getchar(); x = 0;
	while(!isdigit(c)) si = c == '-' ? -1 : si, c = getchar();
	while(isdigit(c)) x = x * 10 + c - 48, c = getchar();
	x *= si;
}
template <typename T, typename... Args>
inline void rd(T& x, Args&... args) { rd(x); rd(args...); }
#define fi first
#define se second
#define mkp std::make_pair
typedef long long ll;
typedef double ff;
typedef std::pair <int, int> pii;
const int kN = 4e5 + 5, kInf = 0x3f3f3f3f;
const ll kMod = 998244353, kInfLL = 0x3f3f3f3f3f3f3f3fLL;

char str[kN]; int n;

int main() {
	int T = 1; //rd(T);
	while(T--) {
		scanf("%s", str + 1);
		n = strlen(str + 1);
		if(str[1] == '0' || str[n - 1] == '0' || str[n] == '1') {
			printf("-1\n"); return 0;
		}
		for(int i = 1; i <= n / 2; ++i) if(str[i] != str[n - i]) {
			printf("-1\n"); return 0;
		}
		int cnt = 1, lst = 0, lst_cnt = 1;
		for(int i = 2; i <= n / 2; ++i) {
			if(str[i] == '0') continue;
			//printf("i = %d, cnt = %d, lst = %d, lst_cnt = %d\n", i, cnt, lst, lst_cnt);
			for(int j = 1; j < i - lst; ++j) {
				++cnt;
				printf("%d %d\n", lst_cnt, cnt);
			}
			printf("%d %d\n", cnt + 1, lst_cnt);
			lst_cnt = ++cnt;
			lst = i;
		}
		//printf("===\n");
		cnt += 1;
		for(; cnt <= n; ++cnt) printf("%d %d\n", lst_cnt, cnt);
	} return 0;
}

Measured memory_bytes: 3844
def solve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort(reverse=True)
    for i in range(M):
        if A[i] < sum(A)*(1/(4*M)):
            print('No')
            exit()
    print('Yes')

if __name__ == '__main__':
    solve()


Measured memory_bytes: 9160
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        char[] s = scanner.next().toCharArray();
        int n = s.length;
        long dp[][] = new long[n + 1][4];
        for (int i = 0; i <= 3; i++) {
            dp[n][i] = i == 3 ? 1 : 0;
        }
        for (int i = n - 1; i >= 0; i--) {
            for (int j = 3; j >= 0; j--) {
                dp[i][j] = dp[i + 1][j] * (s[i] == '?' ? 3L : 1L);
                if (j < 3 && (s[i] == '?' || s[i] == "ABC".toCharArray()[j])) {
                    dp[i][j] += dp[i + 1][j + 1];
                }
                dp[i][j] %= 1_000_000_007L;
            }
        }
        System.out.println(dp[0][0]);
    }
}

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

typedef long long ll;
typedef unsigned long long ull;
const ll MOD=1e9+7;

int main(){
    ll N;
    cin >> N;

    ll dp[64][3];
    dp[0][0]=1;
    dp[0][1]=dp[0][2]=0;
    for(int i=1;i<64;i++){
        int Nb=(N&(1LL<<(63-i)))!=0;
        dp[i][0]=dp[i][1]=dp[i][2]=0;
        for(int j=0;j<=2;j++){
            for(int k=0;k<=2;k++){
                if(j*2-k+Nb>=0){
                    dp[i][min(j*2-k+Nb,2)]=(dp[i][min(j*2-k+Nb,2)]+dp[i-1][j])%MOD;
                }
            }
        }
    }

    cout << (dp[63][0]+dp[63][1]+dp[63][2])%MOD << endl;
    return 0;
}

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

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

  vector<ll> A(N);
  rep(i, N) cin >> A.at(i);

  ll tot = 0; // 合計水量
  ll x = 0; // 奇数番目を2倍したもの
  rep(i, N) {
    tot += A.at(i);
    if (i % 2 == 0) {
      x += A.at(i) * 2;
    }
  }

  vector<ll> B(N);
  B.at(0) = x - tot;
  rep(i, N - 1) {
    B.at(i + 1) = (A.at(i) - B.at(i) / 2) * 2;
  }

  rep(i, N) {
    if (i != N - 1) {
      cout << B.at(i) << " ";
    } else {
      cout << B.at(i) << endl;
    }
  }
  return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        998244353
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  200005
vi fac(N,0);

ll expo(ll base, ll exponent, ll mod) {                                //return base^exponent modulo modulus
    ll ans = 1;
    while(exponent !=0 ) {
        if((exponent&1) == 1) {
            ans = ans*base ;
            ans = ans%mod;
        }
        base = base*base;
        base %= mod;
        exponent>>= 1;
    }
    return ans%mod;
}

void fact()
{
    fac[0]=1;
    for(ll i=1;i<N;i++)
    {
        fac[i]=(fac[i-1]*i)%hell;
    }
}

ll com(ll n,ll r)
{
    if(r>n)return 0;
    ll ans=fac[n];
    ans=(ans*expo(fac[r],hell-2,hell))%hell;
    ans=(ans*expo(fac[n-r],hell-2,hell))%hell;
    return ans;
}
int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    fact();
    while(tt--)
    {
        ll i,j,k,l,m,n;
        cin>>n>>m>>k;
        ll ans=0;
        for(i=0;i<=k;i++)
        {
            ans=(ans+com(n-1,i)*expo(m-1,n-1-i,hell))%hell;
        }
        ans=(ans*m)%hell;
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 4704
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String in = sc.nextLine();
		String first = in.substring(0,1);
		String last = in.substring(in.length()-1,in.length());
		int count = in.length() -2;

		System.out.println(first + count + last);
		sc.close();
	}


}

Measured memory_bytes: 20948
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void print_vector(vector<T> &vec)
{
    for (auto elem : vec)
    {
        cout << elem << endl;
    }
}
int main()
{
    int n, m;
    cin >> n >> m;
    if (n == m)
    {
        cout << "Yes";
        return 0;
    }
    cout << "No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define RANGE(i,n) for(int i=0;i<n;i++)
typedef long long ll;

using namespace std;

ll euc(ll a, ll b) {
  if(a < 1) return b;
  if(b < 1) return a;
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

ll upper_beki(ll a){
    ll now = 1;
    int count = 1;
    while(now < a) now = pow(2,count++);
    return now;
}

signed main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    ll upN = upper_beki(N);
    vector<ll> seg_tree(2*upN-1);
    RANGE(i,upN){
        if (i<N){
            cin >> A[i];
            seg_tree[i + upN-1] = A[i];
        }
        else seg_tree[i + upN-1] = -1;
    }
    for(int i=upN-2;i>=0;i--) seg_tree[i] = euc(seg_tree[2*i+1], seg_tree[2*i+2]);

    ll ans = 0;
    RANGE(i,N){
        ll id = i + upN-1;
        ll now = -1;
        while(id > 0){
            if(id % 2 ==1) id = id+1;
            else id = id-1;
            now = euc(now, seg_tree[id]);
            id = (id-1)/2;
        }
        ans = max(ans, now);
    }
    cout << ans << endl;


}


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

using namespace std;

typedef vector<int> Dice;

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

enum {TOP, FRONT, RIGHT, LEFT, BACK, BOTTOM};
#define rotate_swap(x, a, b, c, d) swap(x[a], x[b]); swap(x[b], x[c]); swap(x[c], x[d]);
void rotate_r(Dice &dice) {rotate_swap(dice, TOP, LEFT, BOTTOM, RIGHT);}
void rotate_l(Dice &dice) {rotate_swap(dice, TOP, RIGHT, BOTTOM, LEFT);}
void rotate_f(Dice &dice) {rotate_swap(dice, TOP, BACK, BOTTOM, FRONT);}
void rotate_b(Dice &dice) {rotate_swap(dice, TOP, FRONT, BOTTOM, BACK);}
void rotate_w(Dice &dice) {rotate_swap(dice, BACK, LEFT, FRONT, RIGHT);}
void rotate_c(Dice &dice) {rotate_swap(dice, BACK, RIGHT, FRONT, LEFT);}
vector<Dice> generate_all(Dice dice) {
  vector<Dice> res;
  rep(i, 6) {
    rep(j, 4) res.push_back(dice), rotate_w(dice);
    i % 2 ? rotate_f(dice) : rotate_r(dice);
  }
  return res;
}

int main() {
  Dice dice(6);
  dice[TOP] = 1;
  dice[FRONT] = 2;
  dice[RIGHT] = 3;
  dice[LEFT] = 4;
  dice[BACK] = 5;
  dice[BOTTOM] = 6;
  vector<Dice> dices = generate_all(dice);
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;
    Dice d = dice;
    int res = 1;
    rep (i, n) {
      string str;
      cin >> str;
      if (str == "North") rotate_b(d);
      if (str == "East") rotate_r(d);
      if (str == "West") rotate_l(d);
      if (str == "South") rotate_f(d);
      if (str == "Right") rotate_w(d);
      if (str == "Left") rotate_c(d);
      res += d[TOP];
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1236
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, K int
	fmt.Scanf("%d %d\n", &N, &K)
	if N <= K {
		fmt.Println(0)
		return
	}
	H := make([]int, N)
	for i := 0; i < N; i++ {
		var h int
		fmt.Scan(&h)
		H[i] = h
	}
	sort.Ints(H)
	sum := 0
	for _, h := range H[:N-K] {
		sum += h
	}
	fmt.Println(sum)
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  ll a, b, h;
  cin >> a >> b >> h;
  print((a+b) * h / 2);
}

Measured memory_bytes: 256
/*~~~~~~~~~~~~~~~~~ K++ code ~~~~~~~~~~~~~~~~~~~
in(string a, b)
string s << a + b
x << stoi(s)
for(i in (1~sqrt(x))){
    if(i*i==x) yes() return 0
}
no()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <iomanip>
using namespace std;

;;

int main(){
  ;;
    string a, b;
    cin >> a >> b;
    ;
    string s = a + b;;
    int x = stoi(s);;
    if(1<sqrt(x)){;
        for(int i = 1; i <= sqrt(x); ++i){;;;
        if(i*i==x) {;cout << "Yes" << endl; return (0);};
    }
    ;}
    else {;
        for(int i = 1; i >= sqrt(x); --i){;;;
        if(i*i==x) {;cout << "Yes" << endl; return (0);};
    }
    ;};;;;
    cout << "No" << endl;;
}

Measured memory_bytes: 256
R,C,K=map(int,input().split())

V=[[0 for _ in range(C)] for _ in range(R)]

for i in range(K):
    r,c,v=map(int,input().split())
    V[r-1][c-1]=v

dp=[[0 for _ in range(4)] for _ in range(C+1)]
for i in range(R):
    ndp=[[0 for _ in range(4)] for _ in range(C+1)]
    for j in range(C):
        ndp[j][0]=max(dp[j])

    for j in range(C):
        v=V[i][j]
        for n in range(1,4):
            ndp[j][n]=max(ndp[j-1][n-1]+v,dp[j][3]+v,ndp[j-1][n])

    dp=ndp

print(max(dp[C-1]))


Measured memory_bytes: 229540
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
int main()
{
	int N, max = 0, an = 0;
	char S[100];
	scanf("%d%s", &N, S);
	int i = 1;
	while (i < N) {
		max = 0;
		int count1[26] = { 0 };
		int count2[26] = { 0 };
		for (int j = 0; j < i; j++) {
			count1[S[j] - 'a'] = 1;
		}
		for (int k = i; k < N; k++) {
			count2[S[k] - 'a'] = 1;
		}
		for (int l = 0; l < 26; l++) {
			if (count1[l] == 1 && count2[l] == 1) {
				max++;
			}
		}
		if (max > an) {
			an = max;
		}
		i++;
	}
	printf("%d", an);
	return 0;
}

Measured memory_bytes: 128