akhauriyash/Code-Regression huggingface dataset:
# include<bits/stdc++.h>
using namespace std;
# define ll long long
ll aw[105],av[105],dp[105][100007]={0},n;
ll fun(ll i,ll w)
{
    if(dp[i][w]!=-1)
    return dp[i][w];
        if(i==n+1)
        return 0;
    ll ans1,ans2;
    ans1=fun(i+1,w); 
    if(w-aw[i]>=0)
    ans2=av[i]+fun(i+1,w-aw[i]);
    else ans2=0;
    dp[i][w]=max(ans1,ans2);
    return dp[i][w];
}
int main()
{
    ll w,i;
    cin>>n>>w;
    for(i=0;i<n;i++)
        cin>>aw[i]>>av[i];
    for(i=0;i<=n;i++)
        for(int j=0;j<=w;j++)
            dp[i][j]=-1;
    cout<<fun(0,w);
return 0;
}

Measured memory_bytes: 80128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }

        int[][] dp = new int[n][3];
        dp[0][0] = a[0];
        dp[0][1] = b[0];
        dp[0][2] = c[0];
        for (int i = 1; i < n; i++) {
            dp[i][0] = a[i] + Math.max(dp[i - 1][1], dp[i - 1][2]);
            dp[i][1] = b[i] + Math.max(dp[i - 1][2], dp[i - 1][0]);
            dp[i][2] = c[i] + Math.max(dp[i - 1][0], dp[i - 1][1]);
        }
        System.out.println(Math.max(dp[n - 1][0], Math.max(dp[n - 1][1], dp[n - 1][2])));
    }

}


Measured memory_bytes: 95072
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;


ll a, b, c, d;

void init()
{
	cin >> a >> b >> c >> d;
}

template <class T>
inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

template <class T>
inline T lcm(T a, T b) { return a / gcd(a, b) * b; }

int main()
{
	init();

	ll ans = b - a + 1;

	ans -= (b) / d - (a - 1) / d;
	ans -= (b) / c - (a - 1) / c;
	ans += (b) / lcm(c, d) - (a - 1) / lcm(c, d);

	cout << ans << endl;

}


Measured memory_bytes: 256
N, M = map(int, input().split())
ABC = []
for i in range(M):
    ab = list(map(int,input().split()))
    c = list(map(int, input().split()))
    ab.append(c)
    ABC.append(ab)
    
INF = float('inf')
dp = [INF] * (2**N)
dp[0] = 0
for i in range(M):
    d = 0
    for c in ABC[i][2]:
        d |= (1 << (c-1))
        
    for j in range(2**N):
        dp[j|d] = min(dp[j|d], dp[j]+ABC[i][0])
        
if dp[-1] == INF:
    print(-1)
else:
    print(dp[-1])

Measured memory_bytes: 46808
// -*- coding:utf-8-unix -*-

use num::Float;
use proconio::input;
use std::collections::VecDeque;
use std::collections::{BTreeSet, HashSet};
use std::io::*;
use std::str::FromStr;
// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a

fn switch<T>(flag: bool, t: T, f: T) -> T {
    if flag {
        t
    } else {
        f
    }
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
#[allow(dead_code)]
fn read_string() -> Vec<char> {
    read::<String>().chars().collect()
}
#[allow(dead_code)]
fn read_vector<T: FromStr>(number: usize) -> Vec<T> {
    (0..number).map(|_| read()).collect()
}

fn main() {
    let (x, y): (i32, i32) = (read(), read());

    let a = (4 * x - y);
    let b = (y - 2 * x);

    if a >= 0 && b >= 0 && (a % 2) == 0 && (b % 2) == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    string S; cin >> S;
    cout << (S[0]==S[1]||S[1]==S[2]||S[2]==S[3]?"Bad":"Good") << endl;
    return 0;
}

Measured memory_bytes: 3612
import java.io.IOException;
import java.util.NoSuchElementException;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            FastScanner fs = new FastScanner();

            final int N = fs.nextInt();

            int mn = 32;

            for (int i = 0; i < N; i++) {
                int A = fs.nextInt();
                int cnt = 0;
                while (0 < A) {
                    if ((A & 1) != 1) cnt++;
                    else break;

                    A = A >> 1;
                }

                if (cnt < mn) mn = cnt;
            }


            System.out.println(mn);
        }
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
        if (hasNextByte()) return buffer[ptr++];
        else return -1;
    }
    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
        while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
        return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if(b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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

struct Shop { long long a, b; };

int main()
{
  int N, M;
  std::cin >> N >> M;

  std::vector<Shop> shops;
  for(int i=0; i<N; i++)
  {
    int A, B;
    std::cin >> A >> B;
    shops.push_back(Shop{A,B});
  }

  std::sort(shops.begin(), shops.end(),
    [](auto& l, auto& r) { return l.a < r.a; });

  long long costs = 0;
  for( const auto& s : shops )
  {
    costs += std::min<long long>(s.b, M) * s.a;
    if( M <= s.b ) {break;}
    M -= s.b;
  }

  std::cout << costs;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  ll keta = 0;
  rep(i, N) {
    cin >> A[i];
    chmax(keta, (ll)(log2(A[i]) + 1));
  }
  chmax(keta, (ll)(log2(K) + 1));

  vector<ll> num_of_zero(keta);
  rep(i, N) {
    rep(j, keta) {
      if (((A[i] >> j) & 1) == 0)
        num_of_zero[j]++;
    }
  }
  reverse(all(num_of_zero));

  ll X = 0;
  ll ans = 0;
  rep(i, keta) {
    ll cand = (ll)1 << (keta - 1 - i);
    if (num_of_zero[i] > N / 2 && X + cand <= K) {
      X += cand;
      ans += cand * num_of_zero[i];
    } else {
      ans += cand * (N - num_of_zero[i]);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){

    int N,D,a;
    scanf("%d %d",&N,&D);
    a=(N%((2*D)+1));

    if(a>0){
        printf("%d",(N/((2*D)+1))+1);
    }
    else{
        printf("%d",(N/((2*D)+1)));
    }




return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
 
#define REP(i,s,N) for (int i=s;i<(N); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;


ll ans=0;

int main(){
	int A,B;
	cin >> A >> B;
	
	float a = A / 0.08;
	float b = B / 0.10;
	int aa = A / 0.08;
	int bb = B / 0.10;
	
	queue<int> q;
	if((float)(a-aa)==0){
		for(int i=0;i<12;i++){
			q.push(aa+i);
		}
	}else{
		for(int i=0;i<11;i++){
			q.push(aa+i+1);
		}
	}
	queue<int> q2;
	if((float)(b-bb)==0){
		for(int i=0;i<9;i++){
			q2.push(bb+i);
		}
	}else{
		for(int i=0;i<8;i++){
			q2.push(bb+i+1);
		}
	}
	if(q.front()<=q2.front() && q2.front() <= q.back()){
		cout << q2.front() << endl;
	}else if(q2.front()<=q.front() && q.front() <= q2.back()){
		cout << q.front() << endl;
	}else{
		cout << -1 << endl;
	}
	

}

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

int main(){
	char b[3][3];
	int x,y;
	int check;
	int boolean = 1;

	while(boolean){
		x = 0;
		y = 0;
		check = 1;
		for(int i = 0; i < 3; i++){
			cin >> b[i];
			if(b[0][0] == '0'){
				 boolean = 0;
				 check = 0;
				 break;
			}
		}
		for(int i = 0; i <= 2; i++){
			if(b[i][0] == 'b' && b[i][1] == 'b' && b[i][2] == 'b'){
		cout << 'b' << endl;
		check = 0; break;
			}
			if(b[0][i] == 'b' && b[1][i] == 'b' && b[2][i] == 'b'){
		cout << 'b' << endl;
		check = 0; break;
			}
			if(b[0][0] == 'b' && b[1][1] == 'b' && b[2][2] == 'b'){
		cout << 'b' << endl;
		check = 0; break;
			}
			if(b[0][2] == 'b' && b[1][1] == 'b' && b[2][0] == 'b'){
		cout << 'b' << endl;
		check = 0; break;
			}

		}
		for(int i = 0; i <= 2; i++){
			if(b[i][0] == 'w' && b[i][1] == 'w' && b[i][2] == 'w'){
		cout << 'w' << endl;
		check = 0; break;
			}
			if(b[0][i] == 'w' && b[1][i] == 'w' && b[2][i] == 'w'){
		cout << 'w' << endl;
		check = 0; break;
			}
			if(b[0][0] == 'w' && b[1][1] == 'w' && b[2][2] == 'w'){
		cout << 'w' << endl;
		check = 0; break;
			}
			if(b[0][2] == 'w' && b[1][1] == 'w' && b[2][0] == 'w'){
		cout << 'w' << endl;
		check = 0; break;
			}

		}
		if(check) cout << "NA" << endl;
	}
}

Measured memory_bytes: 1132
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.clear();
    std::io::stdin().read_line(&mut s).unwrap();
    let a: Vec<f64> = s.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let mut sum = 0.0;
    for a in a {
        sum += 1.0 / a;
    }
    let ans = 1.0 / sum;
    println!("{:.6}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 4352
N = int(input())
S = input()

W = [0] * N
E = [0] * N
for i in range(1, N):
    if S[i-1] == 'W':
        W[i] = W[i-1] + 1
    else:
        W[i] = W[i-1]

    if S[N-i] == 'E':
        E[N-i-1] = E[N-i] + 1
    else:
        E[N-i-1] = E[N-i]

count = N
for i in range(N):
    count = min(count, W[i] + E[i])
print(count)

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

int main() {
  char a, b;
  cin >> a;
  if(a == 'A') {b = 'T';}
    else if (a == 'T') {
      b = 'A';}
    else if (a == 'G') {
      b = 'C';}
    else {
      b = 'G';}
  cout << b << endl;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define ss second
#define ff first
#define INF 30000000000001
#define ll_max 9000000000000000001
#define mod 1000000007
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;
const ll N = 100001;
const ll M = 1;

void update(ll BIT[], ll n, ll x, ll i)
{
    for(; i <= n; i += (i) & (-i)) BIT[i] += x;
}

ll query(ll BIT[], ll l)
{
    ll sum1 = 0;
    for(; l; l = l & (l - 1)) sum1 += BIT[l];
    return sum1;
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll n, x, y;
        cin >> n;
        pair<long double, pair<int,int> > a[2 * n];
        long double ans = 0;
        for(int i = 0; i < n; i++)
        {
            cin >> x >> y;
            a[i].ff = atan2(y, x);
            a[i].ss.ff = x;
            a[i].ss.ss = y;
        }
        sort(a, a + n);
        for(int i = n; i < 2 * n; i++) a[i] = a[i - n], a[i].ff += 2 * PI;
        for(int i = 0; i < n; i++)
        {
            x = 0, y = 0;
            for(int j = i; j < n + i; j++)
            {
                x += a[j].ss.ff;
                y += a[j].ss.ss;
                ans = max((ll)ans, x * x + y * y);
            }
        }
        ans = sqrt(ans);
        cout << fixed << setprecision(11) << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(),x.end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

string s,t;
ll solve(){
   ll ans=0;
   

   return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>s>>t;
    int len=s.size();
    int ans=0;
    rep(i,len){
        if(s[i]!=t[i]){
            ans++;
        }
    }
    cout<<ans<<endl;
    //cout<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 3744
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,z;
    char ca,cb,cc;
    cin>>str>>stra>>a>>b>>straa;
    if(str.compare(straa)==0) a--;
    else b--;
    cout<<a<<" "<<b<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1000000007;

#define vec                vector<int>
#define vecll              vector<ll>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mp(v1, v2)       make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  string s;
  cin >> s;

  int ans=0;
  rep(k1,10){
    int i=0;
    while(1){
      if(s[i]-'0'==k1) break;
      else {
        i++;
        if(i==n) break;
      }
    }
    if(i>n-3) continue;
    rep(k2,10){
      int j=i+1;
      while(1){
        if(s[j]-'0'==k2) break;
        else {
          j++;
          if(j==n) break;
        }
      }
      if(j>n-2) continue;
      rep(k3,10){
        int k=j+1;
        while(1){
          if(s[k]-'0'==k3) break;
          else {
            k++;
            if(k==n) break;
          }
        }
        if(k<n){
          ans++;
          //prt3(k1, k2, k3);
        }
      }
    }
  }

  prt(ans);
}


Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {//lcmを求める
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int a, b;
	scanf("%d%d", &a, &b);
	int c = b - a;
	printf("%d\n", allsum(1, c, c) - b);

	Please AC;
}


Measured memory_bytes: 256
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

n = k()
d = l()

count = Counter(d)
if d[0] == 0 and d.count(0) == 1:
    ans = 1
else:
    ans = 0

for i in range(max(count)):
    ans *= count[i]**count[i+1]
    ans %= 998244353
print(ans)


Measured memory_bytes: 23480
def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    m = [0] * n
    m[0] = 0
    for i, hi in enumerate(h):
        if i == 0:
            continue
        s = max(0, i-k)
        m[i] = min([ml + abs(hl - hi) for ml, hl in zip(m[s:i], h[s:i])])
    print(m[-1])

main()


Measured memory_bytes: 13976
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#define endl '\n'
using namespace std;
int main()
{
	string c1,c2,c3;
	cin >> c1 >> c2 >> c3;
	cout << c1[0] << c2[1] << c3[2] << endl;
	return 0;
}

Measured memory_bytes: 3556
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, k, a;
    map<int, int> m;
    cin >> n >> k;
    for (int i = 0; i < n; ++i)
    {
        cin >> a;
        ++m[a];
    }
    vector<int> v;
    for (pair<int, int> p:m)
    {
        v.push_back(p.second);
    }
    sort(v.rbegin(), v.rend());
    int sum = n;
    for(int i = 0, lp = min(k, (int)v.size()); i < lp; ++i)
    {
        sum -= v[i];
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 10744
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll a,b,c, k;
    cin >>a>>b>>c>>k;

    rep(i,0,k)
    {
        if (a>=b && a>=c) a *= 2;
        if (b>=a && b>=c) b *= 2;
        if (c>=b && c>=a) c *= 2;
    }

    cout << a+b+c << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
# define    all(a)              a.begin(), a.end()
#define forn(i, a, b) for (int i=a; i<b; i++)
#define pb push_back
#define mp make_pair
#define MOD int(1e9+7)
using namespace std;

typedef long long int ll;

bool cmp(int a, int b) {
    return a < b;
}

void printV(vector<int> nums) {
    for (int i: nums) {
        printf("%d ", i);// << " ";
    }
    printf("\n");
}

// void printV(vector<ll> nums) {
//     for (ll i: nums) {
//         printf("%lld ", i);// << " ";
//     }
//     printf("\n");
// }



int dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

bool valid(int i, int j, int n, int m) {
    if (i >= 0 && i < n && j >=0 && j < m)
        return true;
    else 
        return false;
}


int main() {
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    // ios_base::sync_with_stdio(false);
    // cin.tie(0);cout.tie(0);
    // time_t start, end;
    // time(&start);
    int a, b;
    char c;
    cin >> a >> c >> b;
    if (c == '+')
        cout << a+b << endl;
    else
        cout << a-b << endl;
    // time(&end); 
    // double time_taken = double(end - start);
    // cout << "Time Taken: " << fixed << time_taken << setprecision(5);
    // cout << " sec" << endl;
    return 0;
} 

Measured memory_bytes: 3636
N,X = [int(i) for i in input().split()]
ans = 0
while N > 0:
    if X >= 2**(N+2) - 4: #N=2 12 N=1 4
        ans += 2**(N+1) - 1
        break
    
    elif X > 2**(N+1) - 1: #N=2 7
        ans += 2**N
        X -= 2**(N+1) - 1
        
    elif X == 2**(N+1) - 1: #N=2 7
        ans += 2**N
        break
    
    elif X == 2**(N+1) - 2: #N=2 6
        ans += 2**N - 1
        break
    
    elif X > 1:
        X -= 1
        
    else:
        break
    N -= 1
print(ans)

Measured memory_bytes: 3188
import sys
t = [None for i in range(10000)]
c = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            for l in range(10):
                t[c] = i + j + k + l 
                c += 1
for line in sys.stdin:
    print(t.count(int(line)))

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

int main(){
    char c ;
    vector<int> cnt(26,0) ;
    while(cin >> c){
        if('a'<=c&&c<='z') cnt.at(c-'a')++ ;
        else if('A'<=c&&c<='Z') cnt.at(c-'A')++ ;
    }
    for(int i=0;i<26;i++){
        cout << (char)('a'+i) << " : " << cnt.at(i) << endl ;
    }
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define ll long long

template<class T> ostream& operator<<(ostream &os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<" ]";
}
template<class L,class R> ostream& operator<<(ostream &os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}
ll mxm(){return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a,Args... args){return max(a,mxm(args...));}
ll mnm(){return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a,Args... args){return min(a,mnm(args...));}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
		const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vi vector<int>
#define vpll vector<pll>
#define vii vector<ii>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define vld vector<ld>
#define vvld vector<vld>
#define I insert
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(),x.end()
#define endl "\n"
#define siz(a)	((int)(a).size())

const int mod=1e9+7;
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

const int N=1e5+5;

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	string s;cin>>s;
	int n=s.size();
	int a=1;
	vvi dp(n+1,vi(13));
	dp[n][0]=1;
	for(int i=n-1;i>=0;i--){
		for(int j=0;j<13;j++){
			for(int k=0;k<=9;k++){
				int rm=((k*a)+j)%13;
				if((s[i]=='?')||(s[i]-'0'==k))
					dp[i][rm]=add(dp[i][rm],dp[i+1][j]);
			}
		}
		a*=10;a%=13;
	}
	cout<<dp[0][5]<<endl;
}

Measured memory_bytes: 8912
# -*- coding: utf-8 -*-
import numpy as np
import math

N,K=map(int,input().split())
prob = [0]*N


for ii in range(1,N+1):
    index = math.ceil(np.log2(K/ii))
    if index <= 0:
        prob[ii-1] = 1/N
    else:
        prob[ii-1] = 1/N * (1/2)**index

print(sum(prob))


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

int n;
int node[2000000];

int parent(int i) {
	return i / 2;
}

int left(int i) {
	return 2 * i;
}

int right(int i) {
	return 2 * i + 1;
}

void swap(int *x, int *y) {
	int tmp;

	tmp = *x;
	*x = *y;
	*y = tmp;
}

void maxHeapify(int *A, int i) {
	int l, r, largest;

	l = left(i);
	r = right(i);

	if (l <= n && A[l] > A[i]) largest = l;
	else largest = i;

	if (r <= n && A[r] > A[largest]) largest = r;
	if (largest != i) {
		swap(&A[i], &A[largest]);
		maxHeapify(A, largest);
	}
}

void heapIncreaseKey(int *A, int i, int key) {
	if (key >= A[i]) {
		A[i] = key;
		while (i > 1 && A[parent(i)] < A[i]) {
			swap(&A[i], &A[parent(i)]);
			i = parent(i);
		}
	}
}

void maxHeapInsert(int *A, int key) {
	n++;
	A[n] = -32768;
	heapIncreaseKey(A, n, key);
}

int heapExtractMax(int *A) {
	int max;

	if (n >= 1) {
		max = A[1];
		A[1] = A[n];
		n--;
		maxHeapify(A, 1);
		return max;
	}

	return -1;
}

main() {
	int key;
	char order[8];

	// node = (int*)malloc(sizeof(int) * (2000000 + 1));

	while (1) {
		scanf("%s", &order);
		if (!strcmp(order, "insert")) {
			scanf("%d", &key);
			maxHeapInsert(node, key);
		}
		else if (!strcmp(order, "extract")) printf("%d\n", heapExtractMax(node));
		else if (!strcmp(order, "end")) break;
	}

	// free(node);

	return 0;
}

Measured memory_bytes: 4696
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <string>
#include <cmath>
#include <map>
#include <vector>
#include <array>
#include <set>
#include <climits>
using namespace std;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    array<array<int,10>,10>arr;
    for(int i=0;i<10;++i){
        for(int j=0;j<10;++j){
            arr[i][j] = 0;
        }
    }
    int n;cin >> n;
    for(int i=1;i<=n;++i){
        int a = i;
        while(a>=10){
            a/=10;
        }
        arr[a][i%10]++;
    }
    int counter{};
    for(int i=0;i<10;++i){
        for(int j=0;j<10;++j){
            counter+=(arr[i][j]*arr[j][i]);
        }
    }
    cout<<counter<<'\n';
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll       long long
#define DS       pair<LL, LL>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    ll n, r;
    cin >> n >> r;
    if (n >= 10) {
        cout << r << '\n';
    } else {
        ll d = r + (100LL * (10LL - n));
        cout << d << '\n';
    }
    return 0;
}


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


int main() {
    int N;
    cin >> N;
    double ans = 0;
    for (int i = 0; i < N; ++i) {
        double num = 0;
        cin >> num;
        ans += 1/num;
    }
    cout << 1/ans << endl;
}

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

public class Main
{
	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
                solve();
            }
        }, "1", 1 << 26).start();
	}
	static void solve () {
		FastReader fr =new FastReader();	PrintWriter op =new PrintWriter(System.out);
 
 		int n =fr.nextInt() ,i ,ans =0 ;

 		long d =fr.nextLong() ,x ,y ,j ;

 		d *= d ;

 		while (n-- > 0) {
 			x =fr.nextLong() ;	y =fr.nextLong() ;

 			x *= x ;	y *= y ;	j =x + y ;

 			if (j <= d)	++ans ;
 		} 

 		op.println(ans) ;

		op.flush();	op.close();
	}
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

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

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

		String nextLine() {
			String str ="";

			try
			{
				str =br.readLine();
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}

			return str;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next()) ;
		}
	}
}

Measured memory_bytes: 54396
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
int a[29];
int b[29];
int c[29];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=1; i<=n; i++) cin>>a[i];
    for(int i=1; i<=n; i++) cin>>b[i];
    for(int i=1; i<n; i++) cin>>c[i];
    int ans=0;
    for(int i=1; i<=n; i++)
    {
        ans+=b[i];
        if(i<n)
        {
            if(a[i]+1==a[i+1])
            {
                ans+=c[a[i]];
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
H,W = map(int,input().split())
ans = 0
if H==1 or W == 1:
  ans = 1
elif H%2==0:
  ans = H * W // 2
elif W%2 == 0:
  ans = H * W // 2
else:
  ans = (H * W) // 2 + 1
print(ans)

Measured memory_bytes: 2940
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <complex>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << "\n"
#define input(X) getline(cin,X)
static const int INF = 1e+9+7;
static const ll INFL = 1e+18+7;
ll n,m,l;
int p;
string s,t;
ll d[200010],dp[300][300];
char field[200][200];

vc split(string args){
  vc res;
  rep(i,0,args.sz){
    switch(args[i]){
      case '(':
      case ')':
      case '[':
      case ']':
        res.pb(args[i]);
        break;
      default:
        break;
    }
  }
  return res;
}

int main(){
  while(input(s),s != "."){
    stack<char> ans;
    vc vec = split(s);
    rep(i,0,vec.sz){
      if(vec[i] == '[' || vec[i] == '(')ans.push(vec[i]);
      else{
        if(ans.empty())ans.push(vec[i]);
        else if(vec[i] == ']'){
          if(ans.top() == '[')ans.pop();
          else ans.push(vec[i]);
        }else if(vec[i] == ')'){
          if(ans.top() == '(')ans.pop();
          else ans.push(vec[i]);
        }
      }
    }
    if(ans.empty())puts("yes");
    else puts("no");
  }
  return 0;
}


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

int main(){
    int n, i, t, m;
    long long r = 0;
    cin >> n;
    int a[n];
    for(i=0; i<n; i++){
        cin >> t;
        a[i] = t - (i+1);
    }
    sort(a, a+n);
    if(n%2 == 0){
        m = (a[n/2]+a[n/2])/2;
    }else{
        m = a[n/2];
    }
    for(i=0; i<n; i++){
        r += (long long)abs(a[i]-m);
    }
    cout << r;
    return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    int n; cin >> n;
    ll cnt1 = 0, cnt2 = 0;
    for(int i = 0; i < n; i++){
        ll a; cin >> a;
        if(a % 4 == 0) cnt1++;
        if(a % 2 == 0) cnt2++;
    }
    if(cnt1 == 0){
        if(cnt2 == n){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else if((n % 2 == 1 && cnt1 % 2 == 1) || (n % 2 == 0 && cnt1 % 2 == 0)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
s = input()
pre = s[:2]
suf = s[2:]


def is_yy(s):
    return s <= "00" or "13" <= s


if is_yy(pre) and is_yy(suf):
    print("NA")
elif is_yy(pre) and not is_yy(suf):
    print("YYMM")
elif not is_yy(pre) and is_yy(suf):
    print("MMYY")
else:
    print("AMBIGUOUS")


Measured memory_bytes: 3060
s = input()
flag = False
flag1 = True
flag2 = False
for i in range(len(s)):
    if flag1 and s[i] == 'C':
        flag1 = False
        flag2 = True
    if flag2 and s[i] == 'F':
        flag = True
        break
if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<int(n);i++)
using namespace std;
int main(){
    string s, t;
    cin >> s >> t;
    s=s+s;
    int ans=s.find(t);
    if(ans!=string::npos) cout << "Yes" << endl;
    else cout << "No"<<endl;
    return 0;
}

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 <climits>
#include <string>
#include <bitset>
#include <cfloat>
#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;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#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
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const ll MOD = 1000000007;
const double EPS = 1e-9;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;



int main(void){

    ll n,a,b;
    cin>>n>>a>>b;
    if(a%2==b%2){
        cout<<(b-a)/2<<endl;
        return 0;
    }
    ll ans=LLINF;
    ll hasi=a-1+1;
    ans=min(ans,hasi+(b-hasi)/2);
    hasi=n-b+1;
    ans=min(hasi+(n-(a+hasi))/2,ans);
    fin(ans);

}


Measured memory_bytes: 256
import numpy as np

N, K = [int(x) for x in input().split()]
A = np.array([int(x) for x in input().split()])
I = np.array([1] * N)

L = np.max(A)

ans = L
low = 1
high = L
while 1:
    if low == high:
        ans = low
        break
    
    mid = (low + high) // 2
    if np.sum((A - I) // mid) <= K:
        high = mid
    else:
        low = mid + 1

print(ans)

Measured memory_bytes: 49300
#include<bits/stdc++.h>
#include<iomanip>
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mxn 200006
#define mod 1000000007
#define ld long double
#define pb push_back
#define inf 1e18
#define fi first
#define se second
typedef long long int ll;
using  namespace std;
set<int>g[mxn];
int sz[mxn],cc=0,com[mxn];
bool vis[mxn];
void dfs(int u){
	vis[u]=1;
	com[u]=cc;
	sz[cc]++;
	for(auto x:g[u]){
		if(vis[x])
		continue;
		dfs(x);
	}
}
int main(void){
	#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	fast;
	int n,m,x,y,ans=1,i;
	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>x>>y;
		g[x].insert(y);
		g[y].insert(x);
	}
	for(i=0;i<n;i++){
		if(!vis[i]){
			++cc;
			dfs(i);	
		}
	}
	for(i=1;i<=n;i++)
	ans=max(ans,sz[i]);
	cout<<ans;
}


Measured memory_bytes: 38960
from collections import deque

N = int(input())

A = [0]
child = [0] * N
cnlis = [ [] for i in range(N) ]
depth = [0] * N

for i in range(N-1):

    a = int(input())
    a -= 1

    A.append(a)
    child[a] += 1


q = deque([])

for i in range(N):
    if child[i] == 0:
        q.append(i)

while len(q) > 0:

    now = q.pop()

    owndep = 0

    cnlis[now].sort()

    for i in range(len(cnlis[now])):

        owndep = max(owndep , cnlis[now][i] + len(cnlis[now]) - i)

    depth[now] = owndep

    if now == 0:
        break

    pair = A[now]

    child[pair] -= 1
    cnlis[pair].append(owndep)

    if child[pair] <= 0:
        q.append(pair)

print (depth[0])


Measured memory_bytes: 23832
#include<bits/stdc++.h>
using namespace std;
//define
#define int long long
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define Rep(x,y) for(int k=x;k<y;k++)
#define str string
#define vint vector<int>
#define vvint vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vool vector<bool>
#define vtr vector<str>
#define vvtr vector<vector<str>>
#define pb() push_back()
#define elif else if
#define all(x) x.begin(),x.end()
//function
int shizuku(int);
//UnionFind
struct UnionFind{
  vint par;
  UnionFind(int N):par(N){
    rep(0,N)par[i]=i;
  }
  int root(int x){
    if(par[x]==x)return x;
    return par[x]=root(par[x]);
  }
  void unite(int x,int y){
    int rx=root(x);
    int ry=root(y);
    if(rx==ry)return;
    par[rx]=ry;
  }
  bool same(int x,int y){
    return root(x)==root(y);
  }
};

signed main(){
    int pow,D,G,N,M,X,count=0,count2=0;
    double d;
    int C='A'-'a';
    char op;
    str S,T;
    cin>>N>>M;

    cout<<(N*3+M)/2<<endl;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  while (true) {
    int n, m, a; cin >> n >> m >> a;
    if (n == 0) return;
    vi32 v(n);
    iota(all(v), 1);
    vector<vector<pair<int, int>>> H(1001);
    rep(i, m) {
      int h, p, q; cin >> h >> p >> q;
      p--, q--;
      H[h].emplace_back(p, q);
    }
    reps(i, 1000) {
      each(h, H[i]) {
        int p, q;
        tie(p, q) = h;
        swap(v[p], v[q]);
      }
    }
    cout << v[a - 1] << '\n';
  }
}



Measured memory_bytes: 3128
from collections import deque

def breadth_first_search(start):
    work_q = deque([])
    visited = set()
    work_q.append(start)
    visited.add(start)
    cnt_array = [0] * (n+1)
    while work_q:
        here = work_q.popleft()
        for i in edge[here]:
            if i not in visited:
                work_q.append(i)
                visited.add(i)
                cnt_array[i] = cnt_array[here] + 1
    return cnt_array

n,x,y = map(int,input().split())
edge = []
for i in range(n+1):
    edge.append([])
for i in range(1,n+1):
    if i != n:
        edge[i].append(i+1)
    if i != 1:
        edge[i].append(i-1)
edge[x].append(y)
edge[y].append(x)

ans = [0] * n
for i in range(1, n+1):
    a = breadth_first_search(i)
    for j in range(len(a)):
        ans[a[j]] += 1
for i in range(1,n):
    print(ans[i]//2)


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

int main(){
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;//ここまで入力
  
  int cnt=0;//カウンター
  for (int i=0;i<n-1;++i){
    if (s[i]==s[i+1]) cnt++;//文字の連続が何個あるか
  }
  int ans=0;//答を初期値化、今後、更新
  ans=min(cnt+2*k,n-1);
  //1回の操作で最大2個幸せが増える
  //全員同じ方向なら、最大n-1の幸せ
  //2数の小さい方で更新

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int N;   cin >> N;
  ll ans = 1;
  
  vector<ll> A(N); REP(i,N) cin >> A.at(i);
  
  sort(ALL(A));
  
  REP(i,N){
    if(A.at(i) == 0){
      cout << "0" << endl;
      return 0;
    }
    if(A.at(i) > 1000000000000000000 / ans){
      cout << "-1" << endl;
      return 0;
    }
    ans *= A.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3996