akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

const int MN = 100010;

vi g[MN];
int par[MN];
int in[MN];

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

	int num = N - 1 + M;

	rep(i, num) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		g[a].pb(b);
		++in[b];
	}

	queue<int> que;

	rep(i, N) {
		if (in[i] == 0) {
			que.push(i);
		}
	}

	memset(par, -1, sizeof(par));

	while (!que.empty()) {
		int v = que.front(); que.pop();
		for (int to : g[v]) {
			if (--in[to] == 0) {
				par[to] = v;
				que.push(to);
			}
		}
	}

	rep(i, N) {
		cout << par[i] + 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;

int main() {
    int A,B;
    cin >> A >> B;
    if (A+B>=10) {
        cout << "error" << endl;
    }
    else {
        cout << A+B << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define vll vector <ll>
#define all(v) v.begin(),v.end()

ll M = 1e9 + 7;
double pi = acos(-1.0);
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll max3(ll a,ll b,ll c){ return max( max(a,b),c ); }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}
string s,t;
int dp[3005][3005];

void lcs()
{
    int l1 = s.length(), l2 = t.length();
    forn(i,l1+1)
    {
        forn(j,l2+1)
        {
            if(i==0||j==0) dp[i][j] = 0;
            else if(s[i-1]==t[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
            else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }
}

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	cin>>s>>t; 
	int l1 = s.length(), l2 = t.length();
    lcs();
    string ans = "";
    while(l1>0&&l2>0)
    {
        if(s[l1-1]==t[l2-1])
        {
            ans += s[l1-1];
            l1--; l2--;
        }
        else if(dp[l1-1][l2]>dp[l1][l2-1]) l1--;
        else l2--;
    }	
    reverse(all(ans));
    cout<<ans;
	return 0;
}


Measured memory_bytes: 35456
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	cout << ((n - m) * 100 + m * 1900) * (int)pow(2, m) << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define MOD7 1000000007
#define LL_INF 1LL << 60
#define LL_MINF -1LL << 60
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const long double PI = (acos(-1));

int main(){
    string s;
    getline(cin,s);
    for(char &c : s){
        if('a' <= c and c <= 'z') c = toupper(c);
        else if('A' <= c and c <= 'Z') c = tolower(c);
    }
    cout << s <<  endl;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[N][N] = {};
int color[N], d[N], f[N], tt;

void dfs_visit(int u) {
    color[u] = GRAY;
    d[u] = ++tt;
    for (int v = 0; v < n; v++) {
        if (M[u][v] == 0) continue;
        if (color[v] == WHITE) {
            dfs_visit(v);
        }
    }
    color[u] = BLACK;
    f[u] = ++tt;
}

void dfs() {
    for (int u = 0; u < n; u++) color[u] = WHITE;
    tt = 0;
    for (int u = 0; u < n; u++) {
        if (color[u] == WHITE) dfs_visit(u);
    }
    for (int u = 0; u < n; u++) {
        printf("%d %d %d\n", u+1, d[u], f[u]);
    }
}

int main() {
    int u, v, k;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }
    dfs();
}




Measured memory_bytes: 3148
class lheapq:
    def __init__(self, p):
        self.l = []
        if p:
            for sp in p:
                self.heappush(sp)

    def heappush(self, a):
        n = len(self.l)
        self.l.append(a)
        t = n
        while t != 0:
            if self.l[t][1] < self.l[(t - 1) // 2][1]:
                self.l[t], self.l[(t - 1) // 2] = self.l[(t - 1) // 2], self.l[t]
                t = (t - 1) // 2
            else:
                break

    def heappop(self):
        n = len(self.l)
        if n == 0:
            return [-1, 0]
        if n == 1:
            return self.l.pop()
        ret = self.l[0]
        self.l[0] = self.l.pop()
        n -= 1
        t = 0
        while t < n:
            child1 = t * 2 + 1
            child2 = t * 2 + 2
            if child1 >= n:
                break
            elif child2 >= n:
                if self.l[t][1] > self.l[child1][1]:
                    self.l[t], self.l[child1] = self.l[child1], self.l[t]
                    t = child1
                else:
                    break
            else:
                if self.l[child2][1] < self.l[child1][1]:
                    child1, child2 = child2, child1
                if self.l[t][1] > self.l[child1][1]:
                    self.l[t], self.l[child1] = self.l[child1], self.l[t]
                    t = child1
                elif self.l[t][1] > self.l[child2][1]:
                    self.l[t], self.l[child2] = self.l[child2], self.l[t]
                    t = child2
                else:
                    break
        return ret

    def isnotblank(self):
        if self.l:
            return True
        else:
            return False


def dijkstra(g, n):
    # グラフgの点0から点n-1までの最短距離を求める。
    # グラフは隣接行列で[[[目的地、辺の重み],[目的地、辺の重み]],[],...]

    f = [-1 for _ in range(n)]

    s = 0
    f[0] = 0
    q = lheapq(g[0])
    while True:
        kakutei = q.heappop()
        if kakutei[0] == -1:
            return f
        while f[kakutei[0]] != -1:
            kakutei = q.heappop()
            if kakutei[0] == -1:
                return f
        s = kakutei[0]
        f[s] = kakutei[1]
        for sg, sl in g[s]:
            if f[sg] == -1:
                q.heappush([sg, sl + f[s]])


n, m = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(n - 1):
    g[i + 1].append([i, 0])
for i in range(m):
    a, b, l = map(int, input().split())
    g[a - 1].append([b - 1, l])

print(dijkstra(g, n)[-1])


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

P f(int x) {
  int a = x%10;
  int b = 0;
  while (x) {
    b = x;
    x /= 10;
  }
  return P(a,b);
}

int main() {
  int n;
  cin >> n;
  map<P,int> freq;
  for (int i = 1; i <= n; ++i) {
    P p = f(i);
    freq[p]++;
  }
  ll ans = 0;
  for (int i = 1; i <= n; ++i) {
    P p = f(i);
    P q(p.second, p.first);
    ans += freq[q];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3592
// 未解決

#include <bits/stdc++.h>

#include <iostream>
using namespace std;

#define EACH(i, a) for (auto &&i : a)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RFOR(i, a, b) for (int i = (int)b - 1; i >= (int)a; --i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREPS(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(x) (x).begin(), (x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define debug(x) cout << #x << ": " << x << endl

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF (1L << 30)
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

template <class T>
void pv(T a, T b) {
  for (T i = a; i != b; ++i) cout << *i << " ";
  cout << endl;
}
template <class T>
void pvp(T a, T b) {
  for (T i = a; i != b; ++i)
    cout << "(" << i->first << ", " << i->second << ") ";
  cout << endl;
}
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 in() {
  int x;
  scanf("%d", &x);
  return x;
}

using ll = long long;
#define int ll

//***** basic func *****//
int power_mod(int a, int b) {
  // return (a**b)%MOD (O(log b))
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res *= a;
      res %= MOD;
    }
    a *= a;
    a %= MOD;
    b >>= 1;
  }
  return res;
}

int fact[510000], fact_inv[510000];  // n!, (n!)^-1 mod MOD

int comb_mod(int n, int r) {
  return ((fact[n] * fact_inv[r]) % MOD * fact_inv[n - r] % MOD);
}

//**********

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

  int n, k;
  int a[100010];
  cin >> n >> k;
  REP(i, n) { cin >> a[i]; }

  int ans = 0;

  // calc fact
  fact[0] = 1;
  REP(i, n) { fact[i + 1] = fact[i] * (i + 1) % MOD; }
  fact_inv[n] = power_mod(fact[n], MOD - 2);
  RREP(i, n) { fact_inv[i] = fact_inv[i + 1] * (i + 1) % MOD; }

  if (k > 1) {
    sort(a, a + n);

    int sum[100010];
    int sumr[100010];

    sum[0] = a[0];
    sumr[0] = a[n - 1];

    REP(i, n - 1) {
      sum[i + 1] = sum[i] + a[i + 1];
      sum[i + 1] %= MOD;
      sumr[i + 1] = sumr[i] + a[n - 1 - (i + 1)];
      sumr[i + 1] %= MOD;
    }

    REP(i, n - k + 1) {
      // debug(i);
      // debug(nck[i]);
      ans += (sumr[n - k - i] - sum[n - k - i]) * comb_mod(k - 2 + i, k - 2);
      ans %= MOD;
    }
  }
  cout << ans << endl;

  return 0;
};


Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
int main(){
   int n;
   cin >> n;
   vector<int> p(n);
   for(int i = 0;i<n;i++){
       cin >> p.at(i);
   }
   int res = -2000000000;
   int m = p.at(0);
   for(int i = 1; i < n; i++){
       res = max(res, p.at(i) - m);
       m = min(m,p.at(i));
   }

   cout << res << endl;
}




Measured memory_bytes: 3620
import java.util.*;
import java.io.*;

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

		String line = br.readLine();
		int N = Integer.parseInt(line.substring(0,line.indexOf(" ")));
		int W = Integer.parseInt(line.substring(line.indexOf(" ")+1));
		int[] v = new int[N+1];
		int[] w = new int[N+1];

		for (int i=1; i<N+1; i++) {
			line = br.readLine();
			v[i] = Integer.parseInt(line.substring(0,line.indexOf(" ")));
			w[i] = Integer.parseInt(line.substring(line.indexOf(" ")+1));
		}

		int[][] dp = new int[N+1][W+1];

		for (int i=1; i<N+1; i++) {
			for (int j=1; j<W+1; j++) {
				if (j - w[i] >= 0)
					dp[i][j] = Math.max(dp[i-1][j-w[i]]+v[i],dp[i-1][j]);
				else
					dp[i][j] = dp[i-1][j];
			}
		}

		System.out.println(dp[N][W]);

		br.close();
	}
}

Measured memory_bytes: 24268
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int a[] = {1,3,1,2,1,2,1,1,2,1,2,1};
    int x,y; cin >> x >> y;
    Yn(a[x-1]==a[y-1]);

    return 0;
}

Measured memory_bytes: 256
n=int(input())

max_num=1000000000000001
cnt=0
i=1
while True:
    next_cnt=cnt+26**i
    if n<=next_cnt:
        break
    i+=1
    cnt=next_cnt
index=n-cnt
ans=""
for j in range(i):
    k=0
    while True:
        if (26**(i-j-1))*k+1<=index<=(26**(i-j-1))*(k+1):
            ans+=chr(k+97)
            index-=(26**(i-j-1))*k
            #print(index,k)
            break
        k+=1

print(ans)

Measured memory_bytes: 61960
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <functional>
using namespace std;

int a, b, c, d;

int main() {
	cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
const ll INF = 9e18;

void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
    int size = sizeof...(Tail);
    cout << head;
    if (size > 0) {
        cout << " ";
    }
    print(tail...);
}

int main() {
    ull X;
    cin >> X;
    ull v = 100;
    for (ll i = 0; i < 8000; i++) {
        v = v + (v / 100);
        if (v >= X) {
            print(i + 1);
            return 0;
        }
    }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main(){
    int n,m;
    cin >> n >> m;
    pair<int,int>p[100009];
    rep(i,n){
        cin >> p[i].first >> p[i].second;
    }
    int sum=0;
    int now=0;
    ll ans=0;
    sort(p,p+n);

    while(sum<m){
        ans+=p[now].first;
        p[now].second-=1;
        if(p[now].second==0)now++;
        sum++;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 4436
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

int main() {
 map<string,UL> S;
 UL Q; scanf("%u",&Q);
 rep(q,Q){
  UL c; scanf("%u",&c);
  if(c==0){
   char buf[21]; UL x; scanf("%s%u",buf,&x);
   S[buf]=x;
  }
  if(c==1){
   char buf[21]; scanf("%s",buf);
   auto f=S.find(buf);
   printf("%u\n",(f==S.end()) ? 0 : f->second);
  }
  if(c==2){
   char buf[21]; scanf("%s",buf);
   S.erase(buf);
  }
 }
 return 0;
}




Measured memory_bytes: 25948
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
ll n,t,x,y,m,q;

int main(){
      ios_base::sync_with_stdio(false); cin.tie(NULL);
      cin>>n;
      string s,s1;
      cin>>s>>s1;
      for(int i=0;i<n;i++){
      	cout<<s[i]<<s1[i];
      }
      
}

Measured memory_bytes: 3640
package main

import (
	"fmt"
)

func debug(x interface{}) {
	// pp.Print(x)
}

type light struct {
	switches []int
	count    int
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	lights := make([]*light, m)
	for i := range lights {
		var lightsSize int
		fmt.Scan(&lightsSize)
		l := new(light)
		l.switches = make([]int, lightsSize)
		for i := range l.switches {
			var v int
			fmt.Scan(&v)
			l.switches[i] = v
		}
		lights[i] = l
	}

	for _, l := range lights {
		var count int
		fmt.Scan(&count)
		l.count = count
	}
	fmt.Println(abc128c(n, &lights))
}

func abc128c(n int, lights *[]*light) int {
	var result int
	result = 0
	bits := 1 << uint(n)
BITS_LOOP:
	for bit := 0; bit < bits; bit++ {
		for _, l := range *lights {
			count := 0
			for _, s := range l.switches {
				if bit&(1<<uint(s-1)) > 0 {
					count++
				}
			}
			if (count & 1) != l.count {
				continue BITS_LOOP
			}
		}
		result++
	}
	return result
}


Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>

int main(){
  char we[3][7] = {"Sunny", "Cloudy", "Rainy"};
  char t[7]; scanf("%s",t);
  if (strcmp(t,we[0])==0) printf("%s\n",we[1]);
  if (strcmp(t,we[1])==0) printf("%s\n",we[2]);
  if (strcmp(t,we[2])==0) printf("%s\n",we[0]);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#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;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};



int main(){
    CIN(X);
    YES(X == 7 || X == 5 || X == 3);
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007


ll a, b, cou = 0, k;
string s;

int main() {
	cin >> a >> b >> k;
	REPR(i, 110000) {
		if (a % i == 0 and b % i == 0)cou++;
		if (k == cou) {
			cout << i << endl;
			return 0;
		}
	}
}


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

using namespace std;

class EdgeTable : public map<uint64_t, set<uint64_t>> {};

inline uint64_t match_node(uint64_t x, uint64_t y)
{
  return (min(x, y) << 10) + max(x, y);
}

static array<bool, 2000000> visited;
static array<bool, 2000000> finished;
static array<uint64_t, 2000000> cache;

const uint64_t NotFound = static_cast<uint64_t>(-1);

uint64_t search_dfs(uint64_t src, const EdgeTable &edges)
{
  uint64_t max_depth = 1;
  
  if (edges.find(src) == edges.end()) {
    goto END_OF_SEARCH_DFS;
  }
  
  for (auto &dst : edges.at(src)) {
    uint64_t ret = cache[dst];
    
    if (!visited[dst]) { 
      visited[dst] = true;
      
      ret = search_dfs(dst, edges);
    } else {
      if (!finished[dst]) {
        return NotFound;
      }
    }
    
    if (ret == NotFound) {
      return NotFound;
    }
    
    if (ret + 1 > max_depth) {
      max_depth = ret + 1;
    }
  }
  
  cache[src] = max_depth;
  
END_OF_SEARCH_DFS:
  finished[src] = true;
  
  return cache[src];
}

int main()
{
  uint64_t N;
  cin >> N;
  
  vector< vector<uint64_t> > A(N);
  for (uint64_t n = 0; n < N; ++n) {
    A[n] = vector<uint64_t>(N - 1);
    for (uint64_t m = 0; m < N - 1; ++m) {
      cin >> A[n][m];
      --A[n][m];
    }
  }
  
  EdgeTable edges;
  for (uint64_t n = 0; n < N; ++n) {
    for (uint64_t m = 0; m < N - 2; ++m) {
      edges[match_node(n, A[n][m])].insert(match_node(n, A[n][m + 1]));
    }
  }
  
  set<uint64_t> match_set;
  for (uint64_t n = 0; n < N; ++n) {
    for (uint64_t m = 0; m < n; ++m) {
      match_set.insert(match_node(n, m));
      
      cache[match_node(n, m)] = 1;
      visited[match_node(n, m)] = false;
      finished[match_node(n, m)] = false;
    }
  }
  
  uint64_t max_depth = 0;
  for (uint64_t start : match_set) {
    if (visited[start]) { continue; }
    
    visited[start] = true;
    
    uint64_t depth = search_dfs(start, edges);
    
    if (depth == NotFound) {
      cout << -1 << endl;
      return 0;
    }
    
    if (max_depth < depth) { max_depth = depth; }
  }
  
  cout << max_depth << endl;
  
  return 0;
}

Measured memory_bytes: 137600
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void){
	int n,k,i,ans = 1;
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++){
		if(2*ans > ans+k) ans += k;
		else ans *= 2;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

int main() {
	std::string str; std::cin >> str;
	int count = 0;
	for (auto i = 0; i < str.size() - i - 1; ++i) {
		if (str[i] != str[str.size() - i - 1]) {
			++count;
		}
	}
	std::cout << count << std::endl;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////


int main(){
	vector<ll> v(3);
	int k;
	
	cin >> v[0] >> v[1] >> v[2] >> k;

	vsort(v);
	
	rep(i,0,k) v[2]*=2;

	cout << v[0] + v[1] + v[2] << endl;

	ret 0;
}

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

int n;
double dp[512][512][512];
int vis[512][512][512];

double calc(int cnt1, int cnt2, int cnt3) {
    if(cnt1 < 0 or cnt2 < 0 or cnt3 < 0) return 0;
    if(!cnt1 and !cnt2 and !cnt3) return 0;
    double &y = dp[cnt1][cnt2][cnt3];
    if(vis[cnt1][cnt2][cnt3]) return y;
    vis[cnt1][cnt2][cnt3] = 1;
    int self = n - cnt1 - cnt2 - cnt3;
    double denominator = n - self;
    //(n-self/n) E = 1 + cnt1/n * calc(cnt1-1, cnt2, cnt3) + cnt2/n * calc(cnt1+1, cnt2-1, cnt3) + cnt3/n * calc(cnt1, cnt2+1, cnt3-1)
    return y=(n+cnt1 * calc(cnt1-1, cnt2, cnt3) + cnt2 * calc(cnt1+1, cnt2-1, cnt3) + cnt3 * calc(cnt1, cnt2+1, cnt3-1))/denominator;
}

int main() {
	cin >> n;
	map<int, int> m;
	for(int i=1; i<=n; ++i) {
	    int temp;
	    cin >> temp;
	    ++m[temp];
	}
	cout<<fixed<<setprecision(10)<<calc(m[1], m[2], m[3])<<endl;
	return 0;
}


Measured memory_bytes: 276724
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

var C [51][51]int // C[n][k] -> nCk

func combTable(N int) {
	for i := 1; i <= N; i++ {
		for j := 0; j <= N; j++ {
			if j == 0 || j == i {
				C[i][j] = 1
			} else {
				C[i][j] = C[i-1][j-1] + C[i-1][j]
			}
		}
	}
}

// 残念ながら、解説を写経しています（結構面倒）
func main() {
	sc.Split(bufio.ScanWords)

	N, A, B := getInt(), getInt(), getInt()
	combTable(N)
	v := make([]int, N)
	for i := 0; i < N; i++ {
		v[i] = getInt()
	}
	sort.Sort(sort.Reverse(sort.IntSlice(v)))

	sum := 0
	for i := 0; i < A; i++ {
		sum += v[i]
	}
	ave := float64(sum) / float64(A)
	fmt.Printf("%f\n", ave)

	a, apos := 0, 0
	for i := 0; i < N; i++ {
		if v[i] == v[A-1] {
			a++
			if i < A {
				apos++
			}
		}
	}

	cnt := 0
	if apos == A {
		for apos = A; apos <= B; apos++ {
			cnt += C[a][apos]
		}
	} else {
		cnt += C[a][apos]
	}

	out(cnt)
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


signed main(void) 
{
    ll n, k;
    cin >>n >>k;
    ll r = 0;
    vll h(n);
    rep(i, n) {
        cin >>h[i];
        if (h[i] >= k) r++;
    }
    mes(r);
    
   
}


Measured memory_bytes: 4056
#include <iostream>
#include <iomanip> 
#include <algorithm>
#include <deque>
#include <iterator>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
#include <string>
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

        using namespace std;

        int main() {
            int a, b, c;
            cin >> a >> b >> c;
            
            int ans = min(a*b, c);

            cout << ans << endl;
        }




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

char s[5010];
int D[10010],ans=0;
int f[5010][2][2];

inline void Add(int &x,const int &y){x=(x+y>=ha)?(x+y-ha):(x+y);}

void dp(int lim)
{
	int m=lim/2;
	memset(f,0,sizeof(f));
	f[0][0][0]=1;
	for(int i=0;i<m;i++)
		for(int j=0;j<2;j++)
			for(int k=0;k<2;k++)
				if(f[i][j][k]) for(int x=0;x<=9;x++)
				{
					int kl=x+D[i+1]+k,y=kl%10;kl/=10;
					int jl=j*10+x-y-D[lim-i];
					if(jl<0||jl>1) continue;
					if(!i&&(!x||!y)) continue;
					Add(f[i+1][jl][kl],f[i][j][k]);
				}
	if(lim&1)
	{
		int mid=(lim+1)/2;
		for(int j=0;j<2;j++)
			for(int k=0;k<2;k++)
				if(f[m][j][k]) for(int x=0;x<=9;x++)
				{
					int y=x+k+D[mid];
					if(x==y%10&&y/10==j)
						Add(ans,f[m][j][k]);
				}
	}
	else for(int j=0;j<2;j++) Add(ans,f[m][j][j]);
}

int main()
{
	scanf("%s",s+1);
	int len=strlen(s+1);
	reverse(s+1,s+1+len);
	for(int i=1;i<=len;i++)
		D[i]=s[i]-'0';
	for(int i=max(2,len);i<=2*len;i++) dp(i);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream> 
#include <climits>
 using namespace std;
int main() 
{ 
  long long int a,b,c,d;
  /*cin>>a>>b>>c>>d;

  long long int ans;

  if(b<0 and d>0 ){
   ans= b*c;
  }
  else if(d<0 and b>0){
    ans=d*a;
  }
  else if(b<0 and d<0){
    ans=a*c;
  }
  else{
    long long int op1=b*d;
    long long int op2=a*c;
    if(op1>op2)
      ans=op1;
    else
      ans=op2;
  }
  cout<<ans;
  */

  cin>>a>>b>>c>>d;
  long long int ans=LONG_MIN;
  if((a<=0&&b>=0)||(c<=0&&d>=0))ans=0;
  ans=max(max(max(a*c,a*d),max(b*c,b*d)),ans);
  cout<<ans<<'\n';

}

Measured memory_bytes: 3600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	    
		String x = "";
		try {
			while ((x = in.readLine()) != null) {
				String[] ab = x.split(" ");
				int a = Integer.parseInt(ab[0]);
				int b = Integer.parseInt(ab[1]);
				String str = String.valueOf(a + b);
				System.out.println(str.length());
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

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

bool vf(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) {
    return true;
  }
  else {
    return false;
  }
}

int main() {
  int A[3][3], i, j;
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
      std::cin >> A[i][j];
    }
  }
  
  int N;
  std::cin >> N;
  
  std::vector<int> B;
  for (i = 0; i < N; i++) {
    int C;
    std::cin >> C;
    B.push_back(C);
  }
  
  bool ans = false;
  if (vf(B, A[0][0]) && vf(B, A[0][1]) && vf(B, A[0][2])) ans = true;
  if (vf(B, A[1][0]) && vf(B, A[1][1]) && vf(B, A[1][2])) ans = true;
  if (vf(B, A[2][0]) && vf(B, A[2][1]) && vf(B, A[2][2])) ans = true;
  
  if (vf(B, A[0][0]) && vf(B, A[1][0]) && vf(B, A[2][0])) ans = true;
  if (vf(B, A[0][1]) && vf(B, A[1][1]) && vf(B, A[2][1])) ans = true;
  if (vf(B, A[0][2]) && vf(B, A[1][2]) && vf(B, A[2][2])) ans = true;
  
  if (vf(B, A[0][0]) && vf(B, A[1][1]) && vf(B, A[2][2])) ans = true;
  if (vf(B, A[0][2]) && vf(B, A[1][1]) && vf(B, A[2][0])) ans = true;
  
  if (ans) {
  	std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long n, sol, i;
void verif(long long x){
    if(x - 1 > n / x){
        sol += x - 1;
    }
}
int main(){
    cin>> n;
    for(i = 1; i <= n / i; i++){
        if(n % i == 0){
            verif(i);
            if(i != n / i){
                verif(n / i);
            }
        }
    }
    cout<< sol;
}


Measured memory_bytes: 256
from collections import deque,Counter
n=int(input())
abc="abcdefghijklmnopqrstuvwxyz"
arr=deque()
def dfs(string,cnt):
    if cnt==n+1:
        arr.append(string)
        return 0
    l=len(list(set(list(string))))
    for i in abc[:l+1]:
        dfs(string+i,cnt+1)

dfs("",1)
arr=sorted(list(arr))
for i in arr:
    print(i)

Measured memory_bytes: 13760
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

for h in range(1, 3501):
	for n in range(1, 3501):
		if 4*h*n-N*n-N*h == 0: continue
		w = N*h*n/(4*h*n-N*n-N*h)
		if w.is_integer() and 1 <= w:
			print(h, n, int(w))
			exit()


Measured memory_bytes: 61928
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n,num,sum=0;
	cin>>n>>num;
	pair<ll,ll> a[n];
	for(ll i=0;i<n;i++)
	{
		cin>>a[i].first>>a[i].second;
	}
	sort(a,a+n);
	for(ll i=0;i<n;i++)
	{
		if(num<=a[i].second)
		{
			sum+=(num * a[i].first);
			break;
		}
		else
		{
			sum+=(a[i].first*a[i].second);
			num-=a[i].second;
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1792
# https://atcoder.jp/contests/abc127/tasks/abc127_d

n, m = gets.split.map(&:to_i)
nums = gets.split.map(&:to_i).sort

ops = []

m.times do
  max_cards, cand_num = gets.split.map(&:to_i)
  ops << [max_cards, cand_num]
end

ops.sort_by! { |op| op[1] }
ops.reverse!

current_head = 0

ops.each do |op|
  times = 0
  max_cards, cand_num = op

  deletes = []
  adds = []
  # nums.each_with_index do |i, idx|
  current_head.upto(nums.size - 1) do |idx|
    break if times == max_cards
    break if nums[idx] > cand_num
    times += 1
    # if cand_num > nums[idx]
    nums[idx] = cand_num
    current_head += 1
      # nums.delete_at(idx)
    # end
  end
  deletes.each { |i| nums.delete_at(i)}
  nums.push(*adds)
end

# p nums
# puts nums.size
puts nums.inject(:+)

Measured memory_bytes: 20632
N,K = map(int,input().split())
A_list = [int(i) for i in input().split()]

# 自分自身の中で、転倒するような数 * N-1
# 最後の繰り返しは、転倒しないので別途計算
## これじゃダメで、転倒数はどんどん減少していくはず。

# 順序が関係するのは最初のブロックだけ
# あとは、繰り返しになる(繰り返し数が減っていく)

# まず、順序を含めた合算個数を調べる
count_with_seq = 0
deal = 0
for i in range(N) :
    ai = A_list[i]
    for k in range(i+1,N) :
        deal += 1
        ak = A_list[k]
        if (ai > ak) :
            # print(ai,ak)
            count_with_seq += 1

count_without_seq = 0
for ai in A_list :
    for ak in A_list :
        if (ai > ak) :
            count_without_seq += 1

# print(count_with_seq,count_without_seq)

# これらの塊の繰り返し数は、
# 初項：N回
# 初項以降 : sum(k) (1<=K<=n-1) 

total_count = count_with_seq * K
# print(total_count)
rep = (1 + (K-1)) * (K-1) // 2
total_count += count_without_seq * rep
# print(rep)
print(total_count % 1000000007)

Measured memory_bytes: 3188
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
//#include <random>
#include <map>
//#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <time.h>
//#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
//#include <type_traits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0LL);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
double pi = 3.141592653589793;
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }



int main() {
	int n;
	cin >> n;
	vector<ll> a(n), b, c;
	vector<int> z(100005);
	ll sum = 0;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
		z[a[i]]++;

	}

	int q;
	cin >> q;
	b.resize(q);
	c.resize(q);
	rep(i, q) {
		cin >> b[i] >> c[i];
	}

	rep(i, q) {
		ll cc = z[c[i]];
		ll bc = z[b[i]];

		z[c[i]] += z[b[i]];
		sum -= bc * b[i];
		sum += bc * c[i];
		cout << sum << endl;

		z[b[i]] = 0;
	}
}






Measured memory_bytes: 5896
x,y = map(int,input().split())



t = 222222
gap = y - x
a = 111111
if y - x > 2018:
    a =0
else:
    for i in range(x,y+1):
        for j in range(i+1,y+1):
            t = min(t,(i*j)%2019)

print(min(a,t))

Measured memory_bytes: 3060
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//222
	int a,b;
	cin>>a>>b;
	if(b<a)cout<<a-1;
	else cout<<a;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,int>;
const int MOD = 1000000007;

int main() {
    int x,a,b;
    cin>>x>>a>>b;
    cout<<(x-a)%b<<endl;
} 


Measured memory_bytes: 256
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll INF = 1e18;
ll n;
VV dp;
V vec;
V vec2;
ll dfs(ll l,ll r){
  //  cout<<l<<" "<<r<<endl;
    if (dp[l][r]!=-1)
        return dp[l][r];
    if (l == r)
        return dp[l][r] =0;
    ll Min = 1e18;
    rep3(i, l, r){
        chmin(Min, dfs(l, i) + dfs(i+1, r));
    }
    if(l==0){
        return dp[l][r] = vec2[r] + Min;
    }else{
        return dp[l][r] = vec2[r] - vec2[l -1] + Min;
    }
    
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    vec.resize(n);
    vec2.resize(n);
    dp.resize(n, V(n,-1));
    rep(i, n) cin >> vec[i];
    vec2[0] = vec[0];
    rep3(i,1, n) vec2[i] = vec2[i-1] + vec[i];
    cout << dfs(0, n - 1) << endl;
 //   cout<<dp[0][1]<<endl;
}


Measured memory_bytes: 1536
#include <cstdio>
#include <cassert>
#include <map>
#include <vector>
#include <cmath>
#include <set>
using namespace std;

typedef long long llong;

const llong MAX = pow(1e10, 1.0 / 3) + 10;
const int MAX2 = 1e5 + 10;

bool is_prime(int x) {
    for (int i = 2; i * i <= x; i++)
        if (x % i == 0)
            return false;
    return true;
}

vector<llong> prime_cubes;
vector<int> primes;
void build_primes() {
    for (int i = 2; i < MAX; i++) {
        if (is_prime(i))
            prime_cubes.push_back(1ll * i * i * i);
    }
    for (int i = 2; i < MAX2; i++) {
        if (is_prime(i))
            primes.push_back(i);
    }
}

llong norm(llong x) {
    for (llong q : prime_cubes) {
        if (q > x)
            break;
        while (x % q == 0)
            x /= q;
    }
    return x;
}

const llong inf = 1e12;

llong mul(llong a, llong b) {
    if (inf / b < a)
        return inf;
    else
        return a * b;
}

llong contr(llong x) {
    llong y = 1;
    for (int p : primes) {
        if (1ll * p * p > x)
            break;
        if (x % p == 0) {
            if (((x / p) % p) == 0)
                y = mul(y, p), x /= p, x /= p;
            else
                y = mul(y, mul(p, p)), x /= p;
        }
    }
    if (x != 1)
        y = mul(y, mul(x, x));
    return y;
}

int main() {
    int n;
    scanf("%d", &n);
    build_primes();
    map<llong, int> cnt;
    for (int i = 0; i < n; i++) {
        llong x;
        scanf("%lld", &x);
        x = norm(x);
        cnt[x]++;
    }
    int ans = 0;
    set<llong> used;
    for (auto pr : cnt) {
        llong x = pr.first;
        int c = pr.second;
        llong y = contr(x);
        if (used.count(x))
            continue;
        if (x == y) {
            assert(x == 1);
            ans += 1;
        } else {
            if (cnt.count(y)) {
                ans += max(c, cnt[y]);
                used.insert(y);
                used.insert(x);
            } else {
                used.insert(x);
                ans += c;
            }
        }
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 11264
n = int(input())
x = list(map(int,input().split()))

su = sum(x)//n

ans1 = 0
ans2 = 0
for i in range(n):
    ans1 += (x[i]-su)**2
for i in range(n):
    ans2 += (x[i]-su-1)**2

print(min(ans1,ans2))



Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    vector<string> s(h+2);
    string t(w+2,'.');
    s[0] = t;
    s[h+1] = t;
    for(int i = 1; i <= h; i++){
        cin>>s[i];
        s[i].insert(s[i].begin(),'.');
        s[i].push_back('.');
    }
    for(int i = 1; i <=h; i++){
        for(int j = 1; j <=w; j++){
            if(s[i][j]=='.'){
                int count=0;
                if(s[i-1][j-1]=='#')
                    count++;
                if(s[i-1][j]=='#')
                    count++;
                if(s[i-1][j+1]=='#')
                    count++;
                if(s[i][j-1]=='#')
                    count++;
                if(s[i][j+1]=='#')
                    count++;
                if(s[i+1][j-1]=='#')
                    count++;
                if(s[i+1][j]=='#')
                    count++;
                if(s[i+1][j+1]=='#')
                    count++;
                cout<<count;
            }
            else
                cout<<'#';
        }
        cout<<endl;
    }
}

Measured memory_bytes: 256
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        ((a)*((b)/gcd((a),(b))))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

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

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1e5+5;

vector<pii> v[N];
vi vis(N),val(N);

bool bfs(int start)
{
    queue<int> q;

    q.push(start);
    vis[start]=1;
    val[start]=0;

    int x,y,w;
    while(!q.empty())
    {
        x=q.front();
        q.pop();

        for(auto c:v[x])
        {
            y=c.F,w=c.S;

            if(vis[y])
            {
                if(val[x]+w!=val[y])
                    return 0;
            }
            else
            {
                vis[y]=1;
                val[y]=val[x]+w;
                q.push(y);
            }
        }
    }

    return 1;

}

void solve()
{
    int n,m;
    cin>>n>>m;

    int a,b,w;
    for(int i=0;i<m;++i)
    {
        cin>>a>>b>>w;
        v[a].pb({b,w});
        v[b].pb({a,-w});
    }

    for(int i=1;i<=n;++i)
    {
        if(!vis[i])
        {
            if(!bfs(i))
            {
                cout<<"No";
                return;
            }
        }
    }

//    for(int i=1;i<=n;++i)
//        cout<<val[i]<<" ";
//    cout<<"\n";

    cout<<"Yes";
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 14848