akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE BangPatterns #-}
 
module Main
  ( main
  )
where
 
import           Control.Applicative
import           Control.Monad
import           Control.Monad.ST
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import           Data.Ord
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import qualified Data.Vector.Unboxed           as UV

parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine


main = do
  [h, w] <- readIntList
  pic <- forM [1..h] (const getLine)
  forM_ pic (\line -> forM_ [1..2] (\i -> putStrLn line))


Measured memory_bytes: 1276
import numpy as np
N    = int(input())
A    = input().split()
Pro  = 1
PrF  = 1
PrFF = 1

if '0' in A:
    print(0)
    PrF = 0
    
if PrF:
    for T in range(0,len(A)):
        if int(A[T]) == pow(10,18):
            PrFF = 0
            print('-1')
            break
        else:
            Pro = Pro*int(A[T])
            if Pro > pow(10,18):
                PrFF = 0
                print('-1')
                break

if PrF & PrFF:
    print(Pro)

Measured memory_bytes: 37856
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
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;
}

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

    string s;
    cin >> s;

    std::cout << (regex_match(s, regex("(dream|dreamer|erase|eraser)*")) ? "YES"
                                                                         : "NO")
              << '\n';

    return 0;
}

Measured memory_bytes: 39888
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
    int n;
    cin>>n;
    if(n==1)
    {
        cout<<"Hello World"<<endl;
    }
    else
    {
        int a,b;
        cin>>a;
        cin>>b;
        cout<<a+b<<endl;
    }
    
}

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

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
        A[i] -= i+1;
    }
    sort(A.begin(), A.end());

    ll b = A[N/2];
    ll res = 0;
    for(int i=0; i<N; i++) {
        res += abs(A[i]-b);
    }

    cout << res << endl;
    return 0;

}

Measured memory_bytes: 1792
//   <-- Y.L.Asce -->   //
#include <iostream>
#include <cstdio>
#include <cstring>
#include <set>
#include <queue>
#include <string>
#include <algorithm>

using namespace std;

int n;
string from[12],to[12];
string s,e;
queue< pair<string,int> > Q;
set<string> vis;

bool check(string ret,int id)
{
    for(int i=0;i<ret.length();i++)
        if(ret.substr(i,from[id].length()) == from[id]) return true;

    return false;
}

string update(string ret,int id)
{
    string ans = "";
    for(int i=0;i<ret.length();i++)
    {
        if(ret.substr(i,from[id].length()) == from[id])
        {
            ans += to[id];
            i = i+from[id].length()-1;
        }
        else ans += ret[i];
//cout<<i<<' '<<ans<<endl;
    }
    return ans;
}
int main()
{
    while(1)
    {
        scanf("%d",&n);
        if(n==0) break;

        for(int i=0;i<n;i++)
            cin>>from[i]>>to[i];

        cin>>s>>e;

        vis.clear();
        while(!Q.empty()) Q.pop();
        vis.insert(s);

        Q.push(make_pair<string,int>(s,0) );
        while(!Q.empty())
        {
            pair<string,int> tmp = Q.front();
            Q.pop();
//cout<<tmp.first<<endl;
            if(tmp.first==e)
            {
                cout<<tmp.second<<endl;
                goto mark;
            }

            for(int i=0;i<n;i++)
                if(check(tmp.first,i))
            {
                string target = update(tmp.first,i);
                if(vis.count(target)==0 && target.length() <=100)
                    {
                        vis.insert(target);
                        Q.push(make_pair<string,int>(target,tmp.second+1));
                    }
            }
        }
        cout<<-1<<endl;
        mark:;
    }
}

Measured memory_bytes: 4468
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define EPS 1e-10
#define INF 1000000000
#define mp make_pair
#define pb push_back

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

int main() {
  string s;
  bool f = true;
  cin >> s;
  for (int i = 1; i < 3; i++) {
    string ss;
    cin >> ss;
    if (s[s.size()-1] != ss[0]) {
      f = false;
    }
    s = ss;
  }
  if (f) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

// 2???????????????????????????????±???????
double dot(P a, P b) {
    return (a.X * b.X + a.Y * b.Y);
}

// 2???????????????????????????????±???????
double cross(P a, P b) {
    return (a.X * b.Y - a.Y * b.X);
}

int ccw(P a, P b, P c) {
    b -= a; c -= a;
    if( cross(b,c) > EPS ) return +1;
    if( cross(b,c) < -EPS ) return -1;
    if( dot(b,c) < 0 ) return +2;
    if( norm(b) < norm(c) ) return -2;
    return 0;
}

// ??????????????????????????????????????? ccw ???????????¨?????? != 1 ??¨??????
bool isCcwConvex(const vector<P> &ps) {
    int n = ps.size();
    rep(i,0,n) if(ccw(ps[i], ps[(i+1) % n], ps[(i+2) % n]) == -1) return false;
    return true;
}

int main() {
    int n; cin >> n;
    vector<P> ps;
    P a;
    rep(i,0,n) {
        cin >> a.X >> a.Y;
        ps.pb(a);
    }

    cout << isCcwConvex(ps) << endl;
    return 0;
}

Measured memory_bytes: 1252
N, A, B = map(int, input().split())

if A > B:
	print(0)
	exit()

if N == 1 and A == B:
	print(1)
	exit()

if N == 1 and A != B:
	print(0)
	exit()

sum_min, sum_max = A * (N - 1) + B, A + (N - 1) * B

print(sum_max - sum_min + 1)


Measured memory_bytes: 2940
N = int(input())
a = []
for i in range(1,N+1):
    if i%3==0 and i%5==0:
        b = 'FizzBuzz'
    elif i%5==0:
        b = 'Buzz'
    elif i%3==0:
        b = 'Fizz'
    else:
        b = i
    a.append(b)
list_2 = [num for num in a if isinstance(num, (int, float))]
print(sum(list_2))

Measured memory_bytes: 37804
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>

#define for0(i, N)    for (long long i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (long long i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (long long i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (long long i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (long long i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (long long i = (x), a = 0; a < (N);    \
                              i = (i + 1) % (N), ++a)
#define int long long

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

long long constexpr inf = std::numeric_limits<long long>::max();

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;


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

    double m, n;
    cin >> n >> m;

    vector<double> a(n);

    ll all = 0;

    for0(i, n)cin >> a[i], all += a[i];

    sort(a.begin(), a.end());

    // for0(i, n)cout << a[i] << "\n";

    auto x = lower_bound(a.begin(), a.end(), double(all) / (4 * m));

    // cout << distance(a.begin(), x) << "\n";

    if (distance(x, a.end()) < m) cout << "No\n";
    else cout << "Yes\n";

    return 0;
}


Measured memory_bytes: 256
/****************************
*  Developer : joshi08
*  Date  :  14-06-2020
*  Year  :  2020
****************************/

#include <bits/stdc++.h>

#define lli long long int
#define mod 1000000007
#define fi first
#define se second
#define ii pair<lli, lli>
#define mp make_pair
#define endl '\n'
const double PI = 3.141592653589793238460;
lli gcd(lli a, lli b) { if (a == 0) return b; return gcd(b % a, a);}
lli max(lli a, lli b) {if (a > b) return a; else return b;}
lli min(lli a, lli b) {if (a < b) return a; else return b;}
lli power(lli a,lli b) {lli i,p=1; for(i=0;i<b;i++){p*=a;} return p;}

using namespace std;

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

	lli x,y;
	cin>>x>>y;
	
	if(y%2!=0)
		cout<<"No";
	else
	{
		if(2*x<=y && y<=4*x)
		{
			cout<<"Yes";
		}
		else
			cout<<"No";
	}

    return 0;
}



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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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

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<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N; cin >> N;
    vector<i64> A(N);
    REP(i, N) cin >> A[i];

    i64 s = 0;
    REP(i, N) {
        s += A[i] - 1;
    }
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;
typedef vector<int> VI;
#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )

template<typename T>
T getPrimeNum(vector<bool> primes, T index) {
    T ret = 0;
    for (auto i = 0; i <= index; i++) {
        if (primes.at(i)) {
            ++ret;
        }
    }
    return ret;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    vector<bool> primes(1000000, true);
    primes[0] = false;
    primes[1] = false;
    for (unsigned long n = 2; n < 1000000; n++) {
        if (n*n > 1000000)    break;
        if (!n)    continue;
        for(unsigned long i = n+n; i < 1000000; i=i+n) {
            primes[i] = false;
        }
    }

    unsigned long input;
    vector<unsigned long> inputs;
    while (cin >> input) {
        inputs.push_back(input);
    }

    for (auto n : inputs) {
        cout << getPrimeNum(primes, n) << endl;
    }

    return 0;
}

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

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N, T, S;
	cin >> N >> T >> S;
	vector<int> dp(T + 1);
	for (int i = 0; i < N; i++) {
		int A, B;
		cin >> A >> B;
		for (int j = T - B; j >= 0; j--) {
			if (j < S && j + B > S) {
				if (S + B <= T) {
					dp[S + B] = max(dp[S + B], dp[j] + A);
				}
			}
			else {
				dp[j + B] = max(dp[j + B], dp[j] + A);
			}
		}
	}
	cout << *max_element(dp.begin(), dp.end()) << endl;
	return 0;
}



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

int main(){
    int x ,y,z;
    vector<int> ans(3) ;
    cin >> ans[0] >>ans[1]>>ans[2] ;
    sort(ans.begin(),ans.end() );
    cout << ans[0] <<" "<< ans[1] <<" "<< ans[2] <<endl ;

    return 0 ;
}




Measured memory_bytes: 3152
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	if (a == b) cout << "a == b" << endl;
	if (a < b) cout << "a < b" << endl;
	if (a > b) cout << "a > b" << endl;
	return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N, M;
	cin >> N >> M;
	const int sq = max(1, min(N, (int)sqrt(N)));
	vector<ll> t(N);
	vector<int> cnt(sq);
	vector<vector<ll>> v(sq);
	for (int i = 1; i < sq; i++) {
		v[i].assign(i, 0);
	}
	int all = 0;
	for (int i = 0; i < M; i++) {
		int A, B;
		cin >> A >> B;
		A = (A + 1) % B;
		if (sq <= B) {
			++all;
			t[0] += A;
			for (int j = B - A; j < N; j += B) {
				t[j] -= B;
			}
		}
		else {
			cnt[B] += 1;
			v[B][0] += A;
			if (A) v[B][B - A] -= B;
		}
	}
	for (int i = 1; i < N; i++) {
		t[i] += t[i - 1] + all;
	}
	for (int i = 1; i < sq; i++) {
		for (int j = 1; j < i; j++) {
			v[i][j] += v[i][j - 1] + cnt[i];
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 1; j < sq; j++) {
			if (cnt[j]) {
				t[i] += v[j][i % j];
			}
		}
	}
	for (int i = 0; i < N; i++) {
		printf("%lld\n", t[i]);
	}
	return 0;
}



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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> llVEC;
typedef vector<P> PVEC;
typedef priority_queue<P,PVEC,greater<P> > PQ;
typedef priority_queue<ll, llVEC, greater<ll> > llPQ;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> &vec){ return (ll)vec.size(); }
template<typename T>
ll sz(priority_queue<T, vector<T>> &pq) {return (ll)pq.size(); }
template<typename T>
ll sz(priority_queue<T, vector<T>, greater<T>> &pq) {return (ll)pq.size(); }
ll sz(string &s) {return (ll)s.size(); } 
ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b; }
bool checkindex(ll i,ll n){ return (i < n && i >= 0); }
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

using P = pair<ll,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;


struct edge{
    ll to,cost;  
};

void dijkstra(ll V,vector<vector<edge> > &G,vector<ll> &d,ll s){
    PQ que;
    fill(d.begin(),d.end(), LINF);
    d[s] = 0;
    que.push(P(0,s));

    while(!que.empty()){
        P p = que.top(); que.pop();
        ll v = p.second;
        if(d[v] < p.first) continue;

        rep(i,0,G[v].size()){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to],e.to));
            }

        }
    }


}


int main(){
    ll n;
    cin >> n;
    vector<vector<edge>> G(n);    

    ll a,b;
    edge e;
    e.cost = 1;
    rep(i,0,n-1){
        cin >> a >> b;
        a--; b--; e.to = b;
        G[a].push_back(e);
        e.to = a;
        G[b].push_back(e);
    }

    vector<ll> d1(n),d2(n);
    dijkstra(n,G,d1,0);
    dijkstra(n,G,d2,n-1);

    ll cntb = 0,cntw = 0;
    rep(i,0,n){
        if(d1[i] <= d2[i]){
            cntb++;
        }
        else{
            cntw++;
        }
    }

    if(cntb > cntw) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;

    return 0;
}



Measured memory_bytes: 12624
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define MOD2 998244353
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define T int
#define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
 
ll mexp(ll a, ll b, ll m){
    ll ans=1;
    a%=m;
    while(b){
        if(b&1) ans=ans*a%m;
        b>>=1;
        a=a*a%m;
    }
    return ans;
}
 
int main(){
    IOS

    int n;
    cin>>n;
    int a[n+1];
    int mx=0, c=0;
    FOR(i,1,n){
    	cin>>a[i];
    	mx=max(a[i],mx);
    }
    FOR(i,1,n){
    	if(a[i]==mx){
    		c++;
    	}
    }
    if(c>1){
    	FOR(i,1,n){
    		cout<<mx<<" ";
    	}
    	return 0;
    }
    int mx2=0;
    FOR(i,1,n){
    	if(a[i]==mx){
    		continue;
    	}
    	mx2=max(a[i],mx2);
    }
    FOR(i,1,n){
    	if(a[i]==mx){
    		cout<<mx2<<endl;
    	}
    	else{
    		cout<<mx<<endl;
    	}
    }	
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
string a[3];
int x[3],zhi=0;
int main()
{
	cin>>a[0]>>a[1]>>a[2];
	while(a[zhi].size()!=x[zhi])
	{
		switch(a[zhi][x[zhi]])
		{
			case 'a':
				{
					x[zhi]++;
					zhi=0;
					break;
				}
			case 'b':
				{
					x[zhi]++;
					zhi=1;
					break;
				}
			case 'c':
				{
					x[zhi]++;
					zhi=2;
					break;
				}
		}
	}
	if(zhi==0) cout<<"A";
	else if(zhi==1) cout<<"B";
	else cout<<"C";
}

Measured memory_bytes: 3520
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
typedef struct restaurant{
    int number;
    char city[10];
    int point;
}RESTAURANT;
 
int compare(const void *a, const void *b){
    RESTAURANT ra = *(RESTAURANT *)a;
    RESTAURANT rb = *(RESTAURANT *)b;
    int cmp = strcmp(ra.city,rb.city);
    if(cmp==0){
        return rb.point - ra.point;
    }else{
        return cmp;
    }
}
 
int main(){
 
    int n;
    scanf("%d",&n);
    struct restaurant a[n];
    for(int i=0;i<n;i++){
        a[i].number =i+1;
        scanf("%s %d",a[i].city,&(a[i].point));
    }
 
    qsort(a,n,sizeof(RESTAURANT),compare);
 
    for(int i=0;i<n;i++){
        printf("%d\n",a[i].number);
    }
 
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define P std::pair<int,int>
#define double long double
typedef long long ll;
using namespace std;
int i;
void func(int a){
	if(!a){
		int cnt=1;
		cout<<i;
		for(int j=1;j<=i;j++){
			cout<<" "<<cnt;
			cnt+=j;
		}
		cout<<endl;
		cnt=1;
		cout<<i;
		for(int j=1;j<=i;j++){
			cnt+=j;
			cout<<" "<<cnt-1;
		}
		cout<<endl;
	}
	else{
		int cnt=a*(a+1)/2+1;
		cout<<i;
		rep(j,a+1){
			cout<<" "<<cnt;
			cnt++;
		}
		cnt--;
		for(int j=a+1;j<i;j++){
			cnt+=j;
			cout<<" "<<cnt;
		}
		cout<<endl;
	}
}

signed main() {
	int n;
	cin>>n;
	if(n==1){
		puts("Yes");
		cout<<2<<endl<<1<<" "<<1<<endl<<1<<" "<<1<<endl;
		return 0;
	}
	for(i=0;i<n;i++){
		if(i*(i+1)/2==n){
			puts("Yes");
			cout<<i+1<<endl;
			rep(j,i)func(j);
			return 0;
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define sz(x) ((int)(x).size())
#define sq(x) ((x)*(x))
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
int N,M;
int S[1010],k[1010];
vector<int> c[1010];
int mx[10010];
int mi[10010];
int solve(){
	cin >> N >> M;
	if(N+M==0)return 1;
	memset(mx,0,sizeof(mx));
	memset(mi,0,sizeof(mi));
	for(int i=0;i<1010;i++)c[i].clear();
	for(int i=0;i<M;i++){
		cin >> S[i] >> k[i];
		c[i].resize(k[i]);
		for(int j=0;j<k[i];j++){
			cin >> c[i][j];
			c[i][j]--;
			mx[c[i][j]]+=S[i];
			if(k[i]==1)mi[c[i][j]]+=S[i];
		}
	}
	/*for(int i=0;i<N;i++){
		printf("%d: mi %d, mx %d\n",i,mi[i],mx[i]);
	}*/
	multiset<int> ms;
	for(int i=0;i<N;i++)ms.insert(mx[i]);
	int ans = 0;
	for(int i=0;i<N;i++){
		multiset<int>::iterator it = ms.find(mx[i]);
		assert(it!=ms.end());
		ms.erase(it);
		ans = max(ans,(*ms.rbegin())-mi[i]);
		ms.insert(mx[i]);
	}
	cout << ans+1 << endl;
	return 0;
}
int main(){
	while(!solve()){}
	return 0;
}

Measured memory_bytes: 4572
#include <iostream>
#include <sstream>
#include <algorithm>
using namespace std;
int input;
string toString(int n){stringstream ss; ss << n; return ss.str();}
bool isPalindromicNum(int x){
  string s = toString(x);
  int len = s.size();
  for(int i = 0; 1; i++){
    if(i > len-i-1)break;
    if(s[i] != s[len-i-1])return false;
  }
  return true;
}
void solve(){
  int margin = input;
  int ans;
  for(int i = 0 ; i < input + margin; i++){
    if(i % 10 == 0)continue;
    if(isPalindromicNum(i)){
      margin = abs(input - i);
      ans = i;
    }
  }
  cout << ans << endl;
}
int main(){
  while(cin >> input){
    solve();
  }
  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
const int mod = 1'000'000'007;
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int ans = 0;
  int x = 0;
  rep(i,n) {
    ans = (ans+(ll)a[i]*x)%mod;
    x = (x+a[i])%mod;
  }
  cout << ans << endl;
  return 0;
}

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

int main(int argc, char const *argv[])
{
	string s;
	cin>>s;
	if (s=="zyxwvutsrqponmlkjihgfedcba")
	{
		cout<<"-1\n";
	}
	else if (s.size()<26)
	{
		set<char> a;
		for (int i = 0; i < s.size(); ++i)
		{
			a.insert(s[i]);
		}
		for (int i = 0; i < 30; ++i)
		{
			if (a.count('a'+i)==0)
			{
				cout<<s<<(char)('a'+i)<<endl;
				return 0;
			}
		}
	}
	else
	{
		string t=s.substr(0,25);
		while (t[t.size()-1]=='z')
		{
			t=t.substr(0,t.size()-1);
		}
		++t[t.size()-1];
		while (1)
		{
			set<char> a;
			for (int i = 0; i < t.size(); ++i)
			{
				a.insert(t[i]);
			}
			if (a.size()==t.size())
			{
				cout<<t<<endl;
				return 0;
			}
			if (t[t.size()-1]=='z')
			{
				while (t[t.size()-1]=='z')
				{
					t=t.substr(0,t.size()-1);
				}
			}
			++t[t.size()-1];
		}
	}
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace _167_b
{
    internal class EasyLinearProgramming
    {
        private static void Main(string[] args)
        {
            var abck = Console.ReadLine()?.Split(" ").Select(long.Parse).ToArray();
            if (abck == null) return;

            var a = abck[0];
            var b = abck[1];
            var c = abck[2];
            var k = abck[3];

            var remain = k;
            long sum = 0;

            // 1のカード
            if (remain > a)
            {
                remain -= a;
                sum += a;
            }
            else
            {
                sum += remain;
                Console.WriteLine(sum);
                return;
            }
            
            // 0のカード
            if (remain > b)
            {
                remain -= b;
            }
            else
            {
                Console.WriteLine(sum);
                return;
            }

            // -1のカード
            sum -= remain;
            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 28144
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int n,cnt=0,ans=0;
  string s;
  cin>>n>>s;
  rep(i,n){
    if(s[i]=='I') cnt++;
    else cnt--;
    ans=max(ans,cnt);
    
  }
  cout<<ans<<endl;
 
}
///////////////////////////




Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		
      	Scanner sc = new Scanner(System.in);
      	long X = Math.abs(sc.nextLong());
     	long K = sc.nextLong(); //回数
		long D = sc.nextLong(); //移動距離
      	
      	long min_d = X % D;      
      	long req_k = X / D;
      
      	if(min_d > D / 2){
          min_d = D - min_d;
          req_k++;
        }
      
      	if(K == req_k){
        	System.out.println(min_d);
        }else if( K > req_k){
        	if((K - req_k) % 2 == 0){
            	System.out.println(min_d);
            }else{
            	System.out.println(D - min_d);
            }
        }else{
          System.out.println(X - K * D);
        }
	}
}

Measured memory_bytes: 35932
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
using namespace std;
/*
#define int ll
#define double long double
*/
vector<bool> to_check;

struct Node {
public:
	int self_number;
	vector<pair<int, int>> to_child; // first = node_Number, second = cost;
};

int main() {
	int N, M; cin >> N >> M;
	to_check.resize(N, true);
	vector<int> height(N);
	rep(i, N) cin >> height[i];

	for (int i = 0; i < M; i++) {
		int a, b; cin >> a >> b; a--; b--;
		if (height[a] >= height[b]) {
			to_check[b] = false;
		}

		if (height[b] >= height[a]) {
			to_check[a] = false;
		}
	}

	int cnt = 0;
	rep(i, N) {
		if (to_check[i] == true) {
			cnt++;
		}
	}

	cout << cnt << endl;

}

Measured memory_bytes: 3740
#include<iostream>
#include<vector>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>

using namespace std;

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define all(x) (x).begin,(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}


int main(){
  int x;
  cin >> x;
  if(x==3 || x==5 || x==7) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


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


int main()
{
	long long int mul=1,a,b,c;
long long int n,k,l; scanf("%lld %lld",&n,&k); l=k;
if(k%2==0){k/=2;}
a=n/k;
mul=a*a*a;
if(l%2==1){
printf("%lld",mul); return 0;}
b=a/2; c=a-b;
mul=b*b*b+c*c*c;
printf("%lld",mul); 





return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>

using namespace std;

long long k, a, b;


int main()
{
	scanf("%lld%lld%lld", &k, &a, &b);
	
	long long maxNum = 1 + k;
	if ((a + 2) > b)	//做变换不赚的情况 
	{
		printf("%lld\n", maxNum);
		return 0;
	}
	
	long long newNum = 1;
	long long leftOper = k;
	if (leftOper > (a - 1))
	{
		leftOper = leftOper - (a - 1);
		newNum = a;
	}
	else
	{
		printf("%lld\n", maxNum);
		return 0;
	}
	
	long long changeTime = leftOper / 2;
	newNum = newNum + leftOper % 2;
	
	newNum = newNum + (b - a) * changeTime;
	
	if (newNum > maxNum)
		printf("%lld\n", newNum);
	else
		printf("%lld\n", maxNum);


	return 0;
}

//饼干到钱的转换，A+2<=B的情况下才赚 


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
const int MOD=1000000007;
const int nmax=3123;
int n,dp[2][nmax],res,nw,nx=1;
char s[nmax];
void add(int &a, int b) { a += b; if(MOD <= a) a -= MOD; }
int main(){
    scanf("%d",&n);
    scanf("%s",s+1);
    dp[0][1]=1;
    for(int i=2; i<=n; ++i){
        if(s[i-1]=='<'){
            dp[nx][1]=0;
            for(int j=2,s=0; j<=i; ++j){
                add(s,dp[nw][j-1]);
                dp[nx][j]=s;
            }
        }
        else
            for(int j=i-1,s=0; j>0; --j){
                add(s,dp[nw][j]);
                dp[nx][j]=s;
            }
        nw=1-nw;
        nx=1-nx;
    }
    for(int i=1; i<=n; ++i)
        add(res,dp[nw][i]);
    printf("%d",res);
    return 0;
}


Measured memory_bytes: 256
from heapq import heapify, heappush as hpush, heappop as hpop
N, M, S = map(int, input().split())
k = 2451
X = [[] for _ in range(N * k)]
for _ in range(M):
    u, v, a, b = map(int, input().split())
    u, v = u-1, v-1
    for i in range(a, k):
        X[u * k + i].append([v * k + i - a, b])
        X[v * k + i].append([u * k + i - a, b])

for i in range(N):
    c, d = map(int, input().split())
    for j in range(k - 1):
        X[i * k + j].append([i * k + min(j + c, k - 1), d])

def dijkstra(n, E, i0=0):
    h = [[0, i0]]
    D = [-1] * n
    done = [0] * n
    D[i0] = 0
    
    while h:
        d, i = hpop(h)
        done[i] = 1
        for j, w in E[i]:
            nd = d + w
            if D[j] < 0 or D[j] > nd:
                if done[j] == 0:
                    hpush(h, [nd, j])
                    D[j] = nd
    return D

D = dijkstra(N * k, X, min(S, k - 1))
print(*[min(D[i * k:(i+1) * k]) for i in range(N)][1:], sep = "\n")

Measured memory_bytes: 156376
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
flag = False
for i in range(N - M + 1):
    for j in range(N - M + 1):
        if [r[j: j+M] for r in A[i: i+M]] == B:
            flag = True
            break
    if flag:
        break
print('Yes' if flag else 'No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long

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

    int a, b, s1, s2;
    cin >> a >> b;
    if(a < b) {
        for(int i = 0; i < b; i++)
            cout << a;
    } else {
        for(int i = 0; i < a; i++)
            cout << b;
    }

    return 0;
}


Measured memory_bytes: 3472
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: u64, k: u64, a: [u64; n]);

    for i in 0..(n - k) {
        if a[i as usize] < a[(i + k) as usize] {
            println!("{}", "Yes");
        } else {
            println!("{}", "No");
        }
    }
}


Measured memory_bytes: 5568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll n;
  cin >> n;
  vector <ll> v(n), u(n);
  rep(i, n) cin >> v.at(i);
  rep(i, n) cin >> u.at(i);
  ll res = 0;
  rep(i, n) {
    if (v.at(i) > u.at(i)) res += v.at(i)-u.at(i);
  }
  cout << res << endl;
}

Measured memory_bytes: 256
package main

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

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	stdin.Split(bufio.ScanWords)
	var A, B int
	var S, T, U string
	
	S = nextStr()
	T = nextStr()
	A = nextInt()
	B = nextInt()
	U = nextStr()	
	
	if U == S {
		A--
	}
	if U == T {
		B--
	}
	fmt.Println(A, B)
}

func nextInt() int {
	stdin.Scan()
	i, err := strconv.Atoi(stdin.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextStr() string {
	stdin.Scan()
	i := stdin.Text()
	return i
}


Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.TreeSet;
import java.util.function.Supplier;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main{
	static Scanner s=new Scanner(System.in);

	void solve(){
		int n=gInt();
		int[]dp=new int[n+1];
		TreeSet<Integer>tl=new TreeSet<>();
		for(int i=1;i<=9;++i) {
			tl.add((int)Math.pow(9,i));
			tl.add((int)Math.pow(6,i));
		}
		tl.add(1);
		
		System.err.println(tl);
		
		Arrays.setAll(dp,i->i);
		for(Integer i=tl.floor(n);i!=null;i=tl.lower(i)) {
			for(int j=0;j<=n-i;++j) {
				dp[j+i]=Math.min(dp[j]+1,dp[j+i]);
			}
		}
		System.out.println(dp[n]);
	}

	public static void main(String[] A){
		new Main().solve();
	}

	static int gInt(){
		return Integer.parseInt(s.next());
	}
	static long gLong(){
		return Long.parseLong(s.next());
	}
	static double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,Main::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,Main::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,Main::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(Main::gInt).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}
class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int			t;
	Supplier<T>	supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}
class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}

	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}

}

Measured memory_bytes: 28372
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll h,w,d;
    ll a[320][320];
    Fill(a,0);
    std::cin >> h>>w>>d;
    map<ll,pair<ll,ll>> koko;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            std::cin >> a[i][j];
            koko[a[i][j]] = {i,j};
        }
    }
    ll q;
    std::cin >> q;
    
    map<ll,vector<ll>> before;
    
    for (int i = 1; i <=d; i++) {
        ll val = 0;
        before[i].push_back(0);
        while(true){
            val++;
            ll next = val*d+i;
            if(next>h*w)break;
            ll dis = (ll)abs(koko[next].first - koko[next-d].first)+(ll)abs(koko[next].second - koko[next-d].second);
            // std::cout << i<<" "<< dis+before[i][val-1]<<" "<<next<< std::endl;
            before[i].push_back(dis+before[i][val-1]);
        }
    }
    
    for (int i = 0; i < q; i++) {
        ll l,r;
        std::cin >> l>>r;
        if(l==r){
            std::cout << 0 << std::endl;
            continue;
        }
        if(l%d==0){
            // std::cout << before[d][r/d-1]<<" "<<before[d][l/d-1] << std::endl;
            std::cout << before[d][r/d-1]-before[d][max((ll)0,l/d-1)] << std::endl;
        }else{
            // std::cout << before[l%d][r/d]<<" "<<before[l%d][max((ll)0,l/d-1)] << std::endl;
            std::cout << before[l%d][r/d]-before[l%d][max((ll)0,l/d)] << std::endl;
        }
        
    }
}


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

using namespace std;

const int MAXN = 1000 * 1000 + 10;

int arr[MAXN];

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //cout << fixed << setprecision(10);

    string s;
    cin>> s;
    long long sum =0;
    for(int i=0;i<s.size();i++){
        sum += s[i]-'0';
    }
    if(sum%9==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3760
N, M = map(int, input().split())

wars = [tuple(map(int, input().split())) for _ in range(M)]
wars.sort()

ans = 0
right = -1

for a, b in wars:
    if a >= right:
        ans += 1
        right = b
    else:
        right = min(right, b)

print(ans)

Measured memory_bytes: 17136
#include <stdio.h>

int main(void){

    int a, b, ans;
    scanf("%d %d", &a, &b);

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

    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=250001;


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

    ll n;
    cin>>n;
    vector<pi> ar(n);
    for(ll i=0;i<n;++i)
    {
    	cin>>ar[i].second>>ar[i].first;
    }
    sort(ar.begin(),ar.end());
    ll cur=0;
    for(ll i=0;i<n;++i)
    {
    	if(cur+ar[i].second<=ar[i].first)
    	{
    		cur+=ar[i].second;
    	}
    	else
    	{
    		cout<<"No";return(0);
    	}
    }
    cout << "Yes" << endl;

	return(0);
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}

int main(){
  int d,g;
  cin >> d >> g;
  vector<int>p(d);
  vector<int>c(d);
  rep(i,d) cin >> p[i] >> c[i];
    
  ll ans = INFL;
  for(int bit = 0;bit < (1<<d); bit++){
    ll sum = 0,num = 0,rest_max = -1;
    rep(i,d){
      if(bit & (1<<i)){
        sum += c[i] + p[i]*100*(i+1); //bonus含めて決め打ち
        num += p[i];
      }
      else rest_max = i;
    }
    if(sum<g){
      int sum1 = 100*(rest_max+1);
      int need = (g-sum+sum1-1)/sum1;  //最低個数は繰り上がりなので
      if(need>=p[rest_max]) continue;  //超えたらbit選定からやり直し
      num += need;
    }
    ans = min(ans,num);
  }
  cout << ans << endl;  
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
//#define _CRTDBG_MAP_ALLOC
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t ll;
typedef uint64_t ull;

const ll LINF = 9187201950435737471;
const ll nLINF = -9187201950435737472;
const int INF = 2139062143;
const int nINF = -2139062144;
const ull ULINF = numeric_limits<ull>::max();
const int MAXN = 2e4 + 15;
const ll MOD = 1e9  ;
const double EPS = 1e-9;
const double PI = acos(-1);
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rnd(seed);

#define all(_v) _v.begin(), _v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) (int)(v.size())
#define sqr(_v) (_v * _v)
#define vi vector <int>
#define vii vector <pair <int, int> >
#define eb emplace_back
#define pb push_back


inline void IO() {
#if(DEBUG_LEVEL > 0)
    freopen("../input.txt", "r", stdin);
    freopen("../out.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
}

template <typename T>
istream& operator >> (istream& in, vector<T>& a) {
    for (auto& i : a)
        in >> i;
    return in;
}

template <typename T>
ostream& operator << (ostream& out, const vector<T>& a) {
    for (auto& i : a) {
        out << i << " ";
    }
    return out;
}

template <typename T, typename D>
istream& operator >> (istream& in, pair<T, D>& a) {
    in >> a.first >> a.second;
    return in;
}

template <typename T, typename D>
ostream& operator << (ostream& out, const pair<T, D>& a) {
    out << a.first << " " << a.second;
    return out;
}

inline void solve() {
    int n;
    cin >> n;
    set <int> all;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        all.insert(x);
    }
    if (sz(all) == n) {
        cout << "YES";
    }
    else {
        cout << "NO";
    }
}

signed main() {
    IO();
    int t = 1;
   // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

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

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
	int N, K;
	cin >> N >> K;
	vector<ll> A(N);
	rep(i,N)cin >> A[i];
	sort(all(A));
	ll ans = 0;
	COMinit();
	rep(i,N){
		ll bk = i;
		ll ft = N-i-1;
		if(bk >= K-1)ans += (COM(bk, K-1) * A[i]) % MOD;
		if(ft >= K-1)ans -= (COM(ft, K-1) * A[i]) % MOD;
		ans %= MOD;
	}
	if(ans < 0)ans += MOD;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 15892
N = int(input())
li = list(map(int,input().split()))
li.reverse()

dp = [0]*N

for i in range(N-1):
  if li[i+1] >= li[i]:
    dp[i+1] = dp[i]+1
  else:
    dp[i+1] = 0
    
print(max(dp))



Measured memory_bytes: 15020
N,M,X = input().split(" ")
A  = input().split(" ")

N,M,X = int(N),int(M),int(X)

costN = 0

x = X 
while x <= N:
    if str(x) in A:
        costN += 1
    x += 1 

cost0 = 0
x = X
while 0 <= x:
    if str(x) in A:
        cost0 += 1
    x -= 1


print(min(costN, cost0))
    




Measured memory_bytes: 3060