akhauriyash/Code-Regression huggingface dataset:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

import numpy as np
from scipy.spatial.distance import cdist
from scipy.sparse.csgraph import dijkstra, csgraph_from_dense

xs, ys, xt, yt = map(int, readline().split())
n = int(readline())
xyr = np.array(read().split(), np.int64)
xyr = np.append(xyr, [xs, ys, 0, xt, yt, 0])
xyr = xyr.reshape((-1, 3))

xy = xyr[:, :2]
dist = cdist(xy, xy)
r = xyr[:, 2]
dist = np.maximum(dist - r - r.reshape((-1, 1)), 0)
dist[np.arange(n+2), np.arange(n+2)] = np.inf
g = csgraph_from_dense(dist, null_value=np.inf)

ans = dijkstra(g, indices=n)[n+1]
print(ans)


Measured memory_bytes: 52232
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <atcoder/dsu>

using boost::multiprecision::cpp_int;
using namespace std;
using namespace atcoder;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  dsu uni(n);
  rep(i, q){
    int t, u, v;
    cin >> t >> u >> v;
    if(t == 0) uni.merge(u, v);
    else cout << uni.same(u, v) << endl;
  }
}


Measured memory_bytes: 3956
#include<iostream>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int a[n];
    int s=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]>=k)
            s++;
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main(){
    Hello
    int n;
    cin >> n;
    ll ans = 0, mn = 1e10, cntr = 0;
    for(int i = 0; i < n; i++){
        ll a;
        cin >> a;
        mn = min(mn, abs(a));
        if(a < 0) cntr++;
        ans += abs(a);
    }
    if(cntr % 2) ans = ans - (2 * mn);
    cout << ans;
    return 0;
}


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

int main(){
  int n,m;
  int a[100]={0};
  while(cin>>n) a[n-1]++;
  m = *max_element(a,a+100);
  for(int i=0;i<100;i++){
    if(m==a[i]) cout<<i+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,a[100],cnt=0,ans=0;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    cnt+=a[i];
  }
  for(int i=0; i<n; i++) {
    if(abs(a[i]*n-cnt)<abs(a[ans]*n-cnt)) {
      ans=i;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

#define N 4
#define N2 16

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

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

struct State{
    Puzzle puzzle;
    int estimated;
    bool operator < (const State &s) const{
        return estimated>s.estimated;
    }
};

int getallMD(Puzzle pz){
    int sum=0;
    for(int i=0;i<N2;i++){
        if(pz.f[i]==N2) continue;
        sum+=MDT[i][pz.f[i]-1];
    }
    return sum;
}

int astar(Puzzle s){
    priority_queue<State> PQ;
    s.MD=getallMD(s);
    s.cost=0;
    map<Puzzle,bool> V;
    Puzzle u,v;
    State initial;
    initial.puzzle =s;
    initial.estimated=getallMD(s);
    PQ.push(initial);
    while(!PQ.empty()){
        State st=PQ.top(); PQ.pop();
        u=st.puzzle;
        if(u.MD==0) return u.cost;
        V[u]=true;
        int sx=u.space/N;
        int sy=u.space%N;
        for(int r=0;r<4;r++){
            int tx=sx+dx[r];
            int ty=sy+dy[r];
            if(tx<0||ty<0||tx>=N||ty>=N){
                continue;
            }
            v=u;
            v.MD-=MDT[tx*N+ty][v.f[tx*N+ty]-1];
            v.MD+=MDT[sx*N+sy][v.f[tx*N+ty]-1];
            swap(v.f[sx*N+sy],v.f[tx*N+ty]);
            v.space=tx*N+ty;
            if(!V[v]){
                v.cost++;
                State news;
                news.puzzle=v;
                news.estimated=v.cost+v.MD;
                PQ.push(news);
            }
        }
    }
    return -1;
}

int main()
{
    for(int i=0;i<N2;i++){
        for(int j=0;j<N2;j++){
            MDT[i][j]=abs(i/N-j/N)+abs(i%N-j%N);
        }
    }
    Puzzle in;
    for(int i=0;i<N2;i++){
        cin>>in.f[i];
        if(in.f[i]==0){
            in.f[i]=N2;
            in.space=i;
        }
    }
    cout<<astar(in)<<endl;
    return 0;
}



Measured memory_bytes: 257700
// https://atcoder.jp/contests/abc059/tasks/arc072_a
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define BIT(n) (1LL << (n))
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, now = 0, cnt[2] = {0};
    cin >> n;
    vector<int> v(n);
    REP(i, n) cin >> v[i];
    REP(i, 2) {
        now = 0;
        REP(j, n) {
            now += v[j];
            if (j % 2 == i) {
                // 0以下なら1にする
                if (now <= 0) {
                    cnt[i] += 1 - now;
                    now = 1;
                }
            } else {
                // 0以上なら-1にする
                if (now >= 0) {
                    cnt[i] += 1 + now;
                    now = -1;
                }
            }
        }
    }
    cout << min(cnt[0], cnt[1]) << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	string s;
	cin>>s;
	ll n=s.length();
	if(s[n-1]!='s'){
		cout<<s<<"s"<<endl;
	}
	else{
		cout<<s<<"es"<<endl;
	}
}

Measured memory_bytes: 3628
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    ans = 0
    a_time = [0]
    b_time = [0]
    for i in range(1, len(a) + 1):
        a_time.append(a_time[i - 1] + a[i - 1])
    for i in range(1, len(b) + 1):
        b_time.append(b_time[i - 1] + b[i - 1])

    a_max = len(a_time) - 1
    b_max = len(b_time) - 1
    for i in range(1, len(a_time)):
        if a_time[i] > k:
            a_max = i - 1
            break
    for i in range(1, len(b_time)):
        if b_time[i] > k:
            b_max = i - 1
            break

    for i in range(len(b_time)):
        if a_time[a_max] + b_time[i] <= k:
            ans = max(ans, a_max + i)
        else:
            if a_max > 0:
                a_max -= 1
    # for i in range(len(a_time)):
    #     if b_time[b_max] + a_time[i] <= k:
    #         ans = max(ans, b_max + i)
    #     else:
    #         if b_max > 0:
    #             b_max -= 1

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 127008
#include <bits/stdc++.h>
using namespace std;
int main (void) {
    int n;
    cin >> n;
    int i = 0;
    while (i < n){
        int a;
        cin >> a;
        if(a % 2 == 1){
            cout << "first" << endl;
            return 0;
        }
        i++;
    }
    cout << "second" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void swap_int(int *x, int *y) {int temp;temp = *x;*x = *y;*y = temp;}
void swap_char(char *x, char *y) {char temp;temp = *x;*x = *y;*y = temp;}
int max(int x, int y) { return x > y ? x : y; }
int min(int x, int y) { return x > y ? y : x; }

int main(){
    double w,h,x,y;
    double ans1;
    int ans2;

    scanf("%lf %lf %lf %lf",&w,&h,&x,&y);

    ans2=(w/2==x&&h/2==y)?1:0;
    ans1=w*h/2;

    printf("%.12lf %d\n",ans1,ans2); 
    return 0;
    
}

Measured memory_bytes: 128
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            int a = sc.nextInt();
            map.put(a, map.getOrDefault(a, 0)+1);
        }
        int even = 0;
        for (int v : map.values()) {
            if (v%2 == 0) {
                even++;
            }
        }

        System.out.println(even%2 == 0 ? map.size() : map.size()-1);
    }
}



Measured memory_bytes: 59388
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include<algorithm>
#define pf printf
#define sf scanf
#define wh while
#define db double
#define LL long long
#define _USE_MATH_DEFINES
#define re(i,a,b) for(int i=a;i<b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

int main()
{
    char s[50];
    cin>>s;
    int l=strlen(s);
    rev(i,l-1,0)pf("%c",s[i]);
    pf("\n");
    return 0;
}

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

int main(){

  ll N=0;
  cin>>N;
  
  N=N*N;
  cout<<N;
}

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

using ll = long long;
using namespace std;

const int mod = (int)1e9 + 7;

struct mint {
    ll x; // typedef long long ll;
    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 {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=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 {
        mint res(*this);
        return res/=a;
    }
};

//a^n
mint pow(int a, int n){
    if (n == 0) return 1;
    mint x = pow(a, n/2);
    x *= x;
    if (n%2 == 1) x *= a;
    return x;
}

//mint choose(int n, int i){
//    mint numerator = 1, denominator = 1;
//    for (int j = 0; j < i; j++){
//        numerator *= n - j;
//        denominator *= j + 1;
//    }
//    return numerator / denominator;
//}

int main(){
    int n, k;
    cin >> n >> k;
    mint ans = 0;
    k = min(k, n - 1);
    vector<mint> factorial(n+1), ifactorial(n+1);
    factorial[0] = 1;
    for (int i = 0; i < n; i++){
        factorial[i+1] = factorial[i] * (i+1);
    }

    for (int i = 0; i < k + 1; i++){
        mint elem1 = factorial[n] / factorial[i] / factorial[n-i];
        mint elem2 = factorial[n-1] / factorial[i] / factorial[n-i-1];
        ans += elem1 * elem2;
    }
    cout << ans.x << endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

int n;
ll x[1252], y[1252];

int m;
ll d[42];
char c[] = "RULD";
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

char buf[42];

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%lld%lld",x+i,y+i);
  int p = abs(x[0]+y[0])%2;
  REP(i,n){
    int q = abs(x[i]+y[i])%2;
    if(p!=q){
      puts("-1");
      return 0;
    }
  }
  m = 31;
  REP(i,m)d[i] = 1ll<<(m-1-i);
  if(p==0){
    d[m++] = 1ll;
  }
  printf("%d\n",m);
  REP(i,m)printf("%lld%c",d[i],i==m-1?'\n':' ');
  REP(i,n){
    ll px = 0, py = 0;
    REP(j,m){
      ll nx = 1ll<<60, ny = 1ll<<60;
      REP(dd,4){
        ll cx = px+d[j]*dx[dd];
        ll cy = py+d[j]*dy[dd];
        if(abs(cx-x[i])+abs(cy-y[i]) < abs(nx-x[i])+abs(ny-y[i])){
          buf[j] = c[dd];
          nx = cx;
          ny = cy;
        }
      }
      px = nx;
      py = ny;
      // printf("%d: (%lld, %lld)\n",j,px,py);
    }
    puts(buf);
    assert(px==x[i] && py==y[i]);
  }
  return 0;
}


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

using namespace std;
 
int main() {

	string s,t;

	cin>>s>>t;
	int num_common = 0;
	int common;
	for(int i=0; i <= s.length()-t.length(); i++) {

		common = 0;

		for(int j=0; j < t.length(); j++) {
			if(s[i+j] == t[j]) common++;
		}

		num_common = max(num_common, common);
	}

	cout<<t.length()-num_common<<endl;

	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int ord2(int x ){
    int ans = 0;
    while (x%2==0){
        x /= 2;
        ans++;
    }
    return ans;
}

int main() {
    int N;
    cin >> N;
    vector<int>As(N);
    int nin = 1000000;
    for (int i=0; i<N; i++)cin >> As[i];
    for(int i=0; i<N; i++)chmin(nin, ord2(As[i]));

    cout << nin << endl;   
}

Measured memory_bytes: 256
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<bits/stdc++.h>
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector>
#define rep0(i,n)  for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define rep1(i,n)  for(ll i=1; i<=n; i++)
#define rrep1(i,n) for(ll i=n; 1<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e18
using ll = long long;
using namespace std;
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; }

int main(){
  int n;  cin >> n;
  vi a(n),b(n),c(n);
  rep0(i,n)cin >> a[i] >> b[i] >> c[i];
  vector<vll> dp(n+1,vll(3));
  rep1(i,n){
    dp[i][0] = max(dp[i-1][1]+b[i-1],dp[i-1][2]+c[i-1]);
    dp[i][1] = max(dp[i-1][0]+a[i-1],dp[i-1][2]+c[i-1]);
    dp[i][2] = max(dp[i-1][0]+a[i-1],dp[i-1][1]+b[i-1]);
  }
  cout << max({dp[n][0],dp[n][1],dp[n][2]});
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,M;
int A[222222];

int cnt[222222];
int latte[222222];

signed main(){
    cin>>N>>M;
    rep(i,N)cin>>A[i];
    rep(i,N)cnt[A[i]]++;
    for(int i=1;i<=N;i++){
        latte[max(0ll,i-cnt[i])]++;
        latte[i]--;
    }

    rep(i,222222-1)latte[i+1]+=latte[i];

    int ans=0;
    rep(i,N)if(latte[i]==0)ans++;

    rep(i,M){
        int x,y;
        cin>>x>>y;
        x--;

        int k=A[x];
        if(cnt[k]<=k){
            if(--latte[k-cnt[k]]==0)ans++;
        }
        cnt[k]--;

        cnt[y]++;
        if(cnt[y]<=y){
            if(latte[y-cnt[y]]++==0)ans--;
        }

        A[x]=y;

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


Measured memory_bytes: 6400
using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp2
{


    public class Program
    {

        static long mod = (long)Math.Pow(10, 9) + 7;

        public static void Main(string[] args)
        {
            int[] NY = Read(Console.ReadLine());
            int[] bills = { 1, 5, 10 };
            int N = NY[0];
            int Y = NY[1] / 1000;

            for (int man = 0; man <= N; man++)
            {
                for (int go = 0; go <= N-man; go++)
                {
                    int sen = N - man - go;

                    if (Y == 10 * man + 5 * go + sen * 1)
                    {
                        Console.WriteLine(man + " " + go + " " + sen);
            Console.ReadLine();
                        return;
                    }
                }
            }

            Console.WriteLine("-1 -1 -1");
            Console.ReadLine();

        }

        private static int[] Read(string input)
        {
            string[] strings = input.Split(' ');
            int num = strings.Length;
            int[] ints = new int[num];
            for (int i = 0; i < num; i++)
            {
                ints[i] = int.Parse(strings[i]);
            }

            
            return ints;
        }


    }


}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 0x3fffffff;
const ll MOD = 1e9+7;


// n^m%MOD を求める。O( log(m) )
ll modpow(ll n, int m){
	ll ret=1;
	for(int i=1; i<=m; i<<=1, (n*=n)%=MOD){
		if( m&i ) (ret *= n) %= MOD;
	}
	return ret;
}

// 逆元を求める
ll modinv(ll n){
	return modpow( n, MOD-2 );
}

// 階乗を求める。O(1)  準備O( n*log(n) )
// fact[n]     : nの階乗
// fact.inv[n] : nの階乗の逆元
class FACTORIAL{
	public:
		vector<ll> fact, inv;
		FACTORIAL(int MAX_NUM): fact(MAX_NUM), inv(MAX_NUM) {
			fact[0] = inv[0] = 1;
			for(ll i=1; i<MAX_NUM; i++){
				fact[i] = (fact[i-1] * i) % MOD;
				inv[i] = modinv( fact[i] );
			}
		}
		const ll& operator [ ] ( const int i ) const {
			return fact[i];
		}
} fact(1000006); // nの最大値を指定


// 組み合わせ(Combinationを求める) O(1)
ll cmb(unsigned int n, unsigned int r){
	if( n < r ) return 0;
	return fact[n] * fact.inv[r] % MOD * fact.inv[n-r] % MOD;
}


int main(){
	//ios_base::sync_with_stdio(0);
	ll N, ans=0;
	int a[100005];

	cin >> N;
	rep(i,N+1) cin >> a[i];

	int b[100005] = {};
	Fill( b, -1 );
	ll l, r;
	rep(i,N+1){
		if( b[ a[i] ] >= 0 ){
			l = b[a[i]];
			r = i;
		}
		b[a[i]] = i;
	}

	ll memo[2][100005]={};
	//ll ans[100005] = {};
	//Fill( ans, 1ll );
	for(int i=1; i<=N+1; i++){
		ll ans = 1;
		if( i == 1 ) ans = N;
		else{
			ans = cmb( N+1-2, i );
			ans += cmb(N+1-2, i-1);
			ans %= MOD;
			ans += cmb(N+1-2, i-1);
			ans %= MOD;
			ans = ans + MOD - cmb(N-r+l, i-1);
			ans %= MOD;
			ans += cmb(N+1-2, i-2);
			ans %= MOD;
		}
		//ll sum;
		//sum =  cmb( r-l, 1 );
		//sum *= cmb( r, i-1 );
		//sum %= MOD;
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 17664
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var word = Console.ReadLine();
            Console.WriteLine(word[2] == word[3] && word[4] == word[5] ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 13140
use proconio::input;

fn main() {
  input! {
      mut n: usize,
  }
  let mut ans = Vec::new();
  while n > 0 {
    ans.push((((n - 1) % 26) as u8 + 'a' as u8) as char);
    n = (n - 1) / 26
  }
  for e in ans.into_iter().rev() {
    print!("{}", e);
  }
  println!();
}


Measured memory_bytes: 2172
def read_input():
    r, g, b, n = map(int, input().split())
    return r, g, b, n

def submit():
    r, g, b, n = read_input()

    r_max = n // r
    g_max = n // g

    count = 0
    for rc in range(r_max + 1):
        for gc in range(g_max + 1):
            rest = n - (r*rc) - (g*gc)
            if rest < 0:
                continue

            bc, remain = divmod(rest, b)
            if remain == 0:
                count += 1

    print(count)

if __name__ == '__main__':
    submit()


Measured memory_bytes: 40812
#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;
#define lli long long int
#define double long double
#define all(x) x.begin(),x.end()
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define siz(x) x.size()
#define prs(x,y) x.find(y)!=x.end()
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define forn(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res;}
inline int level(int n){int ans=0;while(n%2==0){n/=2;ans++;}return ans;}
map<int,int> col,row;
vector<int> vec[300005];
int main()
{
	fast_io //REMOVE FOR interactive problems
	int h,w,m;
	cin>>h>>w>>m;
	while(m--)
	{
		int x,y;
		cin>>x>>y;
		col[x]++;
		row[y]++;
		vec[x].push_back(y);
	}
	multiset<int> mult,st;
	for(auto x: row)
		mult.insert(x.second);
	int ansa=0;
	for(auto x: col)
	{
		int cl=x.first;
		int siz=x.second;
		for(auto k: vec[cl])
		{
			int kr=row[k];
			mult.erase(mult.find(kr));
			st.insert(kr);
		}
		if(!st.empty())
		ansa=max(ansa,siz+(*st.rbegin())-1);
		if(!mult.empty())
		ansa=max(ansa,siz+(*mult.rbegin()));
		while(!st.empty())
		{
			mult.insert(*st.begin());
			st.erase(st.begin());
		}
	}
	cout<<ansa;
}



Measured memory_bytes: 62196
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<cmath>
using namespace std;

typedef long long ll;
const double INF=0x3f3f3f3f;
const int MAXN=1005;

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        double count1=0;
        for(int i=1;i<=n;i++)
            if(i%2==1)
                count1++;
        printf("%.10f",count1/n);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
    #include <cmath>
    #include <iomanip>
    #include <vector>
    #include <algorithm>
     
    using namespace std;
     
    int main()
    {
     
        int N, K;
     
        cin >> N >> K;
     
        int count = max(0, N - K);
        int p = 0;
     
        for(int i = min(N, K); i > 0; --i){
            int f = (int)ceill(log2l((long double)K / i));
            while(p < f){
                ++p;
                count *= 2;
            }
            count += 1;
        }
     
        cout<< setprecision(14) << (long double)count / N / powl(2, p) << endl;
     
        return 0;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ar[202030];
int main(){
	int k,n;
	cin >> k >> n >> ar[0] >> ar[1];
	int maxi=ar[1]-ar[0];
	for(int i=2;i<n;i++){
		cin >>ar[i];
		if(ar[i]-ar[i-1]>maxi)
			maxi=ar[i]-ar[i-1];
	}
	int max2=ar[0]-(ar[n-1]-k);
	if(max2>maxi)
		cout << k-max2;
	else
		cout << k-maxi;
	cout << "\n";
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    string s;
    cin >> s;
    int ans = 0;
    REP(i, s.length() - 1){
        if(s[i] != s[i+1]) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

template<typename First, typename Second, typename Third>
struct triple {
   First first;
   Second second;
   Third third;
};

using namespace std;

void solve(){
    int A[3];
   cin>>A[0]>>A[1]>>A[2];
   sort(A,A+3);
   if(A[0]==A[1]&&A[2]!=A[1])
          cout<<"Yes";
   else if(A[1]==A[2]&&A[0]!=A[2])
          cout<<"Yes";
   else
         cout<<"No"; 
     
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N;
  	cin >> N;
  	set<string> Gift;
  	for(int i = 0; i < N; i++){
    	string deta;
      	cin >> deta;
      	Gift.insert(deta);
    }
  	cout << Gift.size() << endl;
}

Measured memory_bytes: 19256
from collections import Counter
from functools import reduce
import bisect
import random
import fractions
import math
# import statistics
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]  # LIST INT
def LF(): return [float(x) for x in sys.stdin.readline().split()]  # LIST FLOAT
def LS(): return sys.stdin.readline().split()  # LIST STRING
def MI(): return map(int, sys.stdin.readline().split())  # MAP INT
def II(): return int(sys.stdin.readline())  # INPUT INT
def IS(): return input()  # INPUT STRING
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):  # Greatest Common Divisor
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):  # Least Common Multiple
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))


n, v, c = II(), LI(), LI()
# n = 20
# v = [random.random()* 100 for i in range(20)]
# c = [random.random()* 100 for i in range(20)]
y = 0
maxi = -INF
start = time.time()
for i in range(2 ** n):
    x = 0
    y = 0
    for j in range(n):
        if i >> j & 1:
            x += v[j]
            y += c[j]
    maxi = max(maxi, x - y)

# print(time.time() - start)
print(maxi)


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

using namespace std;

int main()
{
    string str, replaced_string, command, sub_string;
    int input_length, a, b;
    cin >> str;
    cin >> input_length;
    for (int i = 0; i < input_length; ++i)
    {
        cin >> command >> a >> b;
        if (command == "replace")
        {
            cin >> replaced_string;
            str.replace(a, replaced_string.length(), replaced_string);
        }
        else if (command == "print")
        {
            sub_string = str.substr(a, (b - a + 1));
            cout << sub_string << endl;
        }
        else if (command == "reverse")
        {
            replaced_string = "";
            sub_string = str.substr(a, (b - a + 1));
            for (int i = sub_string.length() - 1; 0 <= i; --i)
            {
                replaced_string += sub_string[i];
            }
            str.replace(a, replaced_string.length(), replaced_string);
        }
    }

    return 0;
}


Measured memory_bytes: 3204
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll h,w,n;
  cin >> h >> w >> n;
  map<pair<ll,ll>,ll> mp; 
  vector<ll> y = {-2,-2,-2,-1,-1,-1,0,0,0};
  vector<ll> x = {-2,-1,0,-2,-1,0,-2,-1,0};
  for(int i = 0;i < n;i++){
    ll a,b;
    cin >> a >> b;
    a--,b--;
    for(int j = 0;j < 9;j++){
      ll nexty = a + y[j];
      ll nextx = b + x[j];
      if(nexty >= 0 && nextx >= 0 && nexty + 2 < h && nextx + 2 < w){
        mp[make_pair(nexty,nextx)]++;
      }
    }
  }
  vector<ll> res(10);
  for(int i = 0;i < 10;i++)res[i] = 0;
  for(auto i:mp)res[i.second]++;
  res[0] = (h - 2) * (w - 2);
  for(int i = 1;i < 10;i++)res[0] -= res[i];
  for(int i = 0;i < 10;i++)cout << res[i] << endl;
  //for(int i = 1;i <= 300;i++)for(int j = 1;j <= 300;j++)cout << i << " " << j << endl;
}

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

int main() {
  vector<int> table(10000,1);
  table[0] = 0;
  table[1] = 0;
  for (int i=2; i<100; i++) {
    if (table[i])
      for (int j=i*2; j<=10000; j+=i)
        table[j] = 0;
  }

  int n;
  while(cin >> n) {
    int ans = 0;
    for (int i=1; i<=n; i++)
      if(table[i] && table[n-i+1])
        ans++;
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
bool M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

bool visited[N];

int dfs_visit(int u){
    
    visited[u] = true;
    
    bool all_visited = true;
    rep(i, n){
        if(!visited[i]) all_visited = false;
    }
    if(all_visited) return 1;
    
    int res = 0;
    
    rep(v, n){
        if(M[u][v] == false)    continue;
        if(visited[v] == false){
            
            res = res + dfs_visit(v);
            visited[v] = false;
        }
    }
    
    return res;
}

int dfs(){
    rep(i, n)   visited[i] = false;
    
    int res = dfs_visit(0);
    return res;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int m;
    cin >> n >> m;
    int a, b;
    rep(i, m){
        cin >> a >> b;
        M[a - 1][b - 1] = M[b - 1][a - 1] = true;
    }
    
    int res = dfs();
    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const long INF=1e18;
long N;
int root(int v,int w){
	if(v>w) swap(v,w);
	if(N==1||v==w) return v;
	int a=(v+N-2)/N,b=(w+N-2)/N;
	if(a==b) return a;
	return root(v,b);
}
int main(){
	int Q;cin>>N>>Q;
	long v,w;
	rep(i,0,Q){
		cin>>v>>w;
		cout<<root(v,w)<<endl;
	}
}

Measured memory_bytes: 1280
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = l[0], A = l[1], B = l[2], C = l[3], D = l[4];

            var array = Console.ReadLine().ToCharArray();
            var lastB = D;

            for (var i = B; i < D; i++)
            {
                if (array[i - 2] == '.' && array[i] == '.')
                {
                    lastB = i;
                    break;
                }

                var tmp = Judge(array, i, 'B');
                if (tmp >= 0)
                    i += tmp;
                else
                    return;
            }

            for (var i = A; i < C; i++)
            {
                var tmp = Judge(array, i, 'A');
                if (tmp >= 0)
                    i += tmp;
                else
                    return;
            }

            for (var i = lastB; i < D; i++)
            {
                var tmp = Judge(array, i, 'B');
                if (tmp >= 0)
                    i += tmp;
                else
                    return;
            }

            Console.WriteLine("Yes");
        }

        static int Judge (char[] array, int ind, char word)
        {

            if (array[ind] == '.')
            {
                array[ind - 1] = '.';
                array[ind] = word;
                return 0;
            }
            else if (array[ind + 1] == '.')
            {
                array[ind - 1] = '.';
                array[ind + 1] = word;
                return 1;
            }
            else
            {
                Console.WriteLine("No");
                return -1;
            }
        }
    }
}


Measured memory_bytes: 13288
N = int(raw_input().strip())
A = map(int, raw_input().strip().split(" "))

odd  = 0
for i in range(0, N):
    if(A[i] % 2 != 0):
        odd += 1

if(odd%2 == 0):
    print "YES"
else:
    print "NO"


Measured memory_bytes: 11300
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <utility>
#include <numeric>

using namespace std;

int main() {
    int N; cin >> N;
    vector<int> B(N);
    for (int i = 0; i < N-1; i++)
    {
        cin >> B[i];
    }

    vector<int> A(N);
    A[0] = B[0];
    for (int i = 1; i < N-1; i++)
    {
        A[i] = min(B[i-1], B[i]);
    }
    A[N-1] = B[N-2];
    
    cout << accumulate(A.begin(), A.end(), 0) << endl;
    
}


Measured memory_bytes: 256
import java.util.*;
     
    public class Main {
     
    	public static void main(String[] args){
        		Scanner in = new Scanner(System.in);
        		
        		String[] s = in.next().split("");
        		String answer = "";
        		for (int x = 0; x < 4; x++){
        			answer += s[x];
        		}
        		answer += " ";
        		for (int x = 4; x < s.length; x++){
        			answer += s[x];
        		}
        		System.out.println(answer);
        		in.close();
        }
    }	

Measured memory_bytes: 9684
#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 mset(m,v) memset(m,v,sizeof(m))
#define mod 1000000007
const int N = 2e5 + 5;
#define PI acos(-1.0)
long double EPS = 1e-9;
typedef long long ll;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
#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(int x, int y) { x -= y; if (x < 0) x += mod; return x; }
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;
void solve() {
	int s, w;
	cin >> s >> w;
	if (w >= s) {
		cout << "unsafe" << endl;
	}
	else {
		cout << "safe" << endl;
	}
}
signed main()
{
	fastio;
	//cout<<fixed<<setprecision(15);
	//clock_t begin = clock();
	int tc;
	tc = 1;
	//cin >> tc;
	while (tc--) {
		solve();
	}
	//clock_t end = clock();double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;cerr << elapsed_secs;
}


Measured memory_bytes: 3652
n, x, m = map(int, input().split())

def f(x, m):
    return (x**2) % m

a = [x]
end = 0
for i in range(1, n):
    tmp = f(a[i-1], m)
    if tmp in a:
        end = i
        break
    a.append(tmp)
if end == 0:
    print(sum(a[:n]))
    exit()
start = -1
for idx, v in enumerate(a):
    if v == tmp:
        start = idx
# print(end-start)
# print(a, start, end)
length = end - start
set_sum = sum(a[start:end+1])
# print(set_sum)
if n-1 < start:
    print(sum(a[:n]))
    exit()
else:
    ans = sum(a[:start])
    plus = n - start
    num = plus // length
    yozyo = plus % length
    ans += (set_sum*num)
    ans += sum(a[start:start+yozyo])
    print(ans)
    exit()

Measured memory_bytes: 70832
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		ArrayList<Integer> one = nextIntArray();
		int mae = one.get(0);
		int ato = one.get(1);
		int output = mae;
		if(ato < mae){
			output--;
		}
		myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 32728
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    ll T1, T2, A1, A2, B1, B2;
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;

    if (A1 > B1) {
        swap(A1, B1);
        swap(A2, B2);
    }

    ll D12 = A1 * T1 + A2 * T2 - (B1 * T1 + B2 * T2);
    if (D12 == 0 || A1 == B1) {
        write("infinity");
        return 0;
    }

    if (D12 < 0) {
        write(0);
        return 0;
    }

    ll n2 = (B1 * T1 - A1 * T1) / D12 + 1;
    ll n1 = n2 - 1 - ((B1 * T1 - A1 * T1) % D12 == 0);
    write(n1 + n2);
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

cnt = 0

for h in range(1,101):
    exi = 0
    for f in range(N):
        if H[f] >= h:
            tmp = 1
        else:
            tmp = 0
        if tmp != exi:
            cnt += 1 - exi
            exi = 1 - exi
print(cnt)

Measured memory_bytes: 3060
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
// dfmt on

long M;

long query(long[] A, long lhs, long rhs, long clhs, long crhs, long current = 1)
{
    if (lhs == rhs)
        return long.min;
    if (rhs <= clhs || crhs <= lhs)
        return long.min;
    if (lhs <= clhs && crhs <= rhs)
        return A[current];
    long m = (lhs + rhs) / 2;
    long cm = (clhs + crhs) / 2;
    long l = query(A, lhs, rhs, clhs, cm, current * 2);
    long r = query(A, lhs, rhs, cm, crhs, current * 2 + 1);
    return max(l, r);
}

void main()
{
    long N = lread();
    M = 2 ^^ (cast(long) ceil(log2(N)));
    auto A = new long[](2 * M);
    A[] = long.min;
    foreach (i; 0 .. N)
    {
        A[A.length - M + i] = lread();
    }
    foreach_reverse (d; 0 .. cast(long) ceil(log2(N)))
    {
        foreach (i; 0 .. 2 ^^ d)
        {
            long p = 2 ^^ d + i;
            A[p] = max(A[p * 2], A[p * 2 + 1]);
        }
    }
    foreach (i; 0 .. N)
    {
        writeln(query(A, 0, i, 0, M).max(query(A, i + 1, M, 0, M)));
    }
}


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

#define I cin
#define O cout
#define EN endl
#define ln cout<<endl
#define pb(a) push_back(a)

typedef long long int llint;

int n;
int i, j;
llint cnt = 0;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int gcd(int a, int b)
{
  return (a % b ? gcd(b, a % b) : b);
}

int main()
{
  I >> n;

  int a[100002] = {};
  for(i = 0; i < n; i++) {
    int m;
    I >> m;
    a[m]++;
  }

  int mx = 0;
  for(i = 0; i < 100001; i++) {
    int tmp = a[i] + a[i + 1];
    if(i) tmp += a[i - 1];
    mx = max(mx, tmp);
  }

  O << mx << EN;
      
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
using namespace std;
int main(){
  
  long long int n; cin >> n;
  
  int y500 = n / 500;
  int y5 = (n - y500 * 500) / 5;
  
  cout << y500 * 1000 + y5 * 5 << endl; 
 
    return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
 
		long a,b;
 
		Scanner sc = new Scanner(System.in);
 
		a = sc.nextLong();
		b = sc.nextLong();
 
		long ans = 2018;
 
		if (b - a >= 2019) {
			ans = 0;
		} else {
 
			for (long i = a; i < b; ++i) {
				for (long j = i+1; j <= b; ++j) {
					ans = Math.min(ans, (i * j) % 2019);
				}
 
			}
  
		}
 
			System.out.println(ans);
 	}
  
}


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

#define Fast cin.tie(0), ios::sync_with_stdio(0)
#define All(x) x.begin(), x.end()
#define louisfghbvc int t; cin >> t; while(t--)
#define sz(x) (int)(x).size()
using namespace std;
typedef long long LL;
typedef pair<LL, LL> ii;
typedef vector<LL> vi;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep = ""; for(const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << "\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

void solve(){
    LL n, a, b, c;
    cin >> n;
    vi dp(3);
    for(int i = 0; i < 3; ++i) cin >> dp[i];

    for(int i = 1; i < n; ++i){
        cin >> a >> b >> c;
        vi prev = dp;
        dp[0] = max({prev[0], prev[1]+a, prev[2]+a});
        dp[1] = max({prev[1], prev[0]+b, prev[2]+b});
        dp[2] = max({prev[2], prev[0]+c, prev[1]+c});
    }

    cout << max({dp[0], dp[1], dp[2]}) << "\n";
}

int main()
{
    Fast;
    //louisfghbvc{
        solve();
    //}
    return 0;
}

Measured memory_bytes: 3624