akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    int k;
    vector<int> v;
    cin >> n >> k;
    int max = 0;
    int index = 0;
    for (int j = 0; j < k; j++) {
        int a;
        cin >> a;
        if (a > max) {
            max = a;
            index = j;
        }
        v.push_back(a);
    }
    for (int i = 0; i < n - k; i++) {
        int a;
        cin >> a;
        if (a < max) {
            v[index] = a;
            max = a;
            for (int j = 0; j < k; j++) {
                if (v[j] > max) {
                    index = j;
                    max = v[j];
                }
            }
        }
    }
    int sum = 0;
    for (int i = 0; i < k; i++) {
        sum += v[i];
    }
    cout << sum;
}


Measured memory_bytes: 3572
#![allow(non_snake_case,unused_imports)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf_it = buf.split_whitespace();

    let N = buf_it.next().unwrap().parse::<usize>().unwrap();
    let D = buf_it.next().unwrap().parse::<isize>().unwrap();
    let A = buf_it.next().unwrap().parse::<isize>().unwrap();
    let mut XH = (0..N)
        .map(|_| (buf_it.next().unwrap().parse::<isize>().unwrap(),
                    buf_it.next().unwrap().parse::<isize>().unwrap())).collect::<Vec<_>>();
    XH.push((-1000000000 as isize,0));
    XH.sort();

    for i in 0..N+1{
        let h = XH[i].1;
        XH[i].1 = (h-1)/A + 1;
    }

    let mut ans = 0;
    let mut bomb = SegmentTree::<isize>::new(N+1,add,0);

    for i in 1..N+1{
        let (x,h) = XH[i];
        let mut j;
        let mut l = 0;
        let mut r = i;
        while l+1<r {
            j = (l+r)/2;
            if XH[j].0 < x-2*D{
                l = j;
            } else {
                r = j;
            }
        }
        j = r;
        let m = bomb.get(j,i);
        let n = max(0,h-m);
        ans += n;
        bomb.set(i,n);
    }
    println!("{}",ans);

}

fn add(x:isize,y:isize) -> isize{
    x+y
}

struct SegmentTree<N>{
    n: usize,
    T: Vec<N>,
    func: fn(N,N) -> N,
    identity: N,
}

impl<N:Copy> SegmentTree<N> {
    fn new(n:usize,func:fn(N,N) -> N,identity:N) -> SegmentTree<N>{
        let mut T = SegmentTree { n:n,T:Vec::new(),func:func,identity:identity};
        T.init();
        T
    }
    fn init(&mut self){
        self.n = 1<<format!("{:b}",self.n-1).len();
        self.T = (0..(2*self.n-1)).map(|_| self.identity).collect();
    }
    fn set(&mut self,index:usize,value:N){
        let i = index + self.n - 1;
        self.T[i] = value;
        self._update_parent((i-1)/2);
    }
    fn _update_parent(&mut self,i:usize){
        self.T[i] = (self.func)(self.T[i*2+1],self.T[i*2+2]);
        if i>0 { self._update_parent((i-1)/2)}
    }
    fn get(&self,l:usize,r:usize) -> N{
    self._get(l,r,0,0,self.n)
    }
    fn _get(&self,l:usize,r:usize,i:usize,a:usize,b:usize) -> N{
        if l<=a && b<=r {
            self.T[i]
        } else if b<=l || r<=a {
            self.identity
        } else{
            (self.func)(self._get(l,r,2*i+1,a,(a+b)/2),
                        self._get(l,r,2*i+2,(a+b)/2,b))
        }
    }
}

Measured memory_bytes: 17656
/*
?§???????????????°???????????°

goto ?????????C/C++?¨????????????§???????????¨?????§???????????§????????????????????¨????????¶????????????????????????????????????????£?????????????????????° goto CHECK_NUM; ??¨?????????????????????????????¨???????????°??????????????§ CHECK_NUM: ??¨????????????????????????????§?????????????????????????????????£????????°?????????????????????????????????????????¨?????§????????????

?????????goto ???????????±??????????????????????????°?????????????????§?????±??????????????????????????????????????????????????¨?????¨?\¨?????????????????????

?¬????C++?¨???????????????°????????¨?????????????????????????????°????????????????????????????????????????????????goto ????????????????????§????£?????????????????????????

void call(int n){
int i = 1;
CHECK_NUM:
int x = i;
if ( x % 3 == 0 ){
cout << " " << i;
goto END_CHECK_NUM;
}
INCLUDE3:
if ( x % 10 == 3 ){
cout << " " << i;
goto END_CHECK_NUM;
}
x /= 10;
if ( x ) goto INCLUDE3;
END_CHECK_NUM:
if ( ++i <= n ) goto CHECK_NUM;

cout << endl;
}

*/
#include <iostream>
#include <math.h>

bool power(int x) {
	if (x % 10 == 3) {
		return true;
	}
	else if (x == 0) {
		return false;
	}
	else {
		power(x / 10);
	}
}

int main() {
	int n;
	bool inc3;
	std::cin >> n;
	for (int i = 1; i <= n; i++)
	{
		if (i % 3 == 0) {
			std::cout << " " << i;
		}
		else {
			if (power(i)) {
				std::cout << " " << i;
			}
			/*
			for (int j = 0; j < 4; j++)
			{
				int d = pow(10, j);
				if ((i / d) % 10 == 3) {
					std::cout << " " << i;
					break;
				}
			}*/
		}
	}
	std::cout << std::endl;
	return 0;
}

Measured memory_bytes: 3112
#pragma GCC optimize("Ofast")

#pragma GCC optimize("O3")

#include <bits/stdc++.h>

#define ll long long

using namespace std;

ll i, p, ans;

string s, t;

int main()
{
    cin >> s >> t;

    map < char, vector < ll > > a;

    for (; i<s.size(); i++) a[s[i]].push_back(i+1);

    for (auto &i:t)
    {
        if (!a[i].size()) return cout << -1, 0;

        auto k=upper_bound(a[i].begin(), a[i].end(), p);

        if (k!=a[i].end())
        {
            ans+=*k-p;

            p=*k;
        }
        else
        {
            ans+=s.size()-p+*a[i].begin();

            p=*a[i].begin();
        }
    }

    cout << ans;
}


Measured memory_bytes: 1728
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

using namespace std;
typedef long long ll;

ll gcd(ll a,ll b)
{
	if(b == 0) return a;
	else return gcd(b,a%b);
}

ll lcm(ll a,ll b)
{
	if(a == 0 || b == 0) return 0;
	return ((a / gcd(a,b)*b));
}

int main()
{
	int n;
	while(cin >> n && n)
	{
		vector<pair<ll,ll> > v;
		
		rep(i,n)
		{
			ll a,b;
			cin >> a >> b;
			v.push_back(make_pair(a,b));
		}

		rep(i,n)
		{
			ll temp = gcd(v[i].first,v[i].second);
			v[i].first /= temp;
			v[i].second /= temp;
		}

		ll t,t2;
		rep(i,n)
		{
			if(i == 0)
			{
				t = v[i].first;
				t2 = v[i].second;
			}
			else
			{
				t = lcm(t,v[i].first);
				t2 = gcd(t2,v[i].second);
			}
		}

		rep(i,n)
		{
			ll ans = t * v[i].second;
			ans /= t2;
			ans /= v[i].first;
			cout << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
typedef long long int LL;
using namespace std;

// 插入此處

const int MAXN = 2e3 + 2;
const int MOD = 1e9 +7;
LL ans[MAXN][MAXN];
int ans_T[MAXN][MAXN];
int ans_S[MAXN][MAXN];
int find_T[MAXN][MAXN];
int find_S[MAXN][MAXN];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N, M; cin >> N >> M;
	vector<int> S(N+2), T(M+2);
	for (int i = 1; i <= N; ++i) {
		cin >> S[i];
	}
	for (int i = 1; i <= M; ++i) {
		cin >> T[i];
	}
	memset(find_S, -1, sizeof(find_S));
	memset(find_T, -1, sizeof(find_T));
	for (int i = 1; i <= M; ++i) {
		for (int j = 1; j <= N; ++j) {
			if (T[i] == S[j]) {
				find_S[i][j] = j;
				find_T[i][j] = i;
			} else {
				find_S[i][j] = find_S[i][j-1];
				find_T[i][j] = find_T[i-1][j];
			}
		}
	}
	memset(ans_S, 0, sizeof(ans_S));
	memset(ans_T, 0, sizeof(ans_T));
	memset(ans, 0, sizeof(ans));
	for (int i = 0; i <= M; ++i) {
		ans[i][0] = 1;
	}
	for (int i = 0; i <= N; ++i) {
		ans[0][i] = 1;
	}
	for (int i = 1; i <= M; ++i) {
		for (int j = 1; j <= N; ++j) {
			if (find_T[i][j] != -1) {
				ans_T[i][j] = (ans[find_T[i][j]-1][j-1] + ans_T[find_T[i][j]-1][j]) % MOD;
			}
			if (find_S[i][j] != -1) {
				ans_S[i][j] = (ans[i-1][find_S[i][j]-1] + ans_S[i][find_S[i][j]-1]) % MOD;
			}
			ans[i][j] = ans[i-1][j-1] + ans_T[i][j] + ans_S[i][j];
			if (S[j] == T[i])  ans[i][j] -= ans[i-1][j-1];
			ans[i][j] %= MOD;
			// cout << "i " << i << " j " << j << " ans_T " << ans_T[i][j] << " ans_S " << ans_S[i][j] << " ans " << ans[i][j] << endl;
		}
	}
	cout << ans[M][N] << endl;
	return 0;
}


Measured memory_bytes: 94208
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
struct UnionFind{
    vl par;
    UnionFind(ll N):par(N){
        rep(i,N)par[i]=i;
    }
    ll root(ll x){
        if(par[x]==x)return x;
        return par[x]=root(par[x]);
    }
    bool same(ll x,ll y){
        return root(x)==root(y);
    }
    void unite(ll x,ll y){
        x=root(x),y=root(y);
        if(x==y)return;
        par[x]=y;
        return;
    }
};
int main(){
    ll N,M,K;cin>>N>>M>>K;
    UnionFind tree(N);
    vector<set<ll>> block(N),follow(N);
    rep(i,M){
        ll A,B;cin>>A>>B;
        tree.unite(--A,--B);
        follow[A].insert(B);
        follow[B].insert(A);
    }
    rep(i,K){
        ll A,B;cin>>A>>B;
        block[--A].insert(--B);
        block[B].insert(A);
    }
    vl count(N);
    rep(i,N){
        count[tree.root(i)]++;
    }
    rep(i,N){
        ll ans=count[tree.root(i)]-1;
        for(auto p:follow[i])if(tree.same(i,p))ans--;
        for(auto p:block[i])if(tree.same(i,p))ans--;
        if(i)cout<<" ";cout<<ans;
    }cout<<endl;
    return 0;
}


Measured memory_bytes: 30848
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define ll long long
#define ull unsigned long long
#define int ll
#define ld long double
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
                                                                    
typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 4e3 + 5;
int n , X;
int a[N];
ll f(int x){
	deque < pii > dq;
	rep(i , 1, n){
		while(sz(dq) != 0 and dq.back().fi >= a[i])
			dq.pop_back();
		dq.push_back({a[i] , i});
	}
	ll res = 0;
	//1 2 3 4 5 6

	rep(i, n + 1 , n + n){
		while(sz(dq) != 0 and dq.back().fi >= a[i])
			dq.pop_back();
		dq.push_back({a[i] , i});
		while(sz(dq) != 0 and dq.front().se < i - x)
			dq.pop_front();
		res += dq.front().fi;
	}
	return res + x * X;
}
main(){
//	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> X;
	rep(i , 1 , n){
		cin >> a[i];
		a[n + i] = a[i];
	}

	ll ans = f(0);
	int l = 0 , r = n ;
	while(l <= r){
		int m = (l + r) >> 1;
		int cur1 = f(m) , cur2 = f(m + 1);
		if(cur1 > cur2){
			ans = min(ans , cur2);
			l = m + 1;
		}else r = m - 1;
	}

	cout << ans;
}

Measured memory_bytes: 256
#include<iostream>                                        
#include<string>                                          
using namespace std;                                      
                                                          
int main(){                                               
  string str;                                             
  string sub1,sub2;                                       
  int m;                                                  
  int h;                                                  
                                                          
  while(1){                                               
    cin >> str;                                           
    if(str[0] == '-') break;                              
    cin >> m;                                             
    for(int i=0;i<m;i++){                                 
      cin >> h;                                           
      sub1 = str.substr(0,h);                             
      sub2 = str.substr(h,(str.size()-h));                
      str = sub2 + sub1;                                  
    }                                                     
    cout << str << endl;                                  
  }                                                       
                                                          
  return 0;                                               
}

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

bool isprime(int p){
	for(int i=2;i*i<=p;++i){
		if(p%i==0)return 0;
	}
	return 1;
}

int n;
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	for(int i=31;i<=55555;i+=30){
		if(isprime(i)){
			if(i!=31)cout<<" ";
			cout<<i;
			--n;
		}
		if(n==0)break;
	}
	cout<<"\n";
	return 0;
}

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

#define endl "\n"
#define PB push_back
#define F first 
#define S second
#define int long long 
#define Runner_up ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
const int N = 1e4;
signed main()
{	
	Runner_up
	int a,b,n; cin>>a>>b>>n;
	int z = min(b-1, n);
	int ans = (a*z)/b - a*(z/b);
	cout<<ans;
	return 0;	
}

Measured memory_bytes: 3648
#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;
#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())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,a[200005];
int main(){
	scanf("%d",&n);
	repn(i,n) scanf("%d",&a[i]);
	if(a[1] != 0){
		puts("-1"); return 0;
	}
	repn(i,n-1){
		if(a[i+1]-a[i] >= 2){
			puts("-1"); return 0;
		}
	}
	ll ans = 0;
	set<int>zip;
	int lazy = 0;
	for(int i=n;i>=2;i--){
		if(zip.find(-lazy) != zip.end()){
			zip.erase(zip.find(-lazy));
		}
		if(zip.find(1-lazy) != zip.end()){
			zip.erase(zip.find(1-lazy));
		}
		if(zip.find(a[i]+1-lazy) != zip.end()){
			zip.erase(zip.find(a[i]+1-lazy));
		}
		lazy--;
		if(a[i] != 0){
		    zip.insert(a[i]-lazy);
	    	ans += zip.size();
		}
	}
	cout<<ans<<endl;
}

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

int main(){
  int h1,m1,h2,m2,k;
  cin>>h1>>m1>>h2>>m2>>k;
  int ans=h2*60+m2-h1*60-m1-k;
  if(ans<0){
    cout<<0<<endl;
    return 0;
  }
  cout<<ans<<endl;
}  

Measured memory_bytes: 3596
#include <map>
#include <iostream>

int main() {
	std::map<int, int> sequence;
	int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	for (int i=0; i < 32; i++) {
		sequence.insert({i+1, a[i]});
	}

	int k;
	std::cin >> k;

	std::cout << sequence[k];
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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

__attribute__ ((constructor))
void fastio() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
}

int main(){
  ll n, k;
  cin >> n >> k;
  vector<vector<ll>> dp(60, vector<ll>(2, -1));
  vector<ll> v(n);
  dp[0][0] = 0;
  rep(i, n) cin >> v[i];
  rep(i,50){
    ll mask = 1LL << (50 - 1 - i);
    ll point0 = 0;//0としたときのpoint
    ll point1 = 0;
    ll cnt = 0;
    
    rep(j,n){
      if(v[j]&mask)
        cnt++;
    }

    point0 = mask * cnt;
    point1 = mask * (n - cnt);
    if(dp[i][1] != -1){
      chmax(dp[i + 1][1], dp[i][1] + max(point0, point1));
    }

    if(dp[i][0] != -1){
      // 小さいものを選ぶ
      if(k & mask){
        chmax(dp[i + 1][1], dp[i][0] + point0);
      }
    }

    if(dp[i][0] != -1){
      if(k & mask){
        chmax(dp[i + 1][0], dp[i][0] + point1);
      }
      else{
        chmax(dp[i + 1][0], dp[i][0] + point0);
      }
    }

  }
  cout << max(dp[50][0], dp[50][1]) << endl;
  return 0;
}



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

int main(){
	int N, tmp, max=0;
	int v[200000]={0};
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> tmp;
		v[tmp]++;
		v[tmp+1]++;
		v[tmp+2]++;
	}
	for(int i=1;i<100003;i++){
		if(max<v[i]){
			max = v[i];
		}
	}
	cout << max << endl;
	return 0;
	
}


Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;

int main() {
    int N; cin>>N;
    vi A(N);
    vector<vi> x(N);
    vector<vector<bool>> y(N);
    for (int i = 0; i < N; i++){
        cin>>A[i];
        for (int j = 0; j < A[i]; j++){
            int a,b; cin>>a>>b; a--;
            x[i].push_back(a);
            y[i].push_back(b);
        }
    }
    int ans=0;
    for (int i = 0; i < (1<<N); i++){
        bitset<15> b(i);
        bool ng=false;
        for (int j = 0; j < N; j++){
            if(b[j]){
                for (int k = 0; k < A[j]; k++){
                    if(b[x[j][k]]!=y[j][k])ng=true;
                }
            }
            if(ng)break;
        }
        if(!ng){
            ans=max(ans,(int)b.count());
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3608
#include <stdio.h>

#define INFTY 1000000001

int count = 0;

void merge(int a[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  int l[n1 + 1], r[n2 + 1];
  int i, j, k;
  for (i = 0; i < n1; i++)
    l[i] = a[left + i];
  for (i = 0; i < n2; i++)
    r[i] = a[mid + i];
  l[n1] = INFTY;
  r[n2] = INFTY;
  i = 0;
  j = 0;
  for (k = left; k < right; k++) {
    if (l[i] <= r[j]) 
      a[k] = l[i++];
    else
      a[k] = r[j++];
    count++;
  }
}

void merge_sort(int a[], int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    merge_sort(a, left, mid);
    merge_sort(a, mid, right);
    merge(a, left, mid, right);
  }
}

int main(void) {
  int n;
  int s[500000];
  
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d", &s[i]);

  merge_sort(s, 0, n);
  
  for (int i = 0; i < n; i++) {
    printf("%d", s[i]);
    if (i != n - 1)
      printf(" ");
  }
  printf("\n%d\n", count);
  
  return 0;
}



Measured memory_bytes: 5660
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;


int main() {
	int N , K;
	cin >> N >> K;
	int m = N / K;
	int t = (N + K/2) / K;

	long long res = 0;
		res = pow(m, 3);
	if(K % 2 == 0) res += pow(t, 3);
	cout << res << endl;
}


Measured memory_bytes: 384
//#pragma GCC optimize("-Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//order_of_key(x) : number of items less than x
//find_by_order(x) : iterator to x

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()

const ld pi=3.14159265359;
ll INF=1e18+10;
ll MOD=998244353;
ll mod=1e9+7;

inline ll add(ll a,ll b,ll m){
    if(a+b>=m)return (a+b)-m;
    return a+b;
}

inline ll mul(ll a,ll b,ll m){
    if((a*b)<m)return a*b;
    return (a*b)%m;
}

int main()
{
    ll n,m;cin>>n>>m;
    ll tot=0;
    vector<ll> v(n);
    rep(i,0,n)cin>>v[i],tot+=v[i];
    ll req=(tot+4*m-1)/(4*m);
    ll cnt=0;
    rep(i,0,n)
    if(v[i]>=req)cnt++;
    if(cnt>=m)cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std; typedef long long ll; const int INF=1e9; typedef pair<ll,ll> P;
const int xn=100001; vector<int> v[xn]; int pr[xn]; int ply[xn]; int ct[2];
int dfs(int from, int to){
  pr[to]=from;
  for(int nx:v[to]) {
    if (from == nx) continue;
    dfs(to, nx);
  }
}
int dfs2(int from, int to, int py, int en) {
  ct[py]++;
  for(int nx:v[to]) {
    if (from == nx) continue;
    else if (ply[nx] == en) continue;
    dfs2(to, nx, py, en);
  }
}
int main() {
  int n; cin>>n;
  for(int i=0;i<n-1;i++) {
    int a,b; cin>>a>>b; a--;b--;
    v[a].push_back(b); v[b].push_back(a);
  }
  dfs(-1,0);

  //for(int i=0;i<n;i++) cout<<pr[i]<<" "; cout<<endl;
  
  int pv=n-1;
  vector<int> v2;
  v2.push_back(pv);
  while(true) {
    pv=pr[pv];
    if (pv==-1) break;
    v2.push_back(pv);
  }

  //for(int x:v2) cout<<x<<" "; cout<<endl;
  reverse(v2.begin(), v2.end());

  fill(ply, ply+n, -1);
  ct[0]=ct[1]=0;
  int ii=0, jj=v2.size()-1;
  while(ii<jj) {
    ply[v2[ii]] = 0; ii++;
    ply[v2[jj]] = 1; jj--;
  }
  //for(int i=0;i<n;i++) cout<<ply[i]<<" "; cout<<endl;
  dfs2(-1, 0, 0, 1);
  ct[1] = n - ct[0];
  //cout<<ct[0]<<" "<<ct[1]<<endl;
  if (ct[0] <= ct[1]) cout<<"Snuke"<<endl;
  else cout<<"Fennec"<<endl;
}

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

const int maxn=200005;

inline int read(){
	register int x=0,w=1,ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')w=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-48;
	return w*x;
}

int n,K;
int a[maxn],b[maxn];

int main(){
	n=read(),K=read();
	for(int i=1;i<=n;i++)a[i]=read();
	for(int j=1;j<=K;j++){
		int flag=1;
		memset(b+1,0,4*n);
		for(int i=1;i<=n;i++)
			++b[max(1,i-a[i])],--b[min(n,i+a[i])+1];
		for(int i=2;i<=n;i++)b[i]+=b[i-1];
		for(int i=1;i<=n;i++)
			if(b[i]!=n)flag=0;
		swap(a,b);
		if(flag)break;
	}
	for(int i=1;i<=n;i++)
		cout<<a[i]<<' ';
	cout<<'\n';
	return 0;
}


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

#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;


void solve(){
    char t;
    cin>>t;
    if(t == 'A') cout << 'T' << endl;
    else if(t=='G')cout<<'C' << endl;
    else if(t=='T')cout<<'A' << endl;
    else cout<<'G' << endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
     t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  s = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  n = int(input())
  v = input().strip()
  r = ''.join(s[(s.index(x) + n) % 26] for x in v)

  print(r)


if __name__ == '__main__':
  main()


Measured memory_bytes: 38832
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{

int k;
cin>>k;
if(k%2==0)
{
  cout<<(k/2)*(k/2)<<endl;	
}
else{
cout<<(k/2)*((k+1)/2)<<endl;
}
	
}


Measured memory_bytes: 3636
#!/usr/bin/env python3

from itertools import chain
from collections import Counter

N,M = map(int, input().split())
PY = [ (i, P, Y) for i, (P, Y) in enumerate([map(int, input().split()) for _ in range(M)])]

answers = [0 for x in range(M)]
counter = Counter()

for index, P, Y in sorted(PY, key = lambda x : x[2]):
    counter[P] += 1
    answers[index] = "{:06}{:06}".format(P, counter[P])

print("\n".join(answers))

Measured memory_bytes: 60640
X = int(input())

if(400 <= X <= 599):
    print(8)
elif(600 <= X <= 799):
    print(7)
elif(800 <= X <= 999):
    print(6)
elif(1000 <= X <= 1199):
    print(5)
elif(1200 <= X <= 1399):
    print(4)
elif(1400 <= X <= 1599):
    print(3)
elif(1600 <= X <= 1799):
    print(2)
else:
    print(1)




Measured memory_bytes: 9184
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;
double dp[3010][3010];
int n;
vector<double> p(3010);
int mod = 1000000007;
int main(void){
    cin >> n;
    for(int i = 0;i < n;i++) cin >> p[i];
    dp[0][0] = 1.0;
    for(int i = 0;i < n;i++){
        for(int j = 0;j <= i;j++){
            dp[i+1][j+1] += dp[i][j]*p[i];
            dp[i+1][j] += dp[i][j]*(1.0-p[i]);
        }
    }
    double ans = 0.0;
    for(int i = n/2+1;i <= n;i++) ans += dp[n][i];
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 69120
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define sz(x) int(x.size())
using ll = long long;
using P = pair<int,int>;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;

int main()
{
    string s;
    int k;
    cin >> k >> s;

    for(int i=0;i<s.length();i++){
        if(i<k) cout << s[i];
        else{
            cout << "...";
            break;
        }
    }
    return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    int test=0;
    for(int i=0;i<S.length();i++){
        if(i%2==1&&S[i]=='R'){cout<<NO<<"\n";test+=1;break;}
        if(i%2==0&&S[i]=='L'){cout<<NO<<"\n";test+=1;break;}
    }
    if(test==0){cout<<YES<<"\n";}
}


int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
#define int long long
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;

signed main(){
	int H,W;
	int h,w;
	cin>>H>>W;
	cin>>h>>w;
	cout<<H*W-W*h-(H-h)*w<<endl;
	return 0;
}


Measured memory_bytes: 256
N=int(input())
A=[int(i) for i in input().split()]
a=sum(A)//2#sumx
P=[0]*(N+1)
Q=[0]*(N+1)
for i in range(1,N+1):
    if i%2==1:
        P[i]+=P[i-1]+A[i-1]
        Q[i] += Q[i - 1]
    else:
        Q[i]+=Q[i-1]+A[i-1]
        P[i] += P[i - 1]
#print(a,P,Q)
ans=[]
for i in range(1,N+1):
    x=0
    if i%2==1:
        x+=P[N]-P[i-1]
        x+=Q[i]-Q[0]
    else:
        x += Q[N] - Q[i - 1]
        x += P[i] - P[0]
    print(2*(x-a),end=' ')
    #ans.append(2*(x-a))
#print(ans,end=' ')


Measured memory_bytes: 66660
#include <stdio.h>

int main(void) {

int H,W,x,y;
scanf("%d %d\n",&H,&W);
while((H!=0)||(W!=0)){
for(y=1;y<=H;y++){
for(x=1;x<=W;x++){
printf("#");
}
printf("\n");
}
printf("\n");
scanf("%d %d\n",&H,&W);
}
return 0;
}

Measured memory_bytes: 576
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long A, B, C;
  cin >> A >> B >> C;
  cout << B + min(A + B, C - 1) + 1 << '\n';
  return 0;
}


Measured memory_bytes: 3604
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

//typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)));
#define Mx(a , b) ((a) > (b) ? (a) : (b))
#define Mn(a , b) ((a) < (b) ? (a) : (b))

const double EPS = 1e-10;
const int INF = 2147483647;

int N , K;
int a[100010][17];
bool b[100010];
int d[100010];
vector<int> V[100010];
queue<int> Q;
priority_queue<P2> P;
int ans;

int main(){
	scanf("%d%d%d" , &N , &K , &a[1][0]);
	if(a[1][0] != 1) ++ans;
	for(int i = 2 ; i <= N ; ++i){
		scanf("%d" , &a[i][0]);
		V[a[i][0]].push_back(i);
	}
	for(int i = 1 ; i < 17 ; ++i){
		for(int j = 2 ; j <= N ; ++j){
			a[j][i] = a[j][i - 1] != 1 ? a[a[j][i - 1]][i - 1] : 1;
		}
	}
	Q.push(1);
	while(!Q.empty()){
		int x = Q.front();
		Q.pop();
		for(vector<int>::iterator it = V[x].begin() ; it != V[x].end() ; ++it){
			d[(*it)] = d[x] + 1;
			Q.push((*it));
		}
		if(V[x].begin() == V[x].end() && d[x] > K){
			P.push(MP(d[x] , x));
		}
	}
	while(!P.empty()){
		int x = P.top().second;
		P.pop();
		if(b[x]) continue;
		++ans;
		for(int i = 0 , j = K - 1 ; i < 17 && j > 0 ; ++i , j /= 2){
			if(j % 2 == 1) x = a[x][i];
		}
		Q.push(x);
		if(d[a[x][0]] > K) P.push(MP(d[a[x][0]] , a[x][0]));
		while(!Q.empty()){
			int x = Q.front();
			Q.pop();
			for(vector<int>::iterator it = V[x].begin() ; it != V[x].end() ; ++it){
				if(!b[(*it)]) Q.push((*it));
			}
			b[x] = 1;
		}
	}
	printf("%d\n" , ans);
	return 0;
}


Measured memory_bytes: 12800
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
// const long long MOD = (ll)1e6+3;
const long long MAX = (ll)1e5+10;


int main(void) {
    ll N;
    cin>>N;
    vector<ll> X(N);
    vector<ll> L(N);
    rep(i,0,N) cin>>X[i]>>L[i];

    multimap<ll,ll> A;
    rep(i,0,N) A.insert(make_pair(X[i]+L[i], X[i] - L[i]));
    ll now = -1e15;
    ll ans = 0;
    for (auto itr = A.begin();itr!= A.end();itr++) {
        // cout<<itr->first<<" "<<itr->second<<endl;
        if (itr->second < now) {
        } else {
            ans++;
            now = itr->first;
        }
    }
    cout<<ans<<endl;





   return 0;
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    while(true){
        int n;
        cin >> n;
        if(!n) break;
        vector<int> s(n);
        for(int i = 0; i < n; ++i){
            cin >> s[i];
        }
        cout << (accumulate(s.begin(), s.end(), 0) - *max_element(s.begin(), s.end()) - *min_element(s.begin(), s.end())) / (n-2) << "\n";
    }
    return 0;
}



Measured memory_bytes: 3160
S = gets.chomp
(0..(S.length-2)).each do |i|
  if S[i] == S[i+1]
    puts "#{i+1} #{i+2}"
    exit
  elsif S[i] == S[i+2]
    puts "#{i+1} #{i+3}"
    exit
  end
end
puts "-1 -1"


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    string s;
    cin >> s;
    vpair rl;
    rl.emplace_back(s[0], 1);
    srep(i, s.length(), 1) {
        if (s[i] == rl.back().fi) rl.back().se++;
        else rl.emplace_back(s[i], 1); 
    }

    int ans = rl.size()-1;

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

Measured memory_bytes: 1528
import numpy as np
h,w=map(int,input().split())
grid=np.empty((h,w),dtype="<U")
for i in range(h):
    s=list(input())
    grid[i]=s

del_row=[]
del_col=[]
for i in range(h):
    if all(grid[i]=="."):
        del_row.append(i)
for j in range(w):
    if all(grid[:,j]=="."):
        del_col.append(j)
        
grid=np.delete(grid, del_row, 0)
grid=np.delete(grid, del_col, 1)

for i in grid:
    print("".join(i))

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int>cnt(M,0);
  for(int i=0;i<N;i++){
    int K; cin >> K;
    for(int j=0;j<K;j++){
      int A;cin >> A; --A;
      ++cnt[A];
    }
  }
  int ans=0;
  for(int i=0;i<M;i++){
    if(cnt[i]==N){
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int a,b;
inline int read()
{
	int x=0,ff=1;
	char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') ff=-1;ch=getchar();}
	while(isdigit(ch)) {x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return x*ff;
}
int main()
{
//	freopen("1.in","r",stdin);
	a=read();b=read();
	for(int i=b*10;i<=b*10+9;++i) if((int)(i*0.08)==a) {cout<<i;return 0;}
	puts("-1");
	return 0;
}


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

int main() {
  int a = 0;
  int b = 0;
  int o = 0;
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  for (int i = 0; i < N; i++){
    if (o % 2  == 0){
      a += vec.at(i);
      o++;
    }else{
      b += vec.at(i);
      o++;
    }
  }
  cout << a - b << endl;
}

Measured memory_bytes: 3572
N = int(input())
src = [tuple(map(int,input().split())) for i in range(N)]
nt,na = src[0]
for t,a in src[1:]:
    t1 = nt + (-nt)%t
    a1 = t1//t * a
    a2 = na + (-na)%a
    t2 = a2//a * t
    if a1 < na:
        nt,na = t2,a2
    else:
        nt,na = t1,a1
print(nt+na)


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(){
	char s[100000]; cin >> s;
	int res[100000];
	for(int i = 0; i < 100000; i++) res[i] = 0;
	int idx = 0;
	int i;
	bool RFlag = true;
	for(i = 0; s[i] != '\n' && s[i] != '\0'; i++){
		if(!RFlag && s[i] == 'R'){
			idx = i;
			RFlag = true;
		}
		else if(RFlag && s[i] == 'L'){
			if((i-idx)%2==0){
				res[i-1] += ((i-idx)/2);
				res[i] += ((i-idx)/2);
			}
			else{
				res[i-1] += ((i-idx)/2+1);
				res[i] += ((i-idx)/2);
			}
			RFlag = false;
		}
	}
	bool LFlag = true;
	int j;
	idx = i - 1;
	for(j = i-1; j >= 0; j--){
		if(!LFlag && s[j] == 'L'){
			idx = j;
			LFlag = true;
		}
		else if(LFlag && s[j] == 'R'){
			if((idx-j)%2==0){
				res[j+1] += ((idx-j)/2);
				res[j] += ((idx-j)/2);
			}
			else{
				res[j+1] += ((idx-j)/2+1);
				res[j] += ((idx-j)/2);
			}
			LFlag = false;
		}
	}
	cout << res[0];
	for(int i = 1; s[i] != '\n' && s[i] != '\0'; i++) cout << " " << res[i];
	cout << endl;
}


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

int main() {
  long A, B, K, foo, bar;
  cin >> A >> B >> K;
  
  foo = A - K;
  if (foo < 0) {
    K -= A;
    A = 0;
    bar = B - K;
    if (bar < 0) {
      B = 0;
    } else {
      B -= K; 
    }
  } else {
    A -= K;
  }
  
  cout << A << " " << B << endl;
}

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

int main()
{
	int n;
	int d[100005];
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> d[i];
	}

	sort(d,d+n);

	int mid = n/2;

	cout << d[mid] - d[mid-1] << endl;
	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


//ミョ(-ω- ?)
int main() {
    ll n;
    cin >> n;
    vector<ll> a(n,0);
    vector<ll>  cnt(1001010,0);
    rep(i,n){
        cin >> a[i];
        cnt[a[i]]++;
    }
    vector<bool> ok(1000005,true);
    rep(x,1000001){if(cnt[x] < 1)continue;
        if(cnt[x] > 1)ok[x] = false;
        for(ll i = 2*x;i < 1000001;i += x)ok[i]=false;
    }
    ll res = 0;
    rep(i,n)if(ok[a[i]])res++;
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 12656
import sys
input = sys.stdin.readline


def readlines(n):
    for _ in range(n):
        a, b = map(int, input().split())
        yield a, b

def main():
    H, N = map(int, input().split())
    magics = tuple(readlines(N))
    INF = 10**9
    dp = [INF]*(H+10**4+1)
    dp[0] = 0
    for a, b in magics:
        for i in range(H):
            if dp[i] != INF:
                t = dp[i] + b
                if t < dp[i+a]:
                    dp[i+a] = t
    print(min(dp[H:]))

if __name__ == "__main__":
    main()

Measured memory_bytes: 3692
#include <iostream>

using namespace std;

const int MAX_N = 105;
const int INF = 1e5 + 5;

char grid [MAX_N][MAX_N];
int dp [MAX_N][MAX_N];

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

  int h, w;
  cin >> h >> w;

  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> grid[i][j];
    }
  }

  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      if (i == 1 && j == 1) {
	if (grid[i][j] == '.') {
	  dp[i][j] = 1;
	} else {
	  dp[i][j] = 2;
	}
      } else {
	dp[i][j] = INF;
	if (i != 1) {
	  dp[i][j] = min(dp[i][j],
			 dp[i - 1][j] + (int) (grid[i][j] != grid[i - 1][j]));
	}
	if (j != 1) {
	  dp[i][j] = min(dp[i][j],
			 dp[i][j - 1] + (int) (grid[i][j] != grid[i][j - 1]));
	}
      }
    }
  }

  cout << dp[h][w] / 2 << endl;
}


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

using namespace std;
#define BUF (1000)
#define ll long long 

int n;
int a,b,c,d,e,f;

int main(void){
	cin >> a >> b >> c >> d >> e >> f;


	int W=0,S=0;
	double mx_con=0;
	for(int j=0;j<=f/b/100;j++){
		for(int i=0;i<= (f-100*b*j)/a/100 ;i++){
			int s=f-100*i*a-100*j*b;
			int tmp =e*( a*i+b*j );
			s = min(s, tmp);

			//cout << i << j << s << "\n";

			for (int v = 0; v <= s / d; v++)
			{

				int u = (s - v * d) / c;
				if(i==0&&j==0) break;
				double con = (double)(d * v + c * u) / (double)(100 * i * a + 100 * b * j + d * v + c * u);
				//cout << u<< v<< "+";

				if (mx_con < con)
				{
					mx_con = con;
					W = 100 * i * a + 100 * b * j + d * v + c * u;
					S = d * v + c * u;
					//cout << "update";
				}
			}
		}
	}
	if(W==0){
		W=100*a;
	}
	cout << W << " " << S << endl; ;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
	ll N, A, B;
	cin >> N >> A >> B;
    ll ans = 0;
    if ((B-A)%2) ans = (B-A)/2 + min(A-1, N-B) + 1;
    else         ans = (B-A)/2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#define fi first
#define se second
#define pb(i) push_back(i)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define mes(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e6+10;
const int INF = 0x3f3f3f3f;
const int inf = - INF;
const int mod = 1e9+7;
const double pi = acos(-1.0);


int main(){
    string s;
    cin>>s;
    rep(i,0,s.size()-1)
        cout<<'x';
    cout<<endl;
    return 0;
}

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

int main() {
    int N, K; cin >> N >> K;
    vector<bool> on(N);
    rep(i, K) {
        int d; cin >> d;
        rep(i, d) {
            int x; cin >> x;
            x--;
            on[x] = true;
        }
    }
    cout << count(range(on), false) << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int n, s;
int dp[(1<<11)][1000];



int main() {
	while (cin >> n >> s) {
        memset(dp, 0, sizeof(dp));
        dp[0][0] = 1;
        for (int bit = 0; bit < (1<<10); ++bit) {
            int num = __builtin_popcount(bit);
            
            for (int j = 0; j <= 500; ++j) {
                for (int k = 0; k < 10; ++k) {
                    if (bit & (1<<k)) continue;
                    int nbit = bit | (1<<k);
                    int nj = j + (num+1) * k;
                    
                    dp[nbit][nj] += dp[bit][j];
                }
            }
        }
        int res = 0;
        for (int bit = 0; bit < (1<<10); ++bit) {
            if (__builtin_popcount(bit) == n)
                res += dp[bit][s];
        }
        cout << res << endl;
	}
    
    return 0;
}


Measured memory_bytes: 9172
import numpy as np
N, K = map(int, input().split())
A = np.array(sorted(list(map(int, input().split()))))
F = np.array(sorted(list(map(int, input().split())), reverse=True))

left = - 1
right = 10**12

def f(x):
    return np.maximum(0, A - x//F) .sum()<= K

while right - left > 1:
    mid = (left + right)//2
    if f(mid):
        right = mid
    else:
        left = mid
    
print(right)

Measured memory_bytes: 37272
#include <stdio.h>

char str[100100];

int main(){
    int n;
    scanf("%d%s", &n, str);
    int res = 1;
    for(int i = 0; i < n - 1; i++){
        if(str[i] != str[i + 1]) res++;
    }
    printf("%d\n", res);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 111111111;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int DIV = 1000000007; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================

	ll N;
	cin >> N ;


	ll ans = 0;

	for (int i = 1; i < N; i++){
		ans += i;
	}

	cout << ans;




}



Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                               

using namespace std;
#define ll long long

ll calc(ll n){
  ll ret = 1;
  for(ll i=1; i<=n; i++){
    ret *= i;
    ret %= 1000000007;
  }
  return ret;
}

int main(){
  ll N, M;
  cin >> N >> M;
  if(abs(N - M) > 1){
    cout << 0 << endl;
  } else if(abs(N - M) == 0){
    cout << (2 * calc(N) * calc(M)) % 1000000007 << endl;
  } else {
    cout << (calc(N) * calc(M)) % 1000000007 << endl;
  }
  return 0;
}

Measured memory_bytes: 256