akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
const long long mod = 1e9 + 7;
typedef long long ll;  // ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>  // chmin(min,a)
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>  // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
     
template<typename T>
T gcd(T a, T b){
	return b != 0 ? gcd(b, a % b) : a;
}    

int main() {
  ll x=0,y=0,z=0,k,n,m,h,w,ans=0,sum=0,Max=-1,Min=1e9+1;
  bool ok = true;
  string s,t,r;
  cin >> n;
  VS a(n);
  rep(i,n) cin >> a[i];
  map<string,ll> mp;
  
  for(int i=0; i<n; i++) {
    auto itr = mp.find(a[i]);
    if(itr == mp.end()) 
      mp.insert(make_pair(a[i],1));
  }

  for( auto i = mp.begin(); i != mp.end();i++ ) { 
    ans += i->second;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 25076
A,B,C,D = map(int,input().split())

# T君が必要な攻撃回数
tAttack = -(-C//B)
# A君が必要な攻撃回数
aAttack = -(-A//D)

if tAttack <= aAttack:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9172
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N;
int p2[201010], p5[201010];
int cnt[60][30];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	
	rep(i, 0, N) {
		string s; cin >> s;

		ll x = 0;
		bool f = false;
		int rest = 9;
		fore(c, s) {
			if (c != '.') {
				x = x * 10 + c - '0';
				if (f) rest--;
			}
			else f = true;
		}
		rep(j, 0, rest) x *= 10;

		while (x % 2 == 0) x /= 2, p2[i]++;
		while (x % 5 == 0) x /= 5, p5[i]++;
	}
	rep(i, 0, N) cnt[p2[i]][p5[i]]++;

	ll ans = 0;
	rep(i, 0, N) {
		int need2 = max(18 - p2[i], 0);
		int need5 = max(18 - p5[i], 0);
		rep(i2, need2, 60) rep(i5, need5, 30) ans += cnt[i2][i5];
		if (need2 <= p2[i] && need5 <= p5[i]) ans--;
	}
	ans /= 2;
	cout << ans << endl;
}







Measured memory_bytes: 5232
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, const T& t){ return v2<T>(r, vector<T>(c, t)); }
#define F first
#define S second

const int MOD = 1e9+7; //998244353;
inline int add(int a, int b){ return (a+b)%MOD; }
inline int sub(int a, int b){ return ((a-b)%MOD + MOD)%MOD; }
inline int mul(int a, int b){ return ((ll)a*b)%MOD; }
int pwr(int a, int b){
    if(!b) return 1;
    int temp = pwr(a, b/2);
    if(b%2) return mul(mul(temp, temp), a);
    return mul(temp, temp);
}
inline int dvd(int a, int b){ return mul(a, pwr(b, MOD-2)); } // MOD SHOULD BE PRIME 

void solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) cin >> a[i];

    int sum = 0;
    for(int i = 0; i < n; ++i) sum = add(sum, a[i]);

    int ans = 0;
    for(int i = 0; i < n; ++i){
        int x = sub(sum, a[i]);
        ans = add(ans, mul(a[i], x));
    }
    ans = dvd(ans, 2);

    cout << ans << '\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3988
N,M = map(int,input().split())

a = []

for i in range(N):
  b = list(map(int,input().split()))
  a.append(b)
           
c = [0]*M

for i in range(N):
	for j in range(M):
		c[j] += a[i][1:].count(j+1) 

ans = 0

for i in range(M):
  if c[i] == N:
    ans += 1

print(ans)
  


Measured memory_bytes: 3060
#!/usr/bin/python3
# import bisect
# from collections import Counter, deque, OrderedDict, defaultdict
# from copy import copy, deepcopy # pythonのみ．copyは1次元，deepcopyは多次元．
# from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
# from functools import reduce
from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    x,y,z,k=map(int,input().split())
    A=sorted(list(map(int,input().split())),reverse=True)
    B=sorted(list(map(int,input().split())),reverse=True)
    C=sorted(list(map(int,input().split())),reverse=True)

    h=[]
    heapify(h)
    ac,bc,cc=0,0,0

    heappush(h, (-(A[ac]+B[bc]+C[cc]), ac,bc,cc))
    checked=set()

            
    checked.add((-(A[ac]+B[bc]+C[cc]),ac,bc,cc))


    for _ in range(k):
        (p,ac,bc,cc)=heappop(h)
        print(-p)
        if ac+1<x:
            if (-(A[ac+1]+B[bc]+C[cc]), ac+1,bc,cc) not in checked:
                heappush(h, (-(A[ac+1]+B[bc]+C[cc]), ac+1,bc,cc))
                checked.add((-(A[ac+1]+B[bc]+C[cc]), ac+1,bc,cc))

        if bc+1<y:  
                        
            if (-(A[ac]+B[bc+1]+C[cc]), ac,bc+1,cc) not in checked:
                heappush(h, (-(A[ac]+B[bc+1]+C[cc]), ac,bc+1,cc))
                checked.add((-(A[ac]+B[bc+1]+C[cc]), ac,bc+1,cc))
        if cc+1<z:
            if (-(A[ac]+B[bc]+C[cc+1]), ac,bc,cc+1) not in checked:
                heappush(h, (-(A[ac]+B[bc]+C[cc+1]), ac,bc,cc+1))
                checked.add((-(A[ac]+B[bc]+C[cc+1]), ac,bc,cc+1))




    


    


    
resolve()

Measured memory_bytes: 75856
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#define min(x, y) (x > y ? y : x)
#define LIMITED 1000000007
using namespace std;

/* 
W = 1
 pat = 1 (0)
W = 2
 pat = 2 (1)
W = 3
 pat = 3 (1)
W = 4
 pat = 5 (2,1)
W = 5
 pat = 8 (3,2)
W = 6
 pat = 13 (5,3,4)
W = 7
 pat = 21 (8,5,6)  
W = 8
 pat = 34 (13,8,10,9)
*/
int sum[9] = {0, 1, 2, 3, 5, 8, 13, 21, 34};
int pat[9][7] = {
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0},
    {1, 0, 0, 0, 0, 0, 0},
    {1, 1, 0, 0, 0, 0, 0},
    {2, 1, 2, 0, 0, 0, 0},
    {3, 2, 2, 3, 0, 0, 0},
    {5, 3, 4, 3, 5, 0, 0},
    {8, 5, 6, 6, 5, 8, 0},
    {13, 8, 10, 9, 10, 8, 13},
};

long  anstable[100][8] = {0};

void calc_dp(int H, int W)
{
    anstable[0][0] = 1;
    for (int i = 1; i <= H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (j != 0)
            {
                anstable[i][j] = anstable[i - 1][j - 1] * pat[W][j - 1] + anstable[i-1][j] * (sum[W] - pat[W][j] - pat[W][j-1]) + anstable[i-1][j+1] * pat[W][j];
            }
            else
            {
                anstable[i][j] = anstable[i-1][j] * (sum[W] - pat[W][j]) + anstable[i-1][j+1] * pat[W][j];
            }
            anstable[i][j] %= LIMITED;
            //printf("i%d j%d :%d\n",i,j,anstable[i][j]);
        }
    }
}

int main()
{
    int H, W, K;
    cin >> H >> W >> K;

    calc_dp(H, W);

    cout << anstable[H][K-1] << endl;
}

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

long long h,w,n;
int dx[9]={-1,0,1,-1,0,1,-1,0,1};
int dy[9]={-1,-1,-1,0,0,0,1,1,1};

long long int ans[12];
map<pair<int,int> ,int>mp;


int main(){

	// Input and Init
	cin>>h>>w>>n;
	ans[0]=(h-2)*(w-2);
	for(int i=1;i<10;i++){ans[i]=0ll;}
	
	// Solve
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		for(int j=0;j<9;j++){
			int nh=a+dy[j],nw=b+dx[j];
			if(1<nh && nh<h && 1<nw && nw<w){
				if(mp.count(make_pair(nh,nw))){
					ans[mp[make_pair(nh,nw)]]--;
					mp[make_pair(nh,nw)]++;
					ans[mp[make_pair(nh,nw)]]++;
				}
				else{
					mp[make_pair(nh,nw)]=1;
					ans[0]--;ans[1]++;
				}
			}
		}
	}

	for(int i=0;i<10;i++){
		cout<<ans[i]<<endl;
	}
	return(0);
}

Measured memory_bytes: 56448
#include <bits/stdc++.h> 
    #include<ext/pb_ds/assoc_container.hpp> 
    #include<ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    using namespace std;
    template <typename T>
    using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
    #define int long long  
    typedef long double ld;
    #define pb push_back
    #define f(i,a,b) for(int i=a;i<b;i++)
    #define fd(i,a,b) for(int i=a-1;i>=b;i--)
    #define pf push_front
    #define fi first
    #define pii pair<int,int>
    #define mii map<int,int>
    #define vc vector
    #define se second
    #define INF 1e18
    const int mod=1e9+7; 
    
    int gcd(int a, int b) 
    { 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
    } 
    void swap(int a,int b)
    {
      int temp=a;
      a=b;
      b=temp;
    } 
    int dp[3000+5][3000+5]={};
    signed main() {
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
   /* #ifndef ONLINE_JUDGE
      if(fopen("INPUT.txt","r"))
      {
      freopen ("INPUT.txt" , "r" , stdin);
      freopen ("OUTPUT.txt" , "w" , stdout); 
      }
    #endif  
    */
    // -------------------------------------Code starts here--------------------------------------------------------------------- 
    int t=1;
      //cin>>t;
    while(t--)
    {
      string s,t;
      cin>>s>>t;
      string a="";
      int n=s.length();
      int m=t.length();
      f(i,0,m+1)
      {
        dp[0][i]=0;
      }
      f(i,0,n+1)
      {
        dp[i][0]=0;
      }
      f(i,1,n+1)
      {
        f(j,1,m+1)
        {
          if(s[i-1]==t[j-1])
          {
            dp[i][j]=dp[i-1][j-1]+1;
          }
          else if(dp[i-1][j]>dp[i][j-1])
          {
            dp[i][j]=dp[i-1][j];
          }
          else
          {
            dp[i][j]=dp[i][j-1]; 
          }
        }
      }
          
      int i=n,j=m;
      while(i>0 && j>0 )
      {
        if(s[i-1]==t[j-1])
        {
          a+=s[i-1];
          i--;
          j--;
        }
        else if(dp[i][j-1]>dp[i-1][j])
        {
          j--;
        }
        else
          i--;
      }
      reverse(a.begin(),a.end());
      cout<<a<<endl;
    }
} 

Measured memory_bytes: 70784
#include <stdio.h>

int
main(int argc, char *argv[])
{
  long n, k, x[100000],f;
  scanf("%ld%ld", &n, &k);
  for(int i = 0; i < n; i ++){
    scanf("%ld", &x[i]);
  }
  
  if(x[0] >= 0){
    printf("%ld\n", x[k - 1]);
  }
  
  else if(x[n - 1] <= 0){
    printf("%ld\n",- x[n - k]);
  }
  
 
  else if(x[0] < 0 && x[n - 1] >= 0){
    long m = 1000000000; long t = 1000000000;
    for(int i = 0; i < n; i++){
      if(x[i] < 0 && x[i + 1] >= 0){
        f = i + 1;
      }
    }
    
    for(int i = 0; i < n - f; i++){
      if(k - i - 1 <= f && k - i - 1 > 0){
        if(x[f + i] > -x[f - k + i + 1]){
          t = -2*x[f - k + i + 1] + x[f + i];
        }
        else {
          t = 2*x[f + i] - x[f - k + i + 1];
        }
       // printf("%ld %d\n", t, i);
         if(m > t){ m = t;}
      }
      else if(k - i - 1 == 0){
        t = x[f + k - 1];
       // printf("%ld %d\n", t, i);
         if(m > t){ m = t;}
      }
     
    }
    
    printf("%ld\n", m);
  }
  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long ll;

const int MAXN = 1e5 + 10;
ll v[MAXN] , ans[MAXN] , has[MAXN];
int sum = 1 , q , n;
int main(){
    cin >> n >> q;
    v[1] = n;
    for(int i = 1 ; i <= q ; ++ i){
        ll x;
        cin >> x;
        while(sum && x < v[sum])
        	sum --;
        v[++ sum] = x;
    }
    has[sum] = 1;
    for(int i = sum ; i >= 1 ; -- i){
    	if(has[i] == 0) continue;
    	ll now = v[i];
    	int last = i;
    	while(true){
			int ll = 0 , rr = last - 1;
			while(ll < rr){
				int mid = (ll + rr + 1) >> 1;
				if(now >= v[mid])
					ll = mid;
				else
					rr = mid - 1;
			}
			if(ll == 0){
				ans[now] += has[i];
				break;
			}
			else{
				has[ll] += now / v[ll] * has[i];
				now %= v[ll];
				last = ll;
			}	
		}
    }
    for(int i = n ; i >= 1 ; -- i)
    	ans[i - 1] += ans[i];
    for(int i = 1 ; i <= n ; ++ i)
    	cout << ans[i] << endl;
    return 0;
}

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

int main() {
  int a,b,c;
    cin>>a>>b>>c;
  if(a==5){
    if(max(b,c)==7 && min(b,c)==5){cout<<"YES"<<endl;}
      else{cout<<"NO"<<endl;}
    }
  if(a==7)
    if(b==5&&c==5){cout<<"YES"<<endl;}
    else{cout<<"NO"<<endl;}
  if(a!=7&&a!=5){cout<<"NO"<<endl;}
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
// const ll MOD = 1e9 + 7;
const ll MOD = 998244353;

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








int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    cout << (((a < c && c < b) || (b < c && c < a))? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
const Int MOD = 1000000007;
Int modpow(Int x, Int y) {
    if (y == 0) return 1;
    else if (y % 2 == 0) return modpow(x * x % MOD, y / 2);
    else return x * modpow(x, y - 1) % MOD;
}
int main() {
    int N; cin >> N;
    vector<int> A(N); for (auto &a : A) cin >> a;
    vector<vector<pair<int, int>>> B(N);
    for (int i = 0; i < N; i++) {
        int a = A[i];
        for (int p = 2; p * p <= a; p++) {
            int cnt = 0;
            while (a % p == 0) cnt++, a /= p;
            if (cnt) B[i].emplace_back(p, cnt);
        }
        if (a != 1) B[i].emplace_back(a, 1);
    }
    map<int, int> M;
    for (auto &b : B) for (auto &p : b) {
        M[p.first] = max(M[p.first], p.second);
    }
    Int C = 1;
    for (auto &p : M) {
        C = (C * modpow(p.first, p.second)) % MOD;
    }
    Int ans = 0;
    for (auto a : A) {
        ans = (ans + C * modpow(a, MOD - 2)) % MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1280
function main(input) {
  const args = input.split(' ');
  const A = parseInt(args[0], 10);
  const B = parseInt(args[1], 10);
  if((A+B)%2==0){
    console.log((A+B)/2);
  }else{
    console.log("IMPOSSIBLE");
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21952
use itertools::iproduct;
use proconio::input;

fn main() {
    input!(r: usize, c: usize, goods: [(usize, usize, u64)]);

    let mut val = array![0; r + 1, c + 1];
    for &(r, c, v) in &goods {
        val[r][c] = v;
    }

    let mut dp = array![0; r + 1, c + 1, 4];
    for (i, j, k) in iproduct!(1..=r, 1..=c, (0..=3).rev()) {
        max_assign!(dp[i][j][0], dp[i - 1][j][k]);
        max_assign!(dp[i][j][k], dp[i][j - 1][k]);
        max_assign!(dp[i][j][1], dp[i - 1][j][k] + val[i][j]);
        if k > 0 {
            max_assign!(dp[i][j][k], dp[i][j - 1][k - 1] + val[i][j]);
        }
    }

    println!("{}", dp[r][c].iter().max().unwrap())
}

#[macro_export]
macro_rules! array {
    ($v:expr; $l:expr, $($r:expr),*) => { vec![array!($v; $($r),*); $l] };
    ($v:expr; $l:expr) => { vec![$v; $l] };
    () => { vec![] };
}

#[macro_export]
macro_rules! max_assign {
    ($x:expr, $y:expr) => {{
        let rhs = $y;
        if $x < rhs {
            $x = rhs;
            true
        } else {
            false
        }
    }};
}


Measured memory_bytes: 713608
import math
n = int(input())


def prime_factorization(num):
    sqrt_num = math.sqrt(num)
    prime_numbers = []
    for i in range(2, int(sqrt_num) + 1):
        # print(num)
        while num % i == 0:
            # print(num)
            num = num / i
            prime_numbers.append(i)
    if num != 1:
        prime_numbers.append(int(num))
    return prime_numbers


print(str(n) + ":", *prime_factorization(n))



Measured memory_bytes: 5660
#include <stdio.h>
#include <string.h>
#include <math.h>

int main () {
	char buff[64];
	int weeks;
	float result = 100.0f;
	
	fgets (buff, 64, stdin);
	sscanf (buff, "%d", &weeks);

	for (int i = 0; i < weeks; i++) {
		result = ceil(result * 1.05f);
	}
	
	printf ("%.0f\n", result * 1000.0f);
	
	return 0;
}



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

int main() {
    int N;
    cin >> N;
    vector<ll> L(N);
    for (int i=0; i<N; i++){
        cin >> L.at(i);
    }

    //
    int count = 0;
    for (int i=0; i<N; i++) {
        for (int j=i+1; j<N; j++) {
            if (L.at(i) != L.at(j)) {
                for (int k=j+1; k<N; k++) {
                    if (L.at(i) != L.at(k) and L.at(j) != L.at(k)) {
                        if (L.at(i)<L.at(j)+L.at(k) and L.at(j)<L.at(k)+L.at(i) and L.at(k)<L.at(i)+L.at(j))
                        count++;
                    }
                }
            }
        }
    }

    //
    cout << count << endl;
}

Measured memory_bytes: 3636
class Test
  def initialize(m, books)
    @m, @books = m, books
    @li = @books.count - 1
  end 

  def main
    l, r = 0, [1_500_000, @books.reduce(:+)].min

    while r - l > 1 do
      m = (r + l) / 2 
      check(m) ? r = m : l = m
    end 
    r   
  end 

  def check(v)
    idx = 0 
    @m.times.each do
      vv = v 
      while vv > 0 do
        vv -= @books[idx]
        next if vv < 0 
        return true if idx == @li
        idx += 1
      end 
    end 
    false
  end 
end

loop do
  m, s = STDIN.gets.split(' ').map(&:to_i)
  break if [m, s] == [0, 0]

  books = s.times.map { STDIN.gets.to_i }

  puts Test.new(m, books).main
end

Measured memory_bytes: 8768
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
    long long n;
    long long a;
    long long b;
    long long c;
    long long d;
    cin>>n>>a>>b;
    if(labs(a-b)%2==0){
        cout<<labs(a-b)/2;
    }else if(labs(a-b)%2==1){
        if(labs(a-b)==1){
            if(a<n/2&&b<2/n){
                cout<<max(a-1,b-1);
            }else if(a>n/2&&b>n/2){
                cout<<max(n-a,n-b);
            }else{
                c=max(a,b);
                d=min(a,b);
                cout<<min(c-1,n-d);
            }
        }else{
            c=max(a,b);
            d=min(a,b);
            if(n-c<d-1){
                cout<<n-c+1+(c-d-1)/2;
            }else{
                cout<<d+(c-d-1)/2;
            }
        }
    }
    
    
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 29);

int main()
{
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, int>>> adj(n);
  for (int i = 0; i < m; i++)
  {
    int s, t, w;
    cin >> s >> t >> w;
    adj.at(s).push_back({t, w});
    adj.at(t).push_back({s, w});
  }
  int cost = 0;
  vector<bool> color(n, false);
  vector<int> d(n, INF);
  d.at(0) = 0;
  while (1)
  {
    int mincost = INF, u;
    for (int i = 0; i < n; i++)
    {
      if (color.at(i))
      {
        continue;
      }
      if (d.at(i) < mincost)
      {
        mincost = d.at(i);
        u = i;
      }
    }
    if (mincost == INF)
    {
      break;
    }
    cost += mincost;
    color.at(u) = true;
    for (int i = 0; i < adj.at(u).size(); i++)
    {
      auto p = adj.at(u).at(i);
      if (color.at(p.first))
      {
        continue;
      }
      if (p.second < d.at(p.first))
      {
        d.at(p.first) = p.second;
      }
    }
  }
  cout << cost << endl;
}


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

int main()
{
	long long int a,b,k,c,d;

	cin>>a>>b>>k;

	if(a<=k)
    {
      d=(a+b)-k;
      c=0;
    }
    else
    {
      c=a-k;
      d=b;
    }
  
  if(a+b<k)
  {
    c=0;d=0;
  }

	cout<<c<<" "<<d;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef int_fast64_t ll;
signed main() {
    int_fast32_t X,Y,Z,K;
    cin >> X >> Y >> Z >> K;
    ll A[X], B[Y], C[Z];
    rep(i, X) scanf("%lld", A+i);
    rep(i, Y) scanf("%lld", B+i);
    rep(i, Z) scanf("%lld", C+i);
    vector<ll> AB;
    rep(i, X)rep(j, Y) AB.push_back(A[i]+B[j]);
    sort(AB.begin(),AB.end(),greater<ll>());
    vector<ll> ABC;
    rep(i, min(X*Y, K))rep(j, Z) ABC.push_back(AB[i]+C[j]);
    sort(ABC.begin(),ABC.end(),greater<ll>());
    rep(i, K) printf("%lld\n", ABC[i]);
}

Measured memory_bytes: 43236
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  int A[110]={};

  for(int i=0;i<n;i++)cin>>A[i];

  int ans = 0;
  for(int i=0;i<110;i++){
    int cnt = 0;
    for(int j=0;j<n;j++)cnt += A[j]>=i;
    if(cnt>=i) ans = i;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3120
import java.util.Scanner;
import java.util.ArrayList;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    ArrayList <Integer> li = new ArrayList <Integer>();
    ArrayList <Integer> lili = new ArrayList <Integer>();
    for(int i=0;i<9;i++){
      int a = sc.nextInt();
      li.add(a);
    }
    int n = sc.nextInt();
    for(int i=0;i<n;i++){
      int a = sc.nextInt();
      lili.add(a);
    }
    for(int i=0;i<9;i++){
      for(int k=0;k<n;k++){
        if(li.get(i)==lili.get(k)){
          li.set(i,0);
        }
      }
    }
    if(li.get(0)+li.get(1)+li.get(2)==0
       ||li.get(3)+li.get(4)+li.get(5)==0
       ||li.get(6)+li.get(7)+li.get(8)==0
       ||li.get(0)+li.get(3)+li.get(6)==0
       ||li.get(1)+li.get(4)+li.get(7)==0
       ||li.get(2)+li.get(5)+li.get(8)==0
       ||li.get(0)+li.get(4)+li.get(8)==0
       ||li.get(2)+li.get(4)+li.get(6)==0){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int n;
int l[8];
int hoge[8];
int a[3];
int ans = INF;

void eval() {
    //inc(i, 0, n) cout << hoge[i];
    //cout << endl;
    int res = 0;
    inc(k, 0, 3){
        int sum = 0;
        int cnt = 0;
        inc(i, 0, n){
            if(hoge[i] == k){
                sum += l[i];
                cnt++;
            }
        }
        if(cnt == 0) return;
        res += (cnt-1)*10 + abs(sum-a[k]);
    }
    ans = min(ans, res);
}

void dfs(int i) {
    if(i == n){
        eval();
        return;
    }
    inc(k, 0, 4){
        hoge[i] = k;
        dfs(i+1);
    }
    return;
}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    cin >> n;
    inc(i, 0, 3) cin >> a[i];
    inc(i, 0, n) cin >> l[i];
    dfs(0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
     string S;
     cin >> S;

     int ans = 0;
     int count = 0;
     for(int i = 0; i < S.size(); i++){
          if(S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C'){
               count++;
               ans = max(ans,count);
          }else{
               count = 0;
          }
     }

     cout << ans << endl;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
 
#if DEBUG
    #include "debug.h"
#else
    #define debug(args...)
#endif    

using namespace std;

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


#define M 1000000 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int INF = INT_MAX;
const int mod = 1e9+7;

const int N = 1e6 + 10;
inline int add(int x,int y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline int mul(int x,int y){
  x = (1LL * x * y) % mod;
  return x;
}
inline int pow_(ll x, ll y, int p = mod){
  ll r = 1; while(y){if(y & 1) r = r * x % p; y >>= 1; x = x * x % p;} return r;
}
inline int inv_(int x){return pow_(x, mod - 2, mod);}	
clock_t time_p=clock();

int spf[N];
int a[N];
unordered_map<int,int>aa[N];

int32_t main(){
	fast;

	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);

	FOR(i,1,1e6)spf[i] = i;
	FOR(i,2,1e6) {
		if(spf[i] == i) {
			for(int j = i; j <= 1e6; j+=i) {
				if(spf[j] == j)spf[j]= i;
			}
		}
	}

	int n;
	cin >> n;
	FOR(i,1,n)cin >> a[i];
	unordered_map<int,int>mt;
	FOR(i,1,n) {
		int x = a[i];
		while(x > 1) {
			int pp = spf[x];
			int cc = 0;
			while(x % pp == 0 and x > 1)x /= pp, cc++;
			mt[pp] = max(mt[pp],cc);
			aa[i][pp] = cc;
		}
	}
	// debug(mt);
	// FOR(i,1,n)debug(aa[i]);
	int lc = 1;
	for(auto x : mt) {
		lc = mul(lc, pow_(x.F,x.S));
	}
	int ans = 0;
	FOR(i,1,n) {
		int bb = lc;
		for(auto x : aa[i]) {
			bb = mul(bb, inv_(pow_(x.F,x.S)));
		}
		ans = add(ans,bb);
		// debug(i,bb);
	}
	cout << ans << "\n";
	time_p=clock()-time_p;
	cerr<<"\nTime Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";

	return 0;
}

Measured memory_bytes: 63360
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;
 
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair
 
static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
typedef pair<pii,string> ttt;
static const int INF=1<<24;
 
template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
    v.assign(a,vector<T>(b,t));
}
 
//v.erase(unique(v.begin(),v.end()),v.end());


int main(){
	int n;
	bool f=false;
	while(cin>>n,n){
		if(f){
			cout<<endl;
			// f=true;
		}
		vector<ttt> v(n);
		rep(i,n){
			string s;
			int a,b,c;
			cin>>s>>a>>b>>c;
			v[i]=mkp(mkp(-3*a-c,i),s);
		}
		sort(ALL(v));
		rep(i,n){
			cout<<v[i].S<<","<<-v[i].F.F<<endl;
		}
		f=true;
	}
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define F first
#define S second
#define pb push_back
const ll N = 1e6 + 10, MOD =  1e9 + 7, INF = 1e18;
const long double PI = acos(-1);
int n, len, t, xD;
vector <int> all;
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> len >> t;
	for (int i = 0; i < n; i++){
		int dir, pos;
		cin >> pos >> dir;
		if (dir == 2) dir = -1;
		all.pb(((pos + dir * t) % len + len) % len);
		if (dir == 1){
			xD = (xD + (pos + t) / len) % n;
		}
		if (dir == -1){
			xD = ((xD - (len - pos + t - 1) / len) % n + n) % n;
		}
	}
	sort(all.begin(), all.end());
	for (int i = 0; i < n; i++){
		cout << all[(i + xD) % n] << '\n';
	}
    return 0;
}

Measured memory_bytes: 3816
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {


    public static void main(String[] args) {
        try (CustomReader in = new CustomReader()) {
            new Main().execute(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static final int MAX_INDEX = 100001;

    public void execute(CustomReader in) throws IOException {

        final int N = in.readLineAsInt();
        final int n = N / 2;
        int[] v = in.readLineAsIntArray();

        int[] oddCount = new int[MAX_INDEX];
        int[] evenCount = new int[MAX_INDEX];

        int oddMax = 0, oddMaxNumber = 0;
        int evenMax = 0, evenMaxNumber = 0;
        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                evenCount[v[i]]++;
                if (evenCount[v[i]] > evenMax) {
                    evenMax = evenCount[v[i]];
                    evenMaxNumber = v[i];
                }
            } else {
                oddCount[v[i]]++;
                if(oddCount[v[i]] > oddMax) {
                    oddMax = oddCount[v[i]];
                    oddMaxNumber = v[i];
                }
            }
        }
        Arrays.sort(oddCount);
        Arrays.sort(evenCount);
        int ans = -1;

        if(oddMaxNumber == evenMaxNumber){
            ans = Math.min(
                    (n - oddCount[MAX_INDEX - 1]) + (n - evenCount[MAX_INDEX - 2]),
                    (n - oddCount[MAX_INDEX - 2]) + (n - evenCount[MAX_INDEX - 1])
            );
        }else{
            ans = (n - oddCount[MAX_INDEX - 1]) + (n - evenCount[MAX_INDEX - 1]);
        }
        System.out.println(ans);

    }


    static class CustomReader extends BufferedReader {
        public CustomReader() throws IOException {
            super(new InputStreamReader(System.in));
        }

        public int readLineAsInt() throws IOException {
            return Integer.parseInt(readLine());
        }

        public int[] readLineAsIntArray() throws IOException {
            String[] strArray = this.readLine().split(" ");
            int[] intArray = new int[strArray.length];
            for (int i = 0, n = strArray.length; i < n; i++) {
                intArray[i] = Integer.parseInt(strArray[i]);
            }
            return intArray;
        }

        public int[][] readAsIntMatrix(int rows, int columns) throws IOException {
            int[][] matrix = new int[rows][columns];
            for (int i = 0; i < rows; i++) {
                String[] r = this.readLine().split(" ");
                for (int j = 0; j < columns; j++) {
                    matrix[i][j] = Integer.parseInt(r[j]);
                }
            }
            return matrix;
        }

        public char[][] readAsCharMatrix(int rows) throws IOException {
            char[][] matrix = new char[rows][];
            for (int i = 0; i < rows; i++) {
                matrix[i] = this.readLine().toCharArray();
            }
            return matrix;
        }

    }

}

Measured memory_bytes: 38044
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;
typedef pair<ll,vector<int> > PP;

vector<P> v;
ll n,m;
vector<PP> ans;

void dfs(vector<int> a,int k,int c) {
  if(c<0) return;
  if(k>=v.size()) {
    ll cnt=0;
    rep(i,a.size()) cnt+=a[i];
    rep(i,v.size()) {
      if(c%v[i].S) continue;
      vector<int> b=a;
      b[i]+=c/v[i].S;
      ans.pb(PP(cnt+c/v[i].S,b));
    }
    return;
  }
  rep(i,11) {
    vector<int> b=a;
    b.pb(i);
    dfs(b,k+1,c-v[k].S*i);
  }
}

void Main() {
  cin >> n >> m;
  P a[m];
  rep(i,m) {
    R a[i].S;
    if(a[i].S==1) a[i].F=2;
    if(a[i].S==2) a[i].F=5;
    if(a[i].S==3) a[i].F=5;
    if(a[i].S==4) a[i].F=4;
    if(a[i].S==5) a[i].F=5;
    if(a[i].S==6) a[i].F=6;
    if(a[i].S==7) a[i].F=3;
    if(a[i].S==8) a[i].F=7;
    if(a[i].S==9) a[i].F=6;
  }
  map<ll,ll> ma;
  rep(i,m) ma[a[i].F]=max(ma[a[i].F],a[i].S);
  tr(it,ma) v.pb(P(it->S,it->F));
  sort(all(v),greater<P>());
  dfs(vector<int>(),0,n);
  sort(all(ans),greater<PP>());
  string s="";
  rep(i,ans[0].S.size()) {
    rep(j,ans[0].S[i]) s+=(char)(v[i].F+'0');
  }
  pr(s);
}

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


Measured memory_bytes: 197596
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(true) {
			int n=sc.nextInt();
			if(n==0) {
				System.exit(0);
			}
			else {
				int[] a=new int[n];
				for(int i=0; i<n; i++) {
					a[i]=sc.nextInt();
				}
				Arrays.sort(a);
				int sum=0;
				for(int i=1; i<n-1; i++) {
					sum+=a[i];
				}
				System.out.println(sum/(n-2));
			}
		}
	}
}


Measured memory_bytes: 29240
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

n,a,b,c = inp
abc = [a,b,c]
ans = []
st = "ABC"
h = {"AB" => [0,1],"BC"=>[1,2],"AC"=>[2,0]}
ss=[]
n.times{ss<<gets.chomp}
n.times do |i|
  s= ss[i]
  cd = h[s]
  if(abc[cd[0]]==abc[cd[1]] and abc[cd[0]] == 1 and i != n-1)
    unless(h[ss[i+1]].include?(cd[0]))
      abc[cd[0]] -= 1
      abc[cd[1]] += 1
      ans << st[cd[1]]
    else
      abc[cd[0]] += 1
      abc[cd[1]] -= 1
      ans << st[cd[0]]
    end
  elsif(abc[cd[0]]>=abc[cd[1]])
    abc[cd[0]] -= 1
    abc[cd[1]] += 1
    ans << st[cd[1]]
  else
    abc[cd[0]] += 1
    abc[cd[1]] -= 1
    ans << st[cd[0]]
  end
  unless abc.all?{|u|u>=0}
    puts "No"
    exit
  end
end
puts "Yes"
puts ans

Measured memory_bytes: 27128
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    string S;
    cin >> S;
    string T = S;
    reverse(T.begin(), T.end());
    if (S == T) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
int n,a[300010];
char s[300010];
int main()
{
	scanf("%d",&n);
	scanf("%s",&s);
	for (int i=1;i<=n;i++)
	{
		if (s[i-1]=='W')
		{
			a[i]=a[i-1]+1;
		}
		else
		{
			a[i]=a[i-1];
		}
	}
	int ans=n;
	for (int i=1;i<=n;i++)
	{
		int now=a[i-1]+((n-i)-(a[n]-a[i]));
		ans=min(ans,now);
	}
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main(void)
{
    int n,i;
    long a,t[200000],m=LONG_MAX;
    scanf("%ld",&n);
    for(i=0;i<n;i++){
        scanf("%ld",&a);
        if(i<1)t[i]=a;
        else t[i]=t[i-1]+a;
    }
    for(i=0;i<n-1;i++)if(m>labs(2*t[i]-t[n-1]))m=labs(2*t[i]-t[n-1]);
    printf("%ld",m);
    return 0;
}

Measured memory_bytes: 1664
# AOJ ITP2_6_B: Includes
# Python3 2018.6.24 bal4u

from bisect import bisect_left
n = int(input())
a = list(map(int, input().split()))
a.append(1000000001)  # > 1,000,000,000
m = int(input())
b = list(map(int, input().split()))
if len(b) > len(a): print(0)
else:
	p, f = 0, 1
	for k in b:
		p = bisect_left(a, k, p)
		if a[p] != k:
			f = 0
			break
	print(f)


Measured memory_bytes: 36680
#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 irep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main() {
    ll n,m;
    cin>>n>>m;
    
    ll ans=0;
    ans+=min(n,m/2);
    if((m-2*n)/4>=0) ans+=(m-2*n)/4;
    cout<<ans<<endl;
}


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

L = 20
M = [1<<i for i in range(L)]
T = [[0]*m for m in M]

o = ord('a')

for i, c in enumerate(S):
    T[-1][i] = 1<<(ord(c)-o)

for l in range(L-2, -1, -1):
    for i in range(M[l]):
        T[l][i] = T[l+1][i*2] | T[l+1][i*2+1]
    
def q(layer, n, l, r):
    length_block = (1<<(L-1))//M[layer]
    ml = length_block*n
    mr = ml + length_block

    if l==ml and r==mr:
        return T[layer][n]
    
    center = ml + length_block//2

    ret = 0
    if l<center: ret |= q(layer+1, n*2  , l, min(r,center))
    if r>center: ret |= q(layer+1, n*2+1, max(l,center), r)

    return ret

Q = int(input())
for _ in range(Q):
    t, a1, a2 = input().split()
    if t=='1':
        i = int(a1)-1
        c = a2
        T[-1][i] = 1<<(ord(c)-o)
        for l in range(L-2, -1, -1):
            i = i//2
            T[l][i] = T[l+1][i*2] | T[l+1][i*2+1]
        
    else:
        l = int(a1)-1
        r = int(a2)
        x = q(0, 0, l, r)
        ans = 0
        for i in range(26):
            if (x>>i)&1: ans+=1
        print(ans)
        


Measured memory_bytes: 83528
#include<iostream>
#include <string>
#include<vector>
typedef long long ll;

using namespace std;
int main()
{
	int n, y;
	cin >> n >> y;
	int a1 = -1;
	int a2 = -1;
	int a3 = -1;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n-i; j++) {
			if (10000 * i + 5000 * j + 1000 * (n - i - j) == y) {
				a1 = i;
				a2 = j;
				a3 = n - i - j;
			}
		}
	}
	cout << a1 << " " << a2 << " " << a3 << endl;
	return 0;
}

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

int main()
{
  int a, b, c, x;
  cin >> a >> b >> c >> x;

  int counter = 0;

  for(int i = 0; i <= a; ++i){
    for(int j = 0; j <= b; ++j){
      int k = x - (500 * i + 100 * j);
      if(k >=0 && k <= 50 * c) ++counter;
      else continue;
    }
  }

  cout << counter << endl;

  return 0;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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;
}

vector<int> Zalgorithm(const string &s){
    int n=s.size();
    vector<int> z(n);
    z[0]=n;
    int i=1,j=0;
    while(i<n){
        while(i+j<n&&s[j]==s[i+j]) ++j;
        z[i]=j;
        if (j==0){++i; continue;}
        int k=1;
        while(i+k<n&&k+z[k]<j) z[i+k]=z[k],++k;
        i+=k,j-=k;
    }
    return z;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; string S; cin >> N >> S;
    int ans=0;
    rep(i,N){
        string T=S.substr(i);
        vector<int> lcp=Zalgorithm(T);
        rep(j,T.size()) chmax(ans,min((int)j,lcp[j]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
eval"N,M,*A="+`dd`.split*?,
D=[s=0]*L=3*M
A.each_cons(2){|a,b|b<a&&b+=M;s+=k=b-a;D[a+2]+=1;D[b+1]-=k;D[b+2]+=k-1}
(2*L).times{|i|D[i%L]+=D[~-i%L]};p s-A.map{|a|D[a]+D[a+M]}.max

Measured memory_bytes: 22612
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const int MAXN = 120000;

int n;

ll a[MAXN];
ll b[MAXN];

multiset<ll> ss0, ss1;
ll cs;

void add(ll x) {
	if (ss0.size() < n)
		ss0.insert(x), cs += x;
	else if (*ss0.rbegin() > x) {
		ll y = *ss0.rbegin();
		ss0.erase(ss0.find(y));
		ss0.insert(x);
		cs -= y, cs += x;
		ss1.insert(y);
	}
	else {
		ss1.insert(x);
	}
}

void del(ll y) {
	if (ss1.find(y) != ss1.end()) {
		ss1.erase(ss1.find(y));
	}
	else {
		cs -= y;
		ss0.erase(ss0.find(y));
		if (!ss1.empty()) {
			y = *ss1.begin();
			ss1.erase(ss1.begin());
			cs += y;
			ss0.insert(y);
		}
	}
}

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i] >> b[i];
	ll ans = 0;
	for (int i = 0; i < n; ++i)
		ans += a[i];
	ll sum = 0;
	for (int i = 0; i < n; ++i)
		sum += b[i];
	ans = min(ans, sum);
	for (int i = 1; i < n; ++i)
		add(a[i]), add(b[i]);
	ans = min(ans, cs);
	for (int i = 1; i < n; ++i) {
		add(a[i - 1]), add(b[i - 1]);
		del(a[i]), del(b[i]);
		ans = min(ans, cs);
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 11264
#include <iostream>

using namespace std;

int main() {
    int a,b;
    cin>>a>>b;
    if (a > b){
        cout<<"a > b"<<endl;
    }else if(a < b){
        cout<<"a < b"<<endl;
    }else{
    cout<<"a == b"<<endl;
    }
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
////////////////////////////////////////////////
int main()
{
    int x;
    cin >> x;
    int pre = 0;
    pre += (x / 500) * 1000;
    x = x % 500;
    pre += (x / 5) * 5;
    cout << pre << endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N;
    cin >> N;
    if(N==0)
    {
        cout<<0;
        return 0;
    }
    string S;
    while (N != 0)
    {

        int a = abs(N % 2);
        S = S + (to_string(a));
        N -= a;
        N /= (-2);
    }
    reverse(all(S));
    cout << S;
    return 0;
}


Measured memory_bytes: 256
s = gets.to_i

n = 0
step = 1
digit = 1
stack = []
start = 0

loop {
	over = false
	(start..9).each{|k|
		fizz = (n + step) / 3 - n / 3
		buzz = (n + step) / 5 - n / 5
		fizz_buzz = (n + step) / 15 - n /15
		
		addition = digit * (step - fizz - buzz + fizz_buzz) + 4 * (fizz + buzz) 
		
		if s <= addition
			stack << k
			over = true
			start = 0
			break
		else
			s -= addition
			n += step
			start = 1
		end
	}
	
	if over
		step /= 10
		break if step == 0
	else
		step *= 10
		digit += 1
	end
}

x = stack.join.to_i + 1
str = ""
while 0
	if x % 15 == 0
		str += "FizzBuzz"
	elsif x % 3 == 0
		str += "Fizz"
	elsif x % 5 == 0
		str += "Buzz"
	else
		str += x.to_s
	end
	break if str.size - s >=  20
	x += 1
end

puts str[s-1..s+18]

Measured memory_bytes: 6116
#include <cstdio>
         
        char S[101010];
         
        int main()
        {
        	scanf("%s", S);
         
        	bool app[26];
        	for (int i = 0; i < 26; ++i) {
        		app[i] = false;
        	}
        	for (int i = 0; S[i] != '\0'; ++i) {
        		app[S[i] - 'a'] = true;
        	}
        	for (int i = 0; i < 26; ++i) {
        		if (!app[i]) {
        			printf("%c\n", (char)(i + 'a'));
        			return 0;
        		}
        	}
        	puts("None");
        	return 0;
        }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI (2*acos(0))
using namespace std;
int a1[100000+5],i,full ,sub,c=0,take;
 ;
int b_search(int key)
{
    int l,h,mid;
     l=0,h=full-1;
     while(l<=h)
     {
         mid=l+(h-l)/2;
     if(key==a1[mid]) return 1;
     else if(key>a1[mid]) l=mid+1;
     else h=mid-1;
     }
     return 0;
}
int main()
{
         scanf("%d",&full);
     for(i=0;i<full;i++)
     {
         scanf("%d",&a1[i]);
     }
     scanf("%d",&sub);
     for(i=0;i<sub;i++)
     {
         scanf("%d",&take);
         if(b_search(take)) c++;
     }
    printf("%d\n",c);
    return 0;
}



Measured memory_bytes: 3612