akhauriyash/Code-Regression huggingface dataset:
keysmap = ["qwertasdfgzxcvb","yuiophjklnm"]
while True:
    data = input()
    if data == "#": break
    count = 0
    side = 3
    for c in data:
        for i,keys in enumerate(keysmap):
            if c in keys:
                if side == 3 or side == i:
                    side = i
                else:
                    side = i
                    count += 1
    print(count)


Measured memory_bytes: 5568
#include <bits/stdc++.h>
using namespace std;
int a[2];
int i;

int main(){
  for(i=0;i<3;++i){
    cin>>a[i];
  }
  sort(a,a+3);
  if(a[0] == 5 && a[1] == 5 && a[2] == 7){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    char a[5];
    int b[200]={}, count=0;
    scanf("%s", a);
    for(int i=0; i<4; i++) b[a[i]]++;
    for(int i=65; i<=90; i++) if(b[i]==2) count++;
    if(count == 2) printf("Yes\n");
    else printf("No\n");
    return 0;
}


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

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

  ll ans = 0, cntA = 0;
  rep(i, s.size()) {
    if (s.substr(i, 2) == "BC") {
      ans += cntA;
      i++;
    } else if (s[i] == 'A') {
      cntA++;
    } else {
      cntA = 0;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=100005;
const int mod=998244353;
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){if(y==0)return 1;int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
int n,m;
vector<int> G[max_n];
vector<int> solve(vector<int> a,vector<int> b){
    vector<int> c;
    c.assign(1024,0);
    for(int i=0;i<1024;i++){
        for(int j=0;j<1024;j++)c[i^j]=Add(c[i^j],Mul(a[i],b[j]));
    }
    return c;
}
int p[max_n];
int sg[max_n];
int SG(int u){
    if(~sg[u])return sg[u];
    set<int> s;
    for(auto v:G[u]){
        if(v>u)s.insert(SG(v));
    }
    for(int i=0;;i++)if(s.count(i)==0)return sg[u]=i;
}
int main(){
    p[0]=1,p[1]=Pow(10,18);
    for(int i=2;i<max_n;i++)p[i]=Mul(p[i-1],p[1]);
    scanf("%d",&n);
    vector<int> f;f.assign(1024,0);f[0]=1;
    vector<int> a;
    scanf("%d",&m);
    for(int i=0;i<m;i++){
        int u,v;scanf("%d%d",&u,&v);
        G[u].push_back(v),G[v].push_back(u);
    }
    for(int i=1;i<=n;i++)sg[i]=-1;
    a.assign(1024,0);
    for(int i=n;i>=1;i--){
        int x=SG(i);
        assert(x<1024);
        a[x]=Add(a[x],p[i]);
    }
    f=solve(a,f);
    scanf("%d",&m);
    for(int i=1;i<=n;i++)G[i].clear();
    for(int i=0;i<m;i++){
        int u,v;scanf("%d%d",&u,&v);
        G[u].push_back(v),G[v].push_back(u);
    }
    for(int i=1;i<=n;i++)sg[i]=-1;
    a.assign(1024,0);
    for(int i=n;i>=1;i--){
        int x=SG(i);
        assert(x<1024);
        a[x]=Add(a[x],p[i]);
    }
    f=solve(a,f);
    scanf("%d",&m);
    for(int i=1;i<=n;i++)G[i].clear();
    for(int i=0;i<m;i++){
        int u,v;scanf("%d%d",&u,&v);
        G[u].push_back(v),G[v].push_back(u);
    }
    for(int i=1;i<=n;i++)sg[i]=-1;
    a.assign(1024,0);
    for(int i=n;i>=1;i--){
        int x=SG(i);
        assert(x<1024);
        a[x]=Add(a[x],p[i]);
    }
    f=solve(a,f);
    printf("%d\n",f[0]);
    return 0;
}

Measured memory_bytes: 6912
/*
[caddi2018] F - Square
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 1e5;
const int MAX_M = 5e4;
const ll MOD = 998244353;

int N, M;
int a[MAX_M], b[MAX_M], c[MAX_M];
map<pii, int> m;
ll dp[MAX_N][2];

bool check(int h, int w, int c) {
    auto kv = m.find(pii(h, w));
    return kv == m.end() || kv->second == c;
}

ll solve() {
    for (int i = 0; i < M; i++) {
        m[pii(a[i], b[i])] = c[i];
    }

    ll cnt = 1LL * (N - 3) * (N - 2);
    for (auto &kv0 : m) {
        int h = kv0.first.first;
        int w = kv0.first.second;
        if (abs(h - w) < 3) {
            continue;
        }
        auto kv1 = m.find(pii(w, h));
        if (kv1 != m.end() && kv0.second != kv1->second) {
            return 0;
        }
        if (kv1 != m.end()) {
            cnt--;
        } else {
            cnt -= 2;
        }
    }

    ll ans = 1;
    ll po = 2;
    for (ll i = cnt / 2; i > 0; i >>= 1) {
        if (i & 1) {
            (ans *= po) %= MOD;
        }
        (po *= po) %= MOD;
    }

    for (int b = 0; b < (1 << 3); b++) {
        int p = (b >> 0) & 1;
        int q = (b >> 1) & 1;
        int r = (b >> 2) & 1;
        int k = (p + q + r) % 2;
        if (check(0, 0, p) && check(0, 1, q) && check(1, 0, r) &&
            check(1, 1, k)) {
            dp[1][k] += 1;
        }
    }
    cerr << "dp[" << 1 << "][" << 0 << "]: " << dp[1][0] << endl;
    cerr << "dp[" << 1 << "][" << 1 << "]: " << dp[1][1] << endl;

    for (int n = 2; n < N; n++) {
        for (int k = 0; k < 2; k++) {
            for (int b = 0; b < (1 << 3); b++) {
                int p = (b >> 0) & 1;
                int q = (b >> 1) & 1;
                int r = (b >> 2) & 1;
                int s = (q + r + k) % 2;
                int t = (p + k) % 2;
                if (check(n - 2, n, p) && check(n - 1, n, q) &&
                    check(n, n, r) && check(n, n - 1, s) &&
                    check(n, n - 2, t)) {
                    (dp[n][r] += dp[n - 1][k]) %= MOD;
                }
            }
        }
        // cerr << "dp[" << n << "][" << 0 << "]: " << dp[n][0] << endl;
        // cerr << "dp[" << n << "][" << 1 << "]: " << dp[n][1] << endl;
    }

    ll ans_d = (dp[N - 1][0] + dp[N - 1][1]) % MOD;
    (ans *= ans_d) %= MOD;

    return ans;
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 5504
#include <cstdio>
using namespace std;
int a, b;
char c[105][105];
int main() {
    int i, j;
    scanf("%d%d", &a, &b);
    for (i=0; i<100; i++) for (j=0; j<100; j++) c[i][j] = i<50 ? '.' : '#';
    for (i=0; i<b-1; i++) c[i/50*2][i%50*2] = '#';
    for (i=0; i<a-1; i++) c[i/50*2+60][i%50*2] = '.';
    puts("100 100");
    for(i=0; i<100; i++) puts(c[i]);
    return 0;
}

Measured memory_bytes: 128
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <complex>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

int s[2005], t[2005];

const LL M = (LL)1e9 + 7;

// r_fix[i][j] = 以 s 的第 i 個、 t 的第 j 個元素爲最右所構成的共同子串列數量
LL r_fix[2005][2005];
LL s_pre_t_fix[2005][2005];
LL s_fix_t_pre[2005][2005];
LL total[2005][2005];

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &s[i]);
    }
    for (int i = 1; i <= m; i++) {
        scanf("%d", &t[i]);
    }

    // 初始化
    // for (int i = 0; i <= n; i++) {
    //     total[i][0] = 1;
    // }
    // for (int i = 0; i <= m; i++) {
    //     total[0][i] = 1;
    // }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            // r_fix;
            if (s[i] == t[j]) {
                r_fix[i][j] = (total[i - 1][j - 1] + 1) % M;
            } else {
                r_fix[i][j] = 0;
            }
            s_fix_t_pre[i][j] = (s_fix_t_pre[i][j - 1] + r_fix[i][j]) % M;

            total[i][j] = (total[i - 1][j] + s_fix_t_pre[i][j]) % M;
        }
    }
    printf("%lld\n", total[n][m] + 1);
}


Measured memory_bytes: 95104
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}
void YES(bool ok){
    cout << (ok ? "Yes" : "No") << endl;
}
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll d,t,s; cin >> d >> t >> s;
    YES(t * s >= d);
}

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

int main()
{
    long long H, W;
    cin >> H >> W;

    long long ans = LONG_LONG_MAX;

    if (H % 3 == 0)
    {
        ans = 0;
    }
    else
    {
        ans = min(ans, W);
    }

    if (W % 3 == 0)
    {
        ans = 0;
    }
    else
    {
        ans = min(ans, H);
    }

    for (long long i = 1; i < H; i++)
    {
        long long W1 = W / 2;
        long long W2 = W - W1;
        long long a = i * W;
        long long b = (H - i) * W1;
        long long c = (H - i) * W2;
        ans = min(ans, max(max(a, b), c) - min(min(a, b), c));
    }

    swap(H, W);
    for (long long i = 1; i < H; i++)
    {
        long long W1 = W / 2;
        long long W2 = W - W1;
        long long a = i * W;
        long long b = (H - i) * W1;
        long long c = (H - i) * W2;
        ans = min(ans, max(max(a, b), c) - min(min(a, b), c));
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
n=int(input())
a =list(map(int,input().split() ))
q=int(input())

from collections import Counter

su=sum(a)
cnt=Counter(a)

for i in range(q):
    b,c = map(int,input().split())
    su += (c-b)*cnt[b]
    cnt[c]+=cnt[b]
    cnt[b]=0
    print(su)

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

int n, b[102], fp;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i < n; ++i) {
    	cin >> b[i];
	}
	b[0] = b[n] = 1e9;
	for(int i = 1; i <= n; ++i) {
		fp += min(b[i], b[i - 1]);
	}
	cout << fp << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
 int W, H, x, y, r;
 cin >> W >> H >> x >> y >> r;
 
  if(x-r < 0 || x+r > W || y-r < 0 || y+r > H) cout << "No"<< endl;
  else cout << "Yes" << endl; 

 
  return 0;
}


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

using namespace std;

using PII = pair<int,int>;
#define MP make_pair
#define FF first
#define SS second

bool inc(int l, string& s){
  for(int i=l-1;i>=0;--i){
	if(s[i] != 'z'){
	  s[i]++;
	  return true;
	}
	s[i] = 'a';
  }
  return false;
}

int main(){
  int N; cin >> N;
  vector<string> vs(N);
  for(int i=0;i<N;++i)
	cin >> vs[i];

  for(int l=1;l<10;++l){
	set<string> memo;
	for(int i=0;i<N;++i){
	  for(int j=0;j+l<=vs[i].size();++j){
		memo.insert(vs[i].substr(j,l));
	  }
	}

	bool done = false;
	string s(l, 'a');
	do{
	  if(!memo.count(s)){
		cout << s << endl;
		done = true;
		break;
	  }
	}while(inc(l,s));
	if(done) break;
  }
  
  return 0;
}

Measured memory_bytes: 40652
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include<unordered_map>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << std::endl;
}

using namespace std;

long long gcd(ll x, ll y){
    if(x < y) swap(x,y);
    if (y == 0) return x;
    while(x%y){
        long long tmp = y;
        y = x%y; x = tmp;
    }
    return y;
}

Pll stand(Pll x){
    if(x.first == 0 && x.second == 0) return {0, 0};
    ll g = gcd(abs(x.first), abs(x.second));
    Pll ret = {x.first/g, x.second/g};
    if (ret.first < 0) {
        ret.first *= -1LL;
        ret.second *= -1LL;
    }
    else if(ret.first == 0){
        ret.second = abs(ret.second);
    }
    if(ret.second <= 0){
        ret  = {-ret.second, ret.first};
    }
    return ret;
}

const ll mod = 1000000007;

int main(){
    int n; cin >> n;
    vector<Pll> da(n);
    rip(i,n,0){
        cin >> da[i].first >> da[i].second;
    }
    int ju = 0;
    vector<ll> li(n+1,1);
    rip(i,n,0){
        li[i+1] = li[i] * 2 % mod;
    }
    map<Pll, Pll> mp;
    rip(i,n,0){
        Pll now = stand(da[i]);
        if(mp.count(now)) mp[now].second;
        else mp[now] = {0, 0};
        if((da[i].first <=0 && da[i].second < 0) ||(da[i].first >= 0 && da[i].second > 0)) mp[now].first ++;
        else mp[now].second++;
    }
    ll ans = 1;
    for(auto i: mp){
        if(i.first.first == 0 && i.first.second == 0){
            ju += i.second.second;
            continue;
        }
        ll now = li[i.second.first] + li[i.second.second] -1;
        now = (now+mod)%mod;
        ans *= now;
        ans %= mod;
    }
    ans = (ans+mod-1+ju)%mod;
    assert(0<= ans);
    std::cout << ans << endl;
}

Measured memory_bytes: 23348
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <cctype>
#include <algorithm>
using namespace std;
int main(void){
    int n , k , x , y ;
    cin >> n >> k >> x >> y ;

    if(n <= k) {
        cout << n * x << endl;
    } else{
       cout << k * x + (n - k) * y << endl;
    }
    return 0;
}

Measured memory_bytes: 256
// contest.cpp : アプリケーションのエントリ ポイントを定義します。
//

#include "bits/stdc++.h"
//実装が重そうな問題はある程度考えてから書く
//初期化を忘れずに（特に二分探索とか）
//コーナーケースを考えて（特に場合分けとか）
//不可解すぎるバグは配列外参照（配列の長さ）を検討
#define YES "Yes"
#define NO "No"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int LL
#define zero 0LL
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<int> VI;
typedef vector<VI> VII;
typedef pair < ut, ut > pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5 * 1e5 + 1000;
const int SIZE2 = 5010;
const int SIZE3 = 400;
const int SIZE = SIZE1;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
ut N, M, K, X, L, Y;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
LL vals[SIZE], nums[SIZE], maps[SIZE2][SIZE2], answer = zero;
VI edges[SIZE];
////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////
//LL L;
LL exist[2][SIZE];
bool reached[SIZE];
string s;
void init() {

}
LL solve2() {
	
	return 0;
}
LL solve() {
	int x;
	cin >> N >> x;
	VI v;
	int a;
	REP(i, N) {
		cin >> a;
		v.PB(a);
	}
	sort(ALL(v));
	int ans = 0;
	REP(i, N) {
		if (v[i] <= x) {
			x -= v[i];
			ans++;
		}
		else {
			x = 0;
		}
	}
	if (x) cout << ans - 1 << endl;
	else cout << ans << endl;
	return 0;
}
signed main() {
	solve();
	return 0;
}

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

int main(){
  int h,w;
  cin>>h>>w;
  vector<vector<char>>a(h,vector<char>(w));
  vector<int>H;
  vector<int>W;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >>a.at(i).at(j);
      if( a.at(i).at(j)=='#'){
        H.push_back(i);
        W.push_back(j);
      }
    }
  }
  int ans=0;
  bool paint =true;
  int i=H.size();
  int cnt=0;
  vector<int> dy{1,0,-1,0};
  vector<int> dx{0,1,0,-1};
  while(paint){
    paint =false;
    i=H.size();
    while(i!=cnt){
      cnt++;
      for(int j=0;j<4;j++){
        if(dy.at(j)+H.at(cnt-1)<0||dy.at(j)+H.at(cnt-1)>=h||dx.at(j)+W.at(cnt-1)<0||dx.at(j)+W.at(cnt-1)>=w){
          continue;
        }
        if(a.at(dy.at(j)+H.at(cnt-1)).at(dx.at(j)+W.at(cnt-1))!='#'){
          paint =true;
          a.at(dy.at(j)+H.at(cnt-1)).at(dx.at(j)+W.at(cnt-1))='#';
          H.push_back(dy.at(j)+H.at(cnt-1));
          W.push_back(dx.at(j)+W.at(cnt-1));
        }
      }
    }

    if(paint){
      ans++;
    }
  }
  cout <<ans;                    
      
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n=1,cnt=0,ans=0,a[100000],b,c,cmp,data,m,h,k,w,x,y,xcmp=0,ycmp=0,sum=0;

string s;

vector<int> z;

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

       rep(i,3){
           cin >> a[i];
       }
       sort(a,a+3);
       Cout(a[0]+a[1]);
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   int n;
   cin >> n;
   int ans = 0;
   rep(num, 1, n + 1) {
      if (num % 2 == 0) continue;
      int cnt = 0;
      rep(i, 1, num + 1) {
         if (num % i == 0) cnt++;
      }
      if (cnt == 8) ans++;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<int(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
struct UnionFind {
  vector<int> parent;
  UnionFind (int n) : parent(n, -1) {}
  int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (parent[y] < parent[x]) swap(x, y);
    if (parent[x] == parent[y]) --parent[x];
    parent[y] = x;
    return true;
  }
};

using Graph=map<int,set<int>>;

void add_edge(Graph& g, int src, int dest) {
  g[src].insert(dest);
  g[dest].insert(src);
}

size_t calc(const Graph& g, int node, int parent = -1) {
  size_t sum = 42;
  if (g.empty()) return sum;
  for (const auto ch : g.find(node)->second) {
    if (ch == parent) continue;
    sum += calc(g, ch, node);
  }
  return sum*sum;
}

size_t get_hash(int h, int w) {
  vector<string> table(h);
  table[0] = table[h-1] = string(w, '.');
  REP(i,h-2) {
    string line;
    cin>>line;
    table[i+1] = "." + line + ".";
  }
  UnionFind uf(h*w);
  REP(i,h)REP(j,w) {
    if (table[i][j] == '#') {
      int di[] = {1, 1, 0, -1, -1, -1, 0, 1};
      int dj[] = {0, 1, 1, 1, 0, -1, -1, -1};
      REP(k,8) {
        int ni=i+di[k];
        int nj=j+dj[k];
        if (ni<0||nj<0||ni>=h||nj>=w) continue;
        if (table[ni][nj] == '#') uf.merge(ni*w+nj, i*w+j);
      }
    } else {
      int di[] = {1, 0, -1, 0};
      int dj[] = {0, 1, 0, -1};
      REP(k,4) {
        int ni=i+di[k];
        int nj=j+dj[k];
        if (ni<0||nj<0||ni>=h||nj>=w) continue;
        if (table[ni][nj] == '.') uf.merge(ni*w+nj, i*w+j);
      }
    }
  }
  Graph g;
  REP(i,h)REP(j,w) {
    if (table[i][j] == '#') {
      int di[] = {1, 1, 0, -1, -1, -1, 0, 1};
      int dj[] = {0, 1, 1, 1, 0, -1, -1, -1};
      REP(k,8) {
        int ni=i+di[k];
        int nj=j+dj[k];
        if (ni<0||nj<0||ni>=h||nj>=w) continue;
        if (table[ni][nj] == '.') add_edge(g, uf.root(i*w+j), uf.root(ni*w+nj));
      }
    } else {
      int di[] = {1, 0, -1, 0};
      int dj[] = {0, 1, 0, -1};
      REP(k,4) {
        int ni=i+di[k];
        int nj=j+dj[k];
        if (ni<0||nj<0||ni>=h||nj>=w) continue;
        if (table[ni][nj] == '#') add_edge(g, uf.root(i*w+j), uf.root(ni*w+nj));
      }
    }
  }
  return calc(g, uf.root(0));
}


int main() {
  while(true) {
    int h,w;
    cin>>h>>w;
    if(!h) break;
    auto t1 = get_hash(h+2, w+2);
    cin>>h>>w;
    auto t2 = get_hash(h+2, w+2);
    if (t1 == t2) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3164
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main()
{
    LL r,d,x;cin>>r>>d>>x;

    REP(i,10){
        x = r*x-d;
        cout<<x<<endl;
    }
    
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if(a>=10 || b>=10) co(-1);
  else co(a*b);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 5e5 + 5;
const ll MOD = 1e9 + 7;
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pis pair<ll,string>
#define F first
#define S second
#define LCM(a,b) ((a*b)/__gcd(a,b))
#define inf 1e15
#define test ll cse;cin>>cse;for(ll _i=1;_i<=cse;_i++)
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const double EPS = 1E-9;
typedef vector< vector<double> > matrix;
typedef vector< vector<int> > array_2D;
typedef pair<int, pair<int, int> > ppi;
typedef vector<int> vi;



int main() {
    fast;

    int n; cin >> n;

    unordered_set< string > S;
    string tmp;
    for(int i = 0; i < n; i++) {
        cin >> tmp;
        S.insert(tmp);
    }


    cout << S.size();
    return 0;
}

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

int main(){
  constexpr int64_t Nalp= 26;
  int64_t bufN;
  cin >> bufN;
  int64_t N= bufN;

  string ans;
  while(N > 0){
    N--;
    int64_t tail= N% Nalp;
    char c= ('a'+ tail);
    ans= c+ ans;

    N/= Nalp;
  }
  
  cout << ans << endl;
}

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

int main(){
  int N;
  cin >> N;
  int d[N];
  for(int i=0;i<N;i++){
    cin >> d[i];
  }
  sort(d,d+N);
  int devide_point = N/2;
  int ans = d[devide_point] - d[devide_point-1];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2005;
const int INF = 2e9;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
struct BinaryIndexTree {
	int a[MAXN], n;
	void init(int x) {
		n = x;
		memset(a, 0, sizeof(a));
	}
	void modify(int pos, int d) {
		for (int i = pos; i <= n; i += i & -i)
			a[i] += d;
	}
	int query(int l, int r) {
		int ans = 0;
		for (int i = r; i >= 1; i -= i & -i)
			ans += a[i];
		for (int i = l - 1; i >= 1; i -= i & -i)
			ans -= a[i];
		return ans;
	}
} BIT; 
struct info {int val, home; } a[MAXN];
bool cmp(info a, info b) {
	return a.val < b.val;
}
int main() {
	int n, k, q;
	read(n), read(k), read(q);
	for (int i = 1; i <= n; i++) {
		int x; read(x);
		a[i] = (info) {x, i};
	}
	sort(a + 1, a + n + 1, cmp);
	int ans = INF;
	for (int i = 1; i <= n; i++) {
		BIT.init(n);
		static set <int> st;
		st.clear(); st.insert(0), st.insert(n + 1);
		for (int j = 1; j <= i - 1; j++)
			st.insert(a[j].home);
		BIT.init(n + 1);
		for (int j = i; j <= n; j++)
			BIT.modify(a[j].home, 1);
		int rit = INF, req = q;
		for (int j = i; j <= n; j++) {
			set <int> :: iterator tmp = st.lower_bound(a[j].home);
			int r = *tmp; tmp--; int l = *tmp;
			if (BIT.query(l, r) >= k) {
				if (--req == 0) {
					rit = a[j].val;
					break;
				}
			} else st.insert(a[j].home);
			BIT.modify(a[j].home, -1);
		}
		if (req != 0) break;
		chkmin(ans, rit - a[i].val);
	}
	writeln(ans);
	return 0;
}

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

int main() {
	int n ;
	scanf("%d",&n);
	int arr[n];
	long long sum = 0;
	for(int i = 0 ; i < n ; ++i)scanf("%d",&arr[i]) , sum += arr[i];
	int m ;
	scanf("%d",&m);
	int p , t;
	while(m--){
		scanf("%d%d",&p,&t);
		printf("%lld\n",sum - arr[p-1] + t);
	}
	return 0;
}

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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
///*******///
#define int long long
///*****////
const int mod = 1e9 + 7;
#define pi pair<int,int>
#define pb push_back
#define F first
#define S second
#define fills(x,y) memset(x,y,sizeof x)
#define rep(i,n) for(i=0;i<n;++i)
#define REP(i,k,n) for(i=k;i<=n;++i)
#define tr(i,c) for(auto &i:c)
#define fastio          ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define inchar          getchar
#define outchar(x)      putchar(x)
#define bitcounts(n) __builtin_popcountll(n)
#define sz(a) int((a).size())
#define endl "\n"
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }
template<typename T> void scan(T &x){x=0;bool neg=0;register T c=inchar();if(c=='-')
neg=1,c=inchar();while((c<48)||(c>57))c=inchar();for(;c<48||c>57;c=inchar());
for(;c>47&&c<58;c=inchar())x=(x<<3)+(x<<1)+(c&15);if(neg)x*=-1;}
template<typename T> void output(T n){bool neg=0;if(n<0)n*=-1,neg=1;char snum[65];int i=0;do {snum[i++]=n%10+'0';n/=10;}\
while(n);i=i-1; if(neg)putchar('-'); while(i>=0)outchar(snum[i--]);outchar('\n');}
inline void instr(char *str){register char c=0;register int i=0;while(c<33)c=inchar();while (c!='\n'&&c!=' '&&c!=EOF){\
str[i]=c;c=inchar();++i;}str[i]='\0';}
template<typename T> T lcm(T a, T b){return (a*(b/__gcd(a,b)));}
template<typename T> inline T MOD(T a, T b) {return (a<b ? a : a%b);}
template<typename T> T add(T a, T b, T c){T x=a+b;return (x>=c ? x-c : x);}
template<typename T> T mod_neg(T a, T b) {a=MOD(a, b);if(a<0){a+=b;}return a;}
template<typename T> T expo(T e, T n){T x=1,p=e;while(n){if(n&1)x=x*p;p=p*p;n>>=1;}return x;}
template<typename T> T power(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=MOD(x*p,m);p=MOD(p*p,m);n>>=1;}return x;}
template<typename T> T exted_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;t=xx;\
xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T> T mod_inverse(T a, T n){T x,y;T d = exted_euclid(a, n, x, y);return (d>1?-1:mod_neg(x,n));}
#define tcsolve() int tcs; cin>>tcs;while(tcs--) solve();
//inline string to_string(int num){stringstream ss;ss<<num;return ss.str();}
const int MAX=1003;
//int arr[MAX];
string str1, str2;

void solve()
{

int q,cnt=0,n,a,b,i, j,x,sum = 0,ans=0;
cin >>n>>a>>b;
if(abs(a-b)&1)
    cout<<"Borys";
    else
    cout<<"Alice";

}
int32_t main()
{
fastio;
#ifdef LOCAL
freopen("in.c","r",stdin);
//freopen("out1.c","w",stdout);
#endif
solve();
return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
#include<numeric>
#include<complex>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void printVector(vector<ll> A){
    cout << "[vector]" << endl;
    for(int i=0; i<A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

int divisorCount(int n){
    int count = 0;
    FOR(i, 1, n+1){
        if(n % i == 0){
            count++;
        }
    }
    return count;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    // input
    int N;
    cin >> N;

    int answer = 0;
    for(int i=1; i<N+1; i+=2){
        if(divisorCount(i)==8){
            answer++;
        }
    }

    p(answer);
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ii = pair<int, int>;

int main(){
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<int> vs(n);
	for(auto &x:vs)
		cin >> x;
	ll ans = 0;
	for(int i=0; i<n; ++i)
		for(int j=i+1; j<n; ++j) ans += ll(vs[i])*ll(vs[j]);
	cout << ans << endl;
}


Measured memory_bytes: 3652
#include <iostream>
using namespace std;
int main() {
	int n, l, r;
	int sum = 0;
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> l >> r;
		sum += (r - l + 1);
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    char c; cin >> c;
    if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o') cout << "vowel";
    else cout << "consonant";
    cout << endl;
    return 0;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,l,ans;
  cin>>n>>l;
  ans=0;
  rep(i,n) ans+=l+i;
  if(l<=0 && 0<=l+n-1) cout<<ans<<endl;
  else if(0<l) cout<<ans-l<<endl;
  else cout<<ans-(l+n-1)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

struct UnionFind {
  int n,num;
  vector<int> r,p;
  UnionFind() {}
  UnionFind(int n):n(n),num(n),r(n,1),p(n,0){iota(p.begin(),p.end(),0);}
  int find(int x) {
    return (x==p[x]?x:p[x]=find(p[x]));
  }
  bool same(int x,int y) {
    return find(x)==find(y);
  }
  void unite(int x,int y) {
    x=find(x);y=find(y);
    if (x==y) return;
    if (r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
    num--;
  }
  int size(int x) {
    return r[find(x)];
  }
  int count() {
    return num;
  }
};

int N,M;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> N >> M;
  UnionFind uf(N);
  REP(i,M) {
    int X,Y,Z;
    cin >> X >> Y >> Z;
    X--; Y--;
    uf.unite(X,Y);
  }
  cout << uf.count() << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
const int maxn=2e5+10,mod=1e9+7;
const long long inf=1e10;
using namespace std;
int n,m,k,t;
struct node
{
    long long x,l,r,tag;
    node operator+(const node&p)const
    {
        node ret;
        ret.x=min(x,p.x);
        ret.l=min(l,p.l);
        ret.r=min(r,p.r);
        ret.tag=0;
        return ret;
    }
}tr[maxn<<2];
void pup(int rt){tr[rt]=tr[rt<<1]+tr[rt<<1|1];}
void pdw(int rt)
{
    tr[rt<<1].x+=tr[rt].tag;
    tr[rt<<1].l+=tr[rt].tag;
    tr[rt<<1].r+=tr[rt].tag;
    tr[rt<<1].tag+=tr[rt].tag;
    tr[rt<<1|1].x+=tr[rt].tag;
    tr[rt<<1|1].l+=tr[rt].tag;
    tr[rt<<1|1].r+=tr[rt].tag;
    tr[rt<<1|1].tag+=tr[rt].tag;
    tr[rt].tag=0;
}
node query(int L,int R,int l,int r,int rt)
{
    if(L<=l&&r<=R)return tr[rt];
    int mid=l+r>>1;
    if(tr[rt].tag)pdw(rt);
    node ret={-1,-1,-1,0};
    if(L<=mid)ret=query(L,R,l,mid,rt<<1);
    if(mid+1<=R)
    {
        node tmp=query(L,R,mid+1,r,rt<<1|1);
        if(ret.x==-1)ret=tmp;
        else ret=ret+tmp;
    }
    return ret;
}
void upd1(int L,int R,long long w,int l,int r,int rt)
{
    if(L<=l&&r<=R)
    {
        tr[rt].tag+=w;
        tr[rt].x+=w;
        tr[rt].l+=w;
        tr[rt].r+=w;
        return;
    }
    int mid=l+r>>1;
    if(tr[rt].tag)pdw(rt);
    if(L<=mid)upd1(L,R,w,l,mid,rt<<1);
    if(mid+1<=R)upd1(L,R,w,mid+1,r,rt<<1|1);
    pup(rt);
}
void upd2(int x,long long w,int l,int r,int rt)
{
    if(x==l&&x==r)
    {
        tr[rt]=node{w,w-l,w+l,0};
        return;
    }
    if(tr[rt].tag)pdw(rt);
    int mid=l+r>>1;
    if(x<=mid)upd2(x,w,l,mid,rt<<1);
    else upd2(x,w,mid+1,r,rt<<1|1);
    pup(rt);
}
void build(int l,int r,int rt)
{
    if(l==r)
    {
        tr[rt]=node{inf,inf,inf,0};
        return;
    }
    int mid=l+r>>1;
    build(l,mid,rt<<1);
    build(mid+1,r,rt<<1|1);
    pup(rt);
}
int main()
{
    int i,j;
    int q,a,b,pos;
    scanf("%d%d%d%d%d",&n,&q,&a,&b,&pos);
    build(1,n,1);
    upd2(a,abs(pos-b),1,n,1);
    upd2(b,abs(pos-a),1,n,1);
    //printf("***%lld\n",tr[1].x);
    q--;
    while(q--)
    {
        scanf("%d",&j);
        long long ret=1e18;
        if(j>=1)
        {
            node p=query(1,j,1,n,1);
            ret=min(ret,j+p.l);
        }
        if(j<n)
        {
            node p=query(j+1,n,1,n,1);
            ret=min(ret,p.r-j);
        }
        upd1(1,n,abs(j-pos),1,n,1);
        node x=query(pos,pos,1,n,1);
        if(x.x>ret)upd2(pos,ret,1,n,1);
        pos=j;
        //printf("***%lld\n",tr[1].x);
    }
    printf("%lld\n",tr[1].x);
    return 0;
}

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

int main()
{
    int a , b;
    cin >> a >> b;
    if(a > 8 || b > 8){
        cout << ":(" << endl;
    } else{
        cout << "Yay!" << endl;
    }
}


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

const int MODX = 1000000007;

int main() {
	int col[3] = {-1, -1, -1};
	long long lastdp = 1, nowdp;
	int n;
	cin>>n;
	while(n--) {
		long long a;
		cin>>a;
		long long count = 0;
		for (int i=0; i<3; i++)
			if (col[i] == a-1)
				count++;
		nowdp = (lastdp*count)%MODX;
		for (int i=0; i<3; i++)
			if (col[i] == a-1) {
				col[i]++;
				break;
			}
		lastdp = nowdp;
	}
	cout<<lastdp<<endl;
	return 0;
}

Measured memory_bytes: 256
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

#$stdin = File.open('input.txt')

d,g = gsmi #10,
pcs = Array.new(d){gsmi} #100, 10**6
points = pcs.map.with_index(1) do |(p,c),i|
  [100*i]*(p-1)+[100*i+c]
end

ans = 1000
(2**d).times do |i| #1000
  js = []
  d.times do |j|
    js << j if (i>>j)&1==1
  end

  js.each do |last|
    sum = 0
    crt = 0
    js.each do |j|
      next if j==last
      break if sum>g
      sum += sum(points[j])
      crt += points[j].length
    end
    #p [sum,js,last,crt]
    next if sum>g
    remain = g-sum
    points[last].each do |points|
      remain -= points
      crt += 1
      break if remain<=0
    end
    #puts "remain: #{remain} crt: #{crt}"
    ans = min(ans,crt) if remain<=0
  end
end

puts ans


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

typedef long long ll;

#define M 1000000007

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;

	int len = 0;
	int mlen = 0;
	for (int i = 0; i < 3; ++i) {
		if (s[i] == 'R') {
			len++;
		}
		else {
			mlen = max(mlen, len);
			len = 0;
		}
	}
	mlen = max(mlen, len);
	cout << mlen;

	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

// $ g++ -std=c++11 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
const int MAX_N=3e5+10;
int N;
string S;
int cum[MAX_N];
LL solve() {
  LL res=MAX_N;
  ZERO(cum);
  REP(i,N) cum[i+1]=cum[i]+(S[i]=='E');
  REP(i,N) {
    int le=cum[i],lw=i-le,re=cum[N]-cum[i+1],rw=N-i-1-re;
    LL x=lw+re;
//    dump3(i,le+rw,lw+re);
//    dump4(le,lw,re,rw);
    SMIN(res,x);
  }
  return res;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N>>S;
  cout<<solve()<<endl;
  return 0;
}


Measured memory_bytes: 1812
#include <bits/stdc++.h>  
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define REP(i, a, n, op) for(int i=a; i<(int)(n); i ## op ## op)
#define cout(val) cout << val << endl

using namespace std;  

int main(){
    string a;
    cin >> a;
    if(a == "ABC"){
        cout("ARC");
    }else{
        cout("ABC");
    }
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
const int MAX = 100010;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    COMinit();
    int n,k;
    cin>>n>>k;
    long long ans,m=0,M=0;
    vector<long long> a(n),bin(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());

    for(int i=k-1;i<=n-1;i++){
        bin[i]=COM(i,k-1);
    }
    for(int i=1;i<=n-k+1;i++){
        m+=a[i-1]*bin[n-i]%MOD;

    }
    for(int i=k;i<=n;i++){
        M+=a[i-1]*bin[i-1]%MOD;
    }
    ans=(M-m)%MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define eq(x,y) (fabs((x)-(y)) < 1e-8)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int nmax= 1e5+5;
const ll mod= 1e9+7;

vector<int>v;
int n,k;


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

    cin>>n>>k;
    v.resize(n);
    for(int i=0; i<n; i++)
        cin>>v[i];

    sort(v.begin(), v.end());
    int j=k-1, i=0;
    ll shomoy=INT_MAX;
    while(j<n){
        int L=v[i], R = v[j];
        ll hui;
        if(L>=0) hui=R;
        else if(R<=0) hui=-L;
        else{
            if(-L>R) hui=2*R-L;
            else hui=-2*L+R;
        }

        shomoy=min(shomoy, hui);
        i++, j++;
    }


    cout<<shomoy;

    return 0;
}




Measured memory_bytes: 640
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner (System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		sc.close();

		int x = a*b;
		int y = c*d;

		System.out.println(x>y ? x : y);
	}
}


Measured memory_bytes: 35564