akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;
const char ENDL = '\n';

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int n,a,b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    REP(i,n){
        switch(s[i]){
            case 'a':
                if(a>0){
                    a--;
                    cout << "Yes" << ENDL;

                }else if(b>0){
                    b--;
                    cout << "Yes" << ENDL;
                }else{
                    cout << "No" << ENDL;
                }
                break;
            case 'b':
                if(b>0){
                    b--;
                    cout << "Yes" << ENDL;
                }else {
                    cout << "No" << ENDL;
                }
                break;
            case 'c':
                cout << "No" << ENDL;
        }
    }
    
    return 0;
}

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

#define nl printf("\n")
#define pb(x) push_back(x)

#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define P(a) printf("%d",a)

#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a<b)?a:b)

#define PL(a) printf("%lld",a)
#define PLN(a) printf("%lld\n",a)
#define PLC(a) printf("%lld ",a)
#define SL(a) scanf("%lld",&a)
#define SL2(a,b) scanf("%lld%lld",&a,&b)
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define SL4(a,b,c,d) scanf("%lld%lld%lld%lld",&a,&b,&c,&d)

#define CLR(a) memset(a,0,sizeof(a))
#define SET(a) memset(a,-1,sizeof(a))
#define FOOL(a) memset(a,false,sizeof(a))
#define fr(i,a,n) for(i=a;i<=n;i++)
#define frv(i,v) for(i=0;i<(int)v.size();i++)
#define pi acos(-1.0)
#define po 1000000
#define co 1000000
#define mod 786433

using namespace std;
int main()
{
    string a,b,c;
    cin>>a>>b>>c;
    cout<<a[0]<<b[1]<<c[2]<<"\n";
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,no-stack-protector,fast-math")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 2e5 + 5, M = 2 * N + 5;

int n;
ll ans;
char s[15];

void f(int i, ll sum, ll nw){
    if(i == n)return ans += sum + nw, void();
    f(i + 1, sum * 10 + s[i] - '0', nw);
    f(i + 1, 0, nw + sum);
}

int main(){
    scanf("%s", s);
    n = strlen(s);
    f(0, 0, 0);
    printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
bool isPrime(long long n);
using namespace std;
int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n;
    cin>>n;

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

    int ans=0;
    for(i=1;i<=n;i++){
        if(isPrime(x[i])){
            ans++;
        }
    }

    cout<<ans<<"\n";
    return(0);
}
bool isPrime(long long n){
    if(n==2){
        return(true);
    }
    if(n<=1||n%2==0){
        return(false);
    }
    for(int i=3;i*i<=n;i+=2){
        if(n%i==0){
            return(false);
        }
    }
    return(true);
}


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

int main(){
    int X,Y;
    cin >> X >> Y;
    if (Y % 2 == 1){
        cout << "No" << endl;
    }
    else if (X * 2 > Y || X * 4 < Y){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
}



Measured memory_bytes: 3620
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
a=[0]*n
for i in range(m):
  if l[i][0]==1:
    a[l[i][1]]+=1
  elif l[i][1]==n:
    a[l[i][0]]+=1
for i in range(n):
  if a[i]==2:
    print("POSSIBLE")
    break
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 53280
a, b, c, d = map(int, input())

def A(x):
    if x == 1:
        x = "+"
    else:
        x = "-"
    return x




for i in [1, -1]:
    for j in [1, -1]:
        for k in [1, -1]:
            if a + (i * b) + (j * c) + (k * d) == 7:
                print(str(a) + A(i) + str(b) + A(j) + str(c) + A(k) + str(d) + '=7')
                exit()



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

#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
//#define endl '\n'  
typedef long long ll; 
typedef unsigned long long ull; 
typedef long double ld;
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
const ll mod=1e9+7;
const ll inf=1e17+10;
const ll N=1e5+10;


int main()
{
	boost;
	ll n;
	cin>>n;
	ll a[n];
	for(auto &i:a) cin>>i;
	sort(a,a+n);
	ll k=n/2;
	cout<<a[k]-a[k-1];	
  	return 0;
}

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

#define pb push_back
#define mp make_pair
#define f1 first
#define s2 second

#define fastio ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(x...) cerr << "[" << #x << "]: " << x << "\n";

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pl;

ld const PI = 4*atan((ld)1);

int const N = 2e5 + 7;
ll a[N], b[N];

int main()
{
	fastio;

	ll n, q;
	cin >> n >> q;

	for (int i = 2; i <= n; ++i)
		a[i] = b[i] = n;

	ll res = (n-2) * (n-2);

	ll R = n, C = n;
	while (q--)
	{
		int t, x;
		cin >> t >> x;

		if (t == 1)
		{
			if (x < C)
			{
				for (int i = x; i < C; ++i)
					b[i] = R;
				C = x;
			}
			res -= (b[x] - 2);
		}
		else
		{
			if (x < R)
			{
				for (int i = x; i < R; ++i)
					a[i] = C;
				R = x;
			}
			res -= (a[x] - 2);
		}
	}
	cout << res << '\n';

	return 0;
}


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

using namespace std;
#define ub upper_bound
#define sum(a) accumulate(all(a),0ll)
#define lb lower_bound
#define all(v) begin(v),end(v)
#define allr(v) rbegin(v),rend(v)
#define sort_dec(v) sort(all(v),[](auto e1,auto e2){return e1>e2;})
#define For(n) for(ll i=0;i<n;i++)
#define Forj(n) for(ll j=0;j<n;j++)
#define ios iostream::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef long long int ll;
typedef unsigned long long int ull;
#define fi first
#define se second
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define Mp 1e9+7
#define vpll vector< pair<ll,ll> >
#define bug(n) {cout<<n;return;}
#define cont(n) {cout<<n<<endl;continue;}
#define pb push_back
long long int mod = 1000000007;

const int sz=1000001;

ll MAX=1e18;


void solve()
{
  ll a,b;
  cin>>a>>b;
  ll g=__gcd(a,b);
  ll c=1;
  for(ll i=2;i*i<=g;i++)
  {
      if(g%i==0)
      {
          c++;
          while(g%i==0)g/=i;
      }
  }
  if(g>2)c++;
  cout<<c<<endl;

}

int main() {
  ll t=1;
  while(t--)
  {
      solve();
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		String a = sc.next();
		String b = sc.next();
		
		for(int i=0; i<a.length(); i++){
			
			if (b.equals(a)){
				System.out.println("Yes");
				return;
			}
//			System.out.println(a.substring(a.length()-1));
//			System.out.println(a.substring(0, a.length()-1));
			a = (a.substring(a.length()-1)).concat(a.substring(0, a.length()-1));
//			System.out.println("--");
//			System.out.println(a);
		}
		
		
		
		
		System.out.println("No");
		
	}

}


Measured memory_bytes: 21972
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let N = read int
    let S = read string |> Seq.toArray

    let mutable cnt = 0
    for i in 0 .. 999 do
        let c = [| i / 100; (i / 10) % 10; i % 10 |]
        seq {
            let mutable f = 0
            for j in 0 .. N - 1 do
                if int S.[j] = (int '0' + c.[f]) then
                    f <- f + 1
                if f = 3 then yield ()
        }
        |> fun s ->
            if not (Seq.isEmpty s) then cnt <- cnt + 1

    printfn "%i" cnt
    0

Measured memory_bytes: 14428
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;




int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if (a==b)
        cout<<c;
    else if (a==c)
        cout<<b;
    else if (b==c)
        cout<<a;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a  = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long k = sc.nextLong();
		long ans = a-b;
		if(Math.abs(ans)>Math.pow(10, 18)) {
			System.out.println("Unfair");
			return;
		}
		if(k%2 == 0) {
			System.out.println(ans);
		}
		else {
			System.out.println(ans*-1);
		}
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int a, b;
	cin >> a >> b;

	cout << max(a + b, max(a - b, a * b)) << endl;

}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;

using ll=long long;

const ll inf =1LL << 62;
const ll mod=1000000007LL;

inline ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
inline ll ADD(const ll &a, const ll &b,const ll &mod) { return a+b<mod?a+b:a+b-mod;}
inline ll SUB(const ll &a, const ll &b,const ll &mod) { return a-b>=0?a-b:a-b+mod;}
inline ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
inline ll INV(ll a,ll mod){ll x,y;extgcd(a,mod,x,y);return (x%mod+mod)%mod;}
inline ll DIV(const ll &a, const ll &b,const ll &mod) {return MUL(a,INV(b,mod),mod);}
inline ll POW(ll a,ll n,ll mod){ll b=1LL;for(a%=mod;n;a=MUL(a,a,mod),n>>=1)if(n&1) b=MUL(b,a,mod); return b;}


const int limit=200010;
ll fact[limit],rfact[limit];


void init(){
	fact[0]=1LL;
	rep(i,limit-1) fact[i+1]=MUL(fact[i],i+1,mod);
	rfact[limit-1]=INV(fact[limit-1],mod);
	rrep(i,limit-1) rfact[i]=MUL(rfact[i+1],i+1,mod);
}

inline ll comb(ll a,ll b){
	return MUL(fact[a+b],MUL(rfact[a],rfact[b],mod),mod);
}


int main(void){
	init();

	int h,w,a,b;
	cin >> h >> w >> a >> b;

	int ch=h-1-a,cw=b;


	ll ans=0LL;
	while(0<=ch && cw<w){
		ans=ADD(ans,MUL(comb(ch,cw),comb(h-1-ch,w-1-cw),mod),mod);
		ch--,cw++;
	}

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

Measured memory_bytes: 3328
use proconio::{input, marker::Chars};
use std::collections::VecDeque;

fn main() {
    input! {
        s: Chars,
    }

    let mut deque = VecDeque::from(s);
    let mut ans = 0;

    while let (Some(front), Some(back)) = (deque.pop_front(), deque.pop_back()) {
        if front == back {
            continue;
        }
        if front == 'x' {
            deque.push_back(back);
            ans += 1;
        } else if back == 'x' {
            deque.push_front(front);
            ans += 1;
        } else {
            println!("-1");
            return;
        }
    }

    println!("{}", ans);
}


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

typedef long long ll;
typedef pair<int, int> pii;

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

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

    return 0;
}


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

int main() {
	int N;
	cin >> N;
	int a=N%10;
	int b=(N/10)%10;
	int c=N/100;
	if (c>=b) {
		if (c==b && b<a) {
			cout << c+1 << c+1 << c+1 << endl;
		} else {
			cout << c << c << c << endl;
		}
	} else {
		cout << c+1 << c+1 << c+1 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
use std::io::{self, BufRead};

pub fn is_prime(n: i64) -> bool {
  let mut i = 2;
  while i * i <= n {
    if n % i == 0 {
      return false
    }
    i += 1
  }
  n != 1
}

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let line = lines.next().unwrap().unwrap();
  let mut x: i64 = line.parse().unwrap();
  while !is_prime(x) {
    x += 1;
  }
  println!("{}", x);
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")
int table[365][26];
int main()
{
int D;
	cin >> D;
	vec(C);
	vec(Las);
	fx(26) {
		vecp(C);
		Las.push_back(0);
	}

	fx(D) {
		fy(26) {
			cin >> table[x][y];
		}
	}

	vec(T);
	fx(D) {
		pb(T, x % 26 + 1);
	}
	ll sum = 0;
	srand((time(NULL)));
	fx(100000) {
		int d, q;
		d = rand() % D + 1, q = rand() % 26 + 1;
		int pre = T[d - 1];
		T[d - 1] = q;
		ll ans = 0;

		fy(26) {
			Las[y] = 0;
		}
		fw(D) {

			ans += table[w][T[w] - 1];
			Las[T[w] - 1] = w + 1;
			fz(26) {
				ans -= C[z] * (w + 1 - Las[z]);
			}
		}
		if (ans>sum) {
			sum = ans;
		}
		else {
			T[d - 1] = pre;
		}
	}

	fx(D) {
		ce(T[x])
	}
	
    return 0;
}



Measured memory_bytes: 3644
#include<bits/stdc++.h>
using ll = long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end()

#define INF (ll)1e9 //10^9:∞
#define LLINF (ll)1e12
#define MOD (ll)(1e9+7) //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define F first
#define S second
#define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr);

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)
#define endl "\n"

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/


/*.....................DEFINE FUNCTIONS ......................*/



/*.........................kemkemG0...........................*/
signed main() {
	__MAGIC__


	int N;
	cin >> N;
	vector<string> v(N);
	REP(i, N) {cin >> v[i]; sort(ALL(v[i]));}

	vector<vector<int>> alphabet(N, VI('z' + 1, 0));

	string ans = {""};

	REP(i, N) {
		REP(j, v[i].size()) {
			alphabet[i][(int)v[i][j]]++;
		}
	}
	vector<int> list('z' + 1, INF);
	FOR(i, 'a', 'z') {
		REP(j, N) {
			list[i] = min(list[i], alphabet[j][i]);
		}
	}
	FOR(i, 'a', 'z') {
		REP(j,list[i]){
			ans+=(char)i;
		}
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<cstdlib>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<cmath>
#include<iomanip>
#define rep(i,n) for(int i(0);i<n;i++)

using namespace std;
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;

    int ans(1);
    rep(i,n-1){
        if(s[i] != s[i+1]) ans += 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; i++){
    cin >> A[i];
  }
  vector<int> B;
  copy(A.begin(), A.end(), back_inserter(B));
  sort(B.begin(), B.end(), greater<int>());
  for (int i = 0; i < n; i++){
    if (A[i] == B[0])
      cout << B[1] << endl;
    else
      cout << B[0] << endl;
  }
  return 0;
}


Measured memory_bytes: 3316
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,m;
    cin>>n>>m;
    vi d;
    for(int i=1;i*i<=m;i++){
        if(m%i==0){
            d.pb(i);
            d.pb(m/i);
        }
    }
    sort(all(d));
    int ans=1;
    for(int i=0;i<d.size()&&d[i]<=m/n;i++){
        ans=d[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
def solve():
  x,y,z,k = (int(i) for i in input().split())
  a = list(int(i) for i in input().split())
  b = list(int(i) for i in input().split())
  c = list(int(i) for i in input().split())
  a = sorted(a,reverse=True)
  b = sorted(b,reverse=True)
  c = sorted(c,reverse=True)
  ab = []
  abc = []
  
  for i in range(x):
    for j in range(y):
      ab.append(a[i]+b[j])
  ab = sorted(ab,reverse = True)
  for t in range(min(k,len(ab))):
    for l in range(z):
      abc.append(ab[t]+c[l])
      
  abc = sorted(abc,reverse = True)
  for i in range(k):
    print(abc[i])

solve()

Measured memory_bytes: 140748
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
char name[100];
int t;
}P;

P Q[LEN];
int head, tail,n;

void enqueue(P x){
Q[tail]=x;
tail = (tail+1)%LEN;
}

P dequeue(){
P x=Q[head];
head=(head+1)%LEN;
return x;
}

int min(int a,int b){return a<b?a:b;}

int main(){
int elaps=0,c;
int i,q;
P u;
scanf("%d %d",&n,&q);

for(i=1;i<=n;i++){
scanf("%s",Q[i].name);
scanf("%d",&Q[i].t);
}
head=1;
tail=n+1;

while(head!=tail){
u=dequeue();
c=min(q,u.t);
u.t-=c;
elaps+=c;
if(u.t>0)enqueue(u);
else{
printf("%s %d\n",u.name,elaps);
}
}

return 0;
}

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

int main() {
  string S;
  cin >> S;

  for (int i = 0; i < 26; i++) {
    char C = 'a' + i;
    if (S.find(C) == -1) {
      cout << C << endl;
      return 0;
    }
  }

  cout << "None" << endl;
}

Measured memory_bytes: 512
/*
    Those who cannot remember the past are condemned to repeat it.
                                            - Dynamic Programming
    
    I never lose, I either win or I learn.
                - Competitive Programming

*/

import javax.print.DocFlavor;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

class Pair {
    long x;
    long y;
    Pair(long u, long v) {
        x = u;
        y = v;
    }
}

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        PrintWriter pw = new PrintWriter(System.out);

        st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        long d = Long.parseLong(st.nextToken());
        long a = Long.parseLong(st.nextToken());

        Pair[] p = new Pair[n];

        for(int i=0 ; i<n ; i++) {
            st = new StringTokenizer(br.readLine());
            long u = Long.parseLong(st.nextToken());
            long v = Long.parseLong(st.nextToken());
            p[i] = new Pair(u, v);
        }

        Arrays.sort(p, (o1, o2) -> (int)(o1.x-o2.x));

        int l = 0;
        int r = 0;
        long ans = 0;
        long reduce = 0;
        long[] lazy = new long[n+2];
        for(int i=0 ; i<n ; i++) {
            reduce += lazy[i];
            p[i].y -= reduce*a;
            if(p[i].y <= 0) continue;
            long val = p[i].x;
            long go_to = val+2*d;
            while(r < n && p[r].x <= go_to) {
                r++;
            }
            long reduce_at_this_step = p[i].y%a == 0 ? p[i].y/a : p[i].y/a+1;
            lazy[r] += -reduce_at_this_step;
            reduce += reduce_at_this_step;
            ans += reduce_at_this_step;
        }

        pw.println(ans);
        
        pw.flush();
        pw.close();
    }
}


Measured memory_bytes: 64748
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <cstring>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

constexpr int MOD = 1'000'000'007;

LL dp[10001][100][2] = {};

void solve() {
    string s;
    int d;
    cin >> s >> d;
    int n = s.size();
    memset(dp, -1, sizeof(dp));
    dp[0][0][0] = 1;
    REP(i,0,n) {
        REP(j,0,d) {
            if (dp[i][j][0] != -1) {
                dp[i+1][(j+s[i]-'0')%d][0] = dp[i][j][0];
                REP(k,0,s[i]-'0') {
                    dp[i+1][(j+k)%d][1] = max(0LL,dp[i+1][(j+k)%d][1]);
                    dp[i+1][(j+k)%d][1] += dp[i][j][0];
                    if (dp[i+1][(j+k)%d][1] >= MOD) dp[i+1][(j+k)%d][1] -= MOD;
                }
            }
            if (dp[i][j][1] != -1) {
                REP(k,0,10) {
                    dp[i+1][(j+k)%d][1] = max(0LL,dp[i+1][(j+k)%d][1]);
                    dp[i+1][(j+k)%d][1] += dp[i][j][1];
                    if (dp[i+1][(j+k)%d][1] >= MOD) dp[i+1][(j+k)%d][1] -= MOD;
                }
            }
        }
    }
    cout << (max(0LL, dp[n][0][0]) + max(0LL, dp[n][0][1]) - 1 + MOD) % MOD << endl;
}

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

Measured memory_bytes: 15872
// Last Change:  11/19/2018 00:58:42.
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  stack<int> s;
  string inputData;
  int a, b;
  while (cin >> inputData) {
    if (inputData == "+") {
      a = s.top();
      s.pop();
      b = s.top();
      s.pop();
      s.push(a + b);
    } else if (inputData == "-") {
      a = s.top();
      s.pop();
      b = s.top();
      s.pop();
      s.push(b - a);  //順番注意
    } else if (inputData == "*") {
      a = s.top();
      s.pop();
      b = s.top();
      s.pop();
      s.push(a * b);
    } else {
      s.push(stoi(inputData));
    }
  }
  cout << s.top() << endl;

}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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 h,w; cin>>h>>w;
    if(h==1 || w==1) cout<<1<<endl;
    else if((h*w)%2==0) cout<<(h*w)/2<<endl;
    else cout<<(h*w+1)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
        out << '(' << p.first << ',' << p.second << ')';
            return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
        in >> p.first >> p.second;
            return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
        for (T &x : v)
                    in >> x;
            return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T> > &v)
{
        for (const vector<T> &x : v)
                    out << x << '\n';
            return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
        for (const T &x : v)
                    out << x << ' ';
            return out;
}

template <class T>
ostream& operator << (ostream& out,const set<T> &s)
{
        for (const T &x : s)
                out << x << ' ';
            return out;
}
 
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<nl
#define epsilon 0.00000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main()
{
    fast();
    string s;
    cin>>s;
    ll n=sz(s)+1;
    vi a(n);
    for(ll i=0;i<n-1;i++)
    {
        if(s[i]=='<')
        {
            a[i+1]=a[i]+1;
        }
    }
    for(ll i=n-2;i>=0;i--)
    {
        if(s[i]=='>')
        {
            a[i]=max(1+a[i+1],a[i]);
        }
    }
    cout<<accumulate(all(a),0ll)<<nl;
}


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

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    for (int i = 0; i < H; i++){
        cin >> s[i];
    }
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            if(s[i][j] == '#'){
                if(i > 0){if(s[i - 1][j] == '#')continue;}
                if(i < H - 1){if(s[i + 1][j] == '#')continue;}
                if(j > 0){if(s[i][j - 1] == '#')continue;}
                if(j <W - 1){if(s[i][j + 1] == '#')continue;}
                cout << "No";
                return 0;
            }
        }
    }
    cout << "Yes";
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {

            var nm = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var n = nm[0];
            var m = nm[1];
            var p = new int[m];
            
            var ps = new List<Tuple<int, long>>[n];
            for (int i = 0; i < n; i++)
            {
                ps[i] = new List<Tuple<int, long>>();
            }
            
            for (int i = 0; i < m; i++)
            {
                var py = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
                p[i] = (int)py[0];

                ps[py[0]-1].Add(new Tuple<int, long>(i, py[1]));
            }
            for (int i = 0; i < n; i++)
            {
                ps[i].Sort((a, b) => a.Item2.CompareTo(b.Item2));
            }

            var y = new int[m];
            for (int i = 0; i < n; i++)
            {
                var pss = ps[i];
                for (int j = 0; j < pss.Count; j++)
                {
                    y[pss[j].Item1] = j;
                }
            }

            for (int i = 0; i < m; i++)
            {
                Console.WriteLine(p[i].ToString("000000") + (y[i]+1).ToString("000000"));
            }
    }
}



Measured memory_bytes: 33540
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,M; cin>>N>>M;
    vint x(M);
    REP(i,M) cin>>x[i];

    sort(ALL(x));
    vint l(M-1);
    REP(i,M-1) l[i]=x[i+1]-x[i];
    sort(ALL(l));

    int ans=0;
    REP(i,M-N) ans+=l[i];
    cout<<ans<<endl;

}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    int answer = (n - (n/1000)*1000);
    if(answer == 0) {
        cout << 0 << endl;
    } else {
        cout << 1000 - answer << endl;
    }
    return 0; 
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int k,x;
    cin>>k>>x;
    for(int i=x-k+1;i<=x+k-1;i++) {
        cout<<i<<' ';
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
n = int(input())
l = [list(input().split()) for i in range(n)]
start = []
end = []
d = True
for i in range(n):
    if l[i][0] == "1":
        d = not (d)
    else:
        if l[i][1] == "1":
            if d:
                start.append(l[i][2])
            else:
                end.append(l[i][2])
        else:
            if d:
                end.append(l[i][2])
            else:
                start.append(l[i][2])
if d:
    print("".join(start[::-1]) + s + "".join(end))
else:
    print("".join(end[::-1]) +
          ''.join(list(reversed(s))) + "".join(start))

Measured memory_bytes: 33024
#include<bits/stdc++.h>
using namespace std;
bool cmp(long long int x,long long int y)
{
   return x>y;
}
int main(void)
{
   long long int t,n,x,y,w;
   vector<long long int> v,v1,v2;
   vector< pair <long long int,long long int> >p,p1,p2;
   set<long long int> st;
   priority_queue<long long int> pq;
   priority_queue< long long int,vector<long long int>,greater<long long int> > lpq;
   priority_queue< pair<long long int,long long int>,vector< pair<long long int,long long int> >,greater< pair <long long int,long long int> > > plpq;
   cin>>n>>w;
   if(w>=n)
      cout<<"unsafe"<<endl;
   else
      cout<<"safe"<<endl;
   return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
 
int main()
{

double r,N;
scanf("%lf",&N);
r=remainder(N,2);
if(r==0){ printf("%0.6lf\n",(N/2)/N);}
else{ printf("%0.6lf\n",(((N-1)/2)+1)/N);}
 return 0;
}

Measured memory_bytes: 2260
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
template<typename T>
bool all_same(vector<T> v1,vector<T> v2){
    sort(ALL(v1));
    sort(ALL(v2),greater<T>());
    return v1 == v2;
}
 
// g++ -std=c++11 prac.cpp
ll Max=-1,Min=1e9+1;
 
int main(){
    ll x=0,y=0,n,m,k,l,r,w,sum1=0,sum2=0,ans=0;
    string s,t;
    bool f=true;
    map <ll,ll> a;
    cin >> n;
    rep(i,n){
        cin >> m;
        if (a.find(m) != a.end()){
            a.find(m)->second++;
        }
        else{
            a.insert(make_pair(m,1));
        }
    }
    for(auto i = a.begin(); i!=a.end();i++) {
        if(i->second >= 2){
            if(x < i->first){
                y = x;
                x = i->first;
            }
            else if(y < i->first){
                y = i->first;
            }
        }

        if (i->second >=4){
            ans = i->first * i->first;
        }
    }
    if(ans > x*y)
        cout << ans << endl;
    else  
        cout << x*y << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    int r;
    cin >> r;
    
    cout << 3*(r*r) <<endl;
    
    return 0;
}



Measured memory_bytes: 256
from collections import defaultdict


def main():
    S = input()
    N = len(S)
    index_list_dict = defaultdict(list)
    for i, c in enumerate(S):
        index_list_dict[c].append(i)
    ans = N
    for index_list in index_list_dict.values():
        li = [-1] + index_list + [N]
        v = 0
        for i in range(len(li) - 1):
            v = max(v, li[i + 1] - li[i] - 1)
        ans = min(ans, v)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9328
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <deque>
#include <string>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanInt(M);
    vector<set<int>> edges(N);
    loop(i, M){
        scanInt(ai); --ai;
        scanInt(bi); --bi;
        edges[ai].emplace(bi);
        edges[bi].emplace(ai);
    }
    vector<int> results;
    set_intersection(edges[0].begin(), edges[0].end(), edges[N - 1].begin(), edges[N - 1].end(), back_inserter(results));
    if (results.empty()){
        puts("IMPOSSIBLE");
    }else{
        puts("POSSIBLE");
    }
}


Measured memory_bytes: 28416
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt(), k=sc.nextInt();
        char[] c=sc.next().toCharArray();
        sc.close();
        int h=0;
        for(int i=0;i<n;i++) if(i<n-1 && c[i]==c[i+1]) h++;
        h+=2*k;
        System.out.println(h<=n-1?h:n-1);
    }
}

Measured memory_bytes: 26356
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+5;
#define ls p<<1
#define rs p<<1|1
int mx[N<<2];
void pushup(int p){
	mx[p]=max(mx[ls],mx[rs]);
}
int query(int p,int l,int r,int ql,int qr){
//	cout<<l<<" "<<r<<" "<<mx[p]<<" "<<ql<<" "<<qr<<endl;
	if(ql<=l&&r<=qr) return mx[p];
	int mid=(l+r)>>1,res=0;
	if(ql<=mid) res=query(ls,l,mid,ql,qr);
	if(mid+1<=qr) res=max(res,query(rs,mid+1,r,ql,qr));
	return res;
}
void upt(int p,int l,int r,int pos,int val){
	if(l==r) return (void)(mx[p]=val);
	int mid=(l+r)>>1;
	if(pos<=mid) upt(ls,l,mid,pos,val);
	else upt(rs,mid+1,r,pos,val);
	pushup(p);
}
int a[N],K,f[N],ans;
signed main(){
	int n;
	cin>>n>>K;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	for(int i=n;i>=1;--i){
		f[i]=query(1,0,N-5,max(a[i]-K,0),min(a[i]+K,N-5))+1;
		upt(1,0,N-5,a[i],f[i]);
		ans=max(ans,f[i]);
	//	cout<<f[i]<<endl;
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 9944
import sys

class graph:
  def __init__(self):
    nm = input().split()
    # # vertices
    self.nv = int(nm[0])
    # # edges
    self.ne = int(nm[1])
    # vertices
    self.vertices = [i for i in range(self.nv)]
    # edge [edge id][0,1]
    self.edges = [[0, 0] for i in range(self.ne)]
    # accessible_edge [vertex id][connected vertex id]
    self.accessible_edge = [[] for i in range(self.nv)]
    for i in range(self.ne):
      e = list(map(lambda x: int(x)-1, input().split()))
      self.edges[i] = e
      self.accessible_edge[e[0]].append(e[1])
      self.accessible_edge[e[1]].append(e[0])
  
  def remove_edge(self, i):
    removed_accessible_edge = [[] for i in range(self.nv)]
    for j in range(self.ne):
      if j!=i:
        e = self.edges[j]
        removed_accessible_edge[e[0]].append(e[1])
        removed_accessible_edge[e[1]].append(e[0])
    return removed_accessible_edge

  def DFS(self, mod_edge):
    visited = [False for i in range(self.nv)]
    stack  = []

    #initial id
    I = 0
    # stack, [0]=  vertex id, [1] = # searched children index
    stack.append(I)
    visited[I] = True
    while len(stack)!=0:
      # vertex id
      vid = stack.pop(0)
      # print(vid+1)
      v_edges = mod_edge[vid]
      # if not all([visited[e] for e in v_edges]):
      for e in v_edges:
        if not visited[e]:
          visited[e] = True
          stack.append(e)
    return all(visited)
    

if __name__ == "__main__":
  g = graph()
  count = 0
  for i in range(g.ne):
    mod_edge = g.remove_edge(i)
    # print(mod_edge)
    count += 1 if not g.DFS(mod_edge) else 0
  print(count)

Measured memory_bytes: 3192
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <math.h>
#include <utility>
#include <map>
#include <queue>
#include <stack>
#include <set>

using namespace std;

#define INF 210000000
#define int long long

int gcd(int a, int b) {
  int amari = a % b;
  int c = b;
  if (amari == 0) {
    return b;
  } else {
    return gcd(b, amari);
  }
}

int lcm(int a, int b) { return a * b / gcd(a, b); }

signed main() {
    int n;
    cin >> n;
    vector<string> s;
    for(int i=0;i<n;i++){
        string tmp;
        cin >> tmp;
        s.push_back(tmp);
    }
    set<char> st;
    map<char,int> cnt1;
    map<char,int> cnt2;
    for(int i=0;i<n;i++){
        for(int j=0;j<s[i].length();j++){
            st.insert(s[i][j]);
        }
    }
    for(int i=0;i<n;i++){
        cnt2.clear();
        for(int j=0;j<s[i].length();j++){
            if(i == 0) cnt1[s[i][j]]++;
            cnt2[s[i][j]]++;
            st.insert(s[i][j]);
        }
        for(auto& a : st){
            if(cnt2[a] < cnt1[a]) cnt1[a] = cnt2[a];
            else cnt2[a] = cnt1[a];
        }
    }
    for(auto& a : cnt1){
        for(int i=0;i<a.second;i++){
            cout << a.first;
        }
    }
}



Measured memory_bytes: 256
import itertools,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,W = LI()
wv = [LI() for _ in range(N)]
dp = [[0]*(W+1) for _ in range(N+1)] #1_indexed
for i,j in itertools.product(range(1,N+1),range(W+1)):
    w,v = wv[i-1]
    if j-w>=0:
        dp[i][j] = max(dp[i][j],dp[i-1][j-w]+v)
    dp[i][j] = max(dp[i][j],dp[i-1][j])
print(dp[-1][-1])


Measured memory_bytes: 121200
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using namespace std;


int main()
{
	int n;
	cin >> n ;
	vector<pair<int, int>> p(n);

	rep(i, n) {
		int a;
		scanf("%d", &a);
		p.at(i) = make_pair(a, i + 1);
	}

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

	rep(i, n) {
		int b,a;
		tie(b, a) = p.at(i);
		cout << a << " ";
	}
	
}


Measured memory_bytes: 1536
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N = I()
A = LI()

s = sum(A)
ans = 0
for i in range(N):
    temp = (A[i]%mod)*((s-A[i])%mod)
    temp %= mod
    ans += temp
    ans %= mod

ans *= pow(2,mod-2,mod)
ans %= mod
print(ans)

Measured memory_bytes: 106104
#include <bits/stdc++.h>
     //https://www.codechef.com/viewsolution/28454497
    // https://medium.com/hackernoon/manachers-algorithm-explained-longest-palindromic-substring-22cb27a5e96f
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define vi vector<int>
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define mod 1000000007
#define int long long
vector < ll> primes;
 int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int n;
bool isvalid(int x,int y){
  return (x>=0 and x<n and y>=0 and y<n);
}
void Sieve(ll n) 
{ 
    bool prime[n+1];
	for(ll i=0;i<n+1;++i)
		prime[i]=true;
    for (ll p=2;p*p<=n;++p) 
    {
        if (prime[p] == true) 
        {  
            for (ll i=2*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    }  
    for(ll p=2; p<=n; p++) 
       if (prime[p]) 
		primes.push_back(p);  
}
 const int N = 5e5 + 5;
 	int connected;
	int par[N], sz[N];
 
struct DSU
{

	void init(int n) 
	{
		for(int i=1;i<=n;i++)
		{
			par[i]=i;
			sz[i]=1;
		}
		connected=n;
	}
 
	int getPar(int k)
	{
		while(k!=par[k])
		{
			par[k]=par[par[k]];
			k=par[k];
		}
		return k;
	}
 
	int getSize(int k)
	{
		return sz[getPar(k)];
	}
 
	void unite(int u, int v)
	{
		int par1=getPar(u), par2=getPar(v);
 
		if(par1==par2)
			return;
 
		connected--;
 
		if(sz[par1]>sz[par2])
			swap(par1, par2);
 
		sz[par2]+=sz[par1];
		sz[par1]=0;
		par[par1]=par[par2];
	}
};
 
 

DSU dsu;
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
        return gcd(b % a, a); 
} 
ll powermod(ll x, ll y){
    if(y==0)
    return 1;
        
    if(y%2==0)
    return (powermod(x,y/2)*powermod(x,y/2))%mod;
    else
    return (((powermod(x,y/2)*powermod(x,y/2))%mod)*x)%mod;
}
// vector<vector<int>>dp(3500,vector<int>(3500));

 
 
int32_t main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);


   string s,t,u;
   int a,b;
   
   cin>>s>>t;
    
    
    cin>>a>>b;
   cin>>u;
   
   if(u==s)
   {
       cout<<a-1<<" "<<b;
   }
   else if(u==t)
   {
       cout<<a<<" "<<b-1;
   }
   else
   {
       cout<<a<<" "<<b;
   }
    
    
    
    
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <string.h>
#include <vector>

using namespace std;
int main() {
    int D, Christmas = 25;
    string ans;
    cin >> D;
    if(D == Christmas) {
        ans = "Christmas";
    } else if(D == Christmas - 1) {
        ans = "Christmas Eve";
    } else if(D == Christmas - 2) {
        ans = "Christmas Eve Eve";
    } else {
        ans = "Christmas Eve Eve Eve";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string.h>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<functional>

using namespace std;

int main() {
	int n;
	cin >> n;
	if (n < 1200) { cout << "ABC" << endl; }
	if (n >= 1200) { cout << "ARC" << endl; }
	return 0;
}

Measured memory_bytes: 256