akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(int, n);
	OUT((1000 - n % 1000) % 1000);
}


Measured memory_bytes: 3632
#include <cstdio>
char s[200009];
int main() {
	scanf("%s", s);
	int l = 999999999, r = 0;
	for (int i = 0; s[i]; i++) {
		if (s[i] == 'A' && l == 999999999) l = i;
		if (s[i] == 'Z') r = i;
	}
	printf("%d\n", r - l + 1);
	return 0;
}

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

def li(x):
    L = []
    while x > 0:
        L.append(x % 10)
        x = x // 10
    return L

sum = 0
for i in range(A,B+1):
    if (li(i)[0] == li(i)[4]) and (li(i)[1] == li(i)[3]):
        sum += 1
        
print(sum)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;

public class Main {

    public static void main(String[] args) throws Exception {
	    String input = Io.read();

        ArrayDeque<Character> q = new ArrayDeque<Character>();
	    for (char c : input.toCharArray()){
            if (c == 'B') {
                if (!q.isEmpty()){
                    q.removeLast();
                }
            } else {
                q.add(c);
            }
        }
        StringBuilder builder = new StringBuilder();
        for (char c : q.toArray(new Character[0])) {
	        builder.append(c);
        }

        Io.write(builder.toString());
    }
}

class Io {

    /**
     * 標準入力から1行ずつ受け取る
     * @return
     * @throws IOException
     */
    public static String read() throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();

        br.close();
        return line;
    }

    /**
     * 標準出力
     * @param line
     */
    public static void write(String line)
    {
        System.out.println(line);
    }
}

Measured memory_bytes: 22612
#include <iostream>
#include <cmath>

int main() {
    using namespace std;
    int a, b, i, p, count;
    cin >> a >> b;
    count = 0;

    for(i=0; i<10; i++){
        p = b * 10 + i;
        if(a == floor(p * 0.08)){
            cout << p;
            break;
        }
        count += 1;
        if (count == 10){
            cout << -1;
        }
    }
}

Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;
int deco[1000];

ll res[11];
int c[30];
void Sequence() {
	string w;
	cin >> w;
	for (size_t i = 0; i < w.size(); i++)
	{
		c[w[i] - 'a']++;
	}

	for (size_t i = 0; i < 30; i++)
	{
		if (c[i] % 2 != 0) {
			cout << "No" << endl;
			return;
		}
	}
	cout << "Yes" << endl;

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



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

using namespace std;

typedef vector<int> vint;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin() (x).end()
#define pb push_back

int n,q;
vint s,t;

bool linear_search(int x) {
    rep(i,n) if(s[i] == x) return true;
    return false;
}

int main() {
    cin>>n;
    rep(i,n) {
        int a; scanf("%d",&a);
        s.push_back(a);
    }
    cin>>q;
    rep(i,q) {
        int a; scanf("%d",&a);
        t.push_back(a);
    }

    int ans = 0;
    rep(i,q) {
        if(linear_search(t[i])) ans++;
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 1372
N = int(input())

fizzbuzz = []

for i in range(1, N+1):
    if i % 3 == 0 or i % 5 == 0:
        fizzbuzz.append('0')
    else:
        fizzbuzz.append(str(i))

num = [int(s) for s in fizzbuzz]
print(sum(num))

Measured memory_bytes: 75040
#include<bits/stdc++.h>
#define ll long long 

using namespace std;


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    string s;
    vector<string> arr;
    map<string,int> mp;
    for(int i=0;i<n;i++)
    {   cin>>s;
    	arr.push_back(s);
    	mp[s]=0;
	}
	int maxi=INT_MIN;
	for(int i=0;i<n;i++)
	{
		mp[arr[i]]++;
		maxi=max(maxi,mp[arr[i]]);
	}
	set<string> ans;
	
	for(int i=0;i<n;i++)
	{
		if(mp[arr[i]]==maxi)ans.insert(arr[i]);
	}
	set<string> :: iterator it;
	for(it=ans.begin();it!=ans.end();it++)
	{
		cout<<*it<<endl;
	}

}



Measured memory_bytes: 34800
import sys

# sys.stdin = open('b1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    n = read_int()
    res = 0
    for i in range(n):
        l, r = read_int_list()
        r0 = r - l + 1
        res += r0
    print(res)


main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int N; cin >> N;
    vector<int> P(N); for (auto &p : P) cin >> p;
    int ans = 0;
    for (int i = 1; i < N-1; i++) {
        int A[3];
        A[0] = P[i-1]; A[1] = P[i]; A[2] = P[i+1];
        sort(begin(A), end(A));
        if (A[1] == P[i]) ans++;
    }
    cout << ans << '\n';
    return 0;
}

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

int main(void){
    int N, ans=0;
    std::cin >> N;
    std::vector<int> B(N);
    for (int i=0; i<N-1; ++i){
        std::cin >> B.at(i);
    }
    
    ans += B.at(0);
    
    for (int i=1; i<N-1; ++i){
        ans += std::min(B.at(i-1), B.at(i));
    }

    ans += B.at(N-2);

    std::cout << ans << std::endl;

    return 0;
}


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

using namespace std;

#define N 800000

int n,x,y,tot,S,T,xb,cnt,head[N],q[N],mx[N],num[N],a[N];
bool vis[N];
struct edge{int v,nxt;}e[N];

void add(int x,int y){e[++tot].v=y; e[tot].nxt=head[x]; head[x]=tot;}

void bfs(){
	memset(vis,0,sizeof vis);
	int tt=0,ww=0; q[++ww]=S; vis[S]=1;
	while (tt<ww){
		int u=q[++tt];
		for (int i=head[u],v;i;i=e[i].nxt)
			if (!vis[v=e[i].v]){
				vis[v]=1;
				q[++ww]=v;
			}
	}
	T=q[ww];
}

void dfs(int u,int fa){
	int tmp=0; mx[u]=0;
	for (int i=head[u],v;i;i=e[i].nxt)
		if ((v=e[i].v)!=fa){
			dfs(v,u); mx[u]=max(mx[u],mx[v]);
			if (mx[v]>1) ++tmp;
			else if (v!=T) ++num[u];
		}
	if (tmp>1){puts("-1"); exit(0);}
	++mx[u];
	if (u!=S&&u!=T&&mx[u]>1) a[++xb]=num[u];
}

void print(int u,int fa){
	int t=++cnt;
	for (int i=head[u],v;i;i=e[i].nxt)
		if ((v=e[i].v)!=fa&&mx[v]==1&&v!=T)
			printf("%d ",++cnt);
	printf("%d ",t);
	for (int i=head[u],v;i;i=e[i].nxt)
		if ((v=e[i].v)!=fa&&(mx[v]>1||v==T))
			print(v,u);
}

int main(){
	scanf("%d",&n);
	for (int i=1;i<n;++i){
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	S=1; bfs(); S=T; bfs();
	dfs(S,0); reverse(a+1,a+xb+1);
	bool fl=1;
	for (int i=1;i<=xb;++i){
		if (a[i]<a[xb-i+1]){fl=1; break;}
		if (a[i]>a[xb-i+1]){fl=0; break;}
	}
	xb=0;
	if (fl) print(S,0);
	else{swap(S,T); dfs(S,0); print(S,0);}
	
	return 0;
}
			

Measured memory_bytes: 19968
n = int(input())
s = input()

ans = 0
p = 0
q = 0
sai = 0
v = 0
w = 0
pairs = []
for i in range(n - 1, -1, -1):
    if s[i] == "." and sai == 0:
        p = 0
        q = 0
        p += 1
        v = 1
        sai = 1
    elif s[i] == "." and v == 0:
        pairs.append([q, p])
        p = 0
        q = 0
        w = 0
        p += 1
        v = 1
    elif s[i] == "." and v == 1:
        p += 1
    elif s[i] == "#" and w == 0 and sai == 1:
        v = 0
        q += 1
        w = 1
    elif s[i] == "#" and w == 1:
        q += 1
pairs.append([q, p])
rp = []
for i in range(len(pairs)):
    rp.append(pairs[-i-1])
d = []
prp = []
p0 = 0
p1 = 0
for i in range(len(rp)):
    p0 += rp[i][0]
    p1 += rp[i][1]
    prp.append([p0, p1])
for i in range(len(prp)):
    d.append(prp[i][0] + prp[len(prp) - 1][1] - prp[i][1])
d.append(prp[len(prp) - 1][0])
d.append(prp[len(prp) - 1][1])
print(min(d))


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

int main(){
    string s;
    cin >> s;
    int k = s.size();
    vector<vector<int>> dp(k, vector<int>(2, 0));
    for (int i = 0; i < k; i++) dp[i][0] = 1;
    for (int i = 0; i < k; i++){
        if (s[i] == 'R'){
            dp[i + 1][1] += dp[i][0];
            dp[i][0] = 0;
            dp[i + 1][0] += dp[i][1];
            dp[i][1] = 0;
        }
    }
    for (int i = k - 1; i >= 0; i--){
        if (s[i] == 'L'){
            dp[i - 1][1] += dp[i][0];
            dp[i][0] = 0;
            dp[i - 1][0] += dp[i][1];
            dp[i][1] = 0;
        }
    }
    vector<int> ans(k, 0);
    for (int i = 0; i < k; i++) ans[i] += dp[i][0];
    for (int i = 0; i < k; i++){
        if (s[i] == 'R' && s[i + 1] == 'L') ans[i] += dp[i + 1][1];
        if (s[i] == 'L' && s[i - 1] == 'R') ans[i] += dp[i - 1][1];
    }
    for (int i = 0; i < k; i++){
        cout << ans[i];
        if (i != k) cout << " ";
    }
    cout << endl;
}

Measured memory_bytes: 6400
#include<iostream>

using namespace std;

//sample3つをもとに試行錯誤した
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    int h[n]; for (int i = 0; i < n; ++i) cin >> h[i];
    int i = 1;
    int ans = h[0];
    while (i < n) {
        int tmp = i - 1;
        while (h[i - 1] < h[i] && i < n) i++;
        ans += h[i - 1] - h[tmp];
        //cout << ans << endl;
        i++;
    }
    cout << ans << endl;
    
}


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

int main()
{
    int n;
    cin >> n;
    string result = "APPROVED";
    for(int i = 0; i < n; ++i)
    {
        int t;
        cin >> t;
        if(t%2 == 0
        && t%3 != 0
        && t%5 != 0)
        {
            result = "DENIED";
        }
    }

    cout << result << endl;
}

Measured memory_bytes: 256
a,b,c = map(int,input().split())
count = 0
if a==b and b==c:
    if a%2==1:
        count = 0
    else:
        count = -1
else:
    while True:
        if a%2==1 or b%2==1 or c%2==1:
            break
        d = a;e = b
        a = b//2 + c//2
        b = d//2 + c//2
        c = d//2 + e//2
        count += 1
print(count)

Measured memory_bytes: 38384
#pragma warning(disable:4996)
#include<iostream>
#include<algorithm>
#include<memory.h>
#include<string>	
using namespace std;
typedef long long ll;
const int Max = 1e5 + 5;

int main()
{
	int n, y;
	cin >> n >> y;
	int f = 0;
	for (int i = 0; i <= y / 10000; i++)
	{
		for (int j = 0; j <= y / 5000; j++)
		{
			if (i + j > n)continue;
			if ((n - i - j) * 1000 + i * 10000 + 5000 * j == y)
			{
				cout << i << " " << j << " " << n - i - j;
				return 0;
			}
		}
	}
	if (f == 0)cout << -1 << " " << -1 << " " << -1;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

bool compare_by_second(pair<ll, ll> a, pair<ll, ll> b) {
  return a.second < b.second;
}

int main(){
  ll n;cin>>n;
  vector<pair<ll,ll>> robots;
  rep(i, n){
    ll x,l;cin>>x>>l;
    robots.push_back(make_pair(x-l, x+l));
  }
  sort(robots.begin(), robots.end(), compare_by_second);

  ll result=0;
  ll current=0;
  rep(i,n-1){
    if(robots[i+1].first<robots[current].second){
      result++;
//cout<<robots[i+1].first<<' '<<robots[current].second<<endl;
    }else{
      current=i+1;
    }
  }

  cout<<n-result;

  return 0;
}

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

cnt = 0
for i in range(N):
    if cnt > 2:
        break

    if Nlist[i] == (i + 1):
        continue
    else:
        cnt += 1

if cnt > 2:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 3060
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
ll power(ll x, ll y); 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitcount(n) __builtin_popcountll(n)
#define in_edges(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B);}
#define in_edges3(M) repp(I, 1, M){int A, B, C; cin >> A >> B >> C; v[A].pb(B, C), v[B].pb(A, C);}
#define endl "\n"

const ll MOD = 1000000007;
const ll INF = 1e18;
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    quickio
    ll n, k;
    cin >> n >> k;

    ll p[n + 5], c[n + 5];
    repp(i, 1, n) cin >> p[i];
    repp(i, 1, n) cin >> c[i];

    ll res = -INF;
    repp(st, 1, n){

        ll s = 0, cur = st, cnt = 0;
        while(cur != st || !cnt){
            cur = p[cur];
            s += c[cur];
            ++cnt;
        }
        
        cur = st;
        ll sum = 0;
        repp(extra, 1, min(cnt, k)){
            cur = p[cur];
            sum += c[cur];
            auto x = (k - extra) / cnt;
            if(s >= 0) res = max(res, s*x + sum);
            else res = max(res, sum);
        }
    }

    cout << res;
}

ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

Measured memory_bytes: 3648
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1000000007;
struct bian
{
	int nxt,to;
}bi[10010];
int n,head[5050],num,dp[5050][5050],siz[5050],s[5050],ans;
inline void addedge(int from,int to){bi[++num]=bian{head[from],to};head[from]=num;}
void dfs(int v,int fa)
{
	siz[v]=1;
	dp[v][1]=1;
	for(int i=head[v],u;i;i=bi[i].nxt)
	{
		u=bi[i].to;
		if(u==fa)continue;
		dfs(u,v);
		int sum=0;
		for(int k=2;k<=siz[u];k+=2)sum=(sum+1ll*dp[u][k]*s[k])%mod;
		for(int j=siz[v]+siz[u];j;--j)
		{
			dp[v][j]=1ll*(mod-sum)*dp[v][j]%mod;
			for(int k=max(1,j-siz[v]);k<=siz[u]&&k<j;++k)dp[v][j]=(dp[v][j]+1ll*dp[u][k]*dp[v][j-k])%mod;
		}
		siz[v]+=siz[u];
	}
//	printf("%d:\n",v);
//	for(int i=1;i<=siz[v];++i)printf("%d ",dp[v][i]);printf("\n");
}
int main()
{
	scanf("%d",&n);
	s[0]=1;
	for(int i=2;i<=n;i+=2)s[i]=1ll*s[i-2]*(i-1)%mod;
	int x,y;
	for(int i=1;i<n;++i)
	{
		scanf("%d %d",&x,&y);
		addedge(x,y),addedge(y,x);
	}
	dfs(1,0);
	for(int i=2;i<=n;i+=2)ans=(ans+1ll*s[i]*dp[1][i])%mod;
	printf("%d",ans);
	return 0;
}


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

#define ll long long int
#define ull unsigned long long int
#define eb  emplace_back
#define all(x) x.begin(),x.end()
#define loop(a,n) for(ll i=a;i<n;i++)
#define debug(x)  cout<<#x<<" "<<x<<"\n";
#define mod 1e9+7
#define setbits(x)  __builtin_popcountll(x)
#define digits(a,x)  a=floor(log10(x)) + 1
#define ss second
#define ff first

bool prime(ll s);
ll power(ll x, ll y) ;
bool cmp(ll a, ll b)
{
    return a>b;
}
bool ispower2(ll n)
{
    
    return n && (!(n&(n-1)));
}
void solve()
{
    double d,t,s;
    cin>>d>>t>>s;
    
    if(d/t <=s)
    cout<<"Yes";
    else
    cout<<"No";
    
    
    
    
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    
    ll t=1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    
    return 0;
}



bool prime(ll s)
{
    if (s <= 1)  return false;
    if (s <= 3)  return true;
    if (s%2 == 0 || s%3 == 0) return false;

    for (ll i=5; i*i<=s; i=i+6)
        if (s%i == 0 || s%(i+2) == 0)
           return false;

    return true;
}

ll power(ll x, ll y) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2); 
    if (y%2 == 0) 
        return temp*temp; 
    else
        return x*temp*temp; 
} 

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

int main()
{
    string S;
    cin >> S;
    if(S == "Sunny")
        cout << "Cloudy" << endl;
    else if(S == "Cloudy")
        cout << "Rainy" << endl;
    else
        cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n;
	int a[10000],b[10000];
	int i,sa,sb;
	
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%d %d",&a[i],&b[i]);
		}
		sa=0;
		sb=0;
		for(i=0;i<n;i++){
			if(a[i]>b[i]){
				sa=sa+a[i]+b[i];
			}
			else if(a[i]<b[i]){
				sb=sb+a[i]+b[i];
			}
			else {
				sa=sa+a[i];
				sb=sb+b[i];
			}
		}
		printf("%d %d\n",sa,sb);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 1104
#!/usr/bin/env python3
import collections
N = int(input())
V = list(map(int, input().split()))

V1 = V[::2]
V2 = V[1::2]


C1 = collections.Counter(V1)
C2 = collections.Counter(V2)

C1_s = sorted(C1.items(), key=lambda x:x[1])[::-1]
C2_s = sorted(C2.items(), key=lambda x:x[1])[::-1]

max1 = C1_s[0][1]
index1 = C1_s[0][0]

max2 = C2_s[0][1]
index2 = C2_s[0][0]

max1_2 = 0
max2_2 = 0
if len(C1_s) > 1:
    max1_2 = C1_s[1][1]

if len(C2_s) > 1:
    max2_2 = C2_s[1][1]


nokori1 = len(V1) - max1
nokori2 = len(V2) - max2

nokori1_2 = len(V1) - max1_2
nokori2_2 = len(V2) - max2_2

ans = 0
if index1 == index2:
    ans = min(nokori1_2 + nokori2, nokori1 + nokori2_2)
else:
    ans = nokori1 + nokori2
print(ans)


Measured memory_bytes: 21952
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

N, M = map(int, input().split())
a = set()
for i in range(M):
    a.add(int(input()))

dp = [0 for i in range(N+1)]
dp[0] = 1
if 1 not in a:
    dp[1] = 1
else:
    dp[1] = 0

for i in range(2,N+1):
    if i not in a:
        dp[i] = (dp[i-1] + dp[i-2]) % mod
    else:
        dp[i] = 0

print(dp[N] % mod)

Measured memory_bytes: 95856
#include <bits/stdc++.h>
#define int int64_t
#define pb push_back
#define pii pair<int, int>
#define F first
#define S second
#define vecsort(x) sort(x.begin(), x.end())
#define vecrsort(x) sort(x.rbegin(), x.rend())
#define massort(x, n) sort(x, x + n)
#define FOR(i, n) for(int i = 0; i < n; i ++)
using namespace std;
int max(int32_t a, int b){
   return max((int)a, b);
}

const int INF = 1e18 + 7;
const int N = 1e5 + 2000;

pair<int, pii> dp[3010][3010];

pair<int, pii> max(pair<int, pii> a, pair<int, pii> b){
   if(a.F >= b.F)
      return a;
   else
      return b;
}

int32_t main(){
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   string s, t;
   cin >> s >> t;
   for(int i = 0; i < s.size(); i ++)
      for(int j = 0; j < t.size(); j ++)
         dp[i][j].S = {-1, -1};
   for(int i = 0; i < s.size(); i ++){
      for(int j = 0; j < t.size(); j ++){
         if(s[i] == t[j]){
            dp[i+1][j+1] = max(dp[i+1][j+1], {dp[i][j].F + 1, {i, j}});
         }
         dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
         dp[i][j+1] = max(dp[i][j+1], dp[i][j]);
      }
   }
   int ans = 0;
   pii st = {-1, -1};
   for(int i = 0; i < s.size()+2; i ++){
      for(int j = 0; j < t.size()+2; j ++){
         if(dp[i][j].F > ans){
            ans = dp[i][j].F;
            st = dp[i][j].S;
         }
      }
   }
   string way = "";
   while(st.F != -1){
      way += s[st.F];
      st = dp[st.F][st.S].S;
   }
   reverse(way.begin(), way.end());
   cout << way;

}



Measured memory_bytes: 211968
#include <iostream>
#include <cassert>
#include <complex>
#include <cstdlib>
#include <vector>
using namespace std;

#define EPS 1e-9
#define P complex<double>
#define L vector<P>
#define pb push_back
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define y1 Y1

int N,x1,y1,x2,y2,X,Y;

double cross(const P &a,const P &b){
    return imag(conj(a)*b);
}

P crosspoint(const L &l, const L &m) {
    double A = cross(l[1] - l[0], m[1] - m[0]);
    double B = cross(l[1] - l[0], l[1] - m[0]);
    if (abs(A) < EPS && abs(B) < EPS) return m[0];
    if (abs(A) < EPS) assert(false);
    return m[0] + B / A * (m[1] - m[0]);
}

bool online(int x1,int y1,int x2,int y2){
    return x1==x2 || y1==y2 || labs(x1-x2)==labs(y1-y2);
}

int main(){
	cin>>N;
    rep(tc,N){
        cin>>x1>>y1>>x2>>y2>>X>>Y;
        
        if(x1==X && y1==Y || x2==X && y2==Y){
            cout<<0<<endl;
            continue;
        }
        
        if(online(x1,y1,X,Y) && online(x2,y2,X,Y)){
            cout<<1<<endl;
            continue;
        }
        
        if(online(x1,y1,X,Y) || online(x2,y2,X,Y)){
            cout<<2<<endl;
            continue;
        }
        
        if(online(x1,y1,x2,y2)){
            cout<<3<<endl;
            continue;
        }
        
        P a(x1,y1),b(x2,y2);
        L l[4],m[4];
        l[0].pb(a); l[0].pb(a+P(1,0));
        l[1].pb(a); l[1].pb(a+P(1,1));
        l[2].pb(a); l[2].pb(a+P(0,1));
        l[3].pb(a); l[3].pb(a+P(-1,1));
        m[0].pb(b); m[0].pb(b+P(1,0));
        m[1].pb(b); m[1].pb(b+P(1,1));
        m[2].pb(b); m[2].pb(b+P(0,1));
        m[3].pb(b); m[3].pb(b+P(-1,1));
        
        rep(i,4)rep(j,4)if(i!=j){
            P p=crosspoint(l[i],m[j]);
            double x=p.real(), y=p.imag();
            int xx=floor(x+EPS), yy=floor(y+EPS);
            if(abs(x-xx) > 0.4)continue;
            if(online(xx,yy,X,Y)){
                cout<<3<<endl;
                goto end;
            }
        }
        
        cout<<4<<endl;
    end:;
    }
}

Measured memory_bytes: 0
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<cstdio>
#include<string>
#include<vector>
#include<math.h>
#include<time.h>
#include<utility>
#include<cstdlib>
#include<sstream>
#include<cstring>
#include<stdio.h>
#include<iomanip>
#include<iostream>
#include<algorithm>
//#include<conio.h>
//ios::sync_with_stdio(false);
using namespace std;
bool flag;
int a,b,c,d,e,f,ans,w,s;
vector<int> sugar,water;
int main(){
	cin>>a>>b>>c>>d>>e>>f;
	for(int i=0;i*100<=f;i+=a){
		for(int j=0;(i+j)*100<=f;j+=b){
			water.push_back((i+j)*100);
		}
	}
//	water.erase(water.begin()); 
	sort(water.begin(),water.end());
	water.erase(unique(water.begin(),water.end()),water.end());
//	for(int i=0;i<water.size();i++) cout<<water[i]<<" ";
//	cout<<endl;
	for(int i=0;i<=f;i+=c){
		for(int j=0;i+j<=f;j+=d){
			sugar.push_back((i+j));
		}
	}
	sort(sugar.begin(),sugar.end());
	sugar.erase(unique(sugar.begin(),sugar.end()),sugar.end());
//	for(int i=0;i<sugar.size();i++) cout<<sugar[i]<<" ";
//	cout<<endl;
	for(int i=0;i<water.size();i++){
		if(water[i]==0) continue;
		for(int j=0;j<sugar.size();j++){
			double pc;
			if(water[i]==0) continue;
			if(sugar[j]==0) pc=0;
			else pc=(double)sugar[j]*100/(water[i]);
			if(pc>e||sugar[j]+water[i]>f) break;
			if(pc>ans){
				ans=pc;s=sugar[j];w=water[i];
			}
			if(pc==0&&s==0) w=water[i];
			if(pc==e) flag=1;
			if(flag) break;
		} 
		if(flag) break;
	}
	cout<<w+s<<" "<<s<<endl;
	return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    string s,t;
    cin>>s>>t;
    int cnt=0;
    for(int i=0;i<3;i++){
        if(s[i]==t[i])cnt++;
    }
    cout<<cnt<<endl;
    //vector<int> a(n,0);
    // vector<vector<int>> a(n,vector<int>(m,0));
}

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

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s.at(i);
    sort(s.begin(),s.end());
    int ans = n;
    for(int j = 1; j < n; j++){
        if(s[j] == s[j-1]) ans--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 9548
#include<iostream>

using namespace std;

int main()
{
    int k, n;
    cin >> k >> n;
    int *a = new int[n];
    int maxdist = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 1; i < n; i++) {
        if (a[i] - a[i - 1] > maxdist) {
            maxdist = a[i] - a[i - 1];
        }
    }
    if (a[0] + (k - a[n - 1]) > maxdist) {
        maxdist = a[0] + (k - a[n - 1]);
    }

    cout << k - maxdist << endl;



    return 0;
}


Measured memory_bytes: 1024
#ABC118-B
n,m = map(int,input().split())
anke = []
for i in range(n):
    tmp = list(map(int,input().split()))
    anke.append(tmp[1:])
#print(anke)    
result = []
for i in range(1,m+1):
    flg = True
    for j in anke:
        if i not in j:
            flg = False
            break
    if flg:
        result.append(i)
        

print(len(result))

        
    

Measured memory_bytes: 3060
H,W = map(int,input().split())
A = []
for _ in range(H):
    a = input()
    a.split()
    A.append(a)
dist = [(1,0),(-1,0),(0,1),(0,-1)]
for i in range(H):
    for j in range(W):
        if A[i][j]=='#':
            cnt =0
            for dx,dy in dist:
                if 0<=i+dx<H and 0<=j+dy<W:
                    if A[i+dx][j+dy]=='#':
                        cnt +=1
            if cnt ==0: print('No');exit()
print('Yes')


Measured memory_bytes: 68688
#include <iostream>
using namespace std;
int main() {
	int n;
	int x[100];
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> x[i];
	int max_x = 0;
	for (int i = 1; i <= n; i++)
		if (max_x < x[i])
			max_x = x[i];
	int sum_min = 1000000, sum = 0;
	for (int p = 1; p <= max_x; p++) {
		for (int i = 1; i <= n; i++)
			sum += (x[i] - p) * (x[i] - p);
		if (sum_min > sum)
			sum_min = sum;
		sum = 0;
	}
	cout << sum_min << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ll N;
	cin>>N;
	ll hap = 0;
	hap+=floor(N/500)*1000;
	N = N%500;
	hap+=floor(N/5)*5;
	cout<<hap;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    vector<long long>v(n + 5), dp(n + 5, 1e10);
    for(int i = 1; i <= n; i++){
        cin >> v[i];
    }
    dp[1] = 0;
    for(int i = 2; i <= n; i++){
        for(int j = max(i - k, 1); j < i; j++){
            dp[i] = min(dp[i], dp[j] + abs(v[i] - v[j]));
        }
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const int mod = 1000000007;

long long int powmod(int x, int n){
    long long int ans = 1;
    for (int i = 0; i < n; i++)
    {
        ans = (ans * x) % mod;
    }

    return ans;
}

int main(){
    int n;
    std::cin >> n;

    long long int ans = powmod(10, n) - powmod(9, n) - powmod(9, n) + powmod(8, n);
    ans %= mod;
    ans = (ans + mod) % mod;

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 3644
s = input()

#末尾
a = ord("a")
z = ord("z")

for i in range(a, z + 1):
    if not chr(i) in s:
        ans = s + chr(i)
        print(ans)
        exit()

# 26word
deleted = []
current = s
for i in reversed(s):
    for usable in deleted:
        if ord(current[-1]) <  usable:
            print(current[:-1] + chr(usable))
            exit()

    deleted.append(ord(i))
    sorted(deleted)
    current = current[:-1]

print("-1")



Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void) {
	string s, t;
	cin >> s >> t;
	
	int count=0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] != t[i]) {
			count++;
		}
	}

	cout << count;

	return 0;
}

Measured memory_bytes: 3920
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int i = in.nextInt();
    int j = in.nextInt();
    int res = Math.max(0, (4-i)*100000) + Math.max(0, (4-j)*100000);
    if(i == 1 && j == 1){
      res += 400000;
    }
    System.out.println(res);
    in.close();
  }
}


Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define mii map<int,int>
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b)  (x/gcd(x,y))*y
#define inf (long long) 1e18
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define rep(i,n)  for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define deb(x) cout << #x << "=" << x <<"\n";
const int N = 1e9 + 7;

int pow(int x, int y) { int res = 1; while (y > 0) { if (y & 1) res = ((res) * (x)); res %= N; y = y >> 1; x = ((x) * (x)); } return res; }
int pow(int x, int y, int p)  {  int res = 1; x = x % p; while (y > 0) {if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p;}   return res; }


int dp[100001];
void solve()
{
	int n,w;
	cin>>n>>w;
	vector<pii> v(n+1);
	rep1(i,n)
	{
		int a,b;
		cin>>a>>b;
		v[i]={a,b};
	}
	//dp[i] -> max total value of itmes with weight i
	for(int j=1;j<=n;j++)
	{
		for(int i=w-v[j].F;i>=0;i--)
		{
			dp[i+v[j].F]=max(dp[i+v[j].F],dp[i]+v[j].S);	
		}
		// for(int i=0;i<=w;i++)
		// {
		// 	cout<<dp[i]<<" ";
		// }
		// cout<<"\n";
	}
	int ans=0;
	for(int i=0;i<=w;i++)
	{
		ans=max(ans,dp[i]);
	}
	cout<<ans<<"\n";
}	



int32_t main()
{
	// #ifndef ONLINE_JUDGE
 //    freopen("gymnastics.in", "r", stdin);
 //    freopen("gymnastics.out", "w", stdout);
	// #endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
   int t=1;
   	// cin>>t;
   while(t--)
   	solve();
}






//code by-Roshan











//unnecessary
// bool cmp(pair<int,int> &a,pair<int,int> &b)
// {
// 	if(a.F==b.F)
// 		return (a.S<b.S);
// 	else 
// 		return (a.F<b.F);
// 	//< =chota wala pehle
// 	//> =chota wala baad me
// }


//better use this structure
// struct s{
// 	int a;
// 	bool operator <(const s &x) const
// 	{
// 		return (a>x.a);
// 	}
// };



//	priority_queue<int,vector<int>,greater<>> p;(priority queue as min heap)



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

using namespace std;
using ll = long long;
    
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

    
int main() {
    int n,k;
    cin >> n >> k;
    
    int l[k], r[k];
    vector<mint> dp(n+1);
    vector<mint> dp_sum(n+1);

    for(int i=0; i<k; i++){
        cin >> l[i] >> r[i];
    }

    dp[1] = 1;
    dp_sum[1] = 1;
    for(int i=2; i<=n; i++){
        for(int j=0; j<k; j++){
            int li = i - l[j];
            int ri = i - r[j] - 1;
            if(li < 0) continue;
            ri = max(ri, 0);
            dp[i] += dp_sum[li] - dp_sum[ri];
        }
        dp_sum[i] = dp[i] + dp_sum[i-1];
    }
    
    cout << dp[n] << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;

int main(){
  int a,b;
  char op;

  cin >> a >> op >> b;
  cout <<  (op=='+' ? a+b : a-b) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int parent(int i) {
	return i / 2;
}

int left(int i) {
	return 2 * i;
}

int right(int i) {
	return 2 * i + 1;
}

void print(int* node, int n) {
	int i, pk, lk, rk;

	for (i = 1; i <= n; i++) {
		printf("node %d: ", i);
		printf("key = %d, ", node[i]);
		pk = parent(i - i % 2);
		lk = left(i);
		rk = right(i);
		if (pk > 0) printf("parent key = %d, ", node[pk]);
		if (lk <= n) printf("left key = %d, ", node[lk]);
		if (rk <= n) printf("right key = %d, ", node[rk]);
		puts("");
	}
}

main() {
	int *node;
	int n, i;

	scanf("%d", &n);

	node = (int*)malloc(sizeof(int) * (n + 1));

	for (i = 1; i <= n; i++) {
		scanf("%d", &node[i]);
	}

	print(node, n);
	free(node);

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int n1,n2,n3,n4;
  n1 = n%10;
  n2 = ((n-n1)%100)/10;
  n3 = ((n-n1-10*n2)%1000)/100;
  n4 = (n-n1-10*n2-100*n3)/1000;
  if (n1 == n2 && n2 == n3) {
    cout << "Yes" << endl;
  }
  else if (n2 == n3 && n3 == n4) {
    cout << "Yes" << endl;
  }
  else if (n1 == n2 && n2 == n3 && n3 == n4) {
    cout <<"Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
 

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#define ll long long
#define For(i, j, k) for(int i = j; i <= (int)k; ++ i)
#define Forr(i, j, k) for(int i = j; i >= (int)k; -- i)
#define INF 0x3f3f3f3f
using namespace std;

const int maxn = 5e5 + 5;

int n, last;
int dp[maxn];
char s[maxn];

inline int Max(int x, int y){
	if(x > y)	return x;
	return y;
}

int main(){	
	scanf("%d", &n);	scanf("%s", s + 1);
	
	For(i, 3, n){
		dp[i] = dp[i-1];
		if(s[i] == '1' && s[i-1] == '0' && s[i-2] == '1'){
			last = i;
			for(int j = i-2; s[j]!='0'&&j>0; -- j)
				dp[i] = Max(dp[i], dp[j-1] + (i-j-1));
		}
		if(s[i] == '0')    last = 0;
		if(last != 0)	dp[i] = Max(dp[i], dp[last-3] + (i-last+1));
	}
	
	printf("%d", dp[n]);
	return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
#define w(x) int x; cin>>x; while(x--)
ll int n,k;
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    n=n==1?0:1;
	cout<<n;
}

Measured memory_bytes: 3612
import java.io.*;

public class Main{
	public static void main(String[] args) throws IOException{ 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String sc = br.readLine();
		int n = Integer.parseInt(sc);
		String line2 = br.readLine();
		String[] str = line2.split(" ");
		int[] x = new int[n];
		for (int i = 0; i<n ; i++ ) {
			x[i] = Integer.parseInt(str[i]);
		}
		for (int i = n-1; i>0 ; i-- ) {
			System.out.print(x[i] + " ");
		}
		System.out.println(x[0]);
	}

}

Measured memory_bytes: 24416
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

const llong inf = 1e18;
int n;
int A[300001];
llong L[300001];
llong R[300001];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for (int i = 1; i <= 3 * n; ++i) cin >> A[i];
    {
        priority_queue<int, vector<int>, greater<int>> pq;
        llong sum = 0;
        for (int i = 1; i <= 3 * n; ++i) {
            sum += A[i];
            pq.push(A[i]);
            if (pq.size() > n) {
                sum -= pq.top();
                pq.pop();
            }
            L[i] = sum;
        }
    }
    {
        priority_queue<int> pq;
        llong sum = 0;
        for (int i = 3 * n; i > 0; --i) {
            sum += A[i];
            pq.push(A[i]);
            if (pq.size() > n) {
                sum -= pq.top();
                pq.pop();
            }
            R[i] = sum;
        }
    }
    llong ans = -inf;
    for (int i = n; i <= 2 * n; ++i) {
        ans = max(ans, L[i] - R[i + 1]);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 7028
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using Graph = std::vector<std::vector<int> >;
const int INF = 1e17;
/* libraries */

template <typename M>
struct SegmentTree
{
	const int n;
	const M I;
	const std::function<M(M,M)> f;
	std::vector<M> data;
	SegmentTree(int n, M I, std::function<M(M,M)> f) : n(n), data(2*n,I), I(I), f(f) {}
	void set(int i, const M& v) {
		data[n+i]=v;
	}
	void build() {
		for(int i=n-1;i>0;i--) {
			data[i]=f(data[i<<1],data[i<<1|1]);
		}
	}
	void update(int i, const M& v) {
		set(i,v);
		i+=n;
		for(i>>=1;i>0;i>>=1) {
			data[i]=f(data[i<<1],data[i<<1|1]);
		}
	}
	M get(int i) {
		return data[n+i];
	}
	M query(int l, int r) {
		M L=I, R=I;
		l+=n; r+=n;
		while(r>l) {
			if(l&1) L=f(L,data[l++]);
			if(r&1) R=f(data[--r],R);
			l>>=1; r>>=1;
		}
		return f(L,R);
	}
};


signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	int M = (n+1)*n/4+1;
	int l=0,r=1e9+1;
	while(r-l>1) {
		int o=(l+r)>>1;
		// check if the count of intervals that have a median less than or equal to o is over M or not
		int count=0;
		{
			// make segment trees of even and odd indices
			std::vector<SegmentTree<int> > seg(2,SegmentTree<int>(2*n+1,0,[](int a, int b){return a+b;}));
			std::vector<int> ac(n+1,0);
			rep(i,n) ac[i+1]=ac[i]+(int)(a[i]<=o);
			const int base=n;
			const int MAX=2*n+1;
			for(int i=n;i>=0;i--) {
				int x=2*ac[i]-i+base;
				count+=seg[i&1].query(x+2,MAX);
				count+=seg[(i&1)^1].query(x+1,MAX);
				seg[i&1].update(x,seg[i&1].get(x)+1);
			}
		}
		if(count>=M) r=o;
		else l=o;
	}
	print(r);
	return 0;
}


Measured memory_bytes: 12488
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;

    int a = min({4*q, 2*h, s});
    ll ans;
    if(2*a <= d) {
        ans = (ll)a*n;
    }
    else {
        int m = n/2;

        if(n%2 == 0) {
            ans = (ll)d*m;
        }
        else {
            ans = (ll)d*m + a;
        }
    }

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

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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  sort(s.begin(), s.end());
  int ans = 1;
  for (int i = 1; i < n; ++i) {
    if (s[i] != s[i-1]) ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9448
#include <iostream>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <vector>
#include <map>
#include <stdio.h>
using namespace std;
int main() {
	int N; cin >> N;
	vector<int>B(N);
	B.at(0) = 100001;
	for (int i = 1; i < N; i++) {
		cin >> B.at(i);
	}
	int ans = 0;
	for (int i = 0; i < N - 1; i++) {
		ans += min(B.at(i), B.at(i + 1));
	}
	ans += B.at(N - 1);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
   int n,k,sum;
   cin>>n>>k;
   sum = 1;
   for(int i= 0 ;i < n; i++){
       if(sum+k>sum*2){
           sum=sum*2;
       }else{
           sum+=k;
       }
   }
   cout<<sum<<endl;
    return 0;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
sort(A.begin(),A.end());
  int s=0;
  int count=0;
  for(int i=0;i<N;i++){
     if(A.at(i)!=s){
       count++;
       s=A.at(i);
     }
  }
  cout<<count<<endl;
}

  

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define for(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)    for(i, 0, n)
#define sz(x)        ((int)(x).size())
#define inf          1<<25

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

//typedef vector<int> vi;
//typedef vector<long long> vl;
//typedef vector<double> vd;
//typedef pair<int,int> pii;
//typedef pair<long,long> pll;
//typedef long long ll;

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

int main() {
    string x, y;
    cin >> x >> y;
    
    if (x < y) cout << "<" << endl;
    else if (x > y) cout << ">" << endl;
    else cout << "=" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int n, pt, px, py, t, x, y;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    cin >> t >> x >> y;
    pt = t - pt;
    px = abs(x-px);
    py = abs(y-py);
    if(px+py>pt || (px+py)%2 != pt%2){
      cout << "No" << endl;
      return 0;
    }
    pt = t;
    px = x;
    py = y;
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
p = [[] for i in range(M)]
counter = [0] * N
ans = [""] * M

for i in range(M):
    k, y = map(int, input().split())
    p[i] = [k, y, i]

p.sort(key=lambda x:x[1])
for k, y, i in p:
    counter[k-1] += 1
    ans[i] = "{:06d}{:06d}".format(k, counter[k-1])

for i in ans:
    print(i)

Measured memory_bytes: 32248
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;

int main(){
  ll A[200000],M[200000],temp,ans=0;
  ll n,k,count=0;
  string s;
  cin>>n>>k>>s;

  for(ll i=0;i<n;i++){
    if(i==0) A[count]++;
    else if(s[i]==s[i-1]) A[count]++;
    else A[++count]++;
  }

  M[0]=A[0];

  for(ll i=1;i<n;i++){
    M[i]=A[i]+M[i-1];
  }
  ll start;
  if(s[0]=='1') start=0;
  else start=1;

  for(ll i=start;i+k*2<=count+1;i+=2,ans=max(ans,temp)){
    if(i==0) temp=M[i+k*2];
    else if(i+k*2==count+1) temp=M[count]-M[i-1];
    else temp=M[i+k*2]-M[i-1];
  }

  if(s[0]=='0'){
    ans=max(ans,M[(k-1)*2+1]);
  }

  ll count0=0;
  count0=(count+1)/2;
  if(s[0]=='0') count0++;
  if(count0<=k) ans=n;
  
  cout<<ans<<endl;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    int k;
    cin>>k;
    priority_queue<ll> pq;
    for(int i=0;i<n;i++)
    {
        ll x;
        cin>>x;
        pq.push(-x);
    }
    ll sum=0;
    for(int i=0;i<k;i++)
    {
        sum +=pq.top();
        pq.pop();
    }
    cout<<sum*-1<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
map<int,bool> written;
int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 0;i < n;i++)
    {
        int x;
        scanf("%d",&x);
        if(written[x])
            ans--;
        else
            ans++;

        written[x] = !written[x];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
using namespace std;

int main() {

    int  a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int min = a*x + b*y;

    for (int i = 0; i <= 100000; i++) {
        int sum;
        sum = i*2*c + max(0, x-i)*a + max(0, y-i)*b;
        if (min > sum) {
            min = sum;
        }
    }

    cout << min << endl;

    return 0;
    
}


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


int main() {
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	for (int i = 1;i < n;++i) {
		int cnt = 0;
		for (char c = 'a';c <= 'z';++c) {
			bool left = false;
			bool right = false;
			for (int j = 0;j < i;++j) {
				if (s[j] == c) left = true;
			}
			for (int j = i;j < n;++j) {
				if (s[j] == c)right = true;
			}
			if (left && right)cnt++;
		}
		if (ans <= cnt)ans = cnt;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256