akhauriyash/Code-Regression huggingface dataset:
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int K, S;
	cin >> K >> S;

	int ans = 0;
	rep(i, 0, K + 1)rep(j, 0, K + 1)
	{
		if (i + j > S)continue;
		if (i + j + K >= S)
		{
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N,K;
    cin >> N >> K;
    VLL H(N);
    rep(i,N){
        cin >> H[i];
    }
    sort(all(H));
    ll ans=0;
    rep(i,H.size()-K){
        ans+=H[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>

using namespace std;

int main() {
  string o,e;
  cin >> o >> e;
  for(int i = 0; i < o.length(); i++) {
    cout << o[i];
    if(i == e.length()) break;
    cout << e[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;



int main() {
  int n;
  scanf("%d",&n);
  vi h(n);
  cin>>h;
  int ans = 0, x = 0;
  rep(i,n) {
    mins(x,h[i]);
    ans += h[i]-x;
    x = h[i];
  }
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int k = sc.nextInt();
        int s = sc.nextInt();

        sc.close();

        int ans = 0;

        for (int i = 0; i <= k; i++) {
            for (int j = 0; j <= k; j++) {
                int z = s - i - j;
                if (0 <= z && z <= k) {
                    ans++;
                }
            }
        }

        System.out.println(ans);

    }
}

Measured memory_bytes: 21844
parseInt(x) = parse(BigInt, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)


function main()
    N, X, M = parseMap(split(readline()))
    A = X
    loop = zeros(Int, M+2)
    seen = Set{Int}()
    loop_start = -1
    loop_length = 0
    ans = 0
    for i in 1:N
        #@show seen
        #@show A
        if (loop_start == -1) && !(in(A, seen))
            push!(seen, A)
            ans += A
        elseif (loop_start == -1) && in(A, seen)
            # @show A
            # @show i
            loop_start = A 
            loop_length = 1    
            loop[1] = loop_start
        end

        

        A = (A^2) % M

        if (loop_start != -1)
            if (loop_start == A)
                # @show A
                # @show i 
                k = (N - i) ÷ loop_length
                mo = (N - i) % loop_length
                # @show k
                # @show mo
                # @show loop[1:loop_length]
                # @show loop_length
                return ans + sum(loop) * (k + 1) + sum(loop[1:mo])   
            else
                loop_length += 1
                loop[loop_length] = A
            end
        end
    end
    return ans
end


println(main())

Measured memory_bytes: 272784
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main(){
  int N;
  cin >> N;
  map<char, int> m;
  vector<char> S(N);
  for(int i = 0; i < N; i++){
    cin >> S[i];
  }
  for(int i = 0; i < N; i++){
    m[S[i]]++;
  }
  if(m['Y'] > 0) cout << "Four";
  else cout << "Three";
}


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

A = list(map(int,input().split()))

lis = []

for i in range(N):
    lis.append ([A[i],i+1])

lis.sort()
ans = []

for i in range(N):
    ans.append(lis[i][1])

print (" ".join(map(str,ans)))


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

const int MOD = 1000000007;

int main() {
  int n, m;
  cin>>n>>m;
  int s[n], t[m];
  for (int i=0; i<n; i++) cin>>s[i];
  for (int i=0; i<m; i++) cin>>t[i];

  long long dp[n][m];
  dp[0][0] = s[0] == t[0];
  for (int i=1; i<n; i++) {
    dp[i][0] = dp[i-1][0] + (s[i] == t[0]);
  }
  for (int i=1; i<m; i++) {
    dp[0][i] = dp[0][i-1] + (t[i] == s[0]);
  }
  for (int i=1; i<n; i++) {
    for (int j=1; j<m; j++) {
      if (s[i] != t[j]) {
        dp[i][j] = (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1] + MOD) % MOD;
      } else {
        dp[i][j] = (dp[i-1][j] + dp[i][j-1] + 1) % MOD;
      }
    }
  }
  cout<<(dp[n-1][m-1] + 1) % MOD<<endl;
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

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

    vector<int> a(N);
    REP(i,N) cin >> a[i];
    sort(all(a));

    int ans = 0;
    REP(i,N){
        x -= a[i];
        if((i != N -1 && x < 0) || (i == N -1 && x != 0) ) break;
        ans++;
    }

    pl(ans)

    return 0;
}


Measured memory_bytes: 256
def main():
  h,n=map(int,input().split())
  dp=[10**9]*(h+1)
  dp[h]=0
  for i in range(n):
    a,b=map(int,input().split())
    for j in range(h,0,-1):
      nxt=j-a
      if nxt<0:
        nxt=0
      if dp[nxt]>dp[j]+b:
        dp[nxt]=dp[j]+b
  print(dp[0])
main()

Measured memory_bytes: 75296
#include <bits/stdc++.h>
#define int             long long
#define ld              long double
#define rep0(i,n)       for(int i=0;i<n;i++)
#define rep1(i,n)       for(int i=1;i<=n;i++)
#define rep(i,x,y)      for(int i=x;i<=y;i++)
#define reprev1(i,n)    for(int i=n;i>0;i--)
#define reprev0(i,n)    for(int i=n-1;i>=0;i--)
#define reprev(i,x,y)   for(int i=x;i>=y;i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x,y)         fixed<<setprecision(y)<<x
#define setbits(x)      __builtin_popcount(x)
#define zerobits(x)     __builtin_ctz(x)
#define in(a,n)         vi a(n);rep0(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);rep1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define endl            '\n'
#define mod             1000000007
#define M               (int)1e6+6
#define inf             1e18
using namespace std;

int n,m,k,x,y,z,a1,b,c,d,i,j;





void sol()
{   int a;
    cin>>a>>b;
    cout<<(a+b-3)/--a;
}





int32_t main(){

    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    // w(t)
    sol();
    return 0;
}



Measured memory_bytes: 256
from collections import deque

revFlag = False

s = deque(input())
q = int(input())

for i in range(q):
    a,b,c, *_ = input().split() + [None, None]
    
    if(a == '1'):
        revFlag = not revFlag
        
    else:
        b = int(b)
        if(revFlag):
            b = (int(b)%2)+1
        
        if(b == 1):
            s.appendleft(c)
        else:
            s.append(c)
            
    #print(_,*s, sep="")

if(revFlag):
    s.reverse()
    
print(*s, sep='')


Measured memory_bytes: 12272
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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 DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m, q; cin >> n >> m >> q;
    vvll s(n, vll(m));
    for (ll i = 0; i < n; i++) for (ll j = 0; j < m; j++) {
        char c; cin >> c;
        s[i][j] = c - '0';
    }

    vvll accs(n + 1, vll(m + 1, 0)), acche(n + 1, vll(m + 1, 0)), accve(n + 1, vll(m + 1, 0));
    for (ll i = 0; i < n; i++) {
        for (ll j = 0; j < m; j++) {
            accs[i + 1][j + 1] = accs[i + 1][j] + accs[i][j + 1] - accs[i][j] + s[i][j];
            accve[i + 1][j + 1] = accve[i + 1][j] + accve[i][j + 1] - accve[i][j];
            acche[i + 1][j + 1] = acche[i + 1][j] + acche[i][j + 1] - acche[i][j];
            if (i > 0 && s[i][j] && s[i - 1][j]) accve[i + 1][j + 1]++;
            if (j > 0 && s[i][j] && s[i][j - 1]) acche[i + 1][j + 1]++; 
        }
    }

    for (ll i = 0; i < q; i++) {
        ll x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        x1--, y1--;
        ll blue = accs[x2][y2] - accs[x1][y2] - accs[x2][y1] + accs[x1][y1];
        ll he = acche[x2][y2] - acche[x1][y2] - acche[x2][y1 + 1] + acche[x1][y1 + 1];
        ll ve = accve[x2][y2] - accve[x1 + 1][y2] - accve[x2][y1] + accve[x1 + 1][y1];
        cout << blue - he - ve << '\n';
    }
    return 0;
}


Measured memory_bytes: 127360
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
const int INF = (int)1e9 + 7;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << x << "\n";
//cin,coutより遅いので注意
template <class T = int>
void in() //in<string>();とか書く intのときはそのままin();
{
    T x;
    cin >> x;
    return (x);
}
template <class T>
void print(T &x) { cout << x << "\n"; }

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<int> l(N);
    REP(i, N)
    {
        cin >> l[i];
    }
    sort(ALL(l), greater<int>());

    int ans = 0;
    REP(i, K)
    {
        ans += l[i];
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1e9 + 7
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }


int main() {
  string a;
  int n;
  cin >> n;
  cin >> a;

  int co=0;
  for(int i = 0; i < n; i++){
      if(i < n-2 && a.at(i) == 'A' && a.at(i+1) == 'B' && a.at(i+2) == 'C'){
          co++;
      }
  }

  cout << co << endl;


  

    return 0;
}


Measured memory_bytes: 256
from collections import deque
from heapq import heapify, heappop, heappush
N = int(input())
edge = [[] for _ in range(N)]
ID = set([i for i in range(N-1)])
popular = [0 for _ in range(N)] #繋がっている頂点の数
#ID = set(ID)
for i in range(N-1):
  a,b = map(int,input().split())
  a-=1;b-=1 #0index
  edge[a].append(b) #相手方の点と道のIndexを保存
  edge[b].append(a)
  popular[a] += 1;popular[b] += 1
#print(edge)

Q = []
C = list(map(int,input().split()))
C.sort(reverse = True)
ans = sum(C) - max(C)
print(ans)
#for i in range(N):
#  temp,point = heappop(P)
#  heappush(Q,(C[i],point))
#print(Q)
#while Q:
#  X = heappop(Q)
#  print(X)
Q = deque([])
Q.append(0)
R = [-1 for _ in range(N)]
num = -1
v = 0
reach = set([])
while Q:
  v = Q.popleft() #頂点とID
  if v in reach:
    continue
  reach.add(v)
  num += 1
  #print(v,num)
  R[v] = C[num]
  for u in edge[v]:
    Q.append(u)

#print(ans)
print(*R)
    

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

#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

using ll = long long;
using P = pair<int, int>;

// 最大公約数を計算
ll gcd(ll a, ll b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}

int main() {
  int k;
  cin >> k;

  ll res = 0;
  for (int i = 1; i <= k; ++i) {
    for (int j = 1; j <= k; ++j) {
      for (int l = 1; l <= k; ++l) {
        ll tmp = gcd(i, j);
        tmp = gcd(tmp, l);
        res += tmp;
      }
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3636
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_088_A.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 N      PIC 9(5).
    01 A      PIC 9(4).
    01 X      PIC 9(3).
    01 R      PIC 9(3).
PROCEDURE                        DIVISION.
MAIN.
    ACCEPT N.
    ACCEPT A.

    DIVIDE 500 INTO N GIVING X REMAINDER R.

    IF R <= A THEN
        DISPLAY "Yes"
    ELSE
        DISPLAY "No"
    END-IF

    STOP RUN.


Measured memory_bytes: 764
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	string S;
	cin >> S;
	int l = 0, r = 0;
	rep(i, N) {
		if (S[i] == '(')
			++l;
		else if (l > 0)
			--l;
	}
	reverse(S.begin(), S.end());
	rep(i, N) {
		if (S[i] == ')')
			++r;
		else if (r > 0)
			--r;
	}
	reverse(S.begin(), S.end());
	cout << string(r, '(') << S << string(l, ')');
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(string N){
    ll ans = 0, a = 0;
    REP(i, N.length()){
        ans += N[i]-'0';
        if(i == 0){
            a += N[i]-'1';
        }
        else{
            a+= 9;
        }
    }
    cout << max(a, ans)<<endl;
}

int main(){
    string N; cin>>N;
    solve(N);
    return 0;
}


Measured memory_bytes: 256
/*
Original problem: https://atcoder.jp/contests/dp/tasks/dp_g
Author: sammochen
*/

#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)

#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef vector<ll> VLL;
typedef vector<int> VI;


namespace SOLVE {
    void main() {
        int v, e, a, b;
        cin >> v >> e;
        vector < VI > edges(v + 1);
        VI vin(v + 1);
        queue < int > topo; // find topological order
        
        VI dp(v + 1); // dp[i] stores the max length that ends at i

        REP(i, 0, e) {
            cin >> a >> b;
            edges[a].push_back(b);
            vin[b]++;
        }

        // look for all vertices that have no vout
        REP(i, 1, v + 1) {
            if (vin[i] == 0) {
                topo.push(i);
                dp[i] = 0;
            }
        }

        // finding topological order whilst creating the reversing topological order
        while (topo.size()) {
            int t = topo.front();
            topo.pop();

            // remove the top and remove all vertices outgoing from top
            for (int to: edges[t]) {
                dp[to] = max(dp[to], dp[t] + 1);

                vin[to]--;
                if (vin[to] == 0) {
                    topo.push(to); // to now has no incoming edges and is next in topo order
                }
            }
        }

        int ans = 0;
        REP(i, 1, v + 1) {
            ans = max(ans, dp[i]);
        }
        cout << ans << endl;
    }
}


signed main() {
	int t;
	t = 1;
	// cin >> t;
	while (t--) {
		SOLVE::main();
	}

	return 0;
}

Measured memory_bytes: 6528
#include <iostream>
using namespace std;
int v[101][101];
int node[101][2];
int t=1;
int n;
void dfs(int i){
   
    node[i][0]=t;
    t++;
    for(int i=1;i<=n;i++){
        v[i][1]=0;
    }
    for(int j=1;j<=n;j++){
        if(v[i][j]==1){
            for(int k=1;k<=n;k++){
                v[k][j]=0;
            }
            dfs(j);
        }
    }
    node[i][1]=t;
    t++;
}
int main(void){
    
    cin >> n;
    int x,y,z;
    for(int i=1;i<=n;i++){
        cin >> x>>y;
        for(int j=1;j<=y;j++){
            cin >> z;
            v[i][z]=1;
        }
    }
    dfs(1);
    
   for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(v[i][j]==1){
                dfs(i);
            }
        }
    }
    for(int i=1;i<=n;i++){
        cout <<i<< " " <<node[i][0]<<" " <<node[i][1]<<endl;
    }
   
    
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse -> greater<long long>()
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back
int main(){
   ll h,w;
   cin>>h>>w;
   LL ans=INFTY;
   rep(j,2){
      if(j==1)swap(h,w);
   rep(i,h){
      LL a=(i+1)*w;
      LL rest=h*w-a;
      LL v=h-(i+1);//残りの縦の長さ
      if(rest%2==0)chmin(ans,(LL)llabs(a-rest/2LL));
      else {
         LL r1=v/2*w;
         LL r2=rest-r1;
         LL r3=w/2*v;
         LL r4=rest-r3;
         LL mx1=max(r1,max(a,r2));
         LL mn1=min(r1,min(a,r2));
         LL mx2=max(r3,max(a,r4));
         LL mn2=min(r3,min(a,r4));
         chmin(ans,mx1-mn1);
         chmin(ans,mx2-mn2);
      }
   }
   }
   cout<<ans<<endl;

}

Measured memory_bytes: 3600
N, M = map(int, input().split())
P = [[] for i in range(N)]
data = []
for i in range(M):
    p, y = map(int, input().split())
    data.append([p, y, i])

data.sort(key=lambda x:x[1])
data.sort(key=lambda x:x[0])

city = 0
for i in range(M):
    if data[i][0] != city:
        city = data[i][0]
        num = 1
    data[i][1] = num
    num += 1
    

data.sort(key=lambda x:x[2])
for d in data:
    print("{:0=6}{:0=6}".format(d[0],d[1]))

Measured memory_bytes: 31620
#include <stdio.h>
int main()
{
	int A1, A2, A3;
	int Sum;
	scanf("%d %d %d", &A1, &A2, &A3);
	Sum = A1 + A2 + A3;
		if (Sum>=22)
		{
			printf("bust \n");
		}
		else if (Sum<22)
		{
			printf("win \n");
		}
	return 0;
}

Measured memory_bytes: 1600
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

using namespace std;


int main(){

    int n,m;
    int tmp;

    cin >> n >> m;

    priority_queue<int> pq;

    rep(i,n){
        cin >> tmp;
        pq.push(tmp);
    }

    rep(i,m){
        tmp = pq.top();
        pq.push(tmp / 2);
        pq.pop();
    }

    ll ans = 0;

    rep(i,n){
        ans += pq.top();
        pq.pop();
    }

    cout << ans << endl;

    return 0;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] p = new int[n];
		for (int i = 0; i < p.length; i++) {
			p[i] = sc.nextInt();
		}
		Arrays.sort(p);
		int sum = 0;
		for (int i = 0; i < k; i++) {
			sum += p[i];
		}
		System.out.println(sum);
		sc.close();
	}

}

Measured memory_bytes: 38936
#include<stdio.h>

int fibo(int);

int Fib[50];

int main(){
  int n,i;

  for( i = 0 ; i < 50 ; i++ ){
    Fib[i] = -1;
  }

  scanf("%d",&n);
  printf("%d\n",fibo(n));

  return 0;

}

int fibo(int n){
  if( n == 0 || n == 1 ) return Fib[n] = 1;
  if( Fib[n] >= 0 ) return Fib[n];
  return Fib[n] = fibo(n-1) + fibo(n-2);
}



Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
	int n,t;
	cin>>n>>t;
	int minn=1e9;
	int manx=0;
	for(int i=1;i<=n;++i)
	{
		cin>>a[i];
		minn=min(minn,a[i]);
		manx=max(manx,a[i]-minn);
	}
	int ans=0;
	minn=1e9;
	for(int i=1;i<=n;++i)
	{
		minn=min(minn,a[i]);
		if(a[i]-minn==manx) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    N,K=pin()
    c=[tupin() for i in range(N)]
    C=sorted(filter(lambda x:x[1]<=K,c))
    try:
        print(C[0][0])
    except :print("TLE")
#%%submit!
resolve()


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pll;
 
# define S second
# define F first
# define kill(x) return(cout << x << endl, 0)
# define debug(x) cerr<< #x << " : " << x << endl
# define ddebug(x, y) cerr<< #x << " : " << x  << ", " << #y << " : " << y << endl
# define sz(s) (int)s.size()
# define sq(x) (x) * (x)
# define PB(x) push_back(x)
# define smax(x, y) (x) = max((x), (y))
# define smin(x, y) (x) = min((x), (y))
# define all(x) x.begin(), x.end()
# define SP fixed << setprecision(10)
# define UB upper_bound

const int MAXN = 100 * 1000  + 10;
int a[MAXN], b[MAXN], ind[MAXN];

bool c(int i, int j)
{
	return (a[i] - b[i] < a[j] - b[j]);
}

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	int n;
	cin >> n;
	ll k = 0;
	for (int i = 0; i < n; i ++)
	{
		cin >> a[i];
		k += a[i];
	}
	for (int i = 0; i < n;  i ++)
	{
		cin >> b[i];
		k -= b[i];
	}
	if (k < 0)
		kill(-1);

	iota(ind, ind + n, 0);
	sort(ind, ind + n, c);

	for (int i = 0; i < n; i ++)
	{
		if (a[ind[i]] > b[ind[i]] && k >= a[ind[i]] - b[ind[i]])
		{
			k -= a[ind[i]] - b[ind[i]];
			b[ind[i]] = a[ind[i]];
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i ++)
		if (a[i] != b[i])
			ans ++;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << 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; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll a, b; cin >> a >> b;
    if((a*b)%2 != 0) Yes();
    else No();
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
//max_element



//---------- 1000000007 ----------
const int MOD = 1000000007;
int m_add(int a, int b)
{
	return (a + b) % MOD;
}
int m_sub(int a, int b)
{
	return (a + MOD - b) % MOD;
}
int m_mul(int a, int b)
{
	return (a * b) % MOD;
}
int m_pow(int x, int n)
{
	if (n == 0) return 1;
	ll res = m_pow((x * x) % MOD, n / 2);
	if (n & 1) res = (res * x) % MOD;
	return res;
}
int m_divide(int a, int b)
{
	return m_mul(a, m_pow(b, MOD - 2));
}
int m_comb(int n, int r)
{
	int i;
	int p = 1;
	for (i = 1; i <= r; i++)
	{
		p = m_mul(p, (n - i + 1));
		p = m_divide(p, i);
	}
	return p;
}
int m_comb_with_rep(int n, int r)
{
	return m_comb(n + r - 1, r);
}



int N, M;
int dp[100010];
bool flg[100010];

signed main()
{
	int A, B;
	cin >> A >> B;
	int a = A + A - 1;
	int b = A + B;
	int c = B + B - 1;
	cout << max(a, max(b, c)) << endl;
}



Measured memory_bytes: 3608
/* ABC-132A.c
   Yuta Takayanagi */

#include<stdio.h>
#define SIZE 5
int main(void){
    char string[SIZE], char1, char2;
    int check, i;

    check = 0;

    scanf( "%s" , string); /* 入力 */

    char1 = string[0]; /* 比較する一文字を保存 */

    for(i=0; i < SIZE-1; i++){
        if(char1==string[i]){

            check++; /* 自分も含め、出てくる回数をカウント */

        }else{

            char2 = string[i]; /* 別に比較する一文字を保存 */

        }

    }

    if(check!=2){

        printf( "No\n" ); /* 出てくる回数が2でなければNOを出力 */
        return 0;

    }

    check = 0;

    for(i=0; i < SIZE-1; i++){
        if(char2==string[i]){

            check++; /* 自分も含め、出てくる回数をカウント */

        }

    }

    if(check!=2){

        printf( "No\n" ); /* 出てくる回数が2でなければNOを出力 */
        return 0;

    }

    printf( "Yes\n"); /* 2文字とも2回ずつ出てきた場合Yesを出力 */

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define repm(i,a,b) for(ll i=(ll)(a);i>(ll)(b);i--)
#define all(v) v.begin(), v.end()
#define rall(x) (x).rbegin(),(x).rend()
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vc vector<char>
#define vvc vector<vc>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;
using vb =vector<bool>;
using vvb=vector<vb>;
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; }
//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp

int main(){
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    ll x=0;
    rep(i,n){
        x^=a[i];
    }
    rep(i,n){
        ll b=a[i]^x;
        cout<<b;
        if(i!=n-1) cout<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 4784
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 30;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

struct Edge{
    int to, cost;
};
int N, K, C[10000], R[10000];
std::vector<Edge> G[10000], G_[10000];
int d[10000], used[10000];

void bfs(int s){
    std::fill(d, d+10000, INF);

    std::queue<int> q;
    q.push(s);
    d[s] = 0;

    while(!q.empty()){
        int u = q.front(); q.pop();

        REP(j, G[u].size()){
            Edge e = G[u][j];
            int v = e.to;

            if(d[v] == INF){
                q.push(v);
                d[v] = d[u] + 1;
            }
        }
    }
}

int dijkstra(int s, int g){
    std::fill(used, used+10000, 0);
    std::fill(d, d+10000, INF);
    
    std::priority_queue<P, std::vector<P>, std::greater<P>> q;
    q.push(mp(0, s));
    d[s] = 0;

    while(!q.empty()){
        P p = q.top(); q.pop();
        int cost = p.first, u = p.second;
            
        if(d[u] < cost){continue;}

        used[u] = 1;

        REP(j, G_[u].size()){
            Edge e = G_[u][j];
            int v = e.to;

            if(!used[v] && d[v] > cost + e.cost){
                q.push({cost+e.cost, v});
                d[v] = cost + e.cost;
            }
        }
    }

    return d[g];
}

int main(){
    std::cin >> N >> K;
    
    REP(i, N){
        std::cin >> C[i] >> R[i];
    }
    
    REP(i, K){
        int from, to;
        std::cin >> from >> to;
        from--; to--;

        G[from].push_back({to, 1});
        G[to].push_back({from, 1});
    }

    REP(i, N){
        bfs(i);
        REP(j, N){
            if(i != j && d[j] <= R[i]){
                G_[i].push_back({j, C[i]});
            }
        }
    } 

    std::cout << dijkstra(0, N-1) << std::endl;
}

Measured memory_bytes: 126404
// Tenshi ni Fureta yo!

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef pair<int, int> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define MP make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }
template<typename T> inline T sqr(const T &val) { return val * val; }

namespace fastIO
{
	const int MAX_BUFFER_SIZE = 1 << 16;

	char buffer[MAX_BUFFER_SIZE], *cur = buffer, *ed = buffer;

	inline char getc() { return *(cur == ed ? ed = buffer + fread(buffer, 1, MAX_BUFFER_SIZE, stdin), cur = buffer : cur)++; }
}
using fastIO::getc;

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getc());
	for(; !isdigit(ch); ch = getc()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

// END tpl.

const int MOD = 998244353;

inline int fpm(int x, int y)
{
	int res = 1;
	for(; y; y >>= 1, x = (LL) x * x % MOD) if(y & 1) res = (LL) res * x % MOD;
	return res;
}

inline int inv(int x) { assert(x); return fpm(x, MOD - 2); }

namespace MATH
{
	const int n = (int) 1e6;

	int fac[n + 5], ifac[n + 5];

	inline void init()
	{
		fac[0] = 1;
		for(int i = 1; i <= n; ++i) fac[i] = (LL) fac[i - 1] * i % MOD;
		ifac[n] = inv(fac[n]);
		for(int i = n - 1; i >= 0; --i) ifac[i] = (LL) ifac[i + 1] * (i + 1) % MOD;
	}

	inline int C(int N, int M) { return N < 0 || M < 0 || N < M ? 0 : (LL) fac[N] * ifac[N - M] % MOD * ifac[M] % MOD; }
}
using MATH::C;

int n, K;

inline void input()
{
	n = read<int>(), K = read<int>();
}

inline void solve()
{
	int ans = 0;
	for(int R = n; R <= K; ++R)
	{
		int B = K - R;
		if(R > B) (ans += (C(R + B, R) - C(R + B, 2 * R - n + 1)) % MOD) %= MOD;
		else if(R == B) (ans += (C(R + B - 1, R) - C(R + B - 1, 2 * R - n + 1)) % MOD) %= MOD;
	}
	printf("%d\n", (ans + MOD) % MOD);
}

int main()
{
#ifdef K_ON
	freopen("E.in", "r", stdin);
	freopen("E.out", "w", stdout);
#endif

	MATH::init();
	input();
	solve();

	return 0;
}




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

using namespace std;

using int64 = long long;

int main() {
  string s;
  cin >> s;

  if(s.back() == '1' || s.front() == '0') {
    cout << -1 << endl;
    return 0;
  }
  s.pop_back();

  for(int i = 0; i < s.size(); i++) {
    if(s[i] != s[s.size() - i - 1]) {
      cout << -1 << endl;
      return 0;
    }
  }
  stack< int > stock;
  vector< pair< int, int > > edges;
  for(int i = 0; i < s.size(); i++) {
    if(s[i] == '1') {
      while(stock.size()) {
        edges.emplace_back(stock.top(), i);
        stock.pop();
      }
    }
    stock.emplace(i);
  }

  cout << stock.top() + 1 << " " << s.size() + 1 << endl;
  for(auto &p : edges) cout << p.first + 1 << " " << p.second + 1 << endl;
}




Measured memory_bytes: 2676
n,m,b;char s[9],c[9];
main()
{
	for(;scanf("%d%d",&m,&n)*m;){
		int q[1024]={0},i,t,p=m;
		for(t=i=1;i<=n;i++){
			scanf("%s",s,*c=0);
			i%3||strcat(c,"Fizz");
			i%5||strcat(c,"Buzz");
			*c||sprintf(c,"%d",i);
			for(strcmp(s,c)&&p>1&&(q[t]=p--);q[t=t%m+1];);
		}
		for(t=i=1;i<=m;i++)q[i]||(t=!printf(" %d"+t,i));
		puts("");
	}
}

Measured memory_bytes: 640
S = input()
T = input()

flg = 0

for i in range(0,len(S)):
    if S == T:
        flg = 1
        break
    else:
        S = S[-1] + S[:len(S) - 1]
if flg == 1:
    print('Yes')
else:
    print('No')
    
    
    



Measured memory_bytes: 2940
#include<stdio.h>
#include<string.h>
char m[105][105];
int h,w;
void dfs(int y,int x,char s){
	m[y][x]='X';
	if(x>0 && y>0 && y<=h && x<=w){
		if(m[y-1][x]==s)dfs(y-1,x,s);
		if(m[y+1][x]==s)dfs(y+1,x,s);
		if(m[y][x-1]==s)dfs(y,x-1,s);
		if(m[y][x+1]==s)dfs(y,x+1,s);
	}
	return;
}
int main(){
	int i,j,a;
	char s[105];
	while(scanf("%d%d",&h,&w)!=EOF){
		if(h==0 && w==0)break;a=0;
		for(i=0;i<=w+1;i++)m[0][i]=m[h+1][i]='X';
		for(i=1;i<=h;i++){
			scanf("%s",s);
			strcpy(m[i]+1,s);
			m[i][0]=m[i][w+1]='X';
		}
		for(i=0;i<=h+1;i++){
			for(j=0;j<=w+1;j++){
				if(m[i][j]=='@')dfs(i,j,'@'),a++;
				else if(m[i][j]=='#')dfs(i,j,'#'),a++;
				else if(m[i][j]=='*')dfs(i,j,'*'),a++;
			}
		}
		printf("%d\n",a);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstring>
#include<set>
#include<queue>
#include<stack>
#include<map>
#define rep(i,a,b) for(int i=a;i<=b;i++)
typedef long long ll;
using namespace std;
const int N=1e5+10;
const int INF=0x3f3f3f3f;
int prime[1000010],not_prime[1000010];
int num[1000010],arr[1000010];
int tot = 0,cnt = 0;

void getprime()
{
    for(int i = 2; i <= 1000000; i++)
    {
        if(!not_prime[i]){
            prime[tot++] = i;
            num[i] = 1;
        }
        for(int j = 0; j < tot && prime[j]*i<=1000000; j++)
        {
            not_prime[prime[j]*i] = 1;
            if(i%prime[j]==0)break;
        }
    }
}

int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("in.txt","r",stdin);
    #endif // ONLINE_JUDGE
    not_prime[0] = not_prime[1] = 1;
    getprime();
    ll l,r,ans = 0;
    ll p,cur;
    memset(num,0,sizeof num);
    scanf("%lld %lld",&l,&r);
    for(ll i = l; i <= r; i++){
        arr[i-l] = i;
    }
    for(int j = 0; j < tot; j++){
         p = prime[j];
         while(p<=r){
             cur = l/p;
             if(cur*p<l)cur++;
             while(cur*p<=r){
                num[cur*p-l]++;
                arr[cur*p-l]/=prime[j];
                cur++;
             }
             p*=prime[j];
         }
    }
    for(ll i = l; i <= r; i++){
        if(arr[i-l]>1)
            num[i-l]++;
    }
    for(ll i = l; i <= r; i++){
        if(!not_prime[num[i-l]])
            ans++;
    }
    printf("%lld\n",ans);
    return 0;
}




Measured memory_bytes: 15252
N = int(input())
A = input()
B = input()
C = input()
 
 
def cal_chenge_num(a, b, c):
    if a==b:
        if a==c:
            return 0
        else:
            return 1
    else:
        if a==c or b==c:
            return 1
        else:
            return 2
 
num = 0
for i in range(N):
    num += cal_chenge_num(A[i], B[i], C[i])
print(num)


Measured memory_bytes: 3060
#include"bits/stdc++.h"

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
void sort2array(double *a,long *b,long n){
    for(int i=0;i<n;i++){
        b[i]=i;
    }
    sort(b,b+n,[a](long i,long j)->bool {return a[i]<a[j];} );
}
//bを何回足せばaを超えるか
int wtover(int a,int b){
    if(a%b>0)return (a/b)+1;
    else return a/b;
}
const int INF=100000001,ID_MAX=20;
int bi_e[ID_MAX]={0};
//2進数表示したときの最高桁
int bi_max(long n){
    int m=0;
    for(m;pow(2,m)<=n;m++);m=m-1;
    return m;
}
//bi_eに二進数表示したやつを代入
void bi_exs(long n){
    rep(i,ID_MAX){
        bi_e[i]=0;
    }
    if(n<pow(2,ID_MAX)){
        int m=bi_max(n);
        long l;
        for(m;m>-1;m--){
            l=pow(2,m);
            bi_e[m]=n/l;
            n=n%l;
        }
    }
}

const int N_MAX=1001,Q_MAX=150;
char X[Q_MAX][N_MAX],Y[Q_MAX][N_MAX],x[N_MAX],y[N_MAX];
int ans[Q_MAX],q,dp[N_MAX][N_MAX];

int rec(int i,int j,int k){
    if(dp[i][j]>=0)return dp[i][j];
    int res;
    if(i==0||j==0){
        res=0;
    }else if(X[k][i-1]==Y[k][j-1]){
        res=rec(i-1,j-1,k)+1;
    }else{
        res=max(rec(i-1,j,k),rec(i,j-1,k));
    }
    return dp[i][j]=res;
}

int main(){
    int i;
    //入力
    cin>>q;
    rep(i,q){
        cin>>X[i];
        cin>>Y[i];
    }
    //処理
    rep(i,q){
        memset(dp,-1,sizeof(dp));
        cout<<rec(strlen(X[i]),strlen(Y[i]),i)<<endl;
    }
    //出力
}


Measured memory_bytes: 7232