akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define i64 unsigned long long
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll mod = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}


int pow(ll x, ll y, ll mod){
    ll ret=1;
    for(;y;y>>=1,x=1ll*x*x%mod){
        if(y&1) ret=1ll*ret*x%mod;
    }
    return ret;
}
void kill()
{
    cout << -1 << endl;
    exit(0);
}

int main() {
    sonic();
    int n;
    R n;
    i64 ans = 0;
    priority_queue<pair<i64, i64>> q;
    vi A(n), B(n);
    rep(i, n)R A[i];
    rep(i, n){
        R B[i];
        q.push(make_pair(B[i], i));
    }
    while(0<q.size()) {
        i64 i = q.top().second;
        q.pop();
        if(B[i]==A[i])continue;
        if(B[i]<A[i])kill();
        i64 next = (i + 1 + n) % n;
        i64 prev = (n + i - 1) % n;
        i64 total = B[next] + B[prev];
        i64 t = (B[i] - A[i]) / total;
        if(t==0)kill();
        ans += t;
        B[i] -= t * total;
        q.push(make_pair(B[i], i));
    }
    cout << ans << endl;
}


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

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

  int sum = 0;
  for (int i = 1; i <= N; i++) {
    if (to_string(i).length() % 2 != 0) {
      sum++;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define rep(i,n)for(int i=0;i<n;i++)
int main(){
  char s[59],t[59],ans[59]={'{'},u[59];
  scanf("%s%s",s,t);
  int ls=strlen(s),lt=strlen(t),f;
  rep(i,ls-lt+1){
    f=0;
    rep(j,ls){
      if(i<=j&&j<i+lt){
        if(s[j]!='?'){
          if(s[j]!=t[j-i])f++;
          else u[j]=s[j];
        }
        else u[j]=t[j-i];
      }
      else u[j]=(s[j]=='?'?'a':s[j]);
    }
    u[ls]='\0';
    if(!f&&strcmp(ans,u)>=0)strcpy(ans,u);
  }
  printf("%s",ans[0]=='{'?"UNRESTORABLE":ans);
}

Measured memory_bytes: 1724
using System;
class latte
{
    static void Main()
    {
        while (true)
        {
            string s = Console.ReadLine();
            if (s == null) break;
            int N = int.Parse(s);
            int cnt = 0;
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    for (int k = 0; k < 10; k++)
                    {
                        int sum = i + j + k;
                        if (N - sum >= 0 && N - sum < 10) cnt++;
                    }
                }
            }

            Console.WriteLine(cnt);
        }
    }
}

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

#define DEBUG

using namespace std;

const int N = 2e5+7;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const double eps = 1e-11;
typedef pair<int, int> pii;

template <int _MOD> struct Mint
{
    int v = 0;
    Mint() {}
    Mint(int _v) : v((_v%_MOD+_MOD)%_MOD) {}
    Mint(long long _v) : v(static_cast<int>((_v%_MOD+_MOD)%_MOD)) {}
    Mint operator = (const int &_v) { return *this = Mint(_v); }
    Mint operator = (const long long &_v) { return *this = Mint(_v); }
    bool operator ! () const { return !this->v; }
    bool operator < (const Mint &b) const { return v < b.v; }
    bool operator > (const Mint &b) const { return v > b.v; }
    bool operator == (const Mint &b) const { return v == b.v; }
    bool operator != (const Mint &b) const { return v != b.v; }
    bool operator <= (const Mint &b) const { return v < b.v || v == b.v; }
    bool operator >= (const Mint &b) const { return v > b.v || v == b.v; }
    Mint operator + (const Mint &b) const { return Mint(v+b.v); }
    Mint operator - (const Mint &b) const { return Mint(v-b.v); }
    Mint operator * (const Mint &b) const { return Mint(1ll*v*b.v); }
    Mint operator / (const Mint &b) const { return Mint(b.inv()*v); }
    Mint& operator += (const Mint &b) { return *this = *this+b; }
    Mint& operator -= (const Mint &b) { return *this = *this-b; }
    Mint& operator *= (const Mint &b) { return *this = *this*b; }
    Mint& operator /= (const Mint &b) { return *this = *this/b; }
    Mint operator - () const { return Mint(-v); }
    Mint& operator ++ () { return *this += 1; }
    Mint& operator -- () { return *this -= 1; }
    Mint operator ++ (int) { Mint tmp = *this; *this += 1; return tmp; }
    Mint operator -- (int) { Mint tmp = *this; *this -= 1; return tmp; }
    Mint pow(int p) const {
        Mint res(1), x(*this);
        while (p) {
            if (p&1) res = res*x;
            x *= x;
            p >>= 1;
        }
        return res;
    }
    Mint inv() const { return pow(_MOD-2); }
    friend istream& operator >> (istream &is, Mint &mt) { return is >> mt.v; }
    friend ostream& operator << (ostream &os, const Mint &mt) { return os << mt.v; }
};
using mint = Mint<MOD>;

int n, k;
mint A[N];

inline void init()
{
    A[0] = 1;
    for (int i = 1; i <= n; ++i) {
        A[i] = A[i-1]*i;
    }
}

inline mint C(const int &p, const int &q)
{
    return A[p]/A[q]/A[p-q];
}

inline void solve()
{
    cin >> n >> k;
    init();
    mint res = 1;
    for (int i = 1; i <= min(k, n-1); ++i) {
        // i the number of 0
        res += C(n, i)*C(n-1, n-i-1);
    }
    cout << res << endl;
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int T = 1;
    while (T--) {
        solve();
    }
    return 0;
}

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

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

int main(){
  int n, k, q;
  cin >> n >> k >> q;

  int c[n]={0};
  rep(i,q){
    int a;
    cin >> a;
    c[a-1]++;
  }
  rep(i,n){
    if(k-q+c[i]>0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

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

using namespace std;

typedef long long ll;




int main()
{
    int n,s;
    cin >> n >> s;
    int m = s/1000;
    for(int i=0;i<=2000;++i)
    {
        for(int j=0;j<2000;++j)
        {
            int o = (m-5*j-10*i);
            if((m - 4*j - 9*i) == n && o>=0 && (o+5*j+10*i)==s/1000)
            {
                cout << i << " " << j << " " << o;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1";

}


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;
int INF = 1000000009;
int main()
{
    double l;
    cin >> l;
    double a = l/3;
    double b = a * a * a;
    printf("%lf ",b);
}

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

void insertVal (vector <long long> &v, int elements) {
	for (int i = 1; i <= elements; i++){
		int x;
		cin >> x;
		v.push_back(v[i-1] + x);
	}
}

int main() {
	int n, m, k;
	cin >> n >> m >> k;
	vector <long long> a;
	vector <long long> b;
	a.push_back(0);
	b.push_back(0);
	insertVal(a, n);
	insertVal(b, m);
	int max = 0, check = b.size()-1;
	int s1= a.size();
	for (int i = 0; i < s1; i++){
		for (int j = check; j>= 0; j--){
			if (b[j] + a[i] <= k){
				max = ((i + j) > max)? (i + j) : max;
				check = j;
				break;
			}
		}
	}
	
	cout << max;
	return 0;
}

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

using namespace std;

int main()
{
  string alphabet;
  for (int i = 0; i < 26; ++i) alphabet.push_back('a' + i);

  string s; cin >> s;
  for (int i = 0, len = s.size(); i < len; ++i) {

    int pos = alphabet.find(s[i]);
    if (pos != string::npos) {
      alphabet.erase(alphabet.begin() + pos);
    }
  }

  if (alphabet.size() == 0) {
    cout << "None";
  } else {
    cout << alphabet.front();
  }
}

Measured memory_bytes: 512
;スタックサイズ上限を増やす
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
;split関数
(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
      (cons (subseq str 0 pos)
            (split x (subseq str (+ pos size))))
      (list str))))

;入力
(setq *n* (read))
(setq *v* (make-array *n* :initial-contents (mapcar #'parse-integer (split " " (read-line)))))
(setq *c* (make-array *n* :initial-contents (mapcar #'parse-integer (split " " (read-line)))))

;全探索した結果を入れる
(setq *gains* nil)

;dfs
(defun dfs (gain i)
  (let ((next-gain gain) (result nil))
      (if (>= i *n*)
        (setq *gains* (cons gain *gains*))
        (dotimes (n 2 result)
                 ;(print (list "next-gain " next-gain (aref *v* i) (aref *c* i)))
                 (when (= n 1) (setq next-gain (+ gain (- (aref *v* i) (aref *c* i)))))
                 (setq result (dfs next-gain (1+ i)))))))
;実行
  (dfs 0 0)

;出力
  (print (apply #'max *gains*))


Measured memory_bytes: 33852
#include <bits/stdc++.h>
using namespace std;
typedef long long int  ll;
#define nl cout<<"\n";
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main() {
    
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
    #endif

    set<string> s1;
    int n;cin>>n;
    while(n--){string s;cin>>s; s1.insert(s);}
    cout<<s1.size();
}

Measured memory_bytes: 19236
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include <climits>
#include <set>
#include <map>
using namespace std;

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

typedef long long ll;



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

    if(str == "SUN")
    {
        cout << 7 << endl;
    }
    else if(str == "MON")
    {
        cout << 6 << endl;
    }
    else if(str == "TUE")
    {
        cout << 5 << endl;
    }
    else if(str == "WED")
    {
        cout << 4 << endl;
    }
    else if(str == "THU")
    {
        cout << 3 << endl;
    }
    else if(str == "FRI")
    {
        cout << 2 << endl;
    }
    else
    {
        cout << 1 << endl;
    }
    
    
    return 0;
}

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

using namespace std;

struct State
{
    vector<int> to_solve;
    vector<bool> solved;
    int breaks;

    State(int size) : solved(size, false), breaks(0) {}
};

class Event
{
public:
    Event(int id, int time, int priority)
        : id_(id), time_(time), priority_(priority) {}

    virtual ~Event() {}

    virtual void Execute(State &state) const = 0;

    bool operator<(const Event &other) const
    {
        if (time_ != other.time_) {
            return time_ < other.time_;
        }
        return priority_ > other.priority_;
    }

protected:
    int id_;
    int time_;
    int priority_;
};

class BreakStart : public Event
{
public:
    BreakStart(int id, int time) : Event(id, time, 0) {}

    void Execute(State &state) const override
    {
        state.to_solve.push_back(id_);
    }
};

class BreakStop : public Event
{
public:
    BreakStop(int id, int time) : Event(id, time, 1) {}

    void Execute(State &state) const override
    {
        if (state.solved[id_]) {
            return;
        }

        state.breaks += 1;
        while (!state.to_solve.empty()) {
            state.solved[state.to_solve.back()] = true;
            state.to_solve.pop_back();
        }
    }
};

int main()
{
    int nodes, disputes;
    cin >> nodes >> disputes;

    vector<Event*> events(2 * disputes, nullptr);
    for (int i = 0; i < disputes; i += 1) {
        int left, right;
        cin >> left >> right;
        events[2 * i] = new BreakStart(i, left - 1);
        events[2 * i + 1] = new BreakStop(i, right - 1);
    }

    sort(events.begin(), events.end(), [](Event const *a, Event const *b) {
        return (*a) < (*b);
    });

    State state(disputes);
    for (const auto &e : events) {
        e->Execute(state);
        delete e;
    }

    cout << state.breaks << "\n";
    return 0;
}


Measured memory_bytes: 8448
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define D second

const int N = 2e5 + 5;
const int MOD = 998244353;
const int oo = 2e9;

int n;
pair<int, int> robot[N];
int dp[N];
int st[N << 2];
long long sol[N];

int get(int cur, int s, int e, int i, int j)
{
  if(s > j || e < i)
    return -oo;
  if(s >= i && e <= j)
    return st[cur];
  int l = 2 * cur + 1;
  int r = 2 * cur + 2;
  int mid = (s + e) / 2;
  return max(get(l, s, mid, i, j), get(r, mid + 1, e, i, j));
}

void update(int cur, int s, int e, int idx, int val)
{
  if(s > idx || e < idx)
    return;
  if(s == e){
    st[cur] = val;
    return;
  }
  int l = 2 * cur + 1;
  int r = 2 * cur + 2;
  int mid = (s + e) / 2;
  update(l, s, mid, idx, val);
  update(r, mid + 1, e, idx, val);
  st[cur] = max(st[l], st[r]);
}

void pre()
{
  for(int i = n - 1 ; i >= 0 ; i--) {
    int right = lower_bound(robot, robot + n, make_pair(robot[i].X + robot[i].D, -oo)) - robot - 1;
    // cout << i << " " << right << endl;
    if(right > i)
      dp[i] = get(0, 0, n - 1, i + 1, right);
    else
      dp[i] = i + 1;
    // cout << dp[i] << endl;
    update(0, 0, n - 1, i, dp[i]);
  }
}

int main()
{
  cin >> n;
  for(int i = 0 ; i < n ; i++) {
    cin >> robot[i].X >> robot[i].D;
  }
  sort(robot, robot + n);
  pre();
  sol[n] = 1;
  for(int i = n - 1 ; i >= 0 ; i--) {
    sol[i] = (sol[i + 1] + sol[dp[i]]) % MOD;
  }
  cout << sol[0] << endl;
  return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x) \
  int x;     \
  cin >> x;  \
  while (x--)

int32_t main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  int n;
  cin >> n;

  map<int, int> factor;

  while (n % 2 == 0)
  {
    n /= 2;
    factor[2]++;
  }

  for (int i = 3; i * i <= n; i += 2)
  {
    while (n % i == 0)
    {
      n /= i;
      factor[i]++;
    }
  }
  if (n >= 2)
    factor[n]++;
  int ans = 0;
  for (auto i : factor)
  {
    ans += (sqrt(1.0 + 8.0 * i.second) - 1.0) / 2.0;
  }

  cout << ans;

  return 0;
}

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

int main(){
    int n, m, p;
    string s;
    cin >> n >> m;
    vector<int> wa(n + 1, 0);
    vector<int> res(n + 1, 0);

    int ac = 0, penalty = 0;
    for (int i = 0; i < m; i++){
        cin >> p >> s;
        if (res[p] > 0) continue;
        else if (s == "AC"){
            res[p] = 1;
            ac += 1;
            penalty += wa[p];
        }
        else wa[p] += 1;
    }
    cout << ac << " " << penalty << endl;
}


Measured memory_bytes: 1024
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define st first
#define nd second

using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set =
	tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
#define shandom_ruffle random_shuffle
 
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(11);
	cerr << fixed << setprecision(6);

	int n, m, v, p;
	cin >> n >> m >> v >> p;

	vll scores(n);
	for (ll &x : scores) { cin >> x; }
	sort(ALL(scores), greater<ll>());
	debug() << imie(scores);

	auto CanHave = [&](int idx) {
		debug() << imie(idx);
		if (idx < p) { return true; }
		const ll idx_score = scores[idx] + m;
		const int always_take = (p-1) + (n-idx-1);
		const int L = p-1;
		const int R = idx-1;
		const int rem_others = v - always_take - 1;
		debug() << imie(idx_score) << imie(always_take) << imie(rem_others);
		debug() << imie(L) << imie(R) << imie(idx_score);
		ll total = 0;
		for (int i = L; i <= R; ++i) {
			const ll rem = idx_score - scores[i];
			if (rem < 0) { return false; }
			total += min<ll>(max<ll>(0, rem), m);
		}
		if (rem_others <= 0) { return true; }
      // to make total number of votes >= m*v
		return total >= (ll)rem_others * m;
	};

	int lft = 0, rgt = n;
	while (rgt - lft > 1) {
		const int mid = (lft + rgt) / 2;
		if (CanHave(mid)) {
			lft = mid;
		} else {
			rgt = mid;
		}
	}

	cout << rgt << "\n";
}


Measured memory_bytes: 1024
/* 132b */
#include<stdio.h>
int main(void)
{
  int n,p[20],i,sum;
  scanf("%d",&n);
  sum=0;
  for(i=0;i<n;i++){
    scanf("%d",&p[i]);
  }
  for(i=1;i<n-1;i++){
    if((p[i]<p[i-1]&&p[i]>=p[i+1])||(p[i]>=p[i-1]&&p[i]<p[i+1]))
      sum++;
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 128
N = int(input())
xs, ys = [], []
for _ in range(N):
    x, y = map(int, input().split())
    xs.append(x)
    ys.append(y)
U = [x + y for x, y in zip(xs, ys)]
V = [x - y for x, y in zip(xs, ys)]
ans = max([max(U) - min(U), max(V) - min(V)])
print(ans)

Measured memory_bytes: 126788
n,p=map(int,input().split())
a=list(map(lambda x:int(x)%2,input().split()))
a0=a.count(0)
a1=a.count(1)
base=2**a0

import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if p==1:
  ans=0
  for i in range((a1+1)//2):
    b=combinations_count(a1, 2*i+1)
    ans+=base*b
  print(ans)
else:
  ans=0
  for i in range(a1//2+1):
    b=combinations_count(a1, 2*i)
    ans+=base*b
  print(ans)


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

#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
#define MP make_pair
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;

signed main(){
    string s; cin >> s;
    deque<char> dq;
    rep(i,s.size()) dq.push_back(s[i]);
    
    int q; cin >> q;
    bool rev=false;
    rep(i,q){
        int type; cin >> type;
        if(type==1){
            rev=!rev;
        }else{
            int fb; cin >> fb;
            char add; cin >> add;
            if(rev==true){
                if(fb==1) dq.push_back(add);
                else dq.push_front(add);
            }else{
                if(fb==1) dq.push_front(add);
                else dq.push_back(add);
            }
        }
    }
    if(rev) for(int i=dq.size()-1; i>=0; i--) cout<<dq[i];
    else rep(i,dq.size()) cout<<dq[i];
    cout<<endl;
}

Measured memory_bytes: 896
#include <stdio.h>

int main(void)
{
	int w[10000],h[10000];
	int i,j;
	int n;
	int howmany;
	
	for(n=0;n<10000;n++)
	{
		scanf("%d %d",&h[n],&w[n]);
		
		if(h[n] == 0 && w[n] == 0)
		{
			howmany = n;
			
			goto next;
		}
	}
	
	next:
	
	for(n=0;n<howmany;n++)
	{
		for(i=0;i<h[n];i++)
		{
			for(j=0;j<w[n];j++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int k;
    cin >> k;
    ll ans = 0;
    rep1(i, k) rep1(j, k) rep1(h, k) {
        ans += gcd(gcd(i, j), h);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>

using namespace std;

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

#define INF (1<<29)
#define INFL (1ll<<60)
#define EPS (1e-8)
#define PI (acos(-1))
#define MOD 1000000007ll

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

typedef long long ll;
typedef complex<double> P;
typedef complex<double> Vec;
typedef pair<int, int> pii;
typedef pair<int, pii> p;

int main() {
	string s;
	cin >> s;
	int st = INF, ed = 0;
	REP(i, s.size()) {
		if (s[i] == 'A') chmin(st, i);
		if (st != INF && s[i] == 'Z') chmax(ed, i);
	}
	cout << ed - st + 1 << endl;
	return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")

#pragma GCC optimize("O3")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define f first

ll n;

double s;

int main()
{
    cin >> n;

    vector < double > a(n);

    for (auto &i:a) cin >> i;

    sort(a.begin(), a.end());

    while (a.size()>1)
    {
        a[1]=(a[0]+a[1])/2;

        a.erase(a.begin());
    }

    printf("%.7f", a[0]);
}


Measured memory_bytes: 384
#pragma target("avx")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define rep(i,b,e) for(ll i=b; i<e; i++)
#define be(vec) vec.begin(),vec.end()
#define print(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define scan(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n;
	scanf("%d", &n);
	V a(n); scan(a);
	ll prev = -1, ans = -1;
	bool ok = true;
	for(ll x: a){
		if(x>prev+1) ok = false;
		else{
			if(x>prev) ans++;
			else ans += x;
		}
		prev = x;
	}
	if(ok) printf("%ld\n", ans);
	else puts("-1");
	return 0;
}


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

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

    int l, r, cnt = 0;
    for (int i = 0; i < N; ++i) {
        std::cin >> l >> r;
        cnt += (r - l + 1);
    }

    std::cout << cnt << std::endl;

    return 0;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var sp = input.split(" ").map(Number);
var W = sp[0]; H = sp[1]; x = sp[2]; y = sp[3]; r = sp[4];
if( r <= x && x <= ( W - r ) && r <= y && y <= ( H - r ) ) {
  console.log("Yes");
} else {
  console.log("No");
}

Measured memory_bytes: 15112
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


MIN = 0
MAX = 20
SIZE = 21

N = int(input())
dp = [[0]*SIZE for _ in range(N-1)]

table = list(map(int,input().split()))

dp[0][table[0]] = 1

for i in range(1,N-1):
    for k in range(MIN,MAX+1):
        if dp[i-1][k] == 0:
            continue
        if k+table[i] <= MAX:
            dp[i][k+table[i]] += dp[i-1][k]
        if k-table[i] >= MIN:
            dp[i][k-table[i]] += dp[i-1][k]

print("%d"%(dp[N-2][table[N-1]]))


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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> city(N);
  vector<int> road(M * 2);
  
  for (int i = 0; i < M * 2; i += 2) { 
    cin >> road.at(i) >> road.at(i + 1);
  } 

  for (int i = 0; i < M * 2; i++) {
    for (int j = 0; j < N; j++) {
      if (road.at(i) == j + 1) { 
        city.at(j) += 1;
      }
    }
  }
  
  for (int i = 0; i < N; i++) {
    cout << city.at(i) << endl;
  }
}

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

#define MAXN (int)(2*1e5 + 1)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
#define M_PI 3.1415
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dddx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dddy[] = {0, 0, 1, -1, 1, -1, 1, -1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  string s;
  cin >> s;
  for(int i=0;i<sz(s)-1;i++){
    if(s[i] == s[i+1]){
      cout << "Bad" << endl;
      return 0;
    }
  }

  cout << "Good" << endl;

  return 0;
}

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

int main(){

  int A,B;
  cin >> A >> B;

  int check1[2],check2[2];
  int count = 0;  
  
  for(int i = A; i <= B; ++i){
    
    check1[0] = i / 10000;
    check1[1] = (i - check1[0]*10000) / 1000;
    
    check2[0] = i % 10;
    check2[1] = (i % 100) / 10;
    
  
    if(check1[0] == check2[0] && check1[1] == check2[1]){
    
      count += 1;
    
    }
  
  }
  
  cout << count << endl;
  
  return 0;
  
}

Measured memory_bytes: 256
// eddy1021
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long ll;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<LD,LD> Pt;
typedef tuple<int,int,int> tiii;
typedef tuple<LL,LL,LL> tlll;
#define mod9 1000000009ll
#define mod7 1000000007ll
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define FI first
#define SE second
#define X FI
#define Y SE
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
int __ = 1 , _cs;
/*********default*********/
#define N 111111
void build(){

}
char c[ N ];
void init(){
  scanf( "%s" , c );
}
void solve(){
  bool cc = false , ff = false;
  for( int i = 0 ; c[ i ] ; i ++ ){
    if( !cc && c[ i ] == 'C' ){
      cc = true;
    }
    if( cc && !ff && c[ i ] == 'F' ){
      ff = true;
      break;
    }
  }
  puts( cc && ff ? "Yes" : "No" );
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dg(x) cerr << #x << " = " << x <<endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define fore(i,a,b) for(int i=(int)a;i<=(int)b;++i)
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int main(){
#ifdef LOCAL
    //freopen("h.txt", "r", stdin);
    // freopen("main.out", "w", stdout);
#else
    ios::sync_with_stdio(0), cin.tie(0);
    #define endl '\n'
#endif
    int n,m;
    cin>>n>>m;
    priority_queue<ll> pila;
    ll sum=0;
    forn(i,n){
        int v;
        cin>>v;
        pila.push(v);
    }
    while(m>0){
        ll v=(ll)(pila.top())/2;
        pila.pop();
        pila.push(v);
        m--;
    }
    while(!pila.empty()){
        sum+=(ll)pila.top();
        pila.pop();
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1400
#include <cstdio>
#include <cstring>
using namespace std;
static const int M = 244140625;

int T[M];

int getChar(char ch) {
    if (ch == 'A') return 1;
    else if (ch == 'C') return 2;
    else if (ch == 'G') return 3;
    else if (ch == 'T') return 4;
    else return 0;
}

int getKey(char str[]) {
    int sum = 0, p = 1;
    for (int i = 0; i < strlen(str); i++) {
        sum += p * getChar(str[i]);
        p *= 5;
    }
    return sum;
}

int main() {
    // for (int i = 0; i < M; i++) T[i] = 0;

    int n;
    scanf("%d", &n);
    char cmd[6], str[12];
    int key;
    for (int i = 0; i < n; i++) {
        scanf("%s %s", cmd, str);
        key = getKey(str);
        if (cmd[0] == 'i') {
            T[key] = 1;
        } else if (cmd[0] == 'f') {
            if (T[key]) {
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }

    return 0;
}


Measured memory_bytes: 19644
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
#define M 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int N, Ma, Mb; cin >> N >> Ma >> Mb;
	vector<pair<pair<int, int>, int>> med(N);
	vector<vector<vector<ll>>> dp(N + 1, vector < vector<ll>>(401, vector<ll>(401, 1e15)));
	for (int i = 0; i < N; i++) {
		cin >> med[i].first.first >> med[i].first.second >> med[i].second;
		dp[i + 1][med[i].first.first][med[i].first.second] = med[i].second;
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= 400; j++) {
			for (int k = 0; k <= 400; k++) {
				dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
				if (j + med[i].first.first <= 400 && k + med[i].first.second <= 400)
					dp[i + 1][j + med[i].first.first][k + med[i].first.second] = 
					min(dp[i + 1][j + med[i].first.first][k + med[i].first.second], dp[i][j][k] + med[i].second);
				//cout << "i=" << i << "j=" << j << "k=" << k << endl;
			}
		}
	}

	ll ans = 1e15;
	for (int j = 1; j <= 400; j++) {
		for (int k = 1; k <= 400; k++) {
			if (j * Mb == k * Ma) {
				
				ans = min(ans, dp[N][j][k]);
				//cout << "j=" << j << " k=" << k << " ans=" << ans << endl;
			}
		}
	}

	if (ans == 1e15)cout << -1 << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 56588
#include <stdio.h>

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

  int A[n];
  for(int i=0;i<n;i++) scanf("%d",&A[i]);

  for(int i=n-1;i>-1;i--){
    if(i!=n-1) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  return 0;
}


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

int main(){
	string a, b;
	cin >> a >> b;
	a = a + b;
	int c = stoi(a);
	//cが平方数の判定
	if (c == int(sqrt(c)) * int(sqrt(c))) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (X, A, B) = nextIntList()
    println(
            if (A >= B) "delicious" else if (B - A <= X) "safe" else "dangerous"
    )
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);
    
    string s; cin >> s;
    if (find(s.begin(), s.end(), '7') != s.end()) cout << "Yes" << endl; else cout << "No" << endl;

}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <bitset>
#include <math.h>

typedef long long ll;
typedef unsigned long long ull;

#define vi std::vector<int>
#define vl std::vector<ll>
#define floop(n) for(int i = 0; i < n; ++i)
#define print(x) std::cout << x << std::endl;

const ll INF = 1e18;

int main()
{
    int N, K, X, Y;
    std::cin >> N;
    std::cin >> K;
    std::cin >> X;
    std::cin >> Y;

    if(N <= K)
    {
        print((X*N));
    }

    else
    {
        print((X*K + Y*(N-K)));
    }

    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

int main(void) {
    string str;
    cin>>str;

    Int sum = 0;
    Int anum = 0;
    for(int i = 0;i < str.size()-1;) {
        if(str[i] == 'B' && str[i+1] == 'C') {
            i+=2;
            sum += anum;
        } else if(str[i] == 'A') {
            anum++;
            i++;
        } else {
            anum = 0;
            i++;
        }
    }

    cout<<sum<<endl;

    return 0;
}




Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
long long n, k;

double dp(ll value, double prob){
    if(value>=k){
        return prob;
    }
    else
        return dp(value*2LL, prob*0.5);
}
int main(){
    cin >> n >> k;
    double ans = 0;
    for(ll i=1; i<=n; ++i){
        ans += dp(i, 1.0)/double(n);
    }
    cout << fixed << setprecision(20) << ans << endl;
}  


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

int main(void) {
  int N, A;
  cin >> N >> A;
  vector<int> X(N);
  rep(i, N) { cin >> X[i]; }

  vector<vector<vector<int64_t>>> DP(
      N + 1, vector<vector<int64_t>>(N + 1, vector<int64_t>(2501, 0)));
  DP[0][0][0] = 1;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      for (int k = 0; k <= 2500; ++k) {
        DP[i + 1][j][k] += DP[i][j][k];
        if ((k + X[i]) <= 2500) DP[i + 1][j + 1][k + X[i]] += DP[i][j][k];
      }
    }
  }
  int64_t answer = 0;
  for (int i = 1; i <= N; ++i) {
    answer += (int64_t)DP[N][i][i * A];
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 52224
#include <iostream>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

map<int64_t, int> prime_factor(int64_t n) {
    map<int64_t, int> ret;
    for (int64_t i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1) ret[n] = 1;
    return ret;
}

int main() {
    ll a, b;
    cin >> a >> b;
    ll x = gcd(a, b);
    cout << prime_factor(x).size() + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll A, B;
char op;

int main() {
	scanf("%lld", &A);
	cin >> op;
	scanf("%lld", &B);
	if(op == '+') {
		printf("%lld\n", A + B);
	}
	else {
		printf("%lld\n", A - B);
	}

	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
n = int(input())
x = [list(map(int, input().split())) for i in range(n)]

dp = [[-float("inf")] * 3 for i in range(n + 1)]

for i in range(3):
    dp[0][i] = 0

for i in range(n):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + x[i][k])

print(max(dp[n]))


Measured memory_bytes: 47324
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define forn(i, n) for (ll i = 0; i < (n); i++)
#define fori(i, b, e) for (ll i = (b); i < (e); i++)
#define forr(i, b, e) for (ll i = (b); i >= (e); i--)
#define allele(v) v.begin(), v.end()
#define fi first
#define se second
#define Mat vector<vector<ll>>
#define Arr vector<ll>
#define Matd vector<vector<ld>>
#define Arrd vector<ld>

ll n, k;
Arr a;
ll s;
bool check(ll d)
{
    if(s % d) return false;
    Arr r(n);
    ll sum = 0;
    forn(i, n) r[i] = a[i] % d, sum += r[i];
    if(sum % d != 0) return false;
    sort(allele(r), greater<ll>());
    ll _sum = sum;
    forn(i, _sum / d) sum -= r[i];
    return sum <= k;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    a = Arr(n);
    forn(i, n) cin >> a[i];
    s = 0;
    forn(i, n) s += a[i];
    ll ans = 0;
    for(ll i = 1; i * i <= s; i++)
    {
        if(s % i == 0)
        {
            if(check(i)) ans = max(ans, i);
            if(check(s / i)) ans = max(ans, s / i);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 *    author:  FromDihPout
 *    created: 2020-09-01
**/

#include <bits/stdc++.h>
using namespace std;

const int INF = 1e9;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s, t;
    cin >> s >> t;
    int n = s.length(), m = t.length();
    int ans = INF;
    for (int i = 0; i + m <= n; i++) {
        int cnt = 0;
        for (int j = 0; j < m; j++) {
            if (s[i + j] != t[j]) {
                cnt++;
            }
        }
        ans = min(ans, cnt);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3636
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

typedef long long ll;
typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

/* global variables */

ll as[MAX_N + 1], sums[MAX_N + 1];
int is[MAX_N + 1];

/* subroutines */

/* main */

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

  as[0] = sums[0] = 0;
  is[0] = 0;
  int k = 1;
  ll sum = 0;

  for (int i = 1; i <= n; i++) {
    ll ai;
    scanf("%lld", &ai);

    int j = lower_bound(as, as + k, ai) - as;
    as[j] = ai;
    is[j] = i;
    sums[j] = sums[j - 1] + ai * (i - is[j - 1]);
    sum += sums[j];
    //printf("j=%d, ai=%lld, sums=%lld\n", j, ai, sums[j]);
    k = j + 1;
  }

  printf("%lld\n", sum);
  return 0;
}


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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

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

ll A, B, C;

int main() {
    cin >> A >> B >> C;
    ll ans = 0;
    if(B >= C) {
        cout << B + C << "\n";
    } else {
        ans += 2 * B + 1;
        C -= B + 1;
        cout << ans + min(A, C) << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 500005;
const ll MOD = 1000000007;

double a, b, x;
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> a >> b >> x;
    double c;
    if (x/a <= a*b/2) {
        c = x/a*2/b;
        debug(atan(c/b));
        cout << fixed << setprecision(10) << 90-atan(c/b)/acos(-1)*180 << endl;
    } else {
        c = 2*(b-x/a/a);
        cout << fixed << setprecision(10) << 90-atan(a/c)/acos(-1)*180 << endl;
    }
    debug(a, b, c);

}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

while True:
   a, b = map(int, input().split())
   if a + b == 0:
      break
   
   c = 0
   if a < b:
      a, b = b, a
   while b != 0:
      c += 1
      r = a % b
      a = b
      b = r
   print(a, c)
   



Measured memory_bytes: 5608