akhauriyash/Code-Regression huggingface dataset:
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N[5], k, flag = 0;
    REP(i, 5){
        in >> N[i];
    }
    in >> k;

    if(N[4] - N[0] > k){
        out << ":(" << endl;
    }else{
        out << "Yay!" << endl;
    }
 
    //vector<ll> X(N);

}

Measured memory_bytes: 256
n = int(input())
l = []
pre_c = None
ans = True
for _ in range(n):
    w = input()
    # print(w)

    if w in l:
        ans = False
        break
    if not(pre_c is None or pre_c == w[0]):
        ans = False
        break

    l.append(w)
    pre_c = w[-1]

if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9140
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import Data.List
import Control.Monad
import Debug.Trace
import Data.Bits
import Data.Array.MArray
import Data.Array.ST
import Control.Monad.ST
import Data.STRef
import qualified Data.Set as S
import Control.Monad
import qualified Data.Vector.Mutable as MV
import Control.Applicative (liftA2)
import Control.Monad.Primitive (PrimMonad, PrimState)

data UnionFind s = UnionFind {offset :: Int, graph :: MV.MVector s (Maybe Int), total :: MV.MVector s Int}

newUnionFind :: PrimMonad m => Int -> Int -> m (UnionFind (PrimState m))
newUnionFind start end = liftA2 (UnionFind start) (MV.replicate num Nothing) (MV.replicate num 1)
    where
        num = end - start + 1

convertIndex :: UnionFind s -> Int -> Int
convertIndex u i = i - offset u

root :: PrimMonad m => UnionFind (PrimState m) -> Int -> m Int
root u i = do
    let convertedI = convertIndex u i
    parent <- MV.read (graph u) convertedI 
    parent <- case parent of
        Nothing -> do
            MV.write (graph u) convertedI $ Just i
            pure i
        Just p ->
            pure p
    if parent == i then pure parent
    else do
        parent' <- root u parent
        MV.write (graph u) convertedI (Just parent')
        pure parent'

unite :: PrimMonad m => UnionFind (PrimState m) -> Int -> Int -> m ()
unite u ix iy = do
    rx <- root u ix
    ry <- root u iy 
    if rx == ry then pure ()
    else do 
        sizex <- size u rx
        sizey <- size u ry
        if sizex < sizey then do
            -- yが高い yが親
            MV.write (graph u) (convertIndex u rx) (Just ry)
            MV.write (total u) (convertIndex u ry) (sizex + sizey) 
        else do
            -- xが高い xが親
            MV.write (graph u) (convertIndex u ry) (Just rx)
            MV.write (total u) (convertIndex u rx) (sizex + sizey)

same :: PrimMonad m => UnionFind (PrimState m) -> Int -> Int -> m Bool
same u x y = liftA2 (==) (root u x) (root u y)

size :: PrimMonad m =>  UnionFind (PrimState m) -> Int -> m Int
size u i = root u i >>= MV.read (total u) . convertIndex u

readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine
    


solve :: Int -> [(Int, Int, Int)] -> Int
solve n xyzs = runST $ do
    uf <- newUnionFind 1 n
    forM_ xyzs $ \(x,y,_) ->
        unite uf x y
    roots <- forM [1..n] $ \i->
        root uf i
    pure . S.size . S.fromList $ roots
    


main = do
    (n, m) <- readTuple2
    xyzs <- replicateM m readTuple3
    print $ solve n xyzs
    

Measured memory_bytes: 50300
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <array>
#include <algorithm>
#include <set>
#include <iomanip>
#include <cstdio>

using namespace std;

#define int long long

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

    vector<int> v;

    for (int i = 1; i * i < 1000000000; ++i)
    {
        v.push_back(i * i);
    }
    
    int in;

    cin >> in;

    cout << *(upper_bound(v.begin(), v.end(), in)-1) << endl;
}

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

using namespace std;

int main() {
  // 入力
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; ++i) {
    cin >> L[i];
  }

  //
  sort(L.begin(), L.end());
  int sum = 0;
  for (int i = 0; i < N-1; ++i) {
    sum += L[i];
//    cout << L[i] << endl;
  }

  if(sum <= L[N-1]){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<utility>
#include<algorithm>
#include<unordered_map>
#include <cmath>
#include<climits>
using namespace std;

int main()
{
	long long a[] = { 1, 4, 16, 61, 230, 865, 3247, 12185, 45719, 171531, 643550, 2414454, 9058467, 33985227, 127504505, 478366600, 794717734, 733354121, 261943303, 776803305, 580025381, 51688048, 44657419, 737209731, 604119499, 159693437, 858533109, 639056669, 549054109, 996291083, 531294469, 23314687, 783022045, 855462856, 649970414, 68697295, 409213624, 604356692, 88638656, 978442997, 534833116, 763737161, 785892908, 123883652, 639213333, 181836645, 998121103, 124885216, 501575626, 39816123, 113468411, 799008836, 775465589, 256852905, 664630886, 971550783, 751629411, 51018086, 702530485, 725438992, 696683714, 792638194, 221791721, 149602322, 414054379, 986519078, 981760191, 305799096, 515140586, 406959393, 975058685, 245601370, 324759692, 673385295, 191483611, 570246669, 427196161, 781042769, 569725155, 842176273, 25328739, 847501730, 206282374, 353770801, 323137024, 371653459, 940737264, 123820509, 915711339, 847205021, 252858375, 718889563, 866398347, 738390145, 133009077, 333099663, 170591295, 329869205, 616680192, 597534442, 388130742 };

	int n; cin >> n;
	cout << a[n] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD (int)1e9+7
#define int long long
int a[222222], b[222222];
set<int>st;
signed main() {
	int n, ans = 0;
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		b[a[i] - 1] = i;
	}
	st.insert(-1);
	st.insert(n);
	rep(i, n) {
		auto itr= st.lower_bound(b[i]);
		int right = (*itr) - b[i];
		itr--;
		int left = b[i] - (*itr);
		ans += a[b[i]] * right*left;
		st.insert(b[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 12800
#include <stdio.h>
#include <stdlib.h>

int c2i(char c) {
  return c - '0';
}

int n2c(char c) {
  return c + '0';
}

void plus(char *a, char *b, int an, int bn) {
  char s[100];
  int i, tmp, carry;
  
  if (an > 80 || bn > 80) {
    puts("overflow");
    return;
  }
  
  for (i = 0; i < an; i++) { a[i] = c2i(a[i]); }
  for (i = 0; i < bn; i++) { b[i] = c2i(b[i]); }
  
  i = carry = 0;
  while (bn--) {
    an--;
    tmp = a[an] + b[bn] + carry;
    carry = (tmp - (tmp%10)) / 10;
    s[i] = tmp%10;
    i++;
  }
  
  while (an--) {
    tmp = a[an] + carry;
    carry = (tmp - (tmp%10)) / 10;
    s[i] = tmp%10;
    i++;
  }
  
  if (carry) {
    s[i++] = carry;
  }
  
  if (i <= 80) {
    while (i--) {
      putchar(n2c(s[i]));
    }
    puts("");
  } else {
    puts("overflow");
  }
}

int main() {
  char *a, *b;
  int i, n, an, bn;
  
  scanf("%d\n", &n);
  
  for (i = 0; i < n; i++) {
    scanf("%a[0-9]%n\n", &a, &an);
    scanf("%a[0-9]%n\n", &b, &bn);
    if (an > bn) {
      plus(a, b, an, bn);
    } else {
      plus(b, a, bn, an);
    }
  }
  
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll=long long;  
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
	string s,t;
	cin >> s >> t;
    bool ans = false;
    for (size_t i = 0; i < s.size(); ++i) {
        if (s == t) {
            ans = true;
            break;
        }
        s = s.back() + s.substr(0, s.size() - 1);
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define ct(string) cout << string

int main() {
    string s;
    cin >> s;
    int op;
    rep(i,8) {
        int sum = s.at(0) - '0';
        rep(j,3) {
            if (i & (1<<j)) sum += s.at(j+1) - '0';
            else sum -= (s.at(j+1) - '0');
        }
        if (sum == 7) {op = i; break;}
    }
    ct(s.at(0));
    rep(i,3) {
        if (op & (1<<i)) ct("+");
        else ct("-");
        ct(s.at(i+1));
    }
    ct("=7" << endl);
}

Measured memory_bytes: 256
import numpy as np

#入力
N = input()
#入力値を取り出す
A, B, T = np.array(list(map(int,N.split( ))))

T = T + 0.5
S = 0
n = 1
A1 = A
while A1<T:
  n = n + 1
  A1 = n * A
  S = S + B
print (S)

Measured memory_bytes: 12424
#include<stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
 int A,B, C, D;
 scanf("%d %d %d %d", &A, &B, &C, &D);
 int TAKAHASI = C/B;
 int AOKI = A/D;
 int TM = C % B;
 int AM = A % D;
 //printf("%d %d ",TAKAHASI, AOKI);
 if(TM > 0){
   TAKAHASI += 1;
 } 
 if(AM > 0){
   AOKI += 1;
 } 
 if (TAKAHASI <= AOKI){
   printf("Yes\n");
 }else {
   printf("No\n");
 }
 
  return 0;
}

Measured memory_bytes: 1620
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct flower
{
    int hi;
    int bty;
};

int solve(vector<flower> &v,int n)
{
    int dp[n+1];
    map<int,int> meaningful;
    meaningful[v[1].hi] = v[1].bty;
    dp[1] = v[1].bty;
    int ans = dp[1];

    for(int i=2;i<=n;i++){
        dp[i] = v[i].bty;
        auto it = meaningful.lower_bound(v[i].hi+1);
        if(it != meaningful.begin())
        {
            it--;
            dp[i] = dp[i] + it->second;
        }
        ans = max(ans,dp[i]);
        meaningful[v[i].hi] = dp[i];
        it = meaningful.upper_bound(v[i].hi);
        while(it!=meaningful.end() && it->second<=dp[i]){
            auto temp = it;
            temp++;
            meaningful.erase(it);
            it = temp;
        }


    }
    return ans;



}
int32_t main(){
    int n;cin>>n;
    vector<flower> v(n+1);
    for(int i=1;i<=n;i++){
        cin>>v[i].hi;
    }
    for(int i=1;i<=n;i++){
        cin>>v[i].bty;
    }

    cout<<solve(v,n);

}

Measured memory_bytes: 20228
#include <iostream>
#include <algorithm>
#include <string>
#define ll long long
using namespace std;
int main(){
    string s;
    ll n;
    string ac="AC";
    ll cac=0;
    string wa="WA";
    ll cwa=0;
    string tle="TLE";
    ll ctle=0;
    string re="RE";
    ll cre=0;
    cin>>n;
    for (ll i = 0; i <n ; ++i) {
        cin>>s;
        if(s==ac){
            cac++;
        }
        else if(s==wa){
            cwa++;
        }
        else if(s==tle){
            ctle++;
        }
        else if (s==re){
            cre++;
        }
    }
    cout<<ac<<" x "<<cac<<endl;
    cout<<wa<<" x "<<cwa<<endl;
    cout<<tle<<" x "<<ctle<<endl;
    cout<<re<<" x "<<cre<<endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
#define in(v) v; cin >> v;
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)

const int MAX_N = 3001;
ll dp[MAX_N][MAX_N];
int A[MAX_N];
int N;
const ll INF = 1e13;
ll dfs(int a, int b) {
  if (a + b == N)
    return 0;
  if (dp[a][b] != INF)
    return dp[a][b];

  if ((a + b) % 2 == 0)
    return dp[a][b] = max(dfs(a+1, b) + A[a], dfs(a, b+1) + A[N-b-1]);
  return dp[a][b] = min(dfs(a+1, b) - A[a], dfs(a, b+1) - A[N-b-1]);
}
int main() {
  in(N);
  rep(i, MAX_N) rep(j, MAX_N) dp[i][j] = INF;
  rep(i, N)
    cin >> A[i];

  cout << dfs(0, 0) << endl;
  return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PI acos(-1.0)
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

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

  rep(i,s.size()){
    if(s[i] == '?') s[i] = 'D';
  }
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<ll> a(n);
	rep(i,n){
		cin>>a[i];
	}
	vector<ll> p(n,0),q(n,0),r(n,0),s(n,0);
	p[1]=a[0],q[1]=a[1];
	int l=1;
	FOR(r,2,n-2){
		p[r]=p[r-1],q[r]=q[r-1]+a[r];
		//a[l]をPに入れるべきか見ていく
		while(l<r){
			ll now=abs(p[r]-q[r]);
			ll ne=abs((p[r]+a[l])-(q[r]-a[l]));
			if(ne<now){
				p[r]+=a[l];
				q[r]-=a[l];
				l++;
			}else{
				break;
			}
		}
	}
	int ri=n-2;
	r[n-3]=a[n-2],s[n-3]=a[n-1];
	for(int l=n-4;l>=1;l--){
		r[l]=r[l+1]+a[l+1],s[l]=s[l+1];
		//a[ri]をsに入れるかどうか
		while(l<ri){
			ll now=abs(r[l]-s[l]);
			ll ne=abs((r[l]-a[ri])-(s[l]+a[ri]));
			if(ne<now){
				r[l]-=a[ri];
				s[l]+=a[ri];
				ri--;
			}else{
				break;
			}
		}
	}
	ll ans=inf;
	FOR(i,1,n-2){
		ll mi=min({p[i],q[i],r[i],s[i]});
		ll ma=max({p[i],q[i],r[i],s[i]});
		chmin(ans,abs(ma-mi));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 8064
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

constexpr double EPS = 1e-7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
#define PI (acos(-1))

constexpr int MOD = 1e9 + 7;

int main(int argc, char const *argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	char C;
	cin >> C;
	cout << (char)(C + 1) << endl;
	return 0;
}


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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
        cout << "Bad" << endl;
    } else {
        cout << "Good" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC90 C

n,m = map(int,input().split())


if n>=3 and m >= 3:
    print((n-2)*(m-2))
elif n == 2 or m == 2:
    print(0)
elif n == 1 and m >= 3:
    print(m-2)
elif n >= 3 and m == 1:
    print(n-2)
elif n == 1 and m == 1:
    print(1)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    string s,t;
    cin>>s>>t;
    cout<<t+s;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

/* 阿澄佳奈はいいぞ */

struct sasakikotoko {
	int A, B;
};

int umine(const void* x, const void* y) {
	int a = ((const struct sasakikotoko*)x)->B, b = ((const struct sasakikotoko*)y)->B;
	return a < b ? -1 : a > b;
}

int N;
struct sasakikotoko haisyupaabu[271828];

int main(void) {
	int i;
	int uesakasumire = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d%d", &haisyupaabu[i].A, &haisyupaabu[i].B) != 2) return 1;
	}
	qsort(haisyupaabu, N, sizeof(*haisyupaabu), umine);
	for (i = 0; i < N; i++) {
		uesakasumire += haisyupaabu[i].A;
		if (uesakasumire > haisyupaabu[i].B) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 3324
/**
 *  Hi, I'm Arpan.
 *
*/

#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
#define inv(v)         \
    for (auto &it : v) \
        cin >> it;
#define MOD 1000000007
#define pb push_back
#define popb pop_back()
#define endl "\n"
#define fi first
#define se second
typedef priority_queue<ll, vector<ll>, greater<ll>> minheap;
typedef priority_queue<ll> maxheap;
#define sortv(v) sort(v.begin(),v.end())
#define rsortv(v) sort(v.begin(),v.end(), greater<>());

ll modPower(ll num,ll r) {
	if(r==0) return 1;
	if(r==1) return num%MOD;
	ll ans=modPower(num,r/2)%MOD;
	if(r%2==0) {
		return (ans*ans)%MOD;
	} return (((ans*ans)%MOD)*num)%MOD;
}

ll nCr(ll n, ll r) {
    ll res = 1;
    if (r > n - r) {
        r = n - r;
    }
    for(int i=0;i<r;i++) {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

/*******************************************/
//
void solve()
{
	int l,r,d;
	cin >> l >> r >> d;
	int ans = 0;
	for(int i=l;i<=r;i++){
		if(i%d == 0)ans++;
	}
	cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
	//cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979

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


bool my_cp(pair<int, int> a, pair<int, int> b){
  return (double)b.first / (double)(b.second+1) < (double)a.first / (double)(a.second+1);
}


ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}

int N;

void dfs(string s, char m, int N){
  size_t len = s.length();
  if(len == N){
    cout << s << endl;
  }else{
    for(char c = 'a'; c <= m; c++){
      dfs(s + c, ((c == m)? (m + 1) : m), N);
    }
  }
}


ll gcd(ll a, ll b){
  ll resi, g, l;
  if(a > b){
    g = a; l = b;
  }else if(b > a){
    g = b; l = a;
  }else{
    return a;
  }
  resi = g % l;
  if(resi != 0){
    return gcd(l, resi);
  }else{
    return l;
  } 
}





// substr(start, len)

int main(){

  ll N, K, lim = 1e9 + 7;

  cin >> N >> K;
  ll hum = powmod(10, 100, lim);
  ll sum = 0;

  vector<ll> s(N+2, 0);

  // 累積和の配列を作成
  // s[0] = 0, s[1] = 1e10, ... , s[N+1] = (N+1)*1e10 + 1+...+N
  rep(i, 1, N+2){
    s[i] = (s[i-1] + i - 1) ;
  }

  rep(i, K, N+2){
    ll min = s[i];

    ll max = (s[N+1] - s[N-i+1]);

    sum = (sum + (max - min + 1)) % lim;

  }

  cout << sum << endl;



  
  // cout << setprecision(8) << ans << endl;  // For double
  // CHECK if it's possible to overflow!!
}

Measured memory_bytes: 4660
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
 
int main(){
    string s,t;
    cin>>s>>t;
    t.pop_back();
    if(s==t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  int n, k, s, d, r = 0;
  map<int, int> m;
  vector<int> v;
  cin >> n >> k;
  for (int i=0;i<n;i++) {
    int a;
    cin >> a;
    if (m.find(a) == m.end()) {
      m[a] = 1;
    } else {
      m[a]++;
    }
  }
  for (auto it = m.begin();it != m.end();it++) {
    v.push_back(it->second);
  }
  s = v.size();
  d = s - k;
  if (d > 0) {
    sort(v.begin(), v.end());
    for (int i=0;i<d;i++) {
      r += v[i];
    }
  }
  cout << r << endl;
  return(0);
}


Measured memory_bytes: 10748
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll MOD =(ll)1e9+7;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a<=c&&c<=b)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
a = sorted([tuple(map(int, input().split())) for _ in range(n)], key=lambda x:-x[1])

ans = 0
s = set()
q = []

for i in range(k):
    ans += a[i][1]
    if a[i][0] in s:
        q.append(a[i][1])
    s.add(a[i][0])

ans += len(s)**2
k1 = k
ans1 = ans

#はじめ0~k-1までの和がansなので、k~n-1でチェック
while k1 < n and q:
    if a[k1][0] not in s:
        ans1 = ans1+a[k1][1]-q.pop()-len(s)**2+(len(s)+1)**2
        ans = max(ans, ans1)
        s.add(a[k1][0])
    k1 += 1

print(ans)


Measured memory_bytes: 22160
n = int(input())
a = list(map(int,input().split()))
if sum(a) % 2 == 0:
	print(sum(a) // 2)
else:
	a.sort()
	mi = 10000
	for i in a:
		if i % 2 == 1:
			mi = i
			break
	print((sum(a) - mi) // 2)


Measured memory_bytes: 5588
#include <stdio.h>

int main(void) {
	int n = 0;
	scanf("%d\n", &n);
	int a;
	int b[(int)2e5+1] = {0};
	for (int i = 0; i < n - 1; i++) {
		scanf("%d", &a);
		b[a]++;
	}
	for (int i = 1; i <= n; i++) {
		printf("%d\n", b[i]);
	}
	return 0;
}


Measured memory_bytes: 2516
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <deque>
using namespace std;

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

	for(unsigned int i=0; i<s.size(); i++)
	{
		if(s[i] == 'A')
			s[i] = 'X';
		else if(s[i] == 'B')
			s[i] = 'Y';
		else if(s[i] == 'C')
			s[i] = 'Z';
		else
			s[i] -= 3;
	}

	cout<<s<<endl;

	return 0;

}

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

#define debug(x) cout <<"DEBUG"<<" "<<#x<<":"<<x<<'\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;

/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    cout << fixed << setprecision(10);

    //入力
    ll n, k; cin >> n >> k;
    vll a(n), f(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> f[i];

    //sort
    sort(all(a));
    sort(f.rbegin(), f.rend());

    //にぶたん
    ll r = infll;
    ll l = -1; //null
    ll mid;

    while(r-l > 1) {  //条件を満たす中で最適化  //今回は最大値の'最小化'
        mid = (r+l)/2;

        //条件判定をラムダ式で実装 <- すげぇ～
        bool check = [&](){ //<- []の中に&を入れると外の変数を使える。()は引数ないなら省略可
            ll cnt = 0;
            for(int i = 0; i < n; i++) {
                cnt += max(0LL, a[i] - mid/f[i]);  //a[i]->a'[i]への変更に必要な修行数
            }
            return (cnt <= k); //ここに満たしたい条件式を入れてboolを返してる<-すげぇ
        }();    //  <- 注! ()が必要です。
        //更新
        if(check) r = mid; else l = mid;
    }

    //出力
    cout << r << '\n';
}

Measured memory_bytes: 3328
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-01-11 23:09:31
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#ifdef LOCAL
#define debug(_) cerr << #_ << ": " << (_) << '\n'
#else
#define debug(_) 1728
#endif

template<class T>
T lcm(T x, T y) {
  return x / __gcd(x, y) * y;
}

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

  int n; int64 m; cin >> n >> m;
  vector<int64> a(n); cin >> a;

  auto cnt = [](int64 x) -> int {
    int ret = 0;
    while (!(x & 1)) {
      x >>= 1;
      ++ret;
    }
    return ret;
  };

  int64 l = 1;
  int64 p = cnt(a[0]);

  for (int i = 0; i < n; ++i) {
    if (cnt(a[i]) != p) {
      cout << 0 << endl;
      return 0;
    }
    l = lcm(l, a[i] / 2);
    if (l > m) break;
  }

  int64 ll = l * 2;

  cout << m / l - m / ll << endl;

  return 0;
}

Measured memory_bytes: 1024
def saiki(N,M,A,MAX,queri,ans):
	
	if len(A) == N:
		ret = 0
		for q in queri:
			if (A[q[1]] - A[q[0]]) == q[2]:
				ret += q[3]
		if ret > ans[0]:
			ans[0] = ret

	else:
		for i in range(1,MAX+1):
			a = [i] + A[:]
			saiki(N,M,a,i,queri,ans)




if __name__ == '__main__':
	N,M,Q = map(int, input().split())

	queri = []
	for _ in range(Q):
		a,b,c,d = map(int, input().split())
		queri.append([a-1,b-1,c,d])

	ans = [0]
	saiki(N,M,[],M,queri,ans)

	print(ans[0])

Measured memory_bytes: 77924
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int a, b, c;
	cin >> a >> b >> c;
	cout << (a + b + c >= 22 ? "bust" : "win") << endl;



	return 0;
}

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

using namespace std;

int main(void)
{
    long N;
    cin >> N;
    int i;
    vector<long> data(N);

    map<long,long>temp;
    long all=0;
    long minus=0;
    for (i = 0; i < N; i++)
    {
        cin >> data[i];
        temp[data[i]]++;
        //cout<<temp[data[i]]<<endl;
    }
    size_t size=temp.size();
    for(auto itr=temp.begin();itr!=temp.end();itr++){
        all+=((*itr).second*((*itr).second-1))/2;
        //cout<<all<<"key"<<(*itr).first<<"value"<<(*itr).second<<endl;
    }
    for(long j=0;j<N;j++){
        minus=temp[data[j]]-1;
        cout<<all-minus<<endl;
    }
    return 0;
}

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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using plglg = pair<ll, ll>;
using tlglglg = tuple<ll, ll, ll>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << endl;}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
inline void yesno(bool ok, string yes = "Yes", string no = "No") {cout << (ok?yes:no) << endl;}


signed main() {
    //my-code
    string s; cin >> s;

    int ans;
    if (s == "SSS") {
        print(0);
    }
    if (s == "SSR" || s == "SRS" || s == "RSS" || s == "RSR") {
        print(1);
    }
    if (s == "SRR" || s == "RRS") {
        print(2);
    }
    if (s == "RRR") {
        print(3);
    }

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 3648
n,k = map(int,input().split())
a = [int(i)-1 for i in input().split()]
loc = 0
lst = [False]*n
lst[0] = True
while True:
    if lst[a[loc]]:
        x = a[loc]
        break
    loc = a[loc]
    lst[loc] = True
cnt = 0
loc = 0
if x != 0:
    while True:
        loc = a[loc]
        cnt += 1
        if loc == x: break
cnt2 = 0
while True:
    loc = a[loc]
    cnt2 += 1
    if loc == x: break
if k >= cnt:
    k -= cnt
    k %= cnt2
    loc = x
    while k > 0:
        loc = a[loc]
        k -= 1
else:
    loc = 0
    while k > 0:
        loc = a[loc]
        k -= 1
print(loc+1)

Measured memory_bytes: 32200
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ALDS1_2_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = new int[1000];
            var input = Console.ReadLine().Split(' ');
            for (int i = 0; i < N; i++)
            {
                A[i] = int.Parse(input[i]);
            }

            BubbleSort(A, N);
        }

        public static int[] BubbleSort(int[] A, int N)
        {
            var flag = true;
            var count = 0;
            while (flag)
            {
                flag = false;
                for (int j = N - 1; j >= 1; j--)
                {
                    if (A[j] < A[j - 1])
                    {
                        var c = A[j];
                        A[j] = A[j - 1];
                        A[j - 1] = c;
                        flag = true;
                        count++;
                    }
                }
            }
            var prt = "";
            for (int i = 0; i < N; i++)
            {
                if (i == N - 1)
                {
                    prt += A[i];
                }
                else
                {
                    prt += A[i] + " ";
                }
            }
            Console.WriteLine(prt);

            Console.WriteLine(count);
            return A;
        }
    }
}



Measured memory_bytes: 17932
S = input()
n = len(S)
ans = 0

def dfs(i,s = S[0]):
    if i == n-1:
        global ans
        ans += eval(s)
        return
    dfs(i+1,s+"+"+S[i+1])
    dfs(i+1,s+S[i+1])

dfs(0)
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn = 1005;
int a[maxn];
int dis[maxn];
int main(){
	int n,t,aa,bb;
	scanf("%d%d%d%d",&n,&t,&aa,&bb);
	printf("%d\n",min(n,t)+min(aa,bb));
	return 0;
} 

Measured memory_bytes: 256
while true do
  n = gets.to_i
  break if n == 0

  ss = gets.chomp
  n.times do
    ss = ss.split("").map(&:to_i)
    nss = []
    count = 0
    now = ss.first
    ss.each do |s|
      if s == now
        count += 1
      else
        nss << count << now
        now = s
        count = 1
      end
    end
    nss << count << now
    ss = nss.join
  end

  puts ss
end

Measured memory_bytes: 10344
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;

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

using pqg = priority_queue<ll,vector<ll>, greater<ll> >; // 1,3,5..
using pql = priority_queue<ll,vector<ll> >; //5, 3, 1...

using pqg_p = priority_queue<P,vector<P>, greater<P> >; // 1,3,5..
using pql_p = priority_queue<P,vector<P> >; //5, 3, 1...

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


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

  set<ll> s;
  ll N;
  cin >> N;
  REP(i,N) {
    int t;
    cin >> t;
    s.insert(t);
  }
  cout << s.size() << "\n";
  return 0;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
        int n,i;
        cin >> n;
        int a[n], b[n], c[n-1];
        int s;
        s=0;
        for (i=0;i<n;i++){
                cin >> a[i];
        }
        for (i=0;i<n;i++){
                cin >> b[i];
        }
        for (i=0;i<n-1;i++){
                cin >> c[i];
        }
        for (i=0;i<n;i++){
                s = s + b[a[i]-1];
                if (i!=0 and a[i-1]+1==a[i]){
                        s = s + c[a[i]-2];
                }
        }
        cout << s;
}        


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

int main()
{
    int a, b;
    char op;

    cin >> a >> op >> b;

    if (op == '+'){
        cout << a + b << endl;
    }
    else {
        cout << a - b << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
MOD = 10**9 + 7
MAX_N = 2 * 10**6 + 1

# Construct factorial table
fac = [1] + [0] * MAX_N
for i in range(1, MAX_N+1):
    fac[i] = fac[i-1] * (i) % MOD

fac_inv = [1] + [0] * MAX_N
# Femrmat's little theorem says a**(p-1) mod p == 1
# then, a * a**(p-2) mod p == 1
# it means that a**(p-2) is the inverse element
# Here, Get 1 / n! first
fac_inv[MAX_N] = pow(fac[MAX_N], MOD-2, MOD)
for i in range(MAX_N, 1, -1):
    fac_inv[i-1] = fac_inv[i] * i % MOD

def mod_nCr(n, r):
    if n < r or n < 0 or r < 0:
        return 0
    tmp = fac_inv[n-r] * fac_inv[r] % MOD
    return tmp * fac[n] % MOD

def get_rect_sum(r, c):
    total = 0
    for i in range(1, c+2):
        total += mod_nCr(r + i, r)
    return total

r1, c1, r2, c2 = [int(item) for item in input().split()]
ans = get_rect_sum(r2, c2)
ans += get_rect_sum(r1 - 1, c1 - 1)
ans -= get_rect_sum(r2, c1 - 1)
ans -= get_rect_sum(r1 - 1, c2)
ans %= MOD
print(ans)

Measured memory_bytes: 90720
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <unordered_map>

using namespace std;

struct rest{
    string name;
    int point;
    int idx;

    bool operator<(const rest &another) const {
        if (name != another.name) {
            return name < another.name;
        } else {
            return point > another.point;
        }
    }
};

void solve() {
    int n; cin >> n;
    vector<rest> r(n);
    for(int i = 0; i < n; i++){
        string s; int p;
        cin >> s >> p;
        rest tmp = {s, p, i+1};
        r[i] = tmp;
    }
    sort(r.begin(), r.end());
    for(int i = 0; i < n; i++){
        cout << r[i].idx << endl;
    }

}

int main() {
    solve();
    return 0;
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

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

    long long n;
    cin >> n;

    long long ret = LLONG_MAX;
    for (long long i=1; i*i<=2*n; i++)
        if (2 * n % i == 0)
            for (long long x : {i, 2 * n / i}) {
                auto p = crt({0, 2 * n / x - 1}, {x, 2 * n / x});
                if (p.first != 0)
                    ret = min(ret, p.first);
            }
    cout << ret << "\n";

    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#define rep(i, n) for(Int (i) = 0; (i) < (n); (i)++)
#define debug(var) cout << #var << ": " << var << endl
using namespace std;
using Int = int64_t;
using Uint = uint64_t;
constexpr Uint mod = 1e9 + 7;
constexpr Int Int_max = LLONG_MAX;
constexpr Int Int_min = LLONG_MIN;
using Container = vector<Int>;
using Grid = vector<vector<char>>; // [y][x]
template<typename T, typename U>
using Umap = unordered_map<T, U>;
template<typename T>
using Uset = unordered_set<T>;
template<typename T>
using P = pair<T, T>;

//数字の先頭の数を返す。O(log10(n))
Int head(Int n) {
	Int tmp = n;
	while (n > 0) {
		tmp = n;
		n /= 10;
	}
	return tmp;
}

//数字の末尾の数を返す。O(1)
int tail(Int n) {
	if (n < 10)return n;
	Int tmp = n;
	n /= 10;
	return tmp - n * 10;
}

int main() {

	Int N; cin >> N;
	map<P<Int>, Int> map;
	for (Int i = 1; i <= N; ++i) {
		map[P<Int>(head(i), tail(i))]++;
	}
	Int ans = 0;
	for (auto& m : map) {
		auto reverse = P<Int>(m.first.second, m.first.first);
		if (map.find(reverse) != map.end()) {
			ans += (m.second * map[reverse]);
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define rep2(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define rrep(i,n) ll i=(n);ll now=-1;while(i--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)
#define vint vector<int>
#define vll vector<ll>
#define vstr vector<string>
#define vbl vector<bool>
#define pb push_back
using namespace std;
using ll = long long;

static inline void ignore_ret(int x) {x++;}
template<class T> inline bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> inline T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> inline T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm(r,v.at(i));return r;}
template<class T> inline T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> inline T nCr(T n,T k){if(n<k||n<0||k<0)return 0;T r=1;k=min(k,n-k);for(T i=n-k+1;i<=n;i++)r*=i;return r/factorial(k);}
template<class T> inline T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> inline T sum(vector<T>v){return reduce(all(v),0LL);}
#pragma endregion template

void solve(string S) {
  string ans(S.size(), 'x');
  cout << ans << endl;
}

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


Measured memory_bytes: 256
N, M = map(int, input().split())
oks = [True] * (N+1)
a = [int(input()) for _ in range(M)]
for i in a:
    oks[i] = False

dp = [0] * (N+1)
dp[0] = 1
for i in range(N+1):
    for j in range(i+1, min(i+2, N)+1):
        if oks[j]:
            dp[j] += dp[i]
            dp[j] %= int(1e9+7)


print(dp[N])


Measured memory_bytes: 8616
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >>N;
    vector<int>vec(N);
    for(int i=0;i<N;i++){
        cin >> vec.at(i);
    }
    int count=1;
    int block=0;
    for(int i=0;i<N;i++){
       if(vec.at(i)==count){
           count++;
           block++;
       }

    }
    if(block==0){
        cout <<-1<<endl;
        
    }
    else{
    cout << N-block<<endl;
    }
}

Measured memory_bytes: 4056
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2e9


int main()
{
    fastio;
    int x,n;
    cin >> x >> n;
    map<int,int>m;
    for(int i=0;i<n;i++)
    {
        int x;
        cin >> x;
        m[x]+=1;
    }
    int l=x,r=x;
    while(m.find(l)!=m.end())
        l-=1;
    while (m.find(r)!=m.end())
    {
        r+=1;
    }
    int a=x-l,b=r-x;
    if(a>b)
        cout << r << endl;
    else
        cout << l << endl;
}

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

int main() {
  long long N;
  cin >> N;
  
  vector <long long> p;
  p.reserve(N);
  
  for (int i = 0; i < N; i++) {
    long long tmp;
    cin >> tmp;
    p.push_back(tmp);
  }
  
  int count = 0;
  for (int i = 0; i < N-1; i++) {
    if (p[i] > p[i+1]) {
      count++;
    }
  }
  
  int p_idx=0, f_idx=0;
  for (int i = 0; i < N-1; i++) {
    if (p[i] > p[i+1]) {
      p_idx = i;
      break;
    }
  }
  
  for (int i = N-1; i > 0; i--) {
    if (p[i-1] > p[i]) {
      f_idx = i;
      break;
    }
  }
  
  string result = "YES";
  if (count == 0) {
    result = "YES";
  } else if (count == 1) {
    result = "NO";
  } else if (count > 2) {
    result = "NO";
  } else { // count == 2
    long long tmp = p[p_idx];
    p[p_idx] = p[f_idx];
    p[f_idx] = tmp;
  
    for (int i = 0; i < N-1; i++) {
      if (p[i] > p[i+1]) {
        result = "NO";
        break;
      }
    }
  }
  
  cout << result << endl;
  
  return 0;
}

Measured memory_bytes: 256