akhauriyash/Code-Regression huggingface dataset:
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: u32 = sc.read();
    let x: u32 = sc.read();
    let mut lv: Vec<u32> = Vec::new();
    for _ in 0..n {
        lv.push(sc.read());
    }

    let mut ans = 1;
    let mut pos = 0;
    for li in lv {
        pos += li;
        if x < pos {
            break;
        }
        ans += 1;
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>
#include <inttypes.h>

#define MOD_BY UINT32_C(1000000007)
#define INV2 UINT32_C(500000004)

int N,l;
char s[50000];

#if 0
uint32_t modoru_memo[12000][6000]; /* [場所][残り] */

uint32_t modoru_search(int pos, int left) {
	uint32_t ret = 0;
	if (left == 1) return pos == 1;
	if (left == 0) return 1;
	if (modoru_memo[pos][left]) return ~modoru_memo[pos][left];

	if (pos == 0) {
		/* 空文字列にバックスペース */
		ret = modoru_search(pos, left - 1);
	} else {
		/* 戻って進む */
		ret = modoru_search(pos - 1, left - 2);
		ret += ret; /* 0で進むか１で進むか */
		if (ret >= MOD_BY) ret -= MOD_BY;
	}
	/* 進んで戻る */
	ret += modoru_search(pos + 1, left - 2);
	if (ret >= MOD_BY) ret -= MOD_BY;

	return ~(modoru_memo[pos][left] = ~ret);
}
#endif

uint32_t memo[6000][6000]; /* [位置][残り操作数] */

uint32_t search(int pos, int left) {
	uint32_t ret=0;

	if (left == 0) return pos == l;
	if (memo[pos][left])return ~memo[pos][left];

	/* 0または1を入力 */
	ret = search(pos + 1, left - 1);
	ret += ret;
	if (ret >= MOD_BY) ret -= MOD_BY;
	/* バックスペースを入力 */
	ret += search(pos == 0 ? pos : pos - 1, left - 1);
	if (ret >= MOD_BY) ret -= MOD_BY;

	return ~(memo[pos][left] = ~ret);
}

int main(void) {
	uint32_t tmp;
	uint32_t divnum;
	if(scanf("%d%49999s",&N,s)!=2)return 1;
	l=strlen(s);
	/* 何でもいいから入力する */
	tmp=search(0, N);
	/* 残るところが間違っているものを除く */
	divnum=INV2;
	while(l>0) {
		if(l&1)tmp=((uint64_t)tmp*divnum)%MOD_BY;
		divnum=((uint64_t)divnum*divnum)%MOD_BY;
		l>>=1;
	}
	printf("%"PRIu32"\n", tmp);
	return 0;
}


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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define v(d_type) vector<d_type>
#define p(d_type1, d_type2) pair<d_type1, d_type2>
#define F first
#define S second
#define loop(i, s, n) for(int i = s; i < n; i++)
#define print_vec(X) loop(i, 0, X.size()) cout << X[i] << "\n"
#define nl "\n"
#define fat 1000000007


int main()
{
    boost;

    int n;
    cin >> n;
    
    int b;
    cin >> b;
    ll ans = 0;

    v(int) a(n, 0);

    a[0] = a[1] = b;
    loop(i, 1, n - 1)
    {
        cin >> b;

        if(b < a[i]) a[i] = b;

        a[i + 1] = b;
    }

    ans = accumulate(a.begin(), a.end(), ans);
    cout << ans << nl;
    return 0;

}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
// #include <bits/stdc++.h>

using namespace std;

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

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

int main() {
  int n;
  cin >> n;
  string sequence(n, 'x');
  REP(i, n){
    cin >> sequence[i];
  }
  for(int i = 0;; i++) {
    if (sequence.find(to_string(i)) == string::npos) {
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
using in = int64_t;

int main(){
int n;
  cin>>n;
vector<char> s(n);
  vector<char> t(n);
  rep(i,n) cin>>s.at(i);
  rep(i,n) cin>>t.at(i);
  rep(i,n){
    cout<<s.at(i)<<t.at(i);
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int N;
    cin >>N;
    int check=0;
    REP(i,N){
        int a;
        cin >>a;
        if(a!=(i+1)){
            check++;
        }
    }
    if(check<=2){
        cout <<"YES" <<endl;
    }
    else{
        cout <<"NO"<<endl;
    }
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
d = [int(i) for i in input().split()]
m = int(input())
t = [int(i) for i in input().split()]

c1 = Counter(d)
c2 = Counter(t)

flg = True

for k,v in c2.items():
    if c1[k] < v:
        flg = False
        break
    
print('YES' if flg else 'NO')

Measured memory_bytes: 56928
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=30;
int n,op[N];
char s[N];
map <string,int> tot;
int main(){
	scanf("%d",&n);
	scanf("%s",s+1);
	tot.clear();
	for (int i=0;i<(1<<n);i++){
		string now="";
		for (int j=0;j<n;j++)
			if (!((i>>j)&1))
				now+=s[j+1];
		now+="*";
		for (int j=n-1;j>=0;j--)
			if ((i>>j)&1)
				now+=s[j+1];
//		cout << now << endl;
		tot[now]++;
	}
//	cout << endl;
	LL ans=0;
	for (int i=0;i<(1<<n);i++){
		string now="";
		for (int j=0;j<n;j++)
			if ((i>>j)&1)
				now+=s[n*2-j];
		now+="*";
		for (int j=n-1;j>=0;j--)
			if (!((i>>j)&1))
				now+=s[n*2-j];
//		cout << now << tot[now] << endl;
		ans+=tot[now];
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 73984
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t <decltype (b), decltype (e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define FORR(i,b,e) for (common_type_t <decltype (b), decltype (e)> i = (e), i ## __begin = (b); i -- > i ## __begin;)
#define rep(i,n) for (decay_t <decltype (n)> i = 0, i ## __len = (n); i < i ## __len; ++ i)
#define ALL(x) begin (x), end (x)
using namespace std;

template <typename Iterator>
inline auto cumulative_sum (Iterator first, Iterator last)
{
  using T = typename iterator_traits <Iterator>::value_type;
  vector <T> res (size_t {1}, T {});
  partial_sum (first, last, back_inserter (res));
  return res;
}

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

  size_t n, k; cin >> n >> k;
  char pre = '1';
  vector <int64_t> v (1, 0);
  rep (i, n)
  {
    char c;
    cin >> c;
    if (c == pre) v.back () += 1;
    else v.push_back (1);
    pre = c;
  }

  if (v.size () / 2 <= k)
  {
    cout << n << endl;
  }
  else
  {
    int64_t ans = 0;
    auto a = cumulative_sum (ALL (v));
    for (size_t l = 0, r = k * 2 + 1; r <= a.size (); l += 2, r += 2)
    {
      if (r == a.size ()) --r;
      ans = max (ans, a[r] - a[l]);
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
#include <vector>
#include <string>
using namespace std;
 
int main(){
  long long int a,b,k;
  cin>>a>>b>>k;
  if(a>k) cout<<a-k<<" "<<b<<endl;
  else if(a+b<k) cout<<0<<" "<<0<<endl;
  else{cout<<0<<" "<<a+b-k<<endl;}
  return 0;
}

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

int main(void){
    int n;
    cin >> n;
    
    bool color[8] = {false};
    int rate;
    int under_cnt = 0;
    int over_cnt = 0;
    int i;
    for(i = 1; i <= n; i++){
        cin >> rate;
        if(rate >= 3200){
            over_cnt++;
        }else{
            if(color[rate / 400] == false){
                under_cnt++;
                color[rate / 400] = true;
            }
        }
    }
    
    cout << max(1, under_cnt) << " " << under_cnt + over_cnt << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
int digit(ll n){
  int i=0;
  ll x= 1;
  while(x <= n){
    x*=10;
    i++;
  }
  return i;
}

int main(){
  ll N;
  cin >> N;
  int ans = 15;
  int root = sqrt(N);
  for(ll i=1;i<=root;i++){
    if(N%i==0){
      ans = min(ans, max(digit(i),digit(N/i)));
    }
  }
  cout << ans <<endl;

  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A = sorted(A)
F = sorted(F)[::-1]

left = -1
right = max(A) * max(F)

while left + 1 < right:
  mid = (left + right) // 2
  tmp = 0
  for i in range(N):
    a, f = A[i], F[i]
    if a * f > mid:
      tmp += -(-(a * f - mid) // f)
  if tmp <= K:
    right = mid
  else:
    left = mid
    
print(right)

Measured memory_bytes: 83740
from sys import stdin

(n, a, b) = stdin.readline().rstrip().split()
n = int(n)
a = int(a)
b = int(b)

total=0
POW_MAX=4

for i in range(1, n+1):
    sub_total=0
    for j in range(0, len(str(i))):
        #sub_total = sub_total + math.floor(i / (10 ** j) )
        #sub_total = sub_total + i // (10 ** j)
        sub_total = sub_total + int(str(i)[j])
    if a <= sub_total and sub_total <= b:
        #print("n:%d sub_total:%d" % (i, sub_total))
        total = total + i

print(total)


Measured memory_bytes: 3060
n,k=map(int,input().split())
a=list(map(int,input().split()))
x=[0,a[0]]
for i in range(1,n):
    x.append(x[-1]+a[i])
y=[]
for i in range(n+1):
    for j in range(i+1,n+1):
        y.append(x[j]-x[i])
y.sort()
y=y[::-1]
m=len(bin(y[0]))
y=["0"*(m-len(bin(y[i])))+bin(y[i])[2::] for i in range(len(y))]
res=["0" for _ in range(m-2)]
for x in range(m-2):
    t=0
    z=[]
    for i in range(len(y)):
        if y[i][x]=="1":
            t+=1
            z.append(y[i])
    if t>=k:
        res[x]="1"
        y=z[::]
print(int("".join(res),2))

Measured memory_bytes: 153320
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<iostream>
#define pb push_back
#define fi first
#define se second
#define sz(x)  x.size()
#define cl(x)  x.clear()
#define all(x)  x.begin() , x.end()
#define r(x)  scanf("%d", &x)
#define rr(x , y)  scanf("%d%d" , &x , &y)
#define rst(s)  scanf("%s" , s)
#define rl(x)  scanf("%lld" , &x)
#define rrl(x , y)  scanf("%lld%lld" , &x , &y)
#define w(x)  printf("%d" , x)
#define ww(x , y)  printf("%d %d" , x , y)
#define wl(x)  printf("%lld" , x)
#define wwl(x , y)  printf("%lld %lld" , x , y)
#define sp()  printf(" ")
#define en()  puts("")
#define rep(i , x , n)  for(int i = x ; i <= n ; i ++) 
#define per(i , n , x)  for(int i = n ; i >= x ; i --) 
#define mem0(x)  memset(x , 0 , sizeof(x))
#define mem_1(x)  memset(x , -1 , sizeof(x))
#define mem_inf(x)  memset(x , inf , sizeof(x))
#define mem__inf(x)  memset(x , -inf , sizeof(x))
#define p_queue priority_queue
#define debug(x)  cout << x << '\n'
#define ddebug(x , y)  cout << x << ' ' << y << '\n'
using namespace std ;
//mt19937  rnd(chrono::high_resolution_clock::now().time_since_epoch().count()) ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair<int , int> pii ;
typedef pair<ll , ll> pll ;
typedef pair<int , ll> pil ;
typedef pair<ll , int> pli ;
const int inf = 0x3f3f3f3f ;
const int maxn = 105 ;
const int maxm = 30 ;
const ll mod = 1e9 + 7 ; 
int main()
{
	double pi = acos(-1.0) ;
	int r ;
	r(r) ;
	printf("%.12f\n" , double(r) * pi * 2) ;
	return 0 ;
}


Measured memory_bytes: 3784
#include<iostream>
#include<string>
#include<stack>
#include <cmath>
using namespace std;
bool paren(char a,char b){
	return (a=='('&&b==')')||(a=='['&&b==']');
}
int main(){
	string str;
	while(getline(cin,str)&&str!="."){
		int flg=1;
		stack<char> stk;
		for(unsigned i=0;i<str.size()&&flg==1;i++){
			switch(str[i]){
			case '(':
			case '[':
				stk.push(str[i]);
				break;
			case ']':
			case ')':
				if(stk.empty()||!paren(stk.top(),str[i])){
					flg=0;
				}
				if(flg)stk.pop();
			}
		}
		if(!stk.empty())flg=0;
		cout<<(flg==1?"yes":"no")<<endl;
	}
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define p (int)(1e9 + 7)

int MOD(int a){
	return (a %= p) >= 0 ? a : a + p;
}

int power(int a, int N){
	if(N == 0){
		return 1;
	}
	else if(N % 2 == 0){
		return power(MOD(a * a), N / 2);
	}
	else{
		return MOD(a * power(a, N - 1));
	}
}

signed main(){
	int N, K, i, j, ans = 0;
	scanf("%lld%lld", &N, &K);
	vector<int> count(K + 1, 0);
	for(i = K; i >= 1; i--){
		count[i] = power(K / i, N);
		for(j = i + i; j <= K; j += i){
			count[i] = MOD(count[i] - count[j]);
		}
		ans = MOD(ans + i * count[i]);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4012
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long int lli;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<pll> vop;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define REP(i,a,b) for( int i=a;i<b;i++)
#define REPR(i,a,b) for(int i=a;i>=b;i--)
#define adb(a) for(auto i:a) cout << i << " "; cout << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define endl "\n"

int main()
{

    fastIO;
    int test = 1;
    //cin >> test;
    while (test--)
    {
        ll n;
        cin >> n;
        map<ll, ll>m;
        ll sum = 0;
        REP(i, 0, n) {
            ll x;
            cin >> x;
            m[x]++;
            sum += x;
        }
        ll q;
        cin >> q;
        while (q--)
        {
            ll b, c;
            cin >> b >> c;
            sum -= m[b] * b;
            sum += m[b] * c;
            m[c] += m[b];
            m[b] = 0;
            cout << sum << endl;
        }
    }
    return 0;
}



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

int main() {
int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if (e - a <= k) {
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
    
  vector<int64_t> L = { 2LL, 1LL};
  for(int i=2; i<=N; i++) L.push_back( L.at(i-2) + L.at(i-1) );
  printf("%ld", L.at(N));
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int H,W,i,j;
  while(1){
    scanf("%d %d",&H,&W);
  if(H==0&&W==0){
    break;
  }
  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      printf("#");
    }
    printf("\n");
  }
  printf("\n");
  }
  return 0;
}
    


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

int main() {
  int n;
  cin >> n;
  int d[n];

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

  sort(d, d + n);
  
  if(d[n / 2 - 1] == d[n / 2]){
          cout << 0 << endl;
          return 0;    
      }else{
          cout << d[n / 2 ] - d[n / 2 - 1] << endl;
      }
  
}

Measured memory_bytes: 640
#pragma region header
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a / gcd(a, b) * b ;
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
bool isprime(int n) { //素数判定
    if(n==1)return false;
    if(n==2)return true;
    for(int i = 2;i<=sqrt(n);i++) {
        if(n%i==0) return false;
    }
    return true;
}
/* ----------------------end----------------------- */
#pragma endregion
vi v;
void dfs(int k) {
    v.pb(k);
    if(k>3500000000) return;
    for(int i = max(0LL,k%10-1);i<=min(9LL,k%10+1);i++) dfs(k*10+i);
}
signed main() {
    int k;cin >> k;
    rep1(i, 9)dfs(i);
    sort(all(v));
    cout << v[k-1] << endl;
    return 0;
}

Measured memory_bytes: 7456
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const long long MOD = 1000000007;
long long Comb[2001][2001];

void calc_com(){
//    memset(Com, 0, sizeof(Com));
    Comb[0][0] = 1;
    for (int i = 1; i < 2001; ++i) {
        Comb[i][0] = 1;
        for (int j = 1; j < 2001; ++j) {
            Comb[i][j] = (Comb[i-1][j-1] + Comb[i-1][j]) % MOD;
        }
    }
}

int main(){
    calc_com();
    int n, k; cin >> n >> k;
    for(int i = 1; i <= k; i++){
        cout << (Comb[k-1][i-1] * Comb[n-k+1][i]) % MOD << endl;
    }
    return 0;
}


Measured memory_bytes: 31488
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  string s;
  cin>>s;
  int n=s.length();
  stack<int> st;
  rep(i,0,n){
    if(st.empty()) st.push(s[i]-'0');
    else{
      if(st.top()==0 && s[i]=='1') st.pop();
      else if(st.top()==1 && s[i]=='0') st.pop();
      else st.push(s[i]-'0');
    }
  }
  cout<<n-st.size()<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3868
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let s = sc.read::<String>();
    match s.as_str() {
        "Sunny" => println!("Cloudy"),
        "Rainy" => println!("Sunny"),
        "Cloudy" => println!("Rainy"),
        _ => unreachable!(),
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include <stdio.h>

int num, arry[50];

int solve(int i, int m)
{
	if (m == 0) return 1;
	if (i >= num) return 0;
	int res = solve(i + 1, m) || solve(i + 1, m - arry[i]);
	return res;
}

int main()
{
	int q, M, i;
	scanf("%d", &num);
	for (i = 0; i < num; i++)
	{
		scanf("%d", &arry[i]);
	}
	scanf("%d", &q);
	for (i = 0; i < q; i++)
	{
		scanf("%d", &M);
		if (solve(0, M))printf("yes\n");
		else printf("no\n");
	}
	return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
#include<string.h>
#define ll long long
#define pf printf
#define sf scanf
#define ff first
#define ss second
#define clr clear()
#define sz size()
#define pb push_back
#define mk make_pair
#define pi acos(-1)
#define inf 2000000000000000000
#define mod 1000000007
#define ull unsigned long long int
#define f(i,k,n) for(i=k;i<n;i++)
#define fr(i,n,k) for(i=n;i>=k;i--)
#define ent(a) scanf("%lld",&a)
#define ent2(a,b) scanf("%lld%lld",&a,&b)
#define ent3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define mem(a) memset(a,0,sizeof(a))
#define vec(v,s) vector<ll>v[s]
#define arr(a,s) ll a[s];
/*#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
//knight and king//
int dr[]= {2,2,-2,-2,1,-1,1,-1};
int dc[]= {1,-1,1,-1,2,2,-2,-2};
int dr1[]= {0,0,1,1,1,-1,-1,-1};
int dc1[]= {1,-1,1,0,-1,0,1,-1};
int dr2[]= {0,0,1,-1};
int dc2[]= {1,-1,0,0};
////////////////////////////
using namespace std;
#define ma 1000005

vector<int>adj[ma];
int a[ma],b[ma];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    ll n,i,j,u,v;
    while(cin>>n)
    {
        ll m=0;
        for(i=1;i<=n;i++)m+=i*(n-i+1);
        ll ans=0;
        for(i=1;i<n;i++)
        {
            cin>>u>>v;
            if(u>v)swap(u,v);
            ll r=u*(n-v+1);
            m-=r;
        }
        cout<<m<<endl;
    }
    return 0;
}


Measured memory_bytes: 27108
#include <stdio.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#define maxd 400500
using namespace std;
struct A{
    string s;
    int w;
};A a[maxd];
bool comp(A x,A y)
{
    if(x.w==y.w)
    return x.s.compare(y.s)<0;
    else
    return x.w>y.w;
}
int main()
{
    map<string,int>maps;
    int n,i=1;
    string c;
    cin>>n;
    for(i=1;i<=n;i++)
        {
            cin>>c;
            if(maps[c])
                maps[c]++;
            else
                maps[c]=1;
        }
    map<string,int>::iterator iter;
    for(iter=maps.begin();iter!=maps.end();iter++)
    {
        a[i].s=iter->first;
        a[i].w=iter->second;
        i++;
    }
    sort(a+1,a+i,comp);
    int ma=a[1].w;
    for(i=1;a[i].w==ma;i++)
    cout<<a[i].s<<endl;
    return 0;
}

Measured memory_bytes: 31744
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(n / i);
    }
  }
  return ret;
}

signed main() {
  ll N;
  cin >> N;
  vll A(N);
  map<ll, ll> m;
  rep(i, N) {
    cin >> A[i];
    m[A[i]]++;
  }
  SORT(A);
  ll a_max = A[N - 1];
  vector<bool> dp(a_max + 1, true);
  ll ans = 0;
  rep(i, N) {
    ll a = A[i];
    if (dp[a] && m[a] == 1) {
      ans++;
    }
    ll b = 1;
    while (a * b <= a_max) {
      dp[a * b] = false;
      b++;
    }
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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;
  cin >> n;
  ll total = 0;
  rep(i, n)
  {
    ll l, r;
    cin >> l >> r;
    total += r - l + 1;
  }
  print(total);
}

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

int main() {
    int n, odd;
    cin >> n;
    if(n%2 == 0) {
        odd = n/2;
    } else {
        odd = n/2+1;
    }
    cout << fixed << setprecision(10) << (double)odd/n;
    return 0;
}


Measured memory_bytes: 256
s = input()
for i in range(2**3):
    ls = ['+','+','+']
    for j in range(len(ls)):
        if (i >> j) & 1:
            ls[j] = '-'
    if eval(s[0]+ls[0]+s[1]+ls[1]+s[2]+ls[2]+s[3]) == 7:
        print(s[0]+ls[0]+s[1]+ls[1]+s[2]+ls[2]+s[3]+"=7")
        break

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

const int MAX = 133457 * 2;
int main(){
    int prime[MAX];
    prime[0] = prime[1] = 1;
    for(int i = 2; i * i <= MAX; i++){
        if(prime[i] == 0){
            for(int j = 2; i * j < MAX; j++){
                prime[i * j] = 1;
            }
        }
    }
    int n;
    while(cin >> n, n){
        int cnt = 0;
        for(int i = n + 1; i <= 2 * n; i++){
            if(prime[i] == 0) cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}



Measured memory_bytes: 4116
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>
#include <cassert>

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;

const ll INF = 1e15;

ll f(ll b, ll n) {
	if (b < 2) return INF;
	if (n < b)return n;
	else return f(b, n / b) + n % b;
}

int main() {
	ll n, s;
	cin >> n >> s;

	if (n == s) {
		cout << n + 1 << endl;
		return 0;
	}

	ll ans = INF;

	for (ll i = 2; i*i <= n; i++) {
		if (f(i, n) == s)ans = min(ans, i);
	}

	for (ll i = 1; i*i < n; i++) {
		ll b = (n - s) / i + 1;
		if (f(b, n) == s)ans = min(ans, b);
	}

	if (ans == INF)cout << -1 << endl;
	else cout << ans << endl;
	

	return 0;
}

Measured memory_bytes: 256
s = list(input())
k = int(input())
count1 = 0
count2 = 1
f = s[0]
memo = [0]
for c1, c2 in zip(s[:], s[1:]):
    if not memo[-1] and c1 == c2:
        count1 += 1
        memo.append(1)
    else:
        memo.append(0)
s[0] = "#"
memo2 = [0]
for c1, c2 in zip(s[:], s[1:]):
    if not memo2[-1] and c1 == c2:
        count2 += 1
        memo2.append(1)
    else:
        memo2.append(0)
if len(s) == 1:
    print(k // 2)
    exit()
if f == s[-1]:
    if memo[-1]:
        print(k * count1)
    else:
        if memo2[-1]:
            print(count1 * (k - k // 2) + count2 * (k // 2))
        else:
            print(count1 + count2 * (k-1))
else:
    print(k * count1)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>

using namespace std;

int main(void){
	char a, b;

	cin >> a >> b;

	if (a < b)
		cout << "<" << endl;
	else if (a > b)
		cout << ">" << endl;
	else
		cout << "=" << endl;

	return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
const int N = (int)1e5+5;
//long long int a[N];
int main()
{
    int t;
  long long  int i,j,n,sum=0,x,y,a,b,sum1=0,p,m=0,h;
    cin>>t;
    while(t--)
    {
       cin>>x;
       if(x%2==0)
       {
           if(x%3==0||x%5==0)
           {
               continue;
           }
           else
           {
               m=-1;
               break;
           }
       }



    }

    if(m!=-1)
    {
        cout<<"APPROVED"<<endl;
    }

    else
        cout<<"DENIED"<<endl;


    return 0;

}


Measured memory_bytes: 256
unittest
{
	assert( [ "3 3", "2 2 2" ].parse.expand.solve == 1 );
	assert( [ "6 1", "1 6 1 2 0 4" ].parse.expand.solve == 11 );
	assert( [ "5 9", "3 1 4 1 5" ].parse.expand.solve == 0 );
	assert( [ "2 0", "5 5" ].parse.expand.solve == 10 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nx = input.front.split.to!( long[] );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( nx[ 1 ], as );
}

auto solve( long x, long[] as )
{
	auto ans = 0L;
	for( auto i = 0L; i < as.length - 1; i++ )
	{
		auto d = as[ i ] + as[ i + 1 ] - x;
		if( 0 < d )
		{
			// 2つの箱の総和がxを超えていた場合、右の箱を優先して食べる
			ans += d;
			if( d <= as[ i + 1 ] )
			{
				as[ i + 1 ] -= d;
			}
			else
			{
				as[ i ] -= d - as[ i + 1 ];
				as[ i + 1 ] = 0;
			}
		}
	}
	return ans;
}


Measured memory_bytes: 6984
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll a,b,c,x,y;cin>>a>>b>>c>>x>>y;
    ll p,q,r;
    p=a*x+b*y;
    q=c*max(x,y)*2;
    if(x>y){
        r=c*y*2+a*(x-y);
    }else{
        r=c*x*2+b*(y-x);
    }
    cout<<min(p,min(q,r));
    
    return 0;
}


Measured memory_bytes: 3608
s1=input()
s2=map(int,input().split())
s3=map(int,input().split())
originals2=s2


minus=0
count=0
res=[a-b for a,b in zip(s2,s3)]
for r in res:
    if r<0:
        count+=1
        minus+=r
#print(minus)
#print(count)
#print("--")
if minus<0:
    for r in sorted(res,reverse=True):
        minus=minus+r
        count+=1
        if minus>0:
            print(count)
            break
    if minus<0:
        print(-1)
else:
    print(0)
        

Measured memory_bytes: 21492
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
const long long INF = 1LL << 60;
int h[100005];
long long dp[100005];
int main() {
  int n, k;
  cin >> n >> k;
  for(int i=0; i<n; ++i) {
    cin >> h[i];
    dp[i] = INF;
  }
  dp[0] = 0;
  for(int i=1; i<n; ++i) {
    int t=min(i, k);
    for(int j=1; j<=t; ++j) {
      dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]));
    }
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int main() {
	int N;
	string S, T;
	cin >> N;
	cin >> S >> T;
	string ans;
	ans = "";
	rep(i, N) {
		ans.push_back(S[i]);
		ans.push_back(T[i]);
	}
	cout << ans << endl;

	return 0;
}

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

const ll INF = 1ll << 60;
ll MOD = 2019;

int main()
{

    ll l, r;
    cin >> l;
    cin >> r;

    r = min(r, l + 4038);
    int ans = 2018;
    for (ll i = l; i <= r; ++i)
    {
        for (ll j = i + 1; j <= r; ++j)
        {
            int x = i * j % 2019;
            ans = min(ans, x);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
const int N=202;
vector<int> adj[N];
int color[N],dis[N];
bool dfs(int x){
	bool cac=true;
	for(int i=0;i<adj[x].size();i++){
		if(!color[adj[x][i]]){
			color[adj[x][i]]=3-color[x];
			cac=dfs(adj[x][i]);
			if(!cac){
				return false;
			}
		}
		else{
			if(color[adj[x][i]]!=3-color[x]){
				return false;
			}
		}
	}
	return true;
}
queue<int> lis;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,i,j,k,l,ans=0;
	cin>>n;
	char x;
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			cin>>x;
			if(x=='1'){
				adj[i].push_back(j);
			}	
		}
	}
	color[1]=1;
	bool ok=dfs(1);
	if(!ok){
		cout<<"-1";
		return 0;
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			dis[j]=0;
		}
		dis[i]=1;
		lis.push(i);
		while(lis.size()){
			j=lis.front();
			lis.pop();
			for(int k=0;k<adj[j].size();k++){
				if(!dis[adj[j][k]]){
					dis[adj[j][k]]=dis[j]+1;
					lis.push(adj[j][k]);
				}
			}
		}
		ans=max(ans,dis[j]);
	}
	cout<<ans;
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int keisuu(string S, char digit){
    rep(i, S.length()){
        if(S[i] == digit){
            if(i == 0 || '1' >= S[i-1] || S[i-1] > '9') return 1;
            else return S[i-1] - '0';
        }
    }
    return 0;
}

string conv(int num){
    string ret = "";
    char dig[] = {'m', 'c', 'x', 'i'};
    int divide[] = {1000, 100, 10, 1};
    rep(i, 4){
        int temp = num / divide[i];
        num -= divide[i]*temp;
        if(temp > 0){
            if(temp > 1) ret += (temp + '0');
            ret += dig[i];
        }
    }
    return ret;
}

int main(void){
    //m,c,x,i
    char dig[] = {'m', 'c', 'x', 'i'};
    int add[] = {1000, 100, 10, 1};
    int N; cin >> N;
    vector<string> ans;
    rep(i, N){
        int res = 0;
        string S1, S2; cin >> S1 >> S2;
        rep(j, 4){
            res += add[j]*(keisuu(S1, dig[j]) + keisuu(S2, dig[j]));
        }
        ans.push_back(conv(res));
    }
    rep(i, ans.size()) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 3240
class Dice
  def initialize(numbers)
    @numbers = numbers
    @map = {:top => 1, :R => 6, :S => 2, :E => 3, :N => 5, :W => 4}
  end

  def move(vec)
    case vec
    when "N"
      temp = @map.clone
      temp[:top] = @map[:S]
      temp[:R] = @map[:N]
      temp[:S] = @map[:R]
      temp[:N] = @map[:top]
      @map = temp.clone
    when "W"
      temp = @map.clone
      temp[:top] = @map[:E]
      temp[:R] = @map[:W]
      temp[:E] = @map[:R]
      temp[:W] = @map[:top]
      @map = temp.clone
    when "S"
      temp = @map.clone
      temp[:top] = @map[:N]
      temp[:R] = @map[:S]
      temp[:S] = @map[:top]
      temp[:N] = @map[:R]
      @map = temp.clone
    when "E"
      temp = @map.clone
      temp[:top] = @map[:W]
      temp[:R] = @map[:E]
      temp[:E] = @map[:top]
      temp[:W] = @map[:R]
      @map = temp.clone
    end
  end

  def spin
    temp = @map.clone
    temp[:E] = @map[:N]
    temp[:W] = @map[:S]
    temp[:S] = @map[:E]
    temp[:N] = @map[:W]
    @map = temp.clone
  end

  def top_number
    @numbers[@map[:top] - 1]
  end

  def right_number
    @numbers[@map[:E] - 1]
  end

  def front_number
    @numbers[@map[:S] - 1]
  end

  def back_number
    @numbers[@map[:N] - 1]
  end

  def left_number
    @numbers[@map[:W] - 1]
  end

  def bottom_number
    @numbers[@map[:R] - 1]
  end

  def get_place(number)
    index = @numbers.index(number)
    @map.key(index + 1)
  end

  def dump
    p @numbers
    p @map
  end

end

dice = Dice.new(gets.split.map(&:to_i))
num = gets.to_i

num.times do
  top, front = gets.split.map(&:to_i)
  while dice.top_number != top do
    place = dice.get_place(top)
    if place == :W || place == :E
      dice.move("W")
    else
      dice.move("S")
    end
  end
  while dice.front_number != front do
    dice.spin
  end
  puts dice.right_number
end

Measured memory_bytes: 8768
<?php
list($h, $n) = ints();
for ($i = 0; $i < $n; $i++) list($a[], $b[]) = ints();
$dp = array_fill(0, $h + 1, PHP_INT_MAX);
$dp[0] = 0;
for ($i = 1; $i <= $h; $i++) {
    for ($j = 0; $j < $n; $j++) {
        $d = $b[$j] + $dp[max(0, $i - $a[$j])];
        if ($dp[$i] > $d) $dp[$i] = $d;
    }
}
echo $dp[$h];

function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 4728
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int N=scan.nextInt();
		int i,j,v,n,A[]=new int[N];
		for(i=0;i<N;i++){
			A[i]=scan.nextInt();
		}
		for(n=0;n<N;n++){
			if(n!=N-1){
				System.out.print(A[n]+" ");
			}
			else{
				System.out.println(A[n]);
			}
		}
		for(i=1;i<N;i++){
			v=A[i];
			j=i-1;
			while(j>=0 && A[j]>v ){
				A[j+1]=A[j];
				j--;
				A[j+1]=v;
			}
			for(n=0;n<N;n++){
				if(n!=N-1){
					System.out.print(A[n]+" ");
				}
				else{
					System.out.println(A[n]);
				}
			}
		}
	}

}

Measured memory_bytes: 33596
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 
#include <math.h>
#include <bits/stdc++.h>
using namespace std;

using namespace std;
int main(){
    int n;std::cin >> n;
    int h[n];
    rep(i,n)std::cin >> h[i];
    int ans=1;int k=h[0];
    for(int i=1;i<n;i++){
        if(h[i]==max(k,h[i]))ans++;
        k=max(h[i],k);
    }
    std::cout << ans << std::endl;
}

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

int ReturnDigitsSum( int n ) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }

    return sum;
}
int main() {
    int n, a, b;
    cin >> n >> a >> b;
    long sum;
    long sum_soms = 0;
    for (int i = 1; i < n + 1; i++) {
        sum = ReturnDigitsSum(i);
        if (sum >= a && sum <= b) sum_soms += i;
    }
    cout << sum_soms << endl;
}

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

int n;
void f(vector<char> &s, char can_use) {
  int size = s.size();
  if (size == n) {
    for (char c: s) {
      cout<<c;
    }
    cout<<endl;
    return;
  }
  for (char i='a'; i<=can_use; i++) {
    s.push_back(i);
    f(s, max(can_use, (char)(i + 1)));
    s.pop_back();
  }
}
int main() {
  cin>>n;
  vector<char> s;
  f(s, 'a');
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF int(1e9+7)

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

int main()
{
	IO_OP;
	
	int tot = 0, n, p, mx = -1;
	cin >> n;
	for(int i=0;i<n;i++) {
		cin >> p;
		mx = max(mx, p);
		tot += p;
	}
	cout << tot - mx/2 << endl;
}



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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b){
    if(a==c) cout << "No" << endl;
    else cout << "Yes" << endl;
  }else{
    if(a==c){
      cout << "Yes" << endl;
    }else if(b==c){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3624
/*
    Author: Mohammad faisal
    Problem: K common Divisor
    Date: 06/08/2019

*/
// #include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
int gcd(int a,int b)
{
  if(b)
    return gcd(b,a%b);
  else
    return a;
}
int main()
{
  int a,b,k;
  cin >> a >> b >> k;
  int uper = gcd(a,b);
  int count=0;
  // cout<<(100%4)<<" "<<(50%4)<<endl;
  for(int i=uper;i>0;i--)
  {
    if(a%i==0 && b%i==0)
      count++;
    if(count == k)
    {
      cout<<i<<endl;
      break;
    }
  }
  return 0;
}
  
    

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

#define int long long

int gcd(int x, int y) {
  if ( x < y ) swap(x, y);
  while ( y > 0 )  {
    int r = x % y;    
    x = y;
    y = r;
  }

  return x;
}

signed main() {
  int x, y;
  cin >> x >> y;

  cout << gcd(x, y) << endl;
  
  return 0;
}



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

int main() {
	int N;
	cin >> N;
  vector<double> P(N);
  rep(i,N) cin >> P[i];

  vector<vector<double>> dp(N+1,vector<double>(N+1,0));
  dp[1][0] = 1-P[0];
  dp[1][1] = P[0];

  rep1(i,N)rep(j,N){
    dp[i+1][j] += dp[i][j] * (1-P[i]);
    dp[i+1][j+1] += dp[i][j] * (P[i]);
  }
  double ans = 0;
  for(int i=(N+1)/2;i<=N;i++){
    ans += dp[N][i];
  }
  cout << fixed << setprecision(9);
  cout << ans << endl;
}

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

int comp(const void *a,const void *b){
	return *(int*)a - *(int*)b;
}

int main(){
	int n;
	int d[100002];
	int i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",d+i);
	}
	qsort(d,n,sizeof(int),comp);
	printf("\n%d\n", d[n/2]-d[n/2-1]);
	return 0;
}

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

using namespace std;

int main(){
    double n, m, d;
    cin >> n >> m >> d;
    if(d>=n){
        printf("%.08lf\n", (double) 0);
    }
    else if(2*d>=n || d == 0){
        printf("%.08lf\n", (m-1)*((double)1/n));
    }
    else{
        printf("%.08lf\n", (m-1)*((1/n)*(2*d)/n + (2/n)*((n-2*d)/n)));
    }
}

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

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

    string s, t;
    cin >> s >> t;

    map<char, int> mp_s, mp_t;
    string cnv_s = "";
    string cnv_t = "";
    int ptr_s = 0;
    int ptr_t = 0;
    for(int i = 0; i < s.size(); ++i){
        if(mp_s[s[i]] == 0){
            cnv_s += 'a' + ptr_s;
            mp_s[s[i]] = ptr_s+1;
            ++ptr_s;
        }
        else cnv_s += 'a' + mp_s[s[i]] - 1;

        if(mp_t[t[i]] == 0){
            cnv_t += 'a' + ptr_t;
            mp_t[t[i]] = ptr_t+1;
            ++ptr_t;
        }
        else cnv_t += 'a' + mp_t[t[i]] - 1;
    }

    if(cnv_s == cnv_t) puts("Yes");
    else puts("No");
    
}

Measured memory_bytes: 4348
#![allow(unused_mut)]
#![allow(non_snake_case)]

#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        n: i64,
        m: usize,
        lr: [(i64, i64); m],
    }
    let mut l = lr[0].0;
    let mut r = lr[0].1;
    for i in 0..m {
        if l < lr[i].0 {
            l = lr[i].0;
        }
        if r > lr[i].1 {
            r = lr[i].1;
        }
    }
    if l <= r {
        if l <= n && n <= r {
            println!("{}", n - l + 1);
        } else if r <= n {
            println!("{}", r - l + 1);
        } else {
            println!("0");
        }
    } else {
        println!("0");
    }
}

Measured memory_bytes: 8444
import math

def prime(num):
    count = 0
    for i in range(2, math.floor(math.sqrt(num)) + 1):
        if num == 2:
            break
        if i % 2 == 0 and i != 2:
            continue
        if X % i == 0:
            count += 1

    if count == 0:
        return True
    else:
        return False


X = int(input())

while True:
    if prime(X):
        print(X)
        break
    else:
        X += 1


Measured memory_bytes: 3060
#include <stdio.h>
#define MAX 100000

int partition(int,int,int[]);

int main(){
  int n,i,o;
  int A[MAX];
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  o=partition(0,n-1,A);
  for(i=0;i<n;i++){
    if(i>0)printf(" ");
    if(i==o)printf("[");
    printf("%d",A[i]);
    if(i==o)printf("]");
    
    
  }
  printf("\n");
  return 0;
}


int partition(int b,int a,int A[]){
  int x,y,i,j;
  x=A[a];
  i=b-1;
  for(j=b;j<a;j++){
    if(A[j]<=x){
      i++;
      y=A[i];
      A[i]=A[j];
      A[j]=y;
      
      }
  }
  y=A[i+1];
  A[i+1]=A[a];
  A[a]=y;
  return i+1;
}



Measured memory_bytes: 2108