akhauriyash/Code-Regression huggingface dataset:
#define DEBUG 0

/**
 * File    : B.cpp
 * Author  : Kazune Takahashi
 * Created : 2019-5-28 11:38:19
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

string T = "ATCG";
string S;

int main()
{
  cin >> S;
  int ans = 0;
  int now = 0;
  for (auto i = 0; i < (int)S.size(); i++)
  {
    bool ok = false;
    for (auto j = 0; j < (int)T.size(); j++)
    {
      if (S[i] == T[j])
      {
        ok = true;
      }
    }
    if (!ok)
    {
      now = 0;
    }
    else
    {
      now++;
      ans = max(ans, now);
    }
  }
  cout << ans << endl;
}

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

#define fst first
#define snd second
const int MAXN = 510;
typedef pair<int, int> pii;

template<typename T> inline T read() {
	T x(0), f(1);
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1;
	for(; isdigit(ch); ch = getchar()) x = (x*10)+(ch^48);
	return x * f;
}

pii f[MAXN];
int ans[MAXN*MAXN], n;

int main() {
	int i, j;

	n = read<int>();
	for(i = 1; i <= n; i++) {
		f[i].fst = read<int>();
		f[i].snd = i;
	}

	sort(f+1, f+n+1);

	int l = 1;
	for(i = 1; i <= n; i++) {
		int loc = f[i].fst, id = f[i].snd;
		for(j = 1; j < id; j++) {
			ans[l] = id;
			while(ans[l]) l++;
		}
		if(l > loc) break;
		ans[loc] = id;
		while(ans[l]) l++;
	}
	if(i <= n) {
		printf("No\n");
		return 0;
	}
	l = n*n;
	while(ans[l]) l--;
	for(i = n; i >= 1; i--) {
		int loc = f[i].fst, id = f[i].snd;
		for(j = 1; j <= n-id; j++) {
			if(l < loc) break;
			ans[l] = id;
			while(ans[l]) l--;
		}
		if(j <= n-id) break;
	}
	if(i >= 1) {
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	for(i = 1; i <= n*n; i++) printf("%d ", ans[i]);
	printf("\n");
	return 0;
}


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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    string s, t; cin >> s >> t;

    int dp[1001][1001];
    fill( dp[0], dp[1001], INF );
    REP( i, 1001 ) dp[i][0] = dp[0][i] = i;

    REPONE( i, s.size() ){
        REPONE( j, t.size() ){
            if( s[i - 1] == t[j - 1] ){
                dp[i][j] = dp[i - 1][j - 1];
            }else{
                dp[i][j] = min( { dp[i - 1][j - 1], dp[i - 1][j], dp[i][j - 1] } );
                dp[i][j]++;
            }
        }
    }

    cout << dp[s.size()][t.size()] << endl;

}




Measured memory_bytes: 11044
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    a,b,x=map(int,input().split())
    print(b//x-(a-1)//x)

if __name__ == '__main__':
    main()


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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll A, B, C;
  cin >> A >> B >> C;
  if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0)
    cout << 0 << endl;
  else
  {
    ll sum = A * B * C;
    ll res1, res2, res3;
    res1 = A * B * (C / 2);
    res2 = A * (B / 2) * C;
    res3 = (A / 2) * B * C;
    ll ans = min(sum - res1 - res1, min(sum - res2 - res2, sum - res3 - res3));
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys


def intervals(n):
    results = []
    g = 1
    while g <= n:
        results.append(g)
        g = g * 3 + 1
    return list(reversed(results))


def insertion_sort(a, g):
    n = len(a)
    count = 0
    for i in range(g, n):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j + g] = a[j]
            j -= g
            count += 1
        a[j + g] = v
    return count


def shell_sort(a):
    n = len(a)
    count = 0
    gs = intervals(n)
    for g in gs:
        count += insertion_sort(a, g)
    print(len(gs))
    print(' '.join(map(str, gs)))
    print(count)
    for value in a:
        print(value)


n = int(sys.stdin.readline())
a = [int(sys.stdin.readline()) for _ in range(n)]
shell_sort(a)



Measured memory_bytes: 45516
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var ans = [];
var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next();
  dfs(n,0,"");
  return ans.join("\n");
}

function dfs(n,x,s){
  if(n === 0)return ans.push(s);
  for(var i = 0; i <= x; i++){
    dfs(n-1,Math.max(x,i+1),s+String.fromCharCode(97+i));
  }
}

Measured memory_bytes: 26956
package main

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

type point struct {
	h    int
	w    int
	step int
}

func main() {
	var h, w int
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d %d", &h, &w)

	queues := make([]point, 0, h*w)
	blackPoints := make(map[int]map[int]bool)
	white := h * w
	for i := 0; i < h; i++ {
		scanner.Scan()
		s := scanner.Text()
		blackPoints[i] = make(map[int]bool)
		for j, c := range s {
			if c == '#' {
				if _, ok := blackPoints[i]; !ok {
					blackPoints[i] = make(map[int]bool)
				}
				blackPoints[i][j] = true
				queues = append(queues, point{
					h:    i,
					w:    j,
					step: 0,
				})
				white--
			}
		}
	}

	if white == 0 {
		fmt.Println(0)
		return
	}

	var cur point
	for white > 0 {
		cur, queues = queues[0], queues[1:]
		i, j, step := cur.h, cur.w, cur.step

		if i > 0 && !blackPoints[i-1][j] {
			blackPoints[i-1][j] = true
			queues = append(queues, point{
				h:    i - 1,
				w:    j,
				step: step + 1,
			})
			white--
		}
		if i < h-1 && !blackPoints[i+1][j] {
			blackPoints[i+1][j] = true
			queues = append(queues, point{
				h:    i + 1,
				w:    j,
				step: step + 1,
			})
			white--
		}
		if j > 0 && !blackPoints[i][j-1] {
			blackPoints[i][j-1] = true
			queues = append(queues, point{
				h:    i,
				w:    j - 1,
				step: step + 1,
			})
			white--
		}
		if j < w-1 && !blackPoints[i][j+1] {
			blackPoints[i][j+1] = true
			queues = append(queues, point{
				h:    i,
				w:    j + 1,
				step: step + 1,
			})
			white--
		}
	}

	fmt.Println(cur.step + 1)
}


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

int main() {
  vector<int64_t> L(87);
  L.at(0) = 2;
  L.at(1) = 1;
  int N;
  cin >> N;
  for (int i=2; i<=N; i++){
    L.at(i) = L.at(i-1) + L.at(i-2);
  }
  
  cout << L.at(N) << endl;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)

for i in range(N):
    t[i + 1] = t[i] + (1 if S[i: i + 2] == 'AC' else 0)
#    print(t[i])

for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Measured memory_bytes: 9668
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	VI A(N);
	int ans = 1;
	int cnt = 3;
	REP(i, N)cin >> A[i];
	int dp[100010] = { 0 };
	//REP(i, N)dp[i] = 1;
	REP(i, N) {
		//cout << ans << endl;
		if (A[i] == 0) {
			ans *= cnt;
			cnt--;
			dp[A[i]]++;
		}
		else {
			ans *= (dp[A[i] - 1]-dp[A[i]]);
			ans %= mod;
			dp[A[i]]++;
		}
	}
	cout << ans << endl;
	/*ans = 0;
	REP(i, 3) {
		REP(j, 3) {
			REP(k, 3) {
				cout << i << j << k << endl;
				if (i != j && (i == k || j == k))ans++;
			}
		}
	}

	cout << ans << endl;
	*/
	return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
char arr[1005][1005];
int n,m;
int mem[1005][1005];
int dx[2] = {0 , 1};
int dy[2] = {1 , 0};
const int MOD = 1e9 + 7;
int calc(int i , int j) {
    if (i == n - 1 && j == m - 1)
        return 1;
    if (i >= n || j >= m || arr[i][j] == '#')
        return 0;
    if (mem[i][j] != -1)
        return mem[i][j];
    return mem[i][j] = (calc(i + 1 , j)%MOD) + (calc(i , j+1)%MOD)%MOD;
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    memset(mem , -1 , sizeof(mem));
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> arr[i][j];
        }
    }
    cout << calc(0 , 0)%MOD << endl;
}

Measured memory_bytes: 8632
import itertools
import math
N , K=  list(map(int,input().split(" ")))
ar = []
for _ in range(N):
    a,b = list(map(int,input().split(" ")))
    ar.append((a,b))
ar.sort(key=lambda x:x[0])
co = 0
for num in ar:
    co += num[1]
    if co >= K:
        print(num[0])
        exit()

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

l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(l[n-1])

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

#define INF 1000000000

using namespace std;

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

    vector<int> X(N), Y(N);

    REP(i, N)
    cin >> X[i];

    Y = X;

    sort(ALL(X));

    REP(i, N) {
        int n = Y[i];
        int pos = X.size() / 2;

        if (n >= X[pos]) pos--;

        cout << X[pos] << endl;
    }

    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
# define ll long long int
#define M 1000000007
#define ff first
#define ss second
#define pb push_back  
#define INF 1000000000000
typedef long long C;
typedef complex<C> P; 
#define X real() 
#define Y imag()


									// nestedcode


 int main(){
   ios::sync_with_stdio(0);
   cin.tie(0); cout.tie(0);
   ll k,n,s = 0,i;
   cin>>n>>k;
   ll a[n];
  for(i=0;i<n;i++){
  	cin>>a[i];
  	//s+=a[i];
  }
 sort(a,a+n);
 reverse(a,a+n);
 
 for(i=k;i<n;i++){
 	s+=a[i];
 }
 cout<<s;
}

Measured memory_bytes: 1792
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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(void){  
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int n, i;
  string s;

  cin >> n >> i;

  cout << n-i+1 << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={0,1,0,-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; }

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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(ll n, ll 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(){
    COMinit();
    ll N,K,tasu=0,hiku=0,ans=0;
    cin>>N>>K;
    ll A[N];
    for(ll i=0;i<N;i++) cin>>A[i];
    sort(A,A+N);
   for(ll i=0;i+K<=N;i++){
       hiku+=A[i]*COM(N-i-1,K-1);
       hiku%=MOD;
   }
   for(ll i=K-1;i<N;i++){
       tasu+=A[i]*COM(i,K-1);
       tasu%=MOD;
   }
   ans=tasu-hiku;
   ans+=MOD;
   ans%=MOD;
   cout<<ans<<endl;
}


Measured memory_bytes: 12928
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut ans = 0;
    for ai in a {
        let mut x = ai;
        while x % 2 == 0 {
            ans += 1;
            x /= 2;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <math.h>
using namespace std;


int main() {
	int n;
	cin >> n;
	int *t = new int[n];
	for (int i = 0; i < n; i++){
		cin >> t[i];
	}
	int sum=0;
	int m;
	cin >> m;
	int x, p;
	for (int i = 0; i < m; i++){
		cin >> p>>x;
		p--;
		sum = 0;
		for (int j = 0; j < n; j++){
			if (j == p){ sum += x; }
			else{
				sum += t[j];
			}
		}
		cout <<sum << endl;

	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String S = scanner.nextLine();
    String T = scanner.nextLine();
    if(T.length() == S.length() + 1 && T.startsWith(S)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 35832
#include <bits/stdc++.h>
using namespace std;
#define MOD 1e9 + 7
#define endl '\n'

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

    int n;

    cin >> n;

    vector<long long> a(n),b;

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

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

    for(int i = 0;i < n-1;i++) if(a[i]==a[i+1]){ b.push_back(a[i]); i++; }
    if(b.size()<2) cout << "0";
    else { long long t = b[0]*b[1]; cout << t; }

}


Measured memory_bytes: 1660
def main():
    slimes = int(input())
    color = list(input().split()) + ["-1"]
    before = color[0]
    count = 1
    answer = 0
    for i in range(1, slimes + 1):
        if before == color[i]:
            count += 1
        else:
            before = color[i]
            answer += count // 2
            count = 1
    print(answer)


if __name__ == '__main__':
    main()



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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<pair<int, int>> all(n);
  for (int i = 0; i < n; i++) {
    cin >> all[i].first >> all[i].second;
  }
  sort(all.begin(), all.end());
  vector<int> preff(n), suff(n);
  for (int i = 0; i < n; i++) {
    preff[i] = all[i].second;
    if (i) {
      preff[i] = min(preff[i], preff[i - 1]);
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    suff[i] = all[i].second;
    if (i < n - 1) {
      suff[i] = min(suff[i], suff[i + 1]);
    }
  }
  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    int r1 = all[i].second, r2 = suff[i + 1];
    int l1 = all[i].first, l2 = all[n - 1].first;
    int mn = 1e9;
    if (i) {
      mn = preff[i - 1];
    }
    // cout << i << ' ' << mn << ' ' << l1 << ' ' << r1 << ' ' << l2 << ' ' << r2 << endl;
    ans = max(ans, max(0, min(r1, mn) - l1 + 1) + max(0, r2 - l2 + 1));
    ans = max(ans, max(0, r1 - l1 + 1) + max(0, min(r2, mn) - l2 + 1));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
/** author: __nishad **/

#include<bits/stdc++.h>
using namespace std;


typedef long long ll ;
typedef vector<ll> vll ;

#define all(v) (v).begin(),(v).end()
#define precision(k) cout<<setprecision(k)<<fixed;
#define loop(i,a) for(int i=0; i<a;i++)
#define loop2(i,a,b) for(int i=(a);i<=(b);++i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define pi 3.14159265358979323
#define pi 3.14159265358979323

int main()
{
    IOS;

    ll n, T, c, t, min=1e6;
    cin>>n>>T;

    while(n--){
        cin>>c>>t;
        if(t<= T){
            if(c < min)
                min = c;
        }
    }
    if(min < 1e6)
        cout<<min;
    else
        cout<<"TLE";


}



Measured memory_bytes: 256
#include<iostream>

constexpr size_t mod = 1e9+7;

int main(){
    
    size_t n, ans = 1;
    std::cin >> n;

    for(size_t i = 1; i <= n; i++){
        ans = (ans * i) % mod;
    }

    std::cout << ans << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N_MAX 26

typedef struct T{
  int parent;
  int left;
  int right;
}TREE;

TREE tree[N_MAX];

void Preorder(int);
void Inorder (int);
void Postorder (int);

int main(){
  int i,n,id,lef,rig;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){//初期化
    tree[i].parent=-1;
    tree[i].left=-1;
    tree[i].right=-1;
  }
 
  for(i=0;i<n;i++) {
    scanf("%d %d %d",&id,&lef,&rig);
    tree[id].left = lef;
    tree[id].right = rig;
    
    if(lef!=-1)
      tree[lef].parent = id;
    if(rig!=-1)
      tree[rig].parent = id;
  }
  for(i=0;i<n;i++){
    if(tree[i].parent==-1)
      break;
  }
  
  printf("Preorder\n");
  Preorder(i);
  printf("\n");
  
  printf("Inorder\n");
  Inorder(i);
  printf("\n");
  
  printf("Postorder\n");
  Postorder(i);
  printf("\n");
  
  return 0;
}


void Preorder(int vat){
  printf(" %d",vat);
  if(tree[vat].left!=-1)
    Preorder(tree[vat].left);
  if(tree[vat].right!=-1)
    Preorder(tree[vat].right);
}
void Inorder (int vat){
  if(tree[vat].left!=-1)
    Inorder(tree[vat].left);
  printf(" %d",vat);
  if(tree[vat].right!=-1)
    Inorder(tree[vat].right); 
}
void Postorder (int vat){
  if(tree[vat].left!=-1)
    Postorder(tree[vat].left);
  if(tree[vat].right!=-1)
    Postorder(tree[vat].right);
  printf(" %d",vat);
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
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; }
const ll MOD = 1e9+7;

int main(){
    int N;
    cin >> N;
    vector<ll> H(N);
    REP(i,N){
        ll h;
        cin >> h;
        H[i] = h;
    }

    vector<ll> A(N, 0);
    ll cnt = 0;
    ll last = LLONG_MAX;
    for(int i = N-1; i >= 0; i--){
        ll h = H[i];

        if(h >= last)  cnt++;
        else{
            cnt = 0;
        }

        A[i] = cnt;

        last = h;
    }

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

    ll ans = A[N-1];

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define MOD 1000000007
template <typename Type>
istream &operator>>(istream &in, vector<Type> &vec) {
    ll n = vec.size();
    for (ll i = 0; i < n; i++)
        in >> vec[i];
    return in;
}
template <typename Type>
ostream &operator<<(ostream &out, vector<Type> &vec) {
    for (auto val : vec)
        out << val << " ";
    return out;
}
#define PI 3.14159265
void solve()
{
    string s;
    cin>>s;
    ll ans=INT_MIN;
    ll c=0;
    for(ll i=0;i<s.size();i++)
    {
        if(s[i]=='R')
        {
            c++;
        }
        else
        {
            ans = max(ans,c);
            c = 0;
        }
    }
    ans = max(ans,c);
    cout<<ans<<endl;
}
int main()
{
    ll t=1;
    
    while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 3636
N=gets.to_i
A=gets.split.map(&:to_i)
h=Hash.new{0}
A.each{|a|
    h[a]+=1
}
h.reject!{|k,v|v<2}
e=[]
h.each_key{|k|
    e<<k
    if h[k]>=4
        e<<k
    end
}
e.sort!
if e.size>=2
    puts e[-1]*e[-2]
else
    puts 0
end


Measured memory_bytes: 25516
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int T = sc.nextInt();
        int answer = T / A * B;
        System.out.println(answer);
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
using namespace std;
int main(){   
   int n;
   cin>>n;
   string a,b;
   cin>>a>>b;

   string ans;
   rep(i,n){
      ans+=a[i];
      ans+=b[i];
   }
   cout<<ans;
   
   

   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#include<cctype> 
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
 
int main(){
  string O,E;
  int i;
  cin >> O >> E; 
  if(O.size()==E.size()){
    rep(i,O.size()){
      cout << O[i] << E[i];
    }
  }else{
    rep(i,E.size()){
      cout << O[i] << E[i];
    }
    cout << O[O.size()-1];
  }

  cout << '\n';

  return 0;
} 


Measured memory_bytes: 256
n=int(input())
count=0
if n>=10:
    count+=9
    if n>=1000:
        count+=900
        if n>=100000:
            count+=90000
        else:
            if n>=10000:
                count+=n-10000+1
    else:
        if n>=100:
            count+=n-100+1
    print(count)
else:
    print(n)


Measured memory_bytes: 2940
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#define ll long long int
using namespace std;
int max(int a,int b){
    return a>b?a:b;}
int main() {
	// your code goes here
    ll n,w;
    cin >> n >> w;
    vector<vector<ll>> ans(n+1,vector<ll>(w+1,0));
    vector<vector<ll>> v(n+1,vector<ll>(2,0));
    for(ll i=1;i<=n;i++){
        cin >> v[i][0] >> v[i][1];
       
    }
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=w;j++){
            if(j<v[i][0])
            ans[i][j]=ans[i-1][j];
            else
            ans[i][j]=max(ans[i-1][j],v[i][1]+ans[i-1][j-v[i][0]]);
        }
    }
    cout << ans[n][w];
	return 0;
}


Measured memory_bytes: 80256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<sstream>
#include<stdio.h>
#include <functional>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int min = 0;
	for (int i = 0; i < n; i++)
	{
		if (i == 0)
		{
			min = a[i];
		}
		else
		{
			if (min > a[i])
			{
				min = a[i];
			}
		}
	}
	for (int i = 0; i < n; i++)
	{
		if (a[i] == min)
		{
			cout << i+1 << endl;
			return 0;
		}
	}
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  rep(i, n/7+1) {
    if((n-i*7)%4 == 0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  vector<int>a(n);
  long long kotae=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    kotae+=a[i]-1;
  }
  cout<<kotae<<endl;
  return 0;
}
  

Measured memory_bytes: 256
s = input()
n = len(s)
ans  =[0 for i in range(n)]
i = 0
while i < n:
    le = i
    while i+1 < n and s[i] == s[i+1]:
        i += 1
    length = i - le + 1
    if s[i] == 'L':
        ans[le]+=(length+1)//2
        ans[le-1] += length//2
    else:
        ans[i] += (length+1)//2
        ans[i+1] += length//2
    i += 1

for i in range(n):
    print(ans[i],end=' ')

print()

Measured memory_bytes: 52456
#include <stdio.h>
#include <algorithm>
using namespace std;

int main()
{
    int n, x[200000], y[200000], ai;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &x[i]);
        y[i] = x[i];
    }
    sort(y, y+n);

    for(int i = 0; i < n; i++){
        ai = (y[n/2 - 1] >= x[i] ? y[n/2] : y[n/2 - 1]);
        printf("%d\n", ai);
    }
    return 0;
}
  

Measured memory_bytes: 3712
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(LL i = (a); i < (LL)(n); ++i)
#define REM(i,a,n) for(LL i = ((n) - 1); i >= (a); --i)
#define FLOAT setprecision(16)
#define SPEEDUP {cin.tie(0); ios::sync_with_stdio(false);}
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const string INFSTR = "\x7f";
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template<class T>
T Compare(T left, T right) { return left > right ? 1 : (left < right ? -1 : 0); }
istream& Ignore(istream& ist) {string s; ist >> s; return ist;}
bool Inside(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
// all_of
// partial_sum, adjacent_difference

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "Flow_Solver.h"
#include "Tree.h"
#include "Suffix_Array.h"
#include "Geometry.h"
#include "Matrix.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

#if 1234567891
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif
string s;
string a = "AKIHABARA";
int main() {
	cin >> s;
	int i = 0;
	bool ok = true;
	while(i < a.size() + 1) {
		if (a[i] != s[i]) {
			if (a[i] != 'A') {
				ok = false; break;
			}
			s.insert(s.begin() + i, 'A');
		}
		++i;
	}
	YESNO(ok);
	return 0;
}

/*-------------------------*/
/*-----    二分探索   -----*/
/*-------------------------*/

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

int main()
{
    int n,m;
    cin >> n >> m;
    int a[n],b[m];
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<m;i++) cin >> b[i];
    int p[n]={};
    for(int j=0;j<n;j++){
        for(int i=0;i<m;i++){
            if(b[j]>=a[i]){
                p[i]++;
                break;
            }
        }
    }
    int x=0,y;
    for(int i=0;i<n;i++){
        if(x<p[i]){
            y=i+1;
            x=p[i];
        }
    }
    cout << y << endl;
    return 0;
}



Measured memory_bytes: 3136
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝




*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f=0,x=0,g,p=0,q=0,y=0,z=0;
double kk=0;
    vector<pair<long long,long long>>v;
    vector<long long>u;
    map<string,long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4,s5,s6;
   cin>>n;
 l(i,0,n)
 {
     cin>>s1;
     lw(s1);
     s[s1]++;

 }
 for(auto x:s)
 {
     d+=(x.second*(x.second-1))/2;
    //cout<<x.second<<endl;
 }
 cout<<d<<endl;



}






Measured memory_bytes: 11424
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let k: i64 = it.next().unwrap().parse().unwrap();
    it.next();
    let a: Vec<i64> = it.map(|s| s.parse().unwrap()).collect();
    let mut ans = k - *a.last().unwrap() + a[0];
    for a in a.windows(2) {
        ans = std::cmp::max(ans, a[1] - a[0]);
    }
    ans = k - ans;
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 10492
#include<cstdio>
#include<functional>
#include<algorithm>

const int N=100005;

int n,a[N];

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%d",a+i);
    std::sort(a+1,a+1+n,std::greater<int>());
    for(int i=1;i<=n;++i)
    {
        if(a[i+1]<i+1)
        {
            int ans=0;
            for(int j=i+1;a[j]==i;++j)ans^=1;
            ans|=(a[i]-i)&1;
            if(ans)puts("First");
            else puts("Second");
            return 0;
        }
    }
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int h,n;
    cin >> h >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    int64 sum = accumulate(a.begin(), a.end(), 0L);

    cout << (h<=sum? "Yes" : "No") << endl;
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const int MOD = 2019;

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

    int l, r;
    cin >> l >> r;

    if (r - l >= 2019) {
        cout << 0 << '\n';
        return 0;
    }

    int ans = 2019;
    for (int i = l; i < r; i++) {
        for (int j = i+1; j <= r; j++) {
            int tmp = (i % MOD) * (j % MOD) % MOD;
            ans = min(tmp, ans);
        }
    }

    cout << ans << "\n";
    return 0;
}

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

#define fst first
#define snd second
#define mp make_pair
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define per(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()

template <typename T1, typename T2>
bool umin(T1 &x, const T2 &y) {return (x>y ? (x=y,true):false);}
template <typename T1, typename T2>
bool umax(T1 &x, const T2 &y) {return (x<y ? (x=y,true):false);}

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

const int N = (int)2e3+3;
const int INF = (int)1e9+17;
const ll mod = (ll)1e9+7;
const ll LLINF = (ll)1e18+17;
const ld pi = (ld)acos(-1.0);


int n, m;
int a[N];
bitset<N*N> dp;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    cin >> n;
    int sum = 0;
    rep(i, 0, n) {
        cin >> a[i];
        sum += a[i];
    }
    dp[0] = 1;
    rep(i, 0, n) dp |= (dp << a[i]);
    rep(j, 0, N*N) {
        if (j < (sum+1)/2) continue;
        if (dp[j]) {
            cout << j << endl;
            return 0;
        }
    }
    
#ifdef LOCAL
    cerr << endl << setprecision(3) << fixed 
        << "Running time is " << 1. * clock() / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n, k) for(int i=k; i<n; ++i)
using namespace std;

int main(){
  int a, b, ans;
  cin >> a >> b;
  if(a < b) swap(a,b);
  ans = a;
  a--;
  if(a < b) swap(a,b);
  ans += a;
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0
x = a[0]
c = 0
for i in a:
    if i == x:
        x = i
        c += 1
    else:
        if x > c:
            ans += c
        elif x < c:
            ans += c - x
        c = 1
        x = i
if x > c:
    ans += c
elif x < c:
    ans += c - x
print(ans)

Measured memory_bytes: 14212
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long ll;
ll a[5]={};
int b[10];
int c[5];
inline int b1(int x){
	if(x==0) return 0;
	return __builtin_popcount(x);
}
int main(){
	int N;
	cin>>N;
	rep(i,N) cin>>a[i];
	int I=0;
	rep(i,32){
		int x[5]={};
		rep(j,5) x[j]=(i>>j)&1;
		int s=0;
		rep(j,5) s+=x[j];
		if(s<=1) continue;
		int J=0;
		rep(j,5) for(int k=j+1;k<5;k++){
			if(x[j]&&x[k]) b[J]|=(1<<I);
			J++;
		}
		rep(j,5) if(x[j]) c[j]|=(1<<I);
		I++;
	}
	ll ans=1e15;
	rep(i,1<<I){
		bool ok=1;
		rep(j,10){
			if(b1(i&b[j])>1){
				ok=0;
				break;
			}
		}
		if(!ok) continue;
		ll tmp=0;
		rep(j,5){
			if(b1(i&c[j])>a[j]){
				ok=0;
				break;
			}
			tmp+=a[j]-b1(i&c[j]);
		}
		if(!ok) continue;
		tmp+=b1(i);
		chmin(ans,tmp);
	}
	cout<<ans<<endl;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(c-(a-b) > 0) cout << c-(a-b) << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
#define vint vector<int>
#define vll vector<ll>
typedef long long ll;

using namespace std;

int main(void){
	string str; cin >> str;
	vint l(str.length()+10);
	vint r(str.length()+10);

	ll count = 0;
	rep(i, str.length()){
		if(str[i] == '<') count++;
		else count = 0;
		l[i+1] = count;
	}
	count = 0;
	for(int i=str.size()-1; i>=0; i--){
		if(str[i] == '>') count++;
		else count = 0;
		r[i] = count;
	}

	ll ans = 0;
	rep(i, str.length()+1){
		ans += max(r[i], l[i]);
	}
	cout << ans << endl;
}


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

int main(){
    int x[5],a[5];
    for(int i=0;i<5;i++){
        x[i]=i+1;
    }
    for(int i=0;i<5;i++){
        cin>>a[i];
    }
    for(int i=0;i<5;i++){
        if(x[i]!=a[i]){
            cout<<i+1<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3620
#include<cstdio>
#include<algorithm>
typedef long long ll;
const int M = 110;
int m,ans = 0;
int a[M];

template<typename T>
inline void read(T &x){
    x = 0; char ch = getchar(); int f = 1;
    for(;ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = -1;
    for(;ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
    x *= f;
}
int main(){
    read(m);
    for(int i = 1;i <= m; i++) read(a[i]);
    std::sort(a + 1,a + m + 1);
    for(int i = 1;i <= m - 2; i++)
        for(int j = i + 1;j <= m - 1; j++)
            for(int k = j + 1;k <= m; k++)
                if((a[i] ^ a[j]) && (a[i] ^ a[k]) && (a[j] ^ a[k]) && a[i] + a[j] > a[k])
                    ans++;
    printf("%d\n",ans);
    return 0;
}
/*

*/

Measured memory_bytes: 1604
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>S>>K;
    N = S.size();
    vec ans(0);
    S.push_back('A');
    ll last = S[0], temp = 1;
    reps(i,1,N + 1){
        if(last != S[i]){
            ans.push_back(temp);
            temp = 1;
        }else{
            ++temp;
        }
        last = S[i];
    }
    ll out = 0;
    rep(i,ans.size()){
        out += ans[i]/2;
        //cout<<ans[i]<<endl;
    }
    out *= K;
    if(S[0] == S[N-1]) {
        if(ans.size() != 1) out += (K-1) * ((ans[0] + ans[ans.size() - 1])/2 - ans[0]/2 - ans[ans.size() - 1]/2);
        else out = K*N/2;
    }
    cout<<out<<endl;
}

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

int main(void){
  int a, b;
  int m[] = {0, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335};
  int r = 0;
  while(1){
    cin >> a >> b;
    if(a == 0 && b == 0) break;
    r = (m[a] + b) % 7;
    switch (r)
    {
    case 0:
      cout << "Wednesday" << endl;
      break;
    case 1:
      cout << "Thursday" << endl;
      break;
    case 2:
      cout << "Friday" << endl;
      break;
    case 3:
      cout << "Saturday" << endl;
      break;
    case 4:
      cout << "Sunday" << endl;
      break;
    case 5:
      cout << "Monday" << endl;
      break;
    case 6:
      cout << "Tuesday" << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<sstream>
#include<stack>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
#define req(i,n) for(int i = 1;i <= n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a)  (a).begin(),(a).end()
#define fix  fixed << setprecision(10)
const int MOD = 1000000007;
const int INF = (1 << 31); // 1073741824 //2147483648
string t, u; ll n,m, q, ans = 0, sum = 0, w, d, r = 0;
bool f = true;
int main() {
    cin >> t; int a = t.size() - 1;
    rep(i, (1 << a)) {
        int r = 0, l = 1;
        rep(j, a + 1) {
            if (i & (1 << j) || j == a) {
                u = t.substr(r, l);
                ans += stoll(u);
                r = j + 1; l = 1;
            }
            else l++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <cctype>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

locale l = locale::classic();

int main(){
    int n,k;
    string s;
    cin >> n >> k >> s;
    s[k-1] += 0x20;
    cout << s << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  ll mid = a + b + c - max({a, b, c}) - min({a, b, c});
  ll ans = 10 * max({a, b, c}) + mid + min({a, b, c});
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    int res = INF;
    for(int i = 0;i%2 ==0 and i<=200000;i+=2){
        int cur = i*c+max(0,x-i/2)*a+max(0,y-i/2)*b;
        res = min(res,cur);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
def is_dislike(N, ds):
  num = N
  while(True):
    if (num % 10) in ds:
      return True
    else:
      num = int(num / 10)
      if num == 0:
        break
  return False


nk = list(map(int,input().split()))
N = nk[0]
K = nk[1]
ds = list(map(int,input().split()))
while(True):
  if is_dislike(N, ds):
    N = N+1
  else:
    print(N)
    break

Measured memory_bytes: 9104