akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(x) scanf("%d", &x)
#define sc(x) scanf("%c", &x)
#define sl(x) scanf("%lld", &x)
#define pl(x) printf("%lld\n", x)
#define pi(x) printf("%d\n", x)
#define pii pair <int, int>
#define pll pair <long long, long long>
#define gu getchar_unlocked
#define pu putchar_unlocked
#define setbits __builtin_popcountll
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define speed ios::sync_with_stdio(false)

const int N = 100005;

int A[25], B[25], C[25];

int main(){
    int n;
    si(n);
    for(int i = 1; i <= n; i++){
    	si(A[i]);
    }
    for(int i = 1; i <= n; i++){
    	si(B[i]);
    }
    for(int i = 1; i <= n; i++){
    	si(C[i]);
    }
    int prev = -1;
    int sum = 0;
    for(int i = 1; i <= n; i++){
    	int curr = A[i];
    	sum += B[curr];
    	if(prev == curr - 1){
    		sum += C[prev];
    	}
    	prev = curr;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#if 0
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2015

#endif

#include <iostream>
#include <cstring>
using namespace std;

const int diagcnt = 1500*1000*2 + 10;
int diaggrp[diagcnt];

#define REP(var, start, count) for(int var=start; var<count; var++)

int main(void) {
	
	while(true) {
		int n, m;
		cin >> n >> m;
		if ( n == 0 ) { break; }
		
		int h[1510];
		int w[1510];
		
		memset(diaggrp, 0, sizeof(int)*diagcnt);
		
		int y = 0;
		h[0] = 0;
		REP(i, 0, n) {
			int hhh;
			cin >> hhh;
			y += hhh;
			h[i+1] = y;
		}
		
		int x = 0;
		w[0] = 0;
		REP(i, 0, m) {
			int www;
			cin >> www;
			x += www;
			w[i+1] = x;
		}
		
		REP(j1, 0, n+1) {
			REP(j2, 0, m+1) {
				int diff = h[j1] - w[j2];
				diaggrp[diff + 1500*1000 + 5] += 1;
			}
		}
		
		int sum = 0;
		REP(i, 0, diagcnt) {
			if ( diaggrp[i] >= 2 ) {
				sum += (diaggrp[i] * (diaggrp[i]-1) / 2);
			}
		}
		
		cout << sum << endl;
	}
}

Measured memory_bytes: 14772
#include <iostream>
#include <cmath>
#include <vector>
#include <stack>
#include <algorithm>

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

ll N;
int tmp;
vi vec;
stack<int> ans;
bool update = true;

void show_vec(){
    rep(i,vec.size()) cout << vec[i] << " ";
    cout << endl;
}

bool solve(){
    while(update){
        update = false;
        for(int i = vec.size()-1; i >= 0; --i){
            if(vec[i] == i+1){
                // show_vec();
                // printf("vec[%d] is %d\n",i,i+1);
                vec.erase(vec.begin()+i);
                ans.push(i+1);
                update = true;
                break;
            }
        }
    }
    return (vec.size() == 0);
}

int main(){
    cin >> N;

    rep(i,N){
        cin >> tmp;
        vec.push_back(tmp);
    }

    if(solve()){
        while(!ans.empty()){
            cout << ans.top() << endl;
            ans.pop();
        }
    } else
        cout << -1 << endl;
}


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

int main() {
    int height[10];
    for (int i = 0; i < 10; i++) {
        cin>>height[i];
    }
    for (int i = 0; i < 10; i++) {
        for (int j = i; j < 10; j++) {
            int max = height[i];
            int c = i;
            if (height[j] > max) {
                max = height[j];
                c = j;
            }
            int temp;
            temp = height[c];
            height[c] = height[i];
            height[i] = temp;
        }
    }
    cout<<height[0]<<endl;
    cout<<height[1]<<endl;
    cout<<height[2]<<endl;
    return 0;
}

Measured memory_bytes: 1160
//gcc -std=gnu11 -O2 -o a.out Main.c -lm

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void)
{
	
	int i, j;
	char s[11], ans[11];
	int ret;
	
	ret = scanf("%s", s);
	
	memset(ans, 0, sizeof(ans));
	j = 0;
	for(i = 0 ; s[i] ; i++){
		switch(s[i]){
			case '0':
				ans[j++] = '0';
				break;
			case '1':
				ans[j++] = '1';
				break;
			case 'B':
				if(j){
					ans[--j] = '\0';
				}
				break;
		}
	}
	
	printf("%s\n", ans);
	
	return 0;
}


Measured memory_bytes: 128
import numpy as np
from scipy.ndimage.interpolation import shift as scipy_shift

class shift:
    def __init__(self,a):
        self.arr = a
        self.height = a.shape[0]
        self.width = a.shape[1]
    def shifted(self,down,right):
        temp1 = self.arr[list(np.linspace(-down, -down + self.height - 1, self.height).astype(np.int32) % self.height), :]
        temp2 = temp1[:, list(np.linspace(-right, -right + self.width - 1, self.width).astype(np.int32) % self.width)]
        return temp2
    def shifted_zero(self,down,right):
        index_vertical = np.arange(self.height)
        index_horizontal = np.arange(self.width)
        temp1 = self.arr[list(scipy_shift(index_vertical, down, output = int, mode = 'constant')),:]
        temp2 = temp1[:,list(scipy_shift(index_horizontal, right, output = int, mode = 'constant'))]
        return temp2
    def is_sym(self,down,right):
        temp = self.shifted(down,right)
        delta = temp - temp.T
        return(not (delta*delta).sum())



N = int(input())
array = [list(input()) for i in range(N)]
array_int = np.array([[ord(i) for i in j] for j in array])

if N >= 2:
    count = np.array([shift(array_int).is_sym(0,i)*(N-i) for i in range(N)]).sum() + np.array([shift(array_int).is_sym(i,0)*(N-i) for i in range(1,N)]).sum()
else:
    count =  int(shift(array_int).is_sym(0,0))
print(count)

Measured memory_bytes: 25388
use proconio::fastout;
use proconio::input;

#[fastout]
fn main() {
    input! { k: i64, }
    let limit = if k % 7 == 0 { 9 * k / 7 } else { 9 * k };
    let mut ans = -1;
    let mut m = 1 % limit;
    for i in 1..=limit {
        m = (m * 10) % limit;
        if m == 1 {
            ans = i;
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2172
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return ans.x;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n , k;
cin>>n>>k;
int arr[n];
for(int i = 0 ; i < n ; i++){
	cin>>arr[i];
}
long double dp[n];
for(int i = 0 ; i  < n ;i++){
     dp[i] = ((arr[i] + 1)/2.0);
}
long double sum = 0;
for(int i = 0 ; i < k ; i++){
  sum += dp[i];
}
long double maxi = sum;
for(int i = k ; i < n ;i++){
  // maxi = max(maxi , sum);
     sum -= dp[i-k];
     sum += dp[i];
     maxi = max(maxi , sum);
}
cout<<fixed<<setprecision(10)<<maxi<<endl;
}


Measured memory_bytes: 4992
#include<iostream>
#include<string>

using namespace std;

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

	if (n == 1) {
		cout << "Hello World";
	}
	if (n == 2) {
		int a, b;
		cin >> a>>b;
		cout << a+b;
	}


	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 100005
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
#define mp make_pair
#define ff first
#define ss second

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

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

map<int,int> cnt;

int main(){
	n=read();
	for (int i=1;i<=n;i++) a[i]=read(),++cnt[a[i]];
	sort(a+1,a+n+1); b[1]=a[1],b[2]=a[n]; --cnt[a[1]],--cnt[a[n]];
	for (int i=3;i<=n;i++){
		b[i]=b[i-1]^b[i-2];
		if (!cnt[b[i]]){puts("No"); return 0;}
		--cnt[b[i]];
	}
	if (b[1]!=(b[n]^b[n-1])){puts("No"); return 0;}
	if (b[2]!=(b[1]^b[n])){puts("No"); return 0;}
	puts("Yes");
    return 0;
}


Measured memory_bytes: 4224
r,c = map(int,input().split())
under = [0 for i in range(c+1)]
for i in range(r):
    l = list(map(int,input().split()))
    l.append(sum(l))
    for n in range(c+1):
        under[n]+=l[n]

    print(*l)
print(*under)


Measured memory_bytes: 5636
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> VI;
typedef vector<long long int> VLLI;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b and c == b) {
        cout  << "No" << '\n';
    } else if (a == b or b == c or c == a) {
        cout << "Yes" << '\n';
    } else {
               cout  << "No" << '\n';
 
    }
}



Measured memory_bytes: 256
#![allow(unused_imports)]
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{fastout, input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize, k: usize,
        mut a: [i64; n],
    }
    let m = 1000000007i64;
    let mod_product = |acc: i64, &value: &i64| {
        (acc * value).rem_euclid(m)
    };

    if k == n || k % 2 == 1 && a.iter().all(|v| *v <= 0) {
        a.sort_by_key(|v| -*v);
        let ans = a.iter().take(k).fold(1, mod_product);
        println!("{}", ans);
        return;
    }

    a.sort_by_key(|v| Reverse(v.abs()));
    let mut plus = Vec::new();
    let mut minus = Vec::new();
    for i in 0..n {
        if a[i] >= 0 {
            plus.push(a[i]);
        } else {
            minus.push(a[i]);
        }
    }

    let mut ppos = 0;
    let mut mpos = 0;
    let mut vals = Vec::new();
    let mut retry = false;
    while vals.len() < k {
        if vals.len() < k - 1 && ppos + 1< plus.len() && mpos + 1 < minus.len() {
            if plus[ppos] * plus[ppos+1] < minus[mpos] * minus[mpos+1] {
                vals.push(minus[mpos]);
                vals.push(minus[mpos+1]);
                mpos += 2;
            } else {
                vals.push(plus[ppos]);
                vals.push(plus[ppos+1]);
                ppos += 2;
            }
        } else if vals.len() < k - 1 && mpos + 1 < minus.len() {
            vals.push(minus[mpos]);
            vals.push(minus[mpos+1]);
            mpos += 2;
        } else if ppos < plus.len() {
            vals.push(plus[ppos]);
            ppos += 1;
        } else {
            retry = true;
            break;
        }
    }
    let ans = if !retry {
        vals.iter().fold(1, mod_product)
    } else {
        a.sort_by_key(|v| v.abs());
        assert!(k % 2 == 1);
        assert!(a.iter().filter(|v| **v < 0).count() %2 == 0);
        a.iter().take(k).fold(1, mod_product)
    };
    println!("{}", ans);
}


Measured memory_bytes: 9820
#include <bits/stdc++.h>
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N; cin >> N;
	V<ll> a(N); rep(i,N) cin >> a[i];
	ll S = accumulate(all(a),0LL);
	ll ans = 1e18;
	ll L = a[0];
	rep1(i,N-1){
		ll R = S-L;
		chmin(ans,abs(L-R));
		L += a[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
from collections import deque

n, m = map(int, input().split())
AB = [[int(x) for x in input().split()] for _ in range(m)]

# representation matrix
repn = [[] for j in range(n + 1)]
for a, b in AB:
    repn[a].append(b)
    repn[b].append(a)


# Minimum Spanning Tree
tree = [set() for i in range(n + 1)]
visited = [False] * (n + 1)
visited[1] = True
q = deque([1])

while q:
    u = q.popleft()
    for v in repn[u]:
        if visited[v]:
            continue
        visited[v] = True
        tree[u].add(v)
        tree[v].add(u)
        q.append(v)


# define directions of the edges other than that of MST
degree = [0] * (n + 1)
ans = []

for a, b in AB:
    if b in tree[a]:
        continue
    ans.append('{} {}'.format(a, b))
    degree[a] += 1


# defining orientations
def dfs(u = 1, parent = None):
    for v in tree[u]:
        if v == parent:
            continue
        dfs(v, u)
        if degree[v] % 2 == 0:
            ans.append('{} {}'.format(u, v))
            degree[u] += 1
        else:
            ans.append('{} {}'.format(v, u))
            degree[v] += 1

dfs()

if degree[1] % 2 == 1:
    print(-1)
else:
    print('\n'.join(ans))


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

int main()
{
    int n, out=0;
    cin >> n;
    string s[n];
    rep(i, n) cin >> s[i];

    set<string> values;
    rep(i, n)
    {
        values.insert(s[i]);
    }

    cout << values.size() << endl;
    return 0;
}

Measured memory_bytes: 25428
#define _USE_MA_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int a,b;
    cin>>a>>b;
    int ans=0;
    if(a>b)ans+=a--;
    else ans+=b--;
    if(a>b)ans+=a--;
    else ans+=b--;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var t = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < t; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var k = int.Parse(line[1]);
            string[] line2 = Console.ReadLine().Trim().Split(' ');
            var a = Array.ConvertAll(line2, int.Parse);
            var b = new int[n - 1];
            for (int j = 1; j < n; j++) b[j - 1] = a[j] - a[j - 1];
            Array.Sort(b);
            var ret = 0;
            for (int j = 0; j < n - k; j++) ret += b[j];
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 27436
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#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;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;


vl pow_;
void pow_ini(ll n) {
	pow_.clear();
	pow_.push_back(n);
	rep(j, 62) {
		ll nxt = pow_[j] * pow_[j];
		nxt %= mod;
		pow_.push_back(nxt);
	}
	return;
}

ll pow1(ll k) {
	ll ans = 1;
	rep(ntmp, 62) {
		if ((k >> ntmp) % 2 == 1) {
			ans *= pow_[ntmp];
			ans %= mod;
		}
	}
	return ans;
}

vl fact;
vl fact_inv;

void fact_ini(ll n) {
	fact.resize(n + 1);
	fact[0] = 1;
	for (ll i = 1; i <= n; i++) {
		ll fact_tmp = fact[i - 1] * i;
		fact_tmp %= mod;
		fact[i] = fact_tmp;
	}
	fact_inv.resize(n + 1);
	pow_ini(fact[n]);
	fact_inv[n] = pow1(mod - 2);
	for (ll i = n - 1; i >= 0; i--) {
		fact_inv[i] = fact_inv[i + 1] * (i + 1);
		fact_inv[i] %= mod;
	}
}

ll nPm(ll n, ll m) {
	assert(m >= 0);
	assert(n < fact.size());
	assert(n >= m);
	ll ans = fact[n] * fact_inv[n - m];
	ans %= mod;
	return ans;
}

ll nCm(ll n, ll m) {
	assert(m >= 0);
	assert(n < fact.size());
	assert(n >= m);
	ll ans = fact[n] * fact_inv[m];
	ans %= mod;
	ans *= fact_inv[n - m];
	ans %= mod;
	return ans;
}

int main() {
	fact_ini(5500000);
	ll N, M;
	cin >> N >> M;
	ll ans = 0;
	for (int i = 0; i <= N; i++) {
		ll anstmp = nCm(N, i) * nPm(M - i, N - i);
		anstmp %= mod;
		if (i % 2 == 1) {
			anstmp *= -1;
			anstmp += mod;
			anstmp %= mod;
		}
		ans += anstmp;
		ans %= mod;
	}
	ans *= nPm(M, N);
	ans %= mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 89180
import std.stdio, std.algorithm;

void main() {
  for(int times; scanf("%d", &times), times != 0;) {
    int[] arr = new int[](times);
    long ans, sum;
    foreach(i; 0..times) scanf("%d", &arr[i]);
    sort(arr);
    for(int i = 0; i < arr.length; i++) {
      ans += (times - i - 1) * arr[i];
    }
    writeln(ans);
  }
}

Measured memory_bytes: 1084
#include<bits/stdc++.h>
using namespace std;
int serch(double speed,int floor)
{
    if(speed<9.8*sqrt((5*floor-5)/4.9))return floor;
    return serch(speed,floor+1);
}
int main()
{
    int n;
    double x,y,qux;
    while(cin>>qux){
        n=serch(qux,1);
        cout<<n<<endl;
    }
}

Measured memory_bytes: 1224
a, b = input().split()

a_str = [0] * int(b)
b_str = [0] * int(a)

for i in range(int(b)):
    a_str[i] = a
    
for i in range(int(a)):
    b_str[i] = b
    
if a_str < b_str:
    print(''.join(a_str))
else:
    print(''.join(b_str))

Measured memory_bytes: 3060
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long int;
 
#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define MOD 1000000007 //10^9+7
//#define MOD 1
 
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
const int MAX = 2000;

long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


void sosuu(ll n, vector<ll> &v){

  vector<ll> num(n, 0);

  FOR(i, 1, sqrt(n)){
    if(num[i]==0){
      FOR(j, 0, n/i){
        num[i+(j*i)] = 1;
      }
    }
  }
  REP(i, n){
    if(num[i]==0) v.push_back(i+1);
  }
}

ll GetDigit(ll num){
    ll digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}


int main(void){
 
  ll n;
  cin>>n;
  vector<ll> a(n);
  vector<ll> b(n);
  vector<ll> sub(n);
  ll suma = 0;
  ll sumb = 0;

  REP(i, n){
    cin>>a[i];
    suma += a[i];
  }
  REP(i, n){
    cin>>b[i];
    sumb += b[i];
    sub[i] = a[i]-b[i];
  }

  ll count = 0;

  if(suma < sumb){
    cout<<"-1"<<endl;
    return 0;
  }
  
  sort(sub.begin(), sub.end());
  ll i = 0;
  ll j = n-1;
  while(sub[i]<0){
    if(abs(sub[i]) > sub[j]){
      sub[i] += sub[j];
      count++;
      j--;
    }else{
      sub[j] += sub[i];
      count++;
      i++;
    }
  }
  if(sub[0]>=0) cout<<"0"<<endl;
  else cout<<count+1<<endl;

  return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main{
	public static void main(String[]org){
    	
      Scanner scan = new Scanner(System.in);
      String s = scan.nextLine();
      String result = "";
      if(s.charAt(1)=='B'){
		result = "ARC";
      }
      else{
        result ="ABC";
      }
     System.out.println(result);
	}
}


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

int main() {

  int N, A, f = 0, g = 0;
  cin >> N >> A;
  
  while (true) {
    if (A % 2 == 1) break;
    A = A / 2;
    g++;
  }
    
  for (int i = 0; i < N - 1; i++) {
    cin >> A;
      
    while (true) {
      if (A % 2 == 1) break;
      A = A / 2;
      f++;
    }
      
    if (f < g) g = f;
    f = 0;
  }

  cout << g << endl;
}

Measured memory_bytes: 3588
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ll long long
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define repr(i, a, n) for (ll i = (n); i >= (a); --i)
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int pi = 3.1415926536;
const int MOD = 1000000007;
const int MAX = 510000;

void Main() {
  int n, m, x;
  cin >> n >> m >> x;
  int cnt = 0;
  rep(i, 0, m) {
    int a;
    cin >> a;
    if (a < x)
      cnt++;
  }
  cout << min(cnt, m - cnt) << endl;
}

int main() {
  std::cin.tie(nullptr);                 // 標準入出力高速化
  std::ios_base::sync_with_stdio(false); // CとC++の入出力出力を非同期
  std::cout << std::fixed << std::setprecision(15); // 小数を10進数表示
  Main();
}

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

void dec(map<long long, long long> &ma, long long a) {
    ma[a]--;
    if (ma[a] == 0) {
        ma.erase(a);
    }
}

int main() {
    int N; cin >> N;
    vector<long long> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];
    map<long long, long long> ma;
    for (int i = 0; i < N; ++i) ma[-a[i]]++;

    long long res = 0;
    for (int i = 0; i < N && !ma.empty(); ++i) {
        long long val = -ma.begin()->first;
            
        dec(ma, -val);
        long long po = 1;
        while (po <= val) po *= 2;
        long long rem = po - val;
        if (ma.count(-rem)) {
            ++res;
            dec(ma, -rem);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 14336
#D問題
N = int(input())
A = list(map(int,input().split()))

srui = [0]
xrui = [0]

for a in A:
    srui.append(srui[-1]+a)
    xrui.append(xrui[-1]^a)
    
#print(srui,xrui)
ans = 0
J = 1
for i in range(N):
    I = i+1
    while J <= N and (srui[J]-srui[I-1]) == (xrui[J]^xrui[I-1]):
        J+=1
    J-=1
    ans += J-I+1
            
print(ans)

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

using namespace std;

int n;

void solve(){
    int i,j;
    string str;
    cin >> n;
    vector<long long> d(n),c(n);
    long long s = 0,cs = 0;
    for(i = 0;i < n;i++){
        cin >> d[i] >> c[i];
        s += d[i]*c[i];
        cs += c[i];
    }
    long long ans = cs-1;
    ans += s/9;
    if(s % 9 == 0) ans--;
    cout << ans << endl;
}

int main(){
    solve();
}


Measured memory_bytes: 3328
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    s = [2 if i&1 else 1 for i in a]
    ans = 0
    for b in range((1<<n)-1):
        res = 1
        for i in range(n):
            res *= (s[i]<<(b>>i))%3
        ans += res
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 39408
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
#define   ll long long int
#define inf 1000000
vector<string> s(1005);
int vis[1005][1005];
int h,w;
void dfs(int x,int y,int k){
vis[x][y]=k;
if(x-1>=0  && !vis[x-1][y] &&s[x-1][y]!='#'){
    dfs(x-1,y,k);
}
if(y-1>=0  && !vis[x][y-1] &&s[x][y-1]!='#'){
    dfs(x,y-1,k);
}
if(x+1<h  && !vis[x+1][y] &&s[x+1][y]!='#' ){
    dfs(x+1,y,k);
}
if(y+1<w  && !vis[x][y+1] &&s[x][y+1]!='#' ){
    dfs(x,y+1,k);
}

}



int main(){

cin>>h>>w;
int sx,sy;
cin>>sx>>sy;
sx--;
sy--;
int ex,ey;
cin>>ex>>ey;
ex--;
ey--;
for(int i=0;i<h;i++)
    cin>>s[i];
memset(vis,0,sizeof(vis));
int k=1;
for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
        if(s[i][j]=='#')
            continue;
        if(!vis[i][j]){
            dfs(i,j,k);
            k++;
        }
    }
}
vector<vector<pair<int,int> > > adjl(h*w);
for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
        for(int x=max(i-2,0);x<=min(i+2,h-1);x++){
            for(int y=max(j-2,0);y<=min(j+2,w-1);y++){
                if(s[x][y]=='#')
                    continue;
                adjl[i*w + j].push_back({x*w+y,vis[x][y]!=vis[i][j]});
            }
        }
    }
}

set<pair<int ,int> > q;
int d[h*w];
for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
        d[i*w+j]=inf;
    }
}
d[w*sx+sy]=0;
q.insert({0,w*sx+sy});
while(!q.empty()){
    int dist=q.begin()->first;
    int node=q.begin()->second;
    q.erase(q.begin());
    for(auto x: adjl[node]){
        if(d[node]+ x.second < d[x.first]){
            q.erase({d[x.first],x.first});
            d[x.first]=d[node]+ x.second;
            q.insert({d[x.first],x.first});
        }
    }
}
if(d[w*ex+ey]==inf)
    cout<<-1<<endl;
else
    cout<<d[w*ex+ey]<<endl;


}


Measured memory_bytes: 180404
///
// File:  b.go
// Author: ymiyamoto
//
// Created on Sun Feb 18 21:01:52 2018
//
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	arr := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&arr[i])
	}
	sort.Ints(arr)

	alice := 0
	bob := 0
	count := 0
	for i := N - 1; i >= 0; i-- {
		if count%2 == 0 {
			alice += arr[i]
		} else {
			bob += arr[i]
		}
		count++
	}
	fmt.Println(alice - bob)
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;
int a[MAXN];

void read(){
	scanf("%d%d", &n,&m);
	for(int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
}

void solve(){
	int now = 0, cnt = 0;
	int mxd = 0;
	int ans = 0;
	for(int i = n; i >= 1; i--){
		if (now - a[i] > mxd){
			mxd = now - a[i];
			ans = 1;
		}
		else if (now - a[i] == mxd){
			ans += cnt;
		}
		if (a[i] > now){
			now = a[i];
			cnt = 1;
		}
		else if (a[i] == now)
			cnt++;
	}
	printf("%d\n", ans);
}

void printans(){

}
	

int main(){
	int T = 1;
//	cin>>T;
	while(T--){
		read();
		solve();
		printans();
	}
	return 0;
} 


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int n,m,i,vis[100005],x,y,seq[100005],cnt=0,pre;
vector<int> s[100005];
void dfs1(int p)
{
	int i,v;
	seq[++cnt]=p;
	vis[p]=1;
	for(i=0;i<s[p].size();i++)
	{
		v=s[p][i];
		if(vis[v])continue;
		dfs1(v);
		break;
	}
}
void dfs2(int p)
{
	int i,v;
	for(i=0;i<s[p].size();i++)
	{
		v=s[p][i];
		if(vis[v])continue;
		vis[v]=1;
		dfs2(v);
		seq[++cnt]=v;
		break;
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++)	
	{
		scanf("%d%d",&x,&y);
		s[x].push_back(y);
		s[y].push_back(x);
	}
	dfs1(1);
	pre=cnt;
	dfs2(1);
	printf("%d\n",cnt);
	for(i=pre+1;i<=cnt;i++)printf("%d ",seq[i]);
	for(i=1;i<=pre;i++)printf("%d ",seq[i]); 
	return 0;
} 

Measured memory_bytes: 7168
#pragma gcc optimize("Ofast")

#include "bits/stdc++.h"
using namespace std;
typedef int64_t lld;
typedef pair<int,int> pii;
typedef pair<lld,lld> pll;
typedef pair<int,pll> pip;
typedef pair<pll,int> ppi;
typedef pair<lld,pll> plp;
typedef pair<pll,lld> ppl;
typedef pair<pll,pll> ppp;
template<typename T>
using maxHeap = priority_queue<T,vector<T>,less<T>>;
template<typename T>
using minHeap = priority_queue<T,vector<T>,greater<T>>;
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define endl '\n'
#define jizz cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
inline void input(int &_x) {
    _x = 0;
    int _tmp = 1; char _tc = getchar();
    while((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();
    if(_tc == '-') _tc = getchar(), _tmp = -1;
    while(_tc >= '0' && _tc <= '9') _x = _x*10+(_tc-48), _tc = getchar();
    _x *= _tmp;
}
inline void output(int _x) {
    char _buff[20]; int _f = 0;
    if(_x == 0)putchar('0');
    while(_x > 0)
    {
        _buff[_f++] = _x%10+'0';
        _x /= 10;
    }
    for(_f-=1; _f >= 0; _f--)
        putchar(_buff[_f]);
    putchar('\n');
}
template<typename Iter>
ostream& _out(ostream &s, Iter b, Iter e) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}
template<class T1,class T2>
ostream& operator<<(ostream& out, pair<T1,T2> p) {
    return out << '(' << p.first << ", " << p.second << ')';
}
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) {
     return _out(s,c.begin(),c.end());
 }
#ifdef erd1
    #define pprint(x) cerr<<__PRETTY_FUNCTION__<<":"<<__LINE__<<" - "<<(#x)<<"="<<(x)<<endl
#else
    #define pprint(x)
#endif

// code starts here
struct dsu{
    vector<int> vec, size;
    dsu(int n){
        vec.resize(n+1);
        iota(all(vec), 0);
        size.resize(n+1, 1);
    }
    int root(int i){
        return vec[i] == i ? i : (vec[i] = root(vec[i]));
    }
    inline void join(int i, int j){
        i = root(i), j = root(j);
        if(i == j)return;
        if(size[i] < size[j])swap(i, j);
        vec[j] = i;
        size[i] += size[j];
    }
};
vector<pair<pii, int>> ans;
vector<int> res;
signed main(){
    int n, k, l;
    cin >> n >> k >> l;
    dsu dsuk(n), dsul(n);
    for(int i = 0; i < k; i++){
        int a, b;
        cin >> a >> b;
        dsuk.join(a, b);
    }
    for(int i = 0; i < l; i++){
        int a, b;
        cin >> a >> b;
        dsul.join(a, b);
    }
    ans.resize(n);res.resize(n);
    for(int i = 1; i <= n; i++)
        ans[i-1] = {{dsuk.root(i), dsul.root(i)}, i-1};
    sort(all(ans));
    ans.pb({{-1,-1}, 0});
    for(int i = 0, last = 0; i <= n; i++){
        if(ans[i].ff == ans[last].ff) continue;
        for(int j = last; j < i; j++)
            res[ans[j].ss] = i - last;
        last = i;
    }
    for(auto i: res)cout << i << " ";cout << endl;
}


Measured memory_bytes: 9984
#ABC066C
import pprint
n = int(input())
ai = list(map(int, input().split()))
bi = []
ran = 0
if n%2==0:
    for i in range(n//2):
        bi.append(ai[i+i+1])
    bi.reverse()
    for i in range(n//2):
        bi.append(ai[i+i])
else:
    for i in range(n//2+1):
        bi.append(ai[i+i])
    bi.reverse()
    for i in range(n//2):
        bi.append(ai[i+i+1])
        
for b in bi:
    print(b, end=" ")

Measured memory_bytes: 25796
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

int main() {
        int n;
        scanf("%d", &n);
        vector<int> cap(n);
        for (int i = 0; i < n; i ++) {
                scanf("%d", &cap[i]);
        }
        vector<int> a(n, 0);
        int q;
        scanf("%d", &q);
        while (q --) {
                int t, x, d;
                scanf("%d%d%d", &t, &x, &d);
                x --;
                if (t == 1) {
                        a[x] += d;
                        if (a[x] > cap[x]) {
                                printf("%d\n", x + 1);
                                return 0;
                        }
                } else {
                        a[x] -= d;
                        if (a[x] < 0) {
                                printf("%d\n", x + 1);
                                return 0;
                        }
                }
        }
        printf("0\n");
        return 0;
}




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

int cnt[4][3][10];
int main() {
	int n; cin >> n;
	rep(i, n) {
		int b, f, r, v; cin >> b >> f >> r >> v; b--; f--; r--;
		cnt[b][f][r] += v;
	}
	rep(i, 4) {
		rep(j, 3) {
			rep(k, 10) {
				cout << ' ' << cnt[i][j][k];
			}
			cout << endl;
		}
		if (i < 3) {
			rep(j, 20)cout << '#';
			cout << endl;
		}
	}
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pci pair<char, int>
#define pic pair<int, char>
#define plvl pair<long long, vector<long long> >
#define pcvc pair<char, vector<char> >


using namespace std;

const int mod = 1e9 + 7;

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

template <typename T>
void show1(vector<T> dp) {
	for(auto d : dp) {
		cout << d << " ";
	}
	cout << "\n";
}

template <typename T>
void show2(vector<vector<T> > dp) {
	for(auto d : dp) {
		for(auto dd : d) {
			cout << dd << " ";
		}
		cout << "\n";
	}
}

void executeCode() {
	ll n;
	cin >> n;
	vector<ll> vec(n);
	for(auto &v : vec) {
		cin >> v;
	}
	sort(vec.begin(), vec.end(), greater<ll>());
	ll cnt = 0;
	priority_queue<ll> q;
	q.push(vec[1]);
	q.push(vec[1]);
	ll i = 2;
	cnt = 0 + vec[0];
	while(i < n) {
		ll c = q.top();
		q.pop();
		cnt += c;
		q.push(vec[i]);
		q.push(vec[i]);
		i++;
	}
	cout << cnt << "\n";
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int tt = 1;
	// cin >> tt;
	while(tt--) {
		executeCode();	
	}
	return 0;
}

Measured memory_bytes: 6904
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;
#define N 3
#define N2 9

struct Puzzle{
  int f[N2];
  int space;
  string path;

  bool operator < ( const Puzzle &p ) const {
    for(int i=0;i<N2;i++){
      if(f[i] == p.f[i]) continue;
      return f[i]>p.f[i];
    }
    return false;
  }
};

static const int dx[4] = {-1,0,1,0};
static const int dy[4] = {0,-1,0,1};
static const char dir[4] = {'u','l','d','r'};

bool isTarget(Puzzle p){
  for(int i=0;i<N2;i++)
    if(p.f[i] != (i+1)) return false;
  return true;
}

string bfs(Puzzle s){
  queue<Puzzle> Q;
  map<Puzzle,bool> V;
  Puzzle u,v;
  s.path = "";
  Q.push(s);
  V[s] = true;

  while(!Q.empty()){
    u=Q.front(); Q.pop();
    if(isTarget(u)) return u.path;
    int sx = u.space / N;
    int sy = u.space % N;
    for(int r=0;r<4;r++){
      int tx=sx+dx[r];
      int ty=sy+dy[r];
      if(tx<0 || ty<0 || tx>=N || ty>=N) continue;
      v=u;
      swap(v.f[u.space],v.f[tx*N+ty]);
      v.space = tx * N + ty;
      if(!V[v]){
	V[v] = true;
	v.path += dir[r];
	Q.push(v);
      }
    }
  }
  return "unsolvable";
}

int main(){
  Puzzle in;

  for(int i=0;i<N2;i++){
    cin >> in.f[i];
    if(in.f[i] == 0){
      in.f[i] = N2;
      in.space = i;
    }
  }
  string ans = bfs(in);
  cout << ans.size() << endl;

  return 0;
}



Measured memory_bytes: 30616
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = []
for i in range(m):
    ab.append(list(map(int, input().split())))
keys = [i+1 for i in range(n)]
good_or_bad = {key:0 for key in keys} # 0がgood
for i in range(m):
    a = ab[i][0]
    b = ab[i][1]
    if h[a-1]>h[b-1]:
        good_or_bad[b] = 1
    elif h[a-1]<h[b-1]:
        good_or_bad[a] = 1
    elif h[a-1]==h[b-1]:
        good_or_bad[a] = 1
        good_or_bad[b] = 1
cnt = 0
for key, item in good_or_bad.items():
    if item == 0:
        cnt += 1
print(cnt)


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

int main(){
	int N, K, ans = 1000000000;
	cin >> N >> K;
	int h[N];
	for(int i = 0; i < N; i++) cin >> h[i];
	sort(h, h+N, greater<int>());
	for(int i = 0; i <= N - K; i++){
		if(ans > h[i] - h[i+K-1]) ans = h[i] - h[i+K-1];
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

bool found(long double i, int a, int b) {
	int v1 = (i * 8) / 100;
	int v2 = (i * 10) / 100;

	if (v1 == a && v2 == b) {
		return 1;
	}

	return 0;
}

int main() {
	int a, b;

	cin >> a >> b;

	for (int i = 1; i < 2000; ++i) {
		if (found(i, a, b)) {
			cout << i << endl;
			return 0;
		}
	}

	cout << -1 << endl;

	return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  int l = 1;
  int r = n;
  rep(i,m){
    int li,ri;
    cin >> li >> ri;
    l = max(li,l);
    r = min(ri,r);
  }
  if(r - l + 1>=0){
    cout << r - l + 1<< endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
package main

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

var stdInScanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	stdInScanner.Scan()
	i, _ := strconv.Atoi(stdInScanner.Text())
	return i
}

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

func main() {
	stdInScanner.Split(bufio.ScanWords)

	X := nextInt()

	if 30 <= X {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1772
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
int main(){
    int n;cin>>n;
    ll m=998244353;
    vector<ll> d(n),count(n,0);
    for(int i=0;i<n;i++){
        cin>>d[i];
        count[d[i]]++;
    }
    if(d[0]!=0){
        cout<<0<<endl;
        return 0;
    }
    if(count[0]!=1){
        cout<<0<<endl;
    }
    else{
        ll ans=1;
        for(int i=1;i<n;i++){
            for(int j=0;j<count[i];j++){
                ans*=count[i-1];
                ans%=m;
            }
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
  @SuppressWarnings("resource")
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char[] arr = sc.next().toCharArray();

    System.out.println(arr[2] == arr[3] && arr[4] == arr[5] ? "Yes": "No");
  }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
unordered_map<int,int>mp ;
int main()
{
    int n,z=0 ; string s,as="" ;
    vector<int>v ;
    cin>>s>>n ;
    for(int i = 0 ; i < n ; i++)
    {
        int x ; cin>>x ; mp[x]=1 ;
    }
    for(int i = 0 ; i < 10 ; i++)
    {
        if(!mp[i]){if(i==0){z=1 ; continue ;} v.push_back(i) ;}
    }
    int sz=v.size() ; int xx=s.size(),p ;
    for(int i = 0 ; i < s.size() ; i++)
    {
        int x=s[i]-'0' ;
        if(mp[x])
        {
            int id=lower_bound(v.begin(),v.end(),x)-v.begin() ;
            if(id==sz)
            {
               if(i==0) as+=(v[0]+'0') ;
               else xx++ ;
               if(z) p=0 ; else p=v[0] ;
               while(xx--) as+=(p+'0') ;
            }
            else
            {
                as+=(v[id]+'0') ; xx-- ;
                if(z) p=0 ; else p=v[0] ;
                while(xx--) as+=(p+'0') ;
            }
            break ;
        }
        else {as+=s[i] ; xx-- ;}
    }
    cout<<as<<endl ;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define int long long 
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=100005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a,b,c;cin>>a>>b>>c;
	if (a+b>=c) cout<<"No";	
	else if (4*a*b<(c-a-b)*(c-a-b)) cout<<"Yes";
	else cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define X first
#define Y second
#define LL long long
#define MP make_pair
#define PB push_back
#define SZ(a) (int)(a.size())
const int INF = 1000 * 1000 * 1000 + 47;
using namespace std;

int main()
{
	string s;
	cin >> s;
	int mx = 0;
	vector<string> v;
	for(int i = 0; i < SZ(s); i ++)
	{
		string kek;
		kek += s[i];
		v.PB(kek);
		if(SZ(v) == 1 || kek != v[SZ(v) - 2])
		{
			
		}
		else
		{
			if(i != SZ(s) - 1)
			{
				v.back() += s[i + 1];
				i++;
			}
			else
			{
				v.pop_back();
				v.back() += s[i];
			}
		}
			
		
	}
	
	cout << SZ(v);
}


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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

#define _I(i, j) (i*w+j)

int main(){
	int h, w, k;
	cin>>h>>w>>k;
	int x1, y1, x2, y2;
	cin>>x1>>y1>>x2>>y2;
	x1--; y1--; x2--; y2--;
	char c[1000000];
	rep(i, h) rep(j, w) cin>>c[_I(i, j)];

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

	bool mita[1000000]={0};

	queue<int> q, nq;
	q.emplace(_I(x1, y1));
	mita[_I(x1, y1)]=true;
	unordered_map<int, bool> nmita;
	int cnt=0;
	while(!q.empty()){
		cnt++;
		while(!q.empty()){
			int tx=q.front()/w, ty=q.front()%w;
			q.pop();

			rep(r, 4){
				for(int s=1; s<=k; s++){
					int x=tx+dx[r]*s, y=ty+dy[r]*s;
					if(x==x2 && y==y2){
						cout<<cnt<<endl;
						return 0;
					}

					if(x>=0 && x<h && y>=0 && y<w && 
						c[_I(x, y)]!='@' && !mita[_I(x, y)]){
							if(!nmita[_I(x, y)]){
								nmita[_I(x, y)]=true;
								nq.emplace(_I(x, y));
							}
					}
					else break;
				}
			}

		}
		repit(it, nmita){
			mita[it->first]=true;
		}
		nmita.clear();
		auto tmp=q; q=nq; nq=tmp;
	}

	cout << (-1) << endl;
	return 0;
}


Measured memory_bytes: 10328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define F first
#define S second
//cout<<fixed<<setprecision(11);
const string nl="\n";
const ll MOD=1e9+7;
const ll ARR_MAX = 3e5+1;
// const ll VAL_MAX = 1e5+1;
const ll INF=1e14;

ll pwr(ll x,ll n){
	if(n==1){
		return x;
	}
	if(n%2){
		return (x*pwr(x,n-1))%MOD;
	}
	return (pwr(x,n/2)*pwr(x,n/2))%MOD;

}

ll inv(ll x){
	return pwr(x,MOD-2);
}

void solve(){
    int n;cin>>n;
    ll a[n];
    ll bit_set_cnt[62];
    memset(bit_set_cnt,0,sizeof(bit_set_cnt));
    for(int i=0;i<n;i++){
    	cin>>a[i];
    	for(ll j=0;j<62;j++){
    		if(a[i] & (ll)1<<j){
    			bit_set_cnt[j]++;
    		}
    	}
    }
    ll ans=0;
    for(ll j=0;j<62;j++){
    	// cout<<bit_set_cnt[j]<<nl;
    	ll x=bit_set_cnt[j]*(n-bit_set_cnt[j]);
    	x%=MOD;
    	ans+=(x*(((ll)1<<j)%MOD))%MOD;
    	ans%=MOD;
    	// cout<<ans<<nl;
    }
    cout<<ans%MOD;


}

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

Measured memory_bytes: 2560
N = int(input())
def prime(n):
    flag = False
    for i in range(2,int(n**0.5)+1):
        if n%i == 0:
            return False
            break
    return True
    

L = []
for i in range(2,55556):
    if prime(i) and i%5 == 1:
        L.append(i)
        if len(L) == N:
            break
print(*L[:N])

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

using namespace std;
typedef long long ll;
typedef long double ld;
//#define rep(i, a, b) for(ll i = ll(a); i <= ll(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)


int main(){

 int n;
 cin>>n;

 vector<int>a(n);

 rep(i,n)
 cin>>a[i];

 vector<double>AI(n);

 rep(i,n)
  AI[i] = 1/double(a[i]);

 double sum =0;
 rep(i,n)
  sum += AI[i];

  sum = 1.0/sum;

  cout<<setprecision(10);
  cout<<sum<<endl;

return 0;
}



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

int main(int argc, char const *argv[]) {
    int N;
    double tmp;
    cin >> N;
    vector<double> A(N);

    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    
    sort(A.begin(), A.end());

    for (int i = 0; i < N-1; i++) {
        tmp = double(A.at(i)+A.at(i+1)) / 2.0;
        A.at(i+1) = tmp;
    }

    cout << A.at(N-1) << endl;

    return 0;
}


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

using namespace std;
using ll = long long;

const vector<int> vx={1,0,-1,0,1,-1};
const vector<int> vy={0,1,0,-1,1,-1};

bool solve() {
    int time,n;
    cin>>time>>n;
    if(time==0)return false;

    set<pair<int,int>> st;
    for(int i = 0;i < n;++i) {
        int x,y;
        cin>>x>>y;
        st.emplace(x,y);
    }

    int sx,sy;
    cin>>sx>>sy;

    set<pair<int,int>> ans;

    ans.emplace(sx,sy);

    queue<pair<pair<int,int>,int>> q;
    q.emplace(make_pair(sx,sy),0);
    while(!q.empty()) {
        auto t=q.front();
        q.pop();
        if(t.second==time)continue;
        for(int d = 0;d < 6;++d) {
            int nx=t.first.first+vx[d];
            int ny=t.first.second+vy[d];
            if(st.find(make_pair(nx,ny))!=st.end())continue;
            if(ans.find(make_pair(nx,ny))!=ans.end())continue;
            q.emplace(make_pair(nx,ny),t.second+1);
            ans.insert(make_pair(nx,ny));
        }
    }

    cout<<ans.size()<<endl;

    return true;
}

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



Measured memory_bytes: 3200