akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

bool check(string S, int l, int r) {
    // cout << S[l] << " " << S[r] << endl; 
    while (l < r) {
        if (S[l] != S[r]) {
            // cout << "false " << S[l] << " " << S[r] << endl; 
            return false;
        }
        l++; r--;
    }
    return true;
}

int main() {
    string S; cin >> S;

    if (!check(S, 0, S.size() - 1)) {
        cout << "No" << endl;
        return 0;
    }

    if (!check(S, 0, (S.size() - 1) / 2 - 1)) {
        cout << "No" << endl;
        return 0;
    }
    
    if (!check(S, (S.size() + 3) / 2 - 1, S.size() - 1)) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <queue>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long LL;
const int N = 1100005, INF = 1<<25;

int in[N], n, cc[129];
bool used[N];
char str[N];
vector<int>g[129];

int lowbit(int t)
{
    return t&(t^(t-1));
}

int sum(int end)
{
    int ans=0;
    while(end>0)
    {
        ans+=in[end];
        end-=lowbit(end);
    }
    return ans;
}

void add(int pos ,int num)
{
    while(pos<=n)
    {
        in[pos]+=num;
        pos+=lowbit(pos);
    }
}

void solve()
{
    memset(in, 0, sizeof(in));
    for(int i=1; i<=n+1; i++)
    {
        add(i,1);
    }
    LL ans = 0;
    int v, u, size;
    char s;
    memset(used, 0, sizeof(used));
    for(int i=1; i<=n; i++)
    {
        if(!used[i])
        {
            s = str[i];
            size = g[s].size();
            u = g[s][size-1];
            if(i == u)
            {
                ans += (sum(n) - sum(i))/2;
            }
            else
            {
                ans += sum(n) - sum(u);
            }
            add(u, -1);
            add(i, -1);
            used[i] = used[u] = 1;
            g[s].erase(g[s].end()-1);
        }
    }
    printf("%lld", ans);
    puts("");
}

int main()
{
    scanf("%s", str+1);
        n = strlen(str+1);
        memset(cc, 0, sizeof(cc));

        for(int i=1; i<129; i++)
            g[i].clear();

        for(int i=1; i<=n; i++)
        {
            cc[str[i]]++;
            g[str[i]].push_back(i);
        }

        int flag = 0;
        for(int i=0; i<26; i++)
        {
            if(cc['a'+i]%2) flag++;
            if(cc['A'+i]%2) flag++;
        }
        if(flag > 1)
        {
            printf("-1");
            puts("");
        }
        else
        {
            solve();
        }
    return 0;
}

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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int H, W;
char field[10][20];

int ma;
string mas;

set<string> S;

void add_string(int i, int n, int m, int x, int y) {
    REP(j, n) {
        int sx = x, sy = y;
        stringstream ss;
        ss << field[sy][sx];
        REP(k, m) {
            sx = (sx + dx[i] + W) % W;
            sy = (sy + dy[i] + H) % H;
            ss << field[sy][sx];
            string s = ss.str();
            if (!S.insert(s).second) {
                if (ma < (int)s.length()) {
                    ma = s.length();
                    mas = s;
                } if (ma == (int)s.length()) {
                    mas = min(mas, s);
                }
            }
        }
        x = (x + dx[i] + W) % W;
        y = (y + dy[i] + H) % H;
    }
}

int main() {
    while (cin >> H >> W, H|W) {
        REP(y, H) REP(x, W) cin >> field[y][x];
        S.clear();

        ma = 0;
        REP(i, 8) {
            if (i < 4) {
                if (i % 2 == 0) {
                    REP(y, H) add_string(i, W, W-1, 0, y);
                } else {
                    REP(x, W) add_string(i, H, H-1, x, 0);
                }
            } else {
                int n = (H == W ? H : H*W);
                REP(x, W) REP(y, H) {
                    add_string(i, 1, n-1, x, y);
                }
            }
        }
        if (ma == 0) {
            cout << 0 << endl;
        } else {
            cout << mas << endl;
        }
    }
}

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

int MX = 200000;
vector<vector<int>> G(MX,vector<int>());
vector<int> ans(MX);

void dfs(int i,int p = -1){
    for(auto v : G[i]){
        // pは親、iは今見ている頂点、vは子
        if(v == p) continue;
        ans[v] += ans[i];
        dfs(v,i);
    }
    return;
}

int main(){
    int n,q;
    cin >> n >> q;
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i,q){
        int p,x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }
    dfs(0);
    rep(i,n) printf("%d ",ans[i]);
}

Measured memory_bytes: 23424
from fractions import gcd
a, b, c, d = map(int, input().split(' '))

# cye bolunenler
c_numbers = b//c - (a-1)//c
# dye bolunenler
d_numbers = b//d - (a-1)//d
# ortak bolunenler
gcd_number = c*d // gcd(c, d)
ortak = b//(gcd_number) - (a-1)//(gcd_number)
# result
print(b-a+1-(c_numbers+d_numbers-ortak))

Measured memory_bytes: 5048
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e5+5;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll a,b,n;cin>>a>>b>>n;
    if(b-1<=n)return cout<< (a*(b-1))/b  - a*((b-1)/b) , 0;
    if(a%b)return cout<< (a*n)/b - a*(n/b) , 0;
    ll mx = 0;
    for(ll i=1;i<=a;i++){
        ll v1 = (a*i)/b;
        ll v2 = a*(i/b);
        mx=max(mx,v1-v2);
    }
    cout<<mx;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // [b,c) イテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int n; cin >>n ;
VI a(n); rep(i, 0, n) cin >> a[i];

for (int i = n - 1; i >= 0; i -= 2)
    cout << a[i] << " ";
for (int i = n%2; i < n; i += 2)
    cout << a[i] << " ";

cout << endl;
}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;

    if (n % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }

    if (s.substr(0,n/2) == s.substr(n/2, n/2)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
typedef pair<int, int> P;

int h, w, n;
int py[200000], px[200000];
set<P> walls;
int tc[200000];	//tc[col] = col(>=0)列目に到達する最初の行(高橋君が壁にぶつかるのはアリとして考える）

int main() {
	int i;
	
	cin >> h >> w >> n;
	rep(i, n) {
		cin >> py[i] >> px[i];
		py[i]--;
		px[i]--;
		walls.insert(P(py[i], px[i]));
	}
	
	tc[0] = 0;
	for (i = 1; i < w; i++) {
		tc[i] = tc[i - 1] + 1;
		while (walls.find(P(tc[i], i)) != walls.end()) tc[i]++;
	}
	
	int ans = h;
	rep(i, n) {
		if (tc[px[i]] < py[i]) {
			ans = min(ans, py[i]);
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 11904
String.prototype.splitByIndention = function () {
        return this.split('\n');
}
String.prototype.splitBySpace = function () {
        return this.split(' ');
}
Array.prototype.parseIntToEach = function () {
        return this.map(x => Number(x));
}

function fun(value) {
        return (value * (value - 1)) / 2;
}

const input = require('fs').readFileSync('/dev/stdin', 'utf8');

function main(input) {
        const N = Number(input.shift());
        var S = input;

        S = S.map(x => {
                var result = Array(26).fill(0);
                x = x.split('');
                for (var i = 0; i < x.length; i++) result[x[i].codePointAt(0) - 97]++;
                return result.join('');
        });

        var result = {};
        for (var i = 0;i < S.length;i++) result[S[i]] = (result[S[i]] || 0) + 1;

        var total = 0;
        for (key in result){
          		if(result[key] !== 1){
            			total += fun(result[key]);
          		}
        }

        console.log(total);
};

main(input.splitByIndention());

Measured memory_bytes: 62440
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
main(){
  int N;
  cin >> N;
  vector<int> V(N);
  for(int i = 0;i < N;i++)cin >> V[i];
  sort(V.rbegin(), V.rend());
  int sum = 0;
  for(int i = 0;i < N;i++){
    sum += V[i];
  }
  sum -= V[0] / 2;
  cout << sum << endl;
}  


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

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; }
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
using Graph = vector<vector<int>>;
queue<int> quex,quey;
const int MOD = 1000000007;




int main(){
    int n,m,all=0,cnt=0;    cin >> n >> m;
    int s[m],c[m];
    rep(i,m){ cin >> s[i] >> c[i]; if(s[i]==1) cnt++;}

  if(n!=1 && m==0) {cout << pow(10,n-1) << endl; return 0;}
  else if(m==0) {cout << 0 << endl; return 0;}


    for(int i=0;i<m-1;i++){
        for(int j=i+1;j<m;j++){
            if(s[i]==s[j] && c[i]!=c[j]) {cout << -1 << endl;return 0;}
            
        }
    }

    for(int i=0;i<m;i++) {
        if(n!=1 && c[i]==0 && s[i]==1) {cout << -1 << endl; return 0;}
    }


    for(int i=0;i<m-1;i++){
        for(int j=i+1;j<m;j++){
        
            if(s[i]==s[j] && c[i]==c[j]) {all-=c[i]*pow(10,n-s[i]);break;}
        
            
        }
    }

    for(int i=0;i<m;i++) all+=c[i]*pow(10,n-s[i]);
    if(cnt==0) all+=pow(10,n-1);

    cout << all << endl;


}

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

int main(){
    int n,c=0;
    cin >> n;
    vector<int> h(n);
    for(int i=0;i<n;i++) cin >> h[i];
    for(int i=0;i<n;i++){
        bool flag=1;
        for(int j=0;j<i;j++){
            if(h[i]<h[j]){
                flag=0;
                break;
            }
        }
        if(flag) c++;
    }
    cout << c << endl;
}


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

int main()
{
  string s;
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5]){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long m,k;
    cin>>m>>k;
    long long a[(1<<(m+1))+1];
    long long g=(1LL<<m)-1;
    if(k>g)
    {
        cout<<"-1\n";
        return 0;
    }
    if(k==0)
    {
        int c=0;
        int i;
        for(i=1;i<=(1<<(m+1));i+=2)
        {
            cout<<c<<" "<<c<<" ";
            c++;
        }
        return 0;
    }
    long long gg=0;
    long long int i;
    for(i=0;i<=(1<<m)-1;i++)
    {
        if(i!=k)
        {
            gg^=i;
        }
    }
    if(gg==k)
    {
        cout<<k<<" ";
        for(i=0;i<=(1<<m)-1;i++)
        {
            if(i!=k)
            {
                cout<<i<<" ";
            }
        }
        cout<<k<<" ";
        for(i=(1<<m)-1;i>=0;i--)
        {
            if(i!=k)
            {
                cout<<i<<" ";
            }
        }
    }
    else
    {
        cout<<"-1\n";

    }
    return 0;
    int pos=-1,pos2=0;
    vector<int>v,vv;
    long long ans1=0,ans2=0;
//    int i;
    for(i=0;i<m;i++)
    {

        if(k&(1<<i))
        {
            v.push_back(i);
        }
        else
        {
            vv.push_back(i);
        }
    }
    if(v.size()<1&&vv.size()==1)
    {
        cout<<"-1\n";
        return 0;
    }
    if(vv.size()<1&&v.size()==1)
    {
        cout<<"-1\n";
        return 0;
    }
    if(v.size()>=2)
    {
        for(i=0;i<m;i++)
        {
            if(k&(1<<i)&&i!=v[0]&&i!=v[1])
            {
                ans1+=(1<<i);
                ans2+=(1<<i);
            }
            if(i==v[0])
            {
                ans1+=(1<<i);
            }
            if(i==v[1])
            {
                ans2+=(1<<i);
            }
        }
        vector<long long>kyo;
        for(i=0;i<=((1<<m)-1);i++)
        {
            if(i!=k&&i!=ans1&&i!=ans2)
            {
                cout<<i<<" ";
                kyo.push_back(i);
            }
        }
        kyo.push_back(ans1);
        kyo.push_back(ans2);
        cout<<k<<" "<<ans1<<" "<<ans2<<" "<<k<<" ";
        reverse(kyo.begin(),kyo.end());
        for(i=0;i<kyo.size();i++)
        {
            cout<<kyo[i]<<" ";
        }
        return 0;
    }

        for(i=0;i<m;i++)
        {
            if(k&(1<<i)&&i!=v[0]&&i!=v[1])
            {
                ans1+=(1<<i);
                ans2+=(1<<i);
            }
            if(i==v[0])
            {
                ans1+=(1<<i);
            }
            if(i==vv[0])
            {
                ans1+=(1<<i);
                ans2+=(1<<i);
            }
        }
        vector<long long>kyo;
        for(i=0;i<=((1<<m)-1);i++)
        {
            if(i!=k&&i!=ans1&&i!=ans2)
            {
                cout<<i<<" ";
                kyo.push_back(i);
            }
        }
        kyo.push_back(ans1);
        kyo.push_back(ans2);
        cout<<k<<" "<<ans1<<" "<<ans2<<" "<<k<<" ";
        reverse(kyo.begin(),kyo.end());
        for(i=0;i<kyo.size();i++)
        {
            cout<<kyo[i]<<" ";
        }
    return 0;
}


Measured memory_bytes: 1792
///*
#include<iostream>
#include<vector>
using namespace std;

int main() {

	int element;
	int VC = 0;
	cin >> element;

	vector<int> value(element), cost(element);

	for (int number = 0; number < element; number++) {
		cin >> value[number];
	}
	for (int number = 0; number < element; number++) {
		cin >> cost[number];
		if (value[number] - cost[number] > 0) {
			VC += value[number] - cost[number];
		}
	}

	cout << VC;

	return 0;
}

//*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000007
vector<pair<int,char> > i;
int u[1111111];
int y[1111111]={1000000,100000,10000,100};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d,e=0,f=0;
  for(int n=0;n<3;n++){
    cin >>a;
    if(a==5) e++;
    if(a==7) f++;
  }
  if(e==2&&f==1) cout <<"YES\n";
  else cout <<"NO\n";
  return (0);
}


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).ok();
    let s = buf.trim().as_bytes();
    let mut res = s.len();
    for i in 1..s.len() {
        if s[i] != s[i-1] {
            res = std::cmp::min(res, std::cmp::max(i, s.len()-i));
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 4352
#include <string>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <math.h>
 
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
 
	int x;
    int y = 0;
	cin >> x;
    vector<int> vec(114514);
    for(int i=0; i<x;i++){
      cin >> vec.at(i);
    }
    for(int i=0;i<x;i++){
      for(int j= i+1;j<x;j++){
          y += vec.at(i)*vec.at(j); 
      }
    }
      cout << y << "\n";
  
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
        ll N, K; cin >> N >> K;

        ll a = N % K;
        if (a) {
                cout << min(abs(a-K), a) << endl;
        }
        else {
                cout << a << endl;
        }




}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
long long a[1111],t[1111];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		long long  p,q;
		cin>>p>>q;
		a[i]=p;t[i]=q;
		if(a[i]>=a[i-1]&&t[i]>=t[i-1]) continue;
		
		long long m=max((a[i]+a[i-1]-1)/a[i],(t[i]+t[i-1]-1)/t[i]);
		a[i]=a[i]*m;
		t[i]=t[i]*m;
	//	cout<<i<<" "<<m<<" "<<a[i]<<" "<<t[i];
		/*
		while(a[i]<a[i-1]||t[i]<t[i-1])
		{
			a[i]+=p;
			t[i]+=q;
		}*/
	}
	cout<<a[n]+t[n];
	return 0;
}

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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(A+B > C+D){
  cout << "Left" << endl;
  }
  else if(A+B == C+D){
  cout << "Balanced" << endl;
  }
  else {
  cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-9;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

vector <string> Vl[16];
set <int> Sx[16];

int tus;
int p;
char u[17];
int parseE() {
	if (u[p] == '0') {
		p++;
		return 0;
	}
	if (u[p] == '1') {
		p++;
		return 1;
	}
	if (u[p] >= 'a' && u[p] <= 'd') return !!(tus & (1 << (u[p++] - 'a')));

	if (u[p] == '-') {
		p++;
		return !parseE();
	}
	if (u[p] == '(') {
		p++;
		int t1 = parseE();
		char c = u[p++];
		int t2 = parseE();
		p++;
		if (c == '^') return t1^t2;
		else return t1&t2;
	}
	return 0;
}
int myeval(string str) {
	for (int i = 0; i < str.size(); i++) u[i] = str[i];

	int rv = 0;
	for (tus = 0; tus < 16; tus++) {
		p = 0;
		rv |= parseE() << tus;
	}
	//printf("str = %s, %d\n", str.c_str(), rv);
	return rv;
}
int main() {
	int i, j, k, l;

	Vl[1].emplace_back("0");
	Vl[1].emplace_back("1");
	Vl[1].emplace_back("a");
	Vl[1].emplace_back("b");
	Vl[1].emplace_back("c");
	Vl[1].emplace_back("d");
	for (i = 2; i < 16; i++) {
		for (auto it : Vl[i - 1]) {
			if (it[0] == '-') continue;
			Vl[i].push_back(string("-") + it);
		}
		if (i < 5) continue;

		for (j = 1; j <= i - 3 - j; j++) {
			for (auto it1 : Vl[j]) for (auto it2 : Vl[i - 3 - j]) {
				Vl[i].emplace_back(string("(") + it1 + string("^") + it2 + string(")"));
				Vl[i].emplace_back(string("(") + it1 + string("*") + it2 + string(")"));
			}
		}
	}

	for (i = 1; i <= 15; i++) for (auto it : Vl[i]) Sx[i].insert(myeval(it));

	while (1) {
		scanf("%s", u);
		if (u[0] == '.') break;

		int L = strlen(u);
		int x = myeval(string(u));
		for (i = 1; i < L; i++) if (Sx[i].count(x)) break;
		printf("%d\n", i);
	}
	return 0;
}

Measured memory_bytes: 28360
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int i,j,n,k,x;
  double ans=0;
  cin >> n >> k;
  for(i=1;i<=n;i++){
    j=i,x=0;
    while(j<k){
      j=j*2;
      x++;
    }
    double ans1=1/double(n);
    for(j=0;j<x;j++){
      ans1=ans1/2;
    }
    ans+=ans1;
  }
  printf("%.12lf\n",ans);
  return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll a, b, c;
    cin >> a >> b >> c;
    cout << min(b / a, c) << endl;
    return 0;
}

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

const int M_N=200001;

struct BIT{
    //1-indexed
    LL bit[M_N+1],n;

    LL sum(int i){
        LL s=0;
        while(i>0){
            s+=bit[i];
            i=i&(i-1);
        }
        return s;
    }

    void add(int i,LL x){
        while(i<=n){
            bit[i]+=x;
            i+=i&-i;
        }
    }

};

BIT bit;
map<LL,LL> ma;

int main(){
    int N,t=0;
    LL K;
    cin >> N >> K;
    bit.n=N+1;
    vector<LL> A,T;
    for(int i=0;i<N;i++){
        LL a;
        cin >> a;
        A.eb(a-K);
    }
    LL sum=0;
    for(int i=0;i<N;i++){
        sum+=A[i];
        T.eb(sum);
    }
    A=T;
    T.push_back(0);
    sort(ALL(T));
    for(int i=0;i<=N;i++){
        ma[T[i]]=i+1;
    }
    LL ans=0;
    bit.add(ma[0],1);
    for(int i=0;i<N;i++){
        ans+=bit.sum(ma[A[i]]);
        bit.add(ma[A[i]],1);
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long				ll;
typedef unsigned long long 	    ull;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	char c;
	cin >> c;
	cout << (char)((int)(c + 1)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
  ll i,n,j,a[10010],b[10010];
  map<ll,ll> x;
  cin >> n;
  mint ans=1;
  for(i=0;i<n;i++){
    cin >> a[i];
    b[i]=a[i];
    map<ll,ll> y;
    for(j=2;j*j<=a[i];j++){
      while(b[i]%j==0){
        y[j]++;
        b[i]=b[i]/j;
      }
      if(x[j]<y[j]){
        x[j]=y[j];
      }
    }
    if(b[i]!=1 && x[b[i]]<y[b[i]]+1){
      x[b[i]]=y[b[i]]+1;
    }
  }
  for(i=1;i<=1000000;i++){
    ans=ans*modpow(i,x[i],mod);
  }
  mint ans1=0;
  for(i=0;i<n;i++){
    ans1+=ans/a[i];
  }
  printf("%lld\n",ans1);
  return 0;
}

Measured memory_bytes: 66300
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;

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;}

//pow(llpow,modpow)
template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
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;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
struct UnionFind{
    vi par;

    UnionFind(int n): par(n,-1){}

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

    bool issame(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);
        par[x]+=par[y];
        par[y]=x;
        return true;
    }

    int size(int x){
        return -par[root(x)];
    }
};
long long INF = 1LL<<60;
int main(){
    int n,m,k;
    cin>>n>>m>>k;
    UnionFind uf(n);
    vector<set<int>> connect(n);

    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--; b--;
        connect[a].insert(b);
        connect[b].insert(a);
        uf.merge(a,b);
    }
    rep(i,k){
        int c,d;
        cin>>c>>d;
        c--; d--;
        if(!uf.issame(c,d))continue;
        connect[c].insert(d);
        connect[d].insert(c);
    }

    rep(i,n){
        int res=uf.size(i)-1;
        res-=connect[i].size();
        cout<<res<<" ";
    }
    cout<<endl;
    return 0;
}




Measured memory_bytes: 24704
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N, K;
  cin >> N >> K;
  vector<int64_t> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  vector<int64_t> dp(N);
  for(int i=1; i<N; i++){
    int64_t x = 10000000000;
    for(int j=1; j<=K; j++){
      if(i-j < 0){
        break;
      }
      x = min(x,dp.at(i-j) + abs(vec.at(i) - vec.at(i-j)));
    }
    dp.at(i) = x;
  }
  cout << dp.at(N-1) << endl;
}

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

using namespace std;

const int MaxN = 1e5 + 15;
const int MaxK = 1e2 + 12;
const int MOD = 1e9 + 7;

int dp[MaxK][MaxN];
int n, k;
int d[MaxN], rd[MaxN];
map<int, int> pos;

int main() {
    cin >> n >> k;
    
    int cnt = 0;
    for(int l = 1; l <= n;)
    {
        ++cnt;
        d[cnt] = n / (n / l);
        pos[d[cnt]] = cnt;
        rd[cnt] = n / d[cnt];
        l = d[cnt] + 1;
    }
    
    for(int i = 1; i <= cnt; ++i)
        dp[1][i] = d[i];
        
    for(int i = 2; i <= k; ++i)
    {
        for(int j = 1; j <= cnt; ++j)
        {
            dp[i][j] = dp[i][j - 1] + (long long) (d[j] - d[j - 1]) * dp[i - 1][pos[rd[j]]] % MOD;
            dp[i][j] %= MOD;
        }
    }
    
    cout << dp[k][cnt] << '\n';
    
    return 0;
}

Measured memory_bytes: 43264
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	int n=in();
	vector<int> a(n);
	trav(i,a)i=in();
	int o=0,two=0,four=0;
	trav(i,a)
	{
		if(i%4==0)four++;
		else if((i%2))o++;
	}
	two=n-(o+four);
	if(four>=o or (two==0 and abs(four-o)<=1))puts("Yes");
	else puts("No");
	
}

Measured memory_bytes: 4076
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] p = new int [N];

		for(int i = 0;i<N; i++) {
			p[i] = Integer.parseInt(sc.next());
		}

		Arrays.sort(p);

		p[N-1] /= 2;
		int sum = 0;
		for(int i = 0;i<N;i++) {
			sum += p[i];
		}

		System.out.println(sum);


	}

}

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int main(){
    long double l;
    cin >> l;
    long double ans = (l / 3) * (l / 3) * (l / 3);
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


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

#define int long long

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

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

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

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

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

signed main(){
	int a,p;
	cin>>a>>p;
	p+=a*3;
	cout<<p/2<<endl;
	return 0;
}

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

int main(){
    int r,c;
    int table[101][101];
    cin >> r >> c;

    for (int s = 0; s < r; s++){
        for (int t = 0; t < c; t++){
            cin >> table[s][t];
        }
    }

    for (int i = 0; i <= r; i++){
        table[i][c] = 0;
    }
    for (int j = 0; j <= c; j++){
        table[r][j] = 0;
    }

    for (int i = 0; i < r; i++){
        for (int j = 0; j < c; j++){
            table[i][c] += table[i][j];
            table[r][j] += table[i][j];
            table[r][c] += table[i][j];
        }
    }

    for (int i = 0; i <= r; i++){
        for (int j = 0; j <= c; j++){
            if (j != 0){
                cout << " " << table[i][j];
            } else {
                cout << table[i][j];
            }
        }
        cout << endl;
    }
    //cout << endl;
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
int n,k;
int main(){
//	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); 
	cin >> n >> k;
	int ans = 0;
	while(n){
		ans++;
		n /= k;
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import Data.Maybe
import Data.List

main :: IO ()
main = do
  input <- getContents
  putStrLn $ trim (solve (trim input))

--処理
solve :: String -> String
solve = (++) "ABC"

trimHead :: String -> String
trimHead = dropWhile (\s -> isJust (elemIndex s [' ', '\t', '\n', '\r']))

trim :: String -> String
trim = reverse . trimHead . reverse . trimHead

Measured memory_bytes: 380
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		 int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] cost = new int[n][2];
        int[] std = new int[m];
        for (int i=0; i<n; i++)
            cost[i][0] = sc.nextInt();
        for (int i=0; i<m; i++) 
            std[i] = sc.nextInt();
        java.util.Arrays.sort(std);
        for (int i=0; i<m; i++) {
            for (int j=0; j<n; j++) {
                if (cost[j][0] <= std[i]) {
                    cost[j][1] += 1;
                    break;
                }
            }
        }
        int tmp = cost[0][1];
        int ans = 1;
        for (int i=0; i<n; i++) {
            if (tmp <cost[i][1]) {
                tmp = cost[i][1];
                ans = i+1;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 24996
/*
 * Author : Sadi
 * Sat 18/07/2020
 * 14:48:54.68
 */
#include <bits/stdc++.h>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

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

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;

const int N = 1e6;;
bitset<N> b;
vector<long long> primes;

void sieve() {
    b.set();
    b[0] = 0;
    b[1] = 0;
    primes.push_back(2);
    for(long long i = 3; i <= N; i += 2) {
        if(b[i]) {
            for(long long j = i * i; j <= N; j += i) {
                b[j] = 0;
            }
            primes.push_back(i);
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    sieve();
    int n;
    cin >> n;
    cout << *lower_bound(primes.begin(), primes.end(), n) << endl;    

    return 0;
}



Measured memory_bytes: 4384
/*Starting with the name of Almighty ALLAH*/
/* Bismillahir Rahmanir Rahim */
#include<bits/stdc++.h>
#include<vector>
#include<cmath>
#include<string>
#include<stdlib.h>
#define   ebar_khela_hoppe int main()
#define   bair_ho      return 0;
#define   mod          1000000007
#define   lp(i,a,b)    for(ll i=a;i<=b;i++)
#define   ll           long long int
#define   ull          unsigned long long int
#define   tst          int t;cin>>t;while(t--)
#define   pb           push_back
#define   vi(v)        vector<int>v;
#define   vl(v)        vector<ll>v;
#define   vs(v)        vector<string>v
#define   rslt(x)      cout<<x<<endl;
#define   mp(x,y)      make_pair(x,y)
#define   yes          cout<<"YES"<<endl;
#define   no           cout<<"NO"<<endl;
#define   srt(v)       sort(v.begin(),v.end())
#define   rvs(v)       reverse(v.begin(),v.end());
#define   Araf         ios::sync_with_stdio(false);cin.tie(0);
#define   gcd(a,b)     __gcd(a,b)
#define   lcm(a,b)     (a/gcd(a,b))*b
#define   max          1000007
#define   str          int s[200000];
#define   coutv(v)     for(auto it:v)cout<<it<<' ';cout<<endl;
#define   cinv(v)      for(auto &it:v)cin>>it;
using namespace std;
ebar_khela_hoppe
{
    Araf
    ll n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cout<<"ACL";
    cout<<endl;


    bair_ho
}



Measured memory_bytes: 3608
import sys
from _operator import itemgetter

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()
li = []
for i in range(n):
    li.append([i+1, a[i]])
list.sort(li, key=itemgetter(1))
ans = []
for i in range(n):
    ans.append(li[i][0])
print(*ans)

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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if((C-1)/B<=(A-1)/D){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3596
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn gcd(x: u32, y: u32) -> u32 {
    if x == 0 {
        y
    } else {
        gcd(y % x, x)
    }
}

fn main() {
    let v = read_vec::<u32>();
    let n = v[0] as usize;
    let x = v[1];
    let mut xs = read_vec::<u32>();
    xs.push(x);
    xs.sort();

    let mut diffs = Vec::new();
    for i in 0..n {
        diffs.push(xs[i+1] - xs[i]);
    }

    let first = diffs[0];
    let ans = diffs.into_iter().fold(first, |acc, x| gcd(acc, x));
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

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

	long long n;
	cin >> n;

	long long curr = 1;
	long long c = 0;
	while (curr <= n) {
		curr += powl(26, c + 1);
		++c;
	}

	curr -= powl(26, c);
	string ans(c, 'a');
	int i = 0;
	while (true) {
		--c;
		while (ans[i] < 'z') {
			curr += powl(26, c);
			++ans[i];
			if (curr == n) {
				cout << ans << "\n";
				return 0;
			} 
			else if (curr > n) {
				curr -= powl(26, c);
				--ans[i];
				break;
			}
		}

		++i;
	}

	return 0;

}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, x,sum;
  cin >> N;
  sum=0;
  x=N;
  for(int i=0;i<=8;i++){
    sum+=x%10;
    x/=10;
  /*  cout << x <<endl;
    cout << sum <<endl;
    cout <<i<< endl;
*/
  }
  N%=sum;
  if(N==0)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <time.h>
#define int long long int
#define pb push_back
#define mem(a, x) memset(a, x, sizeof a)
#define all(a) a.begin(), a.end()
#define scnarr(a, n) for (int i = 1; i <= n; ++i) cin >> a[i]
#define vi vector<int>
#define si set<int>
#define pii pair <int, int>
#define sii set<pii>
#define vii vector<pii>
#define mii map <int, int>
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace chrono;
/*
	----------------------------------------------------------------------
	Things to remember : check for coners n = 1, pass references instead
*/
/* -------------------------------Solution Sarted--------------------------------------*/

//Constants
const int MOD = 1000000007; // 1e9 + 7
const int MAXN = 1000005; // 1e6 +5
const int INF = 100000000000005; // 1e15 +5

void solve(){
	cout << fixed << setprecision(12);
	int n;
	cin >> n;
	vector<double> a(n +1);
	scnarr(a, n);

	double dp[n +1][n +1];
	memset(dp, 0.0, sizeof dp);
	dp[0][0] = 1.0;
	for(int i = 1; i <= n; ++i){
		dp[i][0] = dp[i -1][0] * (1 - a[i]);
	}
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= i; ++j){
			dp[i][j] = dp[i -1][j -1]*a[i] + dp[i -1][j]*(1 - a[i]);
		}
	}

	double ans = 0.0;

	for(int i = n/2 +1; i <= n; ++i){
		ans += dp[n][i];
	}

	cout << ans << endl;
	
	
}

signed main()
{
	faster;
#ifndef ONLINE_JUDGE
	freopen("ip.txt", "r", stdin);
	freopen("op.txt", "w", stdout);
#endif
	// int t; cin >> t; while(t--)
		solve();
	return 0;
}


//Author : Ankit Raj
//Problem Link :

/*Snippets*/
/*
sieve - prime factorization using sieve and primes in range
zpower - pow with mod
plate - Initial template
bfs 
dfs
fenwik - BIT
binary_search
segment_tree
*/
	

Measured memory_bytes: 74116
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    string s,t;
    in>>s>>t;
    cout<<t+s<<endl;
}

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

using namespace std;

int main()
{
	string s;
	cin>>s;
	stack<char> v;

	v.push(s[0]);
	for(int i=1;i<s.length();i++)
	{	
		if(v.empty())
		{
			v.push(s[i]);
		}
		else
		{
		if(s[i]!=v.top())
		{	

			v.pop();
		}
		else
		{
			v.push(s[i]);
		}
		}
	}

	int len = s.length();

	cout<<len-v.size()<<'\n';

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)

const ll MOD = 1000000007;

using namespace std;
int n[3];

int main()
{
	int N;
	cin >> N;
	REP(i, N)
	{
		int a;
		cin >> a;
		if (a % 4 == 0)
		{
			n[0]++;
		}
		else if (a % 2 == 0)
		{
			n[1]++;
		}
		else
		{
			n[2]++;
		}
	}
	if (n[1] > 0)n[2]++;

	if (n[0] >= n[2] - 1)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

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

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

long long modinv(long long a, long long m=MOD) {
    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;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}


int main(){
    int n;
    int k;
    cin >> n >> k;
    int tmp = 1;
    int count = 0;
    while(true){
        if(n < k)break;
        n /= k;
        count++;
        
    }

    
    cout << count+1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long LL;
const int N = 1000000007;

int n,m;
int dp[3005][3005] = {0};
char ch;

int main(){
	ios::sync_with_stdio(false);
	dp[1][1] = 1;
	cin >> n >> m;
	for(LL i = 1;i <= n;i ++){
		for(LL j = 1;j <= m;j ++){
			cin >> ch;
			if(ch == '.' && (!(i == 1 && j == 1))){
				dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
				dp[i][j] %= N;
			}
		}
	}
	printf("%d\n",dp[n][m]);
	return 0;
}

Measured memory_bytes: 11904
#include<bits/stdc++.h>
#define ll long long
#define MP make_pair
#define PB push_back
using namespace std;
namespace io{
	const int Sz=1<<13;
	char ibuf[Sz],*ips=ibuf+Sz-1;
	inline int getchar(){
		if(++ips==ibuf+Sz)fread(ips=ibuf,1,Sz,stdin);
		return *ips;
	}
	char obuf[Sz],*ops=obuf;
	inline void flush(){
		fwrite(obuf,1,ops-obuf,stdout);
		ops=obuf;fflush(stdout);
	}
	inline void putchar(int c){
		if(ops==obuf+Sz)flush();
		*ops=c,ops++;
	}
	void gets(char *s){
		int c=getchar();
		while(c<=32)c=getchar();
		while(c>32)*s=c,++s,c=getchar();
		*s=0;
	}
	void puts(const char *s){
		while(*s)putchar(*s),++s;
	}
}
#define getchar io::getchar
#define putchar io::putchar
#define gets io::gets
#define puts io::puts
int read(){
	int x=0,f=1,c=getchar();
	for(;c<48||c>57;c=getchar())
		if(c=='-')f=-f;
	for(;c>=48&&c<=57;c=getchar())
		x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
void write(ll x){
	int stk[20],tp=0;
	if(!x)putchar(48);
	if(x<0)putchar('-'),x=-x;
	for(;x;x/=10)stk[tp++]=(x-x/10*10)^48;
	for(;tp;)putchar(stk[--tp]);
}
struct Flusher{~Flusher(){io::flush();}}flusher;
// ------------------------- Template End ------------------------- //
const int N=5005;
int n,A,B;
int p[N];
ll dp[N];
const ll inf=0x3f3f3f3f3f3f3f3f;
void chkmin(ll &x,ll y){if(y<x)x=y;}
int main(){
	n=read(),A=read(),B=read();
	for(int i=0;i<n;++i)p[i]=read();
	memset(dp,0x3f,sizeof dp);
	dp[0]=0;
	for(int i=1;i<=n+1;++i){
		ll delta=0;
		for(int j=i-1;~j;--j){
			if(i==n+1||!j||p[j-1]<p[i-1])
				chkmin(dp[i],dp[j]+delta);
			if(j){
				if(i==n+1||p[j-1]<p[i-1])delta+=B;
				else delta+=A;
			}
		}
	}
	printf("%lld\n",dp[n+1]);
	return 0;
}



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

int main()
{
  int N,K;
  cin>>N>>K;
  int A[N];
  for(int i=0;i<N;i++)
  {
    cin>>A[i];
  }
  
  int C[N];
  C[N-1]=0;
  C[N-2]=abs(A[N-1]-A[N-2]);

  for(int i=N-3;i>=0;i--)
  {
    int com=abs(A[i]-A[i+1])+C[i+1];
    int j=i+2;
    while(j<N && j<=i+K)
    {
      com=min(com,abs(A[j]-A[i])+C[j]);
      j++;
    }
    C[i]=com;
  }
  cout<<C[0]<<endl;
  
  
}

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

bool check( const vector<string>& s, int H, int W ) {
	for( int i = 0; i < H; ++i ) {
		for( int j = 0; j < W; ++j ) {
			if( s[i][j] == '#' ) {
				bool ok = false;
				if( i > 0 && s[i-1][j] == '#' ) { ok = true; }
				if( i < H-1 && s[i+1][j] == '#' ) { ok = true; }
				if( j > 0 && s[i][j-1] == '#' ) { ok = true; }
				if( j < W-1 && s[i][j+1] == '#' ) { ok = true; }

				if( !ok ) {
					return false;
				}
			}
		}
	}

	return true;
}

int main() {
	ios_base::sync_with_stdio( false );

	int H, W;
	cin >> H >> W;

	vector<string> s( H );
	for( auto& v: s ) { cin >> v; }

	cout << (check( s, H, W ) ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 256