akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define all(cont) cont.begin(), cont.end()
#define unique(a)  sort(all(a)) , (a).erase(unique((a).begin(), (a).end()),(a).end())
#define rall(cont) cont.rbegin(), cont.rend()
#define sz(x) (int)(x).size()
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
const int N = 2e5 + 5;
#define PI acos(-1.0)
typedef long long ll;
#define int long long
typedef long double ld;
typedef vector<int> VI;
#define pqll_max priority_queue<ll> // max heap. push(),pop(),top(),size(),empty()
#define pqll_min priority_queue<ll,vector<ll>,greater<ll> >
#define lb(v,val)   lower_bound(v.begin(),v.end(),val) //first equal to or lower than [------------
#define ub(v,val)   upper_bound(v.begin(),v.end(),val) //first greater than ------------)
#define bs(v,x) binary_search(v.begin(),v.end(),x)
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x; }
inline ll sub(ll a, ll b) { if (a < b)swap(a, b); return (((a%mod) - (b%mod) + mod) % mod); }
inline ll mul(ll x, ll y) { return (x%mod * 1ll * y%mod) % mod; }
inline ll pwr(ll a, ll b) { ll x = 1 % mod; while (b) { if (b & 1) x = mul(x, a); a = mul(a, a); b >>= 1; }return x % mod; }
inline ll inv(ll a) { return pwr(a, mod - 2) % mod; }
ll gcd(ll a, ll b) { if (!a)return b % mod; return gcd(b%a, a) % mod; }
#define debug(x) cout << #x << " = " << x << endl;
#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...);
}
#define in(container) for (auto &it : container) cin>>it;
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
signed main()
{
	fastio;
	string s;
	cin >> s;
	int n = s.length();
	string s1 = s.substr(0, (n - 1) / 2);
	string s2 = s.substr((n + 3) / 2 - 1);
	string s4 = s;
	reverse(all(s4));
	string s5 = s1;
	reverse(all(s5));
	string s6 = s2;
	reverse(all(s2));
	if (s == s4 && s1 == s5 && s2 == s6) {
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}


}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main() {

	bool r = true;

	int a,b;
	cin >> a >> b;

	string s;
	cin >> s;

	int size = s.size();
	if (a + b + 1 != size) {
		r = false;
	}

	for (int i = 0; i < size; ++i) {
		if (a == i) {
			if ('-' != s[i]) {
				r = false;
			}
		}
		else {
			if ('-' == s[i]) {
				r = false;
			}
		}
	}

	cout << (r ? "Yes" : "No") << endl;

	return 0;
}


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

int main()
{
  ll n,m;
  cin >> n >> m;
  
  vector<pair<ll ,ll>> v(n);
  rep(i,n) cin >> v.at(i).first >> v.at(i).second;
  
  sort(v.begin(),v.end());
  
  ll ans = 0;
  rep(i,n)
  {
    if(m - v.at(i).second > 0)
    {
      ans += v.at(i).first * v.at(i).second;
      m -= v.at(i).second;
    }else{
      ans += v.at(i).first * m;
      break;
    }
  }
  
  cout << ans << endl;
  
 
}

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

const int mod = 1000000007;
//const int mod = 998244353;
const int INF = 1001001001;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main()
{
    int a, b, k;
    cin >> a >> b >> k;
    set<int> st;
    rep(i, a, min(a+k, b+1)) st.insert(i);
    rep(i, max(a, b-k+1), b+1) st.insert(i);
    for(auto i : st) cout << i << endl;
    return 0;
}


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

int main(){
  int n;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++){
    cin>>arr[i];
  }
  int odd=0;
  for(int i=0;i<n;i++){
    if(arr[i]%2==1){
      odd++;
    }
  }
  if(odd%2==0){
    cout<<"YES";
  }
  if(odd%2==1){
    cout<<"NO";
  }
}

Measured memory_bytes: 640
s = input()
K = int(input())
lst = []
# substringの長さ候補
ssize = min(5,len(s))
# substringの長さ候補だけ繰り返し部分文字列を取得
for i in range(1 , ssize + 1):
    # j番目の文字から部分文字列を取得
    for j in range(len(s)-i+1):
        #print("j:",j)
        lst.append(s[j:i+j])

#集合にして重複を削除
sset = set(lst)
#リストに戻す
llst = list(sset)
#ソートする
llst.sort()
#print(llst)
print(llst[K-1])

Measured memory_bytes: 5068
from sys import stdin, setrecursionlimit
from collections import defaultdict
from math import gcd

setrecursionlimit(10 ** 9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


MOD = 1000000007
N, *AB = map(int, stdin.buffer.read().split())
d = defaultdict(int)
zeros = 0
for a, b in zip(AB[::2], AB[1::2]):
    if a == 0 and b == 0:
        zeros += 1
    else:
        g = gcd(a, b)
        a //= g
        b //= g
        if a < 0:
            a *= -1
            b *= -1
        if a == 0 and b == -1:
            b = 1
        d[(a, b)] += 1

ans = 1
free = 0
for (a, b), n in d.items():
    if b > 0:
        if (b, -a) in d:
            m = d[(b, -a)]
            ans = ans * (pow(2, n, MOD) + pow(2, m, MOD) - 1) % MOD
        else:
            free += n
    else:
        if (-b, a) not in d:
            free += n

ans = (ans * pow(2, free, MOD) + zeros - 1) % MOD
print(ans)


Measured memory_bytes: 162804
#include <bits/stdc++.h>
using namespace std;
int main () {
    int n,k;cin >> n;
    vector<int> t(n,0);
    for (int i = 0; i < n-1; i++)
    {
        cin >> k;
        t[k-1]+=1;
    }
    for (int j = 0; j < n; j++)
    {
        cout << t[j] <<endl;
    }
    
}

Measured memory_bytes: 4048
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
  ll N;
  cin >> N;
  ll h, prev_h = INT32_MAX, cnt = -1, max_cnt = 0;
  for (int i = 0; i < N; i++) {
    cin >> h;
    if (h <= prev_h) {
      cnt++;
    } else {
      max_cnt = max(cnt, max_cnt);
      cnt = 0;
    }
    prev_h = h;
  }
  cout << max(cnt, max_cnt) << endl;
  return 0;
}

Measured memory_bytes: 256
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	cin >> s;
	
	cout << (s=="AAA" || s=="BBB" ? "No\n" : "Yes\n");
	return 0;
}



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

int A,B,C,K;
cin >> A >> B >> C >> K;
  
  while(A>=B && K!=0){

    B=2*B;
    K--;
    
  }
  
    while(B>=C && K!=0){

    C=2*C;
    K--;
    
  }
  
  if(A<B && B<C){
    cout <<"Yes";
  }else{
    cout <<"No";
  }
  
}


Measured memory_bytes: 3628
from math import log2
n = int(input())
r, ans  = int(log2(n)), []
for i in range(1,r+1):
    ans.append([i,i+1,2**(i-1)])
for i in range(r, 0, -1):
    if n - 2**(i-1) >= 2**r:
        ans.append([i, r+1, n-2**(i-1)])
        n -= 2**(i-1)
print(r+1, len(ans)+r)
for i in range(1,r+1):
    print(i, i+1, 0)
for i,j,k in ans:
    print(i, j, k)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
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<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

struct Dice {
    ll a[6];
    void swap4(ll i1,ll i2,ll i3,ll i4){
        ll tmp=a[i1];
        a[i1]=a[i2];
        a[i2]=a[i3];
        a[i3]=a[i4];
        a[i4]=tmp;
    }
    void rotateE(){
        swap4(2,0,3,5);
    }
    void rotateN(){
        swap4(4,0,1,5);
    }
    void rotateS(){
        swap4(1,0,4,5);
    }
    void rotateW(){
        swap4(3,0,2,5);
    }
    bool sameA(Dice d){
        rep(i,6){
            if(a[i]!=d.a[i])return false;
        }
        return true;
    }
    bool same(Dice d){
        rep(i,2){
            rep(j,4){
                rep(k,4){
                    if(sameA(d))return true;
                    rotateE();
                }
                rotateS();
            }
            rotateE();
        }
        return false;
    }
};

void solve(){
    ll n;cin>>n;
    vector<Dice> d(n);
    rep(i,n){
        rep(j,6)cin>>d[i].a[j];
    }
    rep(i,n){
        fore(j,i+1,n-1){
            if(d[i].same(d[j])){
                cout<<"No"<<endl;
                return;
            }
        }
    }
    cout<<"Yes"<<endl;
}

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



Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    ll n, a, b; cin >> n >> a >> b;
    ll ans;
    if (!((b-a)&1)) ans = (b-a)/2;
    else ans = min(a-1,n-b)+1+(b-a-1)/2;
    cout << ans << endl;
}

Measured memory_bytes: 3576
h,w,n=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
from collections import defaultdict
dct=defaultdict(int)
ans={i:0 for i in range(10)}
ans[0]=(h-2)*(w-2)
for a,b in ab:
  a-=1
  b-=1
  u=max(0,a-2)
  d=min(h-3,a)
  l=max(0,b-2)
  r=min(w-3,b)
  for i in range(u,d+1):
    for j in range(l,r+1):
      ans[dct[(i,j)]]-=1
      dct[(i,j)]+=1
      ans[dct[(i,j)]]+=1
for i in range(10):
  print(ans[i])


Measured memory_bytes: 176440
import java.util.*;
public class Main {
 
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
	    String n = scan.next();
		if(n.matches("[A-Z]")) {
			System.out.println("A");
		} else {
			System.out.println("a");
		}
	}
 
}

Measured memory_bytes: 26976
/*input
5 5
1 2
1 3
3 4
3 5
16 8 17 3 18
2 1
2 3
1 3 7
2 1
2 3


*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
 
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#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(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n;
  cin >> n;
  vector <int> pos(n + 1, 0);
  int v;
  for (int i = 1; i <= n; i++) {
    cin >> v;
    pos[i] = v;
  }
  vector <int> ans(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    ans[pos[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(void) {
    int64_t N, M;
    cin >> N >> M;
    vector<int64_t> A(N), psum(N+1);
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }

    sort(A.begin(), A.end());

    for(int i=0; i<N; i++) {
        psum[i+1] = psum[i] + A[i];
    }

    int64_t low = 0;
    int64_t high = 200'001;
    while(low + 1 < high) {
        int mid = (low + high) / 2;
        int64_t cnt = 0;
        for(int i=0; i<N; i++) {
            cnt += distance(lower_bound(A.begin(), A.end(), mid-A[i]), A.end());
        }
        if(cnt >= M) {
            low = mid;
        } else {
            high = mid;
        }
    }

    int64_t ans = 0, cnt = 0;
    for(int i=0; i<N; i++) {
        int64_t tmp_sum = psum.back() - psum[distance(A.begin(), lower_bound(A.begin(), A.end(), low-A[i]))];
        int64_t tmp_cnt = distance(lower_bound(A.begin(), A.end(), low-A[i]), A.end());
        ans += tmp_sum + A[i] * tmp_cnt;
        cnt += tmp_cnt;
    }

    ans -= low * (cnt - M);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1920
import itertools
N,C = map(int,input().split())
D = [[0 for _ in range(C)]]
for _ in range(C):
    row = list(map(int,input().split()))
    row.insert(0,0)
    D.append(row)
A = [[0 for _ in range(N)]]
for _ in range(N):
    row = list(map(int,input().split()))
    row.insert(0,0)
    A.append(row)
G = {0:{c:0 for c in range(1,C+1)},1:{c:0 for c in range(1,C+1)},2:{c:0 for c in range(1,C+1)}}
for i in range(1,N+1):
    for j in range(1,N+1):
        a = (i+j)%3
        G[a][A[i][j]] += 1
B = {0:{c:0 for c in range(1,C+1)},1:{c:0 for c in range(1,C+1)},2:{c:0 for c in range(1,C+1)}}
for c in range(1,C+1):
    for i in range(3):
        for d in range(1,C+1):
            B[i][c] += G[i][d]*D[d][c]
dmin = 10**10
for x in itertools.permutations(range(1,C+1),3):
        dmin = min(dmin,B[0][x[0]]+B[1][x[1]]+B[2][x[2]])
print(dmin)

Measured memory_bytes: 5620
package main

import (
        "bufio"
        "fmt"
        "math"
        "os"
        "sort"
        "strconv"
        "strings"
)

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
        sc.Scan()
        return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
        buf := make([]byte, 0, 1000000)
        for {
                l, p, e := rdr.ReadLine()
                if e != nil {
                        panic(e)
                }
                buf = append(buf, l...)
                if !p {
                        break
                }
        }
        return string(buf)
}

func strSprit(str string) []string {
        cols := strings.Split(str, " ")
        return cols
}

func parseInt(str string) int {
        n, _ := strconv.Atoi(str)
        return n
}

func intSprit(str string) []int {
        strs := strSprit(str)
        cols := make([]int, len(strs))
        for i, v := range strs {
                cols[i] = parseInt(v)
        }
        return cols
}

type SortSlice []int

func (s SortSlice) Len() int {
        return len(s)
}

func (s SortSlice) Swap(i, j int) {
        s[i], s[j] = s[j], s[i]
}

func (s SortSlice) Less(i, j int) bool {
        return s[i] < s[j]
}

func reverseString(str string) string {
        buf := []rune(str)
        for i, j := 0, len(buf)-1; i < j; i, j = i+1, j-1 {
                buf[i], buf[j] = buf[j], buf[i]
        }
        return string(buf)
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////

func main() {
        line := nextLine()
        nums := intSprit(line)
        sort.Ints(nums)

        s := 0
        for i := 1; i < len(nums); i++ {
                s += int(math.Abs(float64(nums[i] - nums[i-1])))
        }
        fmt.Println(s)

}


Measured memory_bytes: 640
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int N, L; scan(N, L);

    // N 個のリングのおいしさは、L, L + 1, L + 2, ..., L + N - 1
    int t = iota(L, L + N).reduce!((a, b) => abs(a) <= abs(b) ? a : b);
    int ans = iota(L, L + N).sum - t;
    writeln(ans);
}


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

const int N = 100005;

int n, a, b, c;
char s[N];

int main(){
	scanf("%s", s);
	n = strlen(s);
  	a = count(s, s + n, 'a');
  	b = count(s, s + n, 'b');
  	c = n - a - b;
  	int t = (abs(a - b) > 1) || (abs(b - c) > 1) || (abs(c - a) > 1);
  	puts(t ? "NO" : "YES");
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<ctime>
#include<vector>

using namespace std;

#define eps 0.0000000001

struct vec{
  double x, y;
  void nextvec(){ scanf("%lf %lf", &x, &y); return; }
  vec operator+(const vec& a) const { return (vec){x + a.x, y + a.y}; }
  vec operator-(const vec& a) const { return (vec){x - a.x, y - a.y}; }
  vec operator*(const double& k) const { return (vec){k * x, k * y}; }
  vec sca(double t){ return (vec){t * x, t * y}; }
  double dot(vec a){ return x * a.x + y * a.y; }
  double cross(vec a){ return x * a.y - y * a.x; }
  double norm(){ return sqrt(x * x + y * y); }
  double norm2(){ return x * x + y * y; }
};

bool xsort(vec qwe, vec rty){ return qwe.x < rty.x; }
bool ysort(vec qwe, vec rty){ return qwe.y < rty.y; }

vec pt[100000];
vec ytmp[100000];
vec ymerge[100000];
double ma = 100000000000.0;

double closestpair(int l, int r){
  if(r - l <= 1)return ma;
  int m = l + (r - l) / 2;
  double xm = pt[m].x;
  double res = min(closestpair(l, m), closestpair(m, r));

  int hdmerge = 0, hdtmp = 0, lhd = l, rhd = m;
  vec now;
  for(;;){
    if(lhd == m && rhd == r)break;
    else if(rhd == r)now = pt[lhd++];
    else if(lhd == m)now = pt[rhd++];
    else if(ysort(pt[lhd], pt[rhd]))now = pt[lhd++];
    else now = pt[rhd++];

    ymerge[hdmerge++] = now;
    if(abs(now.x - xm) <= res + eps){
      ytmp[hdtmp++] = now;
      for(int i = hdtmp - 2;i >= 0;--i){
        if(abs(ytmp[i].y - now.y) >= res - eps)break;
        res = min(res, (now - ytmp[i]).norm());
      }
    }
  }
  for(int i = l;i < r;++i)pt[i] = ymerge[i - l];

  return res;
}

signed main(void){
  int n;
  scanf("%d", &n);
  for(int i = 0;i < n;++i)pt[i].nextvec();
  sort(pt, pt + n, xsort);
  printf("%.13lf\n", closestpair(0, n));

  return 0;
}

Measured memory_bytes: 7200
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
int b[110000];
int main(){
	int a;
	scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",b+i);
	int ret=0;
	int type=0;
	int sz=0;
	for(int i=0;i<a;i++){
		if(sz==0){
			ret++;
 
		}else if(sz>=1){
			if(type==-1&&b[i-1]<b[i]){
				type=sz=0;ret++;
			}
			else if(type==1&&b[i-1]>b[i]){
				type=sz=0;ret++;
			}
			else if(b[i-1]<b[i])type=1;
			else if(b[i-1]>b[i])type=-1;
		}
		sz++;
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
using namespace std;
int h,w,n=0;
int a[501][501];
int ch[501][501];

int main(){
	cin>>h>>w;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin>>a[i][j];
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(a[i][j]%2!=0){
				if(j!=w){
					a[i][j+1]++;
					ch[i][j]=1;
					n++;
				}else if(i!=h){
					a[i+1][j]++;
					ch[i][j]=1;
					n++;
				}
			}
		}
	}
	cout<<n<<endl;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(ch[i][j]==1){
				if(j!=w){
					cout<<i<<" "<<j<<" "<<i<<" "<<j+1<<endl;				
				}else if(i!=h){
					cout<<i<<" "<<j<<" "<<i+1<<" "<<j<<endl;	
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
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; }
const ll INF = 1LL << 60;
int main(){
    int n;
    cin >> n;
    int fi = n % 10;
    if (fi == 3){
        cout << "bon" << endl;
        return 0;
    }
    int hon[5] = {2,4,5,7,9};
    rep(i,5){
        if (fi == hon[i]){
            cout << "hon" << endl;
            return 0;
        }
    }
    cout << "pon" << endl;
    return 0;
}

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

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int x, a, b; cin >> x >> a >> b;

  if (b <= a) cout << "delicious\n";
  else if (b - x <= a) cout << "safe\n";
  else cout << "dangerous\n";
  
  return (0);
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, L;
  cin >> N >> L;
  int f = N * L + N * (N - 1) / 2;
  // ll c = 0;
  // for (int i = 1; i <= N; i++) {
  //   c += L + i - 1;
  // }
  //cout << c << " " << f << " \n";
  int k = 10000000;
  
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    //cout << f - (L + i - 1);
    if (k >= abs((L + i - 1))) {
      k = abs((L + i - 1));
      ans = f - (L + i - 1);
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<map>
#include<queue>
#include<cmath>
#include<ctime>
#include<stack>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
inline int read(){
	int ans=0,fh=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') fh=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
		ans=ans*10+ch-'0',ch=getchar();
	return ans*fh;
}
const int maxn=1e5+100;
int n,a,b,c,f[maxn][3];
int main(){
//	freopen(".in","r",stdin);
	n=read();
	for(int i=0;i<3;i++) f[1][i]=read();
	for(int i=2;i<=n;i++){
		for(int j=0;j<3;j++){
			int x=read();
			for(int k=0;k<3;k++)
				if(j!=k)
				f[i][j]=max(f[i][j],f[i-1][k]+x);
		}
	}
	printf("%d\n",max(f[n][0],max(f[n][1],f[n][2])));
	return 0;
}








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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll P[55];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, p;
    cin >> N >> p;
    ll odd = 0, even = 0;
    REP(i, N) {
        ll a;
        cin >> a;
        if (a % 2 == 0)
            even++;
        else
            odd++;
    }

    P[0] = 1;
    REP(i, N + 1) {
        P[i + 1] = P[i] * 2LL;
    }

    if (p == 0)
        cout << P[even] * (P[std::max(odd - 1, 0LL)]) << endl;
    else
        cout << P[even] * (P[odd] - P[std::max(odd - 1, 0LL)]) << endl;
    return 0;
}

Measured memory_bytes: 256
<?php

function gcd($a, $b) {
    if ($b === 0) {
        return $a;
    }

    return gcd($b, $a % $b);
}

fscanf(STDIN, "%d", $n);
$A = array_map('intval', explode(' ', trim(fgets(STDIN))));

$L = [];
$L[0] = $A[0];
for ($i = 1; $i < $n; ++$i) {
    $L[$i] = gcd($L[$i - 1], $A[$i]);
}

$R = [];
$R[$n - 1] = $A[$n - 1];
for ($i = $n - 2; $i >= 0; --$i) {
    $R[$i] = gcd($A[$i], $R[$i + 1]);
}

ksort($L);
ksort($R);

/* echo "L: " . implode(', ', $L), PHP_EOL; */
/* echo "R: " . implode(', ', $R), PHP_EOL; */

$max = 0;
for ($i = 0; $i < $n; ++$i) {
    switch ($i) {
    case 0:
        // 先頭
        $max = max($max, $R[1]);
        break;

    case $n - 1:
        // 末尾
        $max = max($max, $L[$n - 2]);
        break;

    default:
        $gcd = gcd($L[$i - 1], $R[$i + 1]);
        $max = max($max, $gcd);
    }
}

echo $max;


Measured memory_bytes: 25072
L = input()
p = 10**9+7
dp=[[0]*2 for i in range(len(L)+1)]
dp[0][0]=1
for digit, i in enumerate(L):
  # a+b = 0
  if L[digit] == "0":
    dp[digit + 1][0] = dp[digit][0]
    dp[digit + 1][1] = dp[digit][1]
  else:
    dp[digit + 1][1] = (dp[digit][0] + dp[digit][1]) % p
  # a+b = 1
  if L[digit] == "0":
    dp[digit + 1][1] += dp[digit][1]*2 % p
    dp[digit + 1][1] %= p
  else:
    dp[digit + 1][0] += dp[digit][0]*2 % p
    dp[digit + 1][0] %= p
    dp[digit + 1][1] += dp[digit][1]*2 % p
    dp[digit + 1][1] %= p
ans = (dp[len(L)][0]+dp[len(L)][1]) % p
print(ans)

Measured memory_bytes: 23940
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main (){
    int n;
    cin >> n;
    vector<string>s(n);
    vi t(n);
    int sum=0;
    rep(i,n) {
        cin >> s[i] >> t[i];
        sum+=t[i];
    }
    string x;
    cin >> x;
    rep(i,n){
        sum-=t[i];
        if(s[i]==x) break;
    }
    cout << sum << endl;


    

    return 0;
}


Measured memory_bytes: 256
n,l = map(int,input().split())
left = l
right = n+l-1
eat = 0
aji = 0

if right <=0:
	eat = right
elif left >=0:
	eat = left
else:
	eat = 0

for i in range(left,right+1):
	aji += i

aji -= eat
print(aji)

Measured memory_bytes: 3060
# coding: utf-8
# Your code here!

N = int(input())

if N%2 != 0 : 
    global_cnt = 0
else : 
    n = 1
    while 2*(5**n) <= N : 
        n += 1
        
    global_cnt = 0
    
    for i in range(1, n) : 
        local_cnt = N // (2*(5**i))
        global_cnt += local_cnt
        
print(global_cnt)

Measured memory_bytes: 3060
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner    sc = new Scanner(System.in);
        BigDecimal a  = new BigDecimal(sc.next());
        BigDecimal b  = new BigDecimal(sc.next());

        System.out.println(a.multiply(b).setScale(0, RoundingMode.DOWN).toPlainString());
    }
}


Measured memory_bytes: 36048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tii;
#define rep(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

int main(){
  ll N; cin >> N;
  if(N==1){
    cout << 0 << endl;
    return 0;
  }
  ll n = N;
  ll ans = 0;
  for(ll i=2;i*i<=N;i++){
    ll x = i;
    while(n%x==0){
      ans++;
      n /= x;
      x *= i; 
    }
    while(n%i==0){
      n /= i;
    }
  }
  if(n != 1) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 3640
class Integer
    def to_express
        suffix = ["", :Man, :Oku, :Cho, :Kei, :Gai, :Jo, :Jou, :Ko, :Kan, :Sei, :Sai, :Gok, :Ggs, :Asg, :Nyt, :Fks, :Mts]
        res = []
        for i in 0 .. 17
            value = (0 ... 4).flat_map{|j| self.to_s[i * -4 - 4 + j]}.drop_while{|s| s == "0"}.join
            res << ((value == "") ? value : (value + suffix[i].to_s))
        end
        res.reverse.join
    end 
end
while(true)
    m, n = gets.split(' ').map(&:to_i)
    break if m == 0
    target = m ** n
    puts target.to_express
end


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

vector< vector<int> > g;
lint memo[2][100010];

lint solve(int v, int prev, int color){

    if(memo[color][v] >= 0LL){
        return memo[color][v];
    }

    vector<lint> vec;
    for(auto x : g[v]){
        if(x != prev){
            lint cnt = solve(x, v, 1);
            cnt %= MOD;
            if(color == 1){
                cnt += solve(x, v, 0);
                cnt %= MOD;
            }
            vec.push_back(cnt);
        }
    }

    lint res = 1;
    rep(i, vec.size()){
        res *= vec[i];
        res %= MOD;
    }

    return memo[color][v] = res;

}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    g.resize(n);
    rep(i, n - 1){
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    fill(memo[0], memo[2], -1);

    lint ans = solve(0, -1, 0) + solve(0, -1, 1);
    ans %= MOD;
    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 19840
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
// import java.util.Scanner;


class Main {
    // static Scanner sc;
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public static void main(final String[] args) throws NumberFormatException, IOException {

        // sc = new Scanner(System.in);
        String[] input = br.readLine().split(" ");
        int age = Integer.parseInt(input[0]);
        int cost = Integer.parseInt(input[1]);

        if(age < 13){
            if(age >=6){
                cost = cost/2;
            }else{
                cost = 0;
            }
        }

        System.out.println(cost);
    
    }

    // public static int parseNumber() throws NumberFormatException, IOException {
    //     return Integer.parseInt(sc.nextLine());
    // }
}

Measured memory_bytes: 32596
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]


macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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


#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    ($arg:expr) => (println!("{:?}",$arg));
}


#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}


use std::cmp;
use std::collections::HashMap;


#[allow(dead_code)]
static INF_I64 :i64 = 9223372036854775807;
#[allow(dead_code)]
static INF_I32 : i32 = 2147483647;
#[allow(dead_code)]
static INF_USIZE : usize = 18446744073709551615;





//約数の列挙
fn divisors(n:u64)->Vec<u64>{
    let mut res = vec![];
    let mut i = 0;
    while(true){
        i+=1;
        if(i*i > n) {break};
        if(n % i != 0) {continue};
        res.push(i);
        if(n/i == i) {continue};
        res.push(n/i);
        

    }
    //res.sort();
    //res.dedup();
    return res;
}

//素数判定
fn is_prime(n:u64) -> bool {
    if(n == 1) {return false};
    let mut i = 1;
    while(true){
        i+=1;
        if(i*i > n)  {break;};
        if(n%i == 0) {return false};
    }
    return true;
}


fn main() {

    input! { 
       a: u64,
       b: u64,
    }

    let mut a = a;
    let mut b = b;
    let mut ans = 0;

    let a1 = divisors(a);
    //let b1 = divisors(b);


    for item in &a1{
        if(b % *item  == 0 && (is_prime(*item) || *item == 1)){
            ans+=1;
        }
    }






 
    println!("{}",ans);


}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007


int main(){
	ll n,m,a,b,p,q;
	cin >> n >> m >> a >> b >> p >> q;
	if(a==1&&b==1){
		ll ans = m;
		ll x = p+q;
		ll y = m/x;
		if(y>=n){
			ans = min(ans,m-x*n);
			cout << ans << endl;
		}else{
			ans = min(ans,m-(x*y));
			ans = min(ans,x-ans);
			cout << ans << endl;
		}
		return 0;
	}
	vector<ll> r1,r2;
	r1.push_back(1);
	r2.push_back(1);
	if(p+q >= m){
		cout << min(m,p+q-m) << endl;
		return 0;
	}
	for(int i=1;i<n;i++){
		r1.PB(r1[i-1]*a);
		r2.PB(r2[i-1]*b);
		if(p*r1[i]+q*r2[i]>=m){
			n=i+1;
		}
	}
	ll ans=m;
	if(p*r1[n-1]+q*r2[n-1]>=m){
		ans = min(ans,p*r1[n-1]+q*r2[n-1]-m);
		n--;
	}
	vector<ll> s1,s2,t1,t2;
	const ll mae = n/2;
	const ll usi = n - mae;
	for(int i=0;i<n/2;i++){
		s1.push_back(p*r1[i]+q*r2[i]);
	}
	for(int i=n/2;i<n;i++){
		s2.push_back(p*r1[i]+q*r2[i]);	
	}
	/*for(int i=0;i<mae;i++){
		cout << s1[i] << endl;
	}
	cout << endl;
	for(int i=0;i<usi;i++){
		cout << s2[i] << endl;
	}*/
	for(ll i=0;i<(1LL<<(mae));i++){
		ll s = 0;
		for(ll j=0;j<mae;j++){
			if(i&(1LL<<j)){
				s += s1[j];
			}
		}
		t1.push_back(s);
	}
	for(ll i=0;i<(1LL<<(usi));i++){
		ll s = 0;
		for(ll j=0;j<usi;j++){
			if(i&(1LL<<j)){
				s += s2[j];
			}
		}
		t2.push_back(s);
	}
	sort(t1.begin(),t1.end());
	sort(t2.begin(),t2.end());
	/*for(int i=0;i<t1.size();i++){
		cout << t1[i] << endl;
	}
	for(int i=0;i<t2.size();i++){
		cout << t2[i] << endl;
	}*/
	for(int i=0;i<t1.size();i++){
		int k = lower_bound(t2.begin(),t2.end(),m-t1[i])-t2.begin()-1;
		ans = min(ans,abs(m-t1[i]-t2[k]));
		if(k+1<t2.size()){
			ans = min(ans,abs(m-t1[i]-t2[k+1]));
		}	
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 23260
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
//--main function
int main(){
	int n,po=0,qo=0;
	cin>>n;
	vi p(n),p_i(n);
	vi q(n),q_i(n);
	REP(i,0,n-1){
		cin>>p[i];
		p_i[i]=p[i];
	}
	REP(i,0,n-1){
		cin>>q[i];
		q_i[i]=q[i];
	}
	sort(p.begin(),p.end());
	sort(q.begin(),q.end());
	int i=1;
	do{
		if(p==p_i)po=i;
		i++;
	}while(next_permutation(p.begin(),p.end()));
	i=1;
		do{
		if(q==q_i)qo=i;
		i++;
	}while(next_permutation(q.begin(),q.end()));
	
	if(qo>po)cout<<qo-po;
	else cout<<po-qo;
	
	return 0;

//   TimeTaken();
}


Measured memory_bytes: 256
import java.util.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Collections;
import java.awt.Point;


public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        List<Point> blue = new ArrayList();
        List<Point> red = new ArrayList();
        
        for (int i = 0; i < n; i++) {
            String[] xy = br.readLine().split(" ");
            int x = Integer.parseInt(xy[0]);
            int y = Integer.parseInt(xy[1]);
            red.add(new Point(x, y));
        }
        
        for (int i = 0; i < n; i++) {
            String[] xy = br.readLine().split(" ");
            int x = Integer.parseInt(xy[0]);
            int y = Integer.parseInt(xy[1]);
            blue.add(new Point(x, y));
        }
        
        Collections.sort(blue, new Comparator<Point>() {
            @Override
            public int compare(Point p1, Point p2) {
                return p1.x - p2.x;
            }
        });
        
        Collections.sort(red, new Comparator<Point>() {
            @Override
            public int compare(Point p1, Point p2) {
                return p1.x - p2.x;
            }
        });
        
        int max_y = -1;
        int r_ind = -1;
        int count = 0;
        boolean matched = false;
        for (int i = 0; i < blue.size(); i++) {
            Point b = blue.get(i);
            for (int j = 0; j < red.size(); j++) {
                Point r = red.get(j);
                if ((b.x - r.x > 0) && (b.y - r.y > 0)) {
                    if (r.y > max_y) {
                        //System.out.println("aaa");
                        max_y = r.y;
                        r_ind = j;
                        matched = true;
                    }
                }
            }
            if (matched) {
                //blue.remove(i);
                red.remove(r_ind);
                count++;
            }
            else {
                //blue.remove(i);
            }
            matched = false;
            max_y = -1;
        }
        
        System.out.println(count);
    }
}

class Box {
    int w;
    int h;
    public Box(int w, int h) {
        this.w = w;
        this.h = h;
    }
}

class BoxComparator1 implements Comparator<Box>{
	public int compare(Box b1, Box b2) {
		return b1.w - b2.w;
	}
}

class BoxComparator2 implements Comparator<Box> {
    public int compare(Box b1, Box b2) {
        return b1.h - b2.h;
    }
}


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

int gcd(int a,int b){
  int temp;
  while(b!=0){
    temp=a%b;
    a=b;
    b=temp;
  }
  return a;
}

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  bool pc=true;
  vector<bool> d(1e6+1,false);
  int n,a;
  for(int i=0;i<N;i++){
    if(A.at(i)==1){
      continue;
    }
    if(d.at(A.at(i))){
      pc=false;
      break;
    }
    n=A.at(i);
    a=2;
    while(a*a<=n){
      if(n%a==0){
        n/=a;
        for(int j=a;j<d.size();j+=a){
          d.at(j)=true;
        }
      }else{
        a++;
      }
    }
    for(int j=n;j<d.size();j+=n){
      d.at(j)=true;
    }
    if(!pc){
      break;
    }
  }
  if(pc){
    cout << "pairwise coprime" << endl;
    return 0;
  }
  int g=gcd(A.at(0),A.at(1));
  for(int i=2;i<N;i++){
    g=gcd(A.at(i),g);
  }
  if(g!=1){
    cout << "not coprime" << endl;
  }else{
    cout << "setwise coprime" << endl;
  }
  return 0;
}


Measured memory_bytes: 7112
W,H,C;char m[484];R(i){m[i]>45?m[i]=0,C++,R(i-1),R(i+1),R(i-W),R(i+W):0;}main(i){for(;scanf("%d%d",&W,&H)*W;i=m,R(strchr(m,64)-i),C=!printf("%d\n",C))for(memset(m,W++,484),i=H*W;i--;)m[W+i]=getchar();}

Measured memory_bytes: 0
def examA():
    a, b = LI()
    ans = a
    if a>b:
        ans -=1
    print(ans)



import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()


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

int ctoi(char c){
	if(c >= '0' && c <= '9'){
		return c - '0';
	}
}


int a[10];
int N;

ll func(ll t, ll res, ll now){
	if (t == N) return res+now;
	else return func(t+1, res + (now*10)+a[t], 0) + func(t+1, res, (now*10) + a[t]);
}

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	string S;
    cin >> S;
	N = S.length();
	for (int i = 0; i < N; i++)
	{
		a[i] = ctoi(S[i]);
	}
	ll ans = func(0, 0, 0)/2;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N;
  cin>>N;
  vector<int> A(N),B(N+1);
  B[0]=0;
  for(int i=0;i<N;i++){
    cin>>A[i];
    B[i+1]=B[i]+A[i];
  }
  map<int,int> C;
  for(int &i:B)
    C[i]++;
  int k=0;
  for(pair<int,int> p:C)
    k+=p.second*(p.second-1)/2;
  cout<<k<<endl;
}

Measured memory_bytes: 18840
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	H,A = inputMap()

	ans = -(-H // A)

	print(ans)

if __name__ == "__main__":
	main()


Measured memory_bytes: 38384