akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;
const int M=1e9 + 7;

string inttos(int num)
{
    return to_string(num);
}

int stoint(string sss)
{
    return stoi(sss);
}

int32_t main()
{
	IOS;
	//memset(dp,-1,sizeof(dp));	
	int T;
	T=1;
	while(T--)
	{
		string s;
		cin >> s;
		if(s[2]==s[3] && s[4]==s[5])
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
}


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

#define I inline
#define fi first
#define se second
#define R register
#define LL long long
#define mp make_pair
#define reg register int
#define pii pair<int,int>
#define fo(i, a, b) for(reg i = a; i <= b; i++)
#define fd(i, a, b) for(reg i = a; i >= b; i--)
#define bp __builtin_popcount
#define vi vector<int>
#define cr const reg&
#define int128 __int128
using namespace std;
const int mod = 998244353, N = 1e6 + 1;

I int _max(cr x, cr y) {return x > y ? x : y;}
I int _min(cr x, cr y) {return x < y ? x : y;}
I int128 read() {
	int128 x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return x * f;
}
I void ptt(int128 x) {if(x >= 10) ptt(x / 10); putchar(x % 10 + '0');}
I void put(int128 x) {x < 0 ? putchar('-'), ptt(-x) : ptt(x);}
I void pr1(int128 x) {put(x), putchar(' ');}
I void pr2(int128 x) {put(x), puts("");}

I int pow_mod(reg a, reg k) {reg ans = 1; for(; k; k >>= 1, a = (LL)a * a % mod) if(k & 1) ans = (LL)ans * a % mod; return ans;}

map<int128, int128> f;
LL A, B, C, D;

I int128 dfs(int128 n) {
	if(!n) return 0;
	if(n == 1) return D;
	if(f.count(n)) return f[n];
	int128 ans = D * n;
	reg o = n % 2;
	if(!o) ans = min(ans, dfs(n / 2) + A);
	else ans = min(ans, min(dfs((n - 1) / 2), dfs((n + 1) / 2)) + A + D);
	o = n % 3;
	if(o <= 1) ans = min(ans, dfs((n - o) / 3) + B + D * o);
	else ans = min(ans, dfs((n + 3 - o) / 3) + B + (3 - o) * D);
	o = n % 5;
	if(o <= 2) ans = min(ans, dfs((n - o) / 5) + C + D * o);
	else ans = min(ans, dfs((n - o + 5) / 5) + C + D * (5 - o));
	return f[n] = ans;
}

int main() {
	reg T = read();
	while(T--) {
		int128 n = read(); A = read(), B = read(), C = read(), D = read();
		f.clear(), pr2(dfs(n));
	}
	return 0;
}


Measured memory_bytes: 4548
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9) + 7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n)
{
	vector<pair<ll, ll>> p;
	for (ll i = 2; i * i <= n; i++)
	{
		if ((n % i) != 0)
			continue;
		pair<ll, ll> a = make_pair(i, 0);
		while ((n % i) == 0)
		{
			n /= i;
			a.second += 1;
		}
		p.push_back(a);
	}

	if (n != 1)
		p.push_back(make_pair(n, 1));
	return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a)
{
	ll b = MOD, u = 1, v = 0;
	while (b)
	{
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0)
	{
		u += MOD;
	}
	return u;
}
// 順列
ll permutation(const ll n, const ll m)
{
	ll result = 1;
	for (ll i = n; i > n - m; i--)
	{
		result = (result * i) % MOD;
	}
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x)
{
	if (x == 0)
		return 1;
	ll res = repeat_square(n, x / 2);
	res = res * res % MOD;
	if ((x % 2) == 1)
		res = res * n % MOD;
	return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m)
{
	ll p = permutation(n, m);
	ll div = 1;
	for (ll i = 2; i <= m; i++)
	{
		div = (div * i) % MOD;
	}
	return (p * modinv(div)) % MOD;
}

int main() {
	int N, K;
	cin >> N >> K;
	vector<ll> a(N);

	rep(i, N) cin >> a[i];

	ll ans = ll(1e10);
	for (int i = 0; i + K - 1 < N; i++) {
		ll cost1 = abs(a[i]) + (a[i+K-1] - a[i]);
		ll cost2 = abs(a[i+K-1]) + (a[i+K-1] - a[i]);
		
		ans = min(ans, cost1);
		ans = min(ans, cost2);
  }
	cout << ans << endl;
	return 0;
}


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

int main(){
	string X;
	cin >> X;
	int remove=0;
	int N=X.size();
	int s=0;
	for(int i=0;i<N;i++){
		if(X[i]=='S')s++;
		else if(s>0){
			remove+=2;
			s--;
		}
	}
	cout << N-remove << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<string>
#include<time.h>
#include<random>
#include<bitset>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;


std::vector<ull> prime;

void initprime(ull MAX) {
    std::vector<bool> is_prime(MAX + 1);
    for (int i = 0; i <= MAX; ++i) is_prime[i] = true;
    for (int i = 2; i <= MAX; ++i) {
        if (is_prime[i]) {
            int loop = (MAX / i);
            for (int j = 2; j <= loop; ++j) {
                is_prime[i * j] = false;
            }
            prime.emplace_back(i);
        }
    }
}

//最大公約数
template<typename T>
constexpr T gcd(T a, T b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
ll gcd2(ll x, ll y) { return y ? gcd2(y, x % y) : x; }
//最小公倍数
template<typename T>
constexpr T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

vector<pair<ll, int>> factorize(ll n) {
    vector<pair<ll, int>> res;
    for (ll i = 2; i * i <= n; ++i) {
        if (n % i) continue;
        res.emplace_back(i, 0);
        while (n % i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1);
    return res;
}

ull p_cnt(ull g) {
    if (g == 1) return 1;
    ull rootg = floor(sqrt((double)g));
    ull p_cnt = 1;
    for (int i = 0; i < prime.size(); ++i) {
        if (g % prime[i] == 0) {
            ++p_cnt;
        }
    }
    if (p_cnt == 1) ++p_cnt;
    return p_cnt;
}

int main() {
    initprime(1000000);
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);
    auto f = factorize(g);
    int ans = f.size() + 1;
    cout << ans << endl;
    return 0;

    ll C = 100000000;
    for (ll i = 1; i <= C; ++i) {
        for (ll j = i; j <= C; ++j) {
            ull a = gcd(i,j);
            ull b = gcd2(i,j);
            if (a != b)
            {
                cout << i << "::" << a << "::" << b << endl;
            }
        }
    }
	return 0;
}

Measured memory_bytes: 1656
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MAX max<ll>
#define MIN min<ll>
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll devc(ll x, ll y) { return (x + y - 1) / y; }

vector<ll> divisor(ll n) {
    vector<ll> ret;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N;
    cin >> N;
    vector<ll> div = divisor(N);
    ll ans = 1e18;
    for(auto d : div){
        chmin(ans, d + N / d - 2);
    }
    print(ans);

    return 0;
}

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

using namespace std;

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

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

ll ans[125252];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
  int n;
  vl a(125252);
  cin>>n;
  auto cmp=[](pii a, pii b){
    if(a.first==b.first) return a.second<b.second;
    return a.first<b.first;
  };
  priority_queue<pii, vector<pii>, decltype(cmp)> q{cmp};
  REP(i, n){
    cin>>a[i];
    q.push(pii(a[i], i));
  }
  int cnt=0, mi=1e9;
  while(q.size()){
    pii tmp=q.top();
    int fir=tmp.first;
    int idx=-1;
    while(q.size() && q.top().first==fir){
      // DEBUG(q.top().second);
      idx=q.top().second;
      q.pop();
      ++cnt;
    }
    ll dif=fir-(q.size() ? q.top().first : 0);
    CHMIN(mi, idx);
    ans[mi]+=dif*cnt;
  }
  REP(i, n){
    cout<<ans[i]<<'\n';
  }
	return 0;
}


Measured memory_bytes: 3828
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 21 21:01:51 2020

@author: NEC-PCuser
"""

N, K = map(int, input().split())

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

P.sort()

ans = 0

for i in range(K):
    ans += P[i]
    
print(ans)

Measured memory_bytes: 9164
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		String input = scan.nextLine();
		StringBuffer sb = new StringBuffer();
		for(int i = 0; i < input.length(); i++){
			char ch = input.charAt(i);
			String c = String.valueOf(ch);
			if(Character.isLowerCase(ch)){
				c = c.toUpperCase();
			} else if(Character.isUpperCase(ch)){
				c = c.toLowerCase();
			}
			sb.append(c);
		}
		String output = sb.toString();
		System.out.println(output);
	}
}

Measured memory_bytes: 26604
def cmb(n,r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

X, Y = map(int, input().split())
if (X+Y)%3!=0:
  print(0)
  exit()
for i in range(X+1):
  n=int((X-i)/2)
  if Y==i*2+n*1:
    print(cmb(i+n,i)%1000000007)
    exit()
    
print(0)

Measured memory_bytes: 46032
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);i--)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int n;
void solve(){
  int ans = 0;
  FOR(i,1,n){
    int tmp = 0;
    REP(j,n){
      tmp += i+j;
      if(tmp == n) ans++;
      if(tmp >= n) break;
    }
  }
  cout << ans << endl;
}

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

  while(cin >> n, n) solve();

  return 0;
}


Measured memory_bytes: 3020
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

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

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

class c {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int a, b;
        cin >> a >> b;
        cout << lcm(a, b) << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    c solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	string s;
	cin >> s;
	int n = s.size();
	char prev = '0';
	int ans = 0;
	for (int i = 0; i < n; i++) {
		char c = s[i];
		ans++;
		if (prev == c) {
			i++;
		 	prev = '0';
			if (i >= n) ans--;
		} else {
			prev = c;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3688
# -*- coding: utf-8 -*-

"""
shell sort
"""
N = int(input())
aN = [int(input()) for i in range(N)]

cnt = 0

def insertion_sort(aN, N, g):
    global cnt
    for i in range(g, N):
        tmp = aN[i]
        j = i - g
        while j >= 0 and aN[j] > tmp:
            aN[j+g] = aN[j]
            j = j - g
            # 要素を前に移動した回数
            cnt += 1
        aN[j+g] = tmp

G = []
g = 1
while g <= N:
    G.append(g)
    g = g * 3 + 1
G.reverse()

# shell sort
for g in G:
    insertion_sort(aN, N, g)

print(len(G))
for i in range(len(G)):
    G[i] = str(G[i])
print(' '.join(G))
print(cnt)
for i in range(N):
    print(aN[i])



Measured memory_bytes: 45528
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int dp[2][110];
int main(){
    cin>>n;
    int a[2][n];
    for(int i = 0;i < 2; i++){
        for(int j = 0;j < n; j++){
            cin>>a[i][j];   
        }
    }
    dp[0][0] = a[0][0];
    for(int i=0;i<2;i++){
        for(int j=0;j<n;j++){
            if(i==0 && j== 0) continue;
            else if(i==1 && j==0) dp[i][j]=dp[0][0]+a[i][j];
            else if( i == 0){
                dp[i][j]=dp[i][j-1]+a[i][j];
            }
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1])+a[i][j];
            }
        }
    }
    cout<<dp[1][n-1]<<endl;;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n,_,*a=map(int,open(0).read().split())\n"
"m=d=c=0\n"
"for t in a[::-1]:\n"
"    if t>m:\n"
"        m=t\n"
"    if m-t>d:\n"
"        d=m-t\n"
"        c=1\n"
"    elif m-t==d:\n"
"        c+=1\n"
"print(c)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 18844
#include <bits/stdc++.h>
 
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define rep_0(i, end) for(int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for(int i = (fr); i <= (ba); ++i)
#define overload_rep(arg0, arg1, arg2, name, ...) name
#define all(box) box.begin(), box.end()
 
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }

using dbl = long double;
constexpr int N = 6;
dbl p[N], q[N];

dbl calc(const dbl& x) {
  dbl res{};
  rep (i, N) {
    res += std::max<dbl>(p[i] * x, q[i] * (1 - x));
  }
  return res;
}

int main() {

  rep (i, N) {
    std::cin >> p[i];
    p[i] /= static_cast<dbl>(100);
  }
  rep (i, N) {
    std::cin >> q[i];
    q[i] /= static_cast<dbl>(100);
  }

  dbl l = 0.0, r = 1.0;
  rep (loop, 500) {
    dbl dif = r - l;
    dbl m1 = l + dif / static_cast<dbl>(3);
    dbl m2 = r - dif / static_cast<dbl>(3);
    if (calc(m1) < calc(m2)) {
      r = m2;
    } else {
      l = m1;
    }
  }

  std::cout << std::fixed << std::setprecision(20);
  std::cout << calc(l) << '\n';
  return 0;

}


Measured memory_bytes: 256
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10;

int main() {
	fast_cin();
	int h, w;
	cin >> h >> w;
	ll ans;
	if (h == 1 or w == 1) {
		ans = 1;
	} else {
		ans = (ll(h) / 2) * w;
		if (h & 1) {
			ans += (w + 1) / 2;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
from collections import defaultdict

n, m = map(int, input().split())
path_d = defaultdict(list)
result = dict()

for _ in range(m):
    a, b = input().split()
    if a == "1":
        result[b] = a
    elif b == "1":
        result[a] = b
    else:
        path_d[a].append(b)
        path_d[b].append(a)

tmp = list(result.keys())

while path_d:
    tmp2 = list()
    for _a in tmp:
        for _b in path_d[_a]:
            if _b not in result:
                result[_b] = _a
                tmp2.append(_b)
        del path_d[_a]
    tmp = tmp2

print("Yes")
for i in range(2, n + 1):
    print(result[str(i)])


Measured memory_bytes: 140716
#include <iostream>
#include <vector>
#include <queue>
#include <list>

using ll = long long;
using namespace std;

vector<int> G[1000000];
int indeg[1000000] = {};
int N;
bool V[1000000];
list<int> out;
void bfs(int s) {
    queue<int> q;
    q.push(s);
    V[s] = true;
    while (!q.empty()){
        int u = q.front(); q.pop();
        out.push_back(u);
        for (int v : G[u]) {
            indeg[v]--;
            if (indeg[v] == 0 && !V[v]) {V[v] = true; q.push(v);}
        }
    }
}

void toporogicalsort() {
    for (int i = 0; i < N; ++i) {
        for (int v : G[i]) {
            indeg[v]++;
        }
    }
    for (int u = 0; u < N; ++u) {
        if ( indeg[u] == 0 && !V[u]) bfs(u);
    }
    for (int &it : out) {
        cout << it << "\n";
    }
}



int main() {
    int s, t, M;
    cin >> N >> M;

    for (int i = 0; i < N; ++i) {
        V[i] = false;
    }

    for (int i = 0; i < M; ++i) {
        cin >> s >> t;
        G[s].push_back(t);
    }

    toporogicalsort();
    return 0;

}


Measured memory_bytes: 27356
module.exports=function(e){var r={};function n(t){if(r[t])return r[t].exports;var o=r[t]={i:t,l:!1,exports:{}};return e[t].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=r,n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,r){if(1&r&&(e=n(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(n.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)n.d(t,o,function(r){return e[r]}.bind(null,o));return t},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},n.p="",n(n.s=0)}([function(e,r,n){n(1)(n(2).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(e,r){e.exports=function(e){for(var r=Number(e[0]),n=e[1].split(" ").map(function(e){return Number(e)}),t=n[1],o=2;o<r;o++)t=n[o]-t;var u=(n[0]-t)/2,i=new Array(r).fill(0);i[0]=2*u;for(var f=1;f<r;f++)i[f]=2*(n[f]-i[f-1]/2);var l=i.pop();i.unshift(l),console.log(i.join(" "))}},function(e,r){e.exports=require("fs")}]);

Measured memory_bytes: 38208
#include <iostream>
using namespace std;
int main() {
	int x,y;
	cin>>x>>y;
	int l=0,o=0,p=0;
	if(y%2!=0)
	cout<<"No";
	else {
		l=y/2;
		if(y%4!=0)p=1;
		o=(y/4)+p;
		if(o<=x&&l>=x)
		cout<<"Yes";
		else
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    
    if(a+b+1>=c){
        cout << b+c << endl;
        return 0;
    }
    cout << b+a+1+b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

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

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

    vector<pair<int64_t, int64_t>> ba(n);
    for (auto&& aa : ba) {
        cin >> aa.second;
    }
    for (auto&& aa : ba) {
        cin >> aa.first;
    }

    sort(ba.rbegin(), ba.rend());

    auto cmp = [&](int64_t lhs, int64_t rhs) {
        return make_pair(ba[lhs].second, ba[lhs].first) <
               make_pair(ba[rhs].second, ba[rhs].first);
    };

    priority_queue<int64_t, vector<int64_t>, decltype(cmp)> q(cmp);

    for (auto i : irange(0L, n)) {
        const auto& t = ba[i];
        // a > b
        if (t.second > t.first) {
            q.emplace(i);
        }
    }

    if (q.size() >= n - 1) {
        std::cout << "No" << endl;
        return 0;
    }

    multiset<int64_t> as;
    auto prev_it = ba.begin();
    int64_t nums = 0;
    while (!q.empty()) {
        auto idx = q.top();
        q.pop();
        auto end = partition_point(ba.begin(), ba.end(),
                                   [&](const pair<int64_t, int64_t>& p) {
                                       return ba[idx].second <= p.first;
                                   });

        if (end == ba.begin()) {
            std::cout << "No" << endl;
            return 0;
        }

        for (auto it = prev_it; it != end; ++it) {
            as.emplace(it->second);
        }
        prev_it = end;

        auto it = as.upper_bound(ba[idx].first);
        if (it != as.begin()) {
            --it;
            auto tmp = ba[idx].second;
            ba[idx].second = *it;
            as.erase(it);
            as.emplace(tmp);
        } else if (*it < ba[idx].second) {
            auto tmp = ba[idx].second;
            ba[idx].second = *it;
            as.erase(it);
            as.emplace(tmp);

            q.emplace(idx);
        }

        ++nums;
        if (nums >= n - 1) {
            std::cout << "No" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 6776
/////////////////////////////////////////////////////////
//
//  c/temp.cpp file
//  Last Updated: 2018-10-23 ...Maybe
//
//    I hope you adding this code to the setting file
//    alias g++='g++ -std=c++1y -DDEBUG_LOCAL'
//
/////////////////////////////////////////////////////////

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

//#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _REP(i,n) REAP(i,0,n)
#define REAP(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,REAP,_REP,)(__VA_ARGS__)

#define _REPR(i,n) REAPR(i,n,0)
#define REAPR(i,a,b) for(int i=int(a-1);i>=int(b);--i)
#define REPR(...) _overload3(__VA_ARGS__,REAPR,_REPR,)(__VA_ARGS__)

#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()

#define coutALL(a) {int loop_coutALL=0;for(auto e:a) cout<<(loop_coutALL++?" ":"")<<e; cout<<endl;}

#define coutYN(a) cout<<((a)?"YES":"NO")<<endl;
#define coutYn(a) cout<<((a)?"Yes":"No")<<endl;
#define coutyn(a) cout<<((a)?"yes":"no")<<endl;

#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)

const int INF=1145141919;
//const long long INF=114514191911451419;
const int MOD=(int)1e9+7;
const double EPS=1e-12;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
//const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;

typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<string,int> psi;
typedef pair<string,string> pss;

typedef long long ll;

template<typename T> istream &operator >> (istream &is, vector<T> &v){for(T &x:v) is>>x;return is;}
template<typename T> ostream &operator << (ostream &os, vector<T> &v){int i=0;for(T &x:v) os<<(i++?" ":"")<<x;return os;}

ll rev(ll n){ll x=0;for(;n>0;){x=x*10+n%10;n/=10;}return x;}

ll upper(ll n,ll m){return (n+m-1)/m;};
ll rounding(ll n){return (long double)n+0.5;};

bool inG(ll x,ll n){return 0<=x && 0<n;}
bool outG(ll x,ll n){return x<0 || n<=x;}

inline int qp(int a,ll b){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
inline int qp(int a,ll b,int mo){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

inline ll fac(ll k,ll n){ll a=1;for(int i=0;i<n;i++)a*=k--;return a;}
inline ll fac(ll k,ll n,int mo){ll a=1;for(int i=0;i<n;i++)a*=k--,a%=mo;return a;}

inline int dsum(ll n){int a=0;for(;n;n/=10)a+=n%10;return a;}

struct Arithmetic{Arithmetic(){cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);}};

//#define DEBUG_LOCAL

#ifdef DEBUG_LOCAL
template<typename T> void deb(T a){cerr<<"deb: "<<a<<"です"<<endl;}
#define debl {cerr<<"debug: "<<__LINE__<<"行目だ"<<endl;}
void what_cr(){cout<<__GCC_ATOMIC_CHAR16_T_LOCK_FREE<<" ←？"<<endl;}
//ori_func S

//ori_func E
#else
template<typename T>void deb(T a){}
#define debl
void what_cr(){}void t_t(){}
#endif

signed main(){

  Arithmetic Exception;

  int n;
  cin>>n;

  ll ans=1;
  REP(i,1,n+1) ans*=i;

  cout<<ans<<endl;

  return 0;

}



Measured memory_bytes: 3168
/*
[abc165] D - Floor Function
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

ll A, B, N;

ll solve() {
    ll ans = A * min(B - 1, N) / B;
    return ans;
}

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

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 3600
import bisect

X, N = map(int, input().split())
P = set(map(int, input().split()))

A = {i for i in range(102)}

S = list(A - P)

T = bisect.bisect_left(S, X)

if T == 0:
    print(S[0])
elif X - S[T-1] > S[T] - X:
    print(S[T])
else:
    print(S[T-1])


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

int main(){
    int N;
    cin >> N;
    for(int i=1;i<10;i++){
        for(int x=1;x<10;x++){
            if(N==i*x){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
import math
n,h=map(int,input().split())
a_l=[]
b_l=[]
c=0
for i in range(n):
  a,b=map(int,input().split())
  a_l.append(a)
  b_l.append(b)
a_l.sort()
b_l.sort()
for i in range(1,n+1):
  if a_l[-1]<=b_l[(-1)*i]:
    h-=b_l[(-1)*i]
    c+=1
    if h<=0:
      break
  else:
    break
if h>0:
  c+=math.ceil(h/a_l[-1])
print(c)

Measured memory_bytes: 61656
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
typedef long long ll;

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i = 0; i < N; ++i) {
		cin >> A[i];
	}

	ll res = 0;
	int msk = 0;
	for(int l = 0, r = 0; l < N; l++){
		while(r < N && !(msk & A[r])) {
			msk |= A[r];
			res++;
			r++;
		}
		res += r - l - 1;
		msk &= ~A[l];
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1024
import sys
S=input()
T=input()
N=len(S)
L=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
Ss=[]
Ts=[]
for x in L:
    A=set()
    B=set()
    for i in range(N):
        if S[i]==x:
            A.add(i)
        if T[i]==x:
            B.add(i)
    Ss.append(A)
    Ts.append(B)
for A in Ss:
    flag=True
    for B in Ts:
        if A==B:
            flag=False
    if flag:
        print('No')
        sys.exit()
print('Yes')

Measured memory_bytes: 82876
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

B = sorted(A, reverse = True)
max_val = B[0]
second_max_val = B[1]

for val in A:
    if val == max_val:
        print(second_max_val)
    else:
        print(max_val)


Measured memory_bytes: 14112
#include<bits/stdc++.h>
#define N 200010
#define EPS 1e-9
#define PI acos(-1)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define fs first
#define sc second
#define db double
#define pb push_back
#define ll long long
#define VI vector<int>
#define PII pair<int,int>
#define PQ priority_queue
#define NP next_permutation
#define ull unsigned long long
#define sz(a) (int)a.size()
#define len(a) (int)strlen(a)
#define all(a) a.begin(),a.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define F(i,j,k) for(register int i=j;i<=k;i++)
#define CK1(x) cout<<"["<<(x)<<"]\n";
#define CK2(x,y) cout<<"["<<(x)<<","<<(y)<<"]\n";
#define CK3(x,y,z) cout<<"["<<(x)<<","<<(y)<<","<<(z)<<"]\n";
#define IOS ios::sync_with_stdio(false)
using namespace std;
istream &operator >> (istream &in,VI &v){for(auto &i:v)in>>i;return in;}
ostream &operator << (ostream &out,VI &v){for(auto i:v)out<<i<<" ";return out;}
int n,k;
ll a[N],ans;
int main()
{
    IOS;
#if 0
    int T;cin>>T;
    while(T--)
#endif
    {

        cin>>n;
        for(int i=1;i<=n;i++)
            ans+=1LL*(n-i+1)*i;
        for(int i=1,u,v;i<n;i++)
        {
            cin>>u>>v;
            if(u>v)swap(u,v);
            ans-=1LL*(u)*(n-v+1);
        }
        cout<<ans;
    }
}


Measured memory_bytes: 3632
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main() {
    int h,w;
    cin >> h >> w;
    char arr[h][w];
    for(int i = 0;i<h;i++) for(int j =0 ;j<w;j++) cin >> arr[i][j];
    vector<vector<int>> dp(h,vector<int>(w,0));
    dp[0][0] = 1;
    for(int i = 0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i==0&&j==0);
            else if(arr[i][j]  == '#' ) dp[i][j] = 0;
            else if(i==0) dp[i][j] = dp[i][j-1]%mod;
            else if(j==0) dp[i][j] = dp[i-1][j]%mod;
            else dp[i][j] = (dp[i-1][j]%mod + dp[i][j-1]%mod)%mod;
        }
    }
    cout << dp[h-1][w-1];
    return 0;
}

Measured memory_bytes: 8496
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#define rep(i, n) for (i = 0; i < n; i++)
using namespace std;

int n;
bool isPrime[55556];
vector<int> primes;

signed main() {
	int i, j;
	
	cin >> n;
	
	rep(i, 55556) isPrime[i] = true;
	isPrime[0] = isPrime[1] = false;
	rep(i, 55556) {
		if (isPrime[i]) {
			for (j = i * 2; j < 55556; j += i)
				isPrime[j] = false;
		}
	}
	
	rep(i, 55556) if (isPrime[i]) primes.push_back(i);
	
	vector<int> ans;
	rep(i, primes.size()) if (primes[i] % 5 == 1) ans.push_back(primes[i]);
	
	rep(i, n) {
		cout << ans[i];
		if (i + 1 < n) cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int power(int x, unsigned int y, unsigned int m)
{
    if (y == 0)
        return 1;
    int p = power(x, y/2, m) % m;
    p = (p * p) % m;
    return (y%2 == 0)? p : (x * p) % m;
}
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		string s;
		int n,p;
		cin >> n >> p;
		cin >> s;
		if(p==2){
			int ans = 0;
			rep(i,0,n){
				if((s[i]-'0')%2==0) ans += i+1;
			}
			cout<<ans;
			r0;
		}
		if(p==5){
			int ans = 0;
			rep(i,0,n){
				if((s[i]-'0')==0 || (s[i]-'0')==5) ans += i+1;
			}
			cout<<ans;
			r0;
		}
		map<int,int> mod;
		int cur = 0;
		int ans = 0;
		mod[0] = 1;
		for(int i=n-1; i>=0; i--){
			cur = (cur+(s[i]-'0')*power(10,n-i-1,p))%p;
			ans += mod[cur];
			mod[cur]++;
			trace(cur,ans);
		}
		cout<<ans;
	}
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1


#ifndef ONLINE_JUDGE
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
						 stringstream _ss(_s); \
						 istream_iterator<string> _it(_ss); \
						 err(_it, args); }
#else
#define error(args...)		42
#endif


void err(istream_iterator<string> it) { cerr << endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "; ";
	err(++it, args...);
}


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
#endif
}

int ceil2(int a, int b){
    int c = a / b;
    if (c * b < a) c++;
    return c;
}


int32_t main()
{
	c_p_c();

	int n; cin>>n;

	int a[n+1];

	int psum[n+1];
	psum[0] = 0;

	for (int i = 1; i < n+1; ++i)
	{
		cin>>a[i];
		psum[i] = psum[i-1]+a[i];
	}

	int dp[n+1][n+1];

	for (int i = 0; i < n+1; ++i)
	{
		for (int j = 0; j < n+1; ++j)
		{
			dp[i][j] = 0;
		}
	}

	int c=1;

	for (int j = 1; j < n+1; ++j)
	{
		for (int l = 0; l < n+1 - j; ++l)
		{
			dp[1+l][j+l] = inf;
			// dp[1+l][j+l] = c;
			// c++;

			if(1+l == j+l)
			{
				dp[1+l][j+l] = 0;
			}else
			{
				for (int k = 1+l; k < j+l; ++k)
				{
					int temp = dp[1+l][k] + dp[k+1][j+l] + (psum[k]-psum[1+l-1]) + (psum[j+l] - psum[k+1-1]);
					dp[1+l][j+l] = min(dp[1+l][j+l], temp);
				}
			}
		}
	}


	cout << dp[1][n];

	// for (int i = 1; i < n+1; ++i)
	// {
	// 	for (int j = 1; j < n+1; ++j)
	// 	{
	// 		cout << dp[i][j] << " ";

	// 	}
	// 	cout << "\n";
	// }
	
	return 0;
}

Measured memory_bytes: 4836
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int C = sc.nextInt();
		int[][] D = new int[C][C];
		for(int i = 0; i < C; i++)
			Arrays.setAll(D[i], j -> sc.nextInt());
		int[][] ls = new int[3][C];
		for(int i = 0; i < N; i++)
			for(int j = 0; j < N; j++) {
				int c = sc.nextInt() - 1;
				ls[(i + j) % 3][c]++;
			}
		int ans = Integer.MAX_VALUE;
		for(int i = 0; i < C; i++) {
			int t1 = 0;
			for(int l = 0; l < C; l++)
				t1 += D[l][i] * ls[0][l];
			for(int j = 0; j < C; j++) {
				if(i == j)
					continue;
				int t2 = t1;
				for(int l = 0; l < C; l++)
					t2 += D[l][j] * ls[1][l];
				for(int k = 0; k < C; k++) {
					if(j == k || k == i)
						continue;
					int t3 = t2;
					for(int l = 0; l < C; l++)
						t3 += D[l][k] * ls[2][l];
					ans = Math.min(ans, t3);
				}
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 86096
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>      // sqrt
#include <cstdlib>    // exit
#include <algorithm>  // min,max
using namespace std;
#define forr(i,m,n) for (int i=(m); i<=(n); i++)
#define forv(i,m,n) for (int i=(m); i>=(n); i--)
#define forall(it,p) for (auto it = p.begin(); it != p.end(); ++it)
#define R 1000000007
#define DBG 1
typedef pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define MAXN 100000
int a[MAXN];
unsigned c2i(char c) { return (c-'a'+1);}
int n;

bool foo(int l, const char* s) {
  ull b = 1000000007;
  ull t = 1;
  ull h = 0;
  forv(i,l-1,0) {
    h = (h+t*c2i(s[i]));
    t = t*b;
  }
  unordered_map<ull,int> g;
  g[h] = 0;
  forr(i,1,n-l) {
    h = (h*b-c2i(s[i-1])*t+c2i(s[i+l-1]));
    if (g.find(h) != g.end()) {
      if (g[h]+l <= i) return true;
    } else g[h] = i;
  }
  return false;
}

int main() {
  //int n;
  string s;
  cin >> n >> s;
  forv(i,n/2,1)
    if (foo(i,s.c_str())) {
      cout << i << endl;
      exit(0);
    }
  cout << 0 << endl;

}


Measured memory_bytes: 652
def is_prime(x):
    if x == 1:
        return False
    i = 2
    n = x
    while i < n:
        if x % i == 0:
            return False
        n = x // i
        i += 1
    return True


n = int(input())
ret = []
for i in range(n):
    x = int(input())
    if is_prime(x):
        ret.append(x)
print(len(ret))


Measured memory_bytes: 5612
n = int(input())
dic = {}
for i in range(n):
    tmp = ''.join(sorted(input()))
    if tmp in dic:
        dic[tmp] = dic[tmp]+1
    else:
        dic.setdefault(tmp, 0)
ans = 0
for i in dic:
    ans += 1/2 * dic[i] * (dic[i]+1)
print(int(ans))


Measured memory_bytes: 17848
/**
 *    Author:   Jay Sabale
 *	       
**/

#include<bits/stdc++.h>

using namespace std;
 
// Competetive Template:
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
typedef vector <lli> vl;
typedef vector <string> vs;
typedef vector < pair <long, long> > vll;

// Debugging :
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ba  back
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp make_pair 
#define mt make_tuple
#define fi first
#define se second
#define gcd __gcd
#define maxe *max_element
#define mine *min_element
#define deb debug
 
#define forz(i,n) for(lli i=0; i<n; i++)
#define rep(i,k,n) for (lli i = k; i < n; i++)
#define deci(n)  fixed<<setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n)  __builtin_ctz(n)
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)

// Printing Data :
#define pvec(v) forz(i,v.si) cout<<v[i]<<" "; cout<<endl;
#define parr(arr, n) forz(i,n) cout<<arr[i]<<" "; cout<<endl;
#define p1(i) cout<<i<<endl;
#define p2(i, j) cout<<i<<" "<<j<<endl;
#define p3(i, j, k) cout<<i<<" "<<j<<" "<<k<<endl;
#define p4(i, j, k, l) cout<<i<<" "<<j<<" "<<k<<" "<<l<<endl;

typedef pair <lli,lli> pll;

// CODE BEGINS :

int main()
{
    kira; 

    lli n; cin>>n;

    lli sum=0;

    for(lli i=1; i<=n; i++)
    {
        if(i%3!=0 && i%5!=0)
        sum+=i;
    }

    cout<<sum<<endl;

    return 0;
}




















































Measured memory_bytes: 3652
def atcoder2():
    a = [list(map(int,input().split())) for l in range(2)]

    n= a[0][0]
    x_l = a[1]

    P = sum(x_l)/n

    # print(a,n)
    # print(P)
    if P - int(P) >= 0.5:
        add= 1
    else:
        add = 0

    P = int(P)+add
    
    # print(P)

    result = 0
    for Xi in x_l:
        result = result + (Xi-P)**2 

    print(result)
    return 


atcoder2()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int n,a,b;cin>>n>>a>>b;
  int ans=0;
  reps(i,n){
    int sum=0;
    int tmp=i;
    while(tmp!=0){
      sum+=tmp%10;
      tmp/=10;
    }
    if(sum>=a&&sum<=b)ans+=i;
  }
  cout(ans);
  return 0;
}

Measured memory_bytes: 256