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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (300006)
int main(){
	FAST
	ll n,a,b;
	cin>>n>>a>>b;
	auto c=[&](ll x){ return __builtin_popcount(x); };
	if((c(a)&1) == (c(b)&1)) { cout<<"NO\n"; return 0; }
	cout<<"YES\n";
	function<vector<ll>(ll,ll,ll)> solve=[&](ll n,ll a,ll b){
		assert(a^b);
		if(n == 1){
			return vector<ll>{a&1, b&1};
		}
		auto expand=[&](ll x,ll bit){
			ll nval=0;
			FOR(i,0,18)if(1<<i&x){
				nval+=1<<(i+(i>=bit));
			}
			return nval;
		};
		auto compress=[&](ll x,ll bit){
			ll nval=0;
			FOR(i,0,18)if(i^bit)if(1<<i&x){
				nval+=1<<(i-(i>=bit));
			}
			return nval;
		};
		#define lsb(x) (__builtin_ctz(x))
		ll bit=lsb(a^b);
		ll oa=a,ob=b;
		a=compress(a,bit), b=compress(b,bit);
		ll c=a^1;
		if(c==b) c=a^2, assert(n>2);
		vector<ll>A=solve(n-1,a,c);
		vector<ll>B=solve(n-1,b,c);
		for(auto&i:A) i=expand(i,bit);
		for(auto&i:B) i=expand(i,bit);
		if(1<<bit&oa)for(auto&i:A)i|=1<<bit;
		else for(auto&i:B)i|=1<<bit;
		while(B.size())A.eb(B.back()),B.pop_back();
		assert(A[0] == oa && A.back() == ob);
		return A;
	};
	vector<ll> ans = solve(n, a, b);
	for(auto i:ans) cout<<i<<' '; cout<<'\n';
}


Measured memory_bytes: 2288
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type war struct {
	left  int
	right int
}

type wars []war

func (w wars) Len() int {
	return len(w)
}

func (w wars) Swap(i, j int) {
	w[i], w[j] = w[j], w[i]
}

func (w wars) Less(i, j int) bool {
	if w[i].right != w[j].right {
		return w[i].right < w[j].right
	}
	return w[i].left > w[j].left
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	_, m := nextInt(), nextInt()

	var wars wars = make([]war, m)
	for i := range wars {
		wars[i] = war{nextInt(), nextInt()}
	}
	sort.Sort(wars)

	ans := 0
	max := 0
	for _, w := range wars {
		if w.left >= max {
			ans++
			max = w.right
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 3456
#pragma region Macros
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
using namespace std;
int_fast32_t nn, n, sqrtN;
int_fast64_t ans, d;
char c;
char wr[15];
char *w = wr;
main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> nn;
    const int_least32_t n = nn;
    if(n == 1){
        cout<<1;
        return 0;
    }
    const int_fast32_t sqrtN = sqrt(n);
    ans = -(int_fast64_t)(sqrtN) * (sqrtN + 1) * (2 * sqrtN + 1) / 6;
    for(int i = 1; i <= sqrtN; ++i) {
        const int_fast32_t a = n / i;
        ans += ((int_fast64_t)i * (i + a) * (a + 1 - i));
    }
    cout << ans;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
#define int ll

const int N = 510;
int pnt[N], ans[N * N], ost[N];

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int>> srt;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    pnt[i] = x;
    srt.pb({x, i});
  }  
  sort(all(srt));
  set<int> empt;
  for (int i = 1; i <= n * n; i++) {
    empt.insert(i);
  }
  for (auto it : srt) {
    for (int j = 0; j < it.S - 1; j++) {
      if (empt.empty()) {
        cout << "No\n";
        exit(0);
      }
      if (*empt.begin() >= it.F) {
        cout << "No\n";
        exit(0);
      }
      ans[*empt.begin()] = it.S;
      empt.erase(empt.begin());
    }
    ans[it.F] = it.S;
    empt.erase(it.F);
    ost[it.S] = n - it.S;
  }
  for (auto it : empt) {
    int id = -1;
    for (int i = 1; i <= n; i++) {
      if (pnt[i] < it && ost[i] > 0) {
        id = i;
        break;
      }
    }
    if (id == -1) {
      cout << "No\n";
      exit(0);
    }
    ans[it] = id;
    ost[id]--;
  }
  cout << "Yes\n";
  for (int i = 1; i <= n * n; i++) {
    cout << ans[i] << ' ';
  }
  cout << '\n';
} 

Measured memory_bytes: 14848
#include<bits/stdc++.h>
#define chal ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
    int q=1;
    //cin>>t;
    while(q--)
    {
        string s;
        cin>>s;
        ll i,p=0;
        for(i=0;i<s.size();i++)
        {
            p=(p+(s[i]-'0'))%9;
        }
        if(p==0)
            cout<<"Yes";
        else
            cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 3720
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    N=int(input())
    A=sorted(list(map(int,input().split())))

    print(A[-1]-A[0])




resolve()

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

int main(){
  int n;
  int a[1010];
  cin>>n;
  for (int i=0; i<n; ++i) cin>>a[i];
  
  for (int j=0; j<n; ++j){
  if (j) cout<<" ";
    cout<<a[j];
  }
  cout<<endl;
  for (int i=1; i<n; ++i){
    int j=i-1;
    int v=a[i];
    while (j>=0 && a[j]>v){
      a[j+1]=a[j];
      --j;
    }
    a[j+1]=v;
    for (j=0; j<n; ++j){
      if (j) cout<<" ";
      cout<<a[j];
    }
    cout<<endl;
  }
}


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

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

    vector<ll> blocks;
    blocks.push_back(0);
    for(int i = 0; i < S.length(); i++) {
        if(i == 0 or S[i] == S[i-1])
            blocks[blocks.size() - 1]++;
        else
            blocks.push_back(1);
    }

    if(blocks.size() == 1) {
        ll ans = K;
        ans *= S.length();
        cout << ans / 2 << "\n";
        return 0;
    }

    ll ans = 0;
    for(int i = 1; i < blocks.size() - 1; i++)
        ans += (blocks[i] / 2) * K;
    ll last_block_size = blocks[blocks.size() - 1];
    if(S[0] == S[S.length() - 1]) {
        ans += blocks[0] / 2;
        ans += last_block_size / 2;
        ans += ((blocks[0] + last_block_size) / 2) * (K - 1);
    } else {
        ans += (blocks[0] / 2) * K;
        ans += (last_block_size / 2) * K;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;

int main(){
  int a, b; cin >> a >> b;
  if(a*b%2 == 0){
    printf("%s", "No");
    return 0;
  }else{
    printf("%s", "Yes");
    return 0;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main(){
	IOS;
	int n, m, x;
	cin >> n >> m >> x;
	int kn[n][m], cst[n];
	for(int i = 0; i < n; i++){
		cin >> cst[i];
		for(int j = 0; j < m; j++)
			cin >> kn[i][j];
	}

	int cur[m], ccst = 0, mx = INT_MAX;
	for(int i = 1; i < (1<<n); i++){
		for(int j = 0; j < m; j++)
			cur[j] = 0;
		ccst = 0;
		for(int j = 0; j < n; j++)
			if( (1<<j)&i ){
				ccst += cst[j];
				for(int k = 0; k < m; k++)
					cur[k] = cur[k] + kn[j][k];
			}

		bool valid = true;
		for(int j = 0; j < m; j++)
			if( cur[j] < x )
				valid = false;

		if( valid )
			mx = min(mx, ccst);
	}

	cout << (mx == INT_MAX ? -1 : mx) << endl;
	return 0;
}

Measured memory_bytes: 3636
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
P = inpl()

min = 10**5 * 2 + 10
cnt = 0
for p in P:
    if min >= p:
        min = p
        cnt += 1

print(cnt)

Measured memory_bytes: 52932
#include <stdio.h>
#include <string.h>

int main(){
    
    long long num;
    scanf("%lld", &num);
    char str[100] ={0};
    int i = 0;
    num--;

    while(num >= 0){
         str[i] = num%26 + 'a';
         num /= 26;
        i++;
        num--;                
    }
    int len = strlen(str);
    
    for(int j=len-1;j>=0;j--){
        printf("%c", str[j]);
    }    

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll N,M;
string A[50];
string B[50];

int main(){
    cin >> N >> M;
    for(int i=0;i<N;i++) cin >> A[i];
    for(int i=0;i<M;i++) cin >> B[i];
    for(int i=0;i+M-1<N;i++){
        for(int j=0;j+M-1<N;j++){
            bool f = true;
            for(int x=0;x<M && f;x++){
                for(int y=0;y<M && f;y++){
                    if(B[x][y] != A[i+x][j+y]) f = false;
                }
            }
            if(f){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    bool ok = true;
    if (s.size() % 2 == 1) ok = false; 
    rep(i,s.size()) {
        if ((i % 2 == 0 && s[i] != 'h') || (i % 2 == 1 && s[i] != 'i')) {
            ok = false;
        }
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int const N = 123456;
 
int ac = 0;
int ans[N], p[N], where[N], a[N], blocked[N];
 
vector<int> edges[N];
 
void shift(int start) {
	int v = start;
	int tmp = a[v];
	while (v != 0) {
		v = p[v];
		int ntmp = a[v];
		a[v] = tmp;
		where[a[v]] = v;
		tmp = ntmp;
	}
	a[start] = tmp;
	where[a[start]] = start;
	ans[ac++] = start;
}
#define pi pair<int,int>
#define aa first
#define bb second
pi getdown(int v, int value) {
	pi mx = make_pair(-1,0);
	for (int to : edges[v]) {
		if (blocked[to]) continue;
		pi got = getdown(to, value);
		if (got.aa < 0) continue;
		if (mx.aa < 0 || a[mx.bb] < a[got.bb]) {
			mx = got;
		}
	}
	if (mx.aa < 0 && a[v] > value) {
		mx = make_pair(v,v);
	}
  if(a[v]>a[mx.bb])
      mx.bb=v;
	return mx;
	// while (true) {
	// 	int mx = -1;
	// 	for (int to : edges[v]) {
	// 		if (blocked[to]) continue;
	// 		if (a[to] < value) continue;
	// 		if (mx < 0 || a[mx] < a[to]) mx = to;
	// 	}
	// 	if (mx < 0) {
	// 		return v;
	// 	}
	// 	v = mx;
	// }
}
 
int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 1; i < n; i++) {
		cin >> p[i];
		edges[p[i]].push_back(i);
	}
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		where[a[i]] = i;
	}
	for (int i = 0; i < n; i++) blocked[i] = false;
	int cur = n - 1;
	while (cur >= 0) {
		while (a[0] != cur) {
			int v = where[cur];
			int u = getdown(v, a[0]).aa;
			shift(u);
		}
		shift(cur);
		blocked[cur] = true;
		--cur;
	}
	cout << ac << '\n';
	for (int i = 0; i < ac; i++) {
		cout << ans[i] << '\n';
	}
}


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

struct union_find{
    vector<ll> parent;
    vector<ll> nums;
    union_find(ll n){
        parent.resize(n);
        nums.resize(n, 1LL);
        rep(i, 0, n) parent[i] = i;
    }

    ll root(ll x){
        if(parent[x] == x) return x;
        parent[x] = root(parent[x]);
        return parent[x];
    }

    void unite(ll x, ll y){
        ll rx = root(x);
        ll ry = root(y);
        if(rx != ry){
            parent[rx] = ry;
            nums[ry] += nums[rx];
        }
    }

    bool same(ll x, ll y){
        ll rx = root(x);
        ll ry = root(y);
        if(rx == ry) return true;
        return false;
    }

    ll size(ll x){
        return nums[root(x)];
    }
};  

int main(){
    ll n, m;
    cin >> n >> m;
    union_find t(n+1);
    rep(i, 0, m){
        ll x, y, z;
        cin >> x >> y >> z;
        t.unite(x, y);
    }
    set<ll> st;
    rep(i, 1, n+1) st.insert(t.root(i));
    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

ll f[100001]={},t[100001]={};
int main() {

	ll n,m;
	cin>>n>>m;
	rep(i,m){
		int p;
		string s;
		cin>>p>>s;
		if(s=="WA"&&f[p]==0)t[p]++;
		if(s=="AC"&&f[p]==0){
			f[p]=1;
		}
	}
	ll a=0,b=0;
	rep(i,n){
		a+=f[i+1];
		if(f[i+1]>0)b+=t[i+1];
	}
	cout<<a<<" "<<b<<endl;
	return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin>>N;
    int a[N]={};

    int sum=0;
    for(int i=0;i<N;i++){
        cin>>a[i];
        sum+=a[i];
    }
    float k=(float)sum/(float)N;
    int ave=0;
    if(k>sum/N+0.5){
         ave=sum/N+1;
    }else{
         ave=sum/N;
    }


    int kei=0;
    for(int i=0;i<N;i++){
        kei+=(a[i]-ave)*(a[i]-ave);
    }
    cout<<kei<<endl;





 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <numeric>
#include <cassert>
#include <algorithm>
#include <queue>
#include <map>
#include <stack>
#include <set>
#include <vector>
#include <array>
#include <memory>

#define IN(a,b) (a.find(b) != a.end())
#define p(a,b) make_pair(a,b)
#define readVec(a) for (int __i = 0; __i<(int)a.size();__i++){cin>>a[__i];}

// jimjam

template<typename T>
void pMin(T &a, T b) {if (b<a){a=b;}}
template<typename T>
void pMax(T &a, T b) {if (b>a){a=b;}}
template<typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& c);
template<typename A, typename B>
std::ostream& operator<<(std::ostream& os, const std::pair<A,B>& c) {std::cout << "(" << c.first << ", " << c.second << ")";return os;}
template<typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& c) {
	if (c.size() == 0) {os << "{}"; return os;}
	os << "{" << c[0];
	for (int64_t i = 1; i < (int)c.size(); i++) {os <<", "<<c[i];}
	os << "}";
	return os;
}

using namespace std;

bool grid[6][6];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	int h, w, k ;cin >> h >> w >> k;
	for (int y = 0; y < h; y++) {
		for (int x = 0; x < w; x++) {
			char ch ; cin >> ch;
			grid[x][y] = (ch=='#');
		}
	}

	int ans=0;
	for (int i=0; i < (1<<(h+w)); i++) {
		int curr=0;
		for (int y = 0; y < h; y++) {
			for (int x = 0; x < w; x++) {
				int t1 = (i & (1<<x));
				int t2 = (i & (1<<w+y));
				if (grid[x][y] && ((i & (1<<x))==0) && ((i & (1<<w+y)) == 0)) {
					curr++;
				}
			}
		}
		if (curr==k) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 3692
#include <iostream>
#include <fstream>
#define maxn 800

using namespace std;
struct punct{int i,j;} q[maxn*maxn+5];
int n,i,j,v[maxn+5][maxn+5],m,ok,filled[maxn+5][maxn+5],r,di[]={0,-1,0,1},dj[]={1,0,-1,0},nrq;
char c;

void myfill()
{
    int i1,j1,i2,j2,dif;
    for(r=1;r<=nrq;r++)
    {
        i1=q[r].i;
        j1=q[r].j;
        for(dif=0;dif<=3;dif++)
        {
            i2=q[r].i+di[dif];
            j2=q[r].j+dj[dif];
            if(i2>=1 && i2<=n && j2>=1 && j2<=m && v[i2][j2]==0 && filled[i2][j2]==0)
            {
                q[++nrq]={i2,j2};
                filled[i2][j2]=filled[i1][j1]+1;
            }
        }
    }
}

inline bool vecin0(int i, int j)
{
    int i2,j2;
    for(int dif=0;dif<=3;dif++)
    {
        i2=i+di[dif];
        j2=j+dj[dif];
        if(i2>=1 && i2<=n && j2>=1 && j2<=m && v[i2][j2]==-1) return 1;
        if(i2==0 || i2==n+1 || j2==0 || j2==m+1) return 1;
    }
    return 0;
}

int closest(int i, int j)
{
    return min(i-1,min(n-i,min(j-1,m-j)));
}

int main()
{
    int k;
    cin>>n>>m>>k;
    int i1,j1;
    for(i=1;i<=n;i++)
    for(j=1;j<=m;j++)
    {
        cin>>c;
        if(c=='.') v[i][j]=0;
        else if(c=='#') v[i][j]=-1;
        else v[i][j]=0, i1=i, j1=j;
    }
    filled[i1][j1]=1;
    q[1]={i1,j1};
    nrq=1;
    myfill();
    int mini=n*m+1,nrpasi;
    for(i=1;i<=n;i++)
    for(j=1;j<=m;j++)
    {
        if(filled[i][j])
        {
            nrpasi=(filled[i][j]+k-2)/k;
            if(nrpasi==0) nrpasi=1;
            nrpasi+=(closest(i,j)+k-1)/k;
            if(nrpasi<mini) mini=nrpasi;
        }
    }
    cout<<mini<<'\n';
    return 0;
}


Measured memory_bytes: 10240
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cassert>
#include <cinttypes>

using namespace std;

typedef int64_t ll;
typedef uint64_t ull;

const ll INF = 1e18 + 10;

typedef pair<int, ll> P;
int n;
vector<P> G[100001];
int q, k;

bool checked[100001];
ll dist[1000001];

void dfs(int v, ll d) {
  if (checked[v]) {
    return;
  } 
  dist[v] = d;
  checked[v] = true;

  for (auto u : G[v]) {
    dfs(u.first, d + u.second);
  }
}


int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    ll a, b, c;
    cin >> a >> b >> c;
    G[a].push_back(P(b, c));
    G[b].push_back(P(a, c));
  }

  cin >> q >> k;
  dfs(k, 0);

  for (int i = 0; i < q; i++) {
    int x, y;
    cin >> x >> y;
    cout << dist[x] + dist[y] << endl;
  }


  return 0;
}

Measured memory_bytes: 14464
// CGL_2_C
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
using namespace std;

struct vec{
	double x;
	double y;
};

void find_intersect(vec p[4]){
	double x, y;
	vec v[2];

	for(int i=0;i<2;i++){
		v[i].x = p[2*i+1].x - p[2*i].x;
		v[i].y = p[2*i+1].y - p[2*i].y;
	}

	x = (v[0].y*v[1].x*p[0].x-v[1].y*v[0].x*p[2].x+(p[2].y-p[0].y)*v[1].x*v[0].x)/(v[0].y*v[1].x-v[1].y*v[0].x);
	
	if(v[0].x == 0)
		y = v[1].y/v[1].x*(x-p[2].x)+p[2].y;
	else
		y = v[0].y/v[0].x*(x-p[0].x)+p[0].y;

	printf("%.10lf %.10lf\n", x, y);
}

int main(){
	int q;
	vec p[4];

	cin>>q;
	for(int i=0;i<q;i++){
		cin>>p[0].x>>p[0].y>>p[1].x>>p[1].y>>p[2].x>>p[2].y>>p[3].x>>p[3].y;

		find_intersect(p);
	}

	return 0;
}

Measured memory_bytes: 1248
def main():
    S = input()
    N = len(S)
    c = N // 2
    for i in range(c):
        if S[i] == S[-(i + 1)]:
            continue
        print("No")
        return

    for i in range(c // 2):
        if S[i] == S[c - i - 1]:
            continue
        print("No")
        return

    print("Yes")
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <stdio.h>
#include<vector>
#include<iostream>
#include<string>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<cmath>
#include<algorithm>
using namespace std;


int main() {
	int n, q;
	cin >> n;
	cin >> q;
	char* s;
	int *cnt;
	cnt = new int[n];
	s = new char[n+1];
	int sum = 0;
	s[0] = '0';
	cnt[0] = 0;
	for (int i = 1; i < n + 1; i++)
	{
		cin >> s[i];
		if (s[i] == 'C'&&s[i - 1] == 'A')
		{
			sum++;
		}
		cnt[i - 1] = sum;
	}
	int l, r;
	for (int i = 0; i < q; i++)
	{
		cin >> l >> r;
		cout << cnt[r - 1] - cnt[l - 1] << endl;
	}


	return 0;
}


Measured memory_bytes: 1280
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

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

const ll mod=1e9+7;


int main()
{
    ll n,m;
    cin >> n >> m;
    string s;
    cin >> s;
    vector<ll> ans;
    vector<pll> info(n+1);
    ll cnt=0;
    rep(i,n+1){
        if(i==0){
            cnt++;
            info[i]=make_pair(0,cnt);
            continue;
        }
        if(s[i-1]==s[i]){
            cnt++;
            if(s[i]=='0'){
                info[i]=make_pair(0,cnt);
            }
            else{
                info[i]=make_pair(1,cnt);
            }
        }
        else{
            if(s[i]=='0'){
                cnt=1;
                info[i]=make_pair(0,cnt);
            }
            if(s[i]=='1'){
                cnt=1;
                info[i]=make_pair(1,cnt);
            }
        }
    }
    ll able_move=m;
    bool ok=true;
    for(ll i=n;i>=0;i--){
        if(i==0){
            if(able_move!=m){
                ans.push_back(m-able_move);
            }
            
            break;
        }
        if(info[i].fi==0 && info[i-1].fi==1){
            if(info[i-1].se+1>m){
                ok=false;
                break;
            }
            if(info[i-1].se+1<=able_move){
                able_move--;
            }
            else{
                ans.push_back(m-able_move);
                able_move=m;
                able_move--;
            }
        }
        else{
            able_move--;
        }
        if(able_move==0){
            ans.push_back(m);
            able_move=m;
        }
    }
    if(!ok){
        cout << -1 << endl;
        return 0;
    }
    ll t=ans.size();
    for(ll i=t-1;i>=0;i--){
        if(i==t-1){
            cout << ans[i];
        }
        else{
            cout << " " << ans[i];
        }
    }
    cout << endl;
    return 0;
} 

Measured memory_bytes: 3064
#include<stdio.h>
#include<cmath>

int main(){

    int n;
    double students[1000] = {0}, sum, m, div;

    while(true){
        scanf("%d", &n);
        if(n==0) break;
        sum = m = div = 0;
        for(int i=0; i<n; i++){
            scanf("%lf", &students[i]);
            sum += students[i];
        }
        m = sum/n;
        for(int i=0; i<n; i++){
            div += (students[i]-m)*(students[i]-m);
        }

        printf("%.8f\n", sqrt(div/n));
    } 
}



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

int main(){
	int cnt[4];
	for(int i = 0; i < 4; i++)
		cnt[i] = 0;
	for(int i = 0; i < 6; i++){
		int tmp;
		cin >> tmp;
		cnt[tmp - 1]++;
	}
	int flag = 1;
	for(int i = 0; i < 4; i++)
		if(cnt[i] == 3)
			flag = 0;
	if(flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	string s;
	cin >> s;
	cout << string(sz(s), 'x') << '\n';
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
long long MOD = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll N;
        cin>>N;
        ll ga,sa,ba,gb,sb,bb;
        cin>>ga>>sa>>ba>>gb>>sb>>bb;
        vvl dp(4,vl(N+1,0));
        ll dong=N;
        rep(i,N+1){
            if(i<ga){
                chmax(dp[1][i],dp[0][i]);
            }else{
                chmax(dp[1][i],dp[0][i]);
                chmax(dp[1][i],dp[1][i-ga]+gb-ga);
            }
        }
        rep(i,N+1){
            if(i<sa){
                chmax(dp[2][i],dp[1][i]);
            }else{
                chmax(dp[2][i],dp[1][i]);
                chmax(dp[2][i],dp[2][i-sa]+sb-sa);
            }
        }
        rep(i,N+1){
            if(i<ba){
                chmax(dp[3][i],dp[2][i]);
            }else{
                chmax(dp[3][i],dp[2][i]);
                chmax(dp[3][i],dp[3][i-ba]+bb-ba);
            }
        }
        dong+=dp[3][N];
        N=dong;
        vvl dp2(4,vl(N+1,0));
        rep(i,N+1){
            if(i<gb){
                chmax(dp2[1][i],dp2[0][i]);
            }else{
                chmax(dp2[1][i],dp2[0][i]);
                chmax(dp2[1][i],dp2[1][i-gb]+ga-gb);
            }
        }
        rep(i,N+1){
            if(i<sb){
                chmax(dp2[2][i],dp2[1][i]);
            }else{
                chmax(dp2[2][i],dp2[1][i]);
                chmax(dp2[2][i],dp2[2][i-sb]+sa-sb);
            }
        }
        rep(i,N+1){
            if(i<bb){
                chmax(dp2[3][i],dp2[2][i]);
            }else{
                chmax(dp2[3][i],dp2[2][i]);
                chmax(dp2[3][i],dp2[3][i-bb]+ba-bb);
            }
        }
        dong+=dp2[3][N];
        cout<<dong<<endl;
    }

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

int main(void){
    int d,e;
    while(cin>>d>>e, d){
        double ans = INF;
        rep(x,d+1){
            int y = d - x;
            ans = min(ans, abs(sqrt(x*x+y*y)-e));
        }
        printf("%.10f\n",ans);
    }
    return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <algorithm>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

using namespace std;

int ans;

int main(void) {
	int N;
	int L[11];
    scanf("%d", &N);

    REP(i, 0, N) scanf("%d", &L[i]);

    sort(L, L + N);

    int sum = 0;
    REP(i, 0, N - 1) sum += L[i];

    if (L[N - 1] < sum) puts("Yes");
    else puts("No");

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int n = sc.nextInt();
		int[] a=new int[n];
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
		}
		Arrays.sort(a);
		int[] d=new int[n];
		for(int i=0;i<n-1;i++){
			d[i]=a[i+1]-a[i];
		}
		d[n-1]=k-(a[n-1]-a[0]);
		Arrays.sort(d);
		System.out.println(k-d[n-1]);
	}
}


Measured memory_bytes: 87448
// 2738_A-unBreathing.cpp
//
#include <bits/stdc++.h>
using namespace std;
int n, cnt;
string s[110];

string solve() {
  cnt = 0;
  for(int i = 0; i < n; ++i) {
    if(s[i] == "A") cnt++;
    if(s[i] == "Un") cnt--;

    if(cnt < 0) return "NO";
  }
  return cnt == 0 ? "YES" : "NO";
}

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) cin >> s[i];
  cout << solve() << endl;
  return 0;
}



Measured memory_bytes: 3204
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

long snuke[105];

int main(){
    long n, k;
    scanf("%ld%ld", &n,&k);
    for(int i = 0; i< k; i++){
        long d;
        scanf("%ld",&d);
        for(int j = 0; j < d; j++){
            long a;
            scanf("%ld",&a);
            snuke[a]++;
        }
    }
    long ans = 0;
    for(int i = 1; i <= n; i++){
        if(snuke[i] == 0){
            ans++;
        }
    }
    printf("%ld\n", ans);
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  int n,p,a[50];
  ll dp[50][2]={0};
  cin>>n>>p;
  if (a[0]%2==0) dp[0][0]=2;
  else {
    dp[0][1]=1;
    dp[0][0]=1;
  }
  for (int i(0);i<n;i++) cin>>a[i];
  for (int i(1);i<n;i++){
    if (a[i]%2==0){
      dp[i][0]=dp[i-1][0]*2; 
      dp[i][1]=dp[i-1][1]*2;
    }else{
      dp[i][0]=dp[i-1][0]+dp[i-1][1];
      dp[i][1]=dp[i-1][0]+dp[i-1][1];
    }
  }
  for (int i(0);i<2;i++){
    for (int j(0);j<5;j++){
      cerr << dp[j][i] << " ";
    }
    cerr << endl;
  }
  cout << dp[n-1][p] << endl;
}



Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
  int N,K,d,x; 
  cin >> N >> K;
  set<int> S;
  
  
  REP(i,K){
    cin >> d;
    REP(j,d){
      cin >> x;
      S.insert(x);
    }
  }
  
  cout << N-S.size() << endl;
}


Measured memory_bytes: 3632
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())

    ans = 0
    for i in range(1, N+1):
        n = N // i
        ans += n * (n + 1) * i // 2

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 62924
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String line = reader.readLine();
        String result = line.replaceAll("apple", "TMP");
        result = result.replaceAll("peach", "apple");
        result = result.replaceAll("TMP", "peach");
        out.println(result);
    }
}

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

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	string path;
	//1st round trip
	for (int i = sx; i < tx; i++) {
		path.push_back('R');
	}
	for (int j = sy; j < ty; j++) {
		path.push_back('U');
	}

	for (int i = sx; i < tx; i++) {
		path.push_back('L');
	}
	for (int j = sy; j < ty; j++) {
		path.push_back('D');
	}

	//2nd round trip
	path.push_back('D');
	for (int i = sx; i <= tx; i++) {
		path.push_back('R');
	}
	for (int j = sy; j <= ty; j++) {
		path.push_back('U');
	}
	path.push_back('L');

	path.push_back('U');
	for (int i = sx; i <= tx; i++) {
		path.push_back('L');
	}
	for (int j = sy; j <= ty; j++) {
		path.push_back('D');
	}
	path.push_back('R');

	cout << path << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return input().split()
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    s = S()
    t = 0
    l = []
    r = []
    for _ in range(II()):
        q = LS()
        if q[0] == "1":
            t ^= 1
        else:
            _,f, c = q
            if f == "1":
                if t:
                    r.append(c)
                else:
                    l.append(c)
            else:
                if t:
                    l.append(c)
                else:
                    r.append(c)
    if t:
        print("".join(r[::-1] + s[::-1] + l))
    else:
        print("".join(l[::-1] + s + r))
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 72968
//
// Created by moono on 2018/10/27.
//

#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;



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

    //
    bool is_found = false;
    for (int i = 0; i < 101; ++i) {
        int n = b*i + c;
        if(n % a == 0){
            is_found = true;
        }
    }

    if(is_found){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> graph[n];
    int result = n;
    for (int a, b; cin >> a >> b; ) {
        graph[a - 1].emplace_back(b - 1);
        graph[b - 1].emplace_back(a - 1);
    }
    if (k % 2 == 0) {
        for (int i = 0; i < n; i++) {
            vector<bool> visited(n);
            visited[i] = true;
            queue<int> queue;
            queue.emplace(i);
            int current = 0, dist = 0;
            do {
                for (auto size = queue.size(); size > 0; size--) {
                    auto front = queue.front();
                    if (dist > k / 2) {
                        current++;
                    }
                    queue.pop();
                    for (auto j : graph[front]) {
                        if (!visited[j]) {
                            visited[j] = true;
                            queue.emplace(j);
                        }
                    }
                }
                dist++;
            } while (!queue.empty());
            result = min(result, current);
        }
    } else {
        for (int i = 0; i < n; i++) {
            for (int j : graph[i]) {
                vector<bool> visited(n);
                visited[i] = true;
                visited[j] = true;
                queue<int> queue;
                queue.emplace(i);
                queue.emplace(j);
                int current = 0, dist = 0;
                do {
                    for (auto size = queue.size(); size > 0; size--) {
                        auto front = queue.front();
                        if (dist > k / 2) {
                            current++;
                        }
                        queue.pop();
                        for (auto j : graph[front]) {
                            if (!visited[j]) {
                                visited[j] = true;
                                queue.emplace(j);
                            }
                        }
                    }
                    dist++;
                } while (!queue.empty());
                result = min(result, current);
            }
        }
    }
    cout << result;
    return 0;
}

Measured memory_bytes: 384
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
L = LI()
A = [0] * n
total = 0
for i in range(n - 1, -1, -1):
    ret = 0
    for j in range((i + 1) * 2 - 1, n, i + 1):
        ret += A[j]
    if L[i] != ret % 2:
        A[i] = 1
        total += 1



print(total)
for k in range(n):
    if A[k]:
        print(k + 1)

Measured memory_bytes: 63052
# B
N = int(input())
S_list = list()
for _ in range(N):
    S_list.append(list(input()))

res = 0

def is_symmetric(M):
    res = True
    for i in range(N):
        for j in range(i+1, N):
            if M[i][j] != M[j][i]:
                return False
    return True

for _ in range(N):
    if is_symmetric(S_list):
        res += 1
    for i in range(N):
        S_list[i] = S_list[i][1:] + S_list[i][:1]
print(res*N)

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

char mp[21][21];
int fx[10001], fy[10001], f[21][21], t[21][21];
int xmo[4] = {1, -1, 0, 0}, ymo[4] = {0, 0, 1, -1};
int ans=-1;

int main()
{
  int h, w;
  scanf("%d%d", &h, &w);
  for(int i = 0; i < h; i++) scanf("%s", mp[i]);
  for(int i = 0; i < h; i++)
    for(int j = 0; j < w; j++)
    {
      if(mp[i][j] != '#')
      {
        int l = 1, r = 2;
        fx[1] = i;
        fy[1] = j;
        memset(f,0,sizeof(f));
        memset(t,0,sizeof(t));
        t[i][j]=1;
        while(l < r)
        {
          for(int k = 0; k < 4; k++)
          {
            int xx = fx[l] + xmo[k], yy = fy[l] + ymo[k];
            if(  xx >= 0 && yy >= 0 && xx < h && yy < w )
            {
              if(mp[xx][yy] != '#'&&(!t[xx][yy]||(t[xx][yy]==0&&f[xx][yy]>f[fx[l]][fy[l]]+1)) )
              {
                t[xx][yy] = 1;
                fx[r] = xx;
                fy[r] = yy;
                f[xx][yy] = f[fx[l]][fy[l]] + 1;
                r++;
              }
            }
          }
          l++;
        }
        for(int i = 0; i < h; i++)
          for(int j = 0; j < w; j++)
            ans=max(ans,f[i][j]);
      }
    }
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 256
/* You are being watched. */


//~ while (clock() <= 69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")

using namespace std;

//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template <typename T>
//~ using ordered_set =
  //~ tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define show(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

void solve() {
  int k; cin >> k;
  string s; cin >> s;
  if(s.length() > k) {
    print(s.substr(0, k) + "...");
  }
  else {
    print(s);
  }
}

int main() {
  int t; t = 1;
  while(t--) solve();
}

Measured memory_bytes: 3616
use whiteread::parse_line;

fn main() {
    let s: String = parse_line().unwrap();
    let mut s: Vec<u8> = s.into_bytes();
    let t: String = parse_line().unwrap();
    let mut t: Vec<u8> = t.into_bytes();

    s.sort();
    if t.iter().any(|x| x > &s[0]) {
        println!("Yes");
    } else {
        t.sort();
        if s.iter().lt(t.iter()) {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}


Measured memory_bytes: 2156
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int l[10];
  int v1,v2;
  int sum;
  double coll;
  int station;
  while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&v1,&v2)+1){
    sum=0;
    for(int i=0;i<10;i++){
      sum+=l[i];
    }
    //  cout<<"sum="<<sum<<endl;
    coll=(double)(v1*sum)/(double)(v1+v2);
    //  cout<<coll<<endl;
    for(int i=0;i<10;i++){
      coll-=l[i];
      if(coll<=0){cout<<i+1<<endl;break;}
    }
  }
}
    

Measured memory_bytes: 1208
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;

void solve()
{
    int n;
    cin >> n;
    if(n >= 30)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


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


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

int main() {
  int N;
  cin >> N ;
  
  if(N/1000 == N%1000/100 && N/1000 == N%100/10)
    cout << "Yes" <<endl;
  else if(N%1000/100 == N%100/10 && N%1000/100 == N%10)
    cout << "Yes" <<endl;
  else if(N%1000/100 == N%100/10 && N%1000/100 == N%10 && N/1000 == N%10)
    cout << "Yes" <<endl;
  else{
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;
int a[3];

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

    int n;
    cin >> n;
    memset(a, 0, sizeof(a));
    REP(i, n){
        int x;
        cin >> x;
        a[x%4]++;
    }

    int sumodd = a[1]+a[3];
    int sum2 = a[2];
    int sum4 = a[0];
    if(sumodd-sum4 > 1){
        puts("No");
    }else if(sumodd-sum4 == 1){
        if(sum2 == 0) puts("Yes");
        else puts("No");
    }else{
        puts("Yes");
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int N;
int Y;
/*==================================================*/
/*function*/

/*==================================================*/

int main() {

    cin>>N>>Y;

    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N; j++){
            if((N-i-j) < 0) continue;
            if(10000*i + 5000*j + 1000*(N-i-j) == Y){
                cout<<i<<" "<<j<<" "<<(N-i-j)<<endl;
                return 0;
            }
        }
    }

    cout<<-1<<" "<<-1<<" "<<-1<<endl;

    return 0;
}


Measured memory_bytes: 256