akhauriyash/Code-Regression huggingface dataset:
#pragma comment (linker, "/STACK:256000000")
 
#define _USE_MATH_DEFINES
#define _CRT_NO_DEPRECEATE
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <memory.h>
#include <sstream>
#include <cassert>
#include <ctime>
#include <complex>
 
//#include <random>
 
using namespace std;
 
 
double PI = 3.1415926535897932384626433832795;
long double EPS = 1e-12;
 
typedef unsigned int uint32;
typedef long long int64;
typedef unsigned long long uint64;
 
typedef pair<int, int> pii;
const int MAXN = 510;
const int ROOT = 333;


int n, m;
int mas[MAXN][MAXN];
int red[MAXN][MAXN];
int blu[MAXN][MAXN];

void solve()
{
	scanf("%d %d\n", &n, &m);
	for(int i = 0; i < m; ++i)
	{
		red[0][i] = 1;
		blu[n - 1][i] = 1;
	}

	for(int i = 1; i < n - 1; ++i)
	{
		for(int j = 0; j < m; ++j)
		{
			if (j & 1)
				red[i][j] = 1;
			else
				blu[i][j] = 1;
		}
	}

	for(int i = 0; i < n; ++i)
	{
		for(int j = 0; j < m; ++j)
		{
			char p;
			scanf("%c", &p);
			if (p == '#')
			{
				red[i][j] = 1;
				blu[i][j] = 1;
			}
		}
		scanf("\n");
	}

	for(int i = 0; i < n; ++i)
	{
		for(int j = 0; j < m; ++j)
		{
			if (red[i][j])
				printf("#");
			else
				printf(".");
		}
		printf("\n");
	}
	printf("\n");
	for(int i = 0; i < n; ++i)
	{
		for(int j = 0; j < m; ++j)
		{
			if (blu[i][j])
				printf("#");
			else
				printf(".");
		}
	
		printf("\n");
	}
}

 
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _MY_DEBUG
    freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout);
#else
    //freopen(TASK ".in", "rt", stdin); freopen(TASK ".out", "wt", stdout);
#endif
    srand(1313);
	
	int t = 1;
	//cin >> t;

	for(int i = 0; i < t; ++i)
	{
		solve();
		
	}
	
    return 0;
}   

Measured memory_bytes: 2816
while num = gets.split(" ").map(&:to_i) do
  if num[0] == 0 && num[1] == 0 then
    exit
  end
  for i in 1..num[0] do
    for j in 1..num[1] do
      printf("#")
    end
    printf("\n")
  end
  printf("\n")
end

Measured memory_bytes: 8732
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>

using namespace std;

#define sz(a) static_cast<int>((a).size())
#define f first
#define s second
#define els(v) for (auto &el : (v))


#ifdef KIRYA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) {
    cerr << _s << " = " << _h << "\n";
}

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;

    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;

    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

const int64_t INF = static_cast<int64_t>(1e9) + 7;
const int64_t LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

void solve() {
    int h, n;
    cin >> h >> n;
    vector<int> vec(n);
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> vec[i];
        sum += vec[i];
    }
    if (sum >= h) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

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

    int q = 1;

    for (int i = 0; i < q; ++i) {
        solve();
    }
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef long long ll;

using namespace std;

ll gcd(ll a,ll b)
{
	if (a%b==0)	{
		return(b);
    } else {
		return(gcd(b,a%b));
    }
}

void Eratosthenes(vector<bool> &vec, ll N){
  ll i,j;
  for(i=0;i<N;i++){
    vec[i] = true;
  }
  i=2;
  for(j=2;i*j<N;j++){
    vec[i*j] = false;
  }
  for(i=3;i<N;i++){
    if(vec[i]){
      for(j=2;i*j<N;j++){
        vec[i*j] = false;
      }
    }
  }
}

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

int main(int argc, const char * argv[]) {
  ll A,B,C;
  cin >> A >> B;
  if(A > B) C = gcd(A,B);
  else C = gcd(B,A);
  ll ans = 0;
  ll i;
  for(i=1;i*i<=C;i++){
    if(C%i==0){
      ans += isprime(i);
      if(C/i!=i)
      	ans += isprime(C/i);
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
def submit():
    n, k = map(int, input().split())
    xlist = list(map(int, input().split()))

    min_cost = float('inf')
    for i in range(n - k + 1):
        st = i
        ed = i + k - 1
        
        to_start = min(abs(xlist[st]), abs(xlist[ed]))
        start_end = xlist[ed] - xlist[st]

        if min_cost > to_start + start_end:
            min_cost = to_start + start_end

    print(min_cost)
        

if __name__ == "__main__":
    submit()

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

#define REP(i, s, e) for(int i = (int)s; i < (int) e; i++)
#define rep(i, n) REP(i, 0 ,n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

typedef long long ll;

int main(){
    int n;
    cin>>n;
    ll ans = 0LL;
    vector<int> h(n);
    rep(i, n) cin>>h[i];
    sort(rall(h));
    rep(i, n){
        ans += max(0, h[i]-i/4);
    }
    cout<<ans+1LL<<endl;
}

Measured memory_bytes: 1200
N,M,C = map(int, input().split())
M = list(map(int, input().split()))

A = []

for i in range(N):
    A.append(list(map(int, input().split()))) 
    # a = list(map(int,input.split()))
sum = 0
count = 0
for i in range(N):
    for j in range(len(M)):
        sum += A[i][j] * M[j]

    sum += C
    if sum > 0:
        count += 1
    sum = 0

print(count)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
	int b[3];
	int i;
	
	for (i = 0; i < 3; i++){
		scanf("%d", &b[i]);
	}
	
	if (b[2] * 2 + b[0] + b[1] >= 2){
		printf("Open\n");
	}
	else {
		printf("Close\n");
	}
	
	return (0);
}

Measured memory_bytes: 584
#include<stdio.h>
int main(){
	int n,moto,ans,min;
  	scanf("%d %d",&n,&moto);
  int pri[n+1];
  pri[0]=moto;
  	for(int i=1;i<1+n;i++){
    	scanf("%d",&pri[i]);
      moto-=pri[i];
      if(pri[0]>pri[i]){
      	pri[0]=pri[i];
      }
    }
  	moto=moto/pri[0];
  	
	printf("%d",moto+n);
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int N, M, A, B[20], C, ans=0;
	cin >> N >> M >> C;
	rep(i, M) cin >> B[i];
	for(int i=0; i<N; i++){
		int total=0;
		for(int j=0; j<M; j++){
			cin >> A;
			total+=B[j]*A;
		}
		total+=C;
		if(total>0){
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    int zorome = 0;
    bool kaisu = false;
    for (size_t i = 0; i < N; i++)
    {
        int fd, sd;
        cin >> fd >> sd;
        if (fd == sd)
        {
            zorome++;
            /* code */
        }
        else
        {
            zorome = 0;
        }
        if (zorome == 3)
        {
            kaisu = true;
            zorome = 0;
        }
        /* code */
    }
    if (kaisu)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

Measured memory_bytes: 3104
module Main where

import Control.Applicative
import Control.Monad
import Data.List
import Data.Maybe
import qualified Data.IntMap.Strict as M

conn :: M.IntMap [Int] -> Bool
conn m = iter (M.singleton k ()) [k]
  where
    k = fst $ M.findMin m
    iter s []     = M.null $ M.difference m s
    iter s (t:ts)
        | isNothing as = iter s ts
        | otherwise    = iter (foldr (\k acc -> M.insert k () acc) s bs) (bs ++ ts)
      where
        as = M.lookup t m
        bs = filter (`M.notMember` s) (fromJust as)

isBridge :: M.IntMap [Int] -> (M.Key, Int) -> Bool
isBridge m (k, e) = not . conn . M.adjust (delete k) e . M.adjust (delete e) k $ m

main :: IO ()
main = do
    [n, m] <- fmap read . words <$> getLine :: IO [Int]
    es <- replicateM m $ do
        [a, b] <- fmap read . words <$> getLine :: IO [Int]
        return (a, b)
    let edges = concatMap (\(a, b) -> [(a, [b]), (b, [a])]) es
    let grp = M.fromListWith (++) edges
    print $ length $ filter (isBridge grp) es

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

const int MAX = 30;
const int MAX2 = 500;
const int INF = 1073741823; // 10^30-1、使わない辺とかに用いる

int main() {
	int N, C, D[MAX][MAX], c[MAX2][MAX2];
	cin >> N >> C;
	for (int i = 0;i < C;i ++) for (int j = 0;j < C;j ++) cin >> D[i][j];
	for (int i = 0;i < N;i ++) for (int j = 0;j < N;j ++) cin >> c[i][j];
	
	if (N == 1) { // 例外条件
		cout << 0;
		return 0;
	}
	
	int color[3][MAX]; // 色の個数
	for (int i = 0;i < 3;i ++) for (int j = 0;j < C;j ++) color[i][j] = 0;
	for (int i = 0;i < N;i ++) {
		for (int j = 0;j < N;j ++) {
			color[(i + j) % 3][c[i][j] - 1] ++;
		}
	}
	
	pair<int, int> change[3][MAX]; // 色を決め打った時のコスト
	for (int i = 0;i < 3;i ++) for (int j = 0;j < C;j ++) change[i][j] = make_pair(0, j);
	for (int i = 0;i < 3;i ++) {
		for (int j = 0;j < C;j ++) { // 決め打つ色
			for (int k = 0;k < C;k ++) {
				change[i][j].first += D[k][j] * color[i][k];
			}
		}
		sort(change[i], change[i] + C);
	}
	
	int ans = INF;
	for (int i = 0;i < 3;i ++) {
		for (int j = 0, k;j < 3;j ++) {
			if (change[0][i].second == change[1][j].second) continue;
			for (k = 0;change[2][k].second == change[0][i].second || change[2][k].second == change[1][j].second;k ++);
			ans = min(ans, change[0][i].first + change[1][j].first + change[2][k].first);
		}
	}
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

まず、(1, 1)、(1, 2)、(2, 1)の所に色を決め打つと全部の色が決まります
そこで、この3つに対してO(N^2)で各色の個数を出しておきます
そうすると、O(C)で決め打った時の違和感の大きさが出せます
次に、これらの中から最小の組み合わせを探すのはO(C^2 + ClogC)です
よって全体でO(N^2 + C^2)で解くことができます
*/

Measured memory_bytes: 1280
fun main(args: Array<String>) {
    val (k, s) = readLine()?.split(" ")?.map { it.toInt() } ?: return
    var count = 0
    for (x in 0..k) {
        for (y in 0..k) {
            val rest = s - (x + y)
            if (rest in 0..k) {
                count++
            }
        }
    }
    println(count)
}

Measured memory_bytes: 36012
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
    int n, l; cin >> n >> l;
    string s[n];
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    sort(s, s + n);
    for (int i = 0; i < n; ++i) {
        cout << s[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int main(){
  int h, w;
  scanf("%d %d\n", &h, &w);
  
  char c[100];
  for(int i=0; i<h; i++){
    scanf("%s", c);
    
    printf("%s\n%s\n", c, c);
  }
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){
  int n;
  char p, dummy;
  int input;
  int arr[4][13];
  int i, j;

  // array initialization
  for(i = 0; i < 4; i++){
    for(j = 0; j < 13; j++){
      arr[i][j] = 0;
    }
  }

  // array input
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%c", &dummy);
    scanf("%c %d", &p, &input);
    switch(p){
      case 'S':
	arr[0][input - 1] = 1;
	break;
      case 'H':
	arr[1][input - 1] = 1;
	break;
      case 'C':
	arr[2][input - 1] = 1;
	break;
      case 'D':
	arr[3][input - 1] = 1;
	break;
    }
  }

  // output
  for(i = 0; i < 4; i++){
    for(j = 0; j < 13; j++){
      if(arr[i][j] == 0){
        switch(i){
          case 0:
            printf("S %d\n", j + 1);
            break;
          case 1:
            printf("H %d\n", j + 1);
            break;
          case 2:
            printf("C %d\n", j + 1);
            break;
          case 3:
            printf("D %d\n", j + 1);
            break;
        }
      }
    }
  }
  
  return 0;
}



Measured memory_bytes: 2032
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tp3 = tuple<int, int, int>;
using Mat = vector<vector<ll>>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
// ============ template finished ============

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N)cin >> a[i];
    int cnt = 0;
    rep(i, N) {
        if (i % 2 == 0 && a[i] % 2 == 1)cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<cctype>
#include<vector>
#include<numeric>
#include<map>
#include<set>

using namespace std;

int par[128];
int M=1000000007;

int find(int x){
  return (x==par[x])?x:par[x]=find(par[x]);
}

void unite(int a,int b){
  par[find(a)]=find(b);
}

int main(){
  int N,m;
  cin>>N>>m;
  string s;
  cin>>s;
  vector<char> var(m);
  vector<int> u(m);
  char vton[128];
  for(int i=0;i<m;i++){
    cin>>var[i]>>u[i];
    vton[var[i]]=i;
  }
  int ans=0;
  for(int i=0;i<1<<m;i++){
    for(int j=0;j<m;j++){
      if(i>>j&1&&u[j]<10)goto next;
    }
    {
      string t;
      for(auto e:s){
	if(isalpha(e)&&i>>vton[e]&1){
	  t+=toupper(e);
	}
	t+=e;
      }
      iota(begin(par),end(par),0);
      for(int j=0;j<t.size();j++){
	unite(t[j],t[t.size()-1-j]);
      }
      set<int> p;
      for(auto e:t){
	p.insert(find(e));
      }
      for(int j=0;;j=(j+1+~i)&i){
	map<int,set<char> > num;
	map<int,int> lb,ub;
	for(auto e:t){
	  int x=find(e);
	  if(isdigit(e)){
	    num[x].insert(e);
	  }else if(islower(e)){
	    int nlb=0,nub=(j>>vton[e]&1)?u[vton[e]]%10+1:min(10,u[vton[e]]+1);
	    if(!lb.count(x)){
	      lb[x]=nlb;
	      ub[x]=nub;
	    }else{
	      lb[x]=max(lb[x],nlb);
	      ub[x]=min(ub[x],nub);
	    }
	  }else{
	    int vux=vton[tolower(e)];
	    if(j>>vux&1){
	      num[x].insert(u[vux]/10+'0');
	    }else{
	      int nlb=1,nub=u[vux]/10;
	      if(!lb.count(x)){
		lb[x]=nlb;
		ub[x]=nub;
	      }else{
		lb[x]=max(lb[x],nlb);
		ub[x]=min(ub[x],nub);
	      }
	    }
	  }
	}
	int c=1;
	for(auto e:p){
	  if(num[e].size()>1){
	    c=0;
	    break;
	  }
	  if(lb.count(e)){
	    if(num[e].empty()){
	      c=c*1LL*max(0,ub[e]-lb[e])%M;
	    }else{
	      int n=*num[e].begin()-'0';
	      if(n<lb[e]||ub[e]<=n){
		c=0;
		break;
	      }
	    }
	  }
	}
	ans=(ans+c)%M;
	if(j==i)break;
      }
    }
  next:
    ;
  }
  cout<<ans<<endl;
}

	      
	    
	    
    
	

	
		

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

int main(void) {
  string a, b, c, d;
  cin >> a >> b >> c >> d;
  string s = a + b + c + d;
  sort(s.begin(), s.end());
  if (s == "1479") cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();
	    System.out.printf("%.7f %.7f\n", r*r*Math.PI, 2*r*Math.PI);
		sc.close();
	}
}


Measured memory_bytes: 28260
#include<bits/stdc++.h>
#include<vector>
#define int long long
#include<string>
#define float long double
using namespace std;
   signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a,b;
  cin>>a>>b;
  int s=1,t=0;
  while(1)
  {
     if(b>s)
     {
         s=s+a-1;
         t++;
     }
     if(b<=s)
     {
         cout<<t;
         return 0;
     }
  }
}


Measured memory_bytes: 384
import bisect
import sys
import itertools
import queue
input = sys.stdin.readline
sys.setrecursionlimit(100000)
# mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    N, K, C = read_values()
    S = input().strip()
    P = []

    c = -1
    for i, s in enumerate(S):
        if s == "o":
            if c == -1:
                c = 0
                L = [i]
            else:
                L.append(i)
        if c == -1:
            continue
        c += 1
        if c > C:
            P.append(L)
            c = -1
    if c != -1:
        P.append(L)

    if len(P) > K:
        return

    t = len(P[-1])
    res = []
    for i in range(len(P) - 1, 0, -1):
        if len(P[i][:t]) == 1:
            res.append(str(P[i][0] + 1))
        
        p = P[i][t - 1]
        t = bisect.bisect_left(P[i - 1], p - C)
    
    if len(P[0][:t]) == 1:
        res.append(str(P[0][0] + 1))

    print("\n".join(res[::-1]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 47428
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    A *= 100, B *= 100;
    double maxp = 0;
    int maxw = 0.0, maxs = 0.0;
    for(int i = 0; A * i <= F; ++i){
        for(int j = 0; A * i + B * j <= F; ++j){
            int W = A * i + B * j;
            if(W == 0)  continue;
            for(int k = 0; W + C * k <= F; ++k){
                if(C * k > W / 100 * E) break;
                for(int l = 0; W + C * k + D * l <= F; ++l){
                    int S = C * k + D * l;
                    if(S > W / 100 * E) break;
                    double P = 100.0 * S / (W + S);
                    if(P > maxp){
                        maxp = P;
                        maxw = W;
                        maxs = S;
                    }
                }
            }
        }
    }
    if(maxp == 0)   maxw = A;
    cout << maxw + maxs << ' ' << maxs << endl;
}

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

int main()
{
    int n;
    bool a[100];

    cin >> n;

    int max = 0, cnt = 0;
    for( int i = 0; i < n; i++ )
    {
        cin >> a[i];
        if( a[i] )
        {
            cnt++;
            max = max < cnt ? cnt : max;
        }
        if( !a[i] )
            cnt = 0;
    }

    cout << max + 1 << endl;

    return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define all(x) x.begin(), x.end()
#define x first
#define y second
#define mp make_pair
#define mt make_tuple

const int N = 1e6 + 10;
int n;
int a[N];
int d[N];

signed main() {
#ifdef LC
	assert(freopen("input.txt", "r", stdin));
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	fill_n(d, N, -1);
	for (int i = n; i >= 1; --i) {
		int x = a[i];
		for (int j = 2 * i; j <= n; j += i) {
			assert(d[j] != -1);
			x ^= d[j];
		}
		assert(d[i] == -1);
		d[i] = x;
	}
	vector<int> ans;

	for (int i = 1; i <= n; ++i) {
		if (d[i]) {
			ans.push_back(i);
		}
	}
	cout << ans.size() << "\n";
	for (int e : ans) {
		cout << e << " ";
	}
	cout << "\n";
	return 0;
}


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

bool f(int x) {
    int digit = 0;
    while(x) {
        digit++;
        x /= 10;
    }
    return digit%2 == 1;
}
int main() {
    int n; cin>>n;
    int ans=0;
    for (int i=1; i<=n; ++i){
        if(f(i)) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int n;
    while(scanf("%d",&n)!=EOF){
        int a = 1;
        for(int i = 1;i <= n; i++){
            a += i;
        }
        printf("%d\n",a);
    }
    return 0;
}

Measured memory_bytes: 1188
import Control.Monad (replicateM,mapM_)
import Data.Array (Array,listArray,(!),elems)
import Data.List (foldl')

type Cards = Array Int Int

main = do
    n <- readLn
    m <- readLn
    ks <- replicateM m readLn

    let
        cards = foldl' (shuffle n) (initCards n) ks

    mapM_ print (elems cards)

    where
    shuffle n cards 0 = riffle n cards
    shuffle n cards k = cut n k cards
        

initCards :: Int -> Cards
initCards n = listArray (1,2*n) [1,2..]

riffle :: Int -> Cards -> Cards
riffle n cards = listArray (1,2*n) (map (cards !) ixs)
    where
    ixs = concatMap (\i -> [i,n+i]) [1..n]

cut :: Int -> Int -> Cards -> Cards
cut n k cards = listArray (1,2*n) (map (cards !) ([k+1..2*n]++[1..k]))

Measured memory_bytes: 24680
#include<algorithm>/*{{{*/
#include<cctype>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<vector>
using namespace std;
typedef long long lld;
typedef long double lf;
typedef unsigned long long uld;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
namespace RA{
    int r(int p){return 1ll*rand()*rand()%p;}
    int r(int L,int R){return r(R-L+1)+L;}
}/*}}}*/
/******************heading******************/
const int P=1e9+7,N=3005,I2=500000004;

int n,q;
int a[N];
int f[N][N];

int main(){
    scanf("%d%d",&n,&q);
    FOR(i,1,n)scanf("%d",&a[i]);
    FOR(i,1,n)FOR(j,1,n){
        if(a[i]>a[j])f[i][j]=1;
    }
    FOR(i,1,q){
        int x,y;
        scanf("%d%d",&x,&y);
        if(x>y)swap(x,y);
        f[x][y]=(1ll*f[x][y]*I2+1ll*f[y][x]*I2)%P;
        f[y][x]=f[x][y];
        FOR(i,1,n){
            if(i==x||i==y)continue;
            f[x][i]=(1ll*f[x][i]*I2+1ll*f[y][i]*I2)%P;
            f[y][i]=f[x][i];
            f[i][x]=(1ll*f[i][x]*I2+1ll*f[i][y]*I2)%P;
            f[i][y]=f[i][x];
        }
    }
    int ans=0;
    FOR(i,1,n)FOR(j,i+1,n)ans=(ans+f[i][j])%P;
    FOR(i,1,q)ans=ans*2%P;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 35456
#![allow(non_snake_case, dead_code)]
use proconio::fastout;
use proconio::input;
use rand::Rng;

#[fastout]
fn main() {
    input! {
        D:usize,
        C:[i64;26],
        S:[[i64;26];D]
    }
    let mut ans = 0;
    let mut rng = rand::thread_rng();
    let mut T = vec![0; D];
    let mut Tmax = vec![0; D];
    let start = std::time::Instant::now();
    loop {
        for i in 0..D {
            T[i] = rng.gen::<usize>() % 26;
        }
        let mut last = vec![vec![0i64; 26]; D];
        for d in 0..D {
            let i = T[d];
            last[d][i] = d as i64 + 1;
            for e in d + 1..D {
                if T[e] != i {
                    last[e][i] = d as i64 + 1;
                } else {
                    break;
                }
            }
        }
        let mut x = 0;
        for d in 0..D {
            let i = T[d];
            x += S[d][i];
            //println!("ss{}", x);
            for j in 0..26 {
                x -= C[j] * (d as i64 + 1 - last[d][j]);
                //println!("C[{}]={} -> {}", j, C[j], x);
            }
        }
        if ans < x {
            for k in 0..D {
                ans = x;
                Tmax[k] = T[k];
            }
        }
        let duration = start.elapsed();
        if duration > std::time::Duration::from_millis(900) {
            break;
        }
    }
    for i in 0..D {
        println!("{}", Tmax[i] + 1);
    }
}


Measured memory_bytes: 2856
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::collections::BinaryHeap;

fn main() {

  let n = read::<u32>();
  let m = read::<u32>();

  let mut start_gates = BinaryHeap::new();
  let mut end_gates = BinaryHeap::new();

  for _ in 0..m {
    let start = read::<i32>();
    let end = read::<i32>();
    start_gates.push(start);
    end_gates.push(-end);
  }

  let sg = start_gates.pop().unwrap();
  let eg = end_gates.pop().unwrap();
  let answer = (-eg) - sg + 1;

  if answer > 0 {
    println!("{}", answer);
  } else {
    println!("{}", 0);
  }

}


Measured memory_bytes: 6396
#include<stdio.h>
int main(void)
{
        int W,H,x,y,r;
        scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
        if(W>=x+r&&H>=y+r){if(r<=x&&r<=y){
                printf("Yes\n");}
        else{   printf("No\n");}}
        else{   printf("No\n");}
        return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
ll ans;
ll fac[100005];
ll sq(ll a){
	return (a*a)%mod;
}
ll fp(ll a,ll b){
	if(b==0)return 1;
	if(b==1)return a;
	if(b&1){
		return (sq(fp(a,b>>1))*a)%mod;
	}
	return sq(fp(a,b>>1))%mod;
}
ll cnk(ll n,ll k){
	if(n<k)return 0;
	if(n==k)return 1;
	if(k==0)return 1;
	ll res=fac[n];
	res*=fp(fac[k],mod-2);
	res%=mod;
	res*=fp(fac[n-k],mod-2);
	return (res)%mod;
}
int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int n,k;cin>>n>>k;
	vector<ll>v;
	for(int i=0;i<n;i++){
		ll a;cin>>a;
		v.push_back(a);
	}
	if(k==1){
		cout<<0<<endl;return 0;
	}
	sort(v.begin(),v.end());
	fac[0]=1;
	for(int i=1;i<1e5;i++){
		fac[i]=fac[i-1]*i;
		fac[i]%=mod;
	}
	for(int i=0;i<n;i++){
		ans+=v[i]*cnk(i,k-1);
		ans%=mod;
		ans-=v[i]*cnk(n-i-1,k-1);
		ans%=mod;ans+=mod;ans%=mod;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A, B, M;
    cin >> A >> B >> M;
    vector<long long> a(A), b(B);
    for(int i = 0; i < A; i++) cin >> a[i];
    for(int i = 0; i < B; i++) cin >> b[i];
    vector<long long> x(M), y(M), c(M);
    for(int i = 0; i < M; i++){
        cin >> x[i] >> y[i] >> c[i];
        x[i]--;
        y[i]--;
    }
    long long ans = a[0] + b[0];
    for(int i = 0; i < M; i++){
        long long res = a[x[i]] + b[y[i]] - c[i];
        if(ans > res) ans = res;
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    if(ans > a[0] + b[0]) ans = a[0] + b[0];
    cout << ans << endl;
}

Measured memory_bytes: 4224
// noobie_corleone
#include <bits/stdc++.h>
#define mp                    make_pair
#define pb                    push_back
#define ll                    long long
#define ss                       second
#define ff                        first
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)
#define inf                   1000000007
#define eps                   0.000000000000001
#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)         ((c).find(x) != (c).end())
#define cpresent(c,x)        (find(all(c),x) != (c).end())
#define pi                   pair<int,int>
#define pll                  pair < ll , ll >
#define endl                 '\n'
#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef vector< int > vi;
typedef vector< vi > vvi;
int dx[8]={1,-1,0,0,-1,-1,1,1};
int dy[8]={0,0,-1,1,-1,1,-1,1};
//vector<int> adj[200010];
//vector<int> value(200010),par(200010),vis(200010,0),fi(200010,0),g(200010,0),col(200010,-1);
int myrandom (int i) { return std::rand()%i;}

int main()
{
	int n;
	cin>>n;
	vector<int> h(n+1);
	fr(i,1,n+1)
	{
		cin>>h[i];
	}
	vector<ll> dp(n+1,inf);
	dp[1]=0;
	for(ll i=2;i<n+1;i++)
	{
		dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
		if(i>2)
		{
			dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
		}
	}
	cout<<dp[n]<<endl;
}


Measured memory_bytes: 1408
n=gets.to_i
l=gets.split.map(&:to_i)

count=0
0.upto(n-3) do |i|
    (i+1).upto(n-2) do |j|
        (j+1).upto(n-1) do |k|
            if l[i]!=l[j] && l[j]!=l[k] && l[k]!=l[i] && [l[i],l[j],l[k]].max<[l[i],l[j],l[k]].min(2).sum
                count+=1
            end
        end
    end
end
puts count


Measured memory_bytes: 14388
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n,k;cin>>n>>k;
    ll ans=k;n--;
    while(n--)ans*=(k-1);
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------









Measured memory_bytes: 896
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  ll h; cin >> h;
  ll ans = 0, num = 1;
  while(h>0) {
    ans += num;
    h /= 2;
    num *= 2;
  }
  cout << ans << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
//#define MOD (ll)(998244353)
#define MOD (ll)(1e9+7)
#define INF (1e15)
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
#ifdef LOCAL_TEST
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\input.in","r",stdin);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\output.out","w",stdout);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	int m,k; cin>>m>>k;
	int mx=(1ll<<m)-1;
	if(k>mx){
		cout<<"-1\n";
		return 0;
	}
	if(m==0){
		cout<<"0 0\n";
		return 0;
	}
	else if(m==1){
		if(k==1) cout<<"-1\n";
		else cout<<"0 0 1 1\n";
		return 0;
	}
	bool f=true;
	For(i,0,mx){
		if(i!=k){
			if(f) f=false;
			else cout<<" ";
			cout<<i;
		}
	}
	cout<<" "<<k;
	for(int i=mx;i>=0;i--){
		if(i!=k) cout<<" "<<i;
	}
	cout<<" "<<k<<"\n";
	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>

const int MaxN = 200000 + 5;

struct Graph {
  int cnte;
  int Head[MaxN], To[MaxN * 2], Next[MaxN * 2];

  inline void addEdge(int from, int to) {
    cnte++; To[cnte] = to;
    Next[cnte] = Head[from]; Head[from] = cnte;
  }
};

int N;
int A[MaxN];
int Ind[MaxN], Oud[MaxN];
bool F[MaxN];
Graph G;

void init() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
  for (int i = 1; i < N; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    if (A[u] > A[v]) {
      G.addEdge(u, v);
      Ind[v]++;
      Oud[u]++;
    } else if (A[u] < A[v]) {
      G.addEdge(v, u);
      Ind[u]++;
      Oud[v]++;
    }
  }
}

void dfs(int u) {
  if (Oud[u] == 0) {
    F[u] = false;
    return;
  }
  for (int i = G.Head[u]; i; i = G.Next[i]) {
    int v = G.To[i];
    dfs(v);
    if (F[v] == false) F[u] = true;
  }
}

void solve() {
  for (int i = 1; i <= N; ++i)
    if (Ind[i] == 0) dfs(i);
  for (int i = 1; i <= N; ++i) {
    if (F[i] == true) {
      printf("%d ", i);
    }
  }
  putchar('\n');
}

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

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

int main() {
    string s, t;
    cin >> s >> t;
    t.pop_back();
    if (s == t) puts("Yes");
    else puts("No");

    return 0;
}

Measured memory_bytes: 3624
n,x,m=map(int,input().split())
ans=x
a=[x]
d={}
d[x]=1
if n==1:
  print(ans)
else:
  for i in range(2,n+1):
    tmp=a[-1]**2%m
    if d.get(tmp,0)==0:
      a.append(tmp)
      d[tmp]=1
      ans+=tmp
    else:
      t=a.index(tmp)
      if len(a)-t>=n-i+1:
        ans+=sum(a[t:t+n-i+1])
        break
      else:
        t=a.index(tmp)
        tmp_a=(n-i+1)//(len(a)-t)
        tmp_b=(n-i+1)-(len(a)-t)*tmp_a
        ans+=sum(a[t:])*tmp_a+sum(a[t:t+tmp_b])
        break
  print(ans)

Measured memory_bytes: 14272
#include <iostream>
#include <string>
#include <vector>
using namespace std;

struct Card
{
	string val;
	size_t order;
};

bool is_smaller(Card a, Card b)
{
	if (stoi(a.val.substr(1,1)) < stoi(b.val.substr(1,1)))
		return true;
	else
		return false;
}

void bubble_sort(vector<Card> *cards, size_t n)
{
	for (size_t i=0; i<n; i++) {
		for (size_t j=n-1; j>i; j--) {
			if (is_smaller((*cards)[j], (*cards)[j-1]))
				swap((*cards)[j], (*cards)[j-1]);
		}
	}
}

void selection_sort(vector<Card> *cards, size_t n)
{
	for (size_t i=0; i<n; i++) {
		size_t minj = i;
		for (size_t j=i; j<n; j++) {
			if (is_smaller((*cards)[j], (*cards)[minj]))
				minj = j;
		}
		swap((*cards)[i], (*cards)[minj]);
	}
}

bool is_stable(vector<Card> cards, size_t n)
{
	for (size_t i=0; i<n-1; i++) {
		if (cards[i].val[1] == cards[i+1].val[1]) {
			if (cards[i].order > cards[i+1].order)
				return false;
		}
	}
	return true;
}

void print_cards(vector<Card> cards, size_t n)
{
	for (size_t i=0; i<n-1; i++)
		cout << cards[i].val << " ";
	cout << cards[n-1].val << endl;
}

int main(void)
{
	size_t n, order = 0;
	vector<Card> cards1, cards2;
	string buf;
	cin >> n;
	for (size_t i=0; i<n; i++) {
		cin >> buf;
		Card card;
		card.val = buf;
		card.order = order++;
		cards1.push_back(card);
		cards2.push_back(card);
	}

	bubble_sort(&cards1, n);
	print_cards(cards1, n);
	cout << (is_stable(cards1, n) ? "Stable" : "Not stable") << endl;

	selection_sort(&cards2, n);
	print_cards(cards2, n);
	cout << (is_stable(cards2, n) ? "Stable" : "Not stable") << endl;

	return 0;
}

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

ll solve() {
    ll H, W;
    cin >> H >> W;
    vector<vector<ll>> A(H, vector<ll>(W)), p(H, vector<ll>(W));
    for ( int i = 0; i < H; i++ ) {
        for ( int j = 0; j < W; j++ ) {
            cin >> A[i][j];
            p[i][j] = A[i][j] % 2;
        }
    }
    vector<int> x1,x2,y1,y2;
    int hn, wn;
    for ( int h = 0; h < H; h++ ) {
        for ( int w = 0; w < W; w++ ) {
            int nh, nw;
            if ( p[h][w] ) {
                if ( w < W-1 ) {
                    nh = h;
                    nw = w+1;
                } else if ( h < H-1 ) {
                    nh = h+1;
                    nw = w;
                } else {
                    continue;
                }
                p[nh][nw] += 1;
                p[nh][nw] %= 2;
                y1.push_back(h+1);
                x1.push_back(w+1);
                y2.push_back(nh+1);
                x2.push_back(nw+1);
            }
        }
    }
    cout << y1.size() << "\n";
    for ( int i = 0; i < y1.size(); i++ ) {
        cout<< y1[i] << " " << x1[i] << " " << y2[i] << " "  << x2[i] << "\n";
    }
    return 0;
}

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

Measured memory_bytes: 8168
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define foro(i, n) for(i=0; i<n; i++)
#define forl(i, n) for(i=1; i<=n; i++)
#define x first
#define y second
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 1e18 + 1;

int main()
{
	int i, j, k, tmp;
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	double l;
	cin >> l;
	l /= 3;
	printf("%.10lf\n", l*l*l);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

int main(){
string s,ans="";cin>>s;
for(int i=0;i<s.length();i++){
    if(s[i]=='0')ans+='0';
    if(s[i]=='1')ans+='1';
    if(s[i]=='B'&&ans.length())ans.erase(ans.length()-1);
    if(s[i]=='B'&&ans.length()==0)continue;
}
cout<<ans;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/agc033/tasks/agc033_b
//B - LRUD Game
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in");
    //std::ifstream in("./input.txt");
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll H,W,N; cin>>H>>W>>N;    
    ll sr,sc; cin>>sr>>sc;
    string S; cin>>S;
    string T; cin>>T;

    unordered_map<char,pair<int,int>> ofs = {
        {'U',{0,-1}},
        {'D',{0,1}},
        {'L',{-1,0}},
        {'R',{1,0}},
    };
    char sts[][2] = {
        {'U','D'},
        {'D','U'},
        {'L','R'},
        {'R','L'},
    };
    for(auto st:sts) {
        //char st[2]={'U','D'};
        ll py=sr;
        ll px=sc;
        REP(i,S.size()){
            const auto& f = ofs[st[0]];
            const auto& s = ofs[st[1]];
            if(S.at(i)==st[0]){
                px+=f.first;
                py+=f.second;
            }
            if(px<1||px>W||py<1||py>H){
                cout<<"NO"<<endl;
                return 0;
            }
            if(T.at(i)==st[1]){
                px+=s.first;
                py+=s.second;
            }
            px=max(1LL,px); px=min(W,px);
            py=max(1LL,py); py=min(H,py);
        }
    }
    cout<<"YES"<<endl;

    return 0;
}

Measured memory_bytes: 920
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<map>
#include<set> 
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<math.h>
using namespace std;
const int maxn = 1e3 + 5;
const int p = 233;
typedef unsigned long long ull;
int main()
{
	int n,sum1=0,sum2=0,cnt1=0,cnt2=0,flag1=0,flag2=0;
	int a[9],b[9],c[9],d[9];
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		c[i]=a[i];
	}
	for(int i=1;i<=n;i++)
	{
		cin>>b[i];
		d[i]=b[i];
	}
	sort(a+1,a+n+1);
	sort(b+1,b+n+1); 
	do{
		cnt1++;
		for(int i=1;i<=n;i++)
		{
			if(a[i]==c[i])
				flag1++;
		}
		if(flag1==n)
			break;
		flag1=0;
	}while(next_permutation(a+1,a+n+1));
	do{
		cnt2++;
		for(int i=1;i<=n;i++)
		{
			if(b[i]==d[i])
				flag2++;
		}
		if(flag2==n)
			break;
		flag2=0;
	}while(next_permutation(b+1,b+n+1));
	int res=cnt2-cnt1;
	if(res>=0)
		cout<<res;
	else
		{
			res=-res;
			cout<<res;
		}	
}

Measured memory_bytes: 3588
#include<stdio.h>
#include<math.h>
#include<string.h> 
#define ll long long int
int main() {
	ll a,b;
	scanf("%lld %lld",&a,&b);
	if(a==1&&b==1){
		printf("1");
	}
	if(a==1&&b!=1){
		printf("%lld",b-2);
	}
	if(a!=1&&b==1){
		printf("%lld",a-2);
	}
	if(a!=1&&b!=1){
		printf("%lld",a*b-2*(a+b)+4);
	}
	return 0;
}

Measured memory_bytes: 128
N, A = map(int, input().split())  # N枚数のカード, 平均をAにしたい
X = tuple(map(int, input().split()))  # N枚のカードの中身

dp = [[[0]*(50*N+2) for _ in range(N+2)] for _ in range(N+2)]

dp[0][0][0] = 1  # 0枚の中から0枚選んで合計が0になる選び方が1通りある

for i in range(N):
    for j in range(N+1):
        for k in range(50*N+1):
            if dp[i][j][k]:  # ここの分岐が分からん
                dp[i+1][j][k] += dp[i][j][k]
                dp[i+1][j+1][k+X[i]] += dp[i][j][k]
ans = 0
for i in range(1, N+1):
    ans += dp[N][i][i*A]
print(ans)


Measured memory_bytes: 65012
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	int ALL,ADD;;
	ALL=ADD=1;
	for(int i=0;i<n;i++){
		cin >> a[i];
		if(a[i]%2==0){
			ADD*=2;
		}else{
			ADD*=1;
		}
		ALL*=3;
	}
	cout << ALL-ADD << endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
base=0
for i in range(n+1):
    if i==0:
        base+=abs(a[0])
    elif i==n:
        base+=abs(a[n-1])
    else:
        base+=abs(a[i]-a[i-1])
ans=[]
for i in range(n):
    if i==0:
        ans.append(base+abs(a[1])-abs(a[0])-abs(a[1]-a[0]))
    elif i==n-1:
        ans.append(base+abs(a[n-2])-abs(a[n-1])-abs(a[n-2]-a[n-1]))
    else:
        ans.append(base+abs(a[i+1]-a[i-1])-abs(a[i+1]-a[i])-abs(a[i]-a[i-1]))
for i in range(n):
    print(ans[i])

Measured memory_bytes: 59116
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
typedef long long ll;

int main(){
  map<int,int> mp;
  rep(i,3){
    int x;
    cin >> x;
    mp[x] ++;
  }
  cout << mp.size() << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int num;
  int a[100];
  int i, j, swap, read;
  int count = 0;
  int min_i, min;

  scanf("%d", &num);
  for(i = 0; i < num; i++) {
    scanf("%d", &read);
    a[i] = read;
  }
  if(num == 1) printf("%d", a[0]);
  else{
  for(i = 0; i < num-1; i++){
    min_i = i; min = a[i];
    for(j = i+1; j < num; j++) if(min > a[j]){min_i = j; min = a[j];}
    if(i != min_i){
      swap = a[i];
      a[i] = a[min_i];
      a[min_i] = swap;
      count++;
    }
    printf("%d ", a[i]);
    if(i == num-2) printf("%d", a[num-1]);
  }
  }
  printf("\n%d\n", count);

  return 0;
}

Measured memory_bytes: 1820
from math import factorial as f
S = raw_input()
L = len(S)
d = [S.count(i) for i in set(list(S))]
dd = sum([i%2 for i in d])
if (L%2 == 0 and dd != 0 ) or (L%2 == 1 and dd != 1): 
		print 0
else:
	ans = f(L/2)
	for i in d:
		ans /= f(i/2)
	print ans

Measured memory_bytes: 4348
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        short[] l = Console.ReadLine().Split(' ').Select(x => short.Parse(x)).ToArray();
        Console.WriteLine(l[0] * l[1] + " " + (l[0] * 2 + l[1] * 2));
    }
}

Measured memory_bytes: 9512
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }


int main() {
    int N;
    int ans=0;
    cin>>N;
    ans=N*N;
    

    Out(ans);
    return 0;
}

Measured memory_bytes: 256
import math
N, M = map(int, input().split())


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])

    if arr == [] and n != 1:
        arr.append([n, 1])

    return arr


mod = 10**9 + 7


def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル
for i in range(2, N*2 + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


primes = factorization(M)
# 何箇所に分けるか（cnt以下）,その中でどう分けるか（しきりをどこにおくか（振り分けられないものが出ると選べれないのとおなじになるので、cnt - 選んだ数））
if N == 1:
    print(1)
    exit(0)
ans = 1

for p, cnt in primes:
    tmp = cmb(N+cnt-1, N-1, mod)
    ans *= tmp
    ans %= mod

print(ans)


Measured memory_bytes: 32864