akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define MOD2 998244353
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define T int
#define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
auto clk=clock();
 
ll mexp(ll a, ll b, ll m){
    ll ans=1;
    a%=m;
    while(b){
        if(b&1) ans=ans*a%m;
        b>>=1;
        a=a*a%m;
    }
    return ans;
}

int a[101];

int square(int x){
    return x * x;
}

int main(){
    IOS
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int n;
    cin >> n;
    FOR(i,1,n){
        cin >> a[i];
    }
    int ans = 5000005;
    FOR(i,-100,100){
        int cost = 0;
        FOR(j,1,n){
            cost += square(a[j] - i);
        }
        ans = min(cost, ans);
    }
    cout << ans;

    cerr<<endl<<endl<<"Time: "<<fixed<<setprecision(12)<<(long double)(clock()-clk)/CLOCKS_PER_SEC<<" ms"<<endl<<endl;
 
    return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;

class Solve
{
    static void Main(string[] args) {
        var S = Console.ReadLine();
        var str = S.Distinct().ToArray();
        var len = str.Length;
        var answer = "None";
        for (char i = 'z'; i >= 'a'; i--) {
            for (int j = 0; j < len; j++) {
                if (str[j] == i) break;
                if (j == len - 1) answer = i.ToString();
            }
        }
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();
    }
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int32 n = s.size();
    int32 cnt = 0;
    REP(i,n/2){
        if(s[i] != s[n-i-1])cnt++;
    }
    ANS(cnt);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define PI acos(-1)
#define sz 100010
#define RUN_FAST ios::sync_with_stdio(false);
using namespace std;

map <string, int> mp;
map <string, int>::iterator it;

int main()
{
    RUN_FAST; cin.tie(nullptr);
    int n, i, mx;
    string s;
    cin >> n;
    for (i=0; i<n; i++) {
        cin >> s;
        mp[s]++;
    }
    mx=0;
    for (it=mp.begin(); it!=mp.end(); it++)
        mx=max(mx, it->second);
    for (it=mp.begin(); it!=mp.end(); it++) {
        if (it->second==mx) cout << it->first << endl;
    }
    return 0;
}

Measured memory_bytes: 19216
//======================================
//author @Amit Singh : global_const
//======================================
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
int a[100000]; 
// int n;
// ll sum=0;
// void change()
// { 
//   int l,m;
//   scanf("%d%d",&l,&m);
//   for(int j=0;j<n;++j)
//   {if(a[j]==l)
//   	a[j]=m;
//   }	
// }
// void solve()
// {
//   for(int j=0;j<n;++j)	
//   sum+=a[j];
//   printf("%lld\n",sum);
//   sum=0;
// }
signed main()
{
 int n;
 cin>>n;
 unordered_map<int,int>pq;
 ll sum=0;
 for(int i=0;i<n;++i)
 {cin>>a[i];
  sum+=a[i];
  ++pq[a[i]];
 }  
 int k;
 scanf("%d",&k);
 for(int i=0;i<k;++i)
 {int l,m;
 	cin>>l>>m;
 	sum+=(m-l)*pq[l];
 	pq[m]=pq[m]+pq[l];
 	pq[l]=0;
 	cout<<sum<<endl;
 }   
return 0; 
}

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

int main(void) {
	int W, a, b, ans;
	
	scanf("%d%d%d", &W, &a, &b);
	
	if (W > abs(a - b)) {
		ans = 0;
	} else if (a < b) {
		ans = b - (a + W);
	} else {
		ans = a - (b + W);
	}
	
	printf("%d", ans);
	
	return 0;	
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        float y = scan.nextInt();

        float z1 = (y -2*x) / 2;
        float z2 = (4 * x - y) / 2;

        if (z1 >= 0 && z2 >= 0 && z1%1 ==0 && z2%1 == 0){
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }


    }
}


Measured memory_bytes: 35692
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
#define pb push_back
int main()
{
	while(1)
	{
		int n;
		cin >> n;
		if(n == 0) return 0;
		vector<int>vec;
		int cur = -1;
		while(n)
		{
			if(cur < 0)
			{
				if(10 > n && n > 0) {vec.pb(n); break;}
				vec.pb(((n%10)+10)%10);
				n -= ((n%10)+10)%10;
			}
			else
			{
				if(-10 < n && n < 0) {vec.pb(-1*n); break;}
				vec.pb((10-((n%10)+10)%10)%10);
				n += (10-((n%10)+10)%10)%10;
			}
			cur *= (-1); n /= 10;
		}
		for(int i=vec.size()-1;i>=0;i--) printf("%d",vec[i]); puts("");
	}
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
int main()
{
map<long long,long long>m;
vector<long long>v;
long long a,b,c,d,i,j,k,l=0;
cin>>a;
for(i=1;i<=a;i++)
{
 cin>>b;
 m[b]++;
 if(m[b]==1)v.push_back(b);
}
for(i=0;i<v.size();i++)
{
 if(m[v[i]]%2==1)l++;
}
cout<<l<<endl;
}

Measured memory_bytes: 7284
#include<bits/stdc++.h>
using Int = int64_t;
using namespace std;
string ans;
int main(){
    Int N; cin >> N;
    vector v(N,0LL);
    for(auto& e : v) cin >> e;
    Int res = v.front();
    for(int i  = 1; i < N; ++i)
        res  =  res xor v[i];
    vector ans(N,0LL);
    for(int i   = 0; i < N; ++i)
        ans[i] = res xor v[i];
    for(auto e : ans)
        cout << e << endl;
}



Measured memory_bytes: 6232
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first.first
#define yy first.second
#define __V vector
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define oit ostream_iterator
#define mod 1000000007ll
using namespace __gnu_pbds;
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifdef LOCALc
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
template<typename T, typename l>
void getv(T& a, int n, l f) {
	a.resize(n);
	for (auto& i : a)
		cin >> i, f(i);
}
template<typename T>
void getv(T& a, int n) {
	a.resize(n);
	for (auto& i : a)
		cin >> i;
}
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll n, m, k, fact[200100];

ll binpow(ll a, ll n) {
	if (n == 0)
		return 1;
	if (n & 1)
		return (binpow(a, n - 1) * a) % mod;
	else {
		ll b = binpow(a, n / 2);
		return (b * 1ll * b) % mod;
	}
}

ll nck(ll n, ll k) {
	return (((fact[n] * binpow(fact[k], mod - 2)) % mod)
			* binpow(fact[n - k], mod - 2)) % mod;
}

ll sum(ll n) {
	return (((n * (n + 1)) % mod) * binpow(2, mod - 2)) % mod;
}

int main() {
	doin();
	fact[0] = 1;
	cin >> n >> m >> k;
	for (ll i = 1; i <= (n * m); i++)
		fact[i] = (i * fact[i - 1]) % mod;
	ll ans = 0;
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < m; j++) {
			ll cont = (sum(i) + sum(n - i - 1)) % mod;
			cont *= m;
			cont%=mod;
			cont += (n*sum(m-j-1))%mod;
			cont%=mod;
			cont += (n*sum(j))%mod;
			cont%=mod;
			cont *= nck(n*m - 2, k - 2);
			cont%=mod;
			(ans += cont)%=mod;
		}
	}
	cout << (ans*binpow(2, mod-2))%mod << "\n";
}


Measured memory_bytes: 1792
n = gets.to_i
vs = gets.chomp.split.map(&:to_i)

even = Hash.new(0)
odd = Hash.new(0)
vs.each_with_index do |v,i|
	if i.even?
		even[v] += 1
	else
		odd[v] += 1
	end
end

even = even.sort_by(&:last)
odd = odd.sort_by(&:last)
even_second = even[-2] ? even[-2][1] : 0
odd_second = odd[-2] ? odd[-2][1] : 0
if even[-1][0] == odd[-1][0]
	cnt = n - [even_second + odd[-1][1], even[-1][1] + odd_second].max
else
	cnt = n - even[-1][1] - odd[-1][1]
end

puts cnt

Measured memory_bytes: 20852
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
ll a,b;
ll as,bs,sum=1;

void solve()
{
    cin>>a>>b;
    rep(i,1,100001)
    {
        sum*=i;
        sum%=mod;
        if(i==a)as=sum;
        if(i==b)bs=sum;
    }   
    if(abs(a-b)>1)cout<<0<<endl;
    else if(abs(a-b)==1)cout<<as*bs%mod<<endl;
    else if(a==b)cout<<as*bs*2%mod<<endl;
}

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

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
for(var i=0;i<4;i++){
var arr=Arr[i].split(" ").map(Number);
if(arr[0]==1)console.log(arr[1]*6000);
if(arr[0]==2)console.log(arr[1]*4000);
if(arr[0]==3)console.log(arr[1]*3000);
if(arr[0]==4)console.log(arr[1]*2000);
}

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

int main(void){
   vector<int> a(5);
   int sum = 0;
   for(int i = 0;i < 5;i++){
       cin >> a[i];
       sum += (a[i] + 9) / 10 * 10; 
   }
   int ans = sum;
   for(int i = 0;i < 5;i++){
       ans = (a[i] % 10 > 0) ? min(ans,sum - 10 + a[i] % 10) : ans;
   }
   cout << ans << endl;
   
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define  fuckit(){	\
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL); \
}
using namespace std;
int main()
{
	fuckit();
	long long a,b,x;
	cin>>a>>b>>x;
	if(a==0){
		cout<<b/x+1<<endl;
	}
	else if(x==1){
		cout<<(b-a)+1<<endl;
	}
	else{
		cout<<b/x-(a-1)/x<<endl;
	}
	return 0;	
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main{
    public static long []dp = new long[110000];
    public static void main(String []args){
        Scanner in = new Scanner(System.in);

        int n, k; n = in.nextInt(); k = in.nextInt();
        long []heights = new long[n];

        for(int i = 0; i < n; i ++)
            heights[i] = in.nextLong();

        for (int i = 0; i < 110000; i ++)
            dp[i] = (long)Math.pow(10,18)+5;

        dp[0] = 0;
        for (int i = 1; i < n; i ++){
            if (i - k >= 0){
                for (int j = 1; j <= k; j ++)
                    dp[i] = Math.min(dp[i], dp[i-j]+Math.abs(heights[i]-heights[i-j]));
            }

            else{
                for(int j = 1; j <= i; j ++){
                    dp[i] = Math.min(dp[i], dp[i-j]+Math.abs(heights[i]-heights[i-j]));
                    if (j == i+1)
                        break;
                }
            }
        }

        System.out.print(dp[n-1]);
    }
}

Measured memory_bytes: 60412
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <cstring>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int maxm = 11;

int n,m,q;
vector<int>e[maxn];
bool in[maxn][maxm];
int f[maxn][maxm];
struct P {
  int d,v,c;
  P() {}
  P(int d,int v,int c):d(d),v(v),c(c) {}
} p[maxn];

int main() {
 // freopen("in.cpp","r",stdin);
  cin>>n>>m;
  for(int i=0; i<m; i++) {
    int x,y;
    cin>>x>>y;
    e[x].push_back(y);
    e[y].push_back(x);
  }
  cin>>q;
  queue<pair<int,int>>que;
  for(int i=0; i<q; i++) {
    int d,v,c;
    cin>>v>>d>>c;
    p[i]=P(d,v,c);
    f[v][d]=i+1;
    que.push(make_pair(v,d));
    in[v][d]=1;
  }
  while(!que.empty()) {
    auto pr=que.front();
    que.pop();
    if(pr.second==0)continue;
    int v=pr.first,d=pr.second;
    in[v][d]=0;
    //if(v==6)cout<<"dfs"<<f[v][d-1]<<endl;
    if(f[v][d-1]<f[v][d]) {
      //if(v==6)cout<<"dfssd"<<endl;
      f[v][d-1]=f[v][d];
      if(!in[v][d-1]) {
        in[v][d-1]=1;
        que.push(make_pair(v,d-1));
      }
    }
    for(int i=0; i<e[v].size(); i++) {
      int u=e[v][i];
      if(f[u][d-1]<f[v][d]) {
        f[u][d-1]=f[v][d];
        if(!in[u][d-1]) {
          in[u][d-1]=1;
          que.push(make_pair(u,d-1));
        }
      }
    }
  }
  for(int i=1; i<=n; i++) {
    if(f[i][0]==0)cout<<0<<endl;
    else cout<<p[f[i][0]-1].c<<endl;
  }
  return 0;
}


Measured memory_bytes: 19960
// I make this just for fun because i'm done
// Aimi Haraguni >> Konomi Suzuki >> Yui >>  Ikimono Gakari >> Garnidelia >> Kalafina >> Eir Aoi.   .. dude? 
// problems that involves any kind of persistent data structures are the best of the best, are not them?
 
// #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
 
#define pb emplace_back
#define ff  first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define sz(x) ll(x.size())
#define all(v) (v).begin(), (v).end()
#define FER(i,a,b) for(ll i=ll(a); i< ll(b); ++i)
#define IFR(i,a,b) for(ll i=ll(a); i>=ll(b); --i )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
 
#define N 31000000
// #define M 19
 
// #define mod  11092019
#define mod1 1000000007
#define mod2 1000000009
#define bas 987625403
#define sqr(x) (x)*(x)  
#define INF 2000000000
 
using namespace std;
using namespace __gnu_pbds;
 
typedef int ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii > tri;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> S_t;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

inline ll mul(ll a, ll b, ll mod) { return (long long) a*b%mod;}
inline ll add(ll a, ll b, ll mod) { return a+b < mod? a+b: a+b-mod;}
inline void Mul(ll &a, ll b, ll mod) { a = (long long) a*b%mod;}
inline ll bp(ll a, ll p, ll mod){
	ll ret;
	for(ret = 1; p; p>>=1, Mul(a, a, mod)) (p & 1) && (Mul(ret, a, mod), 1);
	return ret;
}

static inline void read(ll &result) {
    bool minus = false;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' and ch <= '9') break;
        ch = getchar();
    }
    (ch == '-')? minus = true: result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' or ch > '9') break;
        result = (result<<3)+ (result<<1) + (ch - '0');
    }
    if(minus) result=-result;
}

int main(){
	fastio;
	string a, b; cin>>a>>b;
	ll ans = 0;
	FER(i, 0, sz(a)){
		if(a[i] != b[i]) ans++;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3888
import sys, bisect

N = int(input())
L = list(map(int, sys.stdin.readline().rsplit()))
L.sort()

res = 0
for i in reversed(range(1, N)):
    for j in reversed(range(i)):
        r = bisect.bisect_right(L, abs(L[i] - L[j]))
        
        if r < j:
            res += j - r
        
print(res)


Measured memory_bytes: 9244
#include<bits/stdc++.h>
using namespace std;
int a[103];
bool cmp(int a,int b){
	return a>b;
}
int main(){
	int m,n;
	int sum=0;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	sort(a+1,a+1+n,cmp);
	if(a[m]>=(1.0*sum/(4*m)))printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 256
#include <stdio.h>

int a[200010],n;
int bs(int k){
	if(a[0]>=k)return 0;
	int l=0,r=n;
	while(r-l>1){
		int m=(l+r)/2;
		if(a[m]<k)l=m;
		else r=m;
	}
	return r;
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	int q;
	scanf("%d",&q);
	while(q--){
		int k;
		scanf("%d",&k);
		printf("%d\n",bs(k));
	}
}



Measured memory_bytes: 2128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {
	public static void main(String[] args)throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line[] = br.readLine().split(" ");
			int n = Integer.parseInt(line[0]);
			int k = Integer.parseInt(line[1]);
			if(n==0){break;}

			boolean dealt[] = new boolean[n+1];
			Arrays.fill(dealt, false);

			for(int i=0; i<k; i++){
				dealt[Integer.parseInt(br.readLine())] = true;
			}

			int count = 0;
			ArrayList<Integer> ladder = new ArrayList<Integer>();
			for(int i=1; i<=n; i++){
				if(dealt[i]){
					count++;
				}else{
					ladder.add(count);
					count = 0;
				}
			}
			ladder.add(count);

			int maxi = 0;
			if(dealt[0]){
				for(int i=0; i<ladder.size()-1; i++){
					int twosum = ladder.get(i).intValue() + ladder.get(i+1).intValue();
					if(twosum + 1 > maxi){maxi = twosum+1;}
				}
			}else{
				for(Integer cont:ladder){
					if(cont.intValue() > maxi){maxi = cont.intValue();}
				}
			}

			System.out.println(maxi);
		}
	}
}

Measured memory_bytes: 34648
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("trapv")
#pragma GCC target("sse4")

#include <bits/stdc++.h>

using namespace std;

#define deb(x) cout << #x << " is " << x << "\n"
#define int long long
#define mod 1000000007
#define PI acos(-1)

void solve() {
    int n, x, y;
    cin >> n;
    vector<int> sum(n), diff(n);
    for (int i = 0; i < n; i++) {
        cin >> x >> y;
        sum[i] = x + y;
        diff[i] = x - y;
    }
    int maxone = INT_MIN, maxtwo = INT_MIN;
    int minone = INT_MAX, mintwo = INT_MAX;
    int ans = INT_MIN;
    for (int i = 0; i < n; i++) {
        maxone = max(maxone, sum[i]);
        maxtwo = max(maxtwo, diff[i]);
        minone = min(minone, sum[i]);
        mintwo = min(mintwo, diff[i]);
        ans = max({ans, maxone - minone, maxtwo - mintwo});
    }
    cout << ans;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//#endif
    int tc = 1;
//    cin >> tc;
    while (tc--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 6356
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	long long n, i, j, k, a, ans;
	cin >> n >> a;
	vector<long long> x(n);
	for (i = 0; i < n; i++) cin >> x[i];
	vector<vector<vector<long long>>> dp(n + 1, vector<vector<long long>>(n + 1, vector<long long>(a * n + 1, 0)));
	dp[0][0][0] = 1;
	for (i = 0; i < n; i++) {
		dp[i + 1] = dp[i];
		for (k = 0; k < n; k++) {
			for (j = 0; j < a * n; j++) {
				if (j + x[i] <= a * n) dp[i + 1][k + 1][j + x[i]] += dp[i][k][j];
			}
		}
	}

	ans = 0;
	for (i = 1; i <= n; i++) ans += dp[n][i][a * i];

	cout << ans << "\n";


	return 0;
}



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

int main() {
  string a, b;
  cin >> a >> b;

  if(a.size() > b.size()) cout << "GREATER";
  else if(a.size() < b.size()) cout << "LESS";
  else {
    for(int i = 0; i < a.size(); i++) {
      if(a[i] > b[i]) {
        cout << "GREATER";
        return 0;
      }else if(a[i] < b[i]) {
        cout << "LESS";
        return 0;
      }
    }
    cout << "EQUAL";
  }
}


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

N,Q=map(int,input().split())
a=tuple(map(int1,input().split()))
lr=[[0,0,i] for i in range(Q)]
for i in range(Q):
    lr[i][0],lr[i][1]=map(int1,input().split())
lr.sort(key=lambda t: t[1],reverse=1)
class BIT:
    def __init__(self,n):
        self.num=n
        self.dat=[0]*(self.num+1)
        self.depth=n.bit_length()
    
    def add(self,i,x):
        i+=1
        while i<=self.num:
            self.dat[i]+=x
            i+=i&-i
    
    def sum(self,i):
        i+=1
        s=0
        while i>0:
            s+=self.dat[i]
            i-=i&-i
        return s
    
    def lower_bound(self,x):
        sum_=0
        pos=0
        for i in range(self.depth,-1,-1):
            k=pos+(1<<i)
            if k<=self.num and sum_+self.dat[k]<x:
                sum_+=self.dat[k]
                pos+=1<<i
        return pos, sum_

b=BIT(N)
lastap=[-1]*N
ans=[-1]*Q
l,r,j=lr.pop()
for i,x in enumerate(a):
    if lastap[x]!=-1:
        b.add(lastap[x],-1)
    b.add(i,1)
    lastap[x]=i
    while r==i:
        ans[j]=b.sum(r)-b.sum(l-1)
        if lr:
            l,r,j=lr.pop()
        else:
            l,r,j=-1,-1,-1
for x in ans:
    print(x)

Measured memory_bytes: 181640
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int main(){
    string s;
    cin >> s;
    sort(s.begin(),s.end());

    if(s == "abc"){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e18
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

struct node{ll from,to,cap,flow,cost;};
vector <node> edges;
vector <int> mp[maxn];
ll s,t,n,m,d[maxn],flow,cost,p[maxn],a[maxn];
bool inq[maxn];
queue <int> que;

inline void A(int u,int v,ll w,ll c)
{
	edges.push_back((node){u,v,w,0,c});
	edges.push_back((node){v,u,0,0,-c});
	int pp=edges.size();
	mp[u].push_back(pp-2);
	mp[v].push_back(pp-1);
}

inline bool spfa()
{
	for(int i=0;i<=t;i++) d[i]=inf,inq[i]=0,a[i]=inf;
	que.push(s); d[s]=0;
	while(!que.empty())
	{
		int u=que.front(); que.pop(); inq[u]=0;
		for(int i=0;i<mp[u].size();i++)
		{
			node &v=edges[mp[u][i]];
			if(v.cap-v.flow>0&&d[v.to]>d[u]+v.cost)
			{
				d[v.to]=d[u]+v.cost;
				a[v.to]=min(a[u],v.cap-v.flow);
				p[v.to]=mp[u][i];
				if(inq[v.to]==0) que.push(v.to),inq[v.to]=1;
			}
		}
	}
	if(d[t]==inf) return false;
	flow+=a[t];
	cost+=a[t]*d[t];
	for(int i=t;i!=s;i=edges[p[i]].from)
	{
		edges[p[i]].flow+=a[t];
		edges[p[i]^1].flow-=a[t];
	}
	return true;
}

int main()
{
	n=read(); s=0; t=2*n+5;
	rep(i,1,n)
	{
		ll a=read(),b=read(),c=read();
		A(s,i,c,0); A(i,2*n+1,inf,a+b); A(i,2*n+2,inf,a-b);
		A(i,2*n+3,inf,-a+b); A(i,2*n+4,inf,-a-b);
	}
	rep(i,1,n)
	{
		ll a=read(),b=read(),c=read();
		A(n+i,t,c,0); A(2*n+1,n+i,inf,-a-b); A(2*n+2,n+i,inf,-a+b);
		A(2*n+3,n+i,inf,a-b); A(2*n+4,n+i,inf,a+b);
	}
	while(spfa()); cout<<-cost<<endl;
	return 0;
}

Measured memory_bytes: 30596
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        int d = a / b;
        int s = a % b;
        double f = (double)a / (double)b;

        System.out.print(d + " " + s + " ");
        System.out.println(String.format("%.5f", f));
    }
}



Measured memory_bytes: 26444
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
const int INF = 1e8;
using namespace std;

int main(){
	int n, k;
	cin >> n >> k;

	vector<bool> use(10,1);
	rep(i,k){
		int x;
		cin >> x;
		use[x] = false;
	}

	range(i,n,INF){
		int d = i;
		bool f = true;
		while(d != 0){
			if(not use[d % 10]){
				f = false;
			}
			d/=10;
		}
		if(f){
			cout << i << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int i = 1, n = sc.nextInt();
		while (i <= n) {
			int x = i;
			if (x % 3 == 0) {
				System.out.printf(" %d", i);

			} else {
				while (x >= 1) {
					if (x % 10 == 3) {
						System.out.printf(" %d", i);
						break;
					}
					x /= 10;
				}
			}
			i++;

		}
		System.out.printf("\n");
		sc.close();
	}
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    string s;
    cin >> s;
    int q;
    cin >> q;
    deque<char> ans;
    for (auto u : s)
    {
        ans.push_back(u);
    }
    
    int flag = 0;
    vector<int> t(q);
    vector<int> f(q);
    vector<char> c(q);
    rep(i,q)
    {
        cin >> t[i];
        if (t[i]==2)
        {
            cin >> f[i] >> c[i];
        }
    }
    rep(i,q)
    {
        if (t[i]==1)
        {
            flag = (flag+1)%2;
        }
        else
        {
            if (flag == 0)
            {
                if (f[i]==1)
                {
                    ans.push_front(c[i]);
                }else
                {
                    ans.push_back(c[i]);
                }
            }else
            {
                if (f[i]== 2)
                {
                    ans.push_front(c[i]);
                }
                else
                {
                    ans.push_back(c[i]);
                }
            }
        }
    }
    if (flag == 1)
    {
        reverse(ans.begin(), ans.end());
    }
    for (auto u : ans)
    {
        cout << u;
    }
    cout << endl;
    
}

Measured memory_bytes: 2688
using System;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {      
            var input = Console.ReadLine().Split(' ');
            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);
            var c = int.Parse(input[2]);

            var num = 0;
            for (int i = a; i <= b; i++)
            {
                if ((c % i) == 0) num++;
            }

            Console.WriteLine(num);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 5612
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
int main()
{
	int64_t X;
	std::cin >> X;
	std::vector<int64_t> V;
	for (int64_t i = 0; i < 128; ++i) {
		V.push_back(i*i*i*i*i);
	}
	for (size_t i = 0; i < V.size(); ++i) {
		for (size_t j = 0; j < V.size(); ++j) {
			if (V[i] - V[j] == X) {
				std::cout << i << " " << j << std::endl;
				return 0;
			}
			else if (V[i] + V[j] == X) {
				std::cout << i << " " << -(int64_t)j << std::endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3620
import java.util.*;

import static java.lang.System.*;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = ni();
        int x = ni();
        int[] a = niarr(N);

        Arrays.sort(a);

        int num = 0;
        int i = 0;
        while (i < N && x >= a[i]) {
            x -= a[i];
            i++;
            num++;
        }

        // give all but there is rest
        if (x > 0 && num > 0 && i == N) {
            num--;
        }

        out.println(num);
    }

    static int ni() {
        return sc.nextInt();
    }

    static long nl() {
        return sc.nextLong();
    }

    static String ns() {
        return sc.next();
    }

    static int[] niarr(int N) {
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }
        return a;
    }

    static long[] nlarr(int N) {
        long[] a = new long[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextLong();
        }
        return a;
    }
}

Measured memory_bytes: 23892
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

ll ans;
string s;
int n;

ll val(vi a){
  ll res = 0;
  int keta = a.size() - 1;
  rep(i, a.size()){
    res += pow(10, keta) * a[i];
    keta--;
  }
  return res;
}

int main(){
  cin >> s;
  int n = s.size();
  bitset<9> bs;
  bs = 1;
  int mx = pow(2, n-1);
  rep(i, mx){
    bs = i;
    vi a;
    rep(j, n){
      a.pb(s[j] - '0');
      if(bs[j] == 1){
        ans += val(a);
        a.clear();
      }
    }
    ans += val(a);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int A , B , C , D , N = 0, T = 0;
    cin >> A >> B >> C >> D;
    if(C % B == 0){
        N = C / B;
    }
    else{
        N = C / B + 1;
    }
    if(A % D == 0){
        T = A / D;
    }
    else{
        T = A / D + 1;
    }
    if(T >= N){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3636
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<String,Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            if(map.containsKey(s)) {
                map.put(s, map.get(s) + 1);
            }else {
                map.put(s, 1);
            }
        }
        int m = sc.nextInt();
        for (int i = 0; i < m; i++) {
            String s = sc.next();
            if(map.containsKey(s)) {
                map.put(s, map.get(s) - 1);
            }else {
                map.put(s, -1);
            }
        }
        int max = Collections.max(map.values());
        if(max > 0) System.out.println(max);
        else System.out.println(0);
    }
}

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

using namespace std;


int main(){

    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;

    vector<int> Nums;
    int cnt = 0;
    int now = 1;
    for (int i = 0; i < n; i++) {
        if (s[i] == (char)('0' + now)) cnt++;
        else {
            Nums.push_back(cnt);
            now  = 1 - now;
            cnt = 1;
        }
    }
    if (cnt != 0) Nums.push_back(cnt);
    if (Nums.size() % 2 == 0) Nums.push_back(0);

    int Add = 2 * k + 1;
    int ans = 0;
    int left = 0;
    int right = 0;
    int temp = 0;
    for (int i = 0; i < Nums.size(); i += 2) {

        int Nextleft = i;
        int Nextright = min(i + Add, (int)Nums.size());

        // 左端を移動
        while (Nextleft > left) {
            temp -= Nums[left];
            left++;
        }
        // 右端を移動
         while (Nextright > right) {
            temp += Nums[right];
            right++;
         }
        ans = max(ans, temp);
    }

    cout << ans << '\n';

}


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

typedef long long LL;

int main()
{
	LL n;
	cin>>n;
	if(n==1)
	{
		printf("0\n");
		return 0;
	}
	int ans=0;
	for(LL i=2;i*i<=n;i++)
		if(n%i==0)
		{
			int cnt=0;
			while(n%i==0) n/=i,cnt++;
			for(int i=1;i<=cnt;i++)
				ans++,cnt-=i;
		}
	if(n!=1) ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}

int N,M;
vector<vector<int>> G;
string s;

const int MN = 200010;
int vis[MN][4];
string C = "ABBA";

void dfs(int v,int t){
	if(vis[v][t]==1){
		puts("Yes");
		exit(0);
	}
	if(vis[v][t]==2) return;

	vis[v][t] = 1;

	int nt = (t+1)%4;
	for(int u:G[v]){
		if(s[u] != C[t]) continue;
		dfs(u,nt);
	}
	vis[v][t] = 2;
}

int main(){
	cin>>N>>M;
	cin>>s;
	G.resize(N);
	rep(i,M){
		int x,y;
		cin>>x>>y;
		x--,y--;
		G[x].pb(y);
		G[y].pb(x);
	}
	rep(i,N) if(s[i]=='A' && !vis[i][0]){
		dfs(i,0);
	}
	puts("No");
}


Measured memory_bytes: 21508
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N;
  cin>>N;
  vector<ll> A(N), sumA(N);
  for(int i=0;i<N;++i) {
    cin>>A[i];
  }
  sort(A.begin(), A.end());
  for(int i=0;i<N;++i) sumA[i] = A[i];
  for(int i=1;i<N;++i) sumA[i] += sumA[i-1];
  int l=0, r=N, m;
  ll size;
  bool can;
  while(l<r) {
    m = (l+r)/2;
    size = sumA[m];
    can = true;
    for(int i=m+1;i<N;++i) {
      if(size*2>=A[i]) {
        size += A[i];
      }
      else can = false;
    }
    if(!can) l = m+1;
    else r = m;
  }
  cout<<N-l<<endl;
}



Measured memory_bytes: 4836
#include<stdio.h>
#define M 100000000
int main(){
  int n,m,i,j,k,l;
  int d[21][21];
  scanf("%d %d",&n,&m);
  for(i=0;i<21*21;i++)d[i/21][i%21]=M;
  while(m--){
    scanf("%d,%d,%d,%d",&i,&j,&k,&l);
    d[i][j]=k;
    d[j][i]=l;
    d[i][i]=d[j][j]=0;
  }
  for(k=1;k<=n;k++){
    for(j=1;j<=n;j++){
      for(i=1;i<=n;i++){
	if(d[i][j]>d[i][k]+d[k][j])d[i][j]=d[i][k]+d[k][j];
      }
    }
  }
  scanf("%d,%d,%d,%d",&i,&j,&k,&l);
  printf("%d\n",k-d[i][j]-d[j][i]-l);
  return 0;
}

Measured memory_bytes: 600
from collections import deque 
import sys
input = sys.stdin.readline
q = deque([])
h,w=map(int,input().split())
a=[list(input()) for i in range(h)]
x=[[-1,0],[1,0],[0,-1],[0,1]]
for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
            for k in x:
                if 0<=i+k[0]<h and 0<=j+k[1]<w and a[i+k[0]][j+k[1]]==".":
                    a[i+k[0]][j+k[1]]="0"
                    q.append([i+k[0],j+k[1],1])
ans=0
while q:
    v=q.popleft()
    for k in x:
        if 0<=v[0]+k[0]<h and 0<=v[1]+k[1]<w and a[v[0]+k[0]][v[1]+k[1]]==".":
            a[v[0]+k[0]][v[1]+k[1]]="0"
            q.append([v[0]+k[0],v[1]+k[1],v[2]+1])
            ans=v[2]+1
print(ans)


Measured memory_bytes: 190268
#include <iostream>
#include <cstdio>

#define ll long long

using namespace std;

string s;
int n;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    n = s.size();
    s = " " + s;
    int ans = n;
    for(int i = 1; i <= n; i++){
        if(s[i] == s[i-1]){
            ans--;
            i += 2;
        }
    }
    cout << ans << endl;
    return 0;
}

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

def dfs(s):
#  print("1, s:{}".format(s))
  if int(s) > N:
#    print("4, s:{}".format(s))
    return 0
  ret = 1 if all(s.count(c) > 0 for c in "753") else 0
  for c in "753":
    ret += dfs(s+c)
#    print("2, s:{}, ret:{}".format(s, ret))
#  print("3, s:{}, ret:{}".format(s, ret))
  return ret
  
print(dfs("0"))

Measured memory_bytes: 2940
import math


def main():
    N = int(input())
    P = [int(x) for x in input().split()]
    Q = [int(x) for x in input().split()]

    p_pos = get_pos(P)
    q_pos = get_pos(Q)
    if p_pos > q_pos:
        print(p_pos - q_pos)
    else:
        print(q_pos - p_pos)


def get_pos(arr):
    len_to_pattern = [0, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880]
    p_pos = 0
    pos = len(arr) - 1
    first = len_to_pattern[pos]
    after = list(arr)
    after.sort()
    i = 0
    for p1 in arr:
        p_pos += first * after.index(p1)
        pos -= 1
        first = len_to_pattern[pos]
        i += 1
        after = arr[i:]
        after.sort()
    return p_pos


def get_max_len(l):
    v = l.sort(reverse=True)[0]
    return len(str(v))


if __name__ == "__main__":
    main()


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

public class Test
{
	public static void Main()
	{
		string[] line = Console.ReadLine().Split(' ');
		int n = int.Parse(line[0]);
		int y = int.Parse(line[1]);
		int ans10000 = -1;
		int ans5000 = -1;
		int ans1000 = -1;

		for(int a = 0 ; a <= n ; a++){
			for(int b = 0 ; b+a <= n ; b++){
				int c = n - a - b;
				if(a*10000 + b*5000 + c*1000 == y){
					ans10000 = a;
					ans5000 = b;
					ans1000 = c;			
					break;
				}
			}
		}

		Console.WriteLine(ans10000+ " " + ans5000 + " "+ ans1000);
	}                                                                                                                                                                       
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define int long long
#define fori(j,n) for(int i=j;i<n;i++)
#define forb(n,j) for(int i=n-1;i>=0;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define PI 3.141592653589793
#define M 1000000007
using namespace std;
int fast(int a,int b)
{
    int ans=1;
    a=a%M;
    if(a==0)
        return 0;
    while(b>0)
    {
        if(b&1)
        {
            ans=(ans*a)%M;
        }
        b>>=1;
        a=(a*a)%M;
    }
    return ans;
}

int32_t main()
{
    int x, n, t;
    cin >> x >> n;
	if(n == 0)
    {
		cout << x << endl;
		return 0;
	}
	set<int> s;
	for(int i = 0;i < n; ++i)
    {
		cin >>t;
		s.insert(t);
	}
	int t1=x, t2=x;
	while(true)
	{
		if(!s.count(t1))
		{
			cout << t1<< endl;
			return 0;
		}
		if(!s.count(t2))
		{
			cout << t2 << endl;
			return 0;
		}
		--t1;
		++t2;
	}
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int N, K;
  cin >> N >> K;
  double ans = 0.0;
  REP1(i, N)
  {
    int score = i;
    double div = 1.0;
    while (score < K)
    {
      score *= 2;
      div /= 2.0;
    }
    ans += div;
  }
  ans /= N;
  printf("%.12f\n", ans);
  return 0;
}

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

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

  int N;
  cin >> N;

  int64_t res = 0;
  static int f[10000001];
  for (int i = 1; i <= N; ++i) {
    for (int j = i; j <= N; j += i) {
      ++f[j];
    }
    res += (int64_t) i * f[i];
  }

  cout << res << endl;

  return 0;
}



Measured memory_bytes: 42656
import java.util.*;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        String [][] s = new String[H+2][W+2];

        for(int i = 0 ; i <= (H+1) ; i++){
        	for(int j = 0 ; j <= (W+1) ; j++){
        		s[i][j] = " ";
        	}
        }
        
        String kekka = "Yes";

        for(int i = 1 ; i <= H  ; i++){
            String[] str = sc.next().split("");
            for(int j = 1 ; j <= W ; j++){
                s[i][j] = str[j-1];
            }
        }

        for(int i = 1 ; i <= H  ; i++){
            for(int j = 1 ; j <= W ; j++){
                if(s[i][j].equals("#")){
                	if((s[i-1][j].equals(".")) && (s[i][j-1].equals(".")) && (s[i][j+1].equals(".")) && (s[i+1][j].equals("."))){
                		kekka = "No";
                		break;
                	}
                }
            }
        }

        System.out.println(kekka);
    }
}

Measured memory_bytes: 21972
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat)


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    X = S()
    stack = deque()
    c = 0

    for i in range(len(X)):
        if X[i] == 'S':
            stack.append(X[i])
        elif X[i] == 'T' and len(stack) != 0:
            stack.pop()
            c += 1

    print(len(X) - c * 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 44124
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

#define pb push_back
#define mp make_pair
#define taskname "A"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int maxn = 1e6 + 5;
int n;
int cnt[maxn];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    string s;
    fill_n(cnt,maxn,0);
//    for(int i = 0 ; i < 1e1 ; ++i)cout << rand() % 10;cout << endl;
    cnt[0]++;
    int n , p;cin >> n >> p >> s;
    ll res = 0;
    if(p == 2){
        for(int i = 0 ; i < n ; ++i){
            if((s[i] - '0') % 2 == 0)res += i + 1;
        }
    }else if(p == 5){
        for(int i = 0 ; i < n ; ++i){
            if((s[i] - '0') % 5 == 0)res += i + 1;
        }
    }else{
        int tmp = 1;int cur = 0;
        reverse(s.begin(),s.end());
        for(auto c : s){
            cur = (cur + (c - '0') * tmp) % p;
//            cout << cur << " ";
            res += cnt[cur]++;
            tmp = tmp * 10 % p;
        }
    }
    cout << res;
}




Measured memory_bytes: 4688
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
int main(){
    ll l,r;
    cin >>l>>r;
    r=min(r,l+4038);
    int ans=2018;
    for(ll i=l;i<=r;i++){
        for(ll j=i+1;j<=r;j++){
            int x=i*j%2019;
            ans=min(ans,x);
        }
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<pair<int,int>> p(n);
  for(int i=0;i<n;i++){
    cin >> p[i].second >> p[i].first;
  }
  sort(p.begin(),p.end());
  int t=0;
  string ans = "Yes";
  for(int i=0;i<n;i++){
    t += p[i].second;
    if(t > p[i].first){
      ans = "No";
      break;
    }
  }
  cout <<  ans  << endl;
}


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

using namespace std;

int main()
{
    string a;
    cin>>a;
    string b=a;
    reverse(a.begin(),a.end());
    for(int i=0;i<a.size();++i)
    {
        if(a[i]=='b') a[i]='d';
        else if(a[i]=='d') a[i]='b';
        else if(a[i]=='p') a[i]='q';
        else if(a[i]=='q') a[i]='p';
    }
    if(a==b) cout<<"Yes";
    else cout<<"No";
}

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

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;

struct segtree{
	pll T[606060];
	ll sz = 1 << 18;
	
	void init(ll n, ll *B)
	{
		ll i;
		
		for(i=0; i<n; i++){
			T[sz + i] = pll(B[i], i);
		}
		
		for(i=sz-1; i; i--){
			T[i] = max(T[i << 1], T[i << 1 | 1]);
		}
	}
	
	void update(ll p, ll v)
	{
		T[p + sz] = pll(v, p); p += sz;
		
		for(p>>=1; p; p>>=1){
			T[p] = max(T[p << 1], T[p << 1 | 1]);
		}
	}
	
	pll getval() { return T[1]; }
};

segtree T;
ll A[202020], B[202020];
ll n, cnt, ans;

void die() { printf("-1\n"); exit(0); }

int main()
{
	ll i, v, l, r;
	
	scanf("%lld", &n);
	
	for(i=0; i<n; i++){
		scanf("%lld", A + i);
	}
	
	for(i=0; i<n; i++){
		scanf("%lld", B + i);
	}
	
	T.init(n, B);
	
	for(; cnt<n; ){
		tie(v, i) = T.getval();
		
		if(v == -1) die();
		l = B[(i + n - 1) % n]; r = B[(i + 1) % n];
		
		if(B[i] == A[i]){
			cnt ++; T.update(i, -1);
			continue;
		}
		
		if(B[i] < A[i] || B[i] <= l + r) die();
		
		if((B[i] - A[i]) % (l + r) == 0){
			ans += (B[i] - A[i]) / (l + r);
			B[i] = A[i];
			cnt ++; T.update(i, -1);
			continue;
		}
		else{
			ans += B[i] / (l + r);
			B[i] %= (l + r);
			T.update(i, B[i]);
		}
	}
	
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 10624