akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n,m;cin >> n >> m;
  vector<int> a(m),b(m);
  vector<int> C(m);
  rep(i,m){
    cin >> a[i] >> b[i];
    int S=0;
    rep(j,b[i]){
      int c;cin >> c;c--;
      S |= (1<<c);
    }
    C[i] = S;
  }

  int inf = 1e+9;
  vector<vector<int>> dp(m+1,vector<int>((1<<n),inf));
  dp[0][0] = 0;
  rep(i,m){
    rep(S,(1<<n)){
      dp[i+1][S|C[i]] = min(dp[i+1][S|C[i]],dp[i][S]+a[i]); 
      dp[i+1][S] = min(dp[i+1][S],dp[i][S]);     
    }
  }
  if(dp[m][(1<<n)-1]==inf) cout << -1 << "\n";
  else cout << dp[m][(1<<n)-1] << "\n";
  return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}


const int MAX_D = 16005;
bool dp[2][MAX_D];
const int ZERO = 8000;
bool possible(vector<int> xs, int x) {
  CLR(dp, 0);
  const int M = xs.size();

  dp[0][ZERO] = true;
  for (int i = 0; i < (int)xs.size(); i++) {
    int f = i & 1;
    REP(d, MAX_D) dp[1-f][d] = false;
    REP(d, MAX_D) if (dp[f][d]) {
      if (0 <= d + xs[i] && d + xs[i] < MAX_D) dp[1-f][d+xs[i]] = true;
      if (0 <= d - xs[i] && d - xs[i] < MAX_D) dp[1-f][d-xs[i]] = true;
    }
  }
  if (0 <= ZERO + x && ZERO + x < MAX_D)
    return dp[M & 1][ZERO + x];
  else
    return false;
}

int main2() {
  string s; cin >> s;
  int x, y; cin >> x >> y;
  while (s.size() > 0 && s[0] == 'F') {
    s = s.substr(1);
    x--;
  }
  vector<int> xs, ys;
  int side = 0;
  int len = 0;
  for (int i = 0; i < (int)s.size(); i++) {
    if (s[i] == 'T') {
      if (len > 0) {
        if (side == 0) xs.push_back(len);
        else ys.push_back(len);
      }
      side = 1 - side;
      len = 0;
    } else {
      len++;
    }
  }
  if (len > 0) {
    if (side == 0) xs.push_back(len);
    else ys.push_back(len);
    len = 0;
  }

  // cout << s << endl;
  // pv(ALL(xs));
  // pv(ALL(ys));

  bool ans = possible(xs, x) && possible(ys, y);
  cout << (ans ? "Yes" : "No")<< endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 384
#include<stdio.h>



void getData(int *n,int *r){
	fscanf(stdin,"%d%d",n,r);
}

int selectRate(int n, int r){
	if(n >= 10){
		return r;
	}
	else{
		return r + 100*(10-n);
	}
}

void solv(){
	int n,r;
	int Rate;
	getData(&n,&r);
	Rate = selectRate(n,r);
	printf("%d\n",Rate);
}	


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


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
// typedef pair<int, int> p;

int n, m;
vector<int> k;
vector<vector<int>> s;
vector<int> p;
int res = 0;


void dfs(int a, vector<bool> tmp){
  // print(tmp);
  if(a == n){
    int count1 = 0;
    for (int x1 = 0; x1 < int(s.size()); x1++) {
      int count2 = 0;
      for(auto x2 : s[x1]){
        if(tmp[x2]){
          count2++;
        }
      }
      // cout << count2 << endl;
      if(count2 % 2 == p[x1]) count1++;
    }
    if(count1 == m) res++;
    // cout << "====" << endl;
    return;
  }else{
    tmp[a] = true;
    dfs(a+1, tmp);
    tmp[a] = false;
    dfs(a+1, tmp);
  }
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  k = vector<int> (m);
  s = vector<vector<int>> (m);

  for (int i = 0; i < m; i++) {
    cin >> k[i];
    s[i] = vector<int> (k[i]);
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
      s[i][j]--;
    }
  }

  p = vector<int> (m);
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  vector<bool> tmp(n, false);
  dfs(0, tmp);
  cout << res << endl;

}


Measured memory_bytes: 256
#coding utf-8

def main():
    question_b()

def question_b():
    n = int(input())
    syorui = list(map(int,input().split()))
    flg = False
    oddflg = False
    box = []
    for i in range(n):
        if syorui[i]%2 == 0:
            oddflg = True
            if syorui[i]%3 == 0 or syorui[i]%5 == 0:
                flg = True
            else:
                flg = False
                break
    if flg == True or oddflg == False:
        print("APPROVED")
    else:
        print("DENIED")

main()

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

int N, K;
vector<int> RL[2];
int ans=1e9;

int main() {
  cin >> N >> K;
  int x;
  rep(i, N) {
    scanf("%d", &x);
    RL[(int)(x >= 0)].push_back(abs(x));
  }
  sort(RL[0].begin(), RL[0].end());
  sort(RL[1].begin(), RL[1].end());
  for(int i=min(K-1, (int)RL[0].size())-1; i>=max(0, (int)(K-RL[1].size()-1)); i--) {
    ans = min(ans, RL[0][i] * 2 + RL[1][K-i-2]);
    ans = min(ans, RL[0][i] + RL[1][K-i-2] * 2);
  }
  if(RL[0].size() >= K) {
    ans = min(ans, RL[0][K-1]);
  }
  if(RL[1].size() >= K) {
    ans = min(ans, RL[1][K-1]);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1020
#include <stdio.h>
#include <string.h>

int main(){
  char s[11], t[11];
  scanf(" %s\n %s", s, t);
  int x=strlen(s);
  t[x]='\0';
  if(strcmp(s,t)==0)printf("Yes\n");
  else printf("No\n");
}

Measured memory_bytes: 1664
/*
 * AB_Problem.cpp
 *
 *  Created on: 2014/07/21
 *      Author: WanWan1985
 */
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void) {

	int a, b = 0;
	cin >> a >> b;

	int iResult1 = a / b;
	int iResult2 = a % b;
	double dResult3 = (double)a / (double)b;

	printf("%d %d %.8lf\n", iResult1, iResult2, dResult3);

	return 0;
}

Measured memory_bytes: 1196
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N; 
        public long K;
        public long[] A;
        public long MOD = 1000000007;

        public void Run()
        {
            {
                var line = Input.ReadLongArray();
                N = (int)line[0];
                K = line[1];
            }
            A = Input.ReadLongArray();

            long x = 0;
            for (int d = 50; d >= 0; d--)
            {
                long a = (1L << d);
                if (x + a > K) continue;
                int zero = 0;
                int one = 0;
                for (int i = 0; i < N; i++)
                {
                    long b = (A[i] >> d) & 1;
                    if (b == 1) one++;
                    else zero++;
                }
                if (zero > one)
                {
                    x += a;
                }
            }

            long ret = 0;
            for (int i = 0; i < N; i++)
            {
                ret += x ^ A[i];
            }
            Console.WriteLine(ret);
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 31196
/*
ID: tohoast1
TASK: gymnastics
LANG: C++
*/
#include <bits/stdc++.h>
#define speedup ios_base::sync_with_stdio(NULL)
#define fin freopen("allcodefs.in", "r", stdin)
#define fout freopen("allcodefs.out", "w", stdout)
#define FILENAME
#define PUBG push_back
#define p_b pop_back
#define mp make_pair
#define fi first
#define se second
#define cls clear
#define INF const int ci = 1e6 + 100
#define K_INF 1e9 + 7
#define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define MIN_INT -999999999
#define MOD 1000000007
#define d109 1000000000
#define basay break
#define bmbr exit(0)

using namespace std;
typedef long long LL;
typedef long L;
typedef unsigned long long ULL;
typedef unsigned long UL;
typedef string STR;
int N, cnt, s;

int main() {
    #ifdef FILENAMEs
        fin;
        fout;
    #endif // FILENAME
    cin >> N >> s;
    while (N > 0) {
        cnt ++;
        N -= s;
    }
    cout << cnt;
    ///time;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
char a, b;
int main(){
	scanf("%c %c", &a, &b);
	if((a == 'H' && b == 'H') || (a == 'D' && b == 'D'))
		printf("H\n");
	else printf("D\n");
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

int main(){	
	
	string s;
	cin >> s;
	reverse(s.begin(),s.end());
	for(int i=0;i<s.size();i++){
		string t=s.substr(i,5);
		if(t=="maerd" || t=="esare"){
			i+=4;
			continue;
		}
		
		t=s.substr(i,6);
		if(t=="resare"){
			i+=5;
			continue;
		}
		
		t=s.substr(i,7);
		if(t=="remaerd"){
			i+=6;
			continue;
		}
		
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;
	return 0;
}


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

# x[0] = sum(a) - 2*(a[1]+a[3]+...)
b = 0
for i in range(1, n-1, 2):
    b += a[i]
x = [sum(a) - 2*b]

for i in range(0, n-1):
    x.append(2*a[i]-x[i])
print(' '.join(map(str, x)))


Measured memory_bytes: 19148
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

(deftype int32 () '(signed-byte 32))
(deftype int64 () '(signed-byte 64))


;;macros
(defmacro println (n)
  `(format t "~a~%" ,n))
(defmacro vint-out (vec)
  `(progn
     (rep i (length ,vec)
          (princ (vref ,vec i))
          (princ " "))
     (fresh-line)))
(defmacro aif (test-form then-form &optional else-form)
  `(let ((it ,test-form))
     (if it ,then-form ,else-form)))

;;vector
(defmacro vec (type &optional (num 100) (val 0))
  (let* ((g (gensym)))
    `(let* ((,g ,num))
       (make-array ,g :element-type ',type :initial-element ,val
                   :adjustable nil :fill-pointer ,g))))

(defmacro double-vec (type &optional (dim1 100) (dim2 100) (val 0))
  `(make-array '(,dim1 ,dim2) :element-type ',type :initial-element ,val))

(defmacro vint (&optional (num 0) (val 0))
  `(vec int32 ,num ,val))

(defmacro double-vec (type &optional (dim1 100) (dim2 100) (val 0))
  `(make-array '(,dim1 ,dim2) :element-type ',type :initial-element ,val))

(defmacro vref (vector pos &optional value)
  (let ((g (gensym)))
    `(let ((,g ,value))
       (if ,g
           (setf (aref ,vector ,pos) ,g)
           (aref ,vector ,pos)))))

(defmacro chvar (sym comp predicate)
  (let ((g (gensym)))
    `(let ((,g ,comp))
       (if (or (null ,sym) (not (funcall ,predicate ,sym ,g)))
           (setf ,sym ,g)))))

(defmacro chmax (sym comp &optional (predicate #'>))
  `(chvar ,sym ,comp ,predicate))

(defmacro chmin (sym comp &optional (predicate #'<))
  `(chvar ,sym ,comp ,predicate))

(defmacro defchangef (name op default-val)
  `(defmacro ,name (var &optional (val ,default-val))
     `(setq ,var (,',op ,val ,var))))
(defmacro read-str ()
  `(write-to-string (read)))

;;本体
(defvar n (read))
(defun gifts (lst)
  (if (eq (cdr lst) 'BTC)
      (* (car lst) 380000.0)
      (car lst)))
(defun main ()
  (println
   (loop for i below n
      sum (gifts (cons (read) (read))))))
  
#-swank(main)


Measured memory_bytes: 19940
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#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 ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
 
    // 集合をマージする
    // すでに同じ集合ならfalseが返る
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (data[y] < data[x]) swap(x, y);  // マージテク
        data[x] += data[y];
        data[y] = x;
        return true;
    }
 
    // ある要素がどの集合に属しているかを答える
    ll root(int x) {
        // 根に直接つなぎ直す
        return data[x]<0 ? x : (data[x]=root(data[x]));
    }
 
    // ある集合の大きさを答える
    ll size(int x) {
        return -data[root(x)];
    }
};

int main(){
    ll n,m;
    cin >> n >> m;
    UnionFind uf(n);
    REP(i,m){
        ll a,b;
        cin >> a >> b;
        a--;
        b--;
        uf.merge(a,b);
    }
    ll answer=0;
    REP(i,n){
        answer=max(answer,uf.size(i));
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
 
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
 
/* vector<int> A(N); 
    vector<pair<int, int> > tasks; ＃ソートした場合、１つ目でソート
　tie(b, a) = p.at(i); #pairを分割
    tasks.emplace_back(b, a)  ＃配列tasksの最後に(b,a)を追加
　xの二乗:  pow(x, 2.0) 
    小さい順: sort(v.begin(), v.end());
    大きい順: reverse(v.begin(), v.end());
    int: -2,147,483,648 ～ 2,147,483,647
    ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807
    // int型の2次元配列(3×4要素の)の宣言
    vector<vector<int>> data(3, vector<int>(4));
*/
 
int main() {
  
  int N, B, C, count=0, ans=0;
  string D, E;
  cin >> N;
  vector<int> G(32);
  G={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}; 
  
  cout << G.at(N-1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>


int main(void){
  long long int N;
  std::cin >> N ;
  long double N_root = sqrt(N);
  long long int prod=1;
  long long int i=1;
  long long int min=1e12;
  while(i<=N_root){
    if(N%i==0){
      if(min>(i + N/i - 2)){
        min = i + N/i - 2;
      }
    }
    i++;
  }
  std::cout << min;
  return 0;
}


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

using namespace std;

template< typename Data, typename T >
struct ReRooting {

  struct Node {
    int to, rev;
    Data data;
  };

  using F1 = function< T(T, T) >;
  using F2 = function< T(T, int, int, Data) >; // ret, src, to, data


  vector< vector< Node > > g;
  vector< vector< T > > ldp, rdp;
  vector< int > lptr, rptr;
  const F1 f1;
  const F2 f2;
  const T ident;

  ReRooting(int n, const F1 &f1, const F2 &f2, const T &ident) :
      g(n), ldp(n), rdp(n), lptr(n), rptr(n), f1(f1), f2(f2), ident(ident) {}

  void add_edge(int u, int v, const Data &d) {
    g[u].emplace_back((Node) {v, (int) g[v].size(), d});
    g[v].emplace_back((Node) {u, (int) g[u].size() - 1, d});
  }

  T dfs(int idx, int par) {

    while(lptr[idx] != par && lptr[idx] < g[idx].size()) {
      auto &e = g[idx][lptr[idx]];
      ldp[idx][lptr[idx] + 1] = f1(ldp[idx][lptr[idx]], f2(dfs(e.to, e.rev), idx, e.to, e.data));
      ++lptr[idx];
    }
    while(rptr[idx] != par && rptr[idx] >= 0) {
      auto &e = g[idx][rptr[idx]];
      rdp[idx][rptr[idx]] = f1(rdp[idx][rptr[idx] + 1], f2(dfs(e.to, e.rev), idx, e.to, e.data));
      --rptr[idx];
    }
    if(par < 0) return rdp[idx][0];
    return f1(ldp[idx][par], rdp[idx][par + 1]);
  }

  vector< T > solve() {
    for(int i = 0; i < g.size(); i++) {
      ldp[i].assign(g[i].size() + 1, ident);
      rdp[i].assign(g[i].size() + 1, ident);
      lptr[i] = 0;
      rptr[i] = (int) g[i].size() - 1;
    }
    vector< T > ret;
    for(int i = 0; i < g.size(); i++) {
      ret.push_back(dfs(i, -1));
    }
    return ret;
  }
};


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

  auto f1 = [](int a, int b) {
    return max(a, b);
  };

  auto f2 = [](int a, int src, int to, int data) {
    return a + data;
  };

  ReRooting< int, int > g(N, f1, f2, 0);
  for(int i = 1; i < N; i++) {
    int s, t;
    cin >> s >> t;
    --s, --t;
    g.add_edge(s, t, 1);
  }
  for(auto &p : g.solve()) {
    cout << (N - 1) * 2 - p << endl;
  }
}


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

using namespace std;

bool is_digit(char d) { return '0' <= d && d <= '9'; }

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

  int a, b;
  string s;
  cin >> a >> b >> s;
  int i;
  if (s.size() < a + 1) {
    cout << "No\n";
    return 0;
  }
  for (i = 0; i < a; ++i) {
    if (!is_digit(s[i])) {
      cout << "No\n";
      return 0;
    }
  }
  if (s[i++] != '-') {
    cout << "No\n";
    return 0;
  }
  for (; i < a + b + 1; ++i) {
    if (!is_digit(s[i])) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <set>
#include <algorithm>
using namespace std;
set<string> S;

void count_str(string str1, string str2){
    string rstr1 = str1;
    string rstr2 = str2;
    reverse(rstr1.begin(), rstr1.end());
    reverse(rstr2.begin(), rstr2.end());
    
    S.insert(str1+str2);
    S.insert(str1+rstr2);
    S.insert(rstr1+str2);
    S.insert(rstr1+rstr2);
    S.insert(str2+str1);
    S.insert(str2+rstr1);
    S.insert(rstr2+str1);
    S.insert(rstr2+rstr1);
}

int main()
{
    int m;
    string str, str1, str2;
    cin >> m;
    for (int k = 0; k < m; k++) {
        cin >> str;
        S.clear();
        for (int i = 1; i < str.size(); i++) {
            str1 = "";
            str2 = "";
            for (int j = 0; j < i; j++) {
                str1 += str[j];
            }
            for (int j = i; j < str.size(); j++) {
                str2 += str[j];
            }
            count_str(str1, str2);
        }
        cout << (unsigned int)S.size() << endl;
    }
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  if(n < 10)
    cout << n << endl;
  else if(n < 100)
    cout << 9 << endl;
  else if(n < 1000)
    cout << 9+(n-99) << endl;
  else if(n < 10000)
    cout << 9+900 << endl;
  else if(n < 100000)
    cout << 9+900+n-9999;
  else
    cout << 90909 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
const int N=1e5+9;
ll vis[N],a[N];
int main()
{
    int t,n,x;
    scanf("%d%d",&t,&n);
    memset(a,0,sizeof(a));
    memset(vis,0,sizeof(vis));
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        vis[x]=1;
    }
    a[0]=1;
    if(!vis[1]) a[1]=1;
    for(int i=2;i<=t;i++)
    {
        if(vis[i]) continue;
        a[i]=(a[i-1]+a[i-2])%mod;
//        printf("%lld  a[i],  %d  i\n",a[i],i);
    }
    printf("%lld\n",a[t]);
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,ra,re) for((i)=ra;(i)<(re);(i)++)
#define rep_(i,ra,re) for((i)=ra;(i)<=(re);(i)++)
#define put(n) cout << n << " "; 
#define puts(n) cout << n << endl;
#define pu(n) cout << n;
int i,j,k,l;
static const int MAX_N=10e5;
vector<pair<long,long> > V;
long task,timer;
bool c=true;
int main(void){
	int n;
		cin >> n;
	rep(i,0,n){
		long a,b;
			cin >> a >> b;
		V.push_back(make_pair(b*(-1),a));
		task+=a;
	}
	sort(V.begin(),V.end());
	timer=V[0].first*(-1);
	rep(i,0,n){
		long a=V[i].second,b=V[i].first*(-1);
		if(timer>b)
			timer=b;
		timer-=a;
		if(timer<0){c=false;break;}
	}
	puts((c?"Yes":"No"));
	return 0;
}

Measured memory_bytes: 6128
from collections import Counter

N, M, K = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]
CD = [list(map(int, input().split())) for _ in range(K)]

friend_g = [set() for i in range(N)]
for a, b in AB:
    a, b = a-1, b-1
    friend_g[a].add(b)
    friend_g[b].add(a)
friend_count = [len(s) for s in friend_g]

g_nums = [-1]*N
current_g_num = 0
for i in range(N):
    if g_nums[i] == -1:
        g_nums[i] = current_g_num
        q = [i]
        while q:
            t = q.pop()
            for friend in friend_g[t]:
                if g_nums[friend] == -1:
                    g_nums[friend] = current_g_num
                    q.append(friend)
                # print(i, t, g_nums)
        current_g_num += 1

block_count = [0]*N
for c, d in CD:
    c, d = c-1, d-1
    if g_nums[c] == g_nums[d]:
        block_count[c] += 1
        block_count[d] += 1

g_nums_counter = Counter(g_nums)
print(*(g_nums_counter[g_nums[i]] - friend_count[i] - block_count[i] - 1 for i in range(N)))


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

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

    int n;
    cin >> n;
    vector<ll> p(n + 1), q(n + 1);
    rep(i, 0, n) {
        cin >> p[i];
        q[p[i]] = i;
    }
    /*
    vector<ll> lx(n), rx(n), lx2(n), rx2(n);
    // l
    stack<pair<int, int>> stk;
    stk.push(make_pair(n + 1, -1));
    stk.push(make_pair(n + 1, -1));
    rep(i, 0, n) {
        pair<int, int> pin = make_pair(p[i], i);
        while (stk.top() < pin)
            stk.pop();
        lx[i] = stk.top().second;
        pair<int, int> pin2 = stk.top();
        stk.pop();
        lx2[i] = stk.top().second;
        stk.push(pin2);
        stk.push(pin);
    }
    while (!stk.empty())
        stk.pop();
    // r
    stk.push(make_pair(n + 1, n));
    stk.push(make_pair(n + 1, n));
    for (int i = n - 1; i >= 0; i--) {
        pair<int, int> pin = make_pair(p[i], i);
        while (stk.top() < pin)
            stk.pop();
        rx[i] = stk.top().second;
        pair<int, int> pin2 = stk.top();
        stk.pop();
        rx2[i] = stk.top().second;
        stk.push(pin2);
        stk.push(pin);
    }

    ll ans = 0;
    rep(i, 1, n) {
        int j = q[i];
        if (lx[j] != -1) {
            ans += (ll)(lx[j] - lx2[j]) * (ll)(rx[j] - j) * (ll)i;
        }
        if (rx[j] != n) {
            ans += (ll)(rx2[j] - rx[j]) * (ll)(j - lx[j]) * (ll)i;
        }
        cout << ans << endl;
    }
    cout << ans << endl;
    */

    /* set<int> used;
     used.insert(-1);
     used.insert(-2);
     used.insert(n);
     used.insert(n + 1);
     used.insert(q[n]);

     ll ans = 0;

     for (int i = n - 1; i > 0; i--) {
         auto x = upper_bound(used.begin(), used.end(), q[i]);
         auto y = x;
         int u = *y;
         y++;
         int uu = *y;
         x--;
         int d = *x;
         x--;
         int dd = *x;
         used.insert(q[i]);

         if (d != -1) {
             ans += (d - dd) * (u - q[i]) * (ll)i;
         }
         if (u != n) {
             ans += (uu - u) * (q[i] - d) * (ll)i;
         }
     }
     cout << ans << endl;
     */
    vector<int> used;
    used.push_back(-2);
    used.push_back(-1);
    used.push_back(q[n]);
    used.push_back(n);
    used.push_back(n + 1);

    ll ans = 0;

    for (int i = n - 1; i > 0; i--) {
        auto x = upper_bound(used.begin(), used.end(), q[i]);
        auto y = x;
        int u = *y;
        y++;
        int uu = *y;
        x--;
        int d = *x;
        x--;
        int dd = *x;
        x++;
        x++;
        used.insert(x, q[i]);

        if (d != -1) {
            ans += (d - dd) * (u - q[i]) * (ll)i;
        }
        if (u != n) {
            ans += (uu - u) * (q[i] - d) * (ll)i;
        }
        }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2428
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

using namespace std;
int cnt4,cnt2,n;
int a;

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a);
        if(a%4==0)
            cnt4++;
            else if(a%2==0)
                cnt2++;
    }
    if(cnt2+cnt4*2<n-1)
        printf("No\n");
        else if(cnt4*2+cnt2==n-1&&cnt2!=0)
            printf("No\n");
            else
                printf("Yes\n");
    return 0;
}

Measured memory_bytes: 128
n = int(input())
a = [int(i) for i in input().split()]
b,l,r,ans = [0]*(n+1),[i for i in range(n+2)],[i for i in range(n+2)],0
for i in range(n): b[a[i]]=i
for i in range(n,0,-1):
	m = b[i]
	x,y = l[m],r[m]
	ans+=i*(m-x+1)*(y-m+1)
	l[y+1],r[x-1] = x,y
print(ans)


Measured memory_bytes: 36752
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <map>

#define MAX_N 100000
#define MAX_P 100

#define pb(s) push_back(s)
#define all(s) s.begin(), s.end()

using namespace std;

int N, P;
vector<int> prime;
vector<int> prime_sum;

bool prime_judge(int n){
	if(n == 0 || n == 1) return false;
	for(int i = 2; i*i <= n; i++){
		if(n%i == 0) return false;
	}
	return true;
}

void solve(){
	for (int i = N+1; i < N+1000; i++)
	{
		if(prime_judge(i)){
			prime.pb(i);
		}
	}
	for (int i = 0; i < prime.size(); i++)for(int j = i; j < prime.size(); j++) prime_sum.pb(prime[i]+prime[j]);
	sort(all(prime_sum));
	cout << prime_sum[P-1] << endl;
}

int main(){
	while(1){
		cin >> N >> P;
		if(N == -1) break;
		prime.clear();
		prime_sum.clear();
		solve();
	}
	return 0;
}

Measured memory_bytes: 1336
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
    string S, T, U;
    int A, B;
	cin >> S >> T >> A >> B >> U;
    if (S==U) A--;
    else      B--;
	cout << A << ' ' << B << 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)
typedef complex<double> Point;
typedef vector<Point> VP;
#define X real()
#define Y imag()
const double EPS = 1e-4;

double dot(Point a, Point b) {
  return a.X*b.X + a.Y*b.Y;
}

double cross(Point a, Point b) {
  return a.X*b.Y - a.Y*b.X;
}

int ccw(Point a, Point b, Point c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
  return 0;                          // a--c--b on line or a==c or b==c
}

// ???????????????????????????????????????ccw???????????¨?????? != 1 ??¨??????
bool isCcwConvex(const VP& ps) {
  int n = ps.size();
  rep (i, n) if (ccw(ps[i], ps[(i+1) % n], ps[(i+2) % n]) == -1) return false;
  return true;
}

int main(void){
    int n;
    cin>>n;
    VP p(n);
    rep(i,n){
        double x,y;
        cin>>x>>y;
        p[i] = {x,y};
    }
    cout<<isCcwConvex(p)<<endl;
    return 0;
}

Measured memory_bytes: 3292
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    String a = sc.next();
    if (a.equals("SAT")) {
      System.out.println(1);
    } else if (a.equals("FRI")) {
      System.out.println(2);
    } else if (a.equals("THU")) {
      System.out.println(3);
    } else if (a.equals("WED")) {
      System.out.println(4);
    } else if (a.equals("TUE")) {
      System.out.println(5);
    } else if (a.equals("MON")) {
      System.out.println(6);
    } else {
      System.out.println(7);
    }
  }
}


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

int main(void){
  int a;
  int b;
  string s="";
  cin >> a >> b;
  int min = a>b? b : a;
  int max = a>b? a : b;

  for (int i=0;i<max;i++){
    s += to_string(min);
  }

  cout << s << endl;
}

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

int main(){
  int n;
  cin>>n;
  int a=0;
  if(n/10==0){
    a=n;
  }
  else if(n>=10&&n<=99){
    a=9;
  }
  else if(n/1000==0){
    a=9+n-100+1;
  }
  else if(n>=1000&&n<=9999){
    a=909;
  }
  else if(n/100000==0){
    a=909+n-10000+1;
  }
  else{
    a=90909;
  }
  cout <<a<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){\
    int a, start, stop;
    char s[1001], command[101], replacement[1001], temp[1001];
    scanf("%s", s);
    scanf("%d", &a);
    for (int i = 0; i < a; i++)
    {
        scanf("%s", command);
        if(strcmp(command, "print") == 0){
            scanf("%d %d", &start, &stop);
            while(start <= stop){
                printf("%c", s[start]);
                start = start + 1;
            }
            printf("\n");
        }
        else if(strcmp(command, "reverse") == 0){
            scanf("%d %d", &start, &stop);
            strcpy(temp, s);
            for (int k = 0; k < stop - start + 1; k++)
            {
                s[start + k] = temp[stop - k];
            }
            
        }
        else if (strcmp(command, "replace") == 0){
            scanf("%d %d", &start, &stop);
            scanf("%s", replacement);
            int n = strlen(replacement);
            for (int j = 0; j < n; j++)
            {
                s[start] = replacement[j];
                start = start + 1;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2072
import java.util.*
fun main(args: Array<String>) {

    val sc = Scanner(System.`in`)
    while (sc.hasNext()) {
        val list = Array(6, { sc.nextDouble() })
        var multi = list[3] / list[0]
        val y_multi = list[4] - (list[1] * multi)
        val kai_malti = list[5] - (list[2] * multi)
        var y: Double = kai_malti / y_multi
        var x: Double = (list[2] - (list[1] * y)) / list[0]
        println("%.3f".format(x) + " " + "%.3f".format(y))
    }
}


Measured memory_bytes: 26484
#include<algorithm>
#include<functional>
#include<iostream>
using namespace std;

int main(){
  int yama[10];
  for(int i=0;i<10;i++){
    cin>>yama[i];
  }
  sort(yama,yama +10,greater<int>());
  for(int j=0;j<3;j++){
    cout<<yama[j]<<endl;
  }
}

Measured memory_bytes: 1176
S=input()

#>と<の境界だけ気にすればよい
left=0 #<が連続で続いた記録
right=0 #>が連続で続いた数
SUM=0

def count(l,r,SUM):
    if l<=r:
        SUM+=l*(l-1)//2+r*(r+1)//2
    else:
        SUM+=l*(l+1)//2+r*(r-1)//2
    return SUM
    
for i in range(len(S)):
    if i<len(S)-1 and S[i]==">" and S[i+1]=="<": #><の境界、ここまでのブロックの数列和を計算
        right+=1
        SUM=count(left,right,SUM)
        left=0
        right=0
    elif S[i]=="<":
        left+=1
    elif S[i]==">":
        right+=1

#最後の群を処理して出力
print(count(left,right,SUM))

Measured memory_bytes: 4116
/*
 * 1,2,…,N を並べ替えてできる列であって、以下の条件を満たすものがあるかどうか判定し、あればその例をひとつ構成してください。
 * 
 *     最長増加部分列の長さは A である
 *     最長減少部分列の長さは B である
 */

import java.util.*;
	public class Main{
		public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            //入力
            int n = Integer.parseInt(sc.next());
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            
            if(n < a+b-1 || (long)a*b < n){
            	System.out.println(-1);
            	sc.close();
            	return;
            }else if(b==1){
            	System.out.print(1);
            	
            	for(int i=1; i<n; i++){
        			System.out.print(" " + (i+1));
        		}
            	System.out.println("");
            	sc.close();
            	return;
            }
            
            int set = (n-a-b+1)/(b-1), remain = (n-a-b+1)%(b-1);
            
            for(int i=0; i<b; i++){
            	if(i==0){
            		System.out.print(b);
            		for(int j=1; j<a; j++){
            			if(j<set+1){
            				System.out.print(" " + (b*(j+1)));
            			}else{            			
            				System.out.print(" " + (b*(set+1) + remain + j - set));
            			}
            		}
            	}else if(i<=remain){
            		for(int j=0; j<set+1; j++){
            			System.out.print(" " + (b*(j+1)-i));
            		}
            		System.out.print(" " + (b*(set+1) - i + remain + 1));
            	}else{
            		for(int j=0; j<set+1; j++){
            			System.out.print(" " + (b*(j+1)-i));
            		}
            	}
            }
            
            System.out.println("");
            sc.close();
		}
    }
	

Measured memory_bytes: 48956
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#define MOD 1000000007LL
#define SIZE 20000005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

ll fac[SIZE],finv[SIZE],inv[SIZE];

void make()
{
	inv[1]=1;
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	for(int i=2;i<SIZE;i++)
	{
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		fac[i]=fac[i-1]*(ll) i%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}
ll C(int a,int b)
{
	if(a<b) return 0;
	return fac[a]*(finv[b]*finv[a-b]%MOD)%MOD;
}
ll get(int Y,int X)
{
	ll A=(ll) (X+1)%MOD*(ll) (Y+2)%MOD*C(X+Y+1,Y)%MOD;
	ll B=(ll) (X+1)%MOD*C(X+Y+2,Y)%MOD;
	return (A-B+MOD)%MOD;
}
int main()
{
	make();
	int H,W,k;
	scanf("%d %d %d",&H,&W,&k);
	ll ret=k;
	for(int i=1;i<=k;i++)
	{
		ret+=(ll) H*inv[H+W]%MOD*(1+(ll) (i-1)*(ll) W%MOD*inv[H+W-1]%MOD)%MOD*(ll) (k-i+1)%MOD;
		ret+=(ll) W*inv[H+W]%MOD*(1+(ll) (i-1)*(ll) H%MOD*inv[H+W-1]%MOD)%MOD*(ll) (k-i+1)%MOD;
		ret%=MOD;
	}
	printf("%lld\n",ret*fac[H+W]%MOD*finv[H+W-k]%MOD);
	return 0;
}


Measured memory_bytes: 468992
#include <stdio.h>

int main(void)
{
	int i,j,k;
	int n;
	int b,f,r,v;
	int dat[4][3][10]={{{0}}};
	
	scanf("%d",&n);
	
	for(i=0 ; i<n ; i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		dat[b-1][f-1][r-1]+=v;
	}
	
	for(i=0 ; i<4 ; i++){//?£?
		for(j=0 ; j<3 ; j++){//???
			for(k=0 ; k<10 ; k++){//??¨?±?
				printf(" %d",dat[i][j][k]);
			}
			printf("\n");
		}
		if(i!=3)printf("####################\n");
	}
		
	return 0;
}

Measured memory_bytes: 1792
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    h::Int,n::Int=parseMap(split(readline()))
    data=Vector{Vector{Int}}([parseMap(split(readline())) for i in 1:n])
    INF::Int=2<<32
    dp=Vector{Int}([INF for i in 0:h])
    dp[1]=0
    for i in 1:h
        for (a,b) in data
            tmp=min(i+a,h+1)
            dp[tmp]=min(dp[tmp],dp[i]+b)
        end
    end
    println(dp[h+1])
end
main()

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

int main() {
	string S; cin >> S;
	int n = (int)S.size();
	int res = 0;
	for (int bit = 0; bit < (1 << (n - 1)); ++bit) {
		bool ok = true;
		int tmp = 0, num = 0;
		bool leading_zero = false;
		int div = 0;
		for (int i = 0; i < n; ++i) {
			if (num == 0 && S[i] == '0') leading_zero = true;
			tmp = tmp * 10 + (int)(S[i] - '0');
			++num;
			if ((bit & (1 << i)) || i == n-1) {
				if (leading_zero && num > 1) ok = false;
				if (tmp < 0 || tmp > 255) ok = false;
				tmp = num = 0;
				++div;
			}
		}
		if (ok && div == 4) ++res;
	}
	cout << res << endl;
}


Measured memory_bytes: 3204
#include "bits/stdc++.h"
using namespace std;

bool ok(string s) {
  if (s[0] != 'A') return false;
  if (count(s.begin() + 2, s.end() - 1, 'C') != 1) return false;
  for (char c : s) {
    if (c != 'A' && c != 'C' && isupper(c)) return false;
  }
  return true;
}

int main(){
    string s;
    cin >> s;
    cout << (ok(s) ? "AC" : "WA") << endl;
    
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;

int main() {
  int c[101] =  { 0 };
  int a, b;
  while (cin >> a >> b) {
    if (a + b == 0) {
      int t = 0;
      for (int i = 3; i < 101; i++) {
        t += c[i] % 2;
      }
      if (t == 0 && c[1] % 2 && c[2] % 2) {
        cout << "OK" << endl;
      } else {
        cout << "NG" << endl;
      }

      memset(c, 0, sizeof(c));

    } else {
      c[a]++;
      c[b]++;
    }    
    
  }
  
  return 0;
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
using namespace std;
#define ll long long  
template <typename T>
bool PN(T x){ if (x <= 1) return false; if (x == 2) return true; for (int i = 2; i < sqrt(x) + 1; i++) if (x % i == 0) return false; return true;}

const ll MOD = 1e9+7;

void solve(){
  int x, y; cin >> x >> y;
  int check[13] = {-1, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  if(check[x] == check[y]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

Measured memory_bytes: 3612
import sys

readline = sys.stdin.readline
N = int(readline())
CSF = []
for i in range(N-1):
    CSF.append(tuple(map(int, readline().split())))
for i in range(N):
    time = 0
    for c, s, f in CSF[i:N-1]:
        if time < s:
            time = s
        else:
            time = (time+f-1)//f*f
        time += c
    print(time)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define VI vector<int>
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60 ; const ll mod=1e9+7 ;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------
struct mint {
	ll x;
	mint(ll x=0):x(x%mod){}

	bool operator>=(const mint a){
	return (x >= a.x)? 1: 0;
	}
	bool operator<(const mint a){
		return !(*this>=a);
	}
	bool operator>(const mint a){
		return (x > a.x)? 1:0;
	}
	bool operator<=(const mint a){
		return !(*this>a);
	}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
			return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
			return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
			mint a = pow(t>>1);
			a *= a;  //2 square
		if (t&1) a *= *this; 
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod-2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res/=a;
	}
};

string s;
const int MX = 100000+6;
mint fac3[MX];
int n;

mint solve(int i){
	if(i == n) return 1;
	if(s[i] == '1'){
		return fac3[n-1-i] + solve(i+1)*2;
	}else{
		return solve(i+1);
	}
}

int main(){
	cin >> s;
	n = s.size();
	fac3[0] = 1;
	FOR(i,1,MX-1){
		fac3[i] = fac3[i-1]*3;
	}
	mint ans  = solve(0);
	cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 4352
N = int(input())

def fac(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

A = fac(N)
if N == 1:
    A = []
ans = 0
for i in range(len(A)):
    count = 1
    while True:
        if A[i][1] < 0.5*(count+1)*(count+2):
            break
        else:
            count += 1
    ans += count
    #print(A[i][1])
print(ans)

Measured memory_bytes: 9500
#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int MAXN=100010, LOG=20;

ll ans; // :))
int n, m, k, u, v, x, y, t, a, b, X, Y;
int par[MAXN], h[MAXN], sz[MAXN][2];
pii val[MAXN];
vector<int> G[MAXN];

inline pii operator +(pii i, pii j){ return {i.first+j.first, i.second+j.second};}

void dfs1(int node, int p){
	h[node]=h[par[node]=p]+1;
	for (int v:G[node]) if (v!=par[node]){
		if (!h[v]) dfs1(v, node);
		else{
			X=v;
			Y=node;
		}
	}
}
void dfs2(int node){
	sz[node][h[node]&1]++;
	for (int v:G[node]) if (v!=par[node]){
		dfs2(v);
		sz[node][0]+=sz[v][0];
		sz[node][1]+=sz[v][1];
	}
}
void dfs3(int node){
	if (h[node]&1) val[node].first=1;
	else val[node].first=-1;
	for (int v:G[node]) if (v!=par[node]){
		dfs3(v);
		val[node]=val[node]+val[v];
	}
}
int Solve1(){
	dfs2(1);
	if (sz[1][0]!=sz[1][1]) kill(-1)
	for (int i=2; i<=n; i++) ans+=abs(sz[i][0]-sz[i][1]);
	kill(ans)
}
int Solve2(){
	int diff=sz[1][1]-sz[1][0];
	if (diff&1) kill(-1)
	diff>>=1;
	if (h[X]&1) diff*=-1;
	memset(sz, 0, sizeof(sz));
	sz[X][h[X]&1]+=diff;
	sz[Y][h[Y]&1]+=diff;
	dfs2(1);
	for (int i=2; i<=n; i++) ans+=abs(sz[i][0]-sz[i][1]);
	ans+=abs(diff);
	kill(ans)
}
int Lca(int x, int y){
	while (x^y){
		if (h[x]<h[y]) swap(x, y);
		x=par[x];
	}
	return x;
}
int Solve3(){
	if (sz[1][0]!=sz[1][1]) kill(-1)
	if (h[X]%2==0) swap(X, Y);
	val[X].second--;
	val[Y].second--;
	val[Lca(X, Y)].second+=2;
	dfs3(1);
	vector<int> vec={0};
	for (int i=1; i<=n; i++) if (val[i].second){
		int tmp=val[i].first;
		vec.pb(tmp);
	}
	sort(all(vec));
	debugv(vec)
	int diff=vec[(vec.size()-1)/2];
	debug(diff)
	memset(sz, 0, sizeof(sz));
	/*
	sz[X][h[X]&1]-=diff;
	sz[Y][h[Y]&1]-=diff;
	dfs2(1);
	for (int i=2; i<=n; i++) ans+=abs(sz[i][0]-sz[i][1]);
	*/
	ans+=abs(diff);
	for (int i=1; i<=n; i++) ans+=abs(val[i].first + val[i].second*diff);
	kill(ans)
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>m;
	for (int i=0; i<m; i++){
		cin>>u>>v;
		G[u].pb(v);
		G[v].pb(u);
	}
	dfs1(1, 0);
	if (m==n-1) Solve1();
	else{
		debug2(X, Y)
		for (int &x:G[Y]) if (x==X) swap(G[Y].back(), x);
		for (int &y:G[X]) if (y==Y) swap(G[X].back(), y);
		G[X].pop_back();
		G[Y].pop_back();
		dfs2(1);
		if (h[X]%2==h[Y]%2) Solve2();
		else Solve3();
	}
	
	return 0;
}

Measured memory_bytes: 19540
#include <stdio.h>

int main(int argc, char **argv)
{
    char a, b;
    scanf("%c %c", &a, &b);

    if (a == 'H') {
        printf("%c\n", b);
    } else {
        printf("%c\n", b == 'H' ? 'D' : 'H');
    }
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

#define MAXN 2200
ll facs[MAXN];

// x^n in mod
ll modpow(ll x, ll n, ll mod){
  if(n==0) return 1;

  if(n%2==0){
    return modpow(x*x%mod, n/2, mod) % mod;
  }else{
    return x * modpow(x, (n-1), mod) % mod;
  }
}

// n! in mod
ll fac(ll n){
  return facs[n];
}

// nCr in mod
ll comb(ll n, ll r){
  if(n<0 || n<r || r<0)return 0;
  ll fn = fac(n);
  ll fr = fac(r);
  ll fn_r = fac(n-r);

  ll d = (modpow(fr, MOD-2, MOD) * modpow(fn_r, MOD-2, MOD)) % MOD;
  ll u = fn%MOD;
  
  ll result = u * d % MOD;
 
  return result;
}

ll homogeneous(ll n, ll r){
  return comb(n+r-1, r-1);
}

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

  facs[0]=1;
  rep(i, MAXN)facs[i+1] = (facs[i]*(i+1))%MOD;

  if(n/3==0){ cout<<0<<endl; return 0; }

  ll result = 1;
  for(int i=2; i<=n/3; i++){
    ll remain = n-i*3;
    result += homogeneous(remain, i);
    result %= MOD;
//cout<<remain<<' '<<i<<' '<<homogeneous(remain, i)<<endl;
  }

  cout<<result<<endl;

  return 0;
}

Measured memory_bytes: 3652