akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {

    public static final String YES = "YES";
    public static final String NO = "NO";

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

    public void execute(CustomReader in) throws IOException {
        int[] hwn = in.readLineAsIntArray();
        final int H = hwn[0];
        final int W = hwn[1];
        final int N = hwn[2];

        int[] start = in.readLineAsIntArray();
        int sr = start[0];
        int sc = start[1];

        String takahashi = in.readLine();
        String aoki = in.readLine();

        int leftBound = 1;
        int rightBound = W;
        int upBound = 1;
        int downBound = H;

        for (int i = N - 1; i >= 0; i--) {
            char ca = aoki.charAt(i);
            switch (ca) {
                case 'L':
                    rightBound = Math.min(rightBound + 1, W);
                    break;
                case 'R':
                    leftBound = Math.max(1, leftBound - 1);
                    break;
                case 'U':
                    downBound = Math.min(downBound + 1, H);
                    break;
                case 'D':
                    upBound = Math.max(1, upBound - 1);
                    break;
            }
            char ct = takahashi.charAt(i);
            switch (ct) {
                case 'L':
                    leftBound++;
                    break;
                case 'R':
                    rightBound--;
                    break;
                case 'U':
                    upBound++;
                    break;
                case 'D':
                    downBound--;
                    break;
            }
            if (leftBound > rightBound || upBound > downBound) {
                break;
            }
        }
        if (leftBound <= sc && sc <= rightBound && upBound <= sr && sr <= downBound) {
            System.out.println(YES);
        } else {
            System.out.println(NO);
        }
    }

    static class CustomReader extends BufferedReader {

        public CustomReader() throws IOException {
            super(new InputStreamReader(System.in));
        }

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

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

Measured memory_bytes: 26580
#include<stdio.h>

int main(void){
    
    int m,f,r;
    
    while(1){
        scanf("%d %d %d",&m,&f,&r);
        if(m==-1 && f==-1 && r==-1)
            break;
        
        if(m==-1 || f==-1){
            printf("F\n");
        }else if(m+f>=80){
            printf("A\n");
        }else if(m+f>=65){
            printf("B\n");
        }else if(m+f>=50){
            printf("C\n");
        }else if(m+f>=30){
            if(r>=50){
                printf("C\n");
            }else{
                printf("D\n");
            }
        }else{
            printf("F\n");
        }
        
    }return 0;
}

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

#define db double
const db eps = 1e-6;

struct poi {
	db x, y;
	void r() { cin >> x; cin >> y; }
	void w() { cout << x << ' ' << y << '\n'; }
	poi operator -(poi p) {
		return {x - p.x, y - p.y};
	}
	poi operator +(poi p) {
		return {x + p.x, y + p.y};
	}
	poi operator *(db d) {
		return {x * d, y * d};
	}
	db dot(poi p) {
		return x * p.x + y * p.y;
	}
	db cross(poi p) {
		return x * p.y - y * p.x;
	}
	db len2() { return x * x + y * y; }
	poi proj(poi p, poi q) {
		db s = (*this - p).dot(q - p) / (q - p).len2();
		return p + (q - p) * s;
	}
};

int ccw(poi a, poi b, poi c) {
	poi u = b - a, v = c - a;
	if(u.cross(v) > eps) return 1;
	if(u.cross(v) < -eps) return -1;
	if(u.dot(v) < -eps) return -2;
	if(u.len2() + eps < v.len2()) return 2;
	return 0;
}

int main() {
	ios :: sync_with_stdio(false);

	poi p, q; p.r(); q.r();
	int T; cin >> T;
	while(T --) {
		poi t; t.r();
		int a = ccw(p, q, t);
		//cout << a << '\n';
		cout << (a != -2 ? a != -1 ? a != 0 ? a != 1 ?
			"ONLINE_FRONT" :
			"COUNTER_CLOCKWISE" :
			"ON_SEGMENT" :
			"CLOCKWISE" :
			"ONLINE_BACK") << '\n';
	}
	return 0;
}

Measured memory_bytes: 3272
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;

// ÀW(xNg)
typedef complex<double> P;

// î{Ö(è)
#define EPS			(1e-10)
#define INF			(1e+10)
#define PI			(3.14159265358979323846)

#define X(a)		( (a).real() )
#define Y(a)		( (a).imag() )
#define EQ(a,b)		( -EPS<(a)-(b) && (a)-(b)<EPS )
#define EQV(a,b)	( EQ(X(a),X(b)) && EQ(Y(a),Y(b)) )

#define unit(a)		( (a)/abs(a) )
#define normal(a)	( (a)*P(0,1) )
#define dot(a,b)	( X((a)*conj(b)) )
#define cross(a,b)	( Y(conj(a)*(b)) )

// 3_ÌÊuÖW
int ccw(P a, P b, P c)
{
	b -= a; c -= a;
	if(cross(b, c) > 0)   return +1;	// counter clockwise
	if(cross(b, c) < 0)   return -1;	// clockwise
	if(dot(b, c) < 0)     return +2;	// c--a--b on line
	if(norm(b) < norm(c)) return -2;	// a--b--c on line
	return 0;
}



// üÆ¼üÌð_
P projection(P a, P b, P p)
{
	double t = dot(p-a, a-b) / norm(a-b);
	return a + t*(a-b);
}

// ¼üÉÎÌÈ_
P reflection(P a, P b, P p)
{
	return p + 2.0*(projection(a,b,p) - p);
}

bool intersectSS(P a, P b, P c, P d)
{
	return	ccw(a,b,c)*ccw(a,b,d) <= 0 &&
			ccw(c,d,a)*ccw(c,d,b) <= 0;
}

// ¼üÆ¼üÌð_
P crosspointLL(P a, P b, P c, P d)
{
	double det=cross(d-c,b-a);
	assert(!(abs(det)<EPS));

	return a + (b-a) * cross(d-c,c-a)/det;
}



int N,rf[5];
double a;
P S,D,M[5][2];


P calcPoint(int t)
{
	P T=D;
	for(int i=0; i<t; i++)
	{
		int sm = rf[t-i-1];
		T = reflection(M[sm][0], M[sm][1], T);
	}
	return T;
}

bool check(int t, P X, P Y)
{
	if(t==0)
	{
		for(int i=0; i<N; i++)
		{
			if(intersectSS(X,Y,M[i][0],M[i][1]))
			{
				return false;
			}
		}
		return true;
	}

	P C;
	int prsm = -1;
	for(int i=0; i<t; i++)
	{
		int sm = rf[i];
		if(!intersectSS(X,Y,M[sm][0],M[sm][1]))
		{
			//cout << "No:" << sm << endl;
			return false;
		}

		C=crosspointLL(X,Y,M[sm][0],M[sm][1]);

		for(int j=0; j<N; j++)
		{
			if(j==sm || j==prsm) continue;

			if(intersectSS(X,C,M[j][0],M[j][1]))
			{
				//cout << "Hit:" << i << " " << j << endl;
				return false;
			}
		}
		
		X = C;
		Y = reflection(M[sm][0],M[sm][1],Y);
		prsm = sm;
	}
	
	for(int j=0; j<N; j++)
	{
		if(j==prsm) continue;

		if(intersectSS(C,Y,M[j][0],M[j][1]))
		{
			//cout << "Hit:" << i << " " << j << endl;
			return false;
		}
	}

	return true;
}

void dfs(int t, int p)
{
	if(t>=6) return;

	P T=calcPoint(t);
	if(abs(T-S)>abs(D-S)+EPS || t==0)
	{
		/*
		cout << "Ref:";
		for(int i=0; i<t; i++)
		cout << rf[i];
		cout << endl;
		cout << check(t,S,T) << " " << abs(T-S) << endl;
		*/
		if(check(t,S,T))
		{
			a = min(a,abs(T-S));
		}
	}

	for(int i=0; i<N; i++)
	{
		if(i!=p)
		{
			rf[t] = i;
			dfs(t+1,i);
		}
	}

}

int main()
{
	while(cin >> N, N)
	{
		for(int i=0; i<N; i++)
		{
			cin >> X(M[i][0]) >> Y(M[i][0]);
			cin >> X(M[i][1]) >> Y(M[i][1]);
		}
		cin >> X(D) >> Y(D);
		cin >> X(S) >> Y(S);

		
		a = INF;
		dfs(0,-1);
		printf("%.5lf\n",a);
	}
	
}

Measured memory_bytes: 1004
#include<iostream>
#include<algorithm>
#include<string>
#include<cctype>
#include<cmath>

int main() {
    std::string a, b;
    std::cin >> a >> b;
    auto n = std::stoi(a + b);
    int nn = (int)std::sqrt(n);
    if (n == nn * nn) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
}

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

#define INF 1 << 21

using namespace std;

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

    int N;
    cin >> N;

    int F[N][10];

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 10; ++j) {
            cin >> F[i][j];
        }
    }

    int P[N][11];
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 11; ++j) {
            cin >> P[i][j];
        }
    }

    long long ans = -10000000000000LL;
    for (int i = 0; i < 10; ++i) {
        string iter = "";

        for (int j = 0; j < 9 - i; ++j) {
            iter += "0";
        }

        for (int j = 0; j < i; ++j) {
            iter += "1";
        }

        iter += "1";

        do {
            int counter[N];
            for (int i = 0; i < N; ++i) {
                counter[i] = 0;
            }

            for (int i = 0; i < N; ++i) {
                for (int j = 0; j < 10; ++j) {
                    if (iter[j] - '0' == F[i][j] && F[i][j] == 1) {
                        counter[i]++;
                    }
                }
            }

            int res = 0;
            for (int i = 0; i < N; ++i) {
                res += P[i][counter[i]];
            }

            ans = max(ans, 1LL * res);
        } while (next_permutation(iter.begin(), iter.end()));
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#define pb push_back

using namespace std;

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

int a[4][4], uz[4][4], sl[5], sc[5], sd1, sd2;

int main()
{
    int x;
    for (int i=1;i<=3;i++)
        for (int j=1;j<=3;j++)
            cin >> a[i][j];
    int n;
    cin >> n;
    for (int i=1;i<=n;i++)
    {
        cin >> x;
        for (int l=1;l<=3;l++)
            for (int c=1;c<=3;c++)
                if (a[l][c] == x)
                    uz[l][c] = 1;
    }
    for (int i=1;i<=3;i++)
        for (int j=1;j<=3;j++)
        {
            sl[i]+=uz[i][j];
            sc[j]+=uz[i][j];
            if (i == j)
                sd1+=uz[i][j];
            if (i+j==4)
                sd2+=uz[i][j];
        }
    for (int i=1;i<=3;i++)
        if (sl[i] == 3 || sc[i] == 3)
        {
            cout << "Yes\n";
            return 0;
        }
    if (sd1 == 3 || sd2 == 3)
    {
        cout << "Yes\n";
        return 0;
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
N, M = input().split(" ")
N = int(N)
M = int(M)
s_list = []
c_list = []
for i in range(M):
    si, ci = input().split(" ")
    s_list.append(int(si))
    c_list.append(int(ci))
num = ["0" for i in range(N)]
is_break = False
for si, ci in zip(s_list, c_list):
    if num[si-1] != "0" and num[si-1] != str(ci):
        print(-1)
        is_break = True
        break
    elif N > 1 and si == 1 and ci == 0:
        print(-1)
        is_break = True
        break
    else:
        num[si-1] = str(ci)
if not is_break:
    num = "".join([val for val in num])
    if int(num[0]) or N == 1:
        print(int(num))
    else:
        print(int("1" + num[1:]))

Measured memory_bytes: 3064
#include<stdio.h>
#define MAX 10000
#define NIL -1
struct Node{
int p, l, r;
};
struct Node T[MAX];
int n;
void preParse(int u){
if(u == NIL) return;
printf(" %d",u);
preParse(T[u].l);
preParse(T[u].r);
}
void inParse(int u){
if(u == NIL) return;
inParse(T[u].l);
printf(" %d",u);
inParse(T[u].r);
}
void postParse(int u){
if(u == NIL) return;
postParse(T[u].l);
postParse(T[u].r);
printf(" %d",u);
}
int main(){
int i, v, l, r, root;
scanf("%d", &n);
for(i = 0; i < n; i++){
T[i].p = NIL;
}
for(i = 0; i < n; i++){
scanf("%d %d %d", &v, &l, &r);
T[v].l = l;
T[v].r = r;
if(l != NIL) T[l].p = v;
if(r != NIL) T[r].p = v;
}
for(i = 0; i < n; i++) if(T[i].p == NIL) root = i;
printf("Preorder\n");
preParse(root);
printf("\n");
printf("Inorder\n");
inParse(root);
printf("\n");
printf("Postorder\n");
postParse(root);
printf("\n");
return 0;
}

Measured memory_bytes: 620
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{fastout, input, marker::Chars};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        t: Chars,
    }

    println!(
        "{}",
        t.iter()
            .map(|c| if *c == '?' { 'D' } else { *c })
            .collect::<String>()
    );
}


Measured memory_bytes: 3312
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;

int main() {
	int N,l,r,ans=0;
  cin >> N;
	REP(i,N){
		cin >> l >> r;
		ans+=abs(r-l)+1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N, T = map(int, input().split())
    t = list(map(int, input().split()))

    arr = [[]] * len(t)
    for i in range(len(t)):
        arr[i] = [t[i], t[i]+T]

    ans = arr[0][1]
    for i in range(len(t)-1):
        _, t1 = arr[i]
        f2, t2 = arr[i+1]

        if t1 <= f2:
            ans += t2 - f2
        else:
            ans += t2 - t1
    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  int L;
  L = A + B;
  int R;
  R = C + D; 
  
  if ( L > R ) {
    cout << "Left" << endl;
  } 
  
  else if ( L < R ) {
    cout << "Right" << endl;
  }
  
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI >     VVI;
typedef long long int     LL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n        //index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n     //index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)    //Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("../input.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
    // #endif
    srand(chrono::steady_clock::now().time_since_epoch().count());
    off;
    LL a,b,k;
    cin>>a>>b>>k;
    LL z = 0;
    LL diff = max(z, k-a);
    a = max(z, a-k);
    
    // cout<<diff<<"\n";
    b = max(z,b - diff);
    cout<<a<<" "<<b;

    return 0;
}

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

int main(){
    using namespace std;
    unsigned long N, M;
    cin >> N >> M;
    priority_queue<unsigned long> A;
    for(unsigned long i = 0, a; i < N; ++i){
        cin >> a;
        A.push(a);
    }
    for(unsigned long i = 0; i < M; ++i){
        auto t = A.top();
        A.pop();
        A.push(t / 2);
    }
    unsigned long ans{0};
    for(unsigned long i = 0; i < N; ++i){
        ans += A.top();
        A.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define pb push_back
#define pll pair<ll,ll> 
#define mll map<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0; i<n; i++)
#define All(x,v) for(auto x:v)
#define arrin(a,n) ll a[n]; rep(i,n) cin>>a[i]
#define vi vector<int>
#define nl "\n"
#define print(arr) All(x,arr) cout<<x<<" "; cout<<nl
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define ing(m,ad) rep(i,m){ int u,v; cin>>u>>v; u--;v--; ad[u].pb(v); ad[v].pb(u);}
#define vdsort(v) sort(v.begin(),v.end(),greater<int>())
#define F first
#define S second
#define mod 1000000007
const int MAXN=100005;
int spf[MAXN];
ll fac1[MAXN],fac2[MAXN],inv[MAXN];
ll gcd(ll x, ll y){ return y?gcd(y,x%y):x; }

void sieve(){  
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++)  spf[i] = i; 
    for (int i=4; i<MAXN; i+=2) spf[i] = 2; 
    for (int i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) 
            for (int j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j)  spf[j] = i; 
    } 
} 
vector<int> getFactorization(int x){
    vector<int> ret; 
    while (x != 1) { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
}

ll exp(ll n, ll m){
    ll a = 1;
    while (m){
        if (m & 1) a = (a * n % mod) % mod;
        m /= 2;
        n = (n*n) % mod;
    }
    return a;
}

void pre(){
    fac1[0]=fac2[0]=inv[1]=1;
    for(int i=1;i<MAXN;i++){
        fac1[i]=(fac1[i-1]*i)%mod;
        if(i>1) inv[i]=( mod - ((ll)(mod/i)*inv[mod%i])%mod ) %mod;
    }
    for(int i=1;i<MAXN;i++) fac2[i]=(fac2[i-1]*inv[i])%mod;
}
ll C(int n,int k){
    if(n<k) return 0;
    return ((fac1[n]*fac2[n-k]%mod)*fac2[k]%mod);
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    int n,t=1;
    // cin>>t;
    while(t--){
        cin>>n;
        ll ans=0;
        rep(i,n-1){
            ans+=(n-1)/(i+1);
        }
        cout<<ans<<nl;
    }
    return 0;
}

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


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    string s;
    int flag=0;
    cin>>s;
    sort(s.begin(), s.end());

    for(int i=0; i<n; i++)
    {
        if(s[i]!=s[i+1])
        {
            cout<<"No";
            flag=1;
            break;
        }
        else
            i+=1;
    }
    if(flag==0)
        cout<<"Yes";
    
}

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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  ll n; cin >> n;
  vector<ll> a(5);
  ll mi = LINF;
  for(int i=0;i<5;++i) {
    cin >> a[i];
    mi = min(mi, a[i]);
  }

  cout << 5 + (n-1)/mi << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H,W;
    cin >> H >> W;
    string s[30][30];
    rep(i,0,H){
        rep(j,0,W){
            cin >> s[i][j];
        }
    }
    rep(i,0,H){
        rep(j,0,W){
            if(s[i][j] == "snuke"){
                cout << (char)('A'+j) << i+1 << endl;
            }
        }
    }
}


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

class Main{
    static node[] t;
    public static void main(String[] args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final int n = Integer.parseInt(br.readLine());
        t = new node[n];
        for(int i = 0; i<n; i++)
            t[i] = new node();

        for(int i = 0; i<n; i++){
            final StringTokenizer st = new StringTokenizer(br.readLine(), " ");
            final int id = Integer.parseInt(st.nextToken());
            final int m = Integer.parseInt(st.nextToken());
            int c0 = id;
            for(int j = 0; j<m; j++){
                final int c = Integer.parseInt(st.nextToken());
                t[c].parent = id;
                if(j==0) t[id].child = c;
                else t[c0].sibling = c;
                c0 = c;
            }
        }
        int root = 0;
        while(t[root].parent!=-1)
            root = t[root].parent;
        setdepth(root, 0);
        final StringBuilder sb = new StringBuilder();
        for(int i = 0; i<n; i++){
            sb.append("node ").append(i);
            sb.append(": parent = ").append(t[i].parent);
            sb.append(", depth = ").append(t[i].depth);
            if(t[i].parent==-1) sb.append(", root, [");
            else if(t[i].child==-1) sb.append(", leaf, [");
            else sb.append(", internal node, [");
            final int c = t[i].child;
            if(c!=-1){
                sb.append(c);
                int ch = c;
                while(true){
                    ch = t[ch].sibling;
                    if(ch==-1) break;
                    sb.append(", ").append(ch);
                }
            }
            sb.append("]\n");
        }
        System.out.print(sb);
    }
    static void setdepth(int root, int d){
        int n = root;
        do{
            t[n].depth = d;
            if(t[n].child!=-1){
                setdepth(t[n].child, d+1);
            }
            n = t[n].sibling;
        }while(n!=-1);
    }
}

class node{
    int parent;
    int child;
    int sibling;
    int depth;
    node(){
        parent = -1;
        child = -1;
        sibling = -1;
        depth = -1;
    }
}

Measured memory_bytes: 93624
object Main extends App {
	val N = scala.io.StdIn.readLine.split(" ").map(_.toInt)

	if(N(0)%3 == 0 || N(1)%3 == 0 || (N(0) + N(1))%3 == 0){
		println("Possible")
	}else{
		println("Impossible")
	}
}



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

using namespace std;

int main()
{
    string s;
    int a,b,h=0,n=0,m=0;
    cin>>a>>b;
    cin>>s;
    int i=0;
    while(isdigit(s[i]))  n++,i++;
    if(n!=a){cout<<"No"<<endl; return 0;}
    while(s[i]=='-')  h++,i++;
    if(h!=1){cout<<"No"<<endl; return 0;}
    while(isdigit(s[i]))  m++,i++;
    if(b!=m){cout<<"No"<<endl; return 0;}

    cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int a,b;
  scanf("%d",&a);
  scanf("%d",&b);
  if(a+b>=a*b&&a+b>=a-b)
    printf("%d\n",a+b);
  else if(a*b>=a+b&&a*b>=a-b)
    printf("%d\n",a*b);
  else if(a-b>=a+b&&a-b>=a*b)
    printf("%d\n",a-b);
  return 0;
}  
    

Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
int check(int N,int p){
  if(p == 3) return N / 100;
  else if(p == 2) return (N / 10) % 10;
  else if(p == 1) return N % 10;
}

int main(void){
  int N,M;
  cin >> N >> M;
  
  vector<vector<int>>a(M,vector<int>(2));
  for(int i=0;i<M;i++){
    cin >> a[i][0];
    cin >> a[i][1];
  }
  
  int b = 1;
  int e = 0;
  if(N == 1){
    b = 0;
    e = 10;
  }
  else{
  for(int i=1;i<N;i++){
    b *= 10;
  }
  e = b * 10;
  }
  bool exist = false;
  
  for(int i=b;i<e;i++){
    bool c = true;
    for(int j=0;j<M;j++){
      if(check(i,N + 1 - a[j][0]) != a[j][1]) c = false;
    }
    if(c){
      cout << i << endl;
      exist = true;
      break;
    }
  }
  
  if(!exist) cout << -1 << endl;
  
  return 0;
}

  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
int main() {
    string s, t;
    cin >> s >> t;

    bool ok = true;
    auto n = s.size();
    map<char, char> m1, m2;

    for (size_t i = 0; i < n; ++i) {
        if (m1[s[i]] == 0) {
            m1[s[i]] = t[i];
        } else {
            if (m1[s[i]] != t[i]) {
                //cerr << i << endl;
                ok = false;
                break;
            }
        }
        if (m2[t[i]] == 0) {
            m2[t[i]] = s[i];
        } else {
            if (m2[t[i]] != s[i]) {
                //cerr << i << endl;
                ok = false;
                break;
            }
        }
    }

    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 776
n, k = map(int, input().split())
a = list(map(int, input().split()))

if k == n:
	print(1)
elif 2 * k > n:
	print(2)
else:
	one_index = a.index(1)

	if one_index == 0 or one_index == n - 1:
		print((n - 2) // (k - 1) + 1)
	elif one_index <= k - 1 or n - one_index - 1 <= k - 1:
		print((n - 2) // (k - 1) + 1)
	else:
		print(min((one_index - 1) // (k - 1) + (n - one_index - 2) // (k - 1) + 2, (n - 2) // (k - 1) + 1))


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

const int maxn = 3e3+10;

using namespace std;

int dp[maxn][maxn];

pair<int,int> nextt[maxn][maxn];

char s1[maxn], s2[maxn];

string s, t;

int solve(int n, int m){
    if(n==0 or m==0) return 0;
    if(dp[n][m] != -1) return dp[n][m];

    if(s1[n] == s2[m]){
        nextt[n][m] = {n-1, m-1};
        return dp[n][m] = 1 + solve(n-1, m-1);
    }
    int caso1 = solve(n-1, m), caso2 = solve(n, m-1);

    if(caso1 > caso2){
        nextt[n][m] = {n-1, m};
        return dp[n][m] = caso1;
    }
    else{
        nextt[n][m] = {n, m-1};
        return dp[n][m] = caso2;
    }
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    cin >> s >> t;

    int n = (int)s.size(), m = (int)t.size();

    for(int i=0; i<n; i++) s1[i+1] = s[i];
    for(int i=0; i<m; i++) s2[i+1] = t[i];

    memset(dp, -1, sizeof dp);

    solve(n, m);

    string ans;

    int i=n, j=m;

    while(i>0 or j>0){
        int x = nextt[i][j].first, y = nextt[i][j].second;
        if(dp[x][y] != dp[i][j] and dp[i][j]>0){
            if(x==y) ans += s2[j];
            else ans += s1[i];
        }
        i = x, j = y;
    }

    reverse(ans.begin(), ans.end());

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 106752
// Example program
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
  char a[100],b[100],c[100];
cin>>a>>b>>c;
char k='a';
int i=0,j=0,d=0;
while(true){
 if(i==strlen(a)+1 ){
  cout<<'A';
  break;
 }
if(j==strlen(b)+1 ){
  cout<<'B';
  break;
 }
 if(d==strlen(c)+1){
  cout<<'C';
  break;
 }
 if(k=='a'){
  k=a[i];
  i++;
 }
  if(k=='b'){
  k=b[j];
  j++;
 }
  if(k=='c'){
      
  k=c[d];
  d++;
 }
}
}


Measured memory_bytes: 256
def composite(d,n,s):
    for a in (2,3,5,7):
        p = False
        if pow(a,d,n) == 1:
            continue
        for i in range(s):
            if pow(a, 2**i * d, n) == n-1:
                p = True
                break
        if not p:
            return True
    return False

def is_prime(n):
    if n in (2,3,5,7):
        return True
    elif 0 in (n%2,n%3,n%5,n%7):
        return False
    else:
        d,s = n-1, 0
        while not d%2:
            d,s = d>>1,s+1
        return not composite(d,n,s)
r = []
n = int(input())
for i in range(n):
  n = int(input())
  if is_prime(n):
      if n not in r:
          r.append(n)

print(len(r))

Measured memory_bytes: 7780
def main():
    n = int(input())
    v = [int(i) for i in input().split()]
    v_even = v[::2]
    v_odd = v[1::2]
    from collections import Counter
    v_even_cnt = sorted(list(Counter(v_even).items()),key=lambda x:x[1],reverse=True)
    v_odd_cnt = sorted(list(Counter(v_odd).items()),key=lambda x:x[1],reverse=True)
    ans = 0
    if v_even_cnt[0][0] != v_odd_cnt[0][0]:
        ans = len(v_even) - v_even_cnt[0][1] + len(v_odd) - v_odd_cnt[0][1]
    else:
        if len(v_even_cnt) == 1:
            ans = len(v_even)
        else:
            ans1 = len(v_even) - v_even_cnt[0][1] + len(v_odd) - v_odd_cnt[1][1]
            ans2 = len(v_even) - v_even_cnt[1][1] + len(v_odd) - v_odd_cnt[0][1]
            ans = min(ans1,ans2)
    print(ans)
if __name__ == '__main__':
    main()

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

using namespace std;

#define LL long long
#define ULL unsigned LL
#define LD long double
#define debug(x) cerr << #x << " " << x << endl;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	LL x;
	cin>>x;
	LL w = 100;
	for(int i=0; i<=4000; i++) {
		if(w >= x) {
			cout<<i;
			return 0;
		}
		w+=(w/100);
	}
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*"lcm"   MIN*/                      int lcm(ll a,ll b){return a*b/gcd(a,b);}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int main(){
int a[3][3];
bool che[3][3];
for(int i=0;i<3;i++){
   for(int j=0;j<3;j++){
      cin >> a[i][j];
      che[i][j]=false;
   }
}
int n;
cin >> n;
for(int i=0;i<n;i++){
   int z;
   cin >> z;
   for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
         if(z==a[j][k])che[j][k]=true;
      }
   }
}
for(int j=0;j<3;j++){
   int yoko = 0,tate=0;
for(int i=0;i<3;i++){
  if(che[j][i])yoko++;
  if(che[i][j])tate++;  
  if(yoko==3||tate==3){cout<<"Yes"<<endl;return 0;}
}
}
if(che[0][0]&&che[1][1]&&che[2][2]){cout<<"Yes"<<endl;return 0;}
else if(che[0][2]&&che[1][1]&&che[2][0]){cout<<"Yes"<<endl;return 0;}
else {cout<<"No"<<endl;return 0;}
}





Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int n,k,x,y;int total=0;
	scanf("%d%d%d%d",&n,&k,&x,&y);
	if(n<=k)
	{
		total=total+n*x;
	}
	if(n>k)
	{
		total=total+x*k+(n-k)*y;
	}
	printf("%d",total);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
    int A[3][3],N;
    int b[100];
    int x,y;
    int i;
    int ret = 0;
    for( i = 0 ; i < 3 ; i++){
        scanf("%d %d %d",&(A[0][i]),&(A[1][i]),&(A[2][i]));
    }
    scanf("%d",&N);
    for(i = 0 ; i < N ; i++){
        scanf("%d",&(b[i]));
        //穴をあける(-1にする)
        for( y = 0 ; y < 3 ; y++){
            for( x = 0 ; x < 3 ; x++){
                if(A[x][y] == b[i]){
                    A[x][y] = -1;
                    break;
                }
            }
        }
    }
    //縦横方向チェック
    for(i = 0 ; i < 3 ; i++){
        if(A[0][i] + A[1][i] + A[2][i] == -3) ret++;
        if(A[i][0] + A[i][1] + A[i][2] == -3) ret++;
    }
    //斜めチェック
    if(A[0][0] + A[1][1] + A[2][2] == -3) ret++;
    if(A[2][0] + A[1][1] + A[0][2] == -3) ret++;
    if(ret > 0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 1644
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+5;

vector<int> g[N];

int main(){
    int n;
    cin>>n;
    vector<pair<int,int>> vp;
    for(int i = 0; i < n-1; i++){
        int a,b;cin>>a>>b;
        a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
        vp.push_back({a,b});
    }

    map<pair<int,int>,int> mp;
    vector<int> vis(n);
    vis[0]=1;
    queue<int> q;
    q.push(0);
    int k = 0;
    vector<int> pr(n);
    while(!q.empty()){
        int u = q.front();q.pop();
        if((int)g[u].size()>k) k = (int)g[u].size();
        
        int cur = 1;
        for(int v : g[u]){
            if(vis[v]) continue;
            if(pr[u] == cur) cur++;
            pr[v] = mp[{u,v}]=mp[{v,u}] = cur++;
            vis[v] = 1;
            q.push(v);
        }
    }

    cout<<k<<endl;
    for(auto p : vp) cout<<mp[p]<<endl;
}


Measured memory_bytes: 20084
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
struct Integer{
public:
    ll gcd(ll a,ll b){return b ? gcd(b, a % b) : a;}
    ll lcm(ll a,ll b){return a / gcd(a, b) * b;}

    bool isPrime(ll x){
        if(x < 2) return false;
        if(x == 2) return true;
        if(x % 2 == 0) return false;
        for(ll i = 3;i <= sqrt(x) + 1;i += 2) if(x % i == 0) return false;
        return true;
    }

    vector<ll> divisor(ll M){
        vector<ll> dd;
        for(ll i = 1; i * i <= M; i++){
            if(M % i == 0){
                dd.push_back(i);
                if(i * i != M) dd.push_back(M / i);
            }
        }
        sort(dd.begin(), dd.end());
        return dd;
    }

    vector<ll> factor(ll M){ //素因数分解
        vector<ll> dd;
        if(M == 1){
            dd.push_back(1);
            return dd;
        }
        for(ll i = 2; i*i <= M; i++){
            while(M % i == 0){
                dd.push_back(i);
                M /= i;
            }
        }
        if(M != 1) dd.push_back(M);
        sort(dd.begin(), dd.end());
        return dd;
    }
};
vector<ll> sieve(ll n){ //エラトステネス
    vector<bool> is_prime(n+1);
    vector<ll> prime;
    rep(i,0,n+1) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    rep(i,2,n+1){
        if(is_prime[i]){
            prime.push_back(i);
            for(int j = 2 * i; j <= n; j += i) is_prime[j] = false;
        }
    }
    return prime;
    rep(i,0,(1<<60)){
        print(i);
    }
}

void solve(){
    ll N;
    cin >> N;
    Integer it;
    ll ans = 0;
    rep(i,1,N+1){
        ll v = N / i;
        ans += i * v * (v+1) / 2;
    }
    print(ans);


    

    

}

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

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

int main()
{
    int num,sum =0;
    int weight[110]={};
    cin >> num;
    for(int i=1;i<=num;i++){
        cin >> weight[i];
        sum += weight[i];
    }
    int ans = 999999999;
    int current = 0;
    int check;
    for(int i=1;i<num;i++){
        sum -= weight[i];
        current += weight[i];
        check = sum - current;
        if(check<0){
            check *= (-1);
        }
        if(check<ans){
            ans = check;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
#include <stdio.h>

int main() {
    char str[19];
    scanf("%s", str);

    for(int i = 0; i < 19; i++) {
        if(str[i] == ',') {
            printf(" ");
        } else {
            printf("%c", str[i]);
        }
    }

    return 0;
}

Measured memory_bytes: 1660
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e9+1;

int main()
{
    string s;
    cin >> s;
    ll cnt=0;
    rep(i,3){
        if(s[i]=='o') cnt++;
    }
    cout << cnt*100+700 << endl;
    return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long int
#define f(a,b) for(int i = a;i<=b;i++)
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    int sum = a+b;
    cout << (a % 3 == 0 || b % 3 == 0 || sum % 3 == 0 ? "Possible" : "Impossible") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

void solve(int n, int m, int a) {
	priority_queue<tuple<int, int, int>> que;
	while (m--) {
		int h, p, q;
		cin >> h >> p >> q;
		que.push(make_tuple(h, p, q));
		que.push(make_tuple(h, q, p));
	}
	int nowLine = a, nowHigh = INF;
	while (!que.empty()) {
		int h, p, q;
		tie(h, p, q) = que.top(); que.pop();
		if (h >= nowHigh) continue;
		if (p != nowLine) continue;
		nowHigh = h;
		nowLine = q;
	}
	cout << nowLine << endl;
}

int main(void) {
	int a, b, c, x, y, z, n, m;
	string s;
	while (cin >> n >> m >> a) {
		if (n == 0 && m == 0 && a == 0) break;
		solve(n, m, a);
		//break;
	}
}

Measured memory_bytes: 3108
//abc096.cpp
//Sat May  5 20:52:07 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int a;
	int b;
	cin >> a;
	cin >> b;

	int ans = a-1;
	if (b>=a){
		ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
//int x=1;
//string yn[2] = { "Yes","No" };
//int x=1;
//string yn[2] = { "YES","NO" };
// string alp="abcdefghijklmnopqrstuvwxyz";
// string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//総和
/*
int t_sum(int x) {
int sum = 0;
while (x > 0) {
sum += x % 10;
x = x / 10;
}
return sum;
}
*/
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <regex>
#include <stack>
#include <queue>
#include <vector>
#include <iomanip>
#define MAX_N 100
#define INF 10000000

using namespace std;

string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

long n,a,b,c;
string s,t;

void solve(){
	string ans;
	int x=0;
	if (s[0] != '1') ans = s[0];
	else {
		while (s[x] == '1') {
			x++;
		}
		if (x >= b) ans = '1';
		else ans = s[x];
	}
	cout << ans << endl;
}

int main() {
	cin >> s>>b;
	solve();
	return 0;
}

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

int main() {
    string str;
    cin >> str;
    map<char, int> m;
    for(int i=0; i<str.size(); ++i) {
        m[str[i]] += 1;
    }
    cout << (all_of(m.begin(), m.end(), [](auto const& x) { return x.second%2 == 0; }) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define max(p,q)((p)>(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)

long vv[1<<20],ww[1<<20];
int idx[1<<20];
int cnt;
int c(const void*p,const void*q){
	if(ww[*(int*)p]<ww[*(int*)q])return -1;
	if(ww[*(int*)p]>ww[*(int*)q])return  1;
	if(vv[*(int*)p]>vv[*(int*)q])return -1;
	return 1;
}

int bs(long x){
	//ww[idx[i]]<=xとなるi
	int l=0,r=cnt;
	while(r-l>1){
		int m=(l+r)/2;
		if(ww[idx[m]]<=x)l=m;
		else r=m;
	}
	return l;
}

long v[50],w[50];
int main(){
	long n,m;
	scanf("%ld%ld",&n,&m);
	for(int i=0;i<n;i++)scanf("%ld%ld",v+i,w+i);
	int N=n-n/2;
	n/=2;
	for(int i=0;i<1<<n;i++){
		idx[i]=i;
		for(int k=0;k<n;k++)if(bit(i,k)){
			vv[i]+=v[k];
			ww[i]+=w[k];
		}
	}
	qsort(idx,1<<n,sizeof(int),c);
	cnt=1;
	long cv=vv[idx[0]];
	for(int i=1;i<1<<n;i++){
		if(vv[idx[i]]>cv){
			cv=vv[idx[i]];
			idx[cnt++]=idx[i];
		}
	}
	
//	for(int i=0;i<cnt;i++)printf("%ld %ld\n",ww[idx[i]],vv[idx[i]]);
	
	long ans=0;
	for(int i=0;i<1<<N;i++){
		long vsum=0,wsum=0;
		for(int k=0;k<N;k++)if(bit(i,k)){
			vsum+=v[n+k];
			wsum+=w[n+k];
		}
		if(wsum<=m){
			int j=bs(m-wsum);
			ans=max(ans,vsum+vv[idx[j]]);
		}
	}
	printf("%ld\n",ans);
}


Measured memory_bytes: 26176
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

int minv = 0x3f3f3f3f;
int maxv = -0x3f3f3f3f;

int n = 0;
int a[100];

vector<pair<int, int> > vec;

void solvez() {
    for (int i = 2; i <= n; i++) {
        if (a[i] < a[i-1]) {
            int in = max_element(a+1, a+i)-a;
            vec.push_back(make_pair(in, i));
            a[i] += a[in];
        }
    }
}

void solvef() {
    for (int i = n-1; i >= 1; i--) {
        if (a[i] > a[i+1]) {
            int in = min_element(a+i+1, a+n+1)-a;
            vec.push_back(make_pair(in, i));
            a[i] += a[in];
        }
    }
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        if (a[i] > maxv) maxv = a[i];
        if (a[i] < minv) minv = a[i];
    }
    if (minv >= 0) solvez();
    else if (maxv <= 0) solvef();
    else if (-minv > maxv) {
        int in = min_element(a+1, a+n+1)-a;
        for (int i = 1; i <= n; i++) {
            if (i != in) {
                vec.push_back(make_pair(in, i));
                a[i] += a[in];
            }
        }
        solvef();
    } else {
        int in = max_element(a+1, a+n+1)-a;
        for (int i = 1; i <= n; i++) {
            if (i != in) {
                vec.push_back(make_pair(in, i));
                a[i] += a[in];
            }
        }
        solvez();
    }
    printf("%d\n", vec.size());
    for (int i = 0; i < vec.size(); i++) printf("%d %d\n", vec[i].first, vec[i].second);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
set<string> ans;
bool used['z'+1];
string s,cp;
int n;

void dfs(int x,string t){
  cp=t;
  memset(used,0,sizeof(used));
  for(int i=0;i<x;i++)
    if(cp[i]!='a'&&!used[cp[i]])used[cp[i]]=true,cp[i]--;
  if(x==n){
    if(cp==s)ans.insert(t);
    return;
  }else if(cp!=s.substr(0,x))return;
  dfs(x+1,t+s[x]);
  if(s[x]!='z')dfs(x+1,t+(char)(s[x]+1));
}

int main(){
  while(1){
    cin>>s;
    if(s=="#")break;
    n=s.size();
    dfs(0,"");
    set<string>::iterator ite;
    int len=ans.size(),cnt=0;
    cout<<len<<endl;
    for(ite=ans.begin();ite!=ans.end();ite++,cnt++)
      if(cnt<=4||cnt+5>=len)cout<<(*ite)<<endl;
    ans.clear();
  }
  return 0;
}

Measured memory_bytes: 3176
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int A, B;

  scanf("%d %d\n",&A, &B );

  if((A+B) % 2 ==0 ){
    printf("%d\n", (A+B)/2);
  }else{
    printf("IMPOSSIBLE");
  }
  return 0;
}


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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007

int main()
{ FAST
    int a, b;
    cin >> a >> b;
    int cnt = 1;
    for(int i = 1; i <= 1005; i++){
        if(floor(cnt* 0.08) == a && floor(cnt*0.1) == b){
            cout << i;
            return 0;
        }
        cnt++;
    }
    cout << -1 << endl;
    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define F first
#define S second
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

    ll n,k;
    cin>>n>>k;
    vector<ll>h(n);
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    sort(all(h));

    for(int i=0;i<min(n,k);i++)
    {
        h[n-1-i] = 0;
    }

    ll sum = 0;
    for(int i=0;i<n;i++)
    {
        sum += h[i];
    }
    cout<<sum,nl;

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[2*n];
	for(int i=0;i<2*n;i++){
		cin>>a[i];
	}
	sort(a,a+2*n);
	int ans=0;
	for(int i=0;i<2*n;i+=2){
		ans+=a[i];
	}
	cout<<ans;
	cout<<endl;
}

Measured memory_bytes: 256