akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;

int main() {

	Int a, b, t;
	cin >> a >> b >> t;

	cout << t / a * b << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    string s;
    cin >> s;
    string ans = "";
    REP(i, s.length()) {
        if(s[i] != 'B') {
            ans += s[i];
        } else {
            if(ans.length() > 0) {
                ans.pop_back();
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var s = n / 15;
            WriteLine(n * 800 - s*200);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int a,b,c,d;
cin >> a;
cin >> b;
cin >> c;
cin >>d;

if((a+b) > (c+d)){
cout << "Left" << endl;
}
else if((a+b) == (c+d)){
cout << "Balanced" <<endl;
}
else{
cout << "Right" <<endl;
}

}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
int n,m;
vector<int>v[100009];
int dp[100009];
int bt(int node){
	if(dp[node]!=-1) return dp[node];
	int ans=0;
	for(int i=0;i<v[node].size();i++){
		ans=max(ans,bt(v[node][i])+1);
	}
	dp[node]=ans;
	return ans;
}
int main(){
	memset(dp,-1,sizeof(dp));
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		v[a].push_back(b);
	}
	int ans=0;
	for(int i=0;i<n;i++){
		ans=max(ans,bt(i));
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 8192
#include <iostream>
#include <algorithm>
#include <map>
#include <regex>
#include <string>
#include <cstdlib>
#include <math.h>
using namespace std;
int main() {
  int K, X;
  cin >> K >> X;
  if (500 * K >= X) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

char s[103], t[103];
inline void sswap(char&c1, char&c2) { char c=c1;c1=c2;c2=c; }

int main(void)
{
    scanf("%s %s", s, t);
    int Slen=strlen(s), Tlen=strlen(t);
    for(int i=0; i<Slen-1; ++i)
        for(int j=i+1; j<Slen; ++j)
        {
            if(s[i] > s[j])
                sswap(s[i], s[j]);
        }
    for(int i=0; i<Tlen-1; ++i)
        for(int j=i+1; j<Tlen; ++j)
        {
            if(t[i] < t[j])
                sswap(t[i], t[j]);
        }
    if(strcmp(s, t) < 0)
        puts("Yes");
    else
        puts("No");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PB push_back
#define PII pair<int,int>
#define PLL pair<long long,long long>
#define FI first
#define SE second
#define mem(a) memset(a,0,sizeof(a))
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int INF = 0x3f3f3f3f;
const double pi=acos(-1),eps=1e-8;
const LL maxn = 1<<17;
const int mod = 1e9+7;
const int N = 2e5+5;
LL qpow(LL a,LL b,LL p){
	LL ans=1;
	while(b){
		if(b&1)ans=ans*a%p;
		a=a*a%p;
		b>>=1;
	}
	return ans;
}
char s[N];
int main() {
	ios;
	int n,cnt=0;
	int mo1=0,mo2=0;
	scanf("%d",&n);
	scanf("%s",s+1);
	for(int i=1;i<=n;i++){
		if(s[i]=='1')cnt++;
	}
	for(int i=1;i<=n;i++){
		mo1=(mo1*2+(s[i]-'0'))%(cnt+1);
	}
	if(cnt>1){
		for(int i=1;i<=n;i++){
			mo2=(mo2*2+(s[i]-'0'))%(cnt-1);
		}
	}
	for(int i=1;i<=n;i++){
		int now;
		if(s[i]=='0'){
			now=(mo1+qpow(2,n-i,cnt+1))%(cnt+1);
		}else{
			if(cnt==1){
				cout<<0<<endl;
				continue;
			}
			now=(mo2-qpow(2,n-i,cnt-1)+cnt-1)%(cnt-1);
		}
		int f=1;
		while(now>0){
			now=now%__builtin_popcount(now);
			f++;
		}
		cout<<f<<endl;
	}
	return 0;
}


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

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

int main() {
  string s;
  cin >> s;
  
  reverse(s.begin(), s.end());
  for(int i=0;i<4;++i) reverse(divide[i].begin(), divide[i].end());
  
  bool can=true;
  for(int i=0;i<s.size();){
    bool can2=false;
    for(int j=0;j<4;++j){
      if(s.substr(i, divide[j].size()) == divide[j]){
        can2=true;
        i+=divide[j].size();
        break;
      }
    }
    if(!can2){
      can=false;
      break;
    }
  }
  
  if(can) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  

}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

void QSort(int x[ ], int left, int right);
void Swap(int x[ ], int i, int j);

  /* クイックソートを行う */
void QSort(int x[ ], int left, int right)
{
    int i, j;
    int pivot;

    i = left;                      /* ソートする配列の一番小さい要素の添字 */
    j = right;                     /* ソートする配列の一番大きい要素の添字 */

    pivot = x[(left + right) / 2]; /* 基準値を配列の中央付近にとる */

    while (1) {                    /* 無限ループ */

        while (x[i] < pivot)       /* pivot より大きい値が */
            i++;                   /* 出るまで i を増加させる */

        while (pivot < x[j])       /* pivot より小さい値が */
            j--;                   /*  出るまで j を減少させる */
        if (i >= j)                /* i >= j なら */
            break;                 /* 無限ループから抜ける */

        Swap(x, i, j);             /* x[i] と x[j]を交換 */
        i++;                       /* 次のデータ */
        j--;
    }

    if (left < i - 1)              /* 基準値の左に 2 以上要素があれば */
        QSort(x, left, i - 1);     /* 左の配列を Q ソートする */
    if (j + 1 <  right)            /* 基準値の右に 2 以上要素があれば */
        QSort(x, j + 1, right);    /* 右の配列を Q ソートする */
}

  /* 配列の要素を交換する */
void Swap(int x[ ], int i, int j)
{
    int temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}

int main(){
    // Your code here!
    int N,v[50];
    double S = 0;
    scanf("%d",&N);
    for(int i = 0; i < N; i++)
    {
        scanf("%d", &v[i]);
    }
    
    QSort(v, 0, N-1);
    
    
    for(int i = 0; i < N; i++)
    {
        if(i == 0)
            S += (double)v[i] / pow(2,N-1);
        else
            S += (double)v[i] / pow(2,N-i);
    }
        
    printf("%lf\n",S);
        
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define INF 1000000007
// cin.eof() 入力個数の問題
int main(){
ll n,a,b,c,d,e;
cin>>n>>a>>b>>c>>d>>e;
ll A=min({a,b,c,d,e});
if(n%A==0){
cout<<n/A+4<<endl;
  
}else{
cout<<n/A+5<<endl;
}
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
template <class Key, class Compare = less<Key>>
using Tree = __gnu_pbds::tree<Key, __gnu_pbds::null_type, Compare, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;



int N, W;
int w[100], v[100];
static ll dp[101][100001];

ll dfs(int i, int wrem) {
  ll& res = dp[i][wrem];
  if (res != -1) {
    return res;
  }
  res = 0;
  if (i < N) {
    res = max(res, dfs(i+1, wrem));
    if (w[i] <= wrem) {
      res = max(res, v[i] + dfs(i+1, wrem-w[i]));
    }
  }
  return res;
}

void Main() {
  cin >> N >> W;
  for (int i = 0; i < N; ++i) {
    cin >> w[i] >> v[i];
  }
  memset(dp, -1, sizeof(dp));
  cout << dfs(0, W) << '\n';
}

int main() {
  ios::sync_with_stdio(false);
//  cin.tie(nullptr);
  #ifdef _DEBUG
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  #endif
  Main();
  return 0;
}


Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb emplace_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=LONG_LONG_MAX;
const ll ms=(2e5)+5;


int ar[ms]={0};

int main()
{
    idfc;
    int n;
    cin>>n;
    int i,j,k;
    int ans=0;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            for(k=1;k<=n;k++)
            {
                ans+=__gcd(i,__gcd(j,k));
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3620
def main():
    N = int(input())
    S = list(map(int, input().split()))
    INF = float('inf')

    S.sort()

    parents = [S[-1]]
    S[-1] = INF

    for _ in range(N):
        checking = 2
        parents.sort()
        tmp = parents[::-1]
        for i in tmp:
            while True:
                if S[-checking] < i:
                    parents.append(S[-checking])
                    S[-checking] = INF
                    break
                else:
                    checking += 1
                if checking == 2 ** N + 1:
                    print('No')
                    exit()
    else:
        print('Yes')


if __name__ == '__main__':
    main()

Measured memory_bytes: 34676
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int t; cin >> t; cin.ignore(); while(t--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}
 
int main(){
    fast();
 
/* you get what you work for not what you wish for */
    
    inp(n);
    vector <vector <pll>> a(n);
    int ans = 0;
    for(int i=0; i<n; i++){
        ll x;
        cin >> x;
        for(int j=0; j<x; j++){
            ll b, c;
            cin >> b >> c;
            b--;
            a[i].pb({b, c});
        }
    }
    for(ll i=0; i<(1ll<<n); i++){
        ll bit[n] = {0};
        for(int j=0; j<n; j++){
            if((1ll<<j)&i){
                bit[j] = 1;
            }
        }
        bool check = 1;
        for(int j=0; j<n; j++){
            if(bit[j]){
                for(auto k:a[j]){
                    if(k.ss!=bit[k.ff]){
                        check = 0;
                    }
                }
            }
        }
        if(check){
            int cnt = 0;
            for(int j=0; j<n; j++){
                if(bit[j]){
                    cnt++;
                }
            }
            ans = max(ans, cnt);
        }
    }
    out(ans);
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int S = sc.nextInt();

        int[] a = new int[4];
        for(int i = 0;i < 4; i++){
            a[i] = S % (int)Math.pow(10, 4 - i) / (int)Math.pow(10, 3 - i);
        }

        String x = "Good";
        for(int i = 0; i < a.length - 1; i++){
            if(a[i] == a[i + 1]){
                x = "Bad";
            }
        }
        System.out.println(x);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (ll NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (ll NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (ll NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll INF = 1000000000000000;

string s;
int main(){
	string s,t;
	cin >> s >> t;
	int ans=0;
	REP(i,3){
		if(s[i] == t[i])ans++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
import math,sys,bisect,heapq
from collections import defaultdict,Counter,deque
from itertools import groupby,accumulate
#sys.setrecursionlimit(200000000)
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda: map(int,input().split())
alele = lambda: list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
#def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
MOD = 1000000000 + 7
def Y(c):  print(["NO","YES"][c])
def y(c):  print(["no","yes"][c])
def Yy(c):  print(["No","Yes"][c])
      
def fun(A,B,m,n,dp):
    for i in range(1,m+1):
        for j in range(1,n+1):
            if A[i-1] == B[j-1]:
                dp[i][j] = 1 + dp[i-1][j-1]
            else:
                dp[i][j] = max(dp[i][j-1],dp[i-1][j])
    return dp
                
def longestsub(A,B):
    m = len(A)
    n = len(B)
    if m==0 or n==0:
        return ""
    temp = [0]*(n+1)
    dp = [temp.copy() for i in range(m+1)]
    d = fun(A,B,m,n,dp)
    i= m;j = n;Ans = ""
    while i>0 and j>0:
        if A[i-1] == B[j-1]:
            Ans += A[i-1]
            i-=1;j-=1
        else:
            a = d[i][j-1] ; b =d[i-1][j]
            if a > b:
                j-=1
            else:
                i-=1
    return Ans[::-1]

A = input()
B = input()
print(longestsub(A,B))

Measured memory_bytes: 139344
#include <bits/stdc++.h>
#define x real()
#define y imag()
#define EPS (1e-10)
using namespace std;
typedef complex<double> point;
//vector <point> pl;

namespace std {
    bool operator < (const point& a, const point& b){
        return fabs(real(a)-real(b)) < EPS ? imag(a) < imag(b) : real(a) < real(b);
    }
    bool operator == (const point& a, const point& b){
        return fabs(real(a) - real(b)) < EPS && fabs(imag(a) - imag(b)) < EPS;
    }
    bool operator != (const point& a, const point& b){
        return !(a == b);
    }
    point operator+(const point& a, const point& b){
        point res;
        res.x = a.x + b.x;
        res.y = a.y + b.y;
        return res;
    }
}

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){
    point d = b-a,e = c-a;
    if(cross(d,e)>0) return 1;//"COUNTER_CLOCKWISE"
    if(cross(d,e)<0) return -1;//"CLOCKWISE"
    if(dot(d,e)<0) return 2;//"ONLINE_BACK"
    if(abs(d) < abs(e)) return -2;//"ONLINE_FRONT"
    return 0;//"ON_SEGMENT"
}

point crosspoint(point a,point b,point c,point d){
    a-=d;b-=d;c-=d;
    return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}

bool intersection(point a,point b,point c,point d){
    return (ccw(a,b,c)*ccw(a,b,d)<=0&&ccw(c,d,a)*ccw(c,d,b)<=0);
}

bool is_edge(point p, double edge){
    return abs(p.x + edge) < EPS ||
           abs(p.y + edge) < EPS ||
           abs(p.x - edge) < EPS ||
           abs(p.y - edge) < EPS;
}

int main(void){
    int N;
    while(cin >> N, N){
        int ans = 1;
        set<point> inj;
        set< pair<point, point> > vect;
        for(int i = 0; i < N; i++){
            inj.clear();
            ans += 1;
            point p1, p2;
            cin >> p1.x >> p1.y >> p2.x >> p2.y;
            for(set< pair<point, point> >::iterator it = vect.begin(); it != vect.end(); it++){
                if(intersection(p1, p2, it->first, it->second)){
                    point crossing = crosspoint(p1, p2, it->first, it->second);
                    if(is_edge(crossing, 100)) continue;
                    bool flg = true;
                    for(set<point>::iterator injit = inj.begin(); injit != inj.end(); injit++){
                        if(crossing == *injit){
                            flg = false;
                            break;
                        }
                    }
                    if(flg){
                        ans += 1;
                        inj.insert(crossing);
                    }
                    /*
                    if(inj.find( crosspoint(p1, p2, it->first, it->second)) == inj.end() ){
                        ans += 1;
                        inj.insert( crosspoint(p1, p2, it->first, it->second) );
                    }
                    */
                }
            }
            vect.insert( make_pair(p1, p2) );
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
string p = "YAKI";

int main() {
    string s;
    cin >> s;
    for(int i = 0; i < 4; i++){
        if(p[i] != s[i]){
            cout << "No" << "\n";
            return 0;
        }
    }
    cout << "Yes" << "\n";
    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

map<ll, ll> prime_factorize(ll N) {
    map<ll, ll> res;
    for (ll i = 2; i * i <= N; ++i) {
        while (N % i == 0) {
            res[i]++;
            N /= i;
        }
    }
    if (N != 1) res[N] = 1;
    return res;
}

void solve() {
    ll N;
    cin >> N;
    auto primes = prime_factorize(N);
    ll ans = 0;
    for (P prime : primes) {
        ll p = prime.first;
        ll last = 0;
        ll cnt = 0;
        rep(i, prime.second) {
            cnt ++;
            if (cnt > last) {
                cnt = 0;
                last ++;
                ans ++;
            }
        }
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 3664
using System;
using System.Linq;

public class AtCoder_153_D
{
    public static void Main()
    {
        //var exStdIn = new System.IO.StreamReader( "input.txt" );
        //System.Console.SetIn( exStdIn );

        long h = long.Parse(Console.ReadLine());
        long count = Count(h);
        Console.WriteLine(count);
    }

    private static long Count(long h)
    {
        if (h == 0)
        {
            return 0;
        }
        if (h == 1)
        {
            return 1;
        }
        long count = Count(h / 2);
        return 1 + count + count;
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<vector>
using namespace std;
int h,w,m;
int t[50][50];
int con[50][50],on[50][50],off[50][50];
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
int to[1000][50][50];
string s[50];
void dfs(int x,int y,int pr,int id)
{
	for(int dr=0;dr<4;dr++)
	{
		if(pr>=0&&(dr-pr+4)%4==2)
		{
			to[id][x][y]=dr;
			continue;
		}
		int tx=x+dx[dr],ty=y+dy[dr];
		if(tx>=0&&ty>=0&&tx<h&&ty<w&&s[tx][ty]!='#')dfs(tx,ty,dr,id);
	}
}
main()
{
	cin>>h>>w>>m;
	for(int i=0;i<h;i++)cin>>s[i];
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>con[i][j];
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>on[i][j];
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>off[i][j];
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)t[i][j]=-1;
	for(int i=0;i<m;i++)for(int k=0;k<h;k++)for(int l=0;l<w;l++)to[i][k][l]=-1;
	vector<pair<int,int> >xy;
	for(int i=0;i<m;i++)
	{
		int x,y;cin>>x>>y;xy.push_back({x,y});
		dfs(x,y,-1,i);
	}
	int nx=xy[0].first,ny=xy[0].second;
	t[nx][ny]=0;
	int ans=on[nx][ny]+off[nx][ny];
	int nowt=0;
	for(int i=1;i<m;i++)
	{
		int tx=xy[i].first,ty=xy[i].second;
		while(nx!=tx||ny!=ty)
		{
			int r=to[i][nx][ny];
			nx+=dx[r],ny+=dy[r];
			nowt++;
			ans+=on[nx][ny]+off[nx][ny];
			if(t[nx][ny]>=0)
			{
				int A=on[nx][ny]+off[nx][ny];
				int B=(nowt-t[nx][ny])*con[nx][ny];
				if(A>B)ans-=A-B;
			}
			t[nx][ny]=nowt;
		}
	}
	cout<<ans<<endl;
}



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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
	int N;
	cin>>N;
	if(N&1){
		cout<<0<<endl;
		return 0;
	}
	N/=2;
	int cnt=0;
	for(int i=5;i<=N;i*=5){
		cnt+=N/i;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def divby2(n):
    i = 2
    l = 0
    while n % i == 0:
        n /= i
        l += 1
    return l


# input
n = int(input())
a = list(map(int, input().split()))
o = 0
# calc
for i in range(n):
    o += divby2(a[i])
# output
print(o)

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

int main() {
  int n;
  std::cin >> n;
  std::vector<int> a(n);

  for (auto &i : a) {
    std::cin >> i;
  }

  std::cout << *std::max_element(a.cbegin(), a.cend()) - *std::min_element(a.cbegin(), a.cend()) << std::endl;
  return 0;
}


Measured memory_bytes: 256
N,M=map(int, input().split())
p=list(map(int, input().split()))

uf=[i for i in range(N+1)]

def find(n):
	if uf[n] == n:
		return n
	uf[n] = find(uf[n])
	return uf[n]

def union(n, m):
	uf[find(n)] = find(m)

def same(n, m):
	return find(n) == find(m)

for _ in range(M):
	union(*map(int, input().split()))

for i in range(N+1):
	find(i)

print(sum([1 if same(i+1,v) else 0 for i,v in enumerate(p)]))


Measured memory_bytes: 120300
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import comb

# 再帰がやばいとき
# import sys
# sys.setrecursionlimit(10**9)

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e30)
MOD = int(1e9)+7 # 10^9 + 7

# field[H][W]
def create_grid(H, W, value = 0):
    return [[ value for _ in range(W)] for _ in range(H)]

########

def main():
    N, Ma, Mb = l_inpl()
    abc = []
    for _ in range(N):
        abci = l_inpl()
        abc.append(abci)

    max_ab = 40*10

    # dp[i][j][k]: i番目までの薬品の組み合わせで，物質aがjグラム，物質bがkグラムのときのコスト
    dp = [[[INF for _ in range(max_ab+1)] for _ in range(max_ab+1) ] for _ in range(N+1)]
    dp[0][0][0] = 0

    for i in range(N):
        for j in range(max_ab+1):
            for k in range(max_ab+1):
                # ここでのINFはNoneと同じ意味なので
                if dp[i][j][k] == INF:
                    continue
                # i番目の薬品を加えない
                dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k])
                # i番目の薬品を加える
                dp[i+1][j+abc[i][0]][k+abc[i][1]] = min(dp[i+1][j+abc[i][0]][k+abc[i][1]], dp[i][j][k] + abc[i][2])
                
    ans = INF
    for ca in range(1, max_ab+1):
        for cb in range(1, max_ab+1):
            if ca*Mb == cb*Ma:
                ans = min(ans, dp[N][ca][cb])
    
    if ans == INF:
        print(-1)
    else:
        print(ans)

    
if __name__ == "__main__":
    main()


Measured memory_bytes: 60772
#include <bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, m,n) for (int i = m; i < (int)(n); i++)
int main(){
double a; cin>>a;
  cout<<std::setprecision(20)<<(a/3.0)*(a/3.0)*(a/3.0)<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n, tou, kai, situ, num, a[4][3][10], i, j, k;

  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
	a[i][j][k]=0;
      }
    }
  }
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d %d %d",&tou,&kai,&situ,&num);
    a[tou-1][kai-1][situ-1]+=num;
  }

  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
	printf(" %d",a[i][j][k]);
	if(k==9) printf("\n");
      }
    }
    if(i<3) printf("####################\n");
  }
  
  return 0;
}



Measured memory_bytes: 2072
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
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 SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

using ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(n,x);
  Vi X(n);
  VIN(X)
  X.pb(x);
  SORT(X);
  Vi diff(n);
  REP(i,n){
    diff[i] = X[i+1] - X[i];
  }
  int ans = gcd(diff[0], diff[1]);
  REP(i,n){
    ans = gcd(diff[i], ans);
  }
  OUT(ans);
}

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

int main()
{
	int H,W,h,w;
	cin >> H >> W >> h >> w;
	int ans = H*W - (W*h + H*w - h*w);
	cout << ans << endl;
	return 0;
}

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

int main() {
    int X;
    cin >> X;
    ll sum = 0;
    ll ans = 1;
    while (true) {
        sum += ans;
        if (sum >= X) {
            break;
        }
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def code_for_A(S, test=None):

    if not test:
        S = input()

    condition = 0
    for s in S:
        condition += S.count(s) != 2

    if condition:
        answer = 'No'
    else:
        answer = 'Yes'

    print(answer)

code_for_A(None, 0)

Measured memory_bytes: 2940
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)	   for(int i = 0; i < (n); ++i)
#define all(c)		   begin(c), end(c)
#define rall(c)		   rbegin(c), rend(c)
#define SZ(a)		   ((ll) a.size())

typedef long long		   ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<int> a(N+2);
  rep(i,N) scanf("%d",&a[i+1]);
  a[0]=0;
  a[N+1]=0;
  int sum=0;
  int ans;
  rep(i,N+1){
    sum+=abs(a[i+1]-a[i]);
  }
  FOR(i,1,N+1){
    ans=sum;
    ans-=abs(a[i+1]-a[i]);
    ans-=abs(a[i]-a[i-1]);
    ans+=abs(a[i+1]-a[i-1]);
    printf("%d\n",ans);
  }
}


Measured memory_bytes: 1664
/*****************************************************

@author: vichitr
Compiled On: 27th April 2019

*****************************************************/

#include<bits/stdc++.h>
#define MAX 9223372036854775807
#define endl "\n"
#define ll long long
#define int long long
#define pb push_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define ip pair<int, int>

#define loop(i,n) for(int i=0;i<n;i++)
#define fast ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
using namespace std;

const ll MOD = 1e9+7;
const ll SZ = 107;
const ll N = 2e5+7;

int pow(int x, int y)
{
    ll r = 1LL;
    while(y)
    {
        if(y&1)
            r = (r * x);
        y >>= 1;
        x = (x * x);
    }
    return r;
}

void solve()
{
    int n;cin>>n;
    // int n;cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];

    int gcd1[n], gcd2[n];
    gcd1[0] = a[0];
    for(int i=1;i<n;i++)
    {
        gcd1[i] = __gcd(gcd1[i-1], a[i]);
    }
    gcd2[n-1] = a[n-1];
    for(int i=n-2;i>=0;i--)
    {
        gcd2[i] = __gcd(gcd2[i+1], a[i]);
    }
    // cout<<gcd<<" "<<lcm<<endl;
    int ans = 1;
    for(int i=1;i<n-1;i++)
    {
        ans = max(ans, __gcd(gcd1[i-1], gcd2[i+1]));
    }
    ans = max(ans, gcd1[n-2]);
    ans = max(ans, gcd2[1]);
    cout<<ans;
}

signed main()
{
    fast;

    int t=1;
    // cin >>t;
    while(t--){
        solve();
    }
    return 0;
}

/*****************************


****************************/

Measured memory_bytes: 2560
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long ll;
double maxcal(double x,double y)
{
  if(x>=y) return x-y;
  else return y-x;
}
 
int main(void)
{
  double a,b,h,m,p=3.1415926535898;
  scanf("%lf%lf%lf%lf",&a,&b,&h,&m);
  double ra,rb,rab,c;
  ra=(60.0*h+m)/360*p;
  rb=m*p/30;
  rab=maxcal(ra,rb);
  c=a*a+b*b-2.0*a*b*cos(rab);
  c=sqrt(c);
  printf("%.10lf",c);

  
  return 0;
}

Measured memory_bytes: 2580
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll i,N,M,l,r,c;
  cin>>N>>M;
  vec dist(N,inf);
  pmat v(N);
  rep1(i,N){
    v[i].pb(datas(0,i-1));
  }
  rep(i,M){
    cin>>l>>r>>c;
    v[l-1].pb(datas(c,r-1));
  }
  priority_queue<datas,vector<datas>,greater<datas>> que;
  que.push(datas(0,0));
  while(!que.empty()){
    auto x=que.top();que.pop();
    if(dist[x.second]!=inf)continue;
    dist[x.second]=x.first;
    for(auto i:v[x.second]){
      i.first+=x.first;
      que.push(i);
    }
  }
  cout<<(dist[N-1]==inf?-1:dist[N-1])<<endl;
  return 0;
}

Measured memory_bytes: 10872
#include <bits/stdc++.h>
using namespace std;
//Author: Ezio Sam
/* Shorthands */
#define ll long long
#define pb push_back 
#define mp make_pair
#define sp ": "
#define cs "Case "
#define fi first
#define sn second 
#define po(x) x*x
/* STL */
#define vi vector<int>v
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mem(a,n) memset(a, n, sizeof(a));
#define all(x) x.begin(),x.end()
#define sz(x)  (int)x.size()
#define mx(v)  *max_element(v.begin(),v.end())
#define mxa(a) *max_element(a, a.size())
#define r(a) reverse(a.begin(),a.end())
/* loops */
#define fr(i,n)   for(__typeof(n) i=0;i<(n);i++)
#define fn(i,n)   for(__typeof(n)i=1;i<=(n);i++)
#define fa(i,a,n) for(__typeof(a)i=(a);i<=(b);i++)
/*Special*/
#define Ezio ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define db(something)   cerr<<#something<<" - "<<something<<"\n";         
int main()
{
  
   Ezio
   /*Variables*/
   /*Code*/
   ll a,b,c,k;
   cin>>a>>b>>c>>k;
   ll an=0;
   if(k<=a){
     if(k==a) an= a*1;
     if (k<a) an= k*1;
   }
   else{
     if(k <=a+b)
     an= a*1;
     else{
       an=( a*1 - (k-(a+b))*1);
     }
   }
   cout<<an<<endl;
   
   return 0;
}
    

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MP make_pair
#define PB push_back
typedef long long ll;

int N, M, dp[3][303][303], nu[3][303][303], tot;
int lmost[303][4], rmost[303][4], pos[4], st[5];

//dp[i][v][where is v+1][where is v+2]

void add (int &a, int b) {
        a += b;
        if (a >= MOD) a -= MOD;
}

int main () {
        scanf("%d %d", &N, &M);
        fo(i, 1, N+1) fo(j, 0, 4) lmost[i][j] = -1, rmost[i][j] = -1;
        fo(i, 0, M) {
                int l, r, x; scanf("%d %d %d", &l, &r, &x);
                if (x > r-l+1) {
                        puts("0");
                        return 0;
                }
                if (lmost[r][x] == -1 || l < lmost[r][x]) lmost[r][x] = l;
                if (rmost[r][x] == -1 || l > rmost[r][x]) rmost[r][x] = l;
        }

        fo(c, 0, 3) nu[c][0][0] = 1;
        fo(p, 1, N) {
                fo(c, 0, 3) fo(y, 0, p) fo(z, 0, p) {
                        dp[c][y][z] = nu[c][y][z];
                        nu[c][y][z] = 0;
                }
                fo(c, 0, 3) fo(y, 0, p) fo(z, 0, p) if (dp[c][y][z]) {
                        pos[c] = p, pos[(c+1)%3] = y, pos[(c+2)%3] = z;
                        fo(n, 0, 3) {
                                bool ok = true;
                                fo(i, 0, 3) st[i+1] = pos[i];
                                st[n+1] = p+1;
                                sort(st+1, st+4, greater<int>());
                                fo(i, 1, 4) {
                                        int l = lmost[p+1][i];
                                        int r = rmost[p+1][i];
                                        if (l != -1 && l <= st[i+1]) ok = false;
                                        if (r != -1 && r > st[i]) ok = false;
                                }

                                if (ok) {
                                        if (p == N-1) add(tot, dp[c][y][z]);
                                        else add(nu[n][pos[(n+1)%3]][pos[(n+2)%3]], dp[c][y][z]);
                                }
                        }
                }
        }

        printf("%d\n", tot);
        return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

int gcd(int a,int b){return b ? gcd(b,a%b) : a;} 
int lcm(int a,int b){return a/gcd(a,b)*b;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    int ans = 0;
    rep(i,2){
        if(a > b){ 
            ans += a;
            a--;
        }
        else{
            ans += b;
            b--;
        }
    }   
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#x個の中から2個取る組み合わせの数
def c(x)
  return 0 if x == 0 || x == 1
  x * (x - 1) / 2
end

gets
balls = gets.split.map(&:to_i)

numbers_table = Hash.new(0)
balls.each {|n| numbers_table[n] += 1}

sum = numbers_table.map {|n, i| c(i)}.inject(&:+)

balls.each do |n|
  puts sum - c(numbers_table[n]) + c(numbers_table[n] - 1)
end

Measured memory_bytes: 29700
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int min = 0;
        int count = 0;
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }
        for(int i =0; i < n-1; i++){
            min = i;
            for(int j = i; j < n; j++){
                if(a[j] < a[min]){
                    min = j;
                }
            }
            if(a[i] != a[min]){
                int work = a[min];
                a[min] = a[i];
                a[i] = work;
                count ++;
            }
            
        }
        for (int i = 0; i < n-1; i++){
            System.out.print(a[i] + " ");
        } 
        System.out.println(a[n-1]);
        System.out.println(count);
    }
}



Measured memory_bytes: 26232
#include <iostream>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

int main(){
    ll n, m;
    cin >> n >> m;
    vector<string> a(n), b(m);
    for(int i = 0; i < n; ++i){
        cin >> a.at(i);
    }
    for(int i = 0; i < m; ++i){
        cin >> b.at(i);
    }

    for(int di = 0; di + m <= n; ++di){
        for(int dj = 0; dj + m <= n; ++dj){
            bool flag = true;
            for(int i = 0; i < m; ++i){
                if(b.at(i) != a.at(di + i).substr(dj, m)){
                    flag = false;
                    break;
                }
            }
            if(flag){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}


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

using namespace std;
using pnt=complex<double>;
const double PI = acos(-1);
void solve() {
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    pnt x = polar(a, double(h*60+m)/(60*12) * 2*PI);
    pnt y = polar(b, double(m)/60 * 2*PI);
    cout << fixed << setprecision(10) << abs(x-y);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 4164
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n;
	cin>>n;
	
	vi a(n);
	vector<vector<pii > > v(n);
	REP(i,n){
		cin>>a[i];
		v[i].resize(a[i]);
		REP(j,a[i]){
			int x,y;
			cin>>x>>y;
			v[i][j]=pii(x,y);
		}
	}
	
	/*REP(i,n){
		REP(j,a[i]) cout<<v[i][j].first<<' '<<v[i][j].second<<endl;
	}*/
	
	int ans=0;
	REP(i,(1<<n)){
		//debug(i);
		
		int cnt=0;		
		vi jud(n,0);
		REP(j,n){
			if((i>>j)&1){
				jud[j]=1;
				cnt++;
			}
		}
		//line(jud);
		
		bool flag=true;
		REP(j,n){
			if(jud[j]){
				REP(k,a[j]){
					pii tmp=v[j][k];
					if(jud[tmp.first-1]==tmp.second){}
					else flag=false;
				}
			}
		}
		
		if(flag){
			ans=max(ans,cnt);
			//debug(i);
		}
	}
	
	cout<<ans<<endl;
}


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

using namespace std;

typedef long long int ll;

#define FOR(i,l,r) for(i=l;i<r;i++)

#define REP(i,n) FOR(i,0,n)

#define ALL(x) x.begin(),x.end()

#define P pair<ll,ll>

#define F first

#define S second

signed main(){

  ll A,V,B,W,T;cin>>A>>V>>B>>W>>T;

  if(V>W&&abs(A-B)<=(V-W)*T)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

  return 0;

}

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

void solve(){
	int n; cin >> n;
	int h1; int h2; cin >> h1 >> h2;
	int a = 0;
	int b = abs(h2 - h1);
	int mini = b;
	for(int i = 0; i < n-2; i++){
		int h3;
		cin >> h3;
		mini = min(a + abs(h3 - h1), b + abs(h3 - h2));
		a = b;
		b = mini;
		h1 = h2;
		h2 = h3;
		//cout << mini << " ";
	}
	cout << mini << endl;
}
int main(){
	solve();
}


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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int n;

typedef pair<int, int> P;

signed main()
{

    cin >> n;
    vector<vector<int>> a(n, vector<int>(n - 1));

    rep(i, n)
    {
        rep(j, n - 1)
        {
            cin >> a[i][j];
            a[i][j]--;
        }
        reverse(all(a[i]));
    }

    vector<P> q;

    auto check = [&](int i) {
        if (a[i].size() == 0)
        {
            return;
        }
        int j = a[i].back();

        if (a[j].size() == 0)
        {
            return;
        }

        if (a[j].back() == i)
        {
            P p(i, j);
            if (p.second < p.first)
            {
                swap(p.first, p.second);
            }
            q.pb(p);
        }
    };

    rep(i, n)
    {
        check(i);
    }

    int day = 0;
    while (q.size() > 0)
    {
        day++;
        vector<P> prevQ;
        sort(all(q));
        q.erase(unique(all(q)), q.end());
        swap(prevQ, q);
        for(auto p:prevQ){
            int i = p.fst;
            int j = p.sec;
            a[i].pop_back();
            a[j].pop_back();
        }
        for(auto p:prevQ){
            int i = p.fst, j = p.sec;
            check(i);
            check(j);
        }
    }

    rep(i,n){
        if(a[i].size()!=0){
            cout<<-1<<endl;
            return 0;
        }
    }

    cout << day<<endl;

    return 0;
}


Measured memory_bytes: 8192
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>

using namespace std;

const int N = 1e6 + 10;
bool f[N];
int n;

int main() {
	cin >> n;
	for (int i = 3; i <= n; i += 3) f[i] = true;
	for (int i = 5; i <= n; i += 5) f[i] = true;

	long long res = 0;
	for (int i = 1; i <= n; i++)
		if (!f[i])
			res += i;

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 4424