akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

int main()
{
	string s,t;

	cin>>s>>t;
	long long s_size = s.size();
	long long t_size = t.size();

	vector<vector<long long> > mt(26);
	for(int i=0; i<s_size; i++)
	{
		int index = s[i] - 'a';
		mt[index].push_back(i);
	}

	long long count = 0;
	long long s_index = -1;
	for(int i=0; i<t_size; i++)
	{
		int t_index = t[i] - 'a';
		//tにsに含まれない文字があった場合はその時点で終了
		if(mt[t_index].size() == 0)
		{
			cout<<-1<<endl;
			return 0;
		}
		auto it = upper_bound(mt[t_index].begin(),mt[t_index].end(), s_index);
		
		
		//cout<<endl;
		//cout<<t[i]<<":";
		if(it == mt[t_index].end() || *it <= s_index)
		{
			//cout<<"up:"<<s_size - s_index + mt[t_index][0]<<endl;
			count +=  s_size - s_index + mt[t_index][0];
			s_index = mt[t_index][0];
			
		}
		else
		{
			//cout<<"down:"<<*it - s_index<<endl;
			count += *it - s_index;
			s_index = *it;
			
		}
		

	}
	cout<<count<<endl;

}

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

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i = 0; i < N; i++){
		cin >> A.at(i);
	}
	sort(A.begin(),A.end());
	cout << A.at(N - 1) - A.at(0) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <climits>
#include <unordered_map>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#define int long long 
#define lli unsigned long long int
#define pb push_back
#define ins emplace
#define mod 1e9+7
#define fi(i,n) for(int i=1; i<=n;i++)
#define INF 10000000000
#define unm  unordered_map<int , int>
#define vvi  vector<vector<int>>
#define sortall(v) sort(v.begin(),v.end())
#define deb(x)     cout << #x << "=" << x << endl
#define deb2(x,y)  cout << #x << "=" << x << "," << #y << "=" << y << endl
#define mp make_pair
#define F  first
#define S second
#define itr(it,a) for(auto it = a.begin(); it!=a.end();it++)
#define vi  vector<int>
#define pii pair<int ,int>
#define vii vector<vi>
#define in1(x) int x; cin >> x
#define in2(x,y) int x,y; cin >> x >> y;
#define in3(x,y,z) int x,y,z; cin >> x >> y >> z

using namespace std;
const int mx = 1e5;
vector<int> adj[mx] ;


int32_t main(){
	in2(n,m);
	vi v(m);
	int t =0 ;
	fi(i,m){
		int x ;cin >> x;
   		v.pb(x);   
	}
	for(auto i : v) {
		t+=i;

	}
	if( n-t>=0) cout << n-t << endl;
	else cout <<  "-1" << endl;
}


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

int main()
{
  int N,Y;
  int A=-1,B=-1,C=-1;
  cin >> N >> Y;
  for(int i=0;i<=N;i++){
	 for(int j=0;j+i<=N;j++){
		int k = N - i - j;
       if(10000*i+5000*j+1000*k==Y){
			A = i,B=j,C=k;            
            }
        }
     }
  
  cout << A << " " << B << " " << C;
}


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

int main() {
  int h, w; cin >> h >> w;
  vector<string> grid(h);
  vector<bool> height(h);
  vector<bool> width(w);
  for (int i = 0; i < h; i++) {
    cin >> grid.at(i);
  }

  if (h <= 2 && w == 1 || h == 1 && w <= 2) {
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (j != w - 1) {
        if (grid.at(i).at(j) != '.') cout << grid.at(i).at(j);
        }
        else {
          if (grid.at(i).at(j) != '.') cout << grid.at(i).at(j) << endl;
          else cout << endl;
        }
      }
    }
  }
  else {
    for (int i = 0; i < h; i++) {
      int check = 0;
      for (int j = 0; j < w - 1; j++) {
        if (grid.at(i).at(j) == '.' && grid.at(i).at(j + 1) == '.') check++;
      }
      if (check == w - 1) height.at(i) = false;
      else height.at(i) = true;
    }

    for (int i = 0; i < w; i++) {
      int check = 0;
      for (int j = 0; j < h - 1; j++) {
        if (grid.at(j).at(i) == '.' && grid.at(j + 1).at(i) == '.') check++;
      }
      if (check == h - 1) width.at(i) = false;
      else width.at(i) = true;
    }

    for (int i = 0; i < h; i++) {
      if (height.at(i) == true) {
        for (int j = 0; j < w; j++) {
          if (width.at(j) == true) {
            if (j != w - 1) cout << grid.at(i).at(j);
            else cout << grid.at(i).at(j) << endl;
          }
          else {
            if (j == w - 1) cout << endl;
          }
        }
      }
    }
  }
}


Measured memory_bytes: 256
import numpy as np

n,m,x = map(int,input().split())
ca = list(list(map(int,input().split())) for _ in range(n))

ans = 10**7
for i in range(1,2**n):
  l = []
  for j in range(n):
    if (i >> j) & 1:
      l.append(ca[j])
  s = np.sum(l,axis=0).tolist()
  if all(s[k] >= x for k in range(1,m+1)) and s[0] < ans:
    ans = s[0]

if ans == 10**7:
  print(-1)
else:
  print(ans)

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

int main(){
    int n,k;
    cin >> k >> n;
    vector<int> array(n),d_array(n);
    for(int i=0;i<n;i++) cin >> array.at(i);

    for(int i=0;i<n;i++){
        if(i != 0){
            d_array.at(i) = array.at(i) - array.at(i-1);
        }else{
            d_array.at(0) = array.at(i) + k - array.at(n-1);
        }
    }

    int m = -1;
    for(int i=0;i<n;i++){
        if(m < d_array.at(i)) m = d_array.at(i);
    }
    
    cout << k - m << endl;
}

Measured memory_bytes: 4824
defmodule Main do
  def main do
    [x, y, z] =
      IO.read(:line)
      |> String.trim |> String.split
	x = String.to_integer(x)
    y = String.to_integer(y)
    z = String.to_integer(z)
    IO.puts(Enum.filter(1..49999, fn n -> y * n + z * (n + 1) <= x end) |> Enum.max)
  end
end


Measured memory_bytes: 33952
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#include <math.h>
#include <algorithm>
#include <vector>
#pragma warning(disable:4996)

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

long calc(long n, long k)
{
    long sum = 0;
    while(n>0) {
        sum += (n%k);
        n/=k;
    }
    return sum;
}

int main(int argc, char* argv[])
{
    long n, c;
    scanf("%ld %ld", &n, &c);

    long d[30][30]={0};
    long i, j, k;
    for(i=0; i<c; i++) {
        for(j=0; j<c; j++) {
            scanf("%ld", &(d[i][j]));
        }
    }

    long a[3][30]={0};
    for(i=0; i<n; i++) {
        for(j=0; j<n; j++) {
            long tmp;
            scanf("%ld", &tmp);
            a[(i+j)%3][tmp-1]++;
        }
    }

    long min=MOD;
    long m;
    for(i=0; i<c; i++) {
        for(j=0; j<c; j++) {
            if(i==j) continue;
            for(k=0; k<c; k++) {
                if(i==k||j==k)continue;
                long tmp=0;
                for(m=0; m<c; m++) {
                    tmp += a[0][m]*d[m][i]+a[1][m]*d[m][j]+a[2][m]*d[m][k];
                }
                if(min>tmp)
                    min=tmp;
            }
        }
    }

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


Measured memory_bytes: 128
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

typedef long long ll;

string s, t;
ll res = 0;

int main() {
	cin >> s >> t;
	
	ll n = s.size();
	for (ll i = 0; i < n; i++) {
		if (s[i] != t[i]) {
			res++;
		}
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 3888
antenna = [int(input()) for i in range(5)]
k = int(input())
ans = "Yay!"

if max(antenna)-min(antenna) > k:
    print(":(")
else:
    for i in range(len(antenna)):
        for j in range(len(antenna)):
            if abs(antenna[i]-antenna[j]) > k:
                ans = ":("
    print(ans)

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

int main(){
  int r0,w0,c,r;

  while (1){
    cin >> r0 >> w0 >> c >> r;
    if (r0==0&&w0==0&&c==0&&r==0)return 0;
    if (r0/w0>=c){
      cout << 0 << endl;
      continue;
    }
    if ((c*w0-r0)%r) cout << ((c*w0-r0)/r)+1 << endl;
    else cout << ((c*w0-r0)/r) << endl;
  }
}

Measured memory_bytes: 3048
n = gets.to_i
b = gets.split.map(&:to_i)
arr = []

while n > 0
  if (i = b.rindex.with_index { |e, idx| e == n - idx })
    b.delete_at(i)
    arr << i + 1
    n -= 1
  else
    puts -1
    exit
  end
end

puts arr.reverse

Measured memory_bytes: 14152
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int mod =1e9+7;
const int N = (int)2e5 + 5;

void solve(){
	int n,y;
	cin>>n>>y;
	for(int i=0;i<=y/10000;i++){
		for(int j=0;j<=y/5000;j++){
			int x=n-i-j;
			if(i*10000+j*5000+x*1000==y && x>=0){
				cout<<i<<" "<<j<<" "<<x;
				return;
			}
		}
	}


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

}

int main(){
	Red;
	int t=1;
	// cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 384
n,k = map(int,input().split())
li = list(map(int,input().split()))
t = list(input())
ans = []
for i in range(len(t)):
    if t[i] == 'r':
        if k <= i and t[i] == t[i-k]:
            t[i] = ''
            ans.append(0)
        else:
            ans.append(li[2])
    elif t[i] == 's':
        if k <= i and t[i] == t[i-k]:
            t[i] = ''
            ans.append(0)
        else:
            ans.append(li[0])
    else:
        if k <= i and t[i] == t[i-k]:
            t[i] = ''
            ans.append(0)
        else:
            ans.append(li[1])
print(sum(ans))

Measured memory_bytes: 10588
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

struct Tree {
    n: usize, 
    edges: Vec<Vec<(usize, i64)>>,
}

impl Tree {
    fn new(n: usize) -> Tree {
        Tree {
            n: n,
            edges: vec![vec![]; n],
        }
    }
    fn add_edge(&mut self, s: usize, t: usize, w: i64) {
        self.edges[s].push((t, w));
        self.edges[t].push((s, w));
    }
    fn dists(&self, i: usize) -> Vec<i64> {
        let mut ans = vec![0; self.n];
        self.dists_sub(i, self.n, &mut ans);
        ans
    }

    fn dists_sub(&self, i: usize, prev: usize, res: &mut Vec<i64>) {
        for &(v, w) in &self.edges[i] {
            if v == prev {
                continue;
            }
            res[v] = res[i] + w;
            self.dists_sub(v, i, res);
        }
    }
}



fn main() {
    input!{
        n: usize,
        array: [(usize1, usize1, i64); n-1],
    }
    let mut tree = Tree::new(n);
    for &(s, t, w) in &array {
        tree.add_edge(s, t, w);
    }
    let ds = tree.dists(0);
    let ans: Vec<i64> = ds.iter().map(|&x| x % 2).collect();

    for node in ans {
        println!("{}", node)
    }
}


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

using namespace std;

int d[4444][4444];
int main() {
	string s;
	cin >> s;
	int p = 998244353, r = 0, n = s.length(), c = 0;
	d[0][0] = 1;
	for (int i = 1; i <= n + n; i++) {
		if (i <= n) c += s[i - 1] - '0';
		for (int j = max({ 0,c - i,c + i - n - n }); j <= min(i, c); j++)
			((i < n + n ? d[i][j] : r) += d[i - 1][j] + (j ? d[i - 1][j - 1] : 0)) %= p;
	}
	cout << r << endl;
	return 0;
}


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

using namespace std;
#ifdef ONLINE_JUDGE
#define cerr if(false)cerr
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#define int long long
#define ld1 long double
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL),cout<<setprecision(14);
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back
#define mm0(X) memset((X), 0, sizeof((X)))
#define mm1(X) memset((X), -1, sizeof((X)))
#define INF (int)1e9
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define endl '\n'
#define vcc vector<char>
#define rep(i,a,b) for(int i=a;i<b;i++)

// if you have no idea just guess the appropriate well-known algo instead of doing nothing -- Benq inspiration
const int mod=998244353;
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int powmod(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return powmod(a,mod-2);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

const int N=(int)1e6;


void solve(){
    int x[5];
    for(int i=0;i<5;i++) {
        cin >> x[i];
        if(x[i]==0){
            cout<<i+1<<endl;
            return;
        }
    }

}

int32_t main() {
    faster;

#ifndef ONLINE_JUDGE
    READ("input.txt");
    WRITE("output.txt");
    double beg=clock();
#endif

    int t=1;
//    cin>>t;

    while(t--){
        solve();
    }

#ifndef ONLINE_JUDGE
    double endd=clock();
    cout<<endl;
    cerr<<"*** Total time = "<<(endd-beg)/CLOCKS_PER_SEC;
#endif
}


Measured memory_bytes: 3604
#include <math.h>
#include <stdio.h>

int
main()
{
	double x1, y1, x2, y2;
	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);

	double distance = sqrt(pow(x2-x1, 2.0) + pow(y2-y1, 2.0));
	printf("%f\n", distance);

	return 0;
}

Measured memory_bytes: 652
n = int(input())

sp = []

for i in range(n):
    tmp = list(map(str,input().split()))
    tmp.append(i+1)
    sp.append(tmp)

sp.sort(key=lambda x: (x[0],int(x[1])))

num = 0
while num < n:
    string = sp[num][0]
    l = []
    l.append(sp[num][2])
    while True:
        num += 1
        if num > n-1:
            break
        if sp[num][0] == string:
            l.append(sp[num][2])
        else:
            break

    for i in reversed(range(len(l))):
        print(l[i])


Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))

sum = 0
ans = 0
i = 0
j = 0
while True:
    if i < N and (sum | A[i] == sum + A[i]):
        sum += A[i]
        i += 1
        ans += i-j
    elif i < N:
        while sum | A[i] != sum+A[i]:
            sum -= A[j]
            j += 1
    else:
        break
print(ans)


Measured memory_bytes: 23560
#include<bits/stdc++.h>
using namespace std;
#define int long long

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

template <class T>
struct SegmentTree{
  using F = function<T(T,T)>;
  F f;
  T inf;
  int n;
  vector<T> node;

  SegmentTree(vector<T> v,T inf,F f):inf(inf),f(f){
    n = 1; while(n < v.size()) n *= 2;
    node.resize(2*n-1,inf);
    for(int i = 0; i < v.size(); i++) node[i+n-1] = v[i];
    for(int i = n-2; i >= 0; i--) node[i] = f(node[2*i+1],node[2*i+2]);
  }

  void update(int k,T val){
    k += n-1;
    node[k] = val;
    while(k > 0){
      k = (k-1) / 2;
      node[k] = f(node[2*k+1],node[2*k+2]);
    }
  }

  void add(int k,T val){
    k += n-1;
    node[k] += val;
    while(k > 0){
      k = (k-1) / 2;
      node[k] = f(node[2*k+1],node[2*k+2]);
    }
  }

  T getval(int a,int b){ return getval(a,b,0,0,n); }
  T getval(int a,int b,int k,int l,int r){
    //区間[a, b)の値を返す
    if(r <= a || b <= l) return inf;
    if(a <= l && r <= b) return node[k];
    T vl = getval(a, b, 2*k+1, l, (l+r)/2);
    T vr = getval(a, b, 2*k+2, (l+r)/2, r);
    return f(vl, vr);
  }
};

signed main(){

  int n,k; cin >> n >> k;
  vector<int> a(n),v(n,0);
  int sum = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    if(a[i] < 0) v[i] = a[i];
    sum += a[i];
  }

  SegmentTree<int> seg1(a,0,[&](int x,int y){
    return (x + y);
  });
  SegmentTree<int> seg2(v,0,[&](int x,int y){
    return (x + y);
  });

  int ans = 0;
  for(int i = 0; i+k-1 < n; i++){
    int res1 = sum - seg1.getval(i,i+k) - (seg2.getval(0,i) + seg2.getval(i+k,n));
    int res2 = sum - (seg2.getval(0,i) + seg2.getval(i+k,n));
    ans = max({ans,res1,res2});
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6668
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<string>

using namespace std;

#define ll long long

int main(){
    ll n, t;
    string s;
    cin >> s;
    cout << s[0] << (int)s.size() - 2 << s[s.size()-1] << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

#define SIZE 2000000

int main() {
  int A[SIZE];
  int H=0;
  int i, l, largest, tmp, n;
  char com[21], buf[20];
  buf[19]='\n';
  char *p,*c1,*c2;
  c1 = com+1;
  c2 = com+2;
  do {
    fgets(com, 20, stdin);
    if (*com == 'i') {
      n = 0;
      p = com+7;
      while (*p!='\n') {
        n = n*10+*p-'0';
        p++;
      }
      A[++H] = n;
      for (i=H; i>1 && A[i>>1]<A[i];i>>=1) {
        tmp = A[i>>1];
        A[i>>1] = A[i];
        A[i] = tmp;
      }

    } else if (*c1=='x') { // extract
      n = A[1];
      for (i=18; n>0; n/=10) buf[i--]=(n%10)+'0';
      fputs(buf+i+1, stdout);
      A[1] = A[H];
      i = 1;
      while (1) {
        l = i<<1;
        if (l < H && A[l] > A[i])        largest = l;
        else         largest = i;
        if (l+1 < H && A[l+1] > A[largest])  largest = l+1;
        if (largest == i) break;
        tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
        i = largest;
      }
      H--;
    }
  } while (*c2!='d');
  return 0;
}


Measured memory_bytes: 5452
#include<stdio.h>

void printit(int *a){
  int fst=0,scd=0,trd=0;
  int i;
  for(i=0;i<10;i++){
    if(fst<a[i]){
      trd=scd;
      scd=fst;
      fst=a[i];
    }
    else if(scd<a[i]){
      trd=scd;
      scd=a[i];
    }
    else if(trd<a[i]){
      trd=a[i];
    }
  }
  printf("%d",fst+scd+trd);
}

void doit(){
  int a[10];
  int f=0;
  while(f<2){
    int i;
    for(i=0;i<10;i++){
      scanf("%d",&a[i]);
    }
    printit(a);
    if(f==0){
      printf(" ");
    }
    else{
      printf("\n");
    }
    f++;
  }
}

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

Measured memory_bytes: 600
#include "bits/stdc++.h"
using namespace std;
int a[200005];
int main(){
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	vector<int> v;
	if(n & 1){
	for(int i = 1; i <= n; i+=2)v.push_back(i);
	reverse(v.begin(),v.end());
	for(int i = 2; i <= n; i+=2)v.push_back(i);
	}	else {
	for(int i = 2; i <= n; i+=2)v.push_back(i);
	reverse(v.begin(),v.end());
	for(int i = 1; i <= n; i+=2)v.push_back(i);
	}
	for(int i = 0; i < n; i++)cout << a[v[i]] << ' ';
	return 0;
}

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
using ld = long double;
using ulli = unsigned long long int;
#define filein freopen ("in.txt", "r", stdin)
#define fileout freopen ("out.txt", "w", stdout)
#define dbg(args...) do {cerr << #args << " : "; debug(args); } while(0)
#define all(v) ((v).begin()),((v).end())
#define size(x) (int) x.size() 
#define pb emplace_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
void debug () {cerr << endl;}
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template < typename T, typename ... hello>void debug( T arg, const hello &... rest) {cerr << arg << ' ';debug(rest...);}
int main(){
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    char c;
    cin >> c;
    if(c > 96){
		cout << 'a';
	}else{
		cout << 'A';
	}
}




Measured memory_bytes: 3648
import copy


def parse_stdin(input_lines: int):
    data_list = []
    for i in range(input_lines):
        data_list.append(input().rstrip().split())
    return data_list


def insertion_sort_with_print(values):
    print_now_state(values)
    for i, value in enumerate(values[1:]):
        i += 1
        j = i - 1
        while j >= 0 and values[j] > value:
            values[j + 1] = copy.copy(values[j])
            j -= 1
        values[j + 1] = copy.copy(value)
        print_now_state(values)


def print_now_state(values):
    for val_print in values[:-1]:
        print("{}".format(val_print), end=' ')
    print("{}".format(values[-1]), end='')
    print()


def main():
    input()
    input_lists = parse_stdin(1)
    values = list(map(int, input_lists[0]))
    insertion_sort_with_print(values)


if __name__ == '__main__':
    main()



Measured memory_bytes: 6664
#include <iostream>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a == 1) {
		a = 14;
	}
	if (b == 1) {
		b = 14;
	}
	if (a < b) {
		cout << "Bob" << endl;
	}
	else if (a > b) {
		cout << "Alice" << endl;
	}
	else {
		cout << "Draw" << endl;
	}
}



Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<math.h>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>
// 追加１
#include <fstream>



using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 2019;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()



int main()
{
    int A, B, C, K;
    cin >> A >> B >> C >> K;

    ll sum = 0;
    
    if (K > A)
    {
        sum += A;
        K -= A;
    }
    else
    {
        sum += K;
        K = 0;
    }

    if (K > B)
    {
        K -= B;
    }
    else
    {
        K = 0;
    }

    if (K > C)
    {
        sum -= C;
        K -= C;
    }
    else
    {
        sum -= K;
        K = 0;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int unsigned long long

using namespace std;

const int MAX_TAILLE = 51, MOD = 1e9+7;

int n, k;

int matrice[MAX_TAILLE][MAX_TAILLE] = {0};
int reponse[MAX_TAILLE][MAX_TAILLE] = {0};

void carre() {
    int nouvMatrice[MAX_TAILLE][MAX_TAILLE] = {0};

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            for(int k = 0; k < n; k++) {
                nouvMatrice[i][j] = (nouvMatrice[i][j] + matrice[i][k] * matrice[k][j]) % MOD;
            }
        }
    }

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            matrice[i][j] = nouvMatrice[i][j];
        }
    }
}

void multiplie() {
    int nouvMatrice[MAX_TAILLE][MAX_TAILLE] = {0};

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            for(int k = 0; k < n; k++) {
                nouvMatrice[i][j] = (nouvMatrice[i][j] + reponse[i][k] * matrice[k][j]) % MOD;
            }
        }
    }

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            reponse[i][j] = nouvMatrice[i][j];
        }
    }
}

int32_t main() {

    cin >> n >> k;

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n;j++) {
            cin >> matrice[i][j];
        }
    }

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

    for(int i = 0; i < 62; i++) {
        int nb = pow(2, i);
        if(k & nb) {
            multiplie();
        }
        carre();
    }

    int rep = 0;

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            rep += reponse[i][j];
            rep %= MOD;
        }
    }

    cout << rep;



    return 0;
}


Measured memory_bytes: 4148
#include<bits/stdc++.h>
using namespace std;
map<char,int>s;
char s1[200005],s2[200005];
int main()
{
	scanf("%s",s1);
	scanf("%s",s2);
	int t=strlen(s1);
	for(register int i=0;i<t;i++)
	    if(s[s1[i]]==0)s[s1[i]]=s2[i]-'a'+1;
	    else if(s[s1[i]]!=s2[i]-'a'+1) 
		{
			printf("No\n");
			exit(0);
		}
	s.clear();
	for(register int i=0;i<t;i++)
	    if(s[s2[i]]==0)s[s2[i]]=s1[i]-'a'+1;
	    else if(s[s2[i]]!=s1[i]-'a'+1) 
		{
			printf("No\n");
			exit(0);
		}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void){
    // Your code here!
    
    int n;
    scanf("%d",&n);
    
    int i,j;
    
    for(i=0; i<n; ++i){
        for(j=0; j<n; ++j){
            if( 4*i + 7*j == n ){
                printf("Yes");
                return 0;
            }
        }
    }
    
    printf("No");
    
    return 0;
}


Measured memory_bytes: 128
A, B, C = map(int, input().split())
f1 = f2 = f3 = 0

if A == B:
    f1 = 1
if B == C:
    f2 = 1
if C == A:
    f3 = 1

if f1+f2+f3 == 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;

class Point {
public:
	int id, x, y;
	Point(int id, int x, int y) :
			id(id), x(x), y(y) {
	}
	Point() {
	}
	bool operator <(const Point &p) const {
		return id < p.id;
	}
	void print() {
		printf("%d\n", id);
	}
};

class Node {
public:
	int location, l, r;
};

bool lessX(const Point &p1, const Point &p2) {
	return p1.x < p2.x;
}
bool lessY(const Point &p1, const Point &p2) {
	return p1.y < p2.y;
}

const int NIL = -1;
const int MAX = 500000;
int np = 0;
Point P[MAX];
Node T[MAX];

int makeKdTree(int l, int r, int depth) {
	if (!(l < r))
		return NIL;

	if (depth % 2 == 0) {
		sort(P + l, P + r, lessX);
	} else {
		sort(P + l, P + r, lessY);
	}
	int t = np++;
	int mid = (l + r) / 2;
	T[t].location = mid;
	T[t].l = makeKdTree(l, mid, depth + 1);
	T[t].r = makeKdTree(mid + 1, r, depth + 1);

	return t;
}

void find(int v, int sx, int tx, int sy, int ty, int depth, vector<Point> &ans) {
	int x = P[T[v].location].x;
	int y = P[T[v].location].y;

	if (sx <= x && x <= tx && sy <= y && y <= ty) {
		ans.push_back(P[T[v].location]);
	}

	if (depth % 2 == 0) {
		if (T[v].l != NIL && sx <= x)
			find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
		if (T[v].r != NIL && x <= tx)
			find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
	} else {
		if (T[v].l != NIL && sy <= y)
			find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
		if (T[v].r != NIL && y <= ty)
			find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
	}
}

int main() {

	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		int x, y;
		scanf("%d %d", &x, &y);
		P[i] = Point(i, x, y);
		T[i].location = T[i].l = T[i].r = NIL;
	}

	int root = makeKdTree(0, n, 0);

	int q;
	scanf("%d", &q);
	vector<Point> ans;
	int sx, tx, sy, ty;
	for (int i = 0; i < q; ++i) {
		ans.clear();
		scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
		find(root, sx, tx, sy, ty, 0, ans);
		sort(ans.begin(), ans.end());
		for (int i = 0; i < ans.size(); ++i) {
			ans[i].print();
		}
		printf("\n");
	}

	return 0;
}

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

using namespace std;

int main(){

  string S;
  string T;
  cin>>S>>T;
  int cnt=0;
  int cnt_max=0;

  for(int i=0; i<=S.size()-T.size(); i++){
    cnt=0;
    for(int j=0; j<T.size(); j++){
      if(S[i+j]==T[j]) cnt++;
    }
    cnt_max=max(cnt_max, cnt);
  }

  cout<<T.size()-cnt_max<<endl;
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define ss cout << " ";
#define nn cout << "\n";
#define ct(x) cout << x;
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define oss out << " ";
#define onn out << "\n";
#define oct(x) out << x;
#define octs(x) out << x << " ";
#define octn(x) out << x << "\n";
#define odb(x) out << "> " << #x << ": " << x << "\n";
#define qr queries();
void solve();
void YN(bool b){if (b){ctn("YES");}else{ctn ("NO");}};
void yn(bool b){if (b){ctn("Yes");}else{ctn ("No");}};
void queries(){int n;cin >> n;while (n--)solve();}
// ifstream in ("nume.in");
// ofstream out ("nume.out");
// #define cout out
// #define cin in
// // // // // // // // // // // // // // // // // // // // // // 
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
const int maxn = 200200;
vector <int>  A [100001];
vector <bool> V (100001);
 
void solve(){

    return;
}
 

void dfs(int x){
    V[x] = 1;
    for (int i = 0; i < A[x].size(); i++){
        int cr = A[x][i];
        if (!V[cr]){
            dfs(cr);
            V[cr] = 1;
        }
    }
}
 
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++){
        int x,y;
        cin >> x >> y;
        A[x].push_back(y);
        A[y].push_back(x);
    }
    int rs = 0;
    for (int i = 1; i <= n; i++){
        if (!V[i]){
            dfs(i);
            rs++;
        }
    }
    ctn(rs - 1);
    return 0;
}


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






int main() {
	ios_base::sync_with_stdio(false);
	long long n;
	cin >> n;
	long long ans = n + 1;

	for (long long i = 1; i * i <= n; ++i) {
		if (n % i) continue;
		ans = min(ans, i + n/i);
	}
	cout << ans - 2 << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
const ll MOD = 1e9+7;

signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll n,a,b,c,d,e;
    cin >> n >> a >> b >> c >> d >>e;
    ll mi=a;
    chmin(mi,b);chmin(mi,c);chmin(mi,d);chmin(mi,e);
    ll ans=(n+mi-1)/mi+4;
    cout << ans << endl;
}



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

#define PI acos(-1)
#define int long long int
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fir first
#define sec second
#define MAXN 501
#define MAXL 20
#define mod 1000000007

signed main()
{
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++)
  {
    if (s[i] == '?')
    {
      if (s[i - 1] == 'P')
        s[i] = 'D';
      else if (s[i + 1] == 'D')
        s[i] = 'P';
      else if (s[i + 1] == '?')
        s[i] = 'P', s[i + 1] = 'D';
      else
        s[i] = 'D';
    }
  }
  cout << s << endl;
  return 0;
}


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

typedef long long ll;

const int N = 2 * 100 * 1000  + 20;
ll n, sum[N], dp[N], a[N];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		sum[i] = a[i] + (i > 1? sum[i - 2]: 0);
	for (int i = 1; i < n; i++) {
		if (i % 2 == 0)
			dp[i] = max(a[i] + dp[i - 2], dp[i - 1]);
		else
			dp[i] = max(a[i] + dp[i - 2], sum[i - 1]);
	}
	return cout << dp[n - 1] << endl, 0;
}	


Measured memory_bytes: 8272
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		long a = sc.nextLong();
		long b = sc.nextLong();
		long k = sc.nextLong();
		if(a > 0) {
			if(a >= k) {
				a = a - k;
			}
			else {
				k = k - a;
				a = 0;
				k = k - a;
				if(b > 0){
					if(b >= k) {
						b = b - k;
					}
					else {
						b = 0;
						k = k - b;
					}
				}
			}
		}
		else if(b > 0){
			if(b >= k) {
				b = b - k;
			}
			else {
				b = 0;
			}
		}
		
		System.out.print(a);
		System.out.print(" ");
		System.out.println(b);
	}
	
}

Measured memory_bytes: 35684
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;


template <typename T> T digsum(T a) {
    T res = 0;
    while (a > 0) {
        res += a%10;
        a /= 10;
    }
    return res;
}





int main()
{

    int N;
    cin >> N;
    int ans = 1000000000;
    reps(i,1,N){
        ans = min(ans,digsum(i)+digsum(N-i));
    }
    cout << ans << endl;
    
    
    
    

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

const int maxn = 200000 + 10;
const int inf = 0x3f3f3f3f;

int n, a[maxn], b[maxn], c[maxn];

int read()
{
	int x;
	scanf("%d", &x);
	return x;
}

//AtCoder 4721

int main()
{
	n = read();
	for(int i = 1; i <= n; i ++)
	{
		a[i] = read();
	} 
	b[n] = a[n];
	for(int i = n - 1; i >= 1; i --)
	{
		b[i] = max(b[i + 1], a[i]);
	}
	c[1] = a[1];
	for(int i = 2; i <= n; i ++)
	{
		c[i] = max(c[i - 1], a[i]);
	}
	c[0] = 0;
	b[n + 1] = 0;
	for(int i = 1; i <= n; i ++)
	{
		cout << max(b[i + 1], c[i - 1]) << endl;
	}
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N,Y;
	cin>>N>>Y;
	for(int i=0;i<=N;i++){
		for(int j=0;j<=N;j++){
			if(i*10000+j*5000+(N-i-j)*1000==Y){
				if(N-i-j>=0){
					cout<<i<<" ";
			    	cout<<j<<" ";
			    	cout<<N-i-j<<endl;
		    		return 0;
				}
			}
		}
	}
	cout<<"-1 -1 -1"<<endl;
	return 0;
}

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

#define int long long
#define rep(n, i) for (int i = 0; i < n; i++)
#define rep2(m, n, i) for (int i = m; i < n; i++)
#define rep_r(n, i) for (int i = n - 1; i >= 0; i--)

const int INF = 1LL << 60;
const int MOD = 1e9 + 7;
const int MAX = 1e4;

signed main() {
    int tri[MAX];
    tri[0] = 0;
    rep2(1, MAX, i) {
        tri[i] = tri[i - 1] + i;
    }
    int n;
    cin >> n;
    int max_p = 1;
    while (true) {
        if (tri[max_p] > n) {
            max_p--;
            break;
        }
        max_p++;
    }
    int diff = n - tri[max_p];
    int start_1 = max_p - diff + 1;
    rep2(1, start_1, i) {
        cout << i << endl;
    }
    rep2(start_1, max_p + 1, i) {
        cout << i + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;            //

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

    if (A <= C && C <= B)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
using namespace std;

int main()
{
    string s;
    cin >> s;
    cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int DPx[20000][8005], DPy[20000][8005];

int main() {
  string S;
  cin>>S;
  int x, y;
  cin>>x>>y;
  vector<int> xarr, yarr;
  bool nowx = true;
  int tmp=0;
  for(int i=0;i<S.size();++i) {
    if(S[i]=='F') {
      tmp++;
    }
    else {
      if(nowx) xarr.push_back(tmp);
      else yarr.push_back(tmp);
      tmp = 0;
      nowx ^= 1;
    }
  }
  if(nowx) xarr.push_back(tmp);
  else yarr.push_back(tmp);
  if(yarr.size()==0) yarr.push_back(0);
  DPx[10000+xarr[0]][0] = 1;
  for(int i=0;i<xarr.size()-1;++i) {
    for(int j=0;j<20000;++j) {
      if(DPx[j][i]==1) {
        DPx[j+xarr[i+1]][i+1] = 1;
        DPx[j-xarr[i+1]][i+1] = 1;
      }
    }
  }
  DPy[10000][0] = 1;
  for(int i=0;i<yarr.size();++i) {
    for(int j=0;j<20000;++j) {
      if(DPy[j][i]==1) {
        DPy[j+yarr[i]][i+1] = 1;
        DPy[j-yarr[i]][i+1] = 1;
      }
    }
  }
  if(DPx[10000+x][xarr.size()-1]==1 && DPy[10000+y][yarr.size()]==1) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 73392
/**
*   Bismillahir Rahmanir Rahim.
*   Imtiaz_rafi
*   PCIU, CHITTAGONG
**/
#include<bits/stdc++.h>
using namespace std;
#define speed() ios::sync_with_stdio(0);cin.tie(0);
#define file() freopen ("input.txt", "r", stdin);freopen ("output.txt", "w", stdout);
#define rep(i,a) for(ll i=0;i<a;i++)
#define rep1(i,begin,end) for(ll i=begin;i<=end;i++)
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define all(v)   v.begin(),v.end()
#define rall(v)   v.rbegin(),v.rend()
#define pb push_back
#define pf push_front
#define mp make_pair
#define pi acos(-1)
// bitshift (1LL<<(3)) *2^3
typedef long long int ll;
typedef vector<ll>vi;
typedef map<ll,ll>mi;
typedef pair<ll,ll>pll;
typedef vector<pll> vll;
typedef set<ll>st;
typedef set<char>sc;
ll dx[] = {-1,+1,0,0,+1,-1,+1,-1};
ll dy[] = {0,0,-1,+1,+1,+1,-1,-1};
const ll mx = 1e5+123;
const ll MOD = 1e9+7;

template <class T> T power(T a,T b){a%=MOD;if(!a) return 0;T p=1;while(b>0){if(b&1){p*=a;p%=MOD;}a*=a;a%=MOD;b=b>>1;}return p;}
template <class T> void print(vector<T> &v){for(T u:v){cout<<u<<" ";}cout<<endl;}
template <class T> T gcd(T a, T b){return (b!=0?gcd<T>(b,a%b):a);}
template <class T> T lcm(T a, T b){return (a/gcd<T>(a,b)*b);}

ll BS(ll l,ll r,ll a[],ll k){ll mid,i=-1;while(l<=r){mid=(l+r)>>1;if(a[mid]==k){return i=mid;/*r=mid-1;*/}if(a[mid]<k) l=mid+1;if(a[mid]>k) r=mid-1;}return i;}

int main()
{
    speed();
    ll a,i,ans=0;
    string s;
    cin>>s;
    rep(i,s.size())
    {
        ans+=s[i]-'0';
    }
    if(ans%9==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;




return 0;
}



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

long long C[60][60]={};
long long com(int n, int r){
    if(C[n][r]!=0) return C[n][r];
    else if(n==r || r==0) return C[n][r]=1;
    else if(r==1 || r==n-1) return C[n][r]=n;
    else return  C[n][r] = C[n][n-r] = com(n-1,r-1) + com(n-1,r);
}

int main(void){
    int n,a,b;
    cin>>n>>a>>b;
    vector<ll> v(n);
    rep(i,n){
        cin>>v[i];
    }
    sort(all(v));
    reverse(all(v));

    ll sum = 0;
    rep(i,a) sum += v[i];

    int l = 0, r = n;
    rep(i,n){
        if(v[i] == v[a-1]) {
            l = i;
            break;
        }
    }

    rep(i,n)if(a<=i){
        if(v[i] != v[a-1]) {
            r = i;
            break;
        }
    }
    
    printf("%.10f\n",(double)sum/a);
    ll csum = 0;
    
    for(int k = a; k <= r && k <= b; k++){
        csum += com(r-l,k-l);
        if(l>0)break;
    }
    cout<<csum<<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 n = sc.nextInt();
		char c[] = sc.next().toCharArray();
		int e[] = new int[n];
		int w[] = new int[n];
		Arrays.fill(e, 0);
		Arrays.fill(w, 0);
		for(int i = 1; i < n; i++) {
			w[i] = w[i - 1];
			if(c[i - 1] == 'W') w[i]++;
		}
		for(int i = n - 2; i >= 0; i--) {
			e[i] = e[i + 1];
			if(c[i + 1] == 'E') e[i]++;
		}
		int min = n;
		for(int i = 0; i < n; i++) {
			if(min > e[i] + w[i]) {
				min = e[i] + w[i];
			}
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 32788
use std::io;
//use std::collections::HashMap;
//use std::collections::BinaryHeap;
//use std::collections::HashSet;
//use std::mem; // mem::swap(&mut x,&mut y);
use std::cmp; // cmp::max,cmp::min

// Rust memo: https://hackmd.io/i0lQY1OKTDW1t66TECOmiw?both

#[allow(dead_code)]
fn read_line() -> String{
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn read_charvec() -> Vec<char>{
    read_line().chars().collect()
}

#[allow(dead_code)]
fn read_ints() -> Vec<i64>{
    let s = read_line();
    let split:Vec<&str> = s.split(" ").collect();
    split.iter().map(|&x| x.to_string().parse().unwrap()).collect()
}

#[allow(dead_code)]
fn read_int() -> i64{
    read_ints()[0]
}

#[allow(dead_code)]
fn reverse(s: &String) -> String{
    s.chars().rev().collect::<String>()
}

#[allow(dead_code)]
fn read_lines(n:i64) -> Vec<String>{
    let mut xs = Vec::new();

    for _i in 0..n{
        xs.push(read_line());
    }

    xs
}

#[allow(dead_code)]
fn read_ints2(n:i64) -> Vec<i64>{
    read_lines(n).iter().map(|x| x.parse().unwrap()).collect()
}

#[allow(dead_code)]
fn arange(start:i64,end:i64,step:i64) -> Vec<i64>{
    let mut ret = Vec::new();
    let mut i = start;

    while i < end{
        ret.push(i);
        i += step;
    }

    ret
}

#[allow(dead_code)]
const DXS : [i64; 4] = [0,0,1,-1];
#[allow(dead_code)]
const DYS : [i64; 4]  = [1,-1,0,0];
#[allow(dead_code)]
const INF : i64 = 999999999;

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

fn calc(a:i64,b:i64,c:i64)->i64{
    (a-b).abs() + (b-c).abs()
}


fn main(){
    let x = read_int();
    
    println!("{}",
        if x < 1200{
            "ABC"
        }else if x < 2800{
            "ARC"
        }else{
            "AGC"
        });
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    if(k > log2(n)){
        // log2(n)回以上出来るなら全ての文字を辞書順最小のものに出来る
        sort(s.begin(), s.end());
        char x = s[0];
        for(int i=0;i<n;i++) cout << x;
        cout << endl;
    }else{
        //多くて13回程度, シミュレートして間に合う
        string ans = s;
        for(int i=0;i<k;i++){
            string rev = s;
            reverse(rev.begin(), rev.end());
            s += rev;
            if(i!=k-1){
                string nxt = rev;
                reverse(s.begin(), s.end());
                for(int pos = 0; pos < s.size() - n; pos++){
                    nxt = min(nxt, s.substr(pos, n));
                }
                reverse(nxt.begin(), nxt.end());
                s = nxt;
            }else{
                for(int pos = 0; pos < s.size() - n; pos++){
                    ans = min(ans, s.substr(pos, n));
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = (((1<<30)-1)<<1)+1;
const int nINF = 1<<31;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, int> pci;

/////////////////////////////////////////////////////////////////////
const int N = 2e5+1;
int n, p[N], ans = 0, seen[N];

void findans() {
	REP(i, n) {
		if(seen[p[i]-1]) seen[p[i]] = seen[p[i]-1]+1;
		else seen[p[i]] = 1;
		ans = max(ans, seen[p[i]]);
	}
}

int main() {
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);
    cin >> n;
    REP(i, n) cin >> p[i];
    fill(seen, seen+n, 0);
    findans();
    ans = n-ans;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define Re register
using namespace std;

const int N=2020;

struct Node {
	int u,v,nxt;
}E[2*N];
int cnt,head[N];

int n;
char s[N];
int val[N],dis[N];
int f[N];
int Ans=-1;

inline int rd()
{
	char c=getchar();
	int x=0,f=1;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}

void add(int x,int y)
{
	Node T={x,y,head[x]};
	E[++cnt]=T;
	head[x]=cnt;
}

void dfs(int u,int fa)
{
	val[u]=s[u]-'0';
	dis[u]=0;
	int Son=-1;
	for(int i=head[u];~i;i=E[i].nxt)
	{
		int ver=E[i].v;
		if(ver==fa) continue;
		dfs(ver,u);
		val[u]+=val[ver];
		dis[ver]+=val[ver];
		dis[u]+=dis[ver];
		if(!(~Son)||dis[Son]<dis[ver]) Son=ver;
	}
	if(!(~Son))
	{
		f[u]=0;
		return;
	}
	if(dis[u]-dis[Son]>=dis[Son]) f[u]=dis[u]/2;
	else f[u]=dis[u]-dis[Son]+min(f[Son]*2,2*dis[Son]-dis[u])/2;
}

int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	memset(head,-1,sizeof(head));
	for(Re int i=1;i<n;i++)
	{
		int u=rd();
		int v=rd();
		add(u,v);
		add(v,u);
	}
	for(Re int i=1;i<=n;i++)
	{
		dfs(i,0);
		if(f[i]*2==dis[i])
		{
			if(!(~Ans)) Ans=f[i];
			Ans=min(Ans,f[i]);
		}
	}
	printf("%d",Ans);
	return 0;
}

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

int h,w,k;
char g[10][10];

int main(){

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

    cin>>h>>w>>k;
    for(int i=0;i<h;i++){
        cin>>g[i];
    }
    int ans=0;
    for(int s=0;s<1<<h+w;s++){
        int c=0;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                c+=!(s>>i&1)&&!(s>>h>>j&1)&&g[i][j]=='#';
            }
        }
        ans+=c==k;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3648