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


int main(){
    long long N,cnt=0;
    int A,B;
    cin>>N;
    for(int i=1;i*i<N;i++){
        cnt++;
    }
    int j=1;
    for(int i=2;i<N;i++){
        for(j=1;j<i;j++){
            if(i*j>=N){
                break;
            }
            cnt+=2;
            
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 7/1/2018
 
 9:20-10:30 give up
 17:00-18:16 Read editorials and add solution
 
 Key:
  - fix b
  - compute by cycle of modular arithmetic
 
 Summary:
  - I tried to fix either `a` or `b`. However O(1) or O(lg N) algorithm did not come up with me. Incredibly poor analysis 👎
 
 */

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
int N,K;
void solve() {
  if(K==0) {
    cout<<(LL)N*N<<endl;
    return;
  }
  LL res=0;
  FORE(b,1,N) {
    LL s=(N+1)/b,t=(N+1)%b;
    LL x=max((LL)b-K,0LL)*s,y=max(t-K,0LL);
    res+=x+y;
//    dump3(b,s,t);
//    dump3(b,x,y);
  }
  cout<<res<<endl;
}

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


Measured memory_bytes: 632
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define deb(x) cout << #x << " is " << x << "\n";

using namespace std;
using namespace __gnu_pbds;

const double PI = 2 * acos(0.0);
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    string s, t;
    cin >>n >>s >>t;
    for(int i = 0; i < n; i++)
        cout <<s[i] <<t[i];
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdlib>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	vector<int> v(n);
	for(int i=0;i<n;i++) cin>>v[i];
	sort(v.begin(),v.end());
	long long sum=0;
	for(int i=0;i<k;i++) sum+=v[i];
	cout<<sum<<'\n';
}

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

using namespace std;

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

typedef pair<int, int> ii;

const int mod = 1e9 + 7;

const int inf = 1e9;

int add(int x, int y) {
    return (1ll * x + 1ll * y) % mod;
}

int del(int x, int y) {
    return ((1ll * x - 1ll * y) % mod + mod) % mod;
}

int mul(int x, int y) {
    return (1ll * x * 1ll * y) % mod;
}

const int N = 1e5 + 5;

int n;
string s[N];

long long sum = 0;

vector<string> vec;

int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
        vec.pb(s[i]);
    }
    sort(vec.begin(), vec.end());
    for(int i = 0; i < n; i++) {
        int j = i;
        while(j < n && vec[i] == vec[j] && j < n)
            j++;
        j--;
        sum += 1ll * (j - i + 1) * (j - i) / (1ll * 2);
        i = j;
    }
    cout << sum;
}




Measured memory_bytes: 11252
#include <cstdio>
#include <iostream>
#include <queue>
#include <map>
#include <stack>
#include <string>
#include <cstdlib>
#define INT long long
using namespace std;

string s;
int g, p, n;

int main()
{
    cin>>s;
    for(int i = 0 ; i < s.size() ; i++)
        if( s[i] == 'g' ) g++;
        else p++;
    cout<<(g-p)/2<<endl;
    return 0;
}


Measured memory_bytes: 512
n=int(input())
from collections import Counter as co
g=list(map(int,input().split()))
l=co(g)
f=sum(g)
q=int(input())
for i in range(q):
    b,c=map(int,input().split())
    if b in l:
        v=l[b]
        l[b]=0
        l[c]+=v
        f=f-v*b+c*v
    print(f)

Measured memory_bytes: 20916
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val hoge = mutableListOf<Int>()
    var sum = 0
    var max = 0
    for (i in 1..n) {
        val temp = readLine()!!.toInt()
        sum += temp
        max = Math.max(max, temp)
    }
    print(sum - max / 2)
}


Measured memory_bytes: 31988
N = int(input())
S = [str(input()) for i in range(N)]

cnt_AC = S.count("AC")
cnt_WA = S.count("WA")
cnt_TLE = S.count("TLE")
cnt_RE = S.count("RE")

print("AC x " + str(cnt_AC))
print("WA x " + str(cnt_WA))
print("TLE x " + str(cnt_TLE))
print("RE x " + str(cnt_RE))

Measured memory_bytes: 83264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

int main(){
  int n,m;
  cin >> n >> m;
  ll x[n],y[n],z[n];
  for(int i = 0;i<n;++i){
    cin >> x[i] >> y[i] >> z[i];
  }
  //すべて正の時
  ll ans = 0;
  
  
  
  for(int j = 0;j<8;++j){
    int s[3] = {1 ,1 , 1};
    for(int k = 0;k<3;++k){
      if (!(j & (1<<k))) s[k] = -1;
    }
    
    ll sum[n];
    ll sumM = 0;
    for(int i = 0;i<n;++i){
      sum[i] = s[0]*x[i] + s[1]*y[i] + s[2]*z[i];
    }
    sort(sum,sum+SIZE_OF_ARRAY(sum), greater<>());
    for(int i = 0;i<m;++i) sumM += sum[i];
    ans = max(ans, sumM);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,m;cin>>a>>b>>m;
    vector<int> mv1(a);
    vector<int> mv2(b);
    for(int i=0;i<a;i++)cin>>mv1[i];
    for(int i=0;i<b;i++)cin>>mv2[i];
    int ans=1e9;
    for(int i=0;i<m;i++){
        int x,y,c;cin>>x>>y>>c;
        x--;y--;
        ans=min(ans,max(0,mv1[x]+mv2[y]-c));
        
    }
    sort(mv1.begin(),mv1.end());
    sort(mv2.begin(),mv2.end());
    ans=min(ans,mv1[0]+mv2[0]);
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] p = new int[n];
		for(int i = 0; i < n; i++)
			p[i] = sc.nextInt();
		
		int count = 0;
		for(int i = 1; i < n - 1; i++) {
			if((p[i] > p[i - 1] && p[i] < p[i + 1]) || (p[i] < p[i - 1] && p[i] > p[i + 1]))
				count++;
		}
		
		System.out.println(count);
	}

}


Measured memory_bytes: 21844
#define _USE_MATH_DEFINES //M_PI, M_E
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
ll power(ll a,ll b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll x,y;
	cin>>x>>y;
	int j = 0;
	for(ll i = x; i<=y; i*=2)
		j++;
	cout<<j<<endl;
	return 0;
}

Measured memory_bytes: 256
-- D
local N, Q = io.read("*n", "*n")
local children = {}
for i=1,N do
    children[i] = {}
end
for i=1,N-1 do
    local a, b = io.read("*n", "*n")
    table.insert(children[a], b)
end

local q = {}
for i=1,N do
    q[i] = 0
end
for i=1,Q do
    local p, x = io.read("*n", "*n")
    q[p] = q[p] + x
end

local counters = {}
for i=1,N do
    counters[i] = 0
end

local task = {}
local task_insert_ptr = 0
local function task_add(node, accum)
    task_insert_ptr = task_insert_ptr + 1
    task[task_insert_ptr] = {node, accum}
end
task_add(1, 0)
local task_remove_ptr = 1
local function task_remove()
    local t = task[task_remove_ptr]
    local n, a = t[1], t[2]
    task_remove_ptr = task_remove_ptr + 1
    return n, a
end
while #task >= task_remove_ptr do
    local node, accum = task_remove()
    local inc = q[node]
    counters[node] = accum + inc
    for k, child in ipairs(children[node]) do
        task_add(child, accum + inc)
    end
end

print(table.concat(counters, " "))


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

using namespace std;

int n, h[1000001], dp[1000001];

int main(void){
    cin >> n;
    for(int i = 0; i < n; i++) cin >> h[i];

    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    for(int i = 2; i < n; i++){
        dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
    }
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 4736
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair

typedef long long ll;
typedef long double ld;

ll f(ll n){
    ll res = n - n % 4;
    for(ll m = res + 1; m <= n; m++){
        res ^= m;
    }
    return res;
}

void solve(){
    ll a, b;
    cin >> a >> b;
    cout << (f(b) ^ f(a - 1)) << "\n";
    return;
}

int main(){
    IOS;
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
#include <climits>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>
#include <map>
#include <numeric>
#include <set>
using namespace std;

#define ll long long
#define ld long double
#define pi 3.14159265359f

// v:vector  type:型  order:greater or less
#define _sort(v,type,order) do { sort(v.begin(),v.end(),order<type>()); } while(0)
// vector 要素の総和算出
// v:vector  default_value:初期値
#define _sum(v,default_value) accumulate(v.begin(),v.end(),default_value )
// vector 最大値( return ite )
#define _max_element(v) max_element(v.begin(),v.end())
// vector 最大値が格納されている要素値
#define _max_element_number(v) distance(v.begin(),max_element(v.begin(),v.end()))

//set<uint32_t> member;	// 重複するデータを保持する事はできない member.insert(2) member.insert(2) ⇒ member.count(2)は1
//                                                              member.emplace(2)とかも同じ
//multiset<uint32_t> v;	// 重複するデータも保持する事はできる   member.insert(2) member.insert(2) ⇒ member.count(2)は2

// 丸め
#define _round(v) round(v)
// 2乗 / 3乗
#define _square(v) pow(v,2)
#define _cube(v)   pow(v,3)
// 大小判定
#define _max(x,y) max(x,y)
#define _min(x,y) min(x,y)
// string ⇒ int
#define _stringtoi(s) stoi(s)
// double 平方根
#define _sqrt(x) sqrt(x)
// double 引数 x 以上で最小の整数値 ex) 3.30303 ⇒ 4
#define _ceil(x) ceil(x)
// 指定された要素以上の値が現れる最初の位置のイテレータを取得する
#define _lower_bound(v,min) lower_bound(v.begin(), v.end(), min)
// 指定された要素より大きい値が現れる最初の位置のイテレータを取得する
#define _upper_bound(v,min) upper_bound(v.begin(), v.end(), min)

// 順列 n個の数が与えられる
// 0,1,2,...,n-1
// 全ての並べ方を1行ごとに出力する
// ex 0 1 2 / 0 2 1 / 1 0 2 / 1 2 0 / 2 0 1 / 2 1 0
#define _next_permutation(v) do {   \
	for (auto num : v) {            \
		printf("%d ", num);         \
	}                               \
	printf("\n");                   \
} while (next_permutation(v.begin(), v.end()))

// 絶対値
static int32_t _abs(const int32_t x) { return  (x > 0 ? x : -x); }
// 最大公約数
static int gcd(int a, int b)
{
	if (a < b) {
		a ^= b;
		b ^= a;
		a ^= b;
	}
	return b ? gcd(b, a % b) : a;
}
// 最小公倍数
static int lcm(int a, int b) { return a * b / gcd(a, b); }
// 多次元 std::vector 生成
template<class T>
vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
// ex) auto dp = make_vec<uint64_t>(SIZE + 1, 2, 2);

// UINT32_MAX
// 4294967295 ≒ 4*1e9 


/*

*/
// ABC 163 B
// https://atcoder.jp/contests/abc163/tasks/abc163_b
int main()
{
	uint32_t n,m;
	cin >> n >> m;

	uint32_t temp;
	for (uint32_t i = 0; i < m; i++) {
		cin >> temp;
		if (temp > n) {
			printf("-1\n");
			return 0;
		}
		n -= temp;
	}

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


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

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> d(K);
    map<int, int> mp;
    int num = 0;
    int temp = 0;
    
    rep(i, K){
        cin >> d[i];
        rep(j, d[i]){
            cin >> temp;
            mp[temp]++;
        }
    }

    cout << N - mp.size() << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

int main(){
	ll a, b, n; cin >> a >> b >> n;
	if(b <= n) n = b - 1;
	cout << floor(a * n / b) - a * floor(n / b) << endl;
}

Measured memory_bytes: 3788
s = gets.chomp
t = gets.chomp
if s==t
    puts "Yes"
    exit
end
f=false
s.length.times do |i|
    x=s[-1]+s[0..-2]
    if x==t
        f=true
        break
    end
    s=x
end
puts f ? "Yes" : "No"

Measured memory_bytes: 14308
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

using R = long double;

int d, n;
vi p, h;

inline R calc_v(R theta, int b){
    R dd = 1.0 * d / (b + 1);
    return sqrt(dd / (2.0 * sin(theta) * cos(theta)));
}

bool check(R theta, int b){
    R v = calc_v(theta, b);
    R vx = v * cos(theta);
    R vy = v * sin(theta);
    R dd = 1.0 * d / (b + 1);

    rep(i, n){
        R pos = p[i];
        while(pos > dd) pos -= dd;

        R y = -pow(pos, 2.0) / (2.0 * pow(vx, 2.0)) + pos * vy / vx;
        if(y < h[i]) return false;
    }

    return true;
}

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

    int B; cin >> d >> n >> B;
    p = vi(n), h = vi(n);
    rep(i, n) cin >> p[i] >> h[i];

    R res = inf;
    rep(b, B + 1){
        
        // 45
        R theta = PI / 4.0;
        R v = calc_v(theta, b);
        if(check(theta, b)){
            chmin(res, v);
            continue;
        }

        // others
        R lb = PI / 4.0, ub = PI / 2.0 - EPS;
        rep(loop, 100){
            theta = (lb + ub) / 2.0;
            if(check(theta, b)){
                ub = theta;
            }
            else {
                lb = theta;
            }
        }
        if(check(ub, b)){
            chmin(res, calc_v(ub, b));
        }
    }

    cout.precision(20);
    cout << fixed << res << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cmath>
#include <vector>
#include <cstring>
#include <map>

using namespace std;

bool used[10];
bool tabu[10];
int keisu[10];
int ans;
int cnt; // 文字数
int n;

void dfs(int k, int sum){
    if (k == cnt) {
        if (sum == 0) {
            ans++;
        }
        return;
    }
    
    for (int i = 0; i < 10; i++) {
        if (used[i] || (i == 0 && tabu[k])) {
            continue;
        }
        used[i] = true;
        dfs(k + 1, sum + i * keisu[k]);
        used[i] = false;
    }
    return;
}

int main(){
    while (cin >> n, n) {
        map<char, int> id;
        vector<string> str(n);
        cnt = 0;
        ans = 0;
        
        for (int i = 0; i < 10; i++) {
            used[i] = false;
            tabu[i] = false;
            keisu[i] = 0;
        }

        for(int i = 0; i < n; i++){
            cin >> str[i];
            string s = str[i];
            for (int j = 0; j < s.size(); j++) {
                if (id.find(s[j]) == id.end()) {
                    id[s[j]] = cnt++;
                }
                if (j == 0 && s.size() > 1) { // 0にならない記号か
                    tabu[id[s[j]]] = true;
                }
                if (i != n - 1) {
                    keisu[id[s[j]]] += pow(10, s.size() - j - 1);
                }else{
                    keisu[id[s[j]]] -= pow(10, s.size() - j - 1);
                }
            }
        }
        dfs(0, 0);
        cout << ans << endl;
    }
}

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

#define ll long long

int main() {
	// your code goes here
	ll n, m;
	cin >> n >> m;
	vector<vector<ll>> v(m, vector<ll>(n, 0));
	vector<ll> p(m);
	for(int i = 0; i < m; i++){
		ll k;
		cin >> k;
		for(int j = 0; j < k; j++){
			ll t;
			cin >> t;
			v[i][t - 1] = 1;
		}
	}
	for(int i = 0; i < m; i++){
		cin >> p.at(i);
	}
	ll ans = 0;
	
	for(int bit = 0; bit < (1<<n); bit++){
		int  an = 0;
		for(int i = 0; i < m; i++){
			int a = 0;
			for(int j = 0; j < n; j++){
				if(v[i][j] == 1){
					if(bit &(1 << j)){
						a++;
					}
				}
			}
			if(a % 2 == p[i]){
				an++;
			}
		}
		if(an == m){
			ans++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ull unsigned long long

void fast_IO() { ios_base::sync_with_stdio(false);cin.tie(NULL);}
void test_here_once(){ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);}

int main()
{
	ll n; cin>>n;
	ll h[n]; for(ll i=0;i<n;i++) cin>>h[i];

	ll dp[n];
	dp[0]=0;
	for(ll i=1;i<n;i++)
	{
		ll option1=INT_MAX, option2=INT_MAX;
		if(i>=1) option1= abs(h[i]-h[i-1]) + dp[i-1];
		if(i>=2) option2= abs(h[i]-h[i-2]) + dp[i-2];
		dp[i]=min(option1,option2);
	}
	cout<<dp[n-1];
}

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

int main() {
	
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	
	int x3 = x2 - (y2 - y1);
	int y3 = y2 + (x2 - x1);
	int x4 = x3 - (y3 - y2);
	int y4 = y3 + (x3 - x2);
	
	printf("%d %d %d %d\n", x3, y3, x4, y4);
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n,a[500],b[500];
ll c;
ll x[500][500],dp[500][500];

void solve(){
    cin >> n >> c;
    rep(i,n+1){
        rep(k,c+1){
            dp[i][c]=0;
            x[i][c]=0;
        }
    }
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n){
        vector<ll> v={};
        Rep(k,a[i],b[i]+1) v.push_back(1); 
        rep(k,c+1){
            Rep(j,a[i],b[i]+1) {
                x[i][k]+=v[j-a[i]];
                x[i][k]%=mod;
                v[j-a[i]]*=j;
                v[j-a[i]]%=mod;
            }
            //cout << i << " " << k << " " << x[i][k] << endl;
        }
    }

    dp[0][0]=1;
    rep(i,n){
        rep(k,c+1){
            rep(l,k+1){
                dp[i+1][k]+=dp[i][k-l]*x[i][l];
                dp[i+1][k]%=mod;
            }
        }
    }

    cout << dp[n][c] << endl;
}

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

Measured memory_bytes: 3456
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int main(){
	int n;
	while(cin>>n,n){
		int in[3]={0};
		int out[3]={0};
		while(n--){
			int a,b,c;
			scanf("%d:%d %d",&a,&b,&c);
			bool h=false;
			if(c>b&&c-b<=8||c<b&&60-b+c<=8)h=true;
			if(11<=a&&a<15){in[0]++;out[0]+=h;}
			else if(18<=a&&a<21){in[1]++;out[1]+=h;}
			else if(21<=a||a<2){in[2]++;out[2]+=h;}
		}
		string s[3]={"lunch","dinner","midnight"};
		rep(i,3){
			if(in[i])cout<<s[i]<<" "<<(int)(100.*out[i]/in[i])<<endl;
			else cout<<s[i]<<" no guest"<<endl;
		}
	}
}
 

Measured memory_bytes: 1252
#include<iostream>
#include<map>
#include<vector>

using namespace std;
int main()
{
    int cnt=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i] == '+')
            cnt++;
        else
            cnt--;
    }
    cout<<cnt<<endl;
    return 0;
}


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


using namespace std;



int main() {

	int K;
	string S, ans;

	cin >> K >>S;

	if (S.size() > K) {
		ans = S.substr(0, K) + "...";
	}
	else {
		ans = S;
	}

	cout << ans;

	return 0;

}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

bool a[4];
int main() {
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='S'){
			a[0]=true;
		}
		if(s[i]=='N'){
			a[1]=true;
		}
		if(s[i]=='E'){
			a[2]=true;
		}
		if(s[i]=='W'){
			a[3]=true;
		}
	}
	if(a[0]==a[1]&&a[2]==a[3]){
		cout <<"Yes";
	}
	else{
		cout << "No";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const auto INF = (ll)1e9;
using v = vector<int>;

int main(){
	int n,k;
  	cin >> n >> k;
  	string s;
  	cin >> s;
  	for(int i=0;i<n;i++){
    	cout<<(i==k-1?(char)(s[i]+0x20):s[i]);
    }
}


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

int main() {
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if(u == s) cout << a-1 << " " << b << '\n';
    else cout << a << " " << b-1 << '\n';

    return 0;
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from string import ascii_lowercase

    s = set(input())
    t = set(ascii_lowercase)
    u = t - s

    if u:
        v = sorted(list(u))
        print(v[0])
    else:
        print("None")


if __name__ == '__main__':
    main()


Measured memory_bytes: 69396
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int A[3],K;
  cin>>A[0]>>A[1]>>A[2]>>K;

  sort(A,A+3,greater<int>());
  for(int i=0;i<K;i++) A[0]*=2;

  cout<<A[0]+A[1]+A[2]<<endl;
}


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

int main()
{
    int n, x[101], i, j, s, minim=INT_MAX, p;
    cin>>n;
    for(i=1; i<=n; i++)
        cin>>x[i];
    for(i=1; i<=100; i++)
    {
        p=i;
        s=0;
        for(j=1; j<=n; j++)
            s+=(x[j]-p)*(x[j]-p);
        if(s<minim)
            minim=s;
    }
    cout<<minim;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 3010
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
#define INF 1000000000
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
   int n,m;
   cin>>n>>m;
   vector<int> c[m];
   vector<int> a(m);
   REP(i,m){
        int b;
        cin>>a[i]>>b;
        REP(j,b){
            int t;
            IN(t);
            t--;
            c[i].push_back(t);
        }
   }
   vector<int> dp((1<<n),INF);
   dp[0]=0;
   REP(i,m){
       int tmp=0;
       REP(j,SZ(c[i])){
           tmp|=(1<<c[i][j]);
       }
       for(int bit=0;bit<(1<<n);bit++){
        dp[bit|tmp]=min(dp[bit|tmp],dp[bit]+a[i]);
        }
   }
   if(dp[(1<<n)-1]==INF) dp[(1<<n)-1]=-1;
   OUT(dp[(1<<n)-1]);
    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

void Main(){
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << (H-h) * (W-w) << endl;
	return;
}

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


Measured memory_bytes: 256
//Never stop trying
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//s.order_of_key(), *s.find_by_order()

using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;

typedef pair<int,int> pi;
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;

#define pb push_back
#define eb emplace_back
#define pf push_front

#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

const int MOD = 1e9+7; //998244353
const ll INF = 1e18;
const int nx[4]={0,0,1,-1}, ny[4]={1,-1,0,0}; //right left down up

int32_t main(){
   boost;
   int N; cin>>N;
   int res=0;
   for(int i=1; i<=N; i++){
      int x; cin>>x;
      if(x%2==1 && i%2==1) res++;
   }
	cout << res << endl;

   return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a;
    cin >> a ;
    int flag=0;
    while(a>0){
        int b = a%10;
        a/=10;
        if(b==7){
            cout << "Yes";
            flag=1;
            break;
        }
    }
    if(flag==0)
        cout << "No";
    return 0;
}




Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;

string s,t;
int a[N],b[N],q,k,l,m,n;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> s >> t;
	for (int i=0;i<(int)s.size();i++){
		if (i) a[i]=a[i-1];
		a[i]+=s[i]-'A'+1;
	}
	for (int i=0;i<(int)t.size();i++){
		if (i) b[i]=b[i-1];
		b[i]+=t[i]-'A'+1;
	}
	cin >> q;
	while (q--){
		cin >> k >> l >> m >> n;
		k--;
		l--;
		m--;
		n--;
		cout << ((a[l]-(k?a[k-1]:0))%3 ==
		(b[n]-(m?b[m-1]:0))%3 ?
		"YES" : "NO") << "\n";
	}
}

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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

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

void solve(long long N, std::vector<long long> H) {
    int tot = 0;
    int ans = 0;
    for (int i = N - 1; i >= 0; i--) {
        if (H[i] >= (i + 1 < N ? H[i + 1] : 2e9)) {
            tot = tot + 1;
        } else {
            tot = 0;
        }
        ans = max(ans, tot);
    }
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> H(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &H[i]);
    }
    solve(N, std::move(H));
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int h, w, a, b;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> h >> w >> a >> b;
    a--;
    b--;
    for(int i = 0 ; i < h ; i++){
        for(int j = 0 ; j < w ; j++){
            cout << ((j > a) ^ (i > b));
        }
        cout << endl;
    }
}


Measured memory_bytes: 1280
n = int(input())
maps = [list(map(float,input().split())) for _ in range(n)]

ans = 0
for i in range(n):
    for j in range(n):
        if i == j:
            pass
        else:
            ans += ((maps[i][0]-maps[j][0])**2 + (maps[i][1]-maps[j][1])**2) **(1/2)
			
num = 1
for k in range(1,n+1):
    num *= k
print(ans/n)

Measured memory_bytes: 3064
#include <iostream>//数据输入输出流
#include <cstring>//字符串操作函数
#include <cstdio>//C的输入输出
#include <cstdlib>//定义杂项函数及内存分配函数
#include <cmath>//C中的数学函数
#include <string>//c++中的string类 他不能用strcpy等c函数去操作
#include <vector>//STL vetor
#include <list>//STL list
#include <map>// STL map
#include <queue>// STL queue
#include <stack>//sTL stack
#include <bitset>//bitset可按位定义串
//比如：bitset <1000> all;定义一个1000位的串
#include <algorithm>//STL各种算法 比如 swap sort merge max min 比较
#include <numeric>//常用数字操作 一般和algorithm搭配使用
#include <functional>//STL定义运算函数（代替运算符）
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
#define LOCAL
#define zeros(a,n) memset(a,0,(n)*sizeof(a[0]))
const int modn = 1e9+7;
int mod(int x) { return x<0?x+modn:x<modn?x:x-modn; }
//inv [ i ] = (modn - modn/i)*inv[ modn%i ] %modn;
const double PI = 3.1415926;
int main()
{
    int r;
    scanf("%d", &r);
    printf("%.10f\n", 2 * PI * r);
    return 0;
}



Measured memory_bytes: 3264
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;





signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s, t; cin >> s >> t;
	vector<char>a(26, '*'), b(26, '*');
	rep(i, s.size()) {
		if (a[s[i] - 'a'] == '*')a[s[i] - 'a'] = t[i];
		else if (a[s[i] - 'a'] != t[i]) {
			cout << "No" << endl; return 0;
		}
		if (b[t[i] - 'a'] == '*')b[t[i] - 'a'] = s[i];
		else if (b[t[i] - 'a'] != s[i]) {
			cout << "No" << endl; return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 916
using System;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        new Program().Solve();
    }

    public void Solve()
    {
        int[] nk = ReadLine().Split().Select(int.Parse).ToArray();
        int n = nk[0], k = nk[1];
        int[] d = ReadLine().Split().Select(int.Parse).ToArray();
        while (n.ToString().Any(x => d.Contains(x - '0')))
        {
            n++;
        }
        Console.WriteLine(n);
    }
}

Measured memory_bytes: 15420
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine();
        String param[] = input.split(" ");
        int a = Integer.parseInt(param[0]);
        int b = Integer.parseInt(param[1]);
        if(a < b) {
            System.out.println("a < b");
        }else if(a > b){
            System.out.println("a > b");
        }else if(a == b){
            System.out.println("a == b");
        }
    }
}

Measured memory_bytes: 24420
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define ms(s,x) memset(s,x,sizeof(s))
#define pb push_back
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;

const double PI = acos(-1.0);
const double eps = 1e-8;
const ll MOD = 1e9+7;
const int MAXN = 1e5+5;

int main()
{
    bool flag = 1;
    int n, num;
    cin >> n;
    while (n--)
    {
        cin >> num;
        if (!(num&1) && num%3 && num%5)
            flag = 0;
    }
    if (flag)
        cout << "APPROVED" << endl;
    else
        cout << "DENIED" << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const int MOD=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

struct UnionFind {
	vector<int> par;

	UnionFind(int n) : par(n, -1) { }
	void init(int n) { par.assign(n, -1); }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

int main(){
	ll n,m;
	cin>>n>>m;
	UnionFind tree(n);
	int x[M],y[M];
	//切るのは嫌なのでくっつけていく
	rep(i,0,m)cin>>x[i]>>y[i],x[i]--,y[i]--;
	ll cnt=n*(n-1)/2;
	vl ans;
	rep(i,0,m){
		ans.push_back(cnt);
		int a=x[m-1-i],b=y[m-1-i];
		if(tree.same(a,b))continue;
		ll sa=tree.size(a),sb=tree.size(b);
		cnt-=sa*sb;
		tree.merge(a,b);
	}
	reverse(ALL(ans));
	for(auto v:ans)print(v);
}



Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <complex>

using namespace std;
using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using i32 = int_fast32_t;
using u32 = uint_fast32_t;

#define int i64

signed main() {
	string s;
	cin >> s;
	int n = s.size();

	int res = 0;
	for(int bit = 0; bit < (1 << (n - 1)); bit++) {
		int sum = 0;
		int now = 0;
		for(int i = 0; i < n; i++) {
			now *= 10;
			now += s[i] - '0';
			if(bit & (1 << i)) {
				sum += now;
				now = 0;
			}
		}
		sum += now;
		res += sum;
	}

	cout << res << endl;
	
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int, X: int, Y: int):
    cost = float("inf")

    cost = min(cost,A*X + B*Y)
    cost = min(cost,max(X,Y)*2*C)
    if X > Y:
        cost = min(cost,Y*2*C + (X-Y)*A )
    else:
        cost = min(cost,X*2*C + (Y-X)*B )

    print(cost)



# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(A, B, C, X, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!int;
  int[int] cnt;
  foreach (i; 0..n) {
    auto d = readln.chomp.to!int;
    cnt[d]++;
  }
  cnt.keys.length.writeln;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=5e3+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int a[N],n,k;
bitset<N>s; 
bool check(int x){
	if(a[x]>=k) return true;
	s.reset();s[0]=1;
	for(int i=1;i<=n;i++) if(i!=x) s|=s<<a[i];
	for(int i=k-1;i>=k-a[x];i--) if(s[i]) return true;
	return false; 
}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	int l=1,r=n+1;
	while(l<r){
		int mid=(l+r)>>1;
		if(check(mid)) r=mid;
		else l=mid+1;
	}
	printf("%d",l-1);
	return 0;
}

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

int main ()
{
    int n,m,c=0;
    double s=0;
    cin>>n>>m;
    int x[n];
    for(int i=0;i<n;i++){
        cin>>x[i];
        s+=x[i];
    }
    s=s/(4.0*m);
    sort(x,x+n);
    for(int i=n-1;i>=0;i--)
    {
        if(x[i]>=s)c++;
        else break;
    }

    if(c>=m)cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}


Measured memory_bytes: 256
while true
  n = gets.to_i
  break if n == 0
  c = Array.new(n){gets.split(" ")}.transpose
  m = gets.to_i
  str = ""
  cur = 0
  m.times do
    l = gets.chomp
    idx = c[0].index(l)
    l = c[1][idx] unless idx.nil?
    str += l
  end
  puts str
end

Measured memory_bytes: 98084
//written by: rishav2416
#include <bits/stdc++.h>
#define ll long  long
#define lli long long int
#define ld long double
#define mod 1000000000000000000
#define max_char 128
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define lbd lower_bound
#define ubd upper_bound
#define PI 3.141592653589793238
#define pf push_front
#define all(x) x.begin(),x.end()
#define input(arr,n) for(ll c1=0;c1<n;c1++)cin>>arr[c1];
#define arrinit(arr,n,k) for(ll c1=0;c1<n;c1++) arr[i]=k;
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define revrep(i,a,n) for(ll i=a; i>=n ; i--)
#define mems(x, y) memset(x, y, sizeof(x))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define INF 1e18a



ll power(ll base,ll pow, ll mo)
{
   ll res=1;
   while(pow)
   {
        if (pow%2!=0)  res=(res*base)%mo;
        base=(base*base)%mo;
        pow/=2;
   }
   return res;
}

ll inv(ll i){//mod must be prime and i must be coprime with mo
	return power(i,mod-2,mod);
}

std::string str="All Good Till Here";

/////////////////////////////////////////////////////////////////////////////////

void solve()
{
  ll i,j,x,n;
  cin>>n;
  lli a[n];
  input(a,n);
  sort(a,a+n);
  lli p=1;
  rep(i,0,n)
  {
    if(a[i]==0)
    {
      cout<<0<<'\n';
      return;
    }
  }
  rep(i,0,n)
  {
    if(a[i]>(mod/p))
    {
      cout<<-1<<"\n";
      return;
    }
    else
    p*=a[i];
  }
  cout<<p<<"\n";
  return;

}
int32_t main()
{
    fastio
	ll tt;
	// cin>>tt;
  tt=1;
	while(tt--)
	{
    solve();
	}
    return 0;
}


Measured memory_bytes: 4436
#!/usr/bin/env python

def f(n: int, x: int, t: int) -> int:
    """
    >>> f(20, 12, 6)
    12
    """
    ans = ((n // x + (1 if n % x > 0 else 0))) * t
    return ans


if __name__ == '__main__':
    n, x, t = map(lambda x: int(x), input().split())
    print(f(n, x, t))

Measured memory_bytes: 9088
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rel register ll
#define rec register char
#define gc getchar
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<23,stdin),p1==p2)?-1:*p1++)
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
char buf[1<<23],*p1=buf,*p2=buf;
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) pc('-'),x=-x;
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=5e5;
typedef int fuko[yuzu|10];
struct node {
  int l,r,id;
  void rd(int x) {
    read(l),read(r),id=x;
  }
}qr[yuzu|10];
fuko c,cnt,lxy;
int main() {
  int i,n,q,bk;
  read(n),read(q),bk=sqrt(n);
  for (i=1;i<=n;++i) c[i]=read();
  for (i=1;i<=q;++i) qr[i].rd(i); 
  sort(qr+1,qr+q+1,[&](node a,node b){return a.l/bk^b.l/bk?a.l<b.l:a.r<b.r;});
  int nl=1,nr=0,ans=0;
  for (i=1;i<=q;++i) {
    for (;nr<qr[i].r;) !cnt[c[++nr]]++?++ans:0;
    for (;nr>qr[i].r;) !--cnt[c[nr--]]?--ans:0;
    for (;nl<qr[i].l;) !--cnt[c[nl++]]?--ans:0;
    for (;nl>qr[i].l;) !cnt[c[--nl]]++?++ans:0;
    lxy[qr[i].id]=ans;
  } 
  for (i=1;i<=q;++i) printf("%d\n",lxy[i]);
}

Measured memory_bytes: 15452
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        // final int a = sc.nextInt();
        // 文字列の入力
        // final String s1 = sc.next();
        long n = sc.nextInt();
        long k = 1;
        long l = 1;
        for (int i = 0; i < n; i++) {
            l = sc.nextLong();
            if (k == -1) {
                if (l == 0) {
                    k = 0;
                    break;
                } else {
                    continue;
                }
            }
            if (Math.log10(k) + Math.log10(l) > 18 || l * k > 1000000000000000000L) {
                k = -1;
                continue;
            }
            k = l * k;
        }

        sc.close();
        System.out.println(k);
    }
}

Measured memory_bytes: 59520
n=gets.chomp.to_i
a=gets.chomp.split(" ").map{|s| s.to_i}.insert(0,nil)
b=[]
b[n/2+1..n]=a[n/2+1..n]
i=n/2
while i!=0
  sum=0
  for j in 2..n/i
    sum+=b[i*j]
  end
  if sum%2==a[i]
    b[i]=0
  else
    b[i]=1
  end
  i-=1
end
p b[1..n].inject(:+)
for i in 1..n
  printf "#{i} " if b[i]==1
end

Measured memory_bytes: 21644
#include <iostream>
#include <string>

using namespace std;

void resolve()
{
    int A, B, C;
    cin >> A >> B >> C;

    string ans;
    ans = (A == B && A == C)
              ? "No"
              : (A == B) ? "Yes" : (B == C) ? "Yes" : (C == A) ? "Yes" : "No";

    cout << ans << endl;
}

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


Measured memory_bytes: 256
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]
if x in a and y in a:
  print("Yes")
elif x in b and y in b:
  print("Yes")
elif x in c and y in c:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060