akhauriyash/Code-Regression huggingface dataset:
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

bool sortCheck(int n, vector<int> A){
    int f = 1;
    REP(i, n - 1){
        if(A[i] > A[i + 1]){
            f = 0;
            break;
        }
    }
    if(f) return true;
    else return false;
}

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    for(auto &x : A) cin >> x;

    int cnt = 0, tmp;
    while(1){
        if(sortCheck(n, A)) break;
        else{
            REP(i, n - 1){
                if(A[i] > A[i + 1]){
                    tmp = A[i];
                    A[i] = A[i + 1];
                    A[i + 1] = tmp;
                    cnt++;
                }
            }
        }
    }
    REP(i, n){
        if(i != n - 1) cout << A[i] << " ";
        else cout << A[i] << endl;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3188
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int main()
{	int n;
    cin>>n;
    int ac=0,wa=0,tle=0,re=0;
    while(n--)
    {	string str;
		cin>>str;
		if(str=="AC")	ac++;    	
    	else if(str=="WA")	wa++;
    	else if(str=="TLE") tle++;
    	else re++;
    }
    cout<<"AC x "<<ac<<"\n"<<"WA x "<<wa<<"\n"<<"TLE x "<<tle<<"\n"<<"RE x "<<re<<"\n";
    return 0;
}


Measured memory_bytes: 3648
// inputに入力データ全体が入る
function Main(input) {
 // 1行目がinput[0], 2行目がinput[1], …に入る
 input = input.split(" ");
 //文字列から10進数に変換するときはparseIntを使います
 var a = parseInt(input[0], 10);
 var b = parseInt(input[1], 10);
 var c = parseInt(input[2], 10);
 var s = a == b ? c : a + b - c;
 //出力
 console.log('%d',s);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
// in the name if Allah
// YA Ali!
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll INF = 1<<30 ;
const ll N= 1e6 ;
#define f first
#define s second
#pragma GCC optimize("O1")
#pragma GCC optimize("O2")
#pragma GCC optimize("O3")
#pragma GCC optimize("O4")
#pragma GCC optimize("O5")
#pragma GCC optimize("O6")
#pragma GCC optimize("O7")
#pragma GCC optimize("O8")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
ll n , d;
vector<pair<ll,ll> > v ;
int main()
{
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n ;
for(int i = 0 ; i < n ; i ++){
    ll x ;
    cin >> x ;
    v.push_back({x,i}) ;
}
sort(v.begin() , v.end()) ;
ll xx = v[n-1].s , va = v[n-2].f , maxx = v[n-1].f;
for(int i = 0 ; i < n ; i++){
    if(i==xx)cout << va << endl ;
    else cout << maxx << endl ;
}
    return 0;
}
 /*
              _     _   __
        /_\  (_    (_)  __)
       /   \  _) . (_) (__
 */


Measured memory_bytes: 5872
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int p[51];

int main() {
  int N;
  int i, err;
  scanf ("%d", &N);
  
  err=0;
  for (i=0;i<N;i++) {
      scanf("%d", &p[i]);
      if (p[i]!=i+1) err++;
  }
  
  if ((err==0)||(err==2)) printf("YES");
  else                    printf("NO");
  
  
  return 0;
}




Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
typedef long long ll;
int main(){
  string s;
  while(cin>>s,s!="0"){
    if(s.size()<2){
      cout << 0 << endl;
      continue;
    }
    ll d[80005][11]={{}};
    ll w[80005]={};
    ll i,j,k,ans=0;
    for(i=0;i<s.size();i++){
      w[i+2]=(w[i]+s[i]-'0')%11;
    }
    for(i=0;i+1<s.size();i+=2){
      k=(11+s[i]-s[i+1])%11;
      for(j=0;j<11;j++){
	d[i+2][(j+k)%11]=d[i][j];
      }
      if(s[i]!='0') d[i+2][k]++;
      //for(j=0;j<11;j++) cout << d[i+2][j] << " ";
      //cout << endl;
      ans+=d[i+2][0];
      //cout << ans << "/";
      if(i+2<s.size()){
	k=s[i+2]-'0';
	ans+=d[i+2][(11-k)%11];
      }
      //cout << ans << " ";
    }
    //cout << endl;
    for(i=1;i+1<s.size();i+=2){
      k=(11+s[i]-s[i+1])%11;
      for(j=0;j<11;j++){
	d[i+2][(j+k)%11]=d[i][j];
      }
      if(s[i]!='0') d[i+2][k]++;
      //for(j=0;j<11;j++) cout << d[i+2][j] << " ";
      //cout << endl;
      ans+=d[i+2][0];
      //cout << ans << "/";
      if(i+2<s.size()){
	k=s[i+2]-'0';
	ans+=d[i+2][(11-k)%11];
      }
      //cout << ans << " ";
    }
    //cout << endl;
    cout << ans << endl;
    //cout <<endl;
    s="";
  }
  return 0;
}

Measured memory_bytes: 8260
#include<iostream>
using namespace std;
  
int main(){
  int N;
  cin >> N;
  
  int a[N];
  
  int ans=0;
  for(int i=0;i<N;i++){
    cin >> a[i];
    ans += (a[i] -1);}
  
  cout << ans;
}
  

Measured memory_bytes: 256
#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 <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#endif

using namespace std;


typedef long long LL, ll;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()) {
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t) {
    stringstream ss;
    ss << f;
    ss >> t;
}


#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb push_back


#define MOD 1000000007LL
#define EPS 1e-8



int main() {
    LL a, b;
    cin >> a >> b;
    if (0 == a || 0 == b || (a < 0 && 0 < b)) {
        cout << "Zero" << endl;
        return 0;
    }
    if (0 < a) {
        cout << "Positive" << endl;
        return 0;
    }
    if ((b - a + 1) & 1) {
        cout << "Negative" << endl;
        return 0;
    }
    cout << "Positive" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n - 1];
		for(int i = 0 ; i < n ; i++) a[i] = Integer.parseInt(sc.next());
		for(int i = 0 ; i < n ; i++) b[i] = Integer.parseInt(sc.next());
		for(int i = 0 ; i < n - 1 ; i++) c[i] = Integer.parseInt(sc.next());
		sc.close();
		long yono = 0;
		for(int i = 1 ; i < n ; i++){
			if(a[i - 1] + 1 == a[i]){
				yono += c[a[i - 1] - 1];
			}
		}
		for(int i = 0 ; i < n ; i++) yono += b[a[i] - 1];
		ou.print(yono + "\n");
		ou.flush();
    }
}

Measured memory_bytes: 38704
#![allow(dead_code, unused_mut, unused_variables, unused_imports)]

use std::collections::{HashMap, HashSet, VecDeque};
use std::io::*;
struct Io<'a> {
    r: BufReader<StdinLock<'a>>,
    w: BufWriter<StdoutLock<'a>>,
    buf: VecDeque<String>,
    buf_str: String,
}
impl<'a> Io<'a> {
    fn r<T: std::str::FromStr>(&mut self) -> T {
        if self.buf.len() == 0 {
            self.r.read_line(&mut self.buf_str).unwrap();
            for w in self.buf_str.split_whitespace() {
                self.buf.push_back(w.to_owned());
            }
            self.buf_str.clear();
        }
        self.buf
            .pop_front()
            .unwrap()
            .parse()
            .unwrap_or_else(|_| panic!())
    }
    fn w<T: std::fmt::Display>(&mut self, v: T) {
        writeln!(self.w, "{}", v).unwrap();
    }
    fn iter<'b, T: std::str::FromStr>(&'b mut self) -> IoIter<'a, 'b, T> {
        IoIter {
            io: self,
            p: std::marker::PhantomData,
        }
    }
}
struct IoIter<'a: 'b, 'b, T: std::str::FromStr> {
    io: &'b mut Io<'a>,
    p: std::marker::PhantomData<T>,
}
impl<'a, 'b, T: std::str::FromStr> Iterator for IoIter<'a, 'b, T> {
    type Item = T;
    fn next(&mut self) -> Option<T> {
        Some(self.io.r())
    }
}
fn main() {
    let stdin = stdin();
    let stdout = stdout();
    let r = BufReader::new(stdin.lock());
    let w = BufWriter::new(stdout.lock());
    let io = Io {
        r: r,
        w: w,
        buf: VecDeque::new(),
        buf_str: String::new(),
    };
    problem(io);
}

fn problem(mut io: Io) {
    let n: usize = io.r();
    let k: usize = io.r();

    let ret: usize = (k..=n + 1)
        .map(|i: usize| {
            let min: usize = (0..i).sum();
            let max: usize = (n + 1 - i..=n).sum();
            max - min + 1
        })
        .fold(0, |acc, i| {
            let mut sum = acc + i;
            while sum > 1000000007 {
                sum -= 1000000007;
            }
            sum
        });
    io.w(ret);
}


Measured memory_bytes: 2156
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

const int INF = 1e9;
const long long LINF = 1e18;
const double PI=3.14159265358979323846;

typedef priority_queue<int, vector<int>, greater<int>> priority_queue_asc;

vector<int> h;

int solve(int l, int r) {
    // cout << "(l, r) = " << l << ", " << r << endl;
    // for (int i = l; i < r; i++) {
        // cout << h[i] << ' ';
    // }
    // cout << endl;
    if (l == r) {
        return 0;
    }
    int minh = INF;
    for (int i = l; i < r; i++) {
        minh = min(h[i], minh);
    }
    for (int i = l; i < r; i++) {
        h[i] -= minh;
    }

    // cout << "minh: " << minh << endl;

    int ans = minh;
    int nl = 0, nr;
    for (int i = l; i < r; i++) {
        if (h[i] == 0) {
            nr = i;
            ans += solve(nl, nr);
            nl = nr + 1;
        }
    }
    ans += solve(nl, r);
    return ans;
}

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

    h.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }


    cout << solve(0, N) << endl;

    return 0;
}


Measured memory_bytes: 3192
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int r = 0;
        for (int i = 1; i <= N; i++) {
            if (String.valueOf(i).length() % 2 != 0) r++;
        }
        System.out.println(r);
    }
}

Measured memory_bytes: 28372
#include <bits/stdc++.h>
#define FOR0(i, n) for (int i = 0; i < n; i++)
#define FOR1(i, n) for (int i = 1; i <= n; i++)
#define FORl(i, l, n) for (int i = l; i < n; i++)
using namespace std;
#define pi pair<ll, ll>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x, 0, sizeof(x));
#define vi vector<ll>
#define sync                      \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);                   \
	cout.tie(0);
#define endl '\n'
#define sp << " " <<
#define intmax 1e14
ll mod = 1e9 + 7;


#define MOD 1000000007

const int N = 500005;
ll fact[N], invfact[N];

ll pow(ll a, ll b, ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

ll modinv(ll k)
{
	return pow(k, MOD-2, MOD);
}

void precompute()
{
	fact[0]=fact[1]=1;
	for(ll i=2;i<N;i++)
	{
		fact[i]=fact[i-1]*i;
		fact[i]%=MOD;
	}
	invfact[N-1]=modinv(fact[N-1]);
	for(ll i=N-2;i>=0;i--)
	{
		invfact[i]=invfact[i+1]*(i+1);
		invfact[i]%=MOD;
	}
}

ll nCr(ll x, ll y)
{
	if(y>x)
		return 0;
	ll num=fact[x];
	num*=invfact[y];
	num%=MOD;
	num*=invfact[x-y];
	num%=MOD;
	return num;
}

ll dp[N], dp1[N];

int main(int argc, char const *argv[])
{
	sync;
	precompute();
	ll n, m;
	cin >> n >> m;
	if(m == 1 || n > m){
		cout << "0" << endl;
		return 0;
	}
	ll ans = 1, val = m;
	dp[0] = 1;
	for(int i = 1; i <= n; i++){
		ans *= val;
		ans %= mod;
		dp[i] = dp[i-1]*val;
		dp[i] %= mod;
		val--;
	}
	val = m - n + 1;
	dp1[n] = val;
	dp1[n+1] = 1;
	for(int i = n-1; i >= 1; i--){
		val++;
		dp1[i] = dp1[i+1]*val;
		dp1[i] %= mod;
	}

	ans *= ans;
	ans %= mod;
	ll sign = -1;
	val = m;
	for(int i = 1; i <= n; i++){
		ll tmp = dp1[i+1]*dp1[i+1];
		tmp %= mod;
		tmp *= dp[i];
		tmp %= mod;
		ans += sign*nCr(n,i)*tmp;
		ans %= mod;
		ans += mod;
		ans %= mod;
		sign = -sign;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 19120
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	private static int[] que;
	private static int count;
	public static void main(String[] args)throws IOException{
		que = new int[2000000];
		count =0;
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String[] str=br.readLine().split(" ");
			if(str[0].equals("end")) break;
			else if(str[0].equals("extract")) extract();
			else if(str[0].equals("insert")){
				int n=Integer.parseInt(str[1]);
				insert(n);
			}
		}
	}
	
	private static void extract(){
		int max=que[1];
		que[1]=que[count];
		count--;
		maxHeap(1);
		System.out.println(max);
	}
	
	private static void insert(int n){
		count++;
		que[count]=Integer.MIN_VALUE;
		que[count] = n;
        int i = count;
        while (i > 1 && que[i/2] < que[i]) {
        	swap(i,i/2);
            i = i/2;
        }
	}
	
	private static void maxHeap(int i){
		int l=2*i;
		int r=2*i+1;
		int max;
		if(l<=count && que[l]>que[i]) max=l;
		else max=i;
		if(r<=count && que[r]>que[max]) max=r;
		
		if(max!=i){
			swap(i,max);
			maxHeap(max);
		}
	}
	
	   private static void swap(int i, int j) {
	        int tmp = que[i];
	        que[i] = que[j];
	        que[j] = tmp;
	    }
}

Measured memory_bytes: 544864
#include<iostream>
#include<vector>

int main(){
	int a1, a2, a3, a4, b1, b2, b3, b4;
	while (std::cin >> a1 >> a2 >> a3 >> a4) {
		std::cin >> b1 >> b2 >> b3 >> b4;
		std::vector<int> a = {a1, a2, a3, a4};
		std::vector<int> b = {b1, b2, b3, b4};
		int hit = 0, blow = 0;
		for (int i = 0; i < 4; ++i) {
			for (int j = 0; j < 4; ++j) {
				if (a.at(i) == b.at(j)) {
					if (i == j) {
						++hit;
					} else {
						++blow;
					}
				}
			}
		}
		std::cout << hit << " " << blow << std::endl;

	}
	return 0;
}

Measured memory_bytes: 1204
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        
        List<Integer> to = new ArrayList<Integer>();
        int[] visited = new int[n];
        int now = 1;
        to.add(now);
        visited[now-1] = 1;
        int loopnumber = -1;
        for (int i = 0; i < n-1; i++) {
            now = array[now-1];
            if (visited[now-1] == 1) {
                loopnumber = now;
                break;
            }
            to.add(now);
            visited[now-1] = 1;
            if (i == k - 1) {
                System.out.println(now);
                return;
            }
            // System.out.println(now+1);
        }
        
        int length = to.size();
        int start = 0;
        for (int i = 0; i < to.size(); i++) {
            if (to.get(i) == loopnumber) {
                start = i;
                break;
            }
        }
        
        List<Integer> to2 = new ArrayList<Integer>();
        for (int i = start; i < to.size(); i++) {
            to2.add(to.get(i));
        }
        
        long tmp = (k - start) % to2.size();
        int tmp2 = (int)tmp;
        //  System.out.println(to.size());
        System.out.println(to2.get(tmp2));
    }
}


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

using namespace std;

int isCount(int a, int b)
{
  int tmp = a & b;
  int cnt = 0;
  while (tmp > 0) {
    cnt++;
    tmp &= tmp-1;
  }

  return cnt;
}

int sToI (string s)
{
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    ans |= 1 << (s[i]-'a');
  }

  return ans;
}

int main(int argc, char* argv[])
{
  int N; cin >> N;
  string S; cin >> S;

  int cnt = 0;
  for (int i = 0; i < S.size(); i++) {
    string a = S.substr(0, i), b = S.substr(i, S.size()-i);
    cnt = max(cnt, isCount(sToI(a), sToI(b)));
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 0, mod = (int) 1e9 + 7;

int main() {
	int n, m;
	cin >> n >> m;
	int ways = 1;
	for (int j = 1; j <= n; ++j) ways = (LL) ways * j % mod;
	for (int j = 1; j <= m; ++j) ways = (LL) ways * j % mod;
	if (n == m) {
		ways = (LL) ways * 2 % mod;	
	} else {
		if (abs(n - m) > 1) {
			ways = 0;
		}
	}
	cout << ways << endl;
}




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

int main() {
  
  int n,d;
  cin >> n >> d;
  
  vector<vector<int>> x(n,vector<int>(d));
  for ( int i = 0; i < n; i++){
    for ( int j = 0; j < d; j++){
      cin >> x[i][j];
    }
  }
  
  int moto,sum,count = 0;
  
  for (int i = 0; i < n-1; i++){
    for ( int j = i+1; j < n; j++){
      sum = 0;
      moto = 0;
      for ( int k = 0; k < d; k++){
        sum += ( x[i][k] - x[j][k] ) * ( x[i][k] - x[j][k] );
      }
      moto = int(sqrt(sum));
      if ( moto * moto == sum ){
        count++;
      }
    }
  }
        
  cout << count << endl;        

}

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

using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  string s; cin >> s;
  V<> cnt(26);
  for (char c : s) {
    ++cnt[c - 'a'];
  }
  cout << (all_of(begin(cnt), end(cnt), [](int x) { return ~x & 1; }) ? "Yes" : "No") << '\n';
}

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

vector<vector<int> > item; //[i][0]が価値,[i][1]が重さ
vector<vector<int> > maxs; //[i][j]でiこ中の重さj

int maxfn(int n, int w){
  if (n*w <= 0)
    return 0;
  if (maxs[n][w])
    return maxs[n][w];
  else{
    if  (w-item[n-1][1] >= 0){
      return maxs[n][w] = max(maxfn(n-1,w),
          maxfn(n-1,w-item[n-1][1])+item[n-1][0]);
    }
    else{
      return maxs[n][w] = maxfn(n-1,w);
    }
  }
}

int main(){
  int N,W;
  cin >> N >> W;
  item.assign(N,vector<int>(2,0));
  maxs.assign(N+1,vector<int>(W+1,0));
  for (int i=0;i<N;i++)
    cin >>  item[i][0] >> item[i][1];

  cout << maxfn(N, W) << "\n";
}


Measured memory_bytes: 6804
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = 3e18;
    if ((b - a) % 2 == 0) ans = (b - a) / 2;
    else {
        ans = min(ans, a + (b - a - 1) / 2);
        ans = min(ans, n + 1 - b + (b - a - 1) / 2);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int n,a,b; cin>>n>>a>>b;
	string s; cin>>s;
	int jp=0, ab=0;
	rep(i,n){
		if(s[i]=='a'){
			if(jp+ab<a+b) cout<<"Yes"<<endl, jp++;
			else cout<<"No"<<endl;
		}else if(s[i]=='b'){
			if(jp+ab<a+b&&ab<b) cout<<"Yes"<<endl, ab++;
			else cout<<"No"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}

	return 0;
}


Measured memory_bytes: 848
import std.stdio, std.conv, std.string, std.range, std.typecons, std.format;
import std.algorithm.searching, std.algorithm.sorting, std.algorithm.iteration, std.algorithm.mutation;

void main()
{
    readln();
    int[] input = readln().split.to!(int[]);
    auto max = input.reduce!"a<b?b:a";
    auto sum = input.sum() - max;
    writeln(sum>max?"Yes":"No");

}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;


class Solve
{
  public Solve() { }
  public static int Main()
  {
    new Solve().calc();
    return 0;
  }


  Scanner cin;

  void calc()
  {
    cin = new Scanner();
    int N = cin.nextInt();
    int M = cin.nextInt();

    int first = N >= 2 ? (N * (N - 1)) / 2 : 0;
    int second = M >= 2 ? (M * (M - 1)) / 2 : 0;
    int result = first + second;
    
    Console.WriteLine(result.ToString());
  }
}
class Modulo
{
  private const int M = 1000000007;
  private readonly int[] m_facs;
  public int Mul(int a, int b)
  {
    return (int)(Math.BigMul(a, b) % M);
  }
  public Modulo(int n)
  {
    m_facs = new int[n + 1];
    m_facs[0] = 1;
    for (int i = 1; i <= n; ++i)
    {
      m_facs[i] = Mul(m_facs[i - 1], i);
    }
  }
  public int Fac(int n)
  {
    return m_facs[n];
  }
  public int Pow(int a, int m)
  {
    switch (m)
    {
      case 0:
        return 1;
      case 1:
        return a;
      default:
        int p1 = Pow(a, m / 2);
        int p2 = Mul(p1, p1);
        return ((m % 2) == 0) ? p2 : Mul(p2, a);
    }
  }
  public int Div(int a, int b)
  {
    return Mul(a, Pow(b, M - 2));
  }
  public int Ncr(int n, int r)
  {
    if (n < r) { return 0; }
    if (n == r) { return 1; }
    int res = Fac(n);
    res = Div(res, Fac(r));
    res = Div(res, Fac(n - r));
    return res;
  }
}

class Scanner
{
  string[] s;
  int i;

  char[] cs = new char[] { ' ' };

  public Scanner()
  {
    s = new string[0];
    i = 0;
  }

  public string next()
  {
    if (i < s.Length) return s[i++];
    string st = Console.ReadLine();
    while (st == "") st = Console.ReadLine();
    s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
    if (s.Length == 0) return next();
    i = 0;
    return s[i++];
  }

  public int nextInt()
  {
    return int.Parse(next());
  }
  public int[] ArrayInt(int N, int add = 0)
  {
    int[] Array = new int[N];
    for (int i = 0; i < N; i++)
    {
      Array[i] = nextInt() + add;
    }
    return Array;
  }

  public long nextLong()
  {
    return long.Parse(next());
  }

  public ulong nextULong()
  {
    return ulong.Parse(next());
  }

  public long[] ArrayLong(int N, long add = 0)
  {
    long[] Array = new long[N];
    for (int i = 0; i < N; i++)
    {
      Array[i] = nextLong() + add;
    }
    return Array;
  }

  public double nextDouble()
  {
    return double.Parse(next());
  }


  public double[] ArrayDouble(int N, double add = 0)
  {
    double[] Array = new double[N];
    for (int i = 0; i < N; i++)
    {
      Array[i] = nextDouble() + add;
    }
    return Array;
  }
}


Measured memory_bytes: 11092
#pragma region Template
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RNG(i, a, b) for(int i = a; i < b; i++)
#define RBF(i, v) for(auto& i : v)
#define ALL(x) x.begin(), x.end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }
#pragma endregion

template<typename T> T combination(T N, T K) {
	if (N < K) return 0;
	if (N == K || K == 0) return 1;
	vector<T> v(N, 1);
	T prev1 = 1, prev2 = 1; // prev1 = n−1Ck−1, prev2 = n−1Ck

	for (T n = 2; n <= N; n++) {
		prev1 = 1;
		T k = 1;
		while (k < n && k <= K) {
			prev2 = v[k];
			v[k++] = prev1 + prev2;
			//v[k++] = (prev1 + prev2) % MOD; // 余りを答えるように要求された時用
			prev1 = prev2;
		}
	}
	return v[K];
}

signed main()
{
	LL n;
	cin >> n;
	V<LL> a(n);
	RBF(x, a) cin >> x;

	V<LL> num(n + 1, 0);
	RBF(x, a) {
		num[x]++;
	}

	V<LL> com1(n + 1, 0), com2(n + 1, 0);
	LL sum = 0;
	REP(i, n + 1) {
		com1[i] = combination(num[i], 2ll);
		com2[i] = combination(num[i]-1, 2ll);
		sum += com1[i];
	}

	RBF(x, a) {
		col(sum - com1[x] + com2[x]);
	}

	return 0;
}


Measured memory_bytes: 11068
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner  sc = new Scanner(System.in);
		// input
		String[] s = sc.next().split("");
		// output
		for(int i=0; i<s.length; i++) {
			System.out.print("x");
		}
		System.out.println();
	}
}

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

int main() {
    int n;  cin>>n;
    int arr[n+1];

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

    int dp[n+1]={0};
    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(arr[2]-arr[1]);
    for(int i=3;i<=n;i++){
        dp[i]=min( abs(arr[i]-arr[i-2]) + dp[i-2] , abs(arr[i]-arr[i-1]) + dp[i-1]);
    }

    cout<<dp[n]<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,s,ans;
  ans=0;
  s=1;
  cin >> n;
  vector<int> a(n);
  vector<vector<int>> x(n,vector<int>(n-1));
  vector<vector<int>> y(n,vector<int>(n-1));
  for(int i=0;i<n;i++) {
    s=s*2;
    cin >> a.at(i);
    for(int j=0;j<a.at(i);j++){
      cin >> x.at(i).at(j) >> y.at(i).at(j);
    };
  };
  vector<int> b(n);
  for(int i=0;i<n;i++) b.at(i)=1;
  int d=n;
  for(int i=0;i<s;i++){
    bool c=true;
    for(int j=0;j<n&&c;j++){
      b.at(n-j-1)=(b.at(n-j-1)+1)%2;
      d+=b.at(n-j-1)*2-1;
      if (b.at(n-j-1)==1) c=false;
    };
    c=true;
    for(int j=0;j<n&&c;j++){
      if(b.at(j)==1){ 
        for(int k=0;k<a.at(j)&&c;k++){
          if(b.at(x.at(j).at(k)-1)!=y.at(j).at(k)) c=false;
        };
      };
    };
    if(c&&ans<d) ans=d;
  };
  cout << ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cstdlib>
#include <typeinfo>

using namespace std;

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


int i,j;

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


Measured memory_bytes: 256
points = gets.split.map(&:to_i)

def result(points)
  x1 = points[0]
  y1 = points[1]
  x2 = points[2]
  y2 = points[3]
  
  if x1 > x2
    y3 = y2 - (x1 - x2)
    y4 = y1 - (x1 - x2)
  else
    y3 = y2 + (x2 - x1)
    y4 = y1 + (x2 - x1)
  end
  if y1 > y2
    x3 = x2 + (y1 - y2)
    x4 = x1 + (y1 - y2)
  else
    x3 = x2 - (y2 - y1)
    x4 = x1 - (y2 - y1)
  end
  "#{x3} #{y3} #{x4} #{y4}"
end

puts result(points)

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


template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v){
    if(!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]";
    return out;
}
//---------

int dp[1010][1010]; //dp[??????][??????]
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, W;
    cin >> N >> W;
    vector<int> v(N);
    vector<int> w(N);
    memset(dp, 0, sizeof(dp));

    rep(i, 0, N){
        cin >> v[i] >> w[i];
    }

    for(int i = N-1; i >= 0; i--){
        for(int j = 0; j <= W; j++){
            if(j < w[i]){
                dp[i][j] = dp[i+1][j];
            }else{
                dp[i][j] = max(dp[i+1][j], dp[i+1][j-w[i]] + v[i]);
            }
        }
    }
    cout << dp[0][W] << endl;


    

    
}

Measured memory_bytes: 5192
#include <iostream>
using namespace std;
int main(void){
    int S, h, m, s;
    cin  >> S; 
    h = S / 3600;
    m = S % 3600 / 60;
    s = S % 3600 % 60;
    cout << h;
    cout << ":";
    cout << m;
    cout << ":";
    cout << s;
    cout << endl;
}



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

using namespace std;
#define LL long long 

int main(){
    int r,g,b;
    int N;
    cin >> N;
    LL ans = 0;
    vector <int> a(N);
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    
    cout << a[N-1] - a[0] << endl;
}

Measured memory_bytes: 256
from itertools import accumulate

n, k = map(int, input().split())
MOD = 10 ** 9 + 7
acc = [0] + list(accumulate(range(n + 1)))

ans = 0
for i in range(k, n + 2):
    mi = acc[i]
    ma = acc[-1] - acc[-i - 1]
    ans += ma - mi + 1
    ans %= MOD

print(ans)

Measured memory_bytes: 20792
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int height,weight;
  char pic[100][101]={{'\0'}};
  char ans[200][101]={{'\0'}};
  int i,j;

  scanf("%d %d",&height, &weight );

  for(i=0;i<height;i++)scanf("%s", pic[i]);

  for(i=0;i < height * 2;i++){
    for(j=0;j < weight;j++){
      if( i % 2 != 0){//奇数 1,3,5
        ans[i][j] = pic[(i-1)/2][j];
      }else{//偶数 0,2,4,
        ans[i][j] = pic[i/2][j];
      }
    }
    printf("%s\n",ans[i]);
  }


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    vector<bool> win(k + 1); // 1 = first wins
    for (int & x : a)
        cin >> x;
    for (int i = 1; i <= k; ++i) {
        bool ok = false; 
        for (int x : a)
            if (x <= i)
                ok |= !win[i - x];
        win[i] = ok;
    }
    cout << (win[k] ? "First\n" : "Second\n");
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
#define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

// x,y に ax + by = gcd(a, b) を満たす値が格納される
ll extgcd(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extgcd(b, a%b, y, x);
    y -= a/b * x;
    return d;
}


int main() {

    ll a,b,x,y;
    cin>>a>>b;
    extgcd(a,b,x,y);
    cout<<x<<" "<<y<<endl;
}




Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    string S;
    int N, l, i, r=0;
    cin >> N;
    cin >> S;

    l = S.length();
    for (i=0; i<l; i++){
        if (S[i]=='R') r++;
    }


    if (r > (l-r)) cout << "Yes" << '\n';
    else cout << "No" << '\n';
}

   

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

int main(){
  int a, b;
  cin >> a >> b;
  if(b==1) cout << 0 << endl;
  else if(b<=a) cout << 1 << endl;
  else {
    int k = a-1;
    int d = b-a;
    cout << (d+a-2)/k+1 << endl;
  }
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
if N <= A:
    print(N)
else:
    if N <= (A+B):
        print(A)
    else:
        if ((N % (A+B)) <= A):
            print((N // (A+B) ) * A + (N % (A+B)))
        else:
            print((N // (A+B) ) * A + A)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
const int MOD=1e9+7;

int main() {
    ll n,a,b;
    cin >> n >> a >> b;
    ll ans=n/(a+b)*a+min(n%(a+b),a); 
    cout << ans << endl;
}

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

int main(){
    ll H, W;
    cin >> H >> W;
    
    ll Smax, Smin;
    ll MIN = 100100100100;
    for (ll ha = 1; ha < H; ha++)
    {
        ll hb = (H-ha)/2;
        ll hc = H-ha-hb;
        Smax = max(ha, max(hb, hc)) * W;
        Smin = min(ha, min(hb, hc)) * W;
        MIN = min(MIN, Smax-Smin);

        ll wb = W/2;
        ll wc = W-wb;
        Smax = max(ha*W, max(wb, wc)*(H-ha));
        Smin = min(ha*W, min(wb, wc)*(H-ha));
        MIN = min(MIN, Smax-Smin);
    }

    swap(H, W);
    for (ll ha = 1; ha < H; ha++)
    {
        ll hb = (H-ha)/2;
        ll hc = H-ha-hb;
        Smax = max(ha, max(hb, hc)) * W;
        Smin = min(ha, min(hb, hc)) * W;
        MIN = min(MIN, Smax-Smin);

        ll wb = W/2;
        ll wc = W-wb;
        Smax = max(ha*W, max(wb, wc)*(H-ha));
        Smin = min(ha*W, min(wb, wc)*(H-ha));
        MIN = min(MIN, Smax-Smin);
    }

    cout << MIN << endl;
    // printf("%d\n", N);
    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;
int main()
{
	int N;
	cin >> N;
	vector<ll> a(N), b(N), c(N);
	vector<ll> A;
	ll t = 0;
	int ans = 0;
	rep(i, N) cin >> a[i];
	rep(i, N) cin >> b[i];
	rep(i, N)
	{
		c[i] = a[i] - b[i];
		if (c[i] > 0)
			A.push_back(c[i]);
		else if (c[i] < 0)
		{
			t += -c[i];
			ans++;
		}
	}
	if (t == 0)
	{
		cout << 0 << endl;
		return 0;
	}
	sort(A.begin(), A.end(), greater<int>());
	for (int i = 0; i < A.size(); i++)
	{
		t -= A[i];
		if (t <= 0)
		{
			cout << i + 1 + ans << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}


Measured memory_bytes: 3196
x, n = gets.split.map(&:to_i)

p = gets.split.map(&:to_i)

b = []
c = []
e = []

(-1000..1000).each do |i|
  b << i
end

d = b - p

d.each do |j|
  c << (x-j).abs
  e << j
end

f = c.min
z = 0
w = e.sort
ss = []

w.each do |m|
  if m == x - f
    ss << m
  elsif  m == x + f
    ss << m
  end
end


puts ss.min



Measured memory_bytes: 14432
X, Y, Z, K  = map(int, input().split())

A = sorted(list(map(int, input().split())), reverse=True)[:K]
B = sorted(list(map(int, input().split())), reverse=True)[:K]
C = sorted(list(map(int, input().split())), reverse=True)[:K]

R  = [sum([A[0], B[0], C[0]])]
Q  = {(0, 0, 1), (0, 1, 0), (1, 0, 0)}
D  = {(0, 0, 0), (0, 0, 1), (0, 1, 0), (1, 0, 0)}
iS = [((a, b, c), sum([A[a], B[b], C[c]])) for a, b, c in Q if (a < X) and (b < Y) and (c < Z)]
iS = sorted(iS, key=lambda x: [x[1], x[0]], reverse=True)

while len(R) < K:
    R.append(iS[0][1])
    abc     = iS[0][0]
    a, b, c = abc[0], abc[1], abc[2]
    iS      = iS[1:]
    if a + 1 < X:
        if not (a + 1, b, c) in D:
            s = sum([A[a + 1], B[b], C[c]])
            is_done = False
            for i in range(len(iS)):
                if iS[i][1] < s:
                    iS = iS[:i] + [((a + 1, b, c), s)] + iS[i:]
                    is_done = True
                    break
            if is_done == False:
                iS = iS + [((a + 1, b, c), s)]
            D.add((a + 1, b, c))
    if b + 1 < Y:
        if not (a, b + 1, c) in D:
            s = sum([A[a], B[b + 1], C[c]])
            is_done = False
            for i in range(len(iS)):
                if iS[i][1] < s:
                    iS = iS[:i] + [((a, b + 1, c), s)] + iS[i:]
                    is_done = True
                    break
            if is_done == False:
                iS = iS + [((a, b + 1, c), s)]
            D.add((a, b + 1, c))
    if c + 1 < Z:
        if not (a, b, c + 1) in D:
            s = sum([A[a], B[b], C[c + 1]])
            is_done = False
            for i in range(len(iS)):
                if iS[i][1] < s:
                    iS = iS[:i] + [((a, b, c + 1), s)] + iS[i:]
                    is_done = True
                    break
            if is_done == False:
                iS = iS + [((a, b, c + 1), s)]
            D.add((a, b, c + 1))

for r in R:
    print(r)


Measured memory_bytes: 5180
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1


t, B, a, D = map(int, input().split())

while True:
    a -= B
    if a <= 0:
        print('Yes')
        exit()
    t -= D
    if t <= 0:
        print('No')
        exit()


Measured memory_bytes: 9576
#include <bits/stdc++.h>
using namespace std;
//int freq[10];
int main()
{


   int r,d,x;
   cin>>r>>d>>x;
   int i=10;
   while(i--)
   {
       x=r*x-d;
       cout<<x  ;
       cout<<endl;
   }

}



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

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

int main(){
  int n;
  cin>>n;
  ll vec[n];
  for(int i=0;i<n;i++){
    cin>>vec[i];
  }
  if(n==1){
    cout<<vec[0]<<endl;
    return 0;
  }
  ll vecgcd[n];
  ll vecgcdb[n];
  vecgcd[0]=vec[0];
  for(int i=1;i<n;i++){
    vecgcd[i]=gcd(vecgcd[i-1],vec[i]);
  }
  vecgcdb[n-1]=vec[n-1];
  for(int i=n-2;i>=0;i--){
    vecgcdb[i]=gcd(vecgcdb[i+1],vec[i]);
  }
  ll ans=0;
  for(int i=0;i<n;i++){
    if(i==0){
      ans=max(ans,vecgcdb[1]);
      continue;
    }
    if(i==n-1){
      ans=max(ans,vecgcd[n-2]);
      continue;
    }
    ans=max(ans,gcd(vecgcd[i-1],vecgcdb[i+1]));
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 5936
#include<bits/stdc++.h>
using namespace std;
int main()
{   char c[]={'3','5','7'};
	 int n;
	 cin>>n;
	 queue<string>q;
	 q.push("3");
	 q.push("5");
	 q.push("7");
	 int on=3,nn=0,ans=0,flag=0;
	  while(1)
    {
    	for(int i=1;i<=on;i++)
    	{
    		 string t=q.front();
    		 q.pop();
    		 for(int j=0;j<3;j++)
    		 {
    		 	string tt=t+c[j];
    		
    		 	int num3=0,num5=0,num7=0;
    		 	for(int k=0;k<tt.length();k++)
    		 	{
    		 		if(tt[k]=='3')num3++;
    		 		else if(tt[k]=='5')num5++;
    		 		else if(tt[k]=='7')num7++;
    		 		
				 }
				 
    		 	stringstream ss;
    		 	int x;
    		 	ss<<tt;
    		 	ss>>x;
    		 	q.push(tt);
    		 	nn++;
    		 	if(x<=n){
    		 		if((num3&&num5&&num7))
    		 		ans++;
				 }
				 else
				 {
				 	flag=1;
				 	break;
				 }
			 }
			 if(flag)break;
		}
		if(flag)break;
		on=nn;
		nn=0;
	}
	printf("%d",ans);
 } 

Measured memory_bytes: 1280
let () =
    let split s = let rec loop i cur flag acc =
            if i = String.length s then ( if flag then cur :: acc else acc) else (
                match flag, s.[i] with
                | true,  ' ' -> loop (i + 1) "" false (cur :: acc)
                | false, ' ' -> loop (i + 1) "" false acc
                | true,  v   -> loop (i + 1) (Printf.sprintf "%s%c" cur v) true acc
                | false, v   -> loop (i + 1) (Printf.sprintf "%s%c" cur v) true acc
            )
        in
        List.map int_of_string (List.rev (loop 0 "" false []))
    in
    let test a target k =
        let r = List.map (fun v -> v mod target) a in
        let r = Array.of_list (List.sort compare r) in
        let s = Array.fold_left (+) 0 r  / target in
        let l = Array.length r in
        let rec loop q acc =
            if q + s = l then acc else loop (q + 1) (acc + r.(q))
        in
        loop 0 0 <= k
    in
    let main () =
        let n, k = Scanf.sscanf (read_line ()) "%d %d" (fun n k -> n, k) in
        let a = split (read_line ()) in
        let s = List.fold_left (+) 0 a in
        let rec loop i acc =
            if i * i > s then acc else
            let acc = if s mod i <> 0 then acc else max acc (
                max (if test a i k then i else acc)
                    (if test a (s / i) k then (s / i) else acc)
            )
            in
            loop (i + 1) acc
        in
        Printf.printf "%d\n" (loop 1 (-1))
    in
    main ()

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define pb push_back

int main()
{
    ll N;
    cin >> N;
    map<ll,ll> X, Y;
    REP(i,1,N+1) {
        ll a;        
        cin >> a;
        ++X[i+a];
        ++Y[i-a];
    }

    ll sum = 0;
    FORR(x,X) {
        ll v = x.first, c = x.second;
        sum += c * Y[v];
    }
    PR(sum);

    return 0;
}

/*



*/

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

#define int long long 
#define pb push_back
#define x first
#define y second
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(), (a).end()
typedef pair<int, int> pii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int inf = 1e12 + 12;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)cin >> a[i];
    int to = 0;
    for(int i = 2; i < n; i++)to ^= a[i];
    if((a[0] ^ a[1]) == to) {
        cout << 0;
        return 0;
    }
    int sum = a[0] + a[1];
    if(sum < to || ((sum - to) & 1)) {
        cout << -1;
        return 0;
    }
    int And = (sum - to) / 2;
    sum -= 2 * And;
    if(sum & And) {
        cout << -1;
        return 0;
    }
    if(And > a[0]) {
        cout << -1;
        return 0;
    }
    int num = And;    
    for(int i = 50; i >= 0; i--) {
        if(!((And >> i) & 1) && ((sum >> i) & 1) && num + (1LL << i) <= a[0]) num += 1LL << i;
    }
    if(num == 0) {
        cout << -1;
        return 0;
    }
    cout << a[0] - num;
    return 0;
}


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

int main(void){
  vector<int> v;
  int n,m;
  while(cin >> n >> m){
    if(n==0&&m==0)
      break;
    int sm = m - 1;
    //int memn = n;
    for(int i=1;i<=n;i++){
      v.push_back(i);
    }
    vector<int>::iterator del = v.begin();
    int index = sm;
    while(n>1){
      //cout << v[index] << endl;
      v.erase(del+index);
      n--;
      index += sm;
      //     cout << index << " " << v.size() << endl;
      if(index>=n)
	index %= n;
    }
    cout << v[0] << endl;
    v.clear();
  }
  return 0;
}

Measured memory_bytes: 1228
S = input()
N = len(S)
ans = [0 for i in range(N)]

cnt = [0,0]
prev = 'R'
ind = 0
for i in range(N):
    if prev != S[i]:
        if prev == 'R':
            ans[i-1] += cnt[(i-ind+1)%2]
            ans[i] += cnt[(i-ind)%2]+1
            cnt = [0,0]
        else:
            ans[ind] += cnt[(i-ind)%2]
            ans[ind-1] += cnt[(i-ind+1)%2]
            cnt = [1,0]
        prev = S[i]
        ind = i
    else:
        cnt[(i-ind)%2]+=1

ans[ind] += cnt[(N-ind)%2]
ans[ind-1] += cnt[(N-ind+1)%2]

print(" ".join(map(str,ans)))



Measured memory_bytes: 51356