akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

void solve() {
    ll a, b, c, d, n, k, x,l;
    string s, t;
    ll ans = 0;
    double dans = 0;
    string sans = "Good";

    cin  >> a >> b;
    ans = (3*a+b) /2;

    std::cout << ans << endl; 
    // std::cout << sans << endl; 
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}


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

int main() {
    string S; cin >> S;
    int red = 0;
    int blue = 0;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == '0') red++;
        else blue++;
    }
    int remove_num = min(red, blue);

    cout << remove_num * 2 << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> h(n);
	for(int i = 0; i < n; i++)cin >> h[i];
	vector<int> dp(100100 , 0);
	for(int i = 1; i < n; i++){
		if(i == 1){
			dp[i] += abs(h[i] - h[i - 1]);
		}else{
			dp[i] += min(abs(h[i] - h[i - 1]) + dp[i - 1] , abs(h[i] - h[i - 2]) + dp[i - 2]);
		}
	}
	cout << dp[n - 1] << endl;
	
	return 0;
}
 


Measured memory_bytes: 4048
#include<cstdio>
#include<queue>
using namespace std;
int main() {
    deque<char> q;
    char c;
    int ans=0;
    while(scanf("%c",&c)>0) {
        if(c<'a' || c>'z') break;
        q.push_back(c);
    }
    while(q.size()>1) {
        if(q.front()==q.back()) {
            q.pop_back();
            q.pop_front();
        }
        else if(q.front()=='x') {
            q.pop_front();
            ans++;
        } else if(q.back()=='x') {
            q.pop_back();
            ans++;
        } else return 0*printf("-1\n");
    }
    printf("%d\n",ans);
    return 0;
}

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


def solve(N: int, M: int, L: "List[int]", R: "List[int]"):
    print(max(min(R) - max(L) + 1, 0))
    return


# 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()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    L = [int()] * (M)  # type: "List[int]" 
    R = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        L[i] = int(next(tokens))
        R[i] = int(next(tokens))
    solve(N, M, L, R)

if __name__ == '__main__':
    main()


Measured memory_bytes: 10868
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
            }
            int ans = 0;
            while (true) {
                int count = 0;
                for (int i = 0; i < n; i++) {
                    if (arr[i] > 0) {
                        arr[i] = arr[i] - 1;
                        if (i < n - 1 && arr[i + 1] == 0) {
                            break;
                        }
                    } else if (arr[i] == 0) {
                        count++;
                    }
                }
                if (count == n) {
                    break;
                }
                ans++;
            }
            out.println(ans);
        }
    }

    static boolean permutation_2(String s, String t) {
        if (s.length() != t.length()) {
            return false;
        }

        int[] letters = new int[256];

        char[] s_array = s.toCharArray();
        for (char c : s_array) {
            letters[c]++;
        }

        for (int i = 0; i < t.length(); i++) {
            int c = (int) t.charAt(i);
            if (--letters[c] < 0) {
                return false;
            }
        }
        return true;
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public char nextChar() {
            return next().charAt(0);
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}


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

int main(void)
{
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
    sort(d.begin(), d.end());
    int answer;
    if (d[n/2-1] == d[n/2]) answer = 0;
    answer = d[n/2] - d[n/2-1];
    cout << answer << endl;
}


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

using namespace std;

typedef long long ll;

const int MAX_N = 2e5 + 10;
const ll MOD = 1e9 + 7;

int N, M, K;
bool S[MAX_N];

void init() {
    scanf("%d%d", &N, &M);
    static char _S[MAX_N];
    scanf("%s", _S + 1);
    for (int i = 1; i <= M; i++) S[i] = _S[i] == 'R';
    for (int i = M; i; i--) S[i] ^= S[1];
    K = N | 1;
    int curr = 0;
    bool first = true;
    for (int i = 1; i <= M; i++) {
        if (S[i]) {
            if (curr & 1) {
                K = min(K, curr);
            } else {
                if (first) K = min(K, curr + 1);
            }
            first = false;
            curr = 0;
        } else curr++;
    }
    if (first) {
        static ll fib[MAX_N];
        fib[1] = fib[2] = 1;
        for (int i = 3; i <= N + 1; i++) (fib[i] = fib[i - 1] + fib[i - 2]) %= MOD;
        ll ans = (2 * fib[N + 1] - fib[N] + MOD) % MOD;
        printf("%lld\n", ans);
        exit(0);
    }
}

ll f[MAX_N], pre[MAX_N];
void solve() {
    f[0] = pre[0] = 1;
    for (int i = 1; i <= N; i++) {
        f[i] = ((i - 2 >= 0 ? pre[i - 2] : 0) - (i - K - 3 >= 0 ? pre[i - K - 3] : 0) + MOD) % MOD;
        pre[i] = (i >= 2 ? pre[i - 2] + f[i] : f[i]) % MOD;
    }
    ll ans = 0;
    for (int i = 1; i <= min(K + 1, N); i++) {
        int l = N - (K + 1), r = N - (i + (i & 1));
        (ans += pre[r] - (l - 2 >= 0 ? pre[l - 2] : 0) + MOD) %= MOD;
    }
    printf("%lld\n", ans);
}

int main() {
    init();
    solve();
}


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

int main () {
  int N, A, B;
  cin >> N >> A >> B;
  cout << min(N*A, B) << endl;
  return 0;
}


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

int main() {
    int n[4];
    int a=1, b=9, c=7, d=4;
    for(int i=0;i<4;i++){
        cin >> n[i];
    }
    for(int i=0;i<4;i++) {
        if (n[i] == a) {
            a = -1;
        }
        if (n[i] == b) {
            b = -1;
        }
        if (n[i] == c) {
            c = -1;
        }
        if (n[i] == d) {
            d = -1;
        }
    }
    if(a==-1&&b==-1&&c==-1&&d==-1) {
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
int fav = 753;
int min =1000;
for (int i = 0; i < s.size()-2; i++)
{
  int x = stoi(s.substr(i, 3));
  if(abs(x-fav)<min) min =abs(x-fav);
}
cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
T, A = list(map(int, input().split(" ")))
H = list(map(int, input().split(" ")))

def getTemperature(H):
  return T - H * 0.006

def adjustAbs(H):
  if H > A:
    return abs(H - A)
  else:
    return abs(A - H)

H = list(map(getTemperature, H))

H = list(map(adjustAbs, H))

print(H.index(min(H))+1)

Measured memory_bytes: 9200
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <map>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<int> p(N);
  for (auto& pi: p) scanf("%d", &pi);

  if (std::is_sorted(p.begin(), p.end())) return puts("YES"), 0;

  for (size_t i = 0; i < N; ++i)
    for (size_t j = 0; j < i; ++j) {
      std::swap(p[i], p[j]);
      if (std::is_sorted(p.begin(), p.end())) return puts("YES"), 0;
      std::swap(p[i], p[j]);
    }
  puts("NO");
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
    int x,y;
    cin >>x>>y;
    if(x<=y){
        cout << min(abs(y-x),abs(y+x)+1) << endl;
    }else{
        cout<<min(abs(-y-x)+1,abs(-y+x)+2) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  if (a >= k)
    cout << k << endl;
  else if (a+b >= k)
    cout << a << endl;
  else
    cout << (a-(k-a-b)) << endl;
}


Measured memory_bytes: 3564
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		//入力データを変数で受け取る
		int n = sc.nextInt();

		List<Integer> list = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			list.add(sc.nextInt());
		}

		//入力データを処理して、結果を出力
		int sum = 0;
		for(int i : list) {
			sum += i;
		}

		if(sum % 2 == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	}
}



Measured memory_bytes: 59976
h,n=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]
dp=[10**9]*(h+max(l)[0])
dp[0]=0
for i in range(1,len(dp)):
  for a,b in l:
    if i-a>=0:
      dp[i]=min(dp[i],dp[i-a]+b)
print(min(dp[h:]))

Measured memory_bytes: 42844
#include <bits/stdc++.h>
//#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

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

#define N 1005
ll h,w;
string s[N];
bool valid(ll i,ll j){
    if(0<=i&&i<=h-1&&0<=j&&j<=w-1)return true;
    return false;
}
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

int main(){fastio
    cin>>h>>w;
    rep(i,0,h-1)cin>>s[i];
    ll ans[h][w];rep(i,0,h-1)rep(j,0,w-1)ans[i][j]=inf;
    queue<l_l>q;
    rep(i,0,h-1)rep(j,0,w-1){
        if(s[i][j]=='#'){
            q.push({i,j});
            ans[i][j]=0;
        }
    }
    while(!q.empty()){
        l_l t=q.front();q.pop();
        rep(i,0,3){
            ll nx=t.fi+dx[i];
            ll ny=t.se+dy[i];
            if(valid(nx,ny)){
                if(ans[nx][ny]==inf){
                    q.push({nx,ny});
                    ans[nx][ny]=ans[t.fi][t.se]+1;
                }
            }
        }
    }
    ll re=0;
    rep(i,0,h-1)rep(j,0,w-1)Max(re,ans[i][j]);
    cout<<re<<endl;
    
    return 0;
}


Measured memory_bytes: 25524
#include <stdio.h>
int main()
{
    int t,f;
    scanf("%d",&t);
    scanf("%d",&f);
    if(t==1&&f==2)
        printf("3\n");
    else if(t==1&&f==3)
        printf("2\n");
    else if(t==2&&f==1)
        printf("3\n");
    else if(t==2&&f==3)
        printf("1\n");
    else if(t==3&&f==1)
        printf("2\n");
    else if(t==3&&f==2)
        printf("1\n");
    return 0;
}


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

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

signed main(void) 
{
    ll n;
    cin >>n;
    vll h(n);
    ll ma = 0;
    rep(i, n) {
        cin >>h[i];
        ma = max(ma, h[i]);
        if (h[i] <= ma-2) {
            mes("No");
            re0;
        }
        
    }
    mes("Yes");

}


Measured memory_bytes: 4068
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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








int main(){
    long long N; std::cin >> N;
    std::vector<int> digit;
    while(N){
        digit.push_back((N-1) % 26);
        N = (N-1) / 26;
    }
    std::reverse(std::begin(digit), std::end(digit));
    for(int i(0), i_len(digit.size()); i < i_len; ++i){
        std::cout << (char)(digit[i] + 'a');
    }
    std::cout << std::endl;
    return 0;
}


Measured memory_bytes: 3628
N = int(input())
h = list(map(int, input().split()))

INF = 10**4 + 1
dp = [INF] * N
dp[0] = 0
dp[1] = abs(h[0] - h[1])

for i in range(N-2):
    dp[i+2] = min(dp[i+1]+abs(h[i+1]-h[i+2]), dp[i]+abs(h[i]-h[i+2]))

print(dp[-1])

Measured memory_bytes: 13928
#    !/usr/bin/env python3
#    encoding: UTF-8
#    Last Modified: 19/Oct/2019 05:35:13 PM


#    ✪ H4WK3yE乡
#    Mohd. Farhan Tahir
#    Indian Institute Of Information Technology (IIIT), Gwalior


import sys
import os
from io import IOBase, BytesIO


def main():
    n = int(input())
    s = list(input())
    i = 0
    j = ""
    ans = 0
    while i != n:
        if s[i] == j:
            i += 1
        else:
            j = s[i]
            ans += 1
            i += 1
    print(ans)


BUFSIZE = 8192


class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill():
            pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill()
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        py2 = round(0.5)
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2 == 1:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s: self.buffer.write(s.encode("ascii"))
            self.read = lambda: self.buffer.read().decode("ascii")
            self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def get_array():
    return list(map(int, sys.stdin.readline().split()))


def get_ints():
    return map(int, sys.stdin.readline().split())


def input():
    return sys.stdin.readline().strip()


if __name__ == "__main__":
    main()


Measured memory_bytes: 50160
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;



int main(){
  int n;
  cin >> n;
  vector<int> a;
  rep(i, n){
    int x;
    cin >> x;
    if (x>0) a.push_back(x-1);
    a.push_back(x);
    a.push_back(x+1);
  }
  sort(ALL(a));

  int ans = 0;
  int tmp = a[0];
  int c = 1;
  for (int i = 1; i < a.size(); i++){
    if (a[i] == tmp) c++;
    else {
      ans = max(ans, c);
      c = 1;
      tmp = a[i];
    }
  }
  ans = max(ans, c);
  cout << ans << endl;
}

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

const int N = 20;
int n, m;
ll x, c[N], a[N][N];

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m >> x;
    for(int i = 0; i < n; i++) {
        cin >> c[i];
        for(int j = 0; j < m; j++)
            cin >> a[i][j];
    }

    ll ans = 1e18;
    for(int i = 1; i < (1<<n); i++) {
        ll cur[m+5]; memset(cur, 0, sizeof cur);
        ll cost = 0;
        for(int j = 0; j < n; j++) {
            if(i&(1<<j)) {
                for(int k = 0; k < m; k++)
                    cur[k] += a[j][k];
                cost += c[j];
            }
        }

        bool ok = 1;
        for(int j = 0; j < m && ok; j++)
            if(cur[j] < x) ok = 0;

        if(ok)
            ans = min(ans, cost);
    }

    cout << ((ans==1e18)?(-1):(ans)) << '\n';

    return 0;
}

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

#define int long long
#define endl "\n"
#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 RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    int N,K;
    scanf("%lld",&N);
    scanf("%lld",&K);
    Vi A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    Vi F(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&F[i]);
    }

    sort(ALL(A));
    sort(ALL(F),greater<int>());

    int sum=0;
    REP(i,0,N) sum+=A[i];
    if(sum<=K) {cout<<0<<endl;return 0;}

    int low=0,high=INF;
    while(high-low>1){
        int mid=(low+high)/2;
        int need=0;
        REP(i,0,N){
            int power=mid/F[i];
            int aneed=max(0LL,A[i]-power);
            need += aneed;
        }
        if(need<=K) high=mid;
        else low=mid;
    }
    cout<<high<<endl;

    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template <typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
    for(auto &e:t) fill_v(e,v);
}
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 (a > b) { a = b; return 1;}
    return 0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string S;
    cin >> S;
    REP(i,SZ(S)){
        int cur = S[i] - 'A';
        cur += N;
        cur %= 26;
        cout << (char)('A' + cur);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3660
import sys
sys.setrecursionlimit(10**6)
def dfs(v,p,d):
    for i, j in tree[v]:
        if i != p:
            depth[i] = d + j
            dfs(i,v,d+j)

N = int(input())

tree = [[] for _ in range(N)]

for i in range(N-1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    tree[a].append((b,c))
    tree[b].append((a,c))

Q, K = map(int, input().split())

depth = [0 for i in range(N)]
depth[K-1] = 0

dfs(K-1,-1,0)

for _ in range(Q):
    x, y = map(int, input().split())
    print(depth[x-1] + depth[y-1])

Measured memory_bytes: 135740
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int n, d, cnt=0;
	cin >> n >> d;
	long double a[n], b[n];
	for(int i=0; i<n; ++i)
	{
		cin >> a[i] >> b[i];
		long double res=sqrt(a[i]*a[i]+b[i]*b[i]);
		if(res<=d) ++cnt; 
	}
	cout << cnt << endl;
	return 0; 
}

Measured memory_bytes: 9984
#![allow(non_snake_case)]

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_tuple<T: std::str::FromStr + Copy>() -> (T, T, T, T, T) {
    let v: Vec<T> = read_vec();
    (v[0], v[1], v[2], v[3], v[4])
}

fn main() {
    let (mut A, mut B, C, mut X, mut Y) = read_tuple::<i32>();
    if X < Y {
        std::mem::swap(&mut A, &mut B);
        std::mem::swap(&mut X, &mut Y);
    }
    let ans = (0..X+1).map(|i|
        C*i*2 + A*(X-i) + B*std::cmp::max(0, Y-i)
    ).min().unwrap();
    println!("{}", ans);
}


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

int main(){
  int n;
  cin>>n;
  int v[n];
  
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  
  sort(v,v+n);
  
  cout<<v[n-1]-v[0]<<endl;
  return 0;
}
  

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define N 110
int m[N][N];
int n;
int main(){
    for(int i = 0 ; i <= n; i++) for(int j = 0; j <= n; j++) m[i][j] = 0;
    scanf("%d", &n);
    for(int p = 0; p < n; p++){
        int node, k;
        scanf("%d %d", &node, &k);
        for(int i = 0; i < k; i++){
            int b;
            scanf("%d", &b);
            m[node][b] = 1;
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(j != n) printf("%d ", m[i][j]);
            else printf("%d\n", m[i][j]);
        }
    }
    return 0;
}


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

int main(){
	int N, D;
	cin >> N >> D;
	int canI = 2 * D + 1;
	if(N % canI == 0){
		cout << N / canI << endl;
	} else {
		int ans = (N / canI) + 1;
		cout << ans << endl;
	}
}

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

int main(){

	int x,y;
	cin >> x >> y;
	int box[110][110];

	for(int i=0;i<x;i++){
		for(int k=0;k<y;k++){
			cin >> box[i][k];
			box[i][y] += box[i][k];
			box[x][k] += box[i][k];
		}
		box[x][y] += box[i][y];
	}

	for(int i=0;i<=x;i++){
		for(int k=0;k<=y;k++){
			if(k != y)	cout << box[i][k] << " ";
			else cout << box[i][k] << endl;
		}
	}

	return 0;
}



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

const int MAXN = 200005;

int N;
long long A[MAXN];
long long Answer[MAXN];

void Read() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);

  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
  }
}

bool used[MAXN];
long long pref[MAXN][2]; // (even, odd) only

void Solve() {
  priority_queue<pair<long long, pair<int, int>>> pq;
  set<int> unused;

  for (int i = 1; i <= N; i++) {
    pq.push({A[i], {i, i + 1}});
  }

  for (int i = 0; i <= N + 2; i++) {
    unused.emplace(i);
  }

  for (int i = 1; i <= N + 2; i++) {
    pref[i][0] = pref[i - 1][0];
    pref[i][1] = pref[i - 1][1];
    pref[i][i & 1] += A[i];
  }

  int num = 0;
  long long ans = 0;

  while (!pq.empty()) {
    long long w = pq.top().first;
    int u = pq.top().second.first;
    int v = pq.top().second.second;
    pq.pop();
    if (used[u] || used[v]) continue;

    used[u] = true, used[v] = true;
    unused.erase(u);
    unused.erase(v);

    Answer[++num] = (ans += w);

    int L = *prev(unused.lower_bound(u));
    int R = *unused.lower_bound(v);

    if (1 <= L && R <= N + 1) {
      long long NotTakeUV = (pref[R - 1][L & 1] - pref[L - 1][L & 1]);
      long long TakeUV = (pref[R - 1][(L & 1) ^ 1] - pref[L - 1][(L & 1) ^ 1]);
      pq.push({NotTakeUV - TakeUV, {L, R}});
    }
  }
}

void Write() {
 cout << Answer[N/2];
}

int main() {
  Read();
  Solve();
  Write();
  return 0;
}


Measured memory_bytes: 21444
def main():
    n,m = map(int,input().split())
    ab=[]
    for _ in range(m):
        ab.append(list(map(int,input().split())))
    ab.sort()
    Right=ab[0][1]
    cnt=1
    for i in range(m):
        if ab[i][1]<Right:
            Right=ab[i][1]
        if Right<=ab[i][0]:
            cnt+=1
            Right=ab[i][1]
    print(cnt)
if __name__ == "__main__":
    main()

Measured memory_bytes: 62256
def isValid(row, col, ROWS, COLS):
    return row >= 0 and row < ROWS and col >= 0 and col < COLS

def isSteep(board, row, col, ROWS, COLS):
    global adjR, adjC

    h = board[row][col]
    for i in range(4):
        rr = row + adjR[i]
        cc = col + adjC[i]
        if isValid(rr, cc, ROWS, COLS):
            diff = abs(h - board[rr][cc])
            if diff > 1:
                return True
    return False

def update(board, row, col, ROWS, COLS):
    global adjR, adjC, given
    arr = []

    h = board[row][col]
    for i in range(4):
        rr = row + adjR[i]
        cc = col + adjC[i]
        if (rr, cc) in given:
            continue
        if isValid(rr, cc, ROWS, COLS):
            if board[rr][cc] == None or board[rr][cc] < h - 1:
                board[rr][cc] = h - 1
                arr.append((rr, cc))
    return arr

if __name__ == '__main__':
    COLS, ROWS, N = list(map(int, input().split()))

    board = [ [ None for _ in range(COLS) ] for _ in range(ROWS) ]
    plist = []

    adjR = [-1, 0, 0, 1]
    adjC = [0, -1, 1, 0]

    given = set()

    for _ in range(N):
        c, r, h = list(map(int, input().strip().split()))
        board[r - 1][c - 1] = h
        plist.append((r-1, c-1))
        given.add((r-1, c-1))

    while len(plist) > 0:
        row, col = plist.pop(0)
        updated = update(board, row, col, ROWS, COLS)
        plist.extend(updated)

    isPossible = True
    total = 0
    for r in range(ROWS):
        for c in range(COLS):
            isPossible = isPossible and not isSteep(board, r, c, ROWS, COLS)
            if not isPossible:
                break
            total += board[r][c]
        if not isPossible:
            break

    print(total if isPossible else "No")


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

void Pisz(vector<int>& a, int k)
{
    if (k == a.size())
        return;
    vector<bool> jest(200010, false);
    vector<int> x;
    for (int i = k; i < a.size(); ++i)
    {
        if (!jest[a[i]])
        {
            jest[a[i]] = true;
            x.push_back(a[i]);
        }
        else
        {
            while (x.back() != a[i])
            {
                jest[x.back()] = false;
                x.pop_back();
            }
            jest[x.back()] = false;
            x.pop_back();
        }
    }
    if (x.size() != 0)
        for (int i = 0; i < x.size(); ++i)
            cout << x[i] << " ";
}

int main()
{
    ios_base::sync_with_stdio(0);
    ll n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    vector<int> nast(200010, INF);
    vector<int> zacz(n + 1);
    zacz[n] = -1;
    zacz[n - 1] = a[n - 1];
    nast[a[n - 1]] = n - 1;
    for (int i = n - 2; i >= 0; --i)
    {
        if (nast[a[i]] == INF)
            zacz[i] = a[i];
        else
        {
            int pos = nast[a[i]];
            if (pos == n - 1)
                zacz[i] = -1;
            else
                zacz[i] = zacz[pos + 1];
        }
        nast[a[i]] = i;
    }
    vector<int> pier(200010, INF);
    for (int i = 0; i < n; ++i)
        if (pier[a[i]] == INF)
            pier[a[i]] = i;
    vector<int> suf;
    vector<bool> odw(n + 1, false);
    int akt = 0;
    while (true)
    {
        odw[akt] = true;
        suf.push_back(akt);
        int Zacz = zacz[akt];
        int nast;
        if (Zacz == -1)
            nast = 0;
        else
        {
            int Pier = pier[Zacz];
            if (Pier == n - 1)
                nast = n;
            else
                nast = Pier + 1;
        }
        if (odw[nast])
        {
            suf.push_back(nast);
            break;
        }
        akt = nast;
    }
    int p = 0;
    while (suf[p] != suf.back())
        ++p;
    suf.pop_back();
    vector<int> s, c;
    for (int i = 0; i < p; ++i)
        s.push_back(suf[i]);
    for (int i = p; i < suf.size(); ++i)
        c.push_back(suf[i]);
    if (k <= (ll) s.size())
        Pisz(a, s[k - 1]);
    else
        Pisz(a, c[(k - (ll) s.size()) % (ll) c.size() - 1]);
    return 0;
}


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

long long n, gsb[3][2];
vector<vector<long long>> dp;

long long solve();

int main() {
  cin >> n;
  for(int i = 0; i < 2; ++i)
    for(int j = 0; j < 3; ++j) cin >> gsb[j][i];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  dp.assign(4, vector<long long>(n + 10, 0));
  for(int i = 0; i < 3; ++i)
    for(int j = 0; j <= n; ++j) {
      dp[i + 1][j] = dp[i][j];
      if(gsb[i][0] < gsb[i][1] && gsb[i][0] <= j)
        dp[i + 1][j] =
            max(dp[i + 1][j], dp[i + 1][j - gsb[i][0]] +
                                  gsb[i][1] - gsb[i][0]);
      ans = max(ans, dp[i + 1][j]);
    }
  n += ans;
  ans = 0;
  for(int i = 0; i < 3; ++i) swap(gsb[i][0], gsb[i][1]);
  dp.assign(4, vector<long long>(n + 10, 0));
  for(int i = 0; i < 3; ++i)
    for(int j = 0; j <= n; ++j) {
      dp[i + 1][j] = dp[i][j];
      if(gsb[i][0] < gsb[i][1] && gsb[i][0] <= j)
        dp[i + 1][j] =
            max(dp[i + 1][j], dp[i + 1][j - gsb[i][0]] +
                                  gsb[i][1] - gsb[i][0]);
      ans = max(ans, dp[i + 1][j]);
    }

  return ans + n;
}


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

int main() {
    int N;
    int cnt2 = 0;
    cin >> N;
    for(int i = 1; i <= N; i+=2)
    {
        int cnt1 = 0;
        for(int j = 1; j <= i; j++)
        {
            if(i % j == 0)
                cnt1++;
        }
        if(cnt1 == 8)
            cnt2++;
    }
    cout << cnt2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<class T> void re(T& x) { cin >> x; }
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
template<class H, class... T> void re(H& h, T&... t) { re(h); re(t...); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "/home/o_o/MyCodes/pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  

void solve(){
	int cnt = 0 ;
	int n ;re(n);
	fr(i,1,n){
		string s = to_string(i);
		if(sz(s)&1) cnt++;
	}
	cout << cnt << endl;
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3764
#include<string>
#include<iostream>
int n,k;
std::string s[4][7]={{"aacd","bbcd","cdaa","cdbb"},{"aa.ab",".bbab","a.cca","a.a.a","bbabb"},{"aacd..","bbcd..","cd..aa","cd..bb","..aacd","..bbcd"},{"aacd...","bbcd...","cd.aa..","cd...bb","..a.baa","..a.b.b","..bbaab"}};
int main()
{
    std::cin>>n,k=n&3;
    if(n<3) std::cout<<"-1\n";
    else if(n==3) std::cout<<"aab\nb.b\nbaa\n";
    else for(int i=0;i<n;++i)
	 {
	     std::string t(n,'.');
	     i<n-k-4? t.replace(i/4*4,4,s[0][i%4]):t.replace(n-k-4,k+4,s[k][i-n+k+4]);
	     std::cout<<t<<'\n';
	 }
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans=1,a[ohara],b[ohara],c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,suma[ohara+10],sumb[ohara+10];
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
unordered_map<ll,ll> syua;
unordered_map<ll,ll> syub;

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>m;
    rep(i,n)cin>>a[i],syua[a[i]]=1,suma[a[i]]++;
    rep(i,m)cin>>b[i],syub[b[i]]=1,sumb[b[i]]++;

    rrep(i,1,n*m+1){
        if(suma[i]>=2||sumb[i]>=2){
            Cout(0);
            return 0;
        }
    }

    rrrep(i,n*m,1){
        suma[i-1]+=suma[i];
    }
    rrrep(i,n*m,1){
        sumb[i-1]+=sumb[i];
    }
    sort(a,a+n);
    sort(b,b+m);
    rrrep(i,n*m,1){
        if(syua[i]==1&&syub[i]==1)continue;
        else if(syua[i]==1){
            tmp=sumb[i];
            (ans*=tmp)%=MOD;
        }
        else if(syub[i]==1){
            tmp=suma[i];
            (ans*=tmp)%=MOD;
        }
        else{
            tmp=suma[i];
            tmpp=sumb[i];
            (ans*=((tmp*tmpp-(n*m-i))%MOD))%=MOD;
        }
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 97696
#include <iostream>
#include <cstdio>
#include <map>
#include <vector>
#include <algorithm>
#define loop(i, N) for(int i=0; i<(N); ++i)
using namespace std;
int main() {
	for (;;) {
		vector<int> h(1), w(1), dp;
		int n, m, t, o= 0;
		cin >> n >> m;
		if (!n) return 0;
		loop(i, n) {
			cin >> t;
			o += t;
			h.push_back(o);
		}
		o = 0;
		loop(i, m) {
			cin >> t;
			o += t;
			w.push_back(o);
		}
		o = 0;
		dp.resize(std::max(h[n], w[m]) + 10);
		loop(i, n)
			for (int e = i; e < n; ++e)
				++dp[h[e + 1] - h[i]];
		loop(i, m) {
			for (int e = i; e < m; ++e) {
				t = w[e + 1] - w[i];
				if (dp[t]>0) o += dp[t];
			}
		}
		cout << o << endl;
	}
	return 0;
}

Measured memory_bytes: 5124
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

    private static final String YES = "Yes";
    private static final String NO = "No";

    public static String process(TestCase testCase) {
        final int N = testCase.N;
        final List<String> W = testCase.W;

        final Set<String> announced = new HashSet<>(Collections.singletonList(W.get(0)));

        return IntStream.range(1, N)
                .allMatch(i -> {
                    final String prev = W.get(i - 1);
                    final String curr = W.get(i);
                    final boolean notAnnounced = !announced.contains(curr);
                    final boolean charSatisfied = curr.charAt(0) == prev.charAt(prev.length() - 1);

                    announced.add(curr);
                    return notAnnounced && charSatisfied;
                })
                ? YES
                : NO;
    }

    // Util func

    public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final String result = process(testCase);

        output(result);
    }

    private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        final List<String> W = IntStream.range(0, N).mapToObj(i -> sc.next()).collect(Collectors.toList());

        return new TestCase(N, W);
    }

    private static void output(String result) {
        System.out.println(result);
    }

    public static class TestCase {
        final int N;
        final List<String> W;

        public TestCase(int N, List<String> W) {
            this.N = N;
            this.W = W;
        }
    }
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    int N; cin >> N;
    vector<ll> A(N);
    double pro = 1;
    REP(i,N){
        cin >> A[i];
        pro *= A[i];
    }
    double X = 0;
    REP(i,N) X += pro/A[i];
    cout << pro/X << endl;
    return 0;
}

Measured memory_bytes: 3776
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

string s[10000];
int cnt[2][26];

struct unionfind{
	vector<int> data;
	void use(int n){ data.assign(n, -1); }
	bool unionset(int x, int y){
		x = root(x); y = root(y);
		if(x != y){
			if(data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findset(int x, int y){ return root(x) == root(y); }
	int root(int x){ return (data[x] < 0) ? x : data[x] = root(data[x]); }
	int size(int x){ return -data[root(x)]; }
};

signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int(n);
    if(!n)break;
    scn(n, s);
    rep(i, 26)rep(j, 2)cnt[j][i] = 0;
    unionfind U;
    U.use(26);

    rep(i, n){
      ++cnt[0][s[i][0] - 'a'];
      ++cnt[1][s[i][s[i].size() - 1] - 'a'];
      U.unionset(s[i][0] - 'a', s[i][s[i].size() - 1] - 'a');
    }

    rep(i, 26)if(cnt[0][i] != cnt[1][i])break;
    bool is = (i == 26);
    rep(i, 26)rep(j, 26)if(cnt[0][i] > 0 && cnt[0][j] > 0){
      if(!U.findset(i, j))is = false;
    }
    puts(is ? "OK" : "NG");

//*/

//*/ break;
  }
  return 0;
}

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

a = []
for i in range(n):
    A, B = map(int, input().split())
    a.append([A, B])

b = sorted(a, key=lambda x: x[1])
# print(b)

t = 0
for i in range(n):
    t += b[i][0]
    if t > b[i][1]:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 39700