akhauriyash/Code-Regression huggingface dataset:
/**
 *  author: ivanzuki   
 *  created: Sun Sep 13 2020
**/
#include <bits/stdc++.h>

using namespace std;

class DSU {
 public:
  int n;
  vector<int> parent;

  DSU(int _n) : n(_n) {
    parent.resize(n);
    for (int i = 0; i < n; i++) {
      parent[i] = i;
    }
  }

  int find(int x) {
    if (x == parent[x]) {
      return x;
    }
    return parent[x] = find(parent[x]);
  }

  bool merge(int x, int y) {
    x = find(x), y = find(y);
    if (x == y) {
      return false;
    }
    parent[x] = y;
    return true;
  }

};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> x(n), y(n), order(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    order[i] = i;
  }
  sort(order.begin(), order.end(), [&](int i, int j) {
    return x[i] < x[j];
  });
  int j = -1;
  vector<pair<int, pair<int, int>>> edges; 
  for (int i : order) {
    if (j > -1) {
      if (x[i] - x[j] <= abs(y[i] - y[j])) {
        edges.push_back(make_pair(x[i] - x[j], make_pair(i, j)));
      }
    }
    j = i;
  }
  sort(order.begin(), order.end(), [&](int i, int j) {
    return y[i] < y[j];
  });
  j = -1;
  for (int i : order) {
    if (j > -1) {
      if (y[i] - y[j] <= abs(x[i] - x[j])) {
        edges.push_back(make_pair(y[i] - y[j], make_pair(i, j)));
      }
    }
    j = i;
  }
  sort(edges.begin(), edges.end());
  long long ans = 0;
  DSU dsu(n);
  for (auto& e : edges) {
    int w = e.first, i = e.second.first, j = e.second.second;
    if (dsu.merge(i, j)) {
      ans += w;
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 7508
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    string s;
    cin >> s;
    int ans = 0;
    rep(i,s.size()-1) {
        if (s[i] != s[i+1]){
            ans++;
        }
    }
    cout << ans << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>>N;
    vll a(N);
    rep(i,N) cin>>a[i];
    ll ans=1000;
    rep(i,N-1){
        if (a[i]<=a[i+1]){
            ll t = ans/a[i];
            ans %= a[i];
            ans += a[i+1]*t;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3652
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {x1: i32, y1: i32, x2: i32, y2: i32};

    let xd = x2 - x1;
    let yd = y2 - y1;

    let x3 = x2 - yd;
    let y3 = y2 + xd;

    let x4 = x1 - yd;
    let y4 = y1 + xd;

    println!("{} {} {} {}", x3, y3, x4, y4)
}


Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF (ll)(1e9+7)
#define N 40

int n, ma, mb;

int dp[N+1][(N*10)+1][(N*10)+1];
int A[N+1], B[N+1], C[N+1];

int opt(int i, int ca, int cb)
{
	int ra = ca/(__gcd(ca,cb) == 0?1:__gcd(ca,cb));
	int rb = cb/(__gcd(ca,cb) == 0?1:__gcd(ca,cb));
	if(ra == ma && rb == mb)
	{
		return 0;
	}
	if(i >= n) 
	{
		return INF;
	}
	if(dp[i][ca][cb]==-1)
	{
		dp[i][ca][cb] = min(opt(i+1,ca,cb),opt(i+1,ca+A[i],cb+B[i])+C[i]);
	}
	return dp[i][ca][cb];
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	memset(&dp,-1,sizeof(dp));
	cin >> n >> ma >> mb;
	for(int i = 0; i < n; i ++)
	{
		cin >> A[i] >> B[i] >> C[i];
	}
	int minn = INF;
	for(int i = 0; i < n; i ++)
	{
		minn = min(opt(i,0,0),minn);
	}
	if(minn == INF)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << minn << endl;
	}
	return 0;
}

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

using namespace std;
int main(void){
    long long h;
    cin >> h;
    
    long long ans = 0;
    int count = 0;
     
    while(h > 1){
        count++;
        ans += pow(2, count-1);
        h /= 2;
    }
    ans += pow(2, count);
    cout << ans << endl;
}


Measured memory_bytes: 384
use std::io;
use std::collections::HashSet;

fn main() {

    let n: i32 = get_num();
    let mut a: Vec<i32> = read_line();
    let len = a.len();
    let uniq: HashSet<i32> = a.into_iter().collect();

    if len == uniq.len() {
        println!("YES");
    } else {
        println!("NO");
    }
}

fn read_line() -> Vec<i32> {

    let input_str = get_input();
    let vec: Vec<&str> = input_str.trim().split_whitespace().collect();

    let mut int_vec: Vec<i32> = Vec::new();
    for v in vec {
        int_vec.push(to_i(v));
    }

    int_vec
}

fn get_num() -> i32 {
    to_i(&get_input())
}

fn to_i(s: &str) -> i32 {
    let input_num: i32 = match s.trim().parse() {
        Ok(num) => num ,
        Err(_)  => panic!("input wrong number."),
    };
    input_num
}

fn get_input() -> String {
    let mut input_str = String::new();
    io::stdin().read_line(&mut input_str)
        .expect("Failed to read line")
        ;
    input_str
}


Measured memory_bytes: 13040
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
using namespace std;

int main() {
	const long long int mod = 1000000007;
	map<long long int, long long int>mp;
	long long int  s[200][200];
	//cout << fixed << setprecision(10);
	long long int n, m, res = 0, cou = 0, mi = 999999999, ma = -9999999999;
	long long int max_id, min_id;
	cin >>n>>m ;
	if (n<m) {
		cout << 0;
	}
	else {
		cout << 10;
	}
}


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

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	string s;
  	cin >> s;
 	if(s[0] == '9' || s[1] == '9') {
		puts("Yes");
      	return;
    }
	puts("No");
	return;
}

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


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

int main(){
    int n;
    long long l[100] = {};
    cin >> n;

    l[0] = 2;
    l[1] = 1;
    for(int i = 2;i <= n;i++){
        l[i] = l[i-1]+l[i-2];
    }

    cout << l[n] << endl;
    return 0;
}


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

int a[200010],vis[200010];
int main()
{
    int maxx=-10000000;
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        memset(vis,0,sizeof(vis));
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
            vis[a[i]]++;
            vis[a[i]-1]++;
            vis[a[i]+1]++;
            if(a[i]>maxx) maxx=a[i];
        }
        int minn=-100000000;
        for(int i=0;i<=maxx+1;i++)
        {
            if(vis[i]>minn) minn=vis[i];
        }
        printf("%d\n",minn);
    }
}


Measured memory_bytes: 1408
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double EPS = 1e-10;


int main(void) {
  int N;
  cin >> N;

  ll ans = 0;
  for (int A = 1; A < N; ++A) {
    for (int B = 1; A * B < N; ++ B) {
      ++ans;
    }
  }

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3592
m, d = map(int, input().split())

count = 0

for i in range(1, m+1):
    for j in range(20, d+1):
        d1 = int(str(j)[1])
        d10 = int(str(j)[0])

        if d1 >= 2 and d1 * d10 == i:
            count += 1

print(count)


Measured memory_bytes: 2940
K = int(input())
S = lambda n: sum(map(int,str(n)))
R = lambda n: n/S(n)

arr = []
for i in range(1,10000):
    for j in range(1,15):
        arr.append(int(str(i) + '9'*j))

arr.sort(reverse=True)
min_r = arr[0]
snukes = []
for a in arr:
    r = R(a)
    if r < min_r:
        min_r = r
        snukes.append(a)

for i in range(min(9,K)):
    print(i+1)
if K <= 9:
    exit()
K -= 9

print(*snukes[:-K-1:-1],sep='\n')

Measured memory_bytes: 9128
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	long long x,y,ans=0;
	scanf("%lld%lld",&x,&y);
	for(long long i=x;i<=y;i*=2)
	{
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
using namespace std;

typedef long long ll;

int c[100003];

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; ++i) {
		int a; cin >> a;
		++c[a];
	}
	for (int i = 1; i <= n; ++i) {
		--c[abs(n - 2*i + 1)];
	}
	for (int i = 0; i < n; ++i) {
		if (c[i] != 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	ll ans = 1, mod = 1e9 + 7;
	for (int i = 0; i < n / 2; ++i) {
		ans <<= 1LL;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
import java.io.*;
public class Main{
    static PrintWriter out;
    static Scanner sc;
    public static void main(String[] args){
        sc=new Scanner(System.in);
        out=new PrintWriter(System.out);

        int t=1;
      //  t=sc.nextInt();
        while(t-->0){
            forEachTestcase();
        }

        out.close();
    }

    static void forEachTestcase(){
        int n=sc.nextInt();
        int k=sc.nextInt();
        int a[]=new int[n];
        int min=Integer.MAX_VALUE,max=Integer.MIN_VALUE;
        for(int i=0;i<n;i++){
            a[i]=sc.nextInt();
            min=Math.min(min,a[i]);
            max=Math.max(max,a[i]);
        }
        int dp[]=new int[n];
        tree=new int[(max+2)*4];
        for(int i=n-1;i>=0;i--){
            dp[i]=1+query(0,0,max+1,Math.max(a[i]-k,min),Math.min(a[i]+k,max));
            update(0,0,max+1,a[i],dp[i]);
        }
        int ans=0;
        for(int i=0;i<n;i++){
            ans=Math.max(ans,dp[i]);
        }
        out.println(ans);
    }

    static int tree[];
    static int query(int cur,int l,int r,int start,int end){
        if(l>end || r<start)return 0;
        if(l>=start && r<=end)return tree[cur];
        int mid=(l+r)>>1;
        return Math.max(query(2*cur+1,l,mid,start,end),query(2*cur+2,mid+1,r,start,end));
    }
    static void update(int cur,int l,int r,int ind,int val){
        if(l==r){
            tree[cur]=val;
            return;
        }
        int mid=(l+r)>>1;
        if(mid>=ind)update(2*cur+1,l,mid,ind,val);
        else update(2*cur+2,mid+1,r,ind,val);
        tree[cur]=Math.max(tree[2*cur+1],tree[2*cur+2]);
    }




    static class modOpeation{
        static long mod;
        modOpeation(long mod){
            this.mod=mod;
        }
        static long mul(long a,long b){
            a%=mod;
            b%=mod;
            return (a*b)%mod;
        }
        static long add(long a,long b){
            a%=mod;
            b%=mod;
            return (a+b)%mod;
        }
        static long sub(long a,long b){
            a%=mod;
            b%=mod;
            return ((a-b)%mod+mod)%mod;
        }
        static long modPow(long a,long b){
            long ans=1;
            while(b>0){
                if(b%2==1)ans=mul(ans,a);
                a=mul(a,a);
                b>>=1;
            }
            return ans;
        }
        static long modInv(long a){
            return modPow(a,mod-2);
        }
        static long ifact[],fact[];
        static long nCr(int n,int r){
            if(r>n)return 0;
            return mul(fact[n],mul(ifact[r],ifact[n-r]));
        }
        static void initFactorial(int max){
            fact=new long[max];
            ifact=new long[max];
            fact[0]=ifact[0]=1;
            for (int i = 1; i <max ; i++) {
                fact[i]=mul(fact[i-1],i);
                ifact[i]=mul(ifact[i-1],modInv(i));
            }
        }
    }

}

Measured memory_bytes: 61068
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define mst(a, b)	memset(a, b, sizeof a)
#define pb push_back
#define mk make_pair
#define pill pair<int, int>
#define fi first
#define se second
const int qq = 1e5 + 10;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 10;
int a[qq], b[qq], c[qq];
LL num[qq];

int main() {
	int n;	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
	}
	for(int i = 1; i <= n; ++i) {
		scanf("%d", b + i);
	}
	for(int i = 1; i <= n; ++i) {
		scanf("%d", c + i);
	}
	sort(a + 1, a + 1 + n);
	sort(b + 1, b + 1 + n);
	sort(c + 1, c + 1 + n);
	for(int i = 1; i <= n; ++i) {
		int k = upper_bound(c + 1, c + 1 + n, b[i]) - c;
		num[i] = n - k + 1;
	}
	for(int i = n; i >= 1; --i) {
		num[i] += num[i + 1];
	}
	LL sum = 0;
	for(int i = 1; i <= n; ++i) {
		sum += num[upper_bound(b + 1, b + 1 + n, a[i]) - b]; 
	}
	printf("%lld\n", sum);
	return 0;
}
 

Measured memory_bytes: 2176
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextFloat64() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()

	a1 := make([]int, n)
	a2 := make([]int, n)

	a1sum := make([]int, n)
	a2sum := make([]int, n)

	for i := 0; i < n; i++ {
		a1[i] = nextInt()
		a1sum[i] = a1[i]
		if i > 0 {
			a1sum[i] += a1sum[i-1]
		}
	}
	for i := 0; i < n; i++ {
		a2[len(a2)-i-1] = nextInt()
	}
	for k, v := range a2 {
		a2sum[k] = v
		if k > 0 {
			a2sum[k] += a2sum[k-1]
		}
	}

	ans := 0
	for i := 0; i < n; i++ {
		sum := a1sum[i] + a2sum[len(a2sum)-i-1]
		if ans < sum {
			ans = sum
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1780
import java.util.Scanner;
public class Main{
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		int nagasa = a.length();
		boolean result = true;
		//while(true) {
			for(int i = 0; i < nagasa; i++) {
				int count = 0;
				char ans = a.charAt(i);
				for(int j = 0; j < nagasa; j++) {
					if(ans == a.charAt(j)) {
						count += 1;
						}
					}
				if(count % 2 == 1) {
					result = false;
				}
			}
		if(result == true) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

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

int main(){
  map< char , int > count;
  string str;
  while( cin>>str ){
    for(int i=0;i<(int)str.size();i++){
      if( isupper(str[i]) ){
        str[i]=tolower(str[i]);
      }
    }
    for(int i=0;i<(int)str.size();i++){
      count[ str[i] ]++;
    }
  }
  for(char ch='a';ch<='z';ch++){
    cout<<ch<<" : "<<count[ch]<<endl;
  }
  return 0;
}



Measured memory_bytes: 3168
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int main()
{
	int A,B,C;
	cin>>A>>B>>C;
	cout<<B+min(C,A+B+1)<<"\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)    scanf("%d",&x)
#define sl(x)    scanf("%lld",&x)
#define ss(s)    scanf("%s",s)
#define pi(x)    printf("%d\n",x)
#define pl(x)    printf("%lld\n",x)
#define ps(s)    printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>    pii;
typedef pair<ll, ll>      pl;
typedef vector<int>       vi;
typedef vector<ll>        vl;
typedef vector<pii>       vpii;
typedef vector<pl>        vpl;
typedef vector<vi>        vvi;
typedef vector<vl>        vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
#define MAXN   20000001 
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}

int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;



void solve(){
    ll n,q,i;
    cin>>n;
    ll a[n],sum=0;
    map<ll,ll> m;
    fo(i,n)
    {
        cin>>a[i];
        sum+=a[i];
        m[a[i]]++;
    }
    cin>>q;
    while(q--)
    {
        ll x,y;
        cin>>x>>y;
        sum=sum-m[x]*x+m[x]*y;
        cout<<sum<<endl;
        m[y]+=m[x];
        m[x]=0;
    }
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t = 1;
   // cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}

vl g[N];


int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
    int i, u, v;
    while(m--){
        cin>>u>>v;
    u--, v--;
        g[u].pb(v);
        g[v].pb(u);
    }
}

void dfs(int u, int par){
    for(int v:g[u]){
        if (v == par) continue;
        dfs(v, u);
    }
}


Measured memory_bytes: 17424
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define fast ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define F(i,a,b) for(int i= (int)(a); i<(int)(b);i++)
#define FI(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define what_is(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pii pair<int,int>
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007
const int N = 1e6+7 ;
string s ;

int main(){fast ;
	int n,k ;
	cin >> n ;
	vector<int> a(n) ;
	int mx = -101 , cnt = 0 ;
	for(auto& i : a){
		cin >> i ;
		if(i >= mx){
			mx = i ;
			cnt++ ;
		}
	}
	cout << cnt << endl ;
}




Measured memory_bytes: 256
lines = $stdin.read
array = lines.split("\n")
INF = 10**9
H,W = array[0].split(" ").map(&:to_i)
@d = Array.new(50).map{Array.new(50, INF)}
DX = [1,0,-1,0]
DY = [0,1,0,-1]

@maze = Array.new(H).map{Array.new(W, "")}
array[1..H].each_with_index do |line,i|
  @maze[i] = line.split("")
end

black = @maze.map{|line| line.count{|e| e=="#"}}.inject(&:+)

def bfs(sx,sy,gx,gy)
  @que = []
  @que.push([sx,sy])
  @d[sx][sy] = 1

  while not @que.empty?
    p = @que.shift()
    x = p[0]
    y = p[1]
    break if x==gx and y==gy

    for i in 0..3
      nx = x+DX[i]
      ny = y+DY[i]

      if 0<=nx and
        nx<H and
        0<=ny and
        ny<W and
        @maze[nx][ny] != '#' and
        @d[nx][ny] == INF

        # puts "#{nx},#{ny}"
        # @maze.each_with_index do |line,i|
        #   line.each_with_index do |e,j|
        #     if i==nx and j==ny
        #       printf("+")
        #     else
        #       printf(e)
        #     end
        #   end
        #   puts ""
        # end
        # puts "---"

        @que.push([nx,ny])
        @d[nx][ny] = @d[x][y]+1
      end
    end
  end
  @d[gx][gy]
end

dist = bfs(0,0,H-1,W-1)
ans = H*W - black - dist

if ans < 0
  puts "-1"
else
  puts ans
end


Measured memory_bytes: 2172
const BKRT = "\n";
const SPAC = " ";
const NOSP = "";

function Main(input){
	input = [].concat(...input.split(BKRT).map(a=>a.split(SPAC)));
  const strShift = ()=>input.shift();
  const intShift = ()=>~~input.shift();
  
  var a = intShift();
  var b = intShift();
  var c = intShift();
  var d = intShift();
  
  if(Math.abs(a-c) <= d)return "Yes";
  if(Math.abs(a-b) <= d && Math.abs(b-c) <= d)return "Yes";
  return "No"
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
4 7 9 3
`);

Measured memory_bytes: 19144
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define F(i, j, k) for(ll i = j; i <= k; ++i)
#define pp pair<ll, ll>
#define mp make_pair
const ll maxn = 2e5+5;
ll n, m, x;
ll read() {
    char ch = getchar();
    ll x = 0,f = 1;
    while(!isdigit(ch)) {
	if(ch == '-') f = -1;
	ch = getchar();
    }
    while(isdigit(ch)) {
	x = x * 10 + ch - '0';
	ch = getchar();
    }
    return x * f;
}
set<ll> s;
int main() {
#ifdef orz
    //freopen("input", "r", stdin);
#endif
    n = read();
    while(n--) {
	x = read();
	if(s.count(x)) s.erase(x);
	else s.insert(x);
    }
    printf("%lld\n", s.size());
    return 0;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

ll n;

map<int, int> cnt;
map<int, int> acc;

ll ans;

/////////////////////////////////////////////////////////////
map<ll, ll> prime_factorization(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; ++i) {
    while (n % i == 0) {
      res[i] += 1;
      n /= i;
    }
  }
  if (n != 1) res[n] = 1;
  return res;
}
/////////////////////////////////////////////////////////////

int main(void) {
  // Here your code !
  scanf("%lld", &n);

  map<ll, ll> whole;

  for (int i = 1; i <= n; ++i) {
    map<ll, ll> tmp = prime_factorization(i);

    for (auto itr = tmp.begin(); itr != tmp.end(); ++itr) {
      whole[itr->first] += itr->second;
    }
  }

  ll max_ind = 0;

  for (auto itr = whole.begin(); itr != whole.end(); ++itr) {
    cnt[itr->second] += 1;
    max_ind = max(max_ind, itr->second);
  }

  for (int i = max_ind; i >= 0; --i) {
    acc[i] = 0;
  }

  acc[max_ind] = cnt[max_ind];

  for (int i = max_ind - 1; i >= 0; --i) {
    acc[i] = acc[i + 1] + cnt[i];
  }

  ans += acc[74];

  ans += acc[24] * max(0, (acc[2] - 1));

  ans += acc[14] * max(0, (acc[4] - 1));

  ans += acc[4] * max(0, (acc[4] - 1)) * max(0, (acc[2] - 2)) / 2;

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	string S,S_;
	cin >> S_;
	if (S_.size() < 3) {
		cout << 0 << endl;
		return 0;
	}

	for (int i = 0; i < S_.size() - 1; i++) {
		if (S_[i] == 'B' && S_[i + 1] == 'C') {
			S.push_back('D');
			i++;
		}
		else {
			S.push_back(S_[i]);
		}
	}

	vector<string> s;
	string tmp = "";
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'A' || S[i] == 'D')tmp += S[i];
		else {
			if (tmp == "")continue;
			s.push_back(tmp);
			tmp = "";
		}
	}
	if (tmp != "")s.push_back(tmp);

	ll ans = 0;
	for (int i = 0; i < s.size(); i++) {
		int cnt = 0;
		for (int j = 0; j < s[i].size(); j++) {
			if (s[i][j] == 'A')cnt++;
			else ans += cnt;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3328
#include <stdio.h>
#define rep(i, n) for(int i = 0; i < n; ++i)

int main(void) {
  int n, i, j;
  scanf("%d", &n);
  char r[n][n];
  rep(i, n) rep(j, n) r[i][j] = 0;
  rep(i, n) {
    int u, k;
    scanf("%d%d", &u, &k);
    u--;
    rep(j, k) {
      int v;
      scanf("%d", &v);
      v--;
      r[u][v] = 1;
    }
  }
  rep(i, n) {
    rep(j, n - 1) printf("%d ", r[i][j]);
    printf("%d\n", r[i][n - 1]);
  }
  return 0;
}


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

int main(){
  string S;
  cin >> S;
  int l = S.length();
  string c = "w!kstnhmyr";
  for(int i = 0; i < l; ++i){
    int n = S[i] - '0';
    if(n == 0 && S[i+1] == 'U'){
      cout << "nn";
      ++i;
      continue;
    }
    if(n != 1)
      cout << c[n];
    if(S[i+1] == 'T') cout << 'a';
    if(S[i+1] == 'L') cout << 'i';
    if(S[i+1] == 'U') cout << 'u';
    if(S[i+1] == 'R') cout << 'e';
    if(S[i+1] == 'D') cout << 'o';
    ++i;
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 3216
#include<iostream>
#include<iomanip>
using namespace std;
const double pi=3.141592653589;
int main()
{
double r;
cin>>r;
cout<<fixed<<setprecision(6)<<r*r*pi<<" "<<fixed<<setprecision(6)<<2.000000*r*pi<<endl;
return 0;
}

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

using namespace std;
typedef long long Int;
#define MOD 1000000007
Int res = 1;
Int n, x;
int main(){
  cin >> n;
  int last = -1;
  int gap= 0;
  for(int i = 0;i < n;i++){
    cin >> x;
    res = res * ( i + 1 - gap) % MOD;
    if(last + 2 > x) gap++;
    else last += 2;
  }
  cout << res << endl;
  return 0;
}
  


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  string s;
  cin >> s;
  int N = s.size();
  string t = "";
  for (int i = 0; i < N;) {
    if (i + 1 < N && s[i] == 'B' && s[i + 1] == 'C') {
      t += "D";
      i += 2;
    } else {
      t += s[i];
      i++;
    }
  }
  ll ans = 0;
  int a_cnt = 0;
  for (int i = 0; i < t.size(); ++i) {
    if (t[i] == 'A')
      a_cnt++;
    else if (t[i] == 'D')
      ans += a_cnt;
    else
      a_cnt = 0;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 776
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
#include <stack>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

int main()
{
	int n;
	cin >> n;
	rep(i,0,n) {
		string s;
		cin >> s;
		set<string> ans;
		rep(i,0,s.size()) {
			string a, ar, b, br, c, d, e, f;
			a = s.substr(0,i);
			ar = a;
			reverse(all(ar));
			b = s.substr(i);
			br = b;
			reverse(all(br));

			ans.insert(a + b);
			ans.insert(a + br);
			ans.insert(ar + b);
			ans.insert(ar + br);
			ans.insert(b + a);
			ans.insert(br + a);
			ans.insert(b + ar);
			ans.insert(br + ar);
		}
		cout << ans.size() << endl;
	}

	return 0;
}

Measured memory_bytes: 1296
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
//#include "job.h"
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e5+50;
const int mod=1e9+7;
using namespace std;
int n,m,i,j,rs,x,vz[130],nx[nmax][30];
string s,t;
char c[nmax],r[nmax];
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>s>>t;
	n=s.size(),m=t.size();
	for(i=1;i<=n;i++)
	{
		c[i]=s[i-1];
		vz[c[i]]=1;
	}
	for(i=1;i<=m;i++)
	{
		r[i]=t[i-1];
		if(!vz[r[i]])rc(-1);
	}
	for(i=0;i<26;i++)nx[n][i]=n+1;
	for(i=n-1;i>=0;i--)
	{
		for(j=0;j<26;j++)nx[i][j]=nx[i+1][j];
		nx[i][c[i+1]-'a']=i+1;
	}
	j=0;
	for(i=1;i<=m;i++)
	{
		x=r[i]-'a';
		//cout<<j<<" "<<r[i]<<endl;
		if(nx[j][x]==n+1)
		{
			rs++;
			j=0;
			i--;
		}
		else j=nx[j][x];
	}
	cout<<1LL*rs*n+1LL*j<<endl;
    return 0;
}

Measured memory_bytes: 12496
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (200001)
#define MOD (1000000007)

ll l[MAXN];
int main(void)
{
    ll n,x;
    scanf("%ld %ld",&n,&x);
    for(int i=0;i<n;i++) scanf("%ld",&(l[i]));

    ll z = 0;
    ll ans = 1;
    for(int i=0;i<n;i++)
    {
        z+=l[i];
        if(z<=x) ans++;
    }

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


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

struct Block {
    int w, s, v;
};

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n; cin >> n;
    Block block[n];
    int maxS = 0;
    FOR(i,0,n-1){
        int w, s, v; cin >> w >> s >> v;
        block[i] = {w, s, v};
        maxS = max(maxS, s);
    }

    sort(block, block+n, [](Block a, Block b) {
            // a.s - b.w < b.s - a.w
            return a.s + a.w < b.s + b.w;
            });

    ll dp[2*maxS+1];
    memset(dp, 0, sizeof dp);
    for (Block b : block) {
        RFOR(x, min(2*maxS-b.w, b.s), 0) {
            dp[x + b.w] = max(dp[x+b.w], dp[x] + b.v);
        }
    }
    cout << *max_element(dp, dp+2*maxS+1) << '\n';
}



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

int digit_sum(int n)
{
  if(n<10)
    return n;
  return digit_sum(n/10) + n%10;
}

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

  int fx = digit_sum(N);
  if(N % fx == 0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,K;
  cin>>N>>K;
  vector<int>x(N);
  for(int i=0;i<N;i++)
    cin>>x.at(i);
  vector<int> d(N);
  for(int i=0;i<N;i++){
  if(x[i]<=abs(x[i]-K))
     d.at(i)=2*x[i];
     else
     d.at(i)=2*abs(x[i]-K);
  }int ans=0;
  for(int i=0;i<N;i++)
    ans+=d.at(i);
  cout<<ans<<endl;
  
  
  
  
  
  return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int k = sc.nextInt();
		int[][] s = new int[h][w];
		for (int i = 0; i < h; i++) {
			String row = sc.next();
			for (int j = 0; j < w; j++) {
				s[i][j] = Integer.parseInt(row.substring(j, j + 1));
			}
		}
		sc.close();

		int result = Integer.MAX_VALUE;
		Boolean[] hc = new Boolean[h - 1];
		for (int i = 0; i < Math.pow(2, h - 1); i++) {
			for (int j = 0; j < h - 1; j++) {
				hc[j] = ((i % (int)Math.pow(2, j + 1)) / ((int)Math.pow(2, j))) != 0;
			}
			int hcount = (int) Arrays.stream(hc).filter(value -> value).count();
			int count = count(k, s, hc);
			if (count >= 0) {
				result = Math.min(result, count + hcount);
			}
		}
		System.out.print(result);
	}

	private static int count(int k, int[][] s, Boolean[] hc) {
		int count = 0;
		int[] counts = new int[s.length];
		int wstart = -1;
		for (int w = 0; w < s[0].length; w++) {
			int[] tcounts = new int[s.length];
			int index = 0;
			for (int h = 0; h < s.length; h++) {
				if (s[h][w] == 1) {
					counts[index]++;
					tcounts[index]++;
				}
				if (h < s.length - 1 && hc[h]) {
					index++;
				}
			}
			if (Arrays.stream(counts).anyMatch(c -> c > k)) {
				if (w - wstart <= 1) {
					return -1;
				}
				count++;
				wstart = w - 1;
				counts = tcounts;
			}
		}

		return count;
	}
}

Measured memory_bytes: 60928
#include <iostream>

using namespace std;


void ExceptionHandling()//problems134
{
  int n;
  cin >> n;
  int a;
  int max=0;
  int max_id=0;
  int max2=0;
  for (int i = 0; i < n; i++)
  {
    cin >> a;
    if (max < a)
    {
      max = a;
      max_id = i;
    }
    else 
    {
      if (max2 < a) {
        max2 = a;
      }
    }
  }
  
  for (int i = 0; i < n; i++)
  {
    if (i != max_id) cout << max << endl;
    else cout << max2 << endl;
  }
  return;
}

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

Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N;
	vector<int> a;
	
	cin>>N;
	
	a.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>a[i];
	}
	
	sort(a.begin(), a.end());
	
	cout<<a.back() - a.front()<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    FastScanner in;
    PrintWriter out;

    public static void main(String[] args) {
        new Main().run();
    }

    void solve() {
        String input = in.nextToken();
        if (input.contains("AC")) {
            out.println("Yes");
        } else {
            out.println("No");
        }
    }

    void run() {
        in = new FastScanner();
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    public class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() {
            return Long.parseLong(nextToken());
        }

        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }

}

Measured memory_bytes: 21076
#include <cstdio>

int main()
{
    int A, B;
    scanf("%d %d", &A, &B);

    if (A%3 == 0 || B%3 == 0 || (A+B)%3 == 0)
        printf("Possible");
    else
        printf("Impossible");

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

struct TreeNode;
typedef struct TreeNode * Tree;
typedef struct TreeNode * Position;
typedef int ElementType;

struct TreeNode
{
    ElementType ele;
    Tree left;
    Tree right;
};

void priTreeNode(Tree);
Tree insert(Tree, ElementType);
void inorder(Tree, void (*)(Tree));
void preorder(Tree, void (*)(Tree));

int main(void)
{
    int m, k;
    char op[7];

    Tree T;

    scanf("%d", &m);
    while (m--) {
        scanf("%s", op);
        if (op[0] == 'i') {
            scanf("%d", &k);
            T = insert(T, k);
        } else if (op[0] == 'p') {
            inorder(T, priTreeNode);
            putchar('\n');
            preorder(T, priTreeNode);
            putchar('\n');
        }
    }

    return 0;
}

void priTreeNode(Tree T)
{
    printf(" %d", T->ele);
}

Tree insert(Tree T, ElementType x)
{
    if (T == NULL) {
        T = (Tree) malloc(sizeof(struct TreeNode));
        T->ele = x;
        T->left = T->right = NULL;
    } else if (T->ele < x) {
        T->right = insert(T->right, x);
    } else if (T->ele > x) {
        T->left = insert(T->left, x);
    }
    return T;
}

void inorder(Tree T, void (* print)(Tree))
{
    if (T == NULL)
        return;
    inorder(T->left, print);
    print(T);
    inorder(T->right, print);
}

void preorder(Tree T, void (* print)(Tree))
{
    if (T == NULL)
        return;
    print(T);
    preorder(T->left, print);
    preorder(T->right, print);
}


Measured memory_bytes: 17492
from collections import deque

N, M = [int(s) for s in input().split()]
edge = [[int(s) - 1 for s in input().split()] for _ in range(M)]
graph = [[] for _ in range(N)]
for i, j in edge:
    graph[i].append(j)
    graph[j].append(i)

dq = deque([0])
parent = [0] * N
parent[0] = 1
while(dq):
    search_obj = dq.pop()
    for candidate_obj in graph[search_obj]:
        if not parent[candidate_obj]:
            dq.appendleft(candidate_obj)
            parent[candidate_obj] = search_obj + 1

total_visited = sum(map(lambda x: x != 0, parent))
if total_visited < N:
    print('No')
else:
    print('Yes')
    for i in range(1, N):
        print(parent[i])

Measured memory_bytes: 57440
////////////////////////////////////////////////
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
ll gcd(ll a, ll b) {  // O( log(a) )
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * (b / my::gcd(a, b)); }  // O( log(a) )
bool isPrime(ll n) {                                    // O( sqrt(n) )
  bool flag = true;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      flag = false;
      break;
    }
  }
  return flag;
}
vector<pair<ll, ll>> primeFac(ll n) {  // O( sqrt(n) )
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll exp = 0;
    while (n % i == 0) {
      n /= i;
      exp++;
    }
    ret.push_back(make_pair(i, exp));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}
template <typename T>
void input_vec(vector<T> &a, ll n) {
  for (ll i = 0; i < n; i++) {
    T tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
}
template <typename T>
void input_set(set<T> &a, ll n) {
  for (ll i = 0; i < n; i++) {
    T tmp;
    cin >> tmp;
    a.insert(tmp);
  }
}
}  // namespace my
////////////////////////////////////////////////

int main() {
  int n;
  cin >> n;
  vector<ll> a;
  my::input_vec(a, n);

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      continue;
    }
    if (a.at(i - 1) > a.at(i)) {
      ans += a.at(i - 1) - a.at(i);
      a.at(i) = a.at(i - 1);
    }
  }

  cout << ans << endl;
}

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

int main(){
  int D;
  int N;
  cin >> D >> N;
  if(N!=100){
    if(D==0){
      cout << N << endl;
    }else if(D==1){
      cout << N*100 << endl;
    }else{
      cout << N*10000 << endl;
    }
  }else{
    if(D==0){
      cout << 101 << endl;
    }else if(D==1){
      cout << 10100 << endl;
    }else{
      cout << 101*10000 << endl;
    }
  }
}
  

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

#define rep(i,x,y) for(int (i)=(x);(i)<(y);(i)++)

int main()
{
  int N,M,r,q;

  while(true){
    cin>>N>>M;
    if(N==0&&M==0){
      break;
    }
    vector<vector<int>> map(M,vector<int>(1260-540+1,0));

    cin>>r;

    rep(i,0,r){
      int t,n,m,s;
      cin>>t>>n>>m>>s;
      if(s==1){
        map[m-1][t-540]++;
      }else{
        map[m-1][t-540]--;
      }
    }

    rep(i,0,M){
      rep(j,0,1260-540){
        map[i][j+1]+=map[i][j];
      }
    }

    cin>>q;

    rep(i,0,q){
      int ts,te,num;
      cin>>ts>>te>>num;
      int count=0;
      rep(j,ts-540,te-540){
        if(map[num-1][j]>=1){
          count++;
        }
      }
      cout<<count<<endl;
    }
  }
  return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  int l = 0,r = 0;
  string s; cin>> s;
  for(int i = 0; i < n; ++i){
    if(s[i] == '(') r++;
    else r = max(0,--r);
  }
  for(int i = n-1; i >= 0; --i){
    if(s[i] == ')') l++;
    else l = max(0,--l);
  }
  for(int i = 0; i < l; ++i)cout << '(';
  cout << s;
  for(int i = 0; i < r; ++i)cout << ')';
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int A = in.Int();
            int B = in.Int();
            int C = in.Int();
            int K = in.Int();

            int cnt = 0;
            while (B <= A) {
                B *= 2;
                cnt++;
            }
            while (C <= B) {
                C *= 2;
                cnt++;
            }
            out.println(cnt <= K ? "Yes" : "No");

        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 32796
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

int main(){
	ll N,A,B;
	cin>>N>>A>>B;
	ll x[N];
	rep(i,N) cin>>x[i];
	ll ans=0;
	rep(i,N-1){
		ans+=min(A*(x[i+1]-x[i]),B);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]

tate = [False] * h
yoko = [False] * w

for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            tate[i] = True
            yoko[j] = True

for i in range(h):
    if tate[i]:
        for j in range(w):
            if yoko[j]:
                print(a[i][j], end='')
        print()

Measured memory_bytes: 4596