akhauriyash/Code-Regression huggingface dataset:
import itertools

N = int(input())

M = [0, 0, 0, 0, 0]

for i in range(N):
    S = input()
    s = S[0]
    
    if s == "M":
        M[0] += 1
    elif s == "A":
        M[1] += 1
    elif s == "R":
        M[2] += 1
    elif s == "C":
        M[3] += 1
    elif s == "H":
        M[4] += 1

ans = 0
for a, b, c in list(itertools.combinations(M, 3)):
    ans += a * b * c

print(ans)

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

int main(void){
   char str1[7],str2[4];
   double sq,input;
   int i,str1l,str2l;

   scanf("%s%s",str1,str2);
   str1l=strlen(str1); str2l=strlen(str2);
  
     for(i=0;i<str2l;i++)
      str1[str1l+i]=str2[i];
   input=(double)atoi(str1);

   sq=sqrt(input);
   sq=sq-(int)sq;
   if(sq==0)printf("Yes\n");
   else printf("No\n");

   return 0;
}


Measured memory_bytes: 128
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 200000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	ll cost;
	edge(int _t, ll _cost) : t(_t)
		, cost(_cost) {
	}
};
bool isPrime(int n) {

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

ll gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll a[200010];
ll m[200010];
set<int> s;
int n;
ll calc(int v) {

	if (v > n) return 0;
	if (left > right) return 0;
	
	int pos = m[v];
	s.insert(pos);
	auto p = s.find(pos);
	
	int left = 0;
	if (p == s.begin()) {
		left = 1;
	}
	else {
		p--;
		left = *p + 1;
		p++;
	}
	int right = 0;
	p++;
	if (p == s.end()) {
		right = n;
	}
	else {
		right = *p - 1;
	}
	ll res = 0;
	ll len = right - left + 1;
	ll relp = pos - left + 1;
	res += ((len - (relp - 1)) * relp) * v;
	res += calc(v + 1);
	return res;
}

void Solve() {
	
	cin >> n;

	ll x = n;
	for (size_t i = 1; i <= n; i++)
	{
		cin >> a[i];
		m[a[i]] = i;
	}
	cout << calc(1) << endl;
}
int main() {
	Solve();
	return 0;
}



Measured memory_bytes: 26240
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  string s, t;
  cin >> s >> t;
  cout << t << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <string>

using namespace std;

int main(void){
	while(1){
		int sum=0,n;
		string str;
		cin>>str;
		if(atoi(str.c_str())==0)
			break;
		n = str.size();
		for(int i=0;i<n;i++){
			sum += str[i] - '0';
		}
		cout<<sum<<endl;
	}
  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = long long ;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n,k;
    cin >> n >> k;
    vi v(n);
    rep(i,n) cin >> v.at(i);
    ll num = min(n,k);
    vi vals;
    rep(i,num+1){
        rep(j,num+1-i){
            ll val = 0;
            vi items;
            ll rest = k-i-j;
            rep(t,i) items.push_back(v.at(t));
            rep(t,j) items.push_back(v.at(n-1-t));
            sort(items.begin(), items.end());
            rep(l,items.size()) val += items.at(l);
            rep(l,rest){
                if(l>=items.size()) break;
                if(items.at(l)<0) val -= items.at(l);
            }
            vals.push_back(val);
            cerr << "i:" << i << " j:" << j << " val:" << val << endl;
        }
    }
    sort(vals.begin(), vals.end(), greater<>());
    cout << vals.at(0) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <cstring>
#include <unordered_set>
#include <unordered_map>

using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const ll INF = 1000010000;
static const ll MOD = 1000000007;
 
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

int main(){
	string s;
	cin >> s;
	REP(i, s.length()){
		if(i % 2 == 0) cout << s[i];
	}
	cout << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 n;
  cin >> n;
  map<string, i64> m;
  for (i64 i = 0; i < n; i++)
  {
    string s;
    cin >> s;
    m[s]++;
  }
  vector<pair<i64, string>> t;
  for (pair<string, i64> i : m)
    t.push_back({i.second, i.first});
  sort(t.begin(), t.end());
  for (pair<i64, string> i : t)
    if (t.back().first == i.first)
      cout << i.second << endl;
  return 0;
}


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

using namespace std;

namespace {
    typedef long long ll;
    ll N, T;
    vector<ll> ts;
    void input() {
        cin >> N >> T;
        ts.resize(N);
        for (int i = 0; i < N; i++) cin >> ts[i];
    }

    void solve() {
        ll ans = 0;
        for (int i = 0; i + 1 < N; i++) {
            auto t = ts[i];
            auto u = ts[i + 1];
            ans += min(T, u - t);
        }
        ans += T;
        cout << ans << endl;
    }
}

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



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

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pii> vii; 
typedef vector<ll> vl; 
typedef vector<vl> vvl; 

double EPS=1e-9; 
int INF=1000000005; 
long long INFF=1000000000000000005ll; 
double PI=acos(-1); 
int dirx[8]={ -1, 0, 0, 1, -1, -1, 1, 1 }; 
int diry[8]={ 0, 1, -1, 0, -1, 1, -1, 1 }; 
const ll MOD = 1000000007;

#define DEBUG fprintf(stderr, "====TESTING====\n") 
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl 
#define OUT(x) cout << x << endl 
#define debug(...) fprintf(stderr, __VA_ARGS__) 
#define READ(x) for(auto &(z):x) cin >> z;
#define FOR(a, b, c) for (int(a)=(b); (a) < (c); ++(a)) 
#define FORN(a, b, c) for (int(a)=(b); (a) <= (c); ++(a)) 
#define FORD(a, b, c) for (int(a)=(b); (a) >= (c); --(a)) 
#define FORSQ(a, b, c) for (int(a)=(b); (a) * (a) <= (c); ++(a)) 
#define FORC(a, b, c) for (char(a)=(b); (a) <= (c); ++(a)) 
#define EACH(a, b) for (auto&(a) : (b)) 
#define REP(i, n) FOR(i, 0, n) 
#define REPN(i, n) FORN(i, 1, n) 
#define MAX(a, b) a=max(a, b) 
#define MIN(a, b) a=min(a, b) 
#define SQR(x) ((ll)(x) * (x)) 
#define RESET(a, b) memset(a, b, sizeof(a)) 
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back 
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define SIZE(v) (int)v.size() 
#define SORT(v) sort(ALL(v)) 
#define REVERSE(v) reverse(ALL(v)) 
#define SORTA(arr, sz) sort(ALLA(arr, sz)) 
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz)) 
#define PERMUTE next_permutation 
#define TC(t) while (t--) 
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)


void solve() {

}

int main()  
{ 
    FAST_INP;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r", stdin);
    freopen("output.txt","w", stdout);
    #endif
    
    // int tc; cin >> tc;
    // TC(tc) solve();
    string s;
    int ans=0, cnt=0;
    cin >> s;
    EACH(i,s){
        if(i=='R'){
            cnt++;
            MAX(ans,cnt);
        }else{
            cnt=0;
        }
    }
    OUT(ans);

    return 0; 
} 

Measured memory_bytes: 3636
import java.util.*;
 public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
		// 整数の入力
      int A1 = sc.nextInt();
      int A2 = sc.nextInt();
      int A3 = sc.nextInt();
      int sum = A1 + A2 + A3;
      if(sum<=21){
        System.out.println("win");
      }else{
        System.out.println("bust");
      }
    }
 }

Measured memory_bytes: 22868
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;
int n;
int *S;
int q,m;

bool combination(int x,int i){
	if(x == 0) return true;
	if(i >= n) return false;
	bool ans = combination(x - S[i],i+1) || combination(x,i+1);
	return ans;
}

int main(){

	cin >> n;
	S = new int[n];

	for(int i = 0;i < n;i++){
		cin >> S[i];
	}
	cin >> q;
	for(int j=0;j<q;j++){
		cin >> m;
		if(combination(m,0)){
			cout << "yes" << endl;
		}else{
			cout << "no" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1184
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<cstring>

#define Mod 1000000007
using namespace std;

int a[200010],g[200010],f[200010],n,as;

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	int n_=n;n=1;
	for (int i=1;i<=n_;i++) if(a[i]!=a[n]) a[++n]=a[i];
	f[0]=1;
	for (int i=1;i<=n;i++){
		f[i]=(g[a[i]]+f[i-1])%Mod;
		g[a[i]]=(g[a[i]]+f[i-1])%Mod;
	}
	printf("%d\n",f[n]);
}

Measured memory_bytes: 2560
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let X: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };

    let mut c = 0;
    let mut d = 0;
    for &x in &X {
      if x == 'S' {
        c += 1;
      } else if c >= 1 {
        c -= 1;
        d += 2;
      }
    }
    let ans = X.len() - d;

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <stdio.h>
int main(void)
{
    int n;
    scanf("%d",&n);
    int a[103]={};
    int b[103]={};
    int tt[103]={0};
    for(int p=0;p<n;p++)
    {
        scanf("%d ",&a[p]);
        for(int r=p;r<n;r++)tt[r]+=a[p];
    }
    for(int q=0;q<n;q++)
    {
        scanf("%d ",&b[q]);
        for(int s=0;s<=q;s++)tt[s]+=b[q];
    }
    
    int ans=0;
    for(int ss=0;ss<n;ss++)
    {
        if(ans<tt[ss])ans=tt[ss];
    }
    printf("%d",ans);
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };


// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}


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

	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];

	int ans = 1;

	vector<ll> gcdL(n), gcdR(n);

	gcdL[1] = a[0];
	gcdR[n - 2] = a[n - 1];

	Rep(i, 1, n - 1) {
		gcdL[i + 1] = gcd(gcdL[i], a[i]);
	}
	for (int i = n - 2; i > 0; i--) {
		gcdR[i - 1] = gcd(gcdR[i], a[i]);
	}

	// 一つの整数をないものとしてカウントしていい
	rep(i, n) {
		int tmp;
		if (i == 0) {
			tmp = gcdR[0];
		}
		if (i == n - 1) {
			tmp = gcdL[n - 1];
		}
		else {
			tmp = gcd(gcdL[i], gcdR[i]);
		}
		ans = max(ans, tmp);
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
    long long n,k;
    cin >> n >> k;
    long long a=n%k;
    long long b=abs(a-k);
    long long ans;
    if(a>=b) ans=b;
    else ans=a;
    cout << ans << endl;
}

Measured memory_bytes: 256
def main(input = $stdin)
  str = input.gets.chomp.split(//)
  stack = Array.new
  lake_size = Array.new(1, 0)
  height = 0
  str.each{|char|
    case char
    when '\\'
      height += 1
      stack.push char
    when '/'
      if height != 0
        width = 1
        while case temp = stack.pop
              when '\\'
                stack.push width + 1
                lake_size.push(lake_size.pop + width)
                lake_size.push 0                
                false
              when Integer
                width += temp
                lake_size.push(lake_size.pop + lake_size.pop)
              else
                width += 1
              end
        end
        height -= 1
      end
    else
      stack.push char
    end
  }
  puts lake_size.reduce(&:+)
  lake_size.pop
  lake_size.unshift(lake_size.size)
  puts lake_size.join(" ")
end
main

Measured memory_bytes: 6976
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int h,w,i,k;
	while(cin>>h>>w){
		if(h==0&&w==w){
			return 0;
			}
		for(k=0;k<h;k++){
			for(i=0;i<w;i++){
				if(k%2==0){
				if(i%2!=0){
				cout<<".";
				}
				else{
				cout<<"#";
				}
				}
				if(k%2!=0){
				if(i%2!=0){
					cout<<"#";
					}
				else{
					cout<<".";
					}
					}
				
			}cout<<endl;
			}cout<<endl;
			}
			return 0;
			}

Measured memory_bytes: 1152
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int read() { return readln.chomp.to!int; }
int[] reads() { return readln.split.to!(int[]); }


void main() {
    int n,i; readf("%d %d\n",&n,&i);
    writeln(n - i + 1);
}


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

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

  vector<int> a(N);
  vector<int> b(N);
  int temp = 1000000000;
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
    if (i == 0) {
      b[i] = -a[i];
    } else {
      temp = min(a[i-1],temp);
      b[i] = a[i] - temp;
    }
  }

  int max_b = *max_element(b.begin(), b.end());
  int answer = count_if(b.begin(), b.end(),[=](int n){ return n == max_b;});

  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define pb push_back
#define mp make_pair
#define fi(i,start,end) for(int i=start; i < end ; ++i)
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
//#define mod 100000000

using namespace std;



int main()
{
    char c;
    cin>>c;
    if ( ( int (c) >= int('a') )&& (int (c) <= int('z') ) )
        cout<<'a';
    else
        cout<<'A';

}









Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner (System.in);
		String s=scan.nextLine();
		String t=scan.nextLine();
		int c=0;
		for(int i=0;i<s.length();i++)
		{
			if(s.charAt(i)==t.charAt(i))
			{
				c+=1;
			}
		}
		if(t.length()==c+1) System.out.println("Yes");
		else System.out.println("No");

	}

}


Measured memory_bytes: 26952
#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 <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int 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;}

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

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

// i マス目を 塗らなかった (好意的解釈) / 白く塗った / 黒く塗った 時の最大値
int N, K, a[100010], acc[100010], accb[100010];

signed main() {
    cin >> N >> K;
    rep(i,0,N) {
        cin >> a[i+1];
        acc[i+1] = acc[i] + a[i+1];
        accb[i+1] = accb[i] + (a[i+1] > 0 ? a[i+1] : 0);
    }

    int ans = -INF, whsum = accb[N];
    repq(i,1,N-K+1) {
        int ub = i + K - 1;
        chmax(ans, acc[ub] - acc[i-1] + whsum - accb[ub] + accb[i-1]);
        chmax(ans, whsum - accb[ub] + accb[i-1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n, d;
    cin >> n >> d;
    d = d * d;
    lli ans = 0;
    rep(i,n){
        lli x,y;
        cin >> x >> y;
        x = x * x;
        y = y * y;
        if(x+y<=d){
            ans++;
        }
    }
    out(ans);
}

Measured memory_bytes: 3668
/*
  Contest 114
  A - 753
  Rakesh Kumar --> 28/09/2020
 */

#include <bits/stdc++.h>

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0); std::cout.tie(0);

    int n = 0;
    std::cin >> n;
    if (n == 3 || n == 5 || n == 7)
        std::cout << "YES" << std::endl;
    else
        std::cout << "NO" << std::endl;

    return 0;
}


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

const int nlimit=10;
int n, m;
bool graph[nlimit][nlimit];
bool visited[nlimit];

int dfs(int);
int main(){
  cin >> n >> m;
  int a, b;
  for(int i=0; i<m; i++){
    cin >> a >> b;
    graph[a][b] = true;
    graph[b][a] = true;
  }

  int ans = dfs(1);

  cout << ans << endl;

  return 0;
}

int dfs(int start){
  visited[start] = true;
  bool f=true;
  for(int i=1; i<=n; i++){
    f = f&&visited[i];
  }
  if(f) {
    visited[start] = false;
    return 1;
  }

  int cnt=0;
  for(int i=1; i<=n; i++){
    if(graph[start][i] && !visited[i]) {
      cnt += dfs(i);
    }
  }

  visited[start] = false;

  return cnt;
}


Measured memory_bytes: 384
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int num[] = new int[n];
      
      for(int i=0;i<n;i++){
        num[i] = sc.nextInt();
      }
      Arrays.sort(num);
      System.out.print(Math.abs(num[0]-num[n-1]));
      
      
    }
}

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

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

typedef long long LL;
typedef long double LD;

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

    if (b/a > c) cout << c << endl;
    else cout << b/a << endl;

    return 0;
}


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


using namespace std;

int main()  
{  
    long long n;
    cin>>n;
    if(n>999)
    cout<<"ABD";
    else
    cout<<"ABC";
    //system("pause");
    return 0;
}  

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

const int N = 200000;
int query = 0;
ll a[N] = {};

vector<char> ops;
vector<int> is, js, ks;

void q(char op, int i, int j, int k) {
  is.emplace_back(i);
  js.emplace_back(j);
  ks.emplace_back(k);
  ++query;
  if (op == '+') {
    ops.emplace_back('+');
    a[k] = a[i] + a[j];
  } else if (op == '<') {
    ops.emplace_back('<');
    a[k] = a[i] < a[j];
  }
}

int main() {
  cin >> a[0] >> a[1];
  const int A_BIT = 30, C_BIT = 60;
  const int A = 0, B = 1, C = 2, ONE = 3, P_BASE = ONE, A_BASE = P_BASE + C_BIT, B_BASE = A_BASE + A_BIT;
  q('+', A, B, ONE);
  q('<', C, ONE, ONE);
  FOR(i, 1, C_BIT) {
    q('+', P_BASE + i, P_BASE + i - 1, P_BASE + i);
    q('+', P_BASE + i, P_BASE + i, P_BASE + i);
  }
  for (int i = A_BIT - 1; i >= 0; --i) {
    REP(j, i) q('+', A_BASE + i, P_BASE + j, A_BASE + i);
    FOR(j, i + 1, A_BIT) q('+', A_BASE + i, A_BASE + j, A_BASE + i);
    q('<', A_BASE + i, A, A_BASE + i);
    REP(_, i) q('+', A_BASE + i, A_BASE + i, A_BASE + i);
  }
  REP(i, A_BIT) q('<', C, A_BASE + i, A_BASE + i);
  for (int i = A_BIT - 1; i >= 0; --i) {
    REP(j, i) q('+', B_BASE + i, P_BASE + j, B_BASE + i);
    FOR(j, i + 1, A_BIT) q('+', B_BASE + i, B_BASE + j, B_BASE + i);
    q('<', B_BASE + i, B, B_BASE + i);
    REP(_, i) q('+', B_BASE + i, B_BASE + i, B_BASE + i);
  }
  REP(i, A_BIT) q('<', C, B_BASE + i, B_BASE + i);
  int tmp = N - 1;
  REP(i, A_BIT) REP(j, A_BIT) {
    q('+', A_BASE + i, B_BASE + j, tmp);
    q('<', ONE, tmp, tmp);
    REP(_, i + j) q('+', tmp, tmp, tmp);
    q('+', C, tmp--, C);
  }
  assert(query <= N && a[0] * a[1] == a[2]);
  cout << query << '\n';
  REP(i, query) cout << ops[i] << ' ' << is[i] << ' ' << js[i] << ' ' << ks[i] << '\n';
  return 0;
}


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


void solve(long long N){
  map<long long, long long> counts;
  long long count = 0;
  for(long long i = 1; i <= N; i++){
    counts[floor((long double)log10(i))+1]++;
    if((long long)(floor((long double)log10(i))+1) % 2 == 1) count++;
  }

  cout << count << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3892
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

// value
ll dp[110][100010];
ll w[110], v[110];

void solve() {

	int N, W;
	cin >> N >> W;
	for (int i = 1; i <= N; i++) {
		cin >> w[i] >> v[i];
	}

	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= W; j++) {
			if (j - w[i] < 0) {
				dp[i][j] = dp[i - 1][j];
				continue;
			}
			dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
		}
	}

	cout << dp[N][W] << endl;

	return;

}

int main() {

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

	solve();

	return 0;

}

Measured memory_bytes: 79360
/*  
     author : masaow    
     g++ : 17.3.20  
*/        
#include <bits/stdc++.h>  
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << " -- \n  "
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll                 long long  
#define p(x)               cout << x << "\n" ; 
#define MOD                100000007
#define pi                 pair<int,int>
#define vi                 vector <int>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"
#define mi                 map <int,int> 
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             x.begin(),x.end() 
using namespace std ; 
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set ; 
const int N = 2e5+7;  
/*  
    time : 10 : 14    
    date : 24.01.2020
*/    

// int L,R,mid,target,idx ;
ll n,m,a[N] ;
ll sum  ;  
int tests(){
  int i ; 
  cin >> m >> n  ;
  forn(i,0,n){ 
    cin >> a[i] ; 
    sum += a[i] ;
    } 
  if(sum >= m )
    cout << "Yes\n" ;
  else 
    cout << "No\n" ;  
  return 0 ; 
}
int main(){
    I__O ;  
    int cases = 1 ; 
    // cin >> cases;  
    while(cases--)
      tests(); 
  return 0 ; 
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

int n;
ll a[100100];

ll solve(){
    cin >> n;
    for(int i = 0; i < n; ++i) cin >> a[i];
    sort(a, a + n);
    
    ll x = 0, cx = 0;
    ll y = 0, cy = 0;
    ll cnt = 2;
    for(int i = n - 1; i >= 0; --i){
        if(a[i] == x) cx++;
        else if(a[i] == y) cy++;

        if(cx >= 2 * cnt) return x * x;
        if(cx >= cnt && cy >= cnt){
            return x * y;
        }
        
        if(a[i] != x && cx < cnt){
            x = a[i];
            cx = 1;
        }else if(a[i] != y && cy < cnt){
            y = a[i];
            cy = 1;
        }
    }
    return 0;
}

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

    cout << solve() << "\n";
    
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

ll n;
ll a[200010];
ll ans=INF;
int main(){
	scanf("%lld",&n);
	rep(i,0,n)scanf("%lld",a+i);
	ll goukei=0;
	rep(i,0,n)goukei+=a[i];
	ll s=0;
	rep(i,0,n-1){
		s+=a[i];
		ans=min(ans,llabs(goukei-2*s));
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void chOut(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;



signed main(){

    int N, K; cin >> N >> K;
    vec P(N); cin >> P;
    REP(i, N) P[i]--;
    vec C(N); cin >> C;

    int ans = -INF;
    REP(s, N){
        int now = s, tmp = 0, cnt = 0;
        while(true){
            now = P[now];
            cnt++;
            tmp += C[now];
            if(now == s) break;
        }

        int L = cnt, M = tmp;
        cnt = 0;
        tmp = 0;
        while(true){
            now = P[now];
            cnt++;
            tmp += C[now];
            if(cnt <= K){
                chmax(ans, tmp);
                int m = (K - cnt) / L;
                chmax(ans, tmp + M * m);
            }
            if(now == s) break;
        }
    }
    Out(ans);

    return 0;
}


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

static const int MAX = 1 << 20;

int main() {
	int i, j, n, m, diff, anstaro, anshanako, taro[101], hanako[101];
	
	while (1) {
		cin >> n >> m;
		if (n == 0 && m == 0)break;
		anstaro = MAX;
		anshanako = MAX;
		diff = 0;
		for (i = 0; i < n; i++) {
			cin >> taro[i];
			diff += taro[i];
		}
		for (j = 0; j < m; j++) {
			cin >> hanako[j];
			diff -= hanako[j];
		}
		//cout << "	" << diff << endl;
		if (diff % 2 == 1) {
			cout << -1 << endl;
			continue;
		}
		for (i = 0; i < n; i++) {
			for (j = 0; j < m; j++) {
				if ((taro[i] - hanako[j]) * 2 == diff) {
					if (taro[i] + hanako[j] < anstaro + anshanako) {
						anstaro = taro[i];
						anshanako = hanako[j];
					}
				}
			}
		}
		if (anstaro != MAX && anshanako != MAX) {
			cout << anstaro << " " << anshanako << endl;
		} else {
			cout << -1 << endl;
		}
		
	}




	return 0;
}

Measured memory_bytes: 3052
#include <stdio.h>
int main()
{
    long long N;
    while(scanf("%lld",&N)!=EOF)
    {
        long long h,n,t1,t2;
        int term=0;
        for(h=1;h<=3500;h++)
        {
            for(n=1;n<=3500;n++)
            {
                t1=N*h*n;//分子母 
                t2=4*h*n-n*N-h*N;//分子 
                if(t1>0&&t2>0&&t1%t2==0)
                {
                    printf("%lld %lld %lld\n",h,n,t1/t2);
                    term=1;
                    break;
                }
            }
            if(term) break;
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int A, B;
    cin >> A >> B;
    if (A == 1 && B == 2){
    cout << 3 << endl;
    }
    else if (A == 2 && B == 1){
    cout << 3 << endl;
    }
    else if (A == 1 && B == 3){
    cout << 2 << endl;
    }
    else if (A == 3 && B == 1){
    cout << 2 << endl;
    }
    else if (A == 3 && B == 2){
    cout << 1 << endl;
    }
    else{ 
    cout << 1 << endl;
    }
}

Measured memory_bytes: 3568
s = int(input())

L_MAX = 10**9

x1, y1 = 0, 0
x2, y2 = L_MAX, 1
x3 = ((s + L_MAX - 1) // L_MAX) * L_MAX - s
y3 = (s + L_MAX - 1) // L_MAX

print(x1, y1, x2, y2, x3, y3)


Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	int a,i,g,w,k,n,c,s;
	g=0;
	scanf("%d %d",&n,&c);
	n++;
	for(i=0;i<c;i++){
		scanf("%d",&a);
		g=g+a;
	}
	w=g%n;
	k=g/n;
	if(w>0){
		k=k+1;
	}
	printf("%d\n",k);
	return 0;
}


Measured memory_bytes: 2120
N, K = map(int, input().split())
S = input()

def continuous_list(S):
    # 番兵
    S += '0'

    continuous_list = []
    
    index_1 = 0
    index_0 = 0

    while True:
        index_1 = S.find('1', index_0)
        index_0 = S.find('0', index_1)
        
        if index_1 == -1:
            break
        elif index_0 == len(S) - 1:
            continuous_list.append((index_1, index_0 - 1))
            break
        
        continuous_list.append((index_1, index_0 - 1))
        
    return continuous_list

def hand_stand_operation(continuous_list, K, N):
    '''
    となりあった2つ以上のタプルの結合操作を行い、その結合でできる連続した逆立ちパフォーマーの人数を数える。
    '''
    candidate = 0
    
    # 両端チェック
    KF = min(K, len(continuous_list) + 1)
    
    if KF == len(continuous_list) + 1:
        return N
    
    else:
        candidate = max(candidate, continuous_list[KF - 1][1] + 1)
        candidate = max(candidate, N - continuous_list[-KF][0])
    
    # 両端を含まない場合
    KG = min(K, len(continuous_list) - 1)
    
    for i in range(len(continuous_list) - KG):
        candidate = max(candidate, continuous_list[i + KG][1] - continuous_list[i][0] + 1)
    
    return candidate
  
print(hand_stand_operation(continuous_list(S), K, N))

Measured memory_bytes: 43376
using System;

namespace ConsoleApplication17
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int c = int.Parse(str[2]);
            if (a < b && b < c){
                Console.WriteLine("Yes");
            }
            else {
                Console.WriteLine("No");
            }
            
         }
     }
    
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t k;
    cin >> k;

    string s;
    cin >> s;

    if (s.size() > k) {
        s.resize(k);
        s += "...";
    }

    cout << s << endl;
}

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

int main() {
	long long a, b, n;
	cin>>a>>b>>n;
	if(n < b){
		cout<<((n*a)/b)-(a*(n/b))<<endl;
	}else{
		n = b - 1;
		cout<<((n*a)/b)-(a*(n/b))<<endl;
	}
	return 0;
}


Measured memory_bytes: 3592
/////////////////////////////////TEST CASES////////////////////////////////////
/*
*/
/////////////////////////////////////CODE//////////////////////////////////////		
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = a ; i > b ; i--)
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define PI 3.14159265
typedef long long ll;
#define vl vector<ll> 
#define IN(inp) ll inp;cin>>inp;
#define pb push_back
#define all(a) a.begin(),a.end()
#define FR(i,a) for(auto i:a)
#define what(A) cout<<#A<<" is "<<A<<endl;
ll MAX = 100000000000;
ll MOD = 1000000007;
void solve()
{
	IN(h)IN(w)IN(m);
	map<ll, ll>r, c;
	map<pair<ll, ll>, ll>pairs;
	FOR(i, 0, m)
	{
		IN(in1)IN(in2);
		r[in1]++;
		c[in2]++;
		pairs[{in1, in2}] = 1;
	}
	ll check1 = 0,check2=0;
	vl q, j;
	FR(i, r)
	{
		if (check1 < i.second)
			check1 = i.second;
	}
	FR(i, r)
	{
		if (i.second == check1)
			q.pb(i.first);
	}
	FR(i, c)
	{
		if (check2 < i.second)
			check2 = i.second;
	}
	FR(i, c)
	{
		if (i.second == check2)
			j.pb(i.first);
	}
	ll ans = check1 + check2-1, f = 0;
	FR(i, q)
	{
		FR(z, j)
		{
			if (pairs[{i, z}] == 0)
			{
				f = 1;
				break;
			}
		}
	}
	cout << ans + f << endl;
}
int main()
{
	fastio
		//freopen("input.txt", "rt", stdin);
		//freopen("output.txt", "wt", stdout);
	ll test = 1;
	//cin >> test;
	while (test--)
	{
		solve();
	}
}

Measured memory_bytes: 82852
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    ret =1 if all (s.count(c) > 0 for c in '753') else 0
    for c in '753':
        ret += dfs (s+c)
    return ret

print(dfs('0'))




Measured memory_bytes: 2940
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int pow(int number, int count) {
	if (count == 0 )
		return 1;
	return number * pow(number, count - 1);
}

int main(int argc, char *argv[]) {
	const int WeightNumber = 10;
	int weight[WeightNumber];
	// Make Weight
	for (int i = 0; i < 10; i++) {
		weight[i] = pow(2, i);
	}
	// Load
	int rcv;
	while (EOF != fscanf(stdin, "%d", &rcv)) {
		vector<int> answer;
		// Find Heaviest Weight
		int max_weight_ar_number;
		for (int i = 0; i < WeightNumber; i++) {
			if (weight[i] > rcv) {
				max_weight_ar_number = i;
				break;
			}
		}
		// Get Weight
		for (int i = max_weight_ar_number; i >= 0; i--) {
			if (rcv >= weight[i]) {
				rcv -= weight[i];
				answer.push_back(weight[i]);
			}
			if (rcv == 0) {
				break;
			}
		}
		// Print Result
		sort(answer.begin(), answer.end());
		const int loop_max = static_cast<int>(answer.size());
		for (int i = 0; i < loop_max ; i++) {
			if (i == loop_max - 1)
				printf("%d\n", answer[i]);
			else
				printf("%d ", answer[i]);
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;


int main() {
	int N, M;
	cin >> N >> M;
	int l = 1, r = N;
	for (int i = 0; i < M; i++) {
		int tl, tr;
		cin >> tl >> tr;
		l = max(l, tl);
		r = min(r, tr);

	}
	if ((r - l + 1) < 0) {
		cout << 0 << endl;
		return 0;
	}
	cout << (r - l + 1) << endl;
	return 0;
}



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

#define ll long long
#define lli long long int
#define loop(i,x,n) for(lli i=x; i<=n; i++)
#define rloop(i,n,x) for(lli i=n; i>=x; i--)

typedef vector<ll> v64;
typedef vector<pair<ll,ll>> vp64;
typedef vector<bool> vbo;
typedef set<ll> s64;
typedef set<bool> sbo;
typedef unordered_set<ll> us64;
typedef map<ll,ll> m64;
typedef unordered_map<ll,ll> um64;

int main(){
    int a,b;
    cin>>a>>b;
    int ans ;
    if(b==1) ans = 0;
    else if(a>=b) ans = 1;
    else {
    ans = (b-a)/(a-1)+1;
    if((b-a)%(a-1)!=0) ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int count = 0;
  char s[4], t[4];
  scanf("%s", s);
  scanf("%s", t);
  for(int i = 0; i < 3; ++i){
    if(s[i] == t[i]) count++;
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){

    int N,i;
    cin >> N;
    long long int n[N];

    n[0] = 2;
    n[1] = 1;

    for(i = 0; i < N-2; i++) {
        n[i % 2] = n[0] + n[1];
    }
    
    if(N == 1) {
        cout << 1 << endl;
    }else {
        cout << n[0] + n[1] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
from copy import copy
import random
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for _ in range(D)]
last = [0]*26
ans = [0]*D
score = 0
for i in range(D):
    ps = [0]*26
    for j in range(26):
        pl = copy(last)
        pl[j] = i+1
        ps[j] += s[i][j]
        for k in range(26):
            ps[j] -= c[k]*(i+1-pl[k])
    idx = ps.index(max(ps))
    last[idx] = i+1
    ans[i] = idx+1
    score += max(ps)
for i in range(40000):
    na = copy(ans)
    x = random.randint(1,365)
    y = random.randint(1,365)
    if x == y:
        continue
    na[x-1],na[y-1] = na[y-1],na[x-1]
    last = [0]*26
    ns = 0
    for i in range(D):
        last[na[i]-1] = i+1
        ns += s[i][na[i]-1]
        for j in range(26):
            ns -= c[j]*(i+1-last[j])
    if ns > score:
        ans = na
        score = ns
for a in ans:
    print(a)

Measured memory_bytes: 86272
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

void solve()
{
	string s;
	ll k;
	cin >> s;
	cin >> k;
	string t = s + s;
	int n = s.size();
	ll cnt[2] = {0, 0};
	int succ = 1;
	rep(i, n - 1)
	{
		if (s[i] == s[i + 1])
		{
			succ++;
		}
		else if (succ >= 2)
		{
			cnt[0] += floor((double)succ / 2);
			succ = 1;
		}
		else
		{
			succ = 1;
		}
	}
	if(succ==n){
		cout<<(ll)n*k/2<<endl;
		return ;
	}
	if (succ >= 2)
	{
		cnt[0] += floor((double)succ / 2);
		succ = 1;
	}
	else
	{
		succ = 1;
	}
	succ = 1;
	rep(i, 2 * n - 1)
	{
		if (t[i] == t[i + 1])
		{

			succ++;
		}
		else if (succ >= 2)
		{
			cnt[1] += floor((double)succ / 2);
			succ = 1;
		}
		else
		{
			succ = 1;
		}
	}
	if (succ >= 2)
	{
		cnt[1] += floor((double)succ / 2);
		succ = 1;
	}
	else
	{
		succ = 1;
	}
	ll dis = cnt[1] - cnt[0] ;
	//cout<<cnt[0]<<" "<<cnt[1]<<endl;
	if (k == 1)
	{
		cout << cnt[0] << endl;
	}
	else
	{
		ll ans = cnt[1]+ (ll)dis * (k - 2);
		cout << ans << endl;
	}
}

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


Measured memory_bytes: 256