akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7ll;

ll N;
ll ans;

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N;

//N=q*m+q
for(ll q=1; q<=1000005; q++){
	if(q>N) continue;
	if(N%q==0){
		ll x=N/q;
		if(x>=2){
			if(q<x-1) ans+=(x-1);
		}	
	}
}

cout<<ans<<endl;

}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int N;
	cin >> N;
	int numsB[120];
	int numsA[120];
	for (int i = 0; i < N - 1; i++)
	{
		cin >> numsB[i];
	}
	numsA[0] = numsB[0];
	numsA[1] = numsB[0];
	for (int i = 1; i < N-1; i++)
	{
		if (numsA[i] > numsB[i])
			numsA[i] = numsB[i];
		numsA[i + 1] = numsB[i];
	}
	int ans = 0;
	for (int i = 0; i < N; i++)
		ans += numsA[i];
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <cmath>
typedef long long ll;
using namespace std;
ll n,m;
double ans = 0, p;
int main()
{
    cin >> n >> m;
    p = pow(0.5,m*1.0);
    for(int i = 0; i < 100000; ++i)
        ans += pow(1-p,i)*p*((n-m)*100.0 + 1900.0*m)*(i+1);
    printf("%.0f\n",ans);
    return 0;
}


Measured memory_bytes: 512
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
//#include <bits/stdc++.h>

#define all(v) v.begin(), v.end()
typedef long long ll;
#define rep(i, z, n) for(int i = z; i < n; i++)
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    int X;
    cin >> X;
    cout << 10 - (X / 200) << endl;
}



Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define ll unsigned long long
#define PI 3.141592653589793238
using namespace std;
int main(){
  	double a,b,x;
	cin>>a>>b>>x;
	double num=2.*x/a/b;
	if(num<=a){
		double ans=2.*x/b/a/b;
		printf("%.10lf",(90.-atan(ans)*180./PI));
	}
	else{
		double tmp=2*b-2.*x/a/a;
		double ans=a/tmp;
		printf("%.10lf",(90.-atan(ans)*180./PI));
	}
  	return 0;
}

Measured memory_bytes: 256
$s = gets.chomp

$len = $s.length
$sum = 0
$hash = {}

def split(arr, l)
  if $len == l || arr.length == $len
    arr[arr.length] = $len
    arr = arr.uniq
    return if $hash[arr]

    arr.each_cons(2) do |i, j|
      $sum += $s[i...j].to_i
      $hash[arr] = true
    end
    return
  end
  
  ($len - l).times do |i|
    a = arr + [l + i]
    split(a, l + i)
  end
end

split([0], 0)
puts $sum


Measured memory_bytes: 14540
n = int(input())
d = {'AC':0,'WA':1, 'TLE':2, 'RE':3}
a = ['AC x', 'WA x', 'TLE x', 'RE x']
ans_list = [0]*4
for _ in range(n):
    s = input()
    ans_list[d[s]]+=1
[print(a[i],ans_list[i]) for i in range(4)]

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

int main(){
  int n; cin >>n;
  int t[100100], x[100100], y[100100];
  t[0] = x[0] = y[0] = 0;
  rep(i,n) cin >>t[i+1] >>x[i+1] >>y[i+1];
  bool can = true;
  rep(i,n){
    int dist = abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
    int dt = t[i+1]-t[i];
    if(dt<dist) can = false;
    if(dt%2!=dist%2) can = false;
  }
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <math.h>

int main()
{
    double x1,x2,y1,y2;
    scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
    double XX=pow(x1-x2,2);
    double YY=pow(y1-y2,2);
    printf("%f",pow(XX+YY,0.5));
}



Measured memory_bytes: 2140
N = int(input())
A = list(map(int, input().split()))
dp = [[0] * (N+1) for _ in range(N+1)]

for width in range(1, N+1):
    for i in range(N-width+1):
        j = i + width

        if (N - width) % 2 == 0:
            dp[i][j] = max(dp[i+1][j] + A[i], dp[i][j-1] + A[j-1])
        else:
            dp[i][j] = min(dp[i+1][j] - A[i], dp[i][j-1] - A[j-1])

print(dp[0][N])

Measured memory_bytes: 144456
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static int ArgMax<T>(IList<T> a) where T : IComparable<T> { var m = a[0]; var mi = 0; for (var i = 1; i < a.Count; i++) if (m.CompareTo(a[i]) < 0) { m = a[i]; mi = i; } return mi; }
	static int ArgMin<T>(IList<T> a) where T : IComparable<T> { var m = a[0]; var mi = 0; for (var i = 1; i < a.Count; i++) if (m.CompareTo(a[i]) > 0) { m = a[i]; mi = i; } return mi; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		var ans = 0;
		for (var r = 0; r <= I[3]; r += I[0])
			for (var g = 0; g + r <= I[3]; g += I[1])
			{
				var b = I[3] - g - r;
				if (b % I[2] == 0) ans++;
			}
		WriteLine(ans);
	}
}


Measured memory_bytes: 13268
#include <cstdio>
#include <queue>
using namespace std;

const int N = 1e5 + 10;
struct data {
	int val, cos;
	data(int _val = 0, int _cos = 0) {val = _val, cos = _cos;}
}; deque <data> dq;
int K, vis[N];

template <class T> inline void in(T &x) {
	x = 0; int f = 1; char ch = getchar();
	for (; ch<'0' || ch>'9';) {if (ch=='-') f=-1; ch = getchar();}
	for (; ch>='0' && ch<='9';) x = x*10 + ch-'0', ch = getchar();
	x *= f;
}

inline int calc(int K) {
	data u, v;
	for (dq.push_back(data(1, 1)); !dq.empty();) {
		u = dq.front(), dq.pop_front();
		if (!u.val) return u.cos;
		vis[u.val] = 1;
		v = data((u.val + 1) % K, u.cos + 1);
		if (!vis[v.val]) dq.push_back(v);
		v = data((u.val * 10) % K, u.cos);
		if (!vis[v.val]) dq.push_front(v);
	}
	return 0;
}

inline void work() {
	in(K), printf("%d\n", calc(K));
}

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

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> nums(n);
    for (int i = 0; i < n; i++) {
      cin >> nums[i];
    }
    vector<int> costs(n);
    costs[0] = 0;
    costs[1] = abs(nums[1] - nums[0]);
    for (int i = 2; i < n; i++) {
      costs[i] = min(abs(nums[i] - nums[i-1]) + costs[i-1], abs(nums[i] - nums[i-2]) + costs[i-2]);
    }
    cout << costs[n-1] << endl;
    return 0;
}


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

int main() {
  ll N;
  cin>>N;
  vector<ll> V(5);//M,A,R,C,Hから始まる人の数をカウント
  rep(i,N){
    string S;
    cin>>S;
    if(S[0]=='M')V[0]++;
    if(S[0]=='A')V[1]++;
    if(S[0]=='R')V[2]++;
    if(S[0]=='C')V[3]++;
    if(S[0]=='H')V[4]++;
  }
  
  //5C3=10通り
  ll ans=0;
  for(int i=0;i<=2;i++){
    for(int j=i+1;j<=3;j++){
      for(int k=j+1;k<=4;k++){
        ans += V[i]*V[j]*V[k];
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
from collections import Counter
from collections import defaultdict


def p_d():
    n = int(input())
    *s, = map(int, input())
    nums = Counter(s)
    ans = 0
    alr_1 = set()
    for i in range(n - 2):
        nums[s[i]] -= 1
        if s[i] in alr_1:
            continue
        alr_1.add(s[i])
        alr_2 = set()
        tmp = defaultdict(int)
        for j in range(i + 1, n - 1):
            nums[s[j]] -= 1
            tmp[s[j]] += 1
            if s[j] in alr_2:
                continue
            alr_2.add(s[j])
            for key in nums.keys():
                if nums[key] == 0:
                    continue
                # print(s[i], s[j], key)
                ans += 1
        for key in tmp.keys():
            nums[key] += tmp[key]
    print(ans)
    
p_d()

Measured memory_bytes: 42736
// Author: Harshdeep Sharma , IIT  Indore
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
// #define MOD  998244353
#define ll long long
const double PI = atan(1.0) * 4;
// const ll INF = (int)1e9 ;
const int di[4] = { -1, 0, 1, 0} ;
const int dj[4] = {0, -1, 0, 1} ;
const ll INF = (ll)2e18 + 50;
const int maximum  = numeric_limits<int>::max();
const int minimum  = numeric_limits<int>::min();
// const int N = 1e5 + 5 ;
const ll mod = 1e9 + 7 ;
// const int N = 1e5 + 5 ;

ll power(ll a , ll e) {
	ll res = 1LL ;
	while (e > 0) {
		if (e % 2 == 1) res = res * a;
		a =  a * a  ;
		e /= 2 ;
	}
	return res ;
}






int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// int t ;
	// cin >> t ;
	// while (t--) {
	ll x , k , d ;
	cin >> x >> k >> d ;
	ll ans ;
	x = abs(x) ;
	if (k <= x / d) {
		ans = x - k * d ;
	} else {
		k -= x / d ;
		if (k % 2 == 0) {
			ans = x - d * (x / d) ;
		} else {
			ans = d - (x - d * (x / d)) ;
		}
	}
	cout << ans << "\n";



// }



	return 0 ;
}





Measured memory_bytes: 3640
// Problem : C - Go Home
// Contest : AtCoder Regular Contest 070
// URL : https://atcoder.jp/contests/arc070/tasks/arc070_a
// Memory Limit : 256.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
#include<chrono>
using namespace std::chrono; 
using namespace std;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define maxin(v) *max_element(v.begin(), v.end())
#define minin(v) *min_element(v.begin(), v.end())
#define sumall(vect) accumulate(vect.begin(), vect.end(), 0)
//#define count(x, vect) count(vect.begin(), vect.end(), x)
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 100000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "------------------------------------\n"
//#define min(a, b, c) min(a, min(b, c))
//#define max(a, b, c) max(a, max(b, c))
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,temp;
string str;
set<ll> s;
vll v;
ll x,y,c;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	auto start = high_resolution_clock::now(); 
	cin>>a>>b>>c;
	cin>>x>>y;
	ll mi=llmax;
	for(int i=0;i<=x;i++)
	{
		mi=min(mi,a*i+c*(2*(x-i))+b*max((ll)0,y-(x-i)));
	}
	for(int i=0;i<=y;i++)
	{
		mi=min(mi,b*i+c*2*(y-i)+a*max((ll)0,x-(y-i)));
	}
	cout<<mi;
	return 0;
	auto stop = high_resolution_clock::now();
	auto duration = duration_cast<microseconds>(stop - start); 
	cout<<"\nRun time = ";
	cout <<fixed<<setprecision(5)<<(long double)duration.count()/1000<<" ms";
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] lines = br.readLine().split(" ");
        int n = 0;
        int[] diceList = new int[6];
        while (n < lines.length) {
            diceList[n] = Integer.parseInt(lines[n++]);
        }
        Dice d = new Dice(diceList);
        String order = br.readLine();
        for(char c:order.toCharArray()){
            d.roll(c);
        }
        System.out.println(d.x[0]);
    }

    private static void print(Dice d) {
        for (int i = 0; i < 5; i++) {
            System.out.print(d.x[i] + " ");
        }
        System.out.println();
        for (int i = 0; i < 5; i++) {
            System.out.print(d.y[i] + " ");
        }
        System.out.println();
    }
}

class Dice {
    int[] dimension = new int[6];
    int[] y = new int[5];
    int[] x = new int[5];

    Dice(int[] d) {
        this.dimension = d;
        x = new int[] { d[0], d[2], d[5], d[3], d[0] };
        y = new int[] { d[0], d[1], d[5], d[4], d[0] };
    }

    void roll(char n) {
        switch (n) {
        case 'N':
            for (int i = 0; i < 5; i++) {
                y[i] = y[(i + 1) % 5];
            }
            break;
        case 'E':
            for (int i = 3; i >= -1; i--) {
                x[i + 1] = x[(i + 5) % 5];
            }
            break;
        case 'S':
            for (int i = 3; i >= -1; i--) {
                y[i + 1] = y[(i + 5) % 5];
            }
            break;
        case 'W':
            for (int i = 0; i < 5; i++) {
                x[i] = x[(i + 1) % 5];
            }
            break;
        }
        if(n=='N'||n=='S'){
            x[0] = y[0];
            x[4] = y[0];
            x[2] = y[2];
        }else{
            y[0] = x[0];
            y[4] = y[0];
            y[2] = x[2];
        }
    }
}

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

int main()
{
    int n;
    cin>>n;
    vector<long long> l(n+1);
    l.at(0)=2;
    l.at(1)=1;
    for(int i=2;i<n+1;i++){
        l.at(i)=l.at(i-1)+l.at(i-2);
    }
    cout<<l.at(n)<<endl;
}

Measured memory_bytes: 256
def solve(a, b, c, x):
    return sum(
        x == 500 * i + 100 * j + 50 * k
        for i in range(a + 1) # 500円
        for j in range(b + 1) # 100円
        for k in range(c + 1) # 50円
    )

_a = int(input())
_b = int(input())
_c = int(input())
_x = int(input())
print(solve(_a, _b, _c, _x))


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

const int N = 1e5 + 5;


int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
  
    int n,m,c;
    cin>>n>>m>>c;
    vector<int> b(m);
    for (int i = 0; i < m; i++)cin>>b[i];
    int ans = 0, temp;
    for (int i = 0; i < n; i++){
        int curans = 0;
        for (int j = 0; j < m; j++){
            cin>>temp;
            curans += temp  * b[j];
        }
        
        if(curans + c>0)ans++;
        
    }
    cout<<ans<<endl;
    return 0;
}


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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const ll MOD = 998244353;

int main() {
	int N; cin >> N;
	V<int> D(N); rep(i, N) cin >> D[i];

	V<int> cnt(N);
	rep(i, N) ++cnt[D[i]];
	int M = *max_element(ALL(D));

	bool ok = 1;
	if (D[0] != 0 || cnt[0] != 1) {
		ok = 0;
	}
	ll ans = 1;

	for (int i = 1; i <= M; ++i) {
		if (cnt[i] == 0) {
			ok = 0;
		}
		rep(j, cnt[i]) {
			ans = ans * cnt[i-1] % MOD;
		}
	}
	if (!ok) ans = 0;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int n,a,b,c,d; cin >> n >> a >> b >> c >> d;
    a--; b--; c--; d--;
    string s; cin >> s;
    if(c < b || (c > b && c < d)){
        bool ok = true;
        repr(i,a,c){
            if(s[i] == '#' && s[i+1] == '#') ok = false;
        }
        repr(i,b,d){
            if(s[i] == '#' && s[i+1] == '#') ok = false;
        }
        cout << (ok?"Yes":"No") << endl;
    }
    else{
        bool ok = false;
        repr(i,a,c){
            if(s[i] == '#' && s[i+1] == '#'){
                cout << "No" << endl;
                return 0;
            }
        }
        repr(i,b-1,d){
            if(s[i] == '.' && s[i+1] == '.' && s[i+2] == '.') ok = true;
        }
        cout << (ok?"Yes":"No") << endl;

    }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
typedef long long int ll;
typedef unsigned long long ull;
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;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};

int main(){
    int a,b,c; cin >> a >> b >> c;
    int k; cin >> k;
    bool flag = false;

    for(int i = 0; i < k; i++){
        if(a >= b){
            b *= 2;
            continue;
        }else if(b >= c){
            c *= 2;
            continue;
        }

    }
    
    if(a < b && b < c)flag = true;

    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }



}

Measured memory_bytes: 3604
s = str(input())
rs = s[::-1]

def str_to_num(pattern): 
  rp = pattern[::-1]
  r = []
  r.append(int(rs[0]))
  tmp = 0
  for i in range(0, len(rp)):
    if int(rp[i]):
      tmp += 1
    else:
      tmp = 0
    r.append(int(rs[i+1]) * 10**tmp)
  return r

def dfs45(i, p):
    if i == len(s) - 1:
        return str_to_num(p)
    else:        
        r_l =  dfs45(i + 1, p + "0")
        r_l += dfs45(i + 1, p + "1")
    return r_l
    
result = dfs45(0, "")
print(sum(result))

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

using namespace std;

int main() {
	long long n, m;
	cin >> n >> m;
	if(n == 1 || m == 1) {
		cout << 1 << '\n';
	} else {
		cout << (n * m + 1) / 2 << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sci1(a) scanf("%d",&a)
#define sci2(a,b) scanf("%d %d",&a,&b)
#define sci3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define scs(s) scanf("%s",s)
#ifndef GET_MACRO

#define GET_MACRO(__1,__2,__3,NAME,...) NAME

#endif // GET_MACRO

#define sci(...) GET_MACRO(__VA_ARGS__,sci3,sci2,sci1)(__VA_ARGS__)
#define ll long long
#define pii pair<int,int>
#define mp(a,b) make_pair(a,b)
#define LSB(i) ((i)&(-i))
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)
#define infl 0x7ffffffffffffff
#define infi  0x7fffffff
#define fill_(a,b) fill(a.begin(),a.end(),b)
#define pb push_back
#define xx first
#define yy second
int main(){
    int n,tmp;
    sci(n);
    ll ans=0;
    ll cnt=0;
    for(int i=0;i<n;i++){
        sci(tmp);
        if(tmp==0){
            ans+=cnt/2;
            cnt=0;
        }
        else{
            cnt+=tmp;
        }
    }
    ans+=(cnt/2);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
def main():
    N,M = map(int, input().split())
    req = [[0,0] for i in range(M)]
    for i in range(M):
        a,b = map(lambda x:x-1, map(int, input().split()))
        req[i] = [b,a]
    # bの昇順にソートして小さいbから叶えていく
    req = sorted(req)
    ans = 1
    pos = req[0][0]-1
    for i in range(1,M):
        b,a = req[i]
        if pos<a:
            # できるだけ右の橋を取り除く
            ans += 1
            pos = b-1
    print(ans)

main()


Measured memory_bytes: 20860
package main

import (
	"bufio"
	"fmt"
	"os"
)

const (
	initialBufSize = 10000
	maxBufSize     = 100000000
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	return sc
}()

// Input string
func scanString() (s string) {
	sc.Scan()
	return sc.Text()
}

func main() {
	S := scanString()
	T := scanString()

	if len(T) == len(S)+1 {
		for i := 0; i < len(S); i++ {
			if S[i] != T[i] {
				fmt.Println("No")
				return
			}
		}
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
	return
}


Measured memory_bytes: 1756
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
const int INT_INF = 500000000;
const long long LONG_LONG_INF = (long long)pow(10, 18);
const int MOD = pow(10, 9) + 7;
/* contest template */
int N, X;
int m[100];
int mini = INT_INF;
int sum;
int ans;

int main() {
  cin >> N >> X;
  for (int i = 0; i < N; i++) {
    cin >> m[i];
    sum += m[i];
    if (mini > m[i]) mini = m[i];
  }
  ans += N;
  X -= sum;
  ans += X / mini;
  cout << ans << endl;

  return 0;
}

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

int main(){
    int n;
    cin>>n;
    int p[n];
    for(int i=0;i<n;i++) cin>>p[i];
    int count=1;
    int min=p[0];
    for(int i=1;i<n;i++){
        if(min>p[i]){
            count++;
            min=p[i];
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 1024
import sys


class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n

    def _root(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self._root(self.table[x])
            return self.table[x]

    def find(self, x, y):
        return self._root(x) == self._root(y)

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            if d1 == d2:
                self.table[r1] -= 1
        else:
            self.table[r1] = r2


def dfs(s, lim):
    q = [s]
    visited[s] = True

    while q:
        v = q.pop()
        for y, u, i in links[v]:
            if y > lim:
                continue
            use[i] = 2
            if visited[u]:
                continue
            visited[u] = True
            q.append(u)


n, m = map(int, input().split())
xxx = list(map(int, input().split()))
links = [set() for _ in [0] * n]
links2 = []
for i, line in enumerate(sys.stdin.readlines()):
    a, b, y = map(int, line.split())
    a -= 1
    b -= 1
    links[a].add((y, b, i))
    links[b].add((y, a, i))
    links2.append((y, a, b, i))

srt_links = sorted(links2)

uft = UnionFind(n)
connected_sum = xxx[:]
use = [0] * m  # 0: ambiguous, 1: usable, 2: fixed

for y, a, b, i in srt_links:
    if uft.find(a, b):
        r = uft._root(a)
    else:
        ra = uft._root(a)
        rb = uft._root(b)
        uft.union(a, b)
        r = uft._root(a)
        connected_sum[r] += connected_sum[rb if r == ra else ra]
    if connected_sum[r] >= y:
        use[i] = 1

ans = 0
visited = [False] * n
for y, a, b, i in reversed(srt_links):
    if use[i] == 2:
        continue
    if use[i] == 0:
        ans += 1
        continue
    dfs(a, y)

print(ans)


Measured memory_bytes: 74668
# frozen_string_literal: true

n = gets.to_i
array = gets.split.map(&:to_i)

m = array.uniq.size

case m
when 1
  if array.first == 0
    puts 'Yes'
    exit
  end
when 2
  x, y = array.uniq.sort
  if x == 0 && array.count(y) == 2 * n / 3 && array.count(x) == n / 3
    puts 'Yes'
    exit
  end

when 3
  x, y, z = array.uniq
  if x ^ y ^ z == 0 &&
     array.count(x) == n / 3 && array.count(y) == n / 3 && array.count(z) == n / 3
    puts 'Yes'
    exit
  end
end

puts 'No'


Measured memory_bytes: 12548
N = int(input())
H = list(map(int, input().split()))

ans = 0
ctr = 0
for i in range(1, len(H)):
	if H[i - 1] < H[i]:
		ans = max(ans, ctr)
		ctr = 0
	else:
		ctr += 1
		ans = max(ans, ctr)
print(max(ans, ctr))

Measured memory_bytes: 63856
#include <cctype>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

const int N = 1 << 19, INF = 0x3f3f3f3f;

int nextInt() {
  char ch;
  while (!isdigit(ch = getchar())) {}
  int res = ch - '0';
  while (isdigit(ch = getchar())) res = 10 * res + ch - '0';
  return res;
}

class Seg {
  int data[N << 1];
 public:
  void clear() {
    memset(data, 0x3f, sizeof data);
  }
  void modify(int p, int v) {
    data[p += N] = v;
    while (p >>= 1) data[p] = std::min(data[p << 1], data[p << 1 | 1]);
  }
  int query(int l, int r) {
    int res = INF;
    for (l = l + N - 1, r = r + N + 1; l ^ r ^ 1; l >>= 1, r >>= 1) {
      if (!(l & 1)) res = std::min(res, data[l + 1]);
      if (r & 1) res = std::min(res, data[r - 1]);
    }
    return res;
  }
} seg;

int n, k, p[N];
std::vector<int> adj[N];

int deg[N];

inline void link(int a, int b) {
  adj[a].push_back(b);
  ++deg[b];
}

int main() {
  scanf("%d%d", &n, &k);
  static int pos[N];
  for (int i = 1; i <= n; ++i) pos[p[i] = nextInt()] = i;
  seg.clear();
  for (int i = 1; i <= n; ++i) {
    if (i > k) seg.modify(p[i - k], INF);
    int j = seg.query(p[i], n);
    if (j < INF) link(i, pos[j]);
    seg.modify(p[i], p[i]);
  }
  seg.clear();
  for (int i = n; i > 0; --i) {
    if (i + k <= n) seg.modify(p[i + k], INF);
    int j = seg.query(p[i], n);
    if (j < INF) link(i, pos[j]);
    seg.modify(p[i], p[i]);
  }
  static int heap[N];
  int top = 0;
  for (int i = 1; i <= n; ++i) if (!deg[i]) heap[++top] = -i;
  std::make_heap(heap + 1, heap + top + 1);
  static int ans[N];
  for (int cur = 0; top;) {
    std::pop_heap(heap + 1, heap + top + 1);
    int a = -heap[top--];
    ans[a] = ++cur;
    for (int i = 0; i < adj[a].size(); ++i) {
      int b = adj[a][i];
      if (--deg[b] == 0) {
        heap[++top] = -b;
        std::push_heap(heap + 1, heap + top + 1);
      }
    }
  }
  for (int i = 1; i <= n; ++i) printf("%d\n", ans[i]);
  return 0;
}


Measured memory_bytes: 45696
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
 
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int N, A, B;

int main()
{
    cin >> N;
    cin >> A >> B;
    if( (B - A) % 2 == 0)
    {
        cout << "Alice" << endl;
    }
    else if( (B - A) % 2 == 1)
    {
        cout << "Borys" << endl;
    }
}

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

int main(){
	int n,num,pt,memo_n,memo_p;
  	
  	cin >> n;
  
  	rep(i,0,n){
      cin >> num >> pt;
      if(i == 0){
        memo_n = num;
        memo_p = pt;
      }
      else if(pt < memo_p){
		memo_n = num;
        memo_p = pt;
      }
    }
  
  	cout << memo_n+memo_p << endl;
	return 0; 
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

ll mod_pow(ll n, ll k) {
    ll res = 1;
    for(; k>0; k>>=1) {
        if(k & 1) (res *= n) %= MOD;
        (n *= n) %= MOD;
    }
    return res;
}

// AB どっちも埋まってない・ここまでの移動距離
ll dp[51][51][2510];
int main() {
    int N, K; cin >> N >> K;
    dp[0][N][0] = 1;
    for(int i=1; i<=N; i++) (dp[0][N][0] *= mod_pow(i, MOD-2)) %= MOD;

    for(int i=0; i<N; i++) {
        int num = N - i;
        for(int j=0; j<=N; j++) {
            // どっちも埋まっている
            int s0 = 2 * i - (N - j);
            // どっちかが埋まっている個数
            int s1 = N - j - s0;
            if(s0 < 0 or s0 > N or s1 < 0 or s1 > N) continue;
            int s2 = j;

            // fprintf(stderr, "i = %d, j = %d, s0 = %d, s1 = %d, s2 = %d\n", i, j, s0, s1, s2);

            for(int k=0; k<=N*N; k++) {
                if(!dp[i][j][k]) continue;
                // どっちも埋まっていないものを 1 つ消費し、
                // 同じ値を入れる
                if(j >= 1) {
                    (dp[i+1][j-1][k] += j * dp[i][j][k]) %= MOD;
                }

                // どっちも埋まっていないものを 2 つ消費し、
                // おなじ値をそれぞれ別のところに入れる
                if(j >= 2) {
                    (dp[i+1][j-2][k + 2*num] += j * (j-1) * dp[i][j][k]) %= MOD;
                }

                // s2 を 1 個、s1 を 1 個消費
                if(s2 >= 1 and s1 >= 1) {
                    (dp[i+1][j-1][k] += 2 * s2 * (s1/2) * dp[i][j][k]) %= MOD;
                }
                // s1 を 2 個消費
                if(s1 >= 2) {
                    (dp[i+1][j][k - 2*num] += (s1/2) * (s1/2) * dp[i][j][k]) %= MOD;
                }     
            }
        }
    }
    int ans = dp[N][0][K];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 47360
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string a,b;
	cin >> a >> b;
	if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0]){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int ans,i,j,k,n,m;
int calc(int x){
	int i,res=0;
	for (i=x;i;i/=10) res=res+i%10;
	return res;
}
int main(){
	scanf("%d",&n);ans=1000000;
	for (i=1;i<n;i++) ans=min(ans,calc(i)+calc(n-i));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		System.out.println(solve());
	}
	
	public static String solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		StringBuffer sb = new StringBuffer();
		int max = 0, min = 0;
		if (M > N) {
			max = M;
			min = N;
		}
		else {
			max = N;
			min = M;
		}
			for (int i = 0; i < max; i++) {
				sb.append(min);
			}
		return sb.toString();
	}
}

Measured memory_bytes: 21332
#include<iostream>
using namespace std;
int main(){
	double W, H , x , y;
	int judge;
	cin >> W >> H >> x >> y;
	if (W == 2 * x&&H == 2 * y){
		judge = 1;
	}
	else judge = 0;
	cout << (W*H) / 2 << " " << judge << endl;
	return 0;
}

Measured memory_bytes: 256
// █   https://www.youtube.com/watch?v=Dx6OQ7RvDXc

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

typedef long long ll;
typedef long double ld;
typedef long long unsigned llu;
typedef pair<long long, long long> pll;
const long long inf = 2000000000000000000LL;	// 2e18
#define pi                  acos(-1.0)
#define fast                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define shesh               "\n"
#define ff                  first
#define ss                  second
#define pb                  push_back
#define bp                  pop_back
#define pf                  push_front
#define fp                  pop_front
#define ub                  upper_bound
#define lb                  lower_bound
#define all(x)              x.begin(), x.end()
#define debug(x)            cout<<"debug "<<x<<"\n"
#define mest(a,b)           memset(a,b,sizeof(a))

int main(){
    fast;
    ll t,n,m,i,j,k,l,temp,flag,len,shit,q,res,ans,p;
    cin>>n>>p;
    cout<<n-p+1;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,int>;
using ll=long long;

int main() {
  int N;
  cin >> N;
  vector<int> D(2*N);
  for (int i=0; i<2*N; i++) {
    cin >> D[i];
  }
  string ans="No";
  for (int i=0; i<2*N-4; i+=2) {
    if (D[i]==D[i+1] && D[i+2]==D[i+3] && D[i+4]==D[i+5]) {
      ans = "Yes";
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int total = Integer.parseInt(sc.next());
        List<Integer> list = new ArrayList<>();
        for (int x =1; x <= total ; x++) {
            list.add(Integer.parseInt(sc.next()));
        }
        int res = 0;
        for (int x =1; x <= total-2 ; x++) {
            int first = list.get(x-1);
            int second = list.get(x);
            int third = list.get(x+1);
            if (first<second && second<third) {
                res++;
            }
            if (second<first && third<second) {
                res++;
            }
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
	
	int N;
	
	cin>>N;
	for(int i = 0; i*4 <= N; i++){
		for(int j = 0; j*7+i*4 <= N; j++){
			if(i*4+j*7==N){cout<<"Yes"<<endl;return 0;}
		}
	}
	cout<<"No"<<endl;
	
	
	
	return 0;
}

Measured memory_bytes: 256
/*
*****************************************************************************************
*                               snow man                                                *
*                                                                                       *
*****************************************************************************************
*/

#include <bits/stdc++.h>
using namespace std;
char S[17]="CODEFESTIVAL2016";

int main()
{
    char S1[18];

    while(scanf("%s", S1)!=EOF) {
        int i, c=0;

        //counting
        for(i=0; S1[i]; i++)
            if(S[i]!=S1[i]) c++;


        printf("%d\n", c);
    }



    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <queue>

using namespace std;



int _W, _H;
int W, H;

int map[500][500];

struct state {
	int x, y, d;
	state(int _x, int _y, int _d) : x(_x), y(_y), d(_d) {}
};

int dx[4] = {-1, 0, 1, 0};
int dy[4] = { 0,-1, 0, 1};

int solver() {
	int ans = (int)1e9;
	
	int gx = W-1, gy = H-1;
	
	queue<state> q;
	q.push(state(0, 0, 1));
	
	while (!q.empty()) {
		state s = q.front(); q.pop();
		
		if (s.d >= ans) continue;
		
		if (s.x == gx && s.y == gy) {
			ans = min(ans, s.d);
			continue;
		}
		
		for (int i=0; i<4; i++) {
			if (!(0 <= s.y + dy[i] && s.y + dy[i] < H && 0 <= s.x + dx[i] && s.x + dx[i] < W)) continue;
		
			if (map[s.y + dy[i]][s.x + dx[i]] == 0) {
				map[s.y + dy[i]][s.x + dx[i]] = -1;
				map[s.y + 2 * dy[i]][s.x + 2*dx[i]] = -1;
				q.push(state(s.x + 2*dx[i], s.y + 2*dy[i], s.d + 1));
			}
		}
	}
	
	if (ans == (int)1e9) ans = 0;
	return ans;
}

int main() {
	
	while (1) {
		cin >> _W >> _H; if (_W == 0 && _H == 0) break;
		W = 2*_W - 1; H = 2*_H - 1;
		
		memset(map, 0, sizeof(map));
		cin.ignore();
		
		string str;
		for (int i=0; i<H; i++) {
			getline(cin, str);
			
			int n = (int)str.size();
			for (int j=0; j<n; j++) {
				if (str[j] == '1') {
					map[i][j] = 1;
				}
			}
		}
		
		cout << solver() << endl;
	}
	
	return 0;
}

Measured memory_bytes: 2204
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << " = " << x << ".\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define print(xx) cout << (xx) << endl
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
const int INF = ((1LL << 30) + (1LL << 29));
const ll MOD = 1000000007;

/* 
*/
//================== INPUT ========================
int N, Q;
vector<tuple<int, int, int>> R;
vector<int> D;
//=================================================
//=================================================
void input()
{
    cin >> N >> Q;
    R.resize(N);
    D.resize(Q);
    rep(i, N) cin >> get<0>(R[i]) >> get<1>(R[i]) >> get<2>(R[i]);
    rep(i, Q) cin >> D[i];
}
//=================================================
void solve()
{
    vector<pii> events;
    for (auto x : R)
    {
        events.push_back(make_pair(get<0>(x) - get<2>(x), get<2>(x)));
        events.push_back(make_pair(get<1>(x) - get<2>(x), -get<2>(x)));
    }
    sort(events.begin(), events.end());

    multiset<int> s;

    auto iter = events.begin();
    int i = 0;

    for (auto q : D)
    {
        for (; i < 2 * N; ++i)
        {
            if (events[i].first > q)
            {
                break;
            }
            int ev = events[i].second;
            if (ev > 0)
            {
                s.insert(ev);
            }
            else
            {
                s.erase(s.lower_bound(-ev));
            }
        }
        cout << ((s.empty()) ? (-1LL) : (*s.begin())) << endl;
    }
}

//=================================================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 24552
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd); FUNC(printde);
#endif

template <class F>
auto rec(F f){
    return [&](auto&&... args){ return f(f, args...); };
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s; cin >> s;
    // auto one = [&](int i){ return s[i] == '1'; };
    auto zero = [&](int i){ return s[i] == '0'; };
    vector<string> vs;
    int idx = 0, prev = 0;
    while(idx < n && zero(idx)){ ++idx; }
    prev = idx;
    while(idx <= n){
        if(idx == n || (zero(idx) && (zero(idx + 1) || idx + 1 == n))){
            if(idx - prev){
                vs.push_back(s.substr(prev, idx - prev));
            }
            idx += 2;
            while(idx < n && zero(idx)){ ++idx; }
            prev = idx;
        }
        ++idx;
    }
    prints(vs);
    int ans = 0;
    for(auto& str : vs){
        int n = str.size();
        auto one = [&](int i){ return str[i] == '1'; };
        auto zero = [&](int i){ return str[i] == '0'; };
        vector<int> memo(n, -1);
        auto f = rec([&](auto f, int idx){
            if(idx < 0 || idx >= n){ return 0; }
            if(memo[idx] != -1){ return memo[idx]; }
            int idx0 = idx;
            if(zero(idx)){ return memo[idx0] = f(f, idx + 1); }
            int start = idx;
            while(idx < n && one(idx)){ ++idx; }
            if(idx == n){ return memo[idx0] = 0; }
            int a1 = idx - start + f(f, idx + 2);
            int a2 = f(f, idx + 1);
            ++idx;
            start = idx;
            while(idx < n && one(idx)){ ++idx; }
            int a3 = idx - start + f(f, idx + 1);
            int a4 = idx - start - 1 + f(f, idx - 1);
            return memo[idx0] = max({a1, a2, a3, a4});
        });
        ans += f(0);
        prints(f(0));
    }
    cout << ans << '\n';
}


Measured memory_bytes: 5492
#include <map>
#include <algorithm>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <string>
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;

template<class T> bool chmin(T &a, T b) { return a>b?(a=b,true):false; }
template<class T> bool chmax(T &a,T  b) { return a<b?(a=b,true):false; }
#define forn(i,x,y) for(int i=(x);i<(int)(y);i++)
#define rep(i,y) for(int i=0;i<(int)(y);i++)
#define repb(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)

template<class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << " ";
    os << *it;
  }
  return os;
}

int a[200020];
int b[200020];
int n;
ll ans;
const int mod=1e9+7;
int main() {
    cin >> n;
    rep(i,n) {
        cin>>a[i];
    }
    b[n-1] = a[n-1];
    repb(i,n-1) {
        b[i] = (b[i+1] + a[i]) % mod;
    }
    rep(i,n-1) {
        ans += ((ll)a[i]*b[i+1]) % mod;
        ans %= mod;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5136
#include <bits/stdc++.h>
#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;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const int INF=1e9;

int main(){
  ll a,b,n;
  cin>>a>>b>>n;
  ll x=min(b-1,n);
  cout<< (a*x)/b-a*(x/b)<<endl;
  return 0;


}

Measured memory_bytes: 3624
# 入力
n = int(input())

# 処理
sum = 0

for i in range(1, n + 1):
    if i % 15 == 0:
        i = 'FizzBuzz'
    elif i % 3 == 0:
        i = 'Fizz'
    elif i % 5 == 0:
        i = 'Buzz'
    else:
        sum += i

print(sum)

Measured memory_bytes: 9056
#include<stdio.h>
#include<math.h>

int main (void)
{
	int input1;
	int i,x;
	
	scanf("%d",&input1);
	for(i = 3 ; i <= input1 ; i++)
	{
		if(i % 3 == 0)
		{
			printf(" %d",i);
		}
		else
		{
			x = i;
			do
			{
				if(x % 10 == 3)
				{
					printf(" %d",i);
					break;
				}
				else
				{
					x /= 10;
				}
			}while(x);
		}
	}
	printf("\n");
	return 0;
}


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

int main(){
    string s, t, u; int a, b;
    cin >> s >> t >> a >> b >> u;

    cout << ((s == u) ? a - 1 : a) << " " << ((s == u) ? b : b - 1) << endl;
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
int main(){
    int x ;
    int n ;
    cin >> x >> n;
    vector<int> p (n);
    rep(i, n){
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    vector<int> notp ;
    rep(i, 110){
        bool there = true;
        rep(j, n){
            if (p[j] == i){
                there = false;
            }
        }
        if (there){
            notp.push_back(i);
        }
    }
    int k = notp.size();
    vector<int> ans ;
    int minnum = 1000;
    rep(i, k){
        int l = abs(notp[i] - x) ;
        if (l < minnum){
            ans = {};
            ans.push_back(notp[i]);
            minnum = l ;
        }
        else if (l = minnum){
            ans.push_back(notp[i]);
        }
        else {
            continue;
        }
    }
    sort(ans.begin(), ans.end());
    cout << ans[0] << endl;    
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#define MOD_P 1000000007
#define ll long long
using namespace std;



int main()
{
	int a, b;
	cin >> a >> b;

	if ((a + b) % 2) {
		printf("IMPOSSIBLE");
	} else {
		printf("%d", (a + b) / 2);
	}

	return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

template <int n>
struct UnionFind{
    UnionFind(){
        for(int i=0;i<n;i++){
            par[i] = i;
            rank[i] = 0;
        }
    }
    int find(int x){
        if(x == par[x])return x;
        return par[x] = find(par[x]);
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y){return;}
        
        if(rank[x] > rank[y]){
            par[y] = x;
        }else{
            par[x] = y;
            if(rank[x] == rank[y]){rank[y]++;}
        }
    }
    int rank[n], par[n];
};

UnionFind<100100> uf;
int washa[100100];

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

    int N, M;
    std::cin >> N >> M;

    for(int i=0;i<N;++i){
        int K;
        std::cin >> K;

        int l0;
        for(int j=0;j<K;++j){
            int l;
            std::cin >> l;
            --l;
            
            if(j == 0){l0 = l;}
            else{
                uf.unite(l0, l);
            }

            ++washa[l];
        }
    }

    int l0 = -1;
    for(int i=0;i<M;++i){
        if(washa[i] == 0){continue;}
        if(l0 == -1){l0 = i; continue;}
        if(!uf.same(l0, i)){
            std::cout << "NO" << std::endl;
            return 0;
        }
    }

    std::cout << "YES" << std::endl;
}


Measured memory_bytes: 1408