akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
  
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    
 		int X,Y,Z;
 		cin>>X>>Y>>Z;
 		swap(X,Y);
 		swap(X,Z);
 		cout<<X<<' '<<Y<<' '<<Z<<endl;       
    
	
	return 0;
}
 


Measured memory_bytes: 256
N=int(input())
a = [int(i) for i in input().split() ]

nk = [0]*N
count = 0
for k,v in enumerate(a):
  if k+1 != v :
    nk[k] = v
    if nk[v-1] == k+1 :
      count += 1

print(count)


Measured memory_bytes: 13940
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    int cnt = 0;
    cin >> a >> b >> c;
    if(a==b){
        cnt++;
    }
    if(a==c){
        cnt++;
    }
    if(b==c){
        cnt++;
    }
    if(cnt==1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
//
//#include <immintrin.h>
//#include <emmintrin.h>

#include <bits/stdc++.h>
//#pragma GCC optimize("O2")
#define vi vector<int>
#define pii pair<int, int >
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define LL long long
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define all(x) (x).begin(), (x).end()
#define all2(x,n) (x+1), (x+1+n)
#define sz(x) ((int)(x).size())
#define mod(x) ((x)%MOD)
#define debug(x) cerr<<#x<<" : "<<x<<endl
#define mt make_tuple
#define eb emplace_back
#define o(X) (1<<(X))
#define oL(X) (1LL<<(X))
#define contain(S,X) (((S)&o(X))!=0)
#define containL(S,X) (((S)&oL(X))!=0)
using namespace std;
const int INF=0x3f3f3f3f,N=1e6+5,MOD=998244353;
const LL INF_LL=0x3f3f3f3f3f3f3f3fLL;
inline int getplc(int x,int y) { return (x>>y)&1; }
template<typename T>
T square(T x) {return x*x;}
LL qpow(LL a,LL b=MOD-2,LL _MOD=MOD){
	LL res=1;
	for(;b;b>>=1,a=a*a%_MOD){
		if(b&1)res=res*a%_MOD;
	}
	return res;
}
// Smax
//int Smax() { return -INF; }
template <typename T>
T Smax(T x) { return x; }
template<typename T, typename... Args>
T Smax(T a, Args... args) { return max(a, Smax(args...)); }
// Smin
template <typename T>
T Smin(T x) { return x; }
template<typename T, typename... Args>
T Smin(T a, Args... args) { return min(a, Smin(args...)); }
template <typename T>
// erro
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); errl(_it, args); }

void errl(istream_iterator<string> it) {}
template<typename T, typename... Args>
void errl(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	errl(++it, args...);
}

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr<<endl;}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << "=" << a << " # ";
	err(++it, args...);
}
void Solve();
int main() {
#ifndef ONLINE_JUDGE
//	freopen("in.txt","r",stdin);
//    freopen("o1.txt","w",stdout);
#endif
	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
	Solve();
	return 0;
}

//////////////////////////////////////////////////////////////////

int a[N];
void Solve(){
  int n;
  cin>>n;
  rep(i,1,n)cin>>a[i];
  sort(a+1,a+1+n);
  LL ans=0;
  rep(i,1,n-1)ans+=a[n-i/2];
  cout<<ans<<endl;
}

Measured memory_bytes: 4388
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> w(n);
    rep(i, n) cin >> w[i];
    ll sum = accumulate(ALL(w), 0);
    ll tmp = 0;
    ll ans = INF;
    rep(i, n) {tmp += w[i]; sum -= w[i]; chmin(ans, abs(sum-tmp));}
    cout << ans << endl;
    return 0;
}

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

int main(){
  long long int n;
  long long int sum = 0;
   int s = 0;
   cin >> n;
   for(int i=1; i<=n; i++){
       if(i%15==0){
           s=n;
       }else if(i%5==0){
           s=n;
       }else if(i%3==0){
           s=n;
       }else{
           sum=sum+i;
       }
   }
  cout << sum << endl;
}

Measured memory_bytes: 3628
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template< typename T > istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    string s;
    cin>>s;
    int n=s.size();
    int scnt=0;
    int tcnt=0;
    int ans=0;
    rep(i,n){
        if(s[i]=='S') scnt++;
        if(s[i]=='T'){
            if(scnt==0) ans++;
            if(scnt!=0) scnt--;
        }
    }
    cout<<ans+scnt<<endl;
    
}

Measured memory_bytes: 720
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <climits>

#define F first
#define S second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())


//INT_MAX
//INT_MIN
//LLONG_MAX
//LLONG_MIN
//DBL_MIN
//DBL_MAX
//LDBL_MIN
//LDBL_MAX

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    vector<int> v(3);
    for (int i = 0; i < 3; i++) {
        cin >> v[i];
    }
    vsort(v);
    if (v[0] + v[1] == v[2]) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto& x: a) cin >> x;
    sort(a.begin(), a.end());
    for(int i=1;i<n;i++){
        if(a[i] == a[i-1]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
constexpr int MOD = 1000000007;
constexpr int INF = 1e18;

using namespace std;


signed main() {
  int N, T;
  cin >> N >> T;

  vector<int> t(N+1);
  int ans = T;
  FOR(i, 1, N+1){
    cin >> t[i];
    if(t[i]-t[i-1] <= T) ans += t[i]-t[i-1];
    else ans += T;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1792
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        String S = sc.next();

        if(S.length() > K) System.out.println(S.substring(0, K)+"...");
        else System.out.println(S);
    
    }
}


Measured memory_bytes: 38612
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    vector< pair< LL, char > > v;
    LL bc_cnt = 0;
    LL a_cnt = 0;
    for( int i = 0; i < s.size(); ++i ) {
        if( i + 1 < s.size() && s[i] == 'B' && s[i + 1] == 'C' ) {
            ++bc_cnt;
            if( a_cnt ) {
                v.pb( MP( a_cnt, 'a' ) );
                a_cnt = 0;

            }
            ++i;
        } else {
            if( bc_cnt ) {
                v.pb( MP( bc_cnt, '*' ) );
                bc_cnt = 0;

            }
            if( s[i] == 'A' ) {
                ++a_cnt;

            } else {
                if( a_cnt ) {
                    v.pb( MP( a_cnt, 'a' ) );
                    a_cnt = 0;

                }
                v.pb( MP( 1, s[i] ) );

            }
        }
    }
    if( a_cnt ) {
        v.pb( MP( a_cnt, 'a' ) );

    }
    if( bc_cnt ) {
        v.pb( MP( bc_cnt, '*' ) );

    }

    LL res = 0;
    for( int i = v.size() - 1; i >= 1; --i ) {
        if( v[i - 1].S == 'a' && v[i].S == '*' ) {
            res += v[i - 1].F * v[i].F;
            v[i - 1].F = v[i].F;
            v[i - 1].S = v[i].S;
        } else if( v[i - 1].S == v[i].S ) {
            v[i - 1].F += v[i].F;

        }
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 6664
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

const int MOD = 1000000007;

int exp(int a, int x)
{
    lint ret = 1, tmp = a % MOD;
    while (x > 0) {
        if (x % 2 == 1)
            ret = ret * tmp % MOD;
        x = x / 2;
        tmp = tmp * tmp % MOD;
    }

    return (int) ret;
}

int inv(int a)
{
    return exp(a, MOD - 2);
}

int F(int x, int y)
{
    if ((x + y) % 3 != 0)
        return 0;

    if (x > y)
        swap(x, y);

    // x <= y;
    if (y > 2 * x)
        return 0;

    int row = (x + y) / 3;
    int col = x - row;
    // 0 <= col <= row
    // answer is nCr(row, col) % MOD
    int numer = 1, denom = 1;
    FOR(i, 1, row + 1)
        numer = (int)(numer * 1LL * i % MOD);

    FOR(i, 1, col + 1)
        denom = (int)(denom * 1LL * i % MOD);

    FOR(i, 1, row - col + 1)
        denom = (int)(denom * 1LL * i % MOD);

    return (int)(numer * 1LL * inv(denom) % MOD);
}

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int X, Y;
    cin >> X >> Y;
    cout << F(X, Y) << endl;
    return 0;
};

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int sum;
        
        while(true){
            String s = sc.next();
            if( s.equals("0"))
                break;
            sum = 0;
            for(int i = 0; i < s.length(); i++){
            	sum = sum + Character.getNumericValue(s.charAt(i));
            }
            System.out.println(sum);
        }
        sc.close();
    }
}



Measured memory_bytes: 26616
/*
sdhoipj
shjohsh
sdfkpjb
*/
#include<bits/stdc++.h>
using namespace std;
char a;
string s;
/*
sdhoipj
shjohsh
sdfkpjb
*/
int main()
{
    ios::sync_with_stdio(false);
    cin>>a;
    s="consonant";
    if(a=='a') s="vowel";
    if(a=='e') s="vowel";
    if(a=='i') s="vowel";
    if(a=='o') s="vowel";
    if(a=='u') s="vowel";
    cout<<s<<endl;
    return 0; 
}
/*
sdhoipj
shjohsh
sdfkpjb
*/

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import bisect


def solve(H: int, W: int, S: "List[str]"):
    L = [[0 for _ in range(W)] for _ in range (H)]
    R = [[0 for _ in range(W)] for _ in range (H)]
    D = [[0 for _ in range(W)] for _ in range (H)]
    U = [[0 for _ in range(W)] for _ in range (H)]

    for i in range(H):
        for j in range(W):
            if S[i][j] == "#":
                L[i][j] = 0
            elif j > 0:
                L[i][j] = L[i][j-1] + 1
            else:
                L[i][j] = 1

        for j in range(W-1,-1,-1):
            if S[i][j] == "#":
                R[i][j] = 0
            elif j < W-1:
                R[i][j] = R[i][j+1] + 1
            else:
                R[i][j] = 1

    for j in range(W):
        for i in range(H):
            if S[i][j] == "#":
                U[i][j] = 0
            elif i > 0:
                U[i][j] = U[i-1][j] + 1
            else:
                U[i][j] = 1

        for i in range(H-1,-1,-1):
            if S[i][j] == "#":
                D[i][j] = 0
            elif i < H-1:
                D[i][j] = D[i+1][j] + 1
            else:
                D[i][j] = 1

    res = 0
    for i in range(H):
        for j in range(W):
            res = max(res, L[i][j] + R[i][j] +U[i][j] +D[i][j] -3)

    print(res)





# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    S = [ next(tokens) for _ in range(H) ]  # type: "List[str]"
    solve(H, W, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 182004
#include<stdio.h>
int main(void){
int a,b,c,d;
	
	scanf("%d %d %d",&a,&b,&c);

	if(a>c){
		d=a;
		a=c;
		c=d;
	}
	if(a>b){
		d=a;
		a=b;
		b=d;
	}
	if(b>c){
		d=b;
		b=c;
		c=d;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  if (N==1) {
    cout << 1 << endl;
  }
  
  else {
    vector<int> A(N);
    for (int i=0; i<N; i++) {
      cin >> A.at(i);
    }
    
    sort(A.begin(),A.end());
    
    int H=1;
    for (int i=0; i<N-1; i++) {
      if (A.at(i)-A.at(i+1) < 0) {
        H++;
      }
    }
    
    cout << H << endl;
  }
}

Measured memory_bytes: 3608
h, w = map(int, input().split())
res = ["." * (w + 2)]
for i in range(h):
    res.append("." + input() + ".")

res.append("." * (w + 2))
quit = False
for i in range(h):
    for j in range(w):
        if res[i][j+1] == "." and res[i+1][j:j+3] == ".#." and res[i+2][j+1] == ".":
            print("No")
            quit = True
            break
    if quit:
        break
else:
    print("Yes")

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

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

	string s;cin >> s;
	int ans;
	for(int i = 0; i < pow(2,s.size()-1); i++){
		int sum = stoi(s.substr(0,1));
		for(int j = 0; j < s.size()-1; j++){
			if(i&1<<j){
				sum -= stoi(s.substr(j+1,1));
			}else{
				sum += stoi(s.substr(j+1,1));
			}
		}
		if(sum == 7){
			ans = i;
		}
	}

	string out = "";
	for(int i = 0; i < 3; i++){
		out += s.substr(i,1);
		if(ans&1<<i){
			out += "-";
		}else{
			out += "+";
		}
	}
	out += s.substr(3,1)+"=7";
	cout << out << endl;
	
}


Measured memory_bytes: 384
l=[]
for i in range(3):
  l1=list(map(int,input().split()))
  l.append(l1)
flag=0
for i in range(-1000,1000,):
  y0=l[0][0]-i
  y1=l[1][0]-i
  y2=l[2][0]-i
  x1=l[0][1]-y0
  x2=l[0][2]-y0
  if l[1][1]==y1+x1 and l[1][2]==y1+x2 and l[2][1]==y2+x1 and l[2][2]==y2+x2:
    flag=1
  else:
    continue
if flag==1:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
import sys
S = input()
for i,item in enumerate(S):
    if i%2==0:
        if item not in ['R', 'U', 'D']:
            print('No')
            sys.exit()
    else:
        if item not in ['L', 'U', 'D']:
            print('No')
            sys.exit()
print('Yes')

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
typedef long long ll;

const int INF = 1e9 + 7;
const long long LLINF = 1e18;

ll N;
int main() {
    cin>>N;
    REP(i, 0, N){
        string str;
        cin>>str;

        ll cnt=1;
        ll idx=1;
        vector<ll> v[5001];
        while(cnt>0){
            if(str[idx]=='['){
                cnt++;
                idx++;
            }
            else if(str[idx]==']'){
                ll num=0;
                sort(v[cnt].begin(), v[cnt].end());
                REP(i, 0, v[cnt].size()/2+1){
                    num+=(v[cnt][i]);
                }

                v[cnt].clear();
                cnt--;
                idx++;
                v[cnt].push_back(num);
            }
            else{
                ll num=0;
                while(isdigit(str[idx])){
                    num=num*10 + (str[idx]-'0');
                    idx++;
                }
                v[cnt-1].push_back(num/2+1);
                idx++;
                cnt--;
            }
        }

        cout<<v[0][0]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())

using namespace std;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

using ll = long long;
constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u * v / gcd(u, v);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    int N;
    cin >> N;
    vector<int>A(N);
    cin >> A;
    int gcd = A[0];
    FOR(i, 1, N) {
        gcd = GCD(gcd, A[i]);
    }

    cout << gcd << endl;
    return 0;

}

Measured memory_bytes: 640
def chk(a,b):
    A,B=len(a),len(b)
    rt=[0]*A
    for i in range(A):
        f=1
        for j in range(min(A-i,B)):
            if len(set([a[i+j],b[j],'?']))>2:f=0;break
        rt[i]=f
    return rt+[1]

def tri_chk(ix):
    i1,i2,i3=ix
    ab,bc,ac=M[i1][i2],M[i2][i3],M[i1][i3]
    A,B,C=map(len,[S[i]for i in ix])
    rt=A+B+C
    for l in range(A+1):
        if ab[l]==0:continue
        for r in range(l,A+B+1):
            if (B<r-l or bc[r-l]==1) and ac[min(A,r)]==1:
                rt=min(rt,max(A,l+B,r+C))
    return rt

S=[input()for i in'abc']
A,B,C=map(len,S)
L=10**5
M=[[chk(S[i],S[j]) if i!=j else []for j in range(3)]for i in range(3)]

for i in [(0,1,2),(0,2,1),(1,0,2),(1,2,0),(2,1,0),(2,0,1)]:
    L=min(L,tri_chk(i))

print(L)


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

using namespace std;

#define endl '\n'
#define tab " "
#define lli long long int


void read(){
    lli N, D, counter = 0;

    cin >> N >> D;

    while(N--){
        lli X, Y;
        double distance;

        cin >> X >> Y;

        distance = sqrt((X*X)+(Y*Y));

        if(distance <= D) counter++;

    }

    cout << counter << endl;

    return;
}

int main(void){
    read();
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long x,k,d;
	cin>>x>>k>>d;
	long long a=x/d;
	if(0>a)
	{
		a=0-a;
	}
	if(x<0)
	{
		x+=min(a,k)*d;
	}
	else
	{
		x-=min(a,k)*d;
	}
	k-=min(a,k);
	if(x>0)
	{
		x-=(k%2)*d;
	}
	else
	{
		x+=(k%2)*d;
	}
	if(x>0)
	{
		cout<<x;
	}
	else
	{
		cout<<0-x;
	}
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main()
{
  int n, MIN=1000000, MAX=-1000000;
  long long sum=0;
  cin >> n;
  int i, b;
  for(int i=0;i<n;i++)
  {
      cin >> b;
      MIN=min(MIN, b);
      MAX=max(MAX, b);
      sum+=b;
  }
   cout << MIN << " " << MAX << " " << sum << "\n";

   return 0;
  }



Measured memory_bytes: 3116
#include <iostream>
using namespace std;
 
int main()
{
  int n;
  cin >> n;
  int a = n / 10;
  int b = n - ((n / 1000) * 1000);
  
  if(a % 111 == 0
  || b % 111 == 0)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main(){
    char s[100000];
    int head = 0;
    int tail;
    int counter_left=0;
    int counter_right=0;
    int counter_operate=0;
    int length = 0;
    scanf("%s",&s);
    length = strlen(s);
    tail = length-1;
    if (tail==head){
        printf("%d\n",0);
        return 0;
    }
    while(tail!=head){

        while(s[head]=='x'){
            counter_left +=1;
            head+=1;
        }
        while(s[tail]=='x'){
            counter_right+=1;
            tail-=1;
        }
        if(head<=tail){
            counter_operate+=abs(counter_left-counter_right);
            counter_left=0;
            counter_right=0;
        }
        if (s[head]!=s[tail]){
            printf("%d\n",-1);
            return 0;
        }
        else{
            tail-=1;
            head+=1;
        }
        if (head>=tail){
            printf("%d\n",counter_operate);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include	<iostream>
#include	<cstdio>
#include	<cmath>

using namespace std;

int main(void) {
	while(1) {
		int d;
		int sum = 0;
		cin >> d;
		if( cin.eof() )		break;
		int f = 600 - d;
		for(int i = d; i <= f; i += d) {
			sum += (i * i) * d;
		}
		
		cout << sum << endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
    const int NO_OF_VERTICES = 4, NO_OF_EDGES = 3;

    vector <int> degree(NO_OF_VERTICES + 1, 0);
    for(int i = 1; i <= NO_OF_EDGES; i++)
    {
        int u, v;
        cin >> u >> v;

        degree[u]++;
        degree[v]++;
    }

    vector <int> degree_count(NO_OF_VERTICES + 1, 0);
    for(int i = 1; i <= NO_OF_VERTICES; i++)
    {
        degree_count[degree[i]]++;
    }

    cout << (degree_count[1] == 2 && degree_count[2] == 2 ? "YES\n" : "NO\n");
    return 0;
}

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

using namespace std;

int main(){
  //https://qiita.com/Nasupl_r/items/35a903a4a69932c26c83
  int n;
  cin >> n;
  
  long a[n],b[n];
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
  }
  
  std::vector<int> vec(n);
  long sumao=0;
  for (int i = 0; i < n; ++i) {
    vec[i] = a[i] + b[i];
    sumao += b[i];
  }
  
  std::sort(vec.begin(),vec.end(),std::greater<int>()); //降順ソート
  
  long sumta=0;
  for(int i=0;i<n;i++){
    if(i % 2 == 0){
      sumta += vec[i];
    }
  }
  
  cout << sumta - sumao << endl;
  return 0; 
      
  
  /*
  int ta=0;
  int ao=0;
  
  for(int i=0;i<n;i++){
    if(i % 2 == 0){
      std::vector<int>::iterator iter = std::max_element(vec.begin(), vec.end());
      int index = std::distance(vec.begin(), iter);
      ta += a[index];
      vec.erase(iter);
      a.erase(a.begin() + index);
      b.erase(b.begin() + index);
    }else{
      std::vector<int>::iterator iter = std::max_element(vec.begin(), vec.end());
      int index = std::distance(vec.begin(), iter);
      ao += b[index];
      vec.erase(iter);
      a.erase(a.begin() + index);
      b.erase(b.begin() + index);
    }
  }
  
  cout << ta - ao << endl;
  return 0;
  */
}

Measured memory_bytes: 2176
import java.util.Scanner;

public class Main{
    
    public static void main(String[] args) {
        
        Scanner scanner = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        
        while (true) {
            short h = scanner.nextShort();
            short w = scanner.nextShort();
            
            if (h == 0 && w == 0) { 
                break;
            }
            
            for(short i=0; i<h; i++) {
                for(short j=0; j<w; j++) {
                    sb.append("#");
                }
                sb.append("\n");
            }
            sb.append("\n");
        }
        
        System.out.print(sb);
    }
    
}


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

int main(){
  int N;
  cin>>N;
  vector<int> p(N);
  for(int i=0;i<N;++i){
    cin>>p.at(i);
  }

  int i=0;
  while(i<N && p.at(i)==i+1){
    ++i;
  }
  if(i==N){
    cout<<"YES"<<endl;
  }
  else{
    int j=i+1;
    while(j<N && p.at(j)!=i+1){
      ++j;
    }
    p.at(j)=p.at(i);
    p.at(i)=i+1;

    i=0;
    while(i<N && p.at(i)==i+1){
      ++i;
    }
    if(i==N){
      cout<<"YES"<<endl;
    }
    else{
      cout<<"NO"<<endl;
    }
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL; // VL a(n);
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VL> VLL; // VII a(n,VI(m)) n * m
typedef pair<ll, ll> PL;
typedef map<ll, ll> MP; // MP a;
typedef vector<pair<ll, ll>> PS; // PS a(n);

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

int main() {
  ll n,k,m,x=0,y=0,z=0,cnt=0,h=0,w=0,sum=0,ans=0,Max=-1, Min=3e9+1;
  string s,t;
  cin >> n;
  if(n%1000==0)
    pri(0);
  else{
    x = n/1000;
    x++;
    pri(x*1000 - n);
  }
  return 0;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, ll> P; 
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

vector<int> g[100100];
bool color[100100],visited[100100];

void dfs(int v){
	int u,i;
	visited[v] = true;
	for(i=(g[v].l_ength()-1); i>=0; --i){
		u = g[v][i];
		if(visited[u]){
			continue;
		}
		dfs(u);
		if(!color[u]){
			color[v] = true;
		}
	}
}

int main(void){
	int n,a,b,i,cnt=0;
	bool flag = true;
	cin >> n;
	for(i=1; i<n; ++i){
		cin >> a >> b;
		--a; --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(0);
	for(i=0; i<n; ++i){
		if(color[i]){
			++cnt;
		}
	}
	cout << ((cnt==n-cnt)?"Second":"First") << endl;
	return 0;
}


Measured memory_bytes: 6016
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n + 1];
        long[] b = new long[n];
        for (int i = 0; i < n + 1; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
        }

        long fii1 = 0;
        long sum = 0;
        for (int i = 0; i < n; i++) {
            long fii = Math.min(a[i] - fii1, b[i]);
            fii1 = Math.min(a[i + 1], b[i] - fii);
            sum += fii + fii1;
        }
        System.out.println(sum);
    }

}



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

for i in range(n):
    if (a[i]%2) == 0 :
        if (a[i]%3) != 0 :
            if (a[i]%5) != 0 :
                print("DENIED")
                exit()

print("APPROVED")

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;

int main()
{
	int a,b;
	ll ans=0;
	cin>>a>>b;
	ans=max(0,a-b*2);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    long int N;
    long int x = 1;
    long int count = 0;
    scanf("%ld",&N);
    while(x*x+x < N){
        if(N%x==0){count += ((N/x)-1);}
        x++;
    }
    printf("%ld\n",count);
}

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

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

const int N=2e5+100;
const int mod=1e9+7;

ll a[N];
int vis[N];

void init()
{
     a[0]=1;
     for(int i=1;i<=N;i++)
         a[i]=a[i-1]*i%mod;
}
ll qpow(ll x,ll n)
{
    ll sum=1;
    while(n){
        if(n&1) sum=sum*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return sum;
}
ll C(int x,int y)
{
    if(x<y) return 0; 
    return a[x]*qpow(a[y],mod-2)%mod*qpow(a[x-y],mod-2)%mod;
}
int main()
{
   ios::sync_with_stdio(0);cin.tie(0);
   init();
   int n;cin>>n;
   int l,r;
   for(int i=1;i<=n+1;i++) {
        int x;cin>>x;
       if(vis[x]){
         l=vis[x];
         r=i;
       }
       else {
        vis[x]=i;
       }
   }
   for(int i=1;i<=n+1;i++){
    cout<<(C(n+1,i)-C(n-r+l,i-1)+mod)%mod<<endl;
   }
   return 0;
}



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

int main() {
	int n, m;
	int a, b;
	int h[100000];
	bool g[100000];
	int ret = 0;

	cin >> n >> m;

	for (int i=0; i<n; i++) {
		cin >> h[i];
		g[i] = true;
	}

	for (int i=0; i<m; i++) {
		cin >> a >> b;
		a--; b--;
		if (h[a] < h[b]) {
			g[a] = false;
		} else if(h[a] == h[b]) {
			g[a] = false;
			g[b] = false;
		} else {
			g[b] = false;
		}
	}

	for (int i=0; i<n; i++) {
		if (g[i] == true) {
			ret++;
		}
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 4112
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N = int(input())
fac = factorization(N)
result = 0
for div in fac:
    if div[0] == 1:
        continue
    i = 1
    count = 1
    while i <= div[1]:
        result += 1
        count += 1
        i += count

print(result)



Measured memory_bytes: 63380
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s, t, u;
	int a, b, ans = 0;
	cin >> s >> t >> a >> b >> u; 
	if(s == u) --a;
	if(t == u) --b;
	printf("%d %d\n", a, b);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
if N >= 64:
    print(64)
elif 64 > N >= 32:
    print(32)
elif 32 > N >= 16:
    print(16)
elif 16 > N >= 8:
    print(8)
elif 8 > N >= 4:
    print(4)
elif 4 > N >= 2:
    print(2)
elif 2 > N >= 1:
    print(1)

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

class Cmondai
{
    static void Main()
    {
        var dg = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
        var D = (int)dg[0];
        var G = dg[1];
        var list = new List<long[]>();
        for (int i=0;i<D;++i)
        {
            var pc= Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
            list.Add(new long[2] { pc[0], pc[1] });
        }
        var ans = long.MaxValue;
        for (int i = 0; i < (Math.Pow(2, D)); i++)
        {
            var count = 0L;
            var total = 0L;
            for (int j = 0; j < D; j++)
            {
                if ((1 & i >> j) == 1) {
                    count += list[j][0];
                    total += list[j][0] * 100 * (j + 1) + list[j][1];
                }
            }
            if (total < G)
            {
                for (int j = D - 1; 0 <= j; --j)
                {
                    if ((1 & i >> j) == 0)
                    {
                        var add = ((G-total)+((j + 1) * 100)-1) / ((j + 1) * 100);
                        if (add <= list[j][0])
                        {
                            count+=add;
                            total += add * 100 * (j + 1);
                            if (G <= total) ans = Math.Min(ans, count);
                            break;
                        }
                    }
                }
            }
            else ans=Math.Min(ans,count);
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13396
#include <iostream>

using namespace std;

long long gcd(long long a, long long b) {
    if(b == 0) return a;
    return gcd(b, a % b);
}

long long num(long long n, long long c, long long d) {
    long long G = gcd(c, d);
    long long L = c / G * d;

    return n - n / c - n / d + n / L;
}

int main() {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    
    cout << num(b, c, d) - num(a - 1, c, d) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
using namespace std;

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<int>> vvint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(int i=0;i<n;i++)
#define repf(i,f,n) for(int i=f;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())



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

int N,Q;
string s;
vector<char> t,d;

// int main(){cout << "hoge" << endl;}

int get_ll(int ipos){
  if(ipos<0 || ipos>=N){
    return ipos;
  }

  int fpos = ipos;
  int lpos = ipos;

  rep(i,Q){
    if(s[fpos]==t[i]){
      if(d[i]=='L'){
        fpos--;
      }else{
        fpos++;
      }
      lpos = min(lpos,fpos);

      if(fpos<0 || fpos>=N){
        break;
      }
    }
  }

  return lpos;
}

int get_rl(int ipos){
  if(ipos<0 || ipos>=N){
    return ipos;
  }

  int fpos = ipos;
  int lpos = ipos;

  rep(i,Q){
    if(s[fpos]==t[i]){
      if(d[i]=='L'){
        fpos--;
      }else{
        fpos++;
      }
      lpos = max(lpos,fpos);

      if(fpos<0 || fpos>=N){
        break;
      }
    }
  }

  return lpos;
}

// int binary_search(int key){
//   int left = -1;
//   int right = N;
//
//   while(right - left > 1){
//     int mid = left + (right - left)/2;
//
//     if(isOK(mid, key)) right=mid;
//     else left=mid;
//   }
//
//   return right;
// }

int lb(int key){
  int left = -1;
  int right = N;

  while(right - left > 1){
    int mid = left + (right - left)/2;

    if(get_ll(mid)>=key) right=mid;
    else left=mid;
  }

  return right;
}

int ub(int key){
  int left = -1;
  int right = N;

  while(right - left > 1){
    int mid = left + (right - left)/2;

    if(get_rl(mid)<=key) left=mid;
    else right=mid;
  }

  return left;
}

int main() {

  cin >> N >> Q;
  cin >> s;

  t.resize(Q); d.resize(Q);
  rep(i,Q){
    cin >> t[i] >> d[i];
  }

  cout << ub(N-1) - lb(0) + 1 << endl;
}

















//


Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int M1,D1,M2,D2;
  cin >> M1 >> D1 >> M2 >> D2;
  
  if (M1 == M2){
    cout << 0 << endl;
  }
  else {
    cout << 1 << endl;
  }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {   if (y & 1)
        res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
int main()
{
	IOS;
	string s;
	cin>>s;
	if(s[0]=='7'||s[1]=='7'||s[2]=='7')
	cout<<"Yes";
	else
	cout<<"No";
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
const int MAX = 330000;
int 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;
	}
}
int COMB(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;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int n, k;
int a[224514];
int cnt[224514];
signed main() {
	int ans = 0;
	cin >> n >> k;
	rep(i, n)cin >> a[i];
	for (int i = 1; i <= n; i++)cnt[i] = cnt[i - 1] + a[i - 1];
	for (int i = 0; i <= n - k; i++)chmax(ans, cnt[i + k] - cnt[i]);
	cout << setprecision(10) << (double)((double)(ans + k) / (double)2) << endl;
	ggr
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<ll, ll>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  ll n; cin >> n;
  vector<vector<int>> a(n, vector<int>(n-1));
  rep(i, n) rep(j, n-1) {
    cin >> a[i][j];
    --a[i][j];
  }
  vector<int> now(n, 0);
  vector<bool> yesterday(n, true);
  for(int day = 0;; ++day) {
    vector<bool> flag(n, false);
    bool ok = true;
    rep(i, n) {
      if(!yesterday[i]) continue;
      int j = a[i][now[i]];
      if(flag[i] || flag[j]) continue;
      if(now[i] == n-1 || a[j][now[j]] != i) {
        yesterday[i] = false;
        continue;
      }
      ok = false;
      flag[i] = true;
      flag[j] = true;
      yesterday[i] = true;
      yesterday[j] = true;
      ++now[i];
      ++now[j];
    }
    if(ok) {
      rep(i, n) if(now[i] != n-1) {
        cout << -1 << endl;
        return 0;
      }
      cout << day << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 4224