akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    string s; cin>>s;
    int n=s.size();
    int sum=0;
    rep(i,n){
        if(s[i]=='0') sum++;
    }
    cout<<2*min(sum,n-sum)<<endl;
    return 0;
}


Measured memory_bytes: 512
function Main(input) {
  const lines = input.split('\n');
  const [a, b] = lines[0].split(' ').map(s => parseInt(s));
  const n = a * b / 2;
  const judge = n.toString().includes('.');
  console.log(judge ? 'Odd' : 'Even');
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29636
#include <iostream>
#include <string>

using namespace std;

int main() {
  int n, source_len, sign_len, count = 0, suffix;
  string source, sign;

  cin >> n >> source;
  source_len = source.length();

  bool success;
  while (n--) {
	cin >> sign;
	sign_len = sign.length();
	success = false;
	for (int j = 0; j < sign_len; j++) { //先頭文字のループ
	  for (int k = 0; k <= sign_len / 2; k++) { //間隔のループ
		for (int l = 0, suffix = j; l < source_len; l++) { //文字のループ
		  if (source[l] != sign[suffix]) break; //一文字単位で比較
		  if (l == source_len - 1) { success = true; count++; break; } //すべて一致
		  if ((suffix += k + 1) >= sign_len) break; //添字があふれるのを防ぐ
		}
		if (success) break;
	  }
	  if (success) break;
	}
  }

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define int int64_t
using namespace std;

const int N = 1e5+1;

vector<vector<int>> adj(N);
vector<bool> vu(N);

void dfs(int node){
	for (int i:adj[node]){
		if (!vu[i]){
			vu[i] = true;
			dfs(i);
		}
	}
}

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin >> n >> m;
	for (int i=0; i<m; ++i){
		int a,b,z;
		cin >> a >> b >> z;
		adj[a].emplace_back(b);
		adj[b].emplace_back(a);
	}
	int ans = 0;
	for (int i=1; i<=n; ++i){
		if (!vu[i]){
			vu[i] = true;
			ans++;
			dfs(i);
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 13424
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vector<bool> d(1000001, 1);
  ll ans = 0;
  vll a(n);
  vector<int> cnt(1000001, 0);

  for(int i=0;i<n;i++) {
    scanf("%lld", &a[i]);
    cnt[a[i]]++;
  }
  sort(all(a));

  for(int i=0;i<n;i++){
    if(cnt[a[i]]==114515810) continue;

    if(d[a[i]]&&cnt[a[i]]==1) ans++;
    cnt[a[i]] = 114515810;
    for(ll j=1;j*a[i]<=1000000;j++) d[j*a[i]] = 0;
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 8528
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))

dd=defaultdict(lambda:0)
for aa in a: dd[aa]+=1

ans=0
for aa in dd.keys():
  ca=dd[aa]
  if ca>=aa:
    ans+=ca-aa
  else:
    ans+=ca
print(ans)

Measured memory_bytes: 22444
#include <iostream>
#include <cstdint>
#include <vector>
#include <algorithm>

std::vector<uint32_t> nums;
std::vector<uint32_t> sNums;

void input() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	uint32_t n;
	std::cin >> n;
	nums.resize(n);
	for (uint32_t &i : nums) {
		std::cin >> i;
	}

	sNums = nums;
	std::sort(sNums.begin(), sNums.end());
}

uint32_t find_ind(uint32_t a) {
	uint32_t l = 0;
	uint32_t r = sNums.size();
	while (r - l > 1) {
		uint32_t m = (r + l) / 2;
		if (sNums[m] > a) {
			r = m;
		} else {
			l = m;
			//sNums[m] = l;
		}
	}
	return l;
}

int main() {
	input();
	for (uint32_t i = 0;i < nums.size();i++) {
		uint32_t cInd = find_ind(nums[i]);
		uint32_t med = nums.size() / 2 - 1;
		if (cInd <= med) {
			med++;
		}
		std::cout << sNums[med] << "\n";
	}
}


Measured memory_bytes: 3840
import java.math.BigInteger;
import java.util.*;
public class Main {
	


	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		
		if(n <= m) {
			for(int i=0;i<m;i++) {
				System.out.print(n);
			}
		} else {
			for(int i=0; i<n; i++) {
				System.out.print(m);
			}
		}




		
		
		
		
		

		


		
		
	}
	


}

 

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

int main()
{
  string sss;
  cin >> sss;
  if(sss.at(0) == '1') {
    cout << '9';
  } else {
    cout << '1';
  }
  if(sss.at(1) == '1') {
    cout << '9';
  } else {
    cout << '1';
  }
  if(sss.at(2) == '1') {
    cout << '9';
  } else {
    cout << '1';
  }
  cout << endl;
  
  return 0;
}

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

struct B {
	int price, n;
	double avg;
	bool operator < (const B &b) const {
		return avg < b.avg;
	}
}in[4];
long long rest, price;


int main() {
	while (cin >> in[0].price >> in[1].price >> in[2].price >> in[3].price) {
		for (int i = 0; i < 4; ++i) {
			in[i].n = (1 << i);
			in[i].avg = (double)in[i].price / in[i].n;
		}
		sort (in, in+4);
		cin >> rest;
		rest *= 4;
		price = 0;
		for (int i = 0; i < 4; ++i) {
//			cout << "rest = " << rest << endl;
			if (rest >= in[i].n) {
				price += (rest/in[i].n) * in[i].price;
				rest %= in[i].n;
			}
		}
		cout << price << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    string s;
    cin>>s;
    ll size;
    size=s.size();
    ll k=0;
    string a="",b="";
    a+=s[0];
    for(ll i=1;i<size;i++){
        b+=s[i];
        if(a!=b){
            k++;
            a=b;
            b="";
        }
    }
    cout<<k+1<<endl;
}

Measured memory_bytes: 640
K,A,B=map(int,input().split())
ans=1
if B-A<=2: # 日本円を経由してビスケットを増やせない場合 ※B-A==2であれば，操作2回で日本円を経由するのと，ビスケットを2回叩くのが等価。
    ans+=K
else: # 日本円を経由してビスケットを増やせ得る場合
    if A>1 and A-1<=K: # 日本円に交換するためにビスケットを叩く必要があり，かつ，日本円に交換できるだけのビスケットを得られる場合には，まず，日本円に交換できるだけのビスケットを作る。
        ans=A
        K-=A-1    
    # （最後に回してもよいが，便宜上ここで）残り操作回数が奇数であれば，1回ビスケットを叩いておく。
    if K%2==1:
        ans+=1
        K-=1
    # 以下，日本円を経由する2回の操作でビスケットを(B-A)枚増やせる。
    ans+=(B-A)*(K//2)
    K=0 # 一応
    
print(ans)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
int main(){
  ll K,i;scanf("%lld",&K);
  printf("50\n");
  ll A[50];fill(A,A+50,49+(K+49)/50);
  K = 49-(K+50-1)%50;
  for(i=0;i<K;i++) A[i] = A[i]-51+K;
  for(i=K;i<50;i++) A[i] += K;
  for(i=0;i<50;i++) printf("%lld ",A[i]);
  printf("\n");
}

Measured memory_bytes: 3832
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strings"
)

func main() {
	m := newAlpha()
	s := bufio.NewScanner(os.Stdin)
	for s.Scan() {
		l := s.Text()
		if l == "" {
			break
		}
		countAlpha(&m, l)
	}
	printAlpha(m)

}

func newAlpha() map[string]int {
	m := make(map[string]int)
	for i := 97; i <= 122; i++ {
		m[string(i)] = 0
	}
	return m
}

func countAlpha(m *map[string]int, l string) {
	for i := range l {
		a := strings.ToLower(string(l[i]))
		if a >= "a" && a <= "z" {
			(*m)[a]++
		}
	}
}

func printAlpha(m map[string]int) {
	keys := make([]string, 0, len(m))
	for k := range m {
		keys = append(keys, k)
	}
	sort.Strings(keys)

	for _, k := range keys {
		fmt.Printf("%s : %d\n", k, m[k])
	}
}



Measured memory_bytes: 1152
import java.util.*;
//import java.util.Arrays;

public class Main {
    public static void main(String args[]){

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int a[] = new int[n];
//        List<Integer> a = new ArrayList<>();

        int ball[] = new int[n];

        for (int i=0; i<n; i++) a[i] = sc.nextInt();

        int half=n/2+1;

        for (int i=half-1; i<n; i++){
            if (a[i]==0){
                ball[i] = 0;
            }else{
                ball[i] = 1;
            }
        }


        for (int i=half-2; i>=0; i--){
            long sum = 0;
            for (int j=(i+1)*2; j<=n; j+=i+1){
//                long sum = 0;
                sum += ball[j-1];
            }if (sum%2==a[i]){
                ball[i] = 0;
            }else {
                ball[i] = 1;
            }
        }

//        System.out.println(ball[1]);
//
        int zero =0;
        for (int i=0; i<n; i++){
            if (ball[i]==0)zero++;
        }
        if (zero==n) System.out.println(0);
//
        else {
            List<Integer> ans = new ArrayList<>();
            int count = 0;
            for (int i = 0; i < n; i++) {
                if (ball[i] == 1) {
                    count++;
                    ans.add(i);
                }
            }
                System.out.println(count);
                for (int i = 0; i < ans.size(); i++) {
                    System.out.println(ans.get(i)+1);
            }
        }
    }
}


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

struct Point {
  int x,y;
  bool operator < (const Point& p) const {
    if( y != p.y ) return y < p.y;
    return x > p.x;
  }
};
ostream& operator << (ostream& os,const Point& p) {
  os << p.x << " " << p.y ;
}

int main(){
  priority_queue<Point> Q;
  int n,q,a,v;
  int get[1000000]={0},_top;

  cin >>n>>q;
  for(int i=0;i<q;i++){
    cin >>a>>v;
    get[a]+=v;
    Q.push((Point){a,get[a]});
  PREV:;
    if(get[Q.top().x] != Q.top().y){
      Q.pop();
      goto PREV;
    }
    else{
    cout <<Q.top()<<endl;
    }
  }
  return 0;}
    
    

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

int main() {
  int N;
  int64_t D;
  cin >> N >> D;
  int counter = 0;
  vector<vector<int>> data(N, vector<int>(2));
  for (int i = 0; i < N; i++){
    for (int j = 0; j < 2; j++){
      cin >> data.at(i).at(j);
    }
  }
  
  for (int i = 0; i < N; i++){
    int64_t a = data.at(i).at(0);
    int64_t b= data.at(i).at(1);
    if((a * a) + (b * b) <= D * D){
      counter++;
    }
  }
  
  cout << counter << endl;
}

Measured memory_bytes: 14000
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) (1e9 + 7);
//const ll MOD = 998244353;
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

//------------------------------------------------------

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

    int n;
    cin >> n;
    cout << n * n * n << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define pb push_back
#define ld long double
#define mod 1000000007
#define mk make_pair
#define ull unsigned long long
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main()
{
    fastIO;
    ll a,b;
    cin>>a>>b;
    ll ans;
    if((a>=1 && a<=9) && (b>=1 && b<=9))
    {
        ans=a*b;
        cout<<ans<<'\n';
    }
    else
    {
        cout<<-1<<'\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
int dh0[] = { -1,0,1,1,0,-1 };
int dw0[] = { 1,1,1,0,-1,0 };
int dh1[] = { -1,0,1,1,0,-1 };
int dw1[] = { 0,1,0,-1,-1,-1 };
int W, H;
int res;
void bfs(int sh, int sw, vector<vector<int>> &a) {
	queue<pair<int, int>> q;
	q.emplace(sh, sw);
	while (!q.empty()) {
		int h, w; tie(h, w) = q.front();
		q.pop();
		for (int i = 0; i < 6; i++) {
			int nh = h;
			int nw = w;
			if (h % 2 == 0) {
				nh += dh0[i];
				nw += dw0[i];
			}
			else {
				nh += dh1[i];
				nw += dw1[i];
			}
			if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
			if (a[nh][nw] == 1) res++;
			if (a[nh][nw] == 0) {
				a[nh][nw] = 2;
				q.emplace(nh, nw);
			}
		}
	}
}
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	scanf("%d %d", &W, &H);
	vector<vector<int>> a(H + 4, vector<int>(W + 4)); for (int i = 2; i <= H + 1; i++) for (int j = 2; j <= W + 1; j++) scanf("%d", &a[i][j]);
	H += 4;
	W += 4;

	a[0][0] = 2;
	bfs(0, 0, a);

	cout << res << endl;
	return 0;

}


Measured memory_bytes: 3292
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  string a,b,c;
  char d,e,f;
  cin>>a>>b>>c;
  d=a[0]-32;
  e=b[0]-32;
  f=c[0]-32;
  cout<<d<<e<<f<<endl;

  return 0;
}







Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define MN 2100001
using namespace std;
 
int n,m,a[MN];
long long sum1=0,sum2=0,mmh=1e18;
long long _abs(long long x){return x<0?-x:x;}
int main(){
    scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]),sum2+=a[i];
    for (int i=1;i<n;i++) if (sum1+=a[i],_abs(sum2-sum1-sum1)<mmh) mmh=abs(sum2-sum1-sum1);
    printf("%d\n",mmh);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define all(v) v.begin(), v.end()
vector<int> graf[100001];
vector<pair<pair<int, int>, int>> gvec;
int gr, gc;
string gs, gst;
long long dp[1001][1001];
char grid[1001][1001];

long long whatdo(int r, int c) {
  if (grid[r][c] != '.')
    return 0;
  if (r > gr || c > gc)
    return 0;
  if (r == gr && c == gc) {
    return 1;
  }
  if (dp[r][c] != -1)
    return dp[r][c];
  int ans = 0;
  ans += whatdo(r + 1, c);
  ans += whatdo(r, c + 1);
  return dp[r][c] = ans % (1000000000 + 7);
}

void solve() {
  //----------------------VARs---------------------------------------------
  char car, car2;
  string s, st;
  long long n = 0, a = 0, b = 0, c = 0, e, d = 0, m = 0, t = 0, q = 0, r = 0,
            l = 0, middle = 0, count = 0, add = 0, k, ans = 0, temp = 0, rootsa,
            save = 0, bigg = 0, save2 = 0, counter = 0, counter2 = 0, sum = 0,
            x, y;
  bool flag = false, flag2;

  //-------- --------------VARs--------------------------------------------
  vector<int> vec;
  memset(dp, -1, sizeof(dp));
  cin >> r >> c;
  gr = r;
  gc = c;
  for (int i = 1; i <= r; i++)
    for (int i2 = 1; i2 <= c; i2++)
      cin >> grid[i][i2];

  cout << whatdo(1, 1);
}
int main() {
#ifndef ONLINE_JUDGE
  system("clear");
  freopen("Test0.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false), cin.tie(0);

  cout << fixed << setprecision(10);
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 14860
#include<stdio.h>

int main(){
	int a,b,sum;
	int num;
	while(scanf("%d%d",&a,&b)!=EOF){
		sum=a+b;
		num = 0;
		while(sum){
			sum=sum/10;
			num++;
		}
		printf("%d\n",num);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;


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


#define INF 		2000000007
#define MOD			998244353

#define MAX 		100005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;




int main(){
	int N;	cin >> N;
	int cnt = 0;
	string str;
	int frontB=0, backA=0,bothAB=0;

	REP(i,N){
		cin >> str;
		if(str[0] == 'B' && str[str.length()-1]=='A')bothAB++;
		else if(str[0] == 'B')frontB++;
		else if(str[str.length()-1] == 'A')backA++;
		REP(j,str.length()-1){
			if(str[j]=='A' && str[j+1]=='B')cnt++;
		}
	}

	if(bothAB == 0) cnt += min(frontB,backA);
	else if(frontB + backA > 0)cnt += bothAB + min(frontB,backA);
	else cnt += bothAB - 1;

	cout << cnt << endl;

	return 0;
}

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

int main(){
  int ret=0;
  int num;
  char op[3];

  cin >> ret;

  while (1){
    cin >> op;
    if (op[0]=='=')break;
    cin >> num;
    if (op[0]=='+') ret += num;
    else if (op[0]=='-')ret -= num;
    else if (op[0]=='*')ret *= num;
    else if (op[0]=='/')ret /= num;
  }

  cout << ret<< endl;
  return 0;
}

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

namespace Atcoder
{
    class Atcoderrrrrrr
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            int M = int.Parse(s[1]);
            int X = int.Parse(s[2]);

            int[] array = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int Cost=0;
            for(int i = X;i<N;i++){
                if(array.Contains(i)==true){
                    Cost++;
                }
            }
            int cost =0;
            for(int j = X;0<j;j--){
                if(array.Contains(j)==true){
                    cost++;
                }
            }

            Console.WriteLine(
                Cost>cost? cost:Cost
            );
        }
    }
}


Measured memory_bytes: 11348
n=int(input())
h=list(map(int, input().split()))
dp=[0]*n
dp[1]=abs(h[1] - h[0])

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

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

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i)
{
    return i % 2;
}

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b)
{
    return __gcd(a, b);
}
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f)
{
    if (f)
        printf("Yes\n");
    else
        printf("No\n");
}
void YES_NO(bool f)
{
    if (f)
        printf("YES\n");
    else
        printf("NO\n");
}

template <typename T>
void deb1(T x)
{
    cout << x << "\n";
}

template <typename T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
//-------------------ここから回答する-----------------------

void solve(void)
{
    string s, t;
    cin >> s >> t;
    const int INF = 1e9;
    int ans = INF;
    rep(i, s.length() - t.length() + 1)
    {
        int res = 0;
        rep(j, t.length()) if (s[i + j] != t[j]) res++;
        ans = min(ans, res);
    }
    cout << ans << endl;
}
int main(void) { solve(); }

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
 
#define int long long int
#define pb push_back
#define mp make_pair
#define loop(i,x,n) for(int i=x;i<=n;i++)
#define rloop(i,x,n) for(int i=x;i>=n;i--)
#define ff first
#define ss second
#define N4RUTO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
tree_order_statistics_node_update>
ordered_set;
 
int32_t main(){
    N4RUTO;
    int n,k;
    cin>>n>>k;
    int a[n];
    loop(i,0,n-1)  cin>>a[i];
    sort(a,a+n);
    int ans = 0;
    loop(i,0,n-k-1){
        ans+=a[i];
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef pair<double,int>Q;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
int n,x;
int a[200005],b[200005];
int main(){
	cin>>n;
	repn(i,2*n-1)cin>>a[i];
	int lb = 1,ub = 2*n;
	while(ub-lb>1){
		int mid = (lb+ub)/2; //mid = 8;
		repn(i,2*n-1) b[i] = (a[i]>=mid);
		if(b[n] == b[n-1] || b[n] == b[n+1]){
			if(b[n]) lb = mid;
			else ub = mid;
		}
		else{
		    //cout<<"N"<<endl;return 0;
			int check = -1;
			int cur = n-1;
			while(cur >= 1 && b[n]^( (n-cur)%2 ) == b[cur]){
				cur--;
			}
			int cur2 = n+1;
			while(cur2 <= 2*n-1 && b[n]^( (cur2-n)%2 ) == b[cur2]){
				cur2++;
			}
			int beg = (cur==0?1:cur+2);
			int en = (cur2==2*n?2*n-1:cur2-2);
			//if(mid==8)cout<<beg<<en<<endl;
			if(beg == 1 && en == 2*n-1){
				check = b[1];
				//assert(b[1] == b[2*n-1]);
			}
			else if(beg%2 == en%2){
				check = b[beg]^1;
				//assert(b[cur+2] == b[cur2-2]);
			}
			else{
				if(beg == 1){
					check = b[1];
				}
				else if(en == 2*n-1){
					check = b[2*n-1];
				}
				else{
					int L = (beg+en)/2;
					if(beg<=n && n<=L) check = b[beg]^1;
					else check = b[beg];
				}
			}
			if(check) lb = mid;
			else ub = mid;
		}
	}
	cout<<lb<<endl;
}

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

using namespace std;

vector<int> field[10][10];
int n,m,p;
pair<int,int> orders[1000];

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

bool check(int x,int y){
    int dig=field[y][x][field[y][x].size()-1];
    for(int i = 0; i < 13; i++){
        int cnt=-1;
        int cx=x;
        int cy=y;
        int cz=field[cy][cx].size()-1;
        while(cy>=0&&cx>=0&&cz>=0&&cy<n&&cx<n&cz<field[cy][cx].size()&&field[cy][cx][cz]==dig){
            cy+=dy[i];
            cx+=dx[i];
            cz+=dz[i];
            cnt++;
        }
        cx=x;cy=y;cz=field[cy][cx].size()-1;
        while(cy>=0&&cx>=0&&cz>=0&&cy<n&&cx<n&cz<field[cy][cx].size()&&field[cy][cx][cz]==dig){
            cy-=dy[i];
            cx-=dx[i];
            cz-=dz[i];
            cnt++;
        }
        if(cnt>=m)return true;
    }
    return false;
}

int main(){
    while(cin>>n>>m>>p&&!(n==0&&m==0&&p==0)){
        for(int i = 0; i < n; i++)for(int j = 0; j < n; j++) field[i][j].clear();
        for(int i = 0; i < 1000; i++)
            orders[i].first=orders[i].second=0;
        for(int i = 0; i < p; i++){
            cin>>orders[i].second>>orders[i].first;
            orders[i].first--;
            orders[i].second--;
        }
        for(int i = 0; i < p; i++){
            int num=1;
            if(i%2==0)num=0;
            field[orders[i].first][orders[i].second].push_back(num);
            if(check(orders[i].second,orders[i].first)){
                if(i%2==0)
                    cout<<"Black "<<i+1<<endl;
                else
                    cout<<"White "<<i+1<<endl;
                break;
            }
            if(i==p-1)
                cout<<"Draw"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
#include <random>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<bool> vbool;
typedef vector<string> vstr;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& istr, pair<_KTy, _Ty>& m) { cin >> m.first >> m.second; return istr; }
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) cin >> v[i]; return istr; }
ll modpow(ll n, ll p, ll m) { ll result = 1; while (p > 0) { if (p & 1) result = (result * n) % m; p >>= 1; n = (n * n) % m; } return result; }
template <typename _Ty> _Ty ipow(_Ty x, _Ty n) { _Ty ret = _Ty(1); for (_Ty i = _Ty(0); i < n; i++) ret *= x; return ret; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false




int main()
{
	//clock_t start, end;
	//start = clock();

	string S;
	cin >> S;

	int q;
	cin >> q;

	for (int i = 0; i < q; i++) {
		string T, sub;
		int a, b;
		cin >> T >> a >> b;
		
		sub = S.substr(a, b - a + 1);
		
		if (T == "print")
			cout << sub << endl;
		if (T == "reverse") {
			reverse(all(sub));
			S.replace(a, b - a + 1, sub);
		}
		if (T == "replace") {
			string p;
			cin >> p;
			S.replace(a, b - a + 1, p);
		}
	}


	//end = clock();
	//printf("%d msec.\n", end - start);

	return 0;
}



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

int main(){
	int x,y;
	cin>>x>>y;
	int a1=x;
	while(a1>=0){
		if((a1*2+(x-a1)*4)==y){
			cout<<"Yes";
			return 0;
		}
		a1--;
	}
	cout<<"No";
}

Measured memory_bytes: 3576
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,s[300000],ans;
int main(void){
    cin>>n;
    for(int i=0;i<n*3;i++)cin>>s[i];
    sort(s,s+n*3);
    for(int i=0;i<n;i++){
        ans+=s[n+2*i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2560
w, h, c = input().split()
w = int(w)
h = int(h)
end = "+" + "-" * (w - 2) + "+"
center = "|" + "." * ((w - 3) // 2) + c + "." * ((w - 3) // 2) + "|"
common = "|" + "." * (w - 2) + "|"
for i in range(h):
  if i in (0, h - 1):
    print(end)
  elif i == h // 2:
    print(center)
  else:
    print(common)


Measured memory_bytes: 5600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();

		if(a%2 == 0)
		{
			System.out.println((a/2));
		}
		else
		{
			System.out.println((a/2)+1);
		}
	}

}

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

using vi = std::vector<int>;

constexpr int nil = 0;

class BinaryHeap
{
public:

    BinaryHeap(int n)
        : nodes(n + 1)
    {}

    ~BinaryHeap() = default;

    int parent(int id) const
    {
        return modifiedIndex(id / 2);
    }

    int left(int id) const
    {
        return modifiedIndex(id * 2);
    }

    int right(int id) const
    {
        return modifiedIndex(id * 2 + 1);
    }

    int size() const
    {
        return nodes.size();
    }

    void show(int id) const
    {
        using namespace std;
        cout << "node " << id << ": key = " << nodes[id] << ", ";
        if (parent(id) != nil) 
            cout << "parent key = " << nodes[parent(id)] << ", ";
        if (left(id) != nil)
            cout << "left key = " << nodes[left(id)] << ", ";
        if (right(id) != nil)
            cout << "right key = " << nodes[right(id)] << ", ";
        cout << endl;
    }

    void show() const
    {
        for (int i = 1; i < nodes.size(); ++i)
        {
            show(i);
        }
    }
 
    const int& operator[](int i) const
    {
        return nodes[i];
    }

    int& operator[](int i)
    {
        return nodes[i];
    }

private:

    vi nodes;

    int modifiedIndex(int i) const
    {
        if (i <= 0 || i >= nodes.size())
            i = nil;
        return i;
    }
};

void solve()
{
    using namespace std;
    int n;
    cin >> n;

    BinaryHeap bh {n};

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

    bh.show();
}

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


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

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

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

using namespace std;

string x;
string y;
int dp[3030][3030];
int lcs (int a, int b)
{
    if(dp[a][b]>=0){return dp[a][b];}
    if(a==x.size() or b==y.size()){return dp[a][b]=0;}

    if(x[a]==y[b]){return dp[a][b]=1+lcs(a+1,b+1);}

    else{return dp[a][b]=max(lcs(a+1,b),lcs(a,b+1));}
}
vector<char> v;
void recover (int i, int j)
{
    if(i==x.size() or j==y.size())return;

    int pega = -191919;
    if(x[i]==y[j]){pega=lcs(i+1,j+1);}
    int passa1 = lcs(i+1,j);
    int passa2 = lcs(i,j+1);

    if(pega>=passa1 and pega>=passa2){v.push_back(x[i]); return recover(i+1,j+1);}
    else if (passa1>pega and passa1>passa2){return recover(i+1,j);}
    else {return recover(i,j+1);}
}

int main ()
{

cin>>x;
cin>>y;
memset(dp,-1,sizeof(dp));
recover(0,0);
for(int i=0;i<v.size();i++)
{
    cout<<v[i];
}
cout<<endl;
    return 0;
}


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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first


int n,a[100005],dp[100005];

int main(){
  cin >> n;
  for(int i=0;i<n;++i){
    cin >> a[i];
  }
  dp[0]=0;
  dp[1]=abs(a[0]-a[1]);
  for(int i=2;i<n;++i){
    dp[i]=min(abs(a[i-1]-a[i])+dp[i-1],abs(a[i-2]-a[i])+dp[i-2]);
  }
  cout << dp[n-1];

  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> L(N);
  for(int i=0;i<N;i++){
    cin >> L[i];
  }
  sort(L.begin(),L.end());
  int a=0;
  for(int i=0;i<N-1;i++){
    a+=L[i];
  }
  string ans;
  if(L.at(N-1)<a){
    ans="Yes";
  }
  else{
    ans="No";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.sql.Array;
import java.util.*;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }


    static class TaskD {
        public int log(long a){
            int num = 0;
            while (a > 0){
                num++;
                a>>=1;
            }
            return num;
        }
        public long binerypow(long a){
            if (a == 0) return 1;
            long v = binerypow(a/2);
            return v*v*(a%2==1?2:1);
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int x = in.nextInt();
            int mod = x%100;
            int div = (x/100)*5;
            if (mod > div) System.out.println(0);
            else System.out.println(1);










        }



    }

    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 int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n;
	cin >> n;
	vector<int> col(8);
	int rem = 0;
	for(int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if(a >= 3200) {
			rem++;
			continue;
		}
		col[a / 400]++;
	}
	int mi = 0, mx = 0;
	for(int i = 0; i < 8; i++) {
		if(col[i]) {
			mi++;
			mx++;
		}
	}
	mx += rem;
	if(mi) {
		cout << mi << " " << mx << endl;
	}
	else {
		cout << 1 << " " << mx << endl;
	}
	return 0;	
}


Measured memory_bytes: 256
a,b,c = map(int, input().split())
test = 0
if a==b and b!=c:
  print('Yes')
  test = 1
if a==c and b!=c:
  print('Yes')
  test = 1
if c==b and a!=c:
  print('Yes')
  test = 1
if test == 0:
  print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define pb push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll X;
int main(){
    cin>>X;
    ll l=0,r=X;
    while(r-l>1){
        ll md = (l+r)/2;

        ll t = md * (md+1) / 2;
        if(t < X){
            l = md;
        }else{
            r = md;
        }
    }
    cout << min(X,r) << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
mod = 10 ** 9 + 7
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]


def cmb(n, r):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % mod

def perm(n, r):
    if (r < 0) or (n < r):
        return 0
    return fact[n] * factinv[n - r] % mod


for i in range(2, M + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)


ans = 0
for i in range(N+1):
    ans += cmb(N, i) * perm(M - i, N - i) * (-1) ** i
    ans %= mod
ans *= perm(M, N)
ans %= mod

print(ans)

Measured memory_bytes: 192528
import numpy as np

def rev(i):
    if i==0:
        return 1
    return 0

N=int(input())
A=np.array(list(map(int,input().split())))
s=[]
for i in range(N):
    if A[i]>=0:
        s.append(1)
    else:
        s.append(0)

s[::-1]
for i in range(N-1):
    if s[i]==0:
        s[i]=1
        s[i+1]=rev(s[i+1])
if np.sum(s)!=N:
    ans=np.sum(np.abs(A))-2*np.min(np.abs(A))
    print(ans)
else:
    print(np.sum(np.abs(A)))

Measured memory_bytes: 23384
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
print('YES' if len(a) == len(set(a)) else 'NO')

Measured memory_bytes: 117584
#include <bits/stdc++.h>
using namespace std;
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
  int x;
  cin >> x;
  bool is_prime = IsPrime(x);
  if (is_prime == true) {
    cout << x << endl;
  } else {
    while (1) {
      x++;
      is_prime = IsPrime(x);
      if (is_prime == true) {
        cout << x << endl;
        break;
      }
  	}
  }
}

Measured memory_bytes: 256
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
      var   n = int.Parse(line[0]);
      var   m = int.Parse(line[1]);
      var   k = long.Parse(line[2]);
        line = Console.ReadLine().Trim().Split(' ');
       var  a = Array.ConvertAll(line, int.Parse);
        line = Console.ReadLine().Trim().Split(' ');
        var b = Array.ConvertAll(line, int.Parse);
        var t = getAns(a, b, k);
        Console.WriteLine(t);
    }
    static int getAns (int [] a, int [] b , long k)
    {
        var aL = a.Length;
        var bL = b.Length;
        var bsum = 0L;
        var bcount = 0;
        var p = 0;
        for (int i = 0; i < bL; i++)
        {
            bsum += b[i];
            if (bsum > k) { bsum -= b[i]; p = i - 1;   break; }
            bcount++;
            p++;
        }
        var res = bcount;
        if (bcount == bL) p = bL - 1;
        for (int i = 0; i < aL; i++)
        {
            k -= a[i];
            if (k < 0) break;
            while (p >= 0)
            {
                if (bsum <= k) break;
                else  bsum -= b[p];
                p--;
            }
            res = Max(res, i + 2 + p);
        }
        return res;
    }
}


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

int main(){
    int s;
    int n = 0;
    vector<int> a;
    
    cin >> s;
    n = s;
    a.push_back(s);

    int i = 0;
    while(true){
        if(a[i] % 2 == 0){
            a.push_back(a[i]/2);
        } else {
            a.push_back(3*a[i]+1);
        }
        //cout << a[a.size()-1]  << endl;
        i++;
        for(int j = 0; j < a.size()-1; j++){
            if(a[a.size()-1] == a[j]){
                cout << a.size() << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,cnt=0,ans=0;
  cin>>n;
  vector<int> x(n);
  
  for(int i=0; i<n; ++i){
    cin>>x[i];
    cnt += x[i];
  }
  
  sort(x.begin(),x.end());
  
  if(cnt % 10 == 0){
    for(int i=0; i<n; ++i){
      if(x[i] % 10 != 0){
        cnt -= x[i];
        break;
      }
      ans += x[i];
    }
    if(cnt == ans)
      cnt = 0;
  }
  
  cout<<cnt<<'\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair <int, int> pii;
typedef vector<int> vi;

#define mp make_pair
#define pb push_back

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
 
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
 
const int MOD = 1000000007;
double PI = 4*atan(1);

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int N; cin >> N;
	vector<ll> seq(N); F0R(i,N) cin >> seq[i];
	
	ll s = 0, sgn = 0, ans = 0;
	F0R(i,N) {
	    s += seq[i];
	    if (sgn == 1) {
	        if (s<=0) {
	            ans += 1-s;
	            s = 1;
	        }
	    } else {
	        if (s>=0) {
	            ans += s+1;
	            s = -1;
	        }
	    }
	    sgn = 1-sgn;
	}
	s = 0; sgn = 1;
	ll ans1 = 0;
	F0R(i,N) {
	    s += seq[i];
	    if (sgn == 1) {
	        if (s<=0) {
	            ans1 += 1-s;
	            s = 1;
	        }
	    } else {
	        if (s>=0) {
	            ans1 += s+1;
	            s = -1;
	        }
	    }
	    sgn = 1-sgn;
	}
	cout << min(ans,ans1);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,a[200009],tmp=0,ans=0;
vector<int>b[200009];
int main()
{
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d",&a[i]),b[a[i]].push_back(i);
    for(int i=1; i<=n; i++)
    {
        int locate=lower_bound(b[i].begin(),b[i].end(),tmp)-b[i].begin();
        if(locate==b[i].size())
            break;
        tmp=b[i][locate];
        ans++;
    }
    printf("%d",n-ans==n?-1:n-ans);
    return 0;
}


Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int P = 1'000'000'007;
ll power(ll x, ll t) {
	ll ret = 1;
	for(; t; t >>= 1, x = x * x % P) {
		if(t & 1) {
			ret = ret * x % P;
		}
	}
	return ret;
}
int main() {
	int n, k;
	cin >> n >> k;
	k = min(k, n - 1);
	vector<ll> fac;
	vector<ll> inv;
	vector<ll> facinv;
	fac.resize(n + 1);
	inv.resize(n + 1);
	facinv.resize(n + 1);
	fac[0] = 1;
	inv[1] = 1;
	facinv[0] = 1;
	for(int i = 1; i <= n; ++i) {
		if(i != 1) {
			inv[i] = (P - P / i) * inv[P % i] % P;
		}
		fac[i] = fac[i - 1] * i % P;
		facinv[i] = facinv[i - 1] * inv[i] % P;
	}
	auto C = [&] (int n, int m) {
		return fac[n] * facinv[m] % P * facinv[n - m] % P;
	};
	ll ans = 0;
	for(int i = 0; i <= k; ++i) {
		ans = (ans + C(n, i) * C(n - 1, i) % P) % P;
	}
	cout << ans << '\n';
	/*
	 1 1 2

	 3 1
	 2 2
	 1 3
	 */
	return 0;
}

Measured memory_bytes: 5504
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int K, X;
signed main(){
    cin >> K >> X;
    if(500*K >= X) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,ma=0,ans;
vector <int>num;
int nu=0;
map <int,int>a;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		int t;
		cin>>t;
		if(a[t]==0){
			num.push_back(t);
			nu++;
		}
		a[t]++;
	}
	for(int i=0;i<nu;i++){
		if(a[num[i]]<num[i]){
			ans+=a[num[i]];
		}else if(a[num[i]]>num[i]){
			ans+=a[num[i]]-num[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

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


int main() {
  int ans= 0, cnt;
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    cnt = 0;
    for(int j = i; j < s.size(); j++){
      if((s[j] == 'A') || (s[j] == 'G') || (s[j] == 'C') || (s[j] == 'T'))cnt++;
      else break;
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<map>
using namespace std;
map<int,int> M;
int x,n,T=0;
int main(){
	int bj=0,maxn=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		if(bj){puts("No");continue;}
		if(x<=T){
//			cout<<maxn<<endl;
			if(maxn>x)	puts("No");
			else		puts("Yes"),bj=1;
			continue;
		}
		maxn=max(maxn,x);
		M[x]++;puts("Yes");
		while(M[x]==2){maxn=maxn==x?maxn-1:maxn;M[x]=0;M[--x]++;}
		while(M[T+1])	T++;
	}
}



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

using int64 = long long;
constexpr int64 kMod = 1000000007;

int64 PowMod(int64 a, int64 e) {
  int64 r = 1;
  for (; e; e >>= 1) {
    if (e & 1)
      r = r * a % kMod;
    a = a * a % kMod;
  }
  return r;
}

int main() {
  int64 n;
  cin >> n;
  vector<int64> as(n + 1);
  for (int64 i = 0; i <= n; ++i)
    cin >> as[i];
  int64 x = accumulate(as.begin(), as.end(), 0LL) - n * (n + 1) / 2;

  int64 l = find(as.begin(), as.end(), x) - as.begin();
  int64 r = find(as.begin() + l + 1, as.end(), x) - as.begin();

  int64 all = 1;
  int64 dup = 1;
  int64 m = n - r + l;
  for (int64 k = 1; k <= n + 1; ++k) {
    all = all * (n + 2 - k) % kMod;
    all = all * PowMod(k, kMod - 2) % kMod;
    if (k - 1 > m)
      dup = 0;
    else if (k > 1) {
      dup = dup * (m - k + 2) % kMod;
      dup = dup * PowMod(k - 1, kMod - 2) % kMod;
    }
    int64 ret = all - dup;
    if (ret < 0)
      ret += kMod;
    cout << ret << "\n";
  }

  return 0;
}


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

int n,m,a,b;
map<int,int> M[220000];

int main(){
    cin >> n >> m;

    for(int i=0;i<m;i++){
        cin >> a >> b;
		M[a][b]=1;
		M[b][a]=1;
    }
    
	for(int i=2;i<=n;i++){
        if(M[1][i]==1 && M[i][n]==1){
			cout << "POSSIBLE" << endl;
			return 0;
		}
    }
    
	cout << "IMPOSSIBLE" << endl;

    return 0;
}


Measured memory_bytes: 38656