akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include<vector>

using namespace std;
int N;
vector<long long int >X, Y;
int main(void) {

	cin >> N;
	long long int tmp;
	for (int i = 1; i <= N; i++) {
		cin >> tmp;
		X.push_back(tmp);
		Y.push_back(tmp);
	}

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

	long long int M1, M2;
	M2 = Y[N / 2];
	M1 = Y[N / 2 - 1];

	for (int i = 0; i < N; i++) {
		if (X[i] <= M1) { cout << M2 << endl; }
		else { cout << M1 << endl; }
	}

	//system("pause");
	return 0;
}


Measured memory_bytes: 5604
#include <bits/stdc++.h>
 
#define ll long long
#define loop(a) loopi(i,a)
#define loopi(i,a) for(int i=0; i<a; i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
 
using namespace std;
 
const int mod=1e9+7;
const int maxn=100005;
 
int main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	int n,m;
	string s;
	cin >> n >> m >> s;
	reverse(s.begin(),s.end());
	vector<int> ans;
	int x=0;
	int y;
	while(1){
		if(x+m>=n){
			ans.push_back(n-x);
			break;
		}
		y=x+m;
		while(s[y]=='1') y--;
		if(y<=x){
			cout << -1 << "\n";
			return 0;
		}
		ans.push_back(y-x);
		x=y;
	}
	reverse(ans.begin(),ans.end());
	loop(ans.size()) cout << ans[i] << " ";
	cout << "\n";
	return 0;
}


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

signed main(){
  int N,D,ans=0;
  cin>>N>>D;
  rep(i,N){
    int X,Y;
    cin>>X>>Y;
    double num=X*X+Y*Y;
    if(sqrt(num)<=D)ans+=1;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3664
n=gets.to_i
 line=gets.split(' ').map(&:to_i)
q=gets.to_i
bc=[]
q.times do
  bc << gets.chomp.split(" ").map { |e|e.to_i  }
end
sum=line.sum
table=line.tally
table.default = 0
bc.each do |i,j|
  sum+=table[i]*(j-i)

table[j]+=table[i]
  table[i]=0

  p sum
  end

 


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	vector<vector<vector<int>>>a(4,vector<vector<int>>(3,vector<int>(10,0)));
	int n; cin>>n;
	for(int i=0;i<n;++i){
		int b,f,r,v; cin>>b>>f>>r>>v;
		a.at(b-1).at(f-1).at(r-1)+=v;
	}
	for(int i=0;i<4;++i){
		for(int j=0;j<3;++j){
			for(int k=0;k<10;++k){
				cout<<" "s<<a.at(i).at(j).at(k);
			}
			cout<<"\n"s;
		}
		if(i!=3)cout<<"####################\n"s;
	}
}


Measured memory_bytes: 3212
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
#include <iterator>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#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, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string ab = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string as = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------
//提出するときC++に帰る
//--------------------------



int main() {

  ll A;
  string B;
  cin >> A >> B;
  ll C = (B[0]-'0')*100 + (B[2]-'0')*10 + (B[3]-'0');
  cout << (A*C)/100 << endl;


  return 0;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    int[] arr = {sc.nextInt(), sc.nextInt(), sc.nextInt()};
    Arrays.sort(arr);
    boolean is575 = (arr[0] == 5 && arr[1] == 5 && arr[2] == 7);

    System.out.println(is575 ? "YES" : "NO");
  }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    double l; cin >> l;
    double a = l / 3.0;
    double ans = a*a*a;
    printf("%.10f", ans);
}


Measured memory_bytes: 256
p = 10**9+7
N = int(input())
S1 = input().strip()
S2 = input().strip()
cnt = 1
cur = 0
if N>=2 and S1[0]==S1[1]:
    cnt = cnt*6
    cur = 2
else:
    cnt = cnt*3
    cur = 1
while cur<N:
    if cur<N-1 and S1[cur]==S1[cur+1]:
        if S1[cur-1]==S2[cur-1]:
            cnt = (cnt*2)%p
            cur += 2
        else:
            cnt = (cnt*3)%p
            cur += 2
    elif S1[cur-1]==S2[cur-1]:
        cnt = (cnt*2)%p
        cur += 1
    elif cur>=2 and S1[cur-2]==S1[cur-1]:
        cur += 1
print(cnt)    

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
  string S;
  cin >> S;
  if(S.find("AC") == string::npos) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import math
X = int(input())
def isPrime(n):
  if n == 1:
    return False
  max = math.ceil(math.sqrt(n))
  for i in range(2,max):
    if n % i == 0:
      return False
  return True

while(True):
  if isPrime(X):
    print(X)
    quit()
  else:
    X = X+1

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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;

void z_algorithm(const string s, lli *z) {
    lli len = s.length();

    // 0文字目に何を入れたいかに依る
    z[0] = 0;

    lli left = 0;
    lli right = 0;
    REP(i, 1, len) {
        if (i > right) {
            left = right = i;
            while (true) {
                if (right >= len || s[right-left] != s[right])
                    break;
                right++;
            }
            z[i] = right - left;
            right--;
        }
        else {
            lli j = i - left;
            // z-box の範囲に収まっている場合はそのままz-boxの値を入れれば良い
            if (z[j] < right - i + 1) {
                z[i] = z[j];
            }
            else {
                left = i;
                while (true) {
                    if (right >= len || s[right-left] != s[right])
                        break;
                    right++;
                }
                z[i] = right - left;
                right--;
            }

        }

    }
}

int main() {
    lli n;
    string s;
    cin1(n);
    cin1(s);
    lli ans = 0;
    REP(i,0,n) {
        lli z[n-i];
        z_algorithm(s.substr(i), z);

        //cout << s.substr(i,n-i) << endl;
        REP(j,0,n-i) {
            ans = max(ans, min(z[j], j));
            //cout << z[j];
        }
        //cout << endl;
    }
    cout << ans << endl;
}


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

namespace AthleteProgramming2
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            char[] charStr = str.ToArray();
            for(int i = 0; i < charStr.Length; i++)
            {
                if (charStr[i] >= 65 && charStr[i] <= 90)
                {
                    charStr[i] = (char)(charStr[i] + 32);
                    continue;
                }
                if (charStr[i] >= 97 && charStr[i] <= 122)
                {
                    charStr[i] = (char)(charStr[i] - 32);
                    continue;
                }
            }
            foreach(var x in charStr)
            {
                Console.Write(x);
            }
            Console.WriteLine();
        }
        
       
    }

}

Measured memory_bytes: 9044
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, L;
	vector<string> S;

	cin >> N >> L;
	for(int i=0; i<N; i++){
		string s;
		cin >> s;
		S.push_back(s);
	}
	sort(S.begin(), S.end());
	for(int i=0; i<N; i++){
		printf("%s", S[i].c_str());
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 3696
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int x=1;
    while(x*x<=2*n){
        x++;
    }
    x--;
    if(x*(x+1)/2!=n){cout<<"No"<<endl;return 0;}
    else{
        cout<<"Yes"<<endl;
        cout<<x+1<<endl;
        cout<<x<<" "<<1<<" ";
        int a=1;
        for(int i=2;i<=x;i++){
            a+=i;
            cout<<a<<" ";
        }
        cout<<endl;
    }
    int s[x];
    int a=1;
    for(int i=0;i<x;i++){
        a+=i;
        s[i]=a;
    }
    for(int i=0;i<x;i++){
        cout<<x<<" "<<s[i]<<" ";
        for(int j=1;j<x;j++){
            if(j>=i+1){
                s[i]+=j;
                cout<<s[i]<<" ";
            }
            else{
                s[i]++;
                cout<<s[i]<<" ";
            }
        }
        cout<<endl;
    }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef unsigned long long u64;
u32 P;
u32 &inc(u32 &a, u32 b) {return (a+=b)<P?a:(a-=P);}
u32 &dec(u32 &a, u32 b) {return (a-=b)&0x80000000?(a+=P):a;}
u32 sum(u32 a, u32 b) {return inc(a, b);}
u32 dif(u32 a, u32 b) {return dec(a, b);}
u64 power(u64 a, int b) {
	u64 ans=1;
	for(; b; a=a*a%P, b/=2) if(b&1) ans=ans*a%P;
	return ans;
}

const int N=3005;
u32 ifac[N], s[N][N];
int main() {
	int n;
	u32 ans=0, x=1;
	u64 fac=1, tot=2;
	assert(scanf("%d%u", &n, &P)==2);
	for(int i=1; i<=n; ++i) fac=fac*i%P;
	ifac[n]=power(fac, P-2);
	for(int i=n; i--; ) ifac[i]=(i+1llu)*ifac[i+1]%P;
	s[0][0]=1;
	for(int i=1; i<=n; ++i) {
		s[i][0]=1;
		for(int j=1; j<=i; ++j) s[i][j]=(s[i-1][j-1]+(j+1llu)*s[i-1][j])%P;
	}
	for(int i=0; i<=n; ++i) {
		u64 y=tot*ifac[i]%P*ifac[n-i]%P;
		if((n-i)&1) y=dif(0, y);
		for(int j=0; j<=n-i; ++j) {
			ans=(ans+y*s[n-i][j])%P;
			y=y*x%P;
		}
		inc(x, x);
		tot=(u64)tot*tot%P;
	}
	ans=ans*fac%P;
	printf("%u\n", ans);
	return 0;
}


Measured memory_bytes: 34176
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		while(true){
			int n = stdIn.nextInt();
			if(n==0){
				return;
			}
			int[] a = new int[n];
			for(int i=0;i<n;i++){
				a[i] = stdIn.nextInt();
			}
			Arrays.sort(a);
			for(int i=0;i<n;i++){
				System.out.print(a[i]);
				for(int j=i+1;j<n;j++){
					if(j==n-1&&a[n-2]+1==a[n-1]){
						System.out.print("-"+a[j]);
						i = j;
						break;
					}
					else if(a[j-1]+1!=a[j]){
						if(i!=j-1){
							System.out.print("-"+a[j-1]);
							i = j-1;
						}
						System.out.print(" ");
						break;
					}
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007

using namespace std;

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

int main()
{
    IOS;
    ll n,m;
    cin>>n>>m;
    string s;
    cin>>s;
    int dis[n+1],mleft[n+1];
    memset(dis,-1,sizeof dis);
    memset(mleft,-1,sizeof mleft);
    mleft[0]=n;
    dis[n]=0;
    int left=n,next=n-1,timer=0;
    while(true)
    {
        timer++;
        int nleft=left;
        while(next>=left-m && next>=0)
        {
            if(s[next]=='0')
            {
                dis[next]=timer;
                nleft=next;
            }
            --next;
        }
        if(nleft==left)
        {
            cout<<-1<<endl;
            return 0;
        }
        left=nleft;
        mleft[timer]=left;
        if(next<0) break;
    }
    vector<int> ans;
    timer=dis[0];
    int now=0;
    while(timer)
    {
        timer--;
        ans.pb(mleft[timer]-now);
        now=mleft[timer];
    }
    for(auto i:ans) cout<<i<<" ";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1864
#include <stdio.h>

int main(void)
{
	int N;
	scanf("%d",&N);
	
	int H[N],i;
	for(i=0;i<N;i++){
		scanf("%d",&H[i]);
	}
	int ans = 0;
	int w = 0;
	for(i = 0; i< N;i++)
	{
		w = 0;
		while(H[i]>=H[i+1] && i+1 < N){
			w++;
			i++;
		}
		//printf("w = %d, i = %d, H[i] = %d,H[i+1] = %d\n",w);
		if(ans < w) ans = w;
	}
	printf("%d",ans);
	return 0;
}





Measured memory_bytes: 512
import java.util.*;

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

        long N = Long.parseLong(scan.next());
        long K = Long.parseLong(scan.next());
        long temp = 0;

        System.out.println(Math.min(N%K, K-N%K));
        scan.close();
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define REPI(i,a,b) for(int (i)=int(a);i<int(b);++i)
#define INF 10000000;
int main(void){
  using namespace std;
  int L;cin >> L;
  int R;cin >> R;
  const int DIVIDER = 2019;
  auto Q_L = L/DIVIDER;
  auto Q_R = R/DIVIDER;
  if(Q_L<Q_R){
    cout << 0;
  }
  else{
    auto min = INF;
    REPI(i,L,R+1){
      REPI(j,i+1,R+1){
        auto M_i = i % DIVIDER;
        auto M_j = j % DIVIDER;
        auto M_ij = (M_i*M_j)%DIVIDER;
        if(min>M_ij) min = M_ij;
      }
    }
    cout << min;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=2e5+5;
const int mod=1e9+7;

ll cnt[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;
    cin>>n>>k;
    for(int i=1;i<maxn;i++)
    {
        cnt[i]=cnt[i-1]+i;
        cnt[i]%=mod;
    }
    ll ans=0;
    for(int i=k;i<=n+1;i++)
    {
        ans=ans+1ll*i*n%mod-cnt[i-1]*2+1;
        ans=(ans+mod)%mod;
    }
    cout<<ans<<'\n';

}


Measured memory_bytes: 5204
N, K = map(int, input().split())
a = list(map(int, input().split()))

min_time = 10 ** 12
for i in range(N):
    if i + K > N:
        break
    if a[i] > 0:
        min_time = min(min_time, abs(a[i + K - 1]))
        break
    
    if a[i + K - 1] < 0:
        if (i + K < N and a[i + K] > 0) or i + K == N:
            min_time = min(min_time, abs(a[i]))
        continue
        
    min_time = min(min_time, 2 * abs(a[i]) + abs(a[i + K - 1]), abs(a[i]) + 2 * abs(a[i + K - 1]))

print(min_time)

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

typedef long long ll;

ll n;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    ll cnt = n / 11 * 2;
    ll r = n % 11;
    if (r != 0) {
        if (r <= 6)
            ++cnt;
        else
            cnt += 2;
    }
    cout << cnt << endl;

    return 0;
}



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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }

int n, m;
int a[305][305];
int pos[305];
bool used[305];
void solve() {
    cin >> n >> m;

    rep(i, n) rep(j, m) { cin >> a[i][j]; --a[i][j]; }

    int ans = iinf;
    int now = 0;
    rep(_, m) {
        vector<int> res(m, 0);
        rep(i, n) ++res[a[i][pos[i]]];
        int tmp = 0;
        int update = 0;
        rep(i, m) if (tmp < res[i]) { update = i; tmp = res[i]; }
        mins(ans, tmp);

        used[update] = true;
        rep(i, n) while (used[a[i][pos[i]]]) ++pos[i];
    }

    cout << ans << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    solve();

    cout << flush;

    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
void verificar(int a,int b,int c,int &n){
    if((b<a&&b>c||b<c&&b>a))
        n++;
}
int main(){
    int n;
    int sum=0;
    
    cin >>n;
    int* arr=new int[n];
    for(int i=0;i<n;++i){
        cin>>arr[i];
    }
    for(int i=1;i<n-1;++i){
        verificar(arr[i-1],arr[i],arr[i+1],sum);
    }
    cout <<sum;

    return 0;
}

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

int main() {
  string X, Y, ans;
  cin >> X >> Y;
  
  if (X > Y)
    cout << ">" << endl;
  else if (X < Y)
    cout << "<" << endl;
  else
    cout << "=" << endl;
}
  
  

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int x;
int main(){
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	in(x);
	if(x%10==3){printf("bon\n");}
	else if(x%10==0||x%10==1||x%10==6||x%10==8){printf("pon\n");}
	else printf("hon\n");
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define mod 2019

using namespace std;

int P = 1, N, ans;
string s;
unordered_map < int , int > M;

int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> s;
  M[0] = 1;
  for (int i = s.size() - 1; i >= 0; --i) {
    N = (N + P * (s[i] - '0')) % mod;
    P = (P * 10) % mod;
    ans += M[N];
    M[N] ++;
  }
  cout << ans;
}


Measured memory_bytes: 3688
#include<iostream>
#include<map>
#include<queue>
using namespace std;
typedef pair<int,int> P;
char F[51][51];
int C[51][51];
int x[4]={1,0,-1,0};
int y[4]={0,1,0,-1};
int white=0;
queue<P> Q;

void bfs(int h,int w){
  C[1][1]=1;
  Q.push(P{1,1});
  while(!Q.empty()){
    P p=Q.front(); Q.pop();
    if(p.first==h&&p.second==w) break;
    for(int i=0;i<4;i++){
      int nx=p.first+x[i];
      int ny=p.second+y[i];
      if(nx>0&&nx<=w&&ny>0&&ny<=h&&F[ny][nx]=='.'){
        F[ny][nx]='#';
        C[ny][nx]=C[p.second][p.first]+1;
        Q.push(P{nx,ny});
      }
    }
  }
}
int main(){
  int h,w;
  cin>>h>>w;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin>>F[i][j];
      if(F[i][j]=='.') white++;
      C[i][j]=0;
    }
  }

  bfs(h,w);
  if(C[h][w]==0) cout<<-1<<"\n";
  else cout<<white-C[h][w]<<"\n";

}


Measured memory_bytes: 256
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def largestRectangInHistgram(heights):
    stack = [-1]
    maxArea = 0

    for i in range(len(heights)):
        # we are saving indexes in stack that is why we comparing last element in stack
        # with current height to check if last element in stack not bigger then
        # current element
        while stack[-1] != -1 and heights[stack[-1]] > heights[i]:
            lastElementIndex = stack.pop()
            maxArea = max(maxArea, heights[lastElementIndex] * (i - stack[-1] - 1))
        stack.append(i)

    # we went through all elements of heights array
    # let's check if we have something left in stack
    while stack[-1] != -1:
        lastElementIndex = stack.pop()
        maxArea = max(maxArea, heights[lastElementIndex] * (len(heights) - stack[-1] - 1))

    return maxArea


def main():
    n, v = ns()
    a = na()
    b = na()
    c = na()
    d = na()

    pair1 = []
    pair2 = []
    ans = 0

    for ai in a:
        for bi in b:
            pair1.append(ai + bi)

    for ci in c:
        for di in d:
            pair2.append(ci + di)

    pair1.sort()
    pair2.sort()
    p2cnt= collections.Counter(pair2)

    for p in pair1:
        tmp = v - p
        if tmp in p2cnt.keys():
            ans += p2cnt[tmp]

    print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 164696
import java.util.Scanner;

/**
 * Maximal Value
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int[] B = new int[N - 1];
            for (int i = 0; i < N - 1; i++) {
                B[i] = sc.nextInt();
            }

            int S = 0;
            S += B[0];
            for (int i = 0; i < N - 2; i++) {
                S += Math.min(B[i], B[i + 1]);
            }
            S += B[N - 2];

            System.out.println(S);
        }
    }

}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
 
int main()
{
	ll n,m;
    cin>>n>>m;
    ll sum = 0;
    for(ll i = 0; i < m; i++)
    {
    	ll  k;
        cin>>k;
        sum += k;
    }
    if(sum>n)
    	cout<<-1<<endl;
    else
    	cout<<n-sum<<endl;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <string.h>

#define INF 999999999

char connected[128][128];
int mofu[256][256];

int main(void) {
	int n, m;
	while (scanf("%d%d", &n, &m) == 2 && (n | m) != 0) {
		int i, j, k;
		memset(connected, 0, sizeof(connected));
		for (i = 1; i <= n * 2; i++) {
			for (j = 1; j <= n * 2; j++) {
				mofu[i][j] = INF;
			}
			mofu[i][i] = 0;
			mofu[i][i + n] = 0;
		}
		/* nizyuuhenn ya ruupu ga nai towa ittenai koto ni chuui */
		for (i = 0; i < m; i++) {
			int a, b, c;
			if (scanf("%d%d%d", &a, &b, &c) != 3) return 1;
			if (mofu[a][b] > c) mofu[a][b] = c;
			if (mofu[b][a] > c) mofu[b][a] = c;
			if (mofu[a + n][b + n] > c) mofu[a + n][b + n] = c;
			if (mofu[b + n][a + n] > c) mofu[b + n][a + n] = c;
			connected[a][b] = connected[b][a] = 1;
		}
		for (i = 1; i <= n; i++) {
			for (j = 1; j <= n; j++) {
				if (connected[i][j]) {
					for (k = 1; k <= n; k++) {
						if (connected[j][k]) mofu[i][k + n] = 0;
					}
				}
			}
		}
		for (k = 1; k <= n * 2; k++) {
			for (i = 1; i <= n * 2; i++) {
				for (j = 1; j <= n * 2; j++) {
					if (mofu[i][j] > mofu[i][k] + mofu[k][j]) {
						mofu[i][j] = mofu[i][k] + mofu[k][j];
					}
				}
			}
		}
		printf("%d\n", mofu[1][n + n]);
	}
	return 0;
}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
 
#define rin(i,a,b) for(int i=(a);i<=(b);++i)
#define irin(i,a,b) for(int i=(a);i>=(b);--i)
#define trav(i,a) for(int i=head[a];i;i=e[i].nxt)
#define Size(a) (int)a.size()
#define pb push_back
#define mkpr std::make_pair
#define fi first
#define se second
#define lowbit(a) ((a)&(-(a)))
typedef long long LL;
 
using std::cerr;
using std::endl;
 
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
 
const int MAXN=200005;
 
int n,a,b,c,d;
char s[MAXN];
 
int main(){
	n=read(),a=read(),b=read(),c=read(),d=read();
	scanf("%s",s+1);
	if(c<d){
		rin(i,b+1,d-1){
			if(s[i-1]=='#'&&s[i]=='#'){
				printf("No\n");
				return 0;
			}
		}
		rin(i,a+1,c-1){
			if(s[i-1]=='#'&&s[i]=='#'){
				printf("No\n");
				return 0;
			}
		}
		printf("Yes\n");
		return 0;
	}
	else{
		bool flag=false;
		rin(i,b,d){
			if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.'){
				flag=true;
				s[i]='#';
			}
		}
		if(!flag){
			printf("No\n");
			return 0;
		}
		rin(i,a+1,c-1){
			if(s[i-1]=='#'&&s[i]=='#'){
				printf("No\n");
				return 0;
			}
		}
		printf("Yes\n");
		return 0;
	}
}

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

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;

const ll INF = 2e18;
const int MOD = 998244353;
const int MAXN = 2e5 + 5;

struct S {
	int a, b;
};

int N, tot, en;
vector<S> V, T;

struct cmp1 {
	bool operator() (const S &x, const S &y) {
		return x.b < y.b;
	}
};

struct cmp2 {
	bool operator() (const S &x, const S &y) {
		return x.a > y.a;
	}
};

void wrong(int x) {
	cout << "No";
	exit(0);
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	for(int i=1; i<=N; i++) {
		string s; cin >> s;
		vector<char> v;
		for(int j=0; j<s.size(); j++) {
			if(v.empty()) v.push_back(s[j]);
			else {
				if(s[j] == '(') v.push_back(s[j]);
				else {
					if(v.back() == ')') v.push_back(s[j]);
					else v.pop_back();
				}
			}
		}
		int a = 0, b = 0;
		int j;
		for(j=0; j<v.size(); j++) {
			if(v[j] == '(') break;
			else b++;
		}
		for(; j<v.size(); j++) a++;

		if(b == 0) tot += a;
		else if(a == 0) en -= b;
		else {
			if(a >= b) V.push_back({a, b});
			else T.push_back({a, b});
		}
	}

	sort(all(V), cmp1());
	sort(all(T), cmp2());

	for(int i=0; i<V.size(); i++) {
		if(tot < V[i].b) wrong(1);
		tot += -V[i].b + V[i].a;
	}

	for(int i=0; i<T.size(); i++) {
		if(tot < T[i].b) wrong(2);
		tot += -T[i].b + T[i].a;
	}

	tot += en;
	if(tot != 0) wrong(3);

	cout << "Yes";
}

Measured memory_bytes: 5332
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include <sstream>
#include <iomanip>


using namespace std;
typedef long long ll;
const int INF=1000000000;
const int MOD=1000000007;

int main()
{
 ll t1, t2, a1, a2, b1, b2;
 cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
 if(a1<b1){
   ll c1=b1;
   ll c2=b2;
   b1=a1;
   b2=a2;
   a1=c1;
   a2=c2;
 }
 ll diff=(t1*a1+t2*a2)-(t1*b1+t2*b2);
 if(diff>0){
   cout << 0;
 }else if(diff==0){
   cout << "infinity";
 }else{
   ll dis=(a1-b1)*t1;
   ll a=dis/(-1*diff);
   ll b=dis%(-1*diff);
   if(a==0) cout<<1;
   else{
     ll ans=0;
     ans=1+a*2;
     if(b==0) ans=ans-1; 
     cout << ans << 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 N = sc.nextInt();
		int K = sc.nextInt();
		String[] D = new String[K];
		
		for(int i = 0; i < K; i++) {
			D[i] = sc.next();
		}
		
		for(int i = N; i < 100000; i++) {
			String x = String.valueOf(i);
			for(int j = 0; j < K; j++) {
				if(x.indexOf(D[j]) >= 0) {
					break;
				}
				if(j == K - 1 && x.indexOf(D[j]) == -1) {
					System.out.println(x);
					return;
				}
			}
		}
		
		
	}
}


Measured memory_bytes: 24404
#include<stdio.h>
#define H 250

int main(){
  int x,a,b,c,i,A[H+1];

  scanf("%d",&x);

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


  for(i=1;i<=x;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i==1) {
      if(x==2) printf("left key = %d, ",A[2*i]);
      else printf("left key = %d, right key = %d, ",A[2*i],A[2*i+1]);
    }
    else
      {
	printf("parent key = %d, ",A[i/2]);
	if(x>=2*i) printf("left key = %d, ",A[2*i]);
	if(x>=2*i+1) printf("right key = %d, ",A[2*i+1]);
	
			    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 600
import java.util.*;

class Main {
	static final int INF = Integer.MAX_VALUE/2;
	public static final Comparator<Node> COMPARATOR = new Comp();
	
	private static class Comp implements Comparator<Node>{
		public int compare(Node x,Node y){
			if(x.d>y.d){
			return 1;
			}
			else if(x.d<y.d){
			return -1;
			}
			return 0;
		}
	}
	
	static class Node{
		int id;
		int d;
		Node(int id,int d){
			this.id = id;
			this.d = d;
		}
	}
	
	
	static class Edge{
		int to;
		int cost;
		Edge(int to,int cost){
			this.to = to;
			this.cost = cost;
		}
	}
	
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int V = stdIn.nextInt();
		int E = stdIn.nextInt();
		int r = stdIn.nextInt();
		
		ArrayList<ArrayList<Edge>> graph = new ArrayList<ArrayList<Edge>>(); 
		for(int i=0;i<V;i++){
			graph.add(new ArrayList<Edge>());
		}
		
		for(int i=0;i<E;i++){
			int s = stdIn.nextInt();
			int t = stdIn.nextInt();
			int d = stdIn.nextInt();
			Edge edge = new Edge(t,d);
			ArrayList<Edge> list = graph.get(s);
			list.add(edge);
		}
		
		PriorityQueue<Node> queue = new PriorityQueue<Node>(10,COMPARATOR);
		int[] d = new int[V];
		Arrays.fill(d,INF);
		d[r] = 0;
		Node node = new Node(r,0); 
		queue.add(node);
		
		while(!queue.isEmpty()){
			Node x = queue.poll();
			if(d[x.id]<x.d)
				continue;
			ArrayList<Edge> list = graph.get(x.id);
			for(int i=0;i<list.size();i++){
				Edge y = list.get(i);
				if(d[x.id]+y.cost<d[y.to]){
					d[y.to] = d[x.id] + y.cost;
					Node node_ = new Node(y.to,d[y.to]);
					queue.add(node_);
				}
			}
		}
		for(int i=0;i<V;i++){
			if(d[i]==INF){
				System.out.println("INF");
			}
			else{
				System.out.println(d[i]);
			}
		}
	}
}

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

int main() {
  
   string a;
   cin >> a;
   
    int b = a.find("A");
  
    int c = a.rfind("Z");
  
     int d = c - b + 1;
  
 
  cout << d << endl;
  
   
   return 0;
}

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

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

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

const int mod = 998244353;
const ll inf = 3e18 + 5;

int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }  

int main(){

    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll lcm = (c*d)/__gcd(c,d);
    ll a2 = a;
    ll cnt1 = b/c - a/c;
    if(a%c==0) cnt1++;
    ll cnt2 = b/d - a/d;
    if(a%d==0) cnt2++;
    ll cnt3 = b/lcm - a/lcm;
    if(a%lcm==0) cnt3++;
    ll sol = cnt1+cnt2-cnt3;
    cout << b - a + 1 - sol;
}

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

int main() {
  
  long long N,K,sum=0;
  cin >> N >> K;
  vector<long long> H(N);
  for(long long i=0;i<N;i++){
    cin >> H[i];
  }

  sort(H.begin(),H.end());
  reverse(H.begin(),H.end());

  for(long long i=K;i<N;i++){
    sum+=H[i];
  }

  cout << sum << endl;
}


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

int main() {
  int n, k, a;
  cin >> n >> k;
  a = 1;
  for ( int i = 0; i < n; i++ ){
    if ( a*2 > a+k ){
      a += k;
    }
    else {
      a *= 2;
    }
  }
  cout << a << endl;
}


Measured memory_bytes: 256
s = input()
a = int(s[:2])
b = int(s[2:])
if 1 <= a <= 12 and 1<= b <= 12:
    print('AMBIGUOUS')
elif 1 <= a <= 12:
    print('MMYY')
elif 1 <= b <= 12:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#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 ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int n,m;cin>>n>>m;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  sort(a.begin(),a.end());
  int num=0;
  int sum=0;
  rep(i,n)sum+=a[i];
  rep(i,n){
    if(a[i]*4*m>=sum){
      num++;
    }
  }
  	if(num>=m){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val n    = inputs(0).toInt
  val ta   = inputs(1).split(" ").map(_.toInt)
  val t    = ta(0)
  val a    = ta(1)
  val hSeq = inputs(2).split(" ").map(_.toInt)

  println(solve(n, t, a, hSeq))

  def solve(n: Int, t: Int, a: Int, hSeq: Seq[Int]): Int = {
    val c = 0.006D
    val absSeq = hSeq.map { i =>
      val averageC = t - (i * c)
      Math.abs(a - averageC)
    }

    absSeq.indexOf(absSeq.min) + 1
  }
}

Measured memory_bytes: 55204
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>
#include <cctype>
#include <climits>
#include <list>
#include <queue>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;


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

  ll K,A,B; cin>>K>>A>>B;
  ll ans;
  if (B -A <= 2 || K <= A - 1) {
    ans = K + 1;
  } else {
    ll turn = K - (A - 1);
    ans = A + (turn / 2) * (B - A) + (turn % 2);
  }

  cout << ans << endl;
}


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

int kock(int n,double p1x,double p1y,double p2x,double p2y)
{
	double sx,sy,tx,ty,ux,uy;
	double cos60 = 0.5, sin60 = sqrt(3) / 2;

	if (n == 0) {
		return 0;
	}
	sx = (2 * p1x + p2x) / 3;
	sy = (2 * p1y + p2y) / 3;
	tx = (p1x + 2 * p2x) / 3;
	ty = (p1y + 2 * p2y) / 3;
	ux = (tx - sx) * cos60 - (ty - sy) * sin60 + sx;
	uy = (tx - sx) * sin60 + (ty - sy) * cos60 + sy;

	kock(n - 1,p1x,p1y,sx,sy);
	printf("%f %f\n",sx,sy);
	kock(n - 1,sx,sy,ux,uy);
	printf("%f %f\n",ux,uy);
	kock(n - 1,ux,uy,tx,ty);
	printf("%f %f\n",tx,ty);
	kock(n - 1,tx,ty,p2x,p2y);
}

int main()
{
	int n;
	double p1x = 0,p1y = 0,p2x = 100,p2y = 0;
	scanf("%d",&n);
	printf("%f %f\n",p1x,p1y);
	kock(n,p1x,p1y,p2x,p2y);
	printf("%f %f\n",p2x,p2y);

	return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <vector>
#include <map>

using namespace std;

#define int long long

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, k, res = 0;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<int> pref(n + 1);
    for (int i = 0; i < n; i++)
        pref[i + 1] = (pref[i] + (a[i] - 1)) % k;
    map<int, int> p;
    for (int i = 0; i <= n; i++)
    {
        if (i - k >= 0)
            p[pref[i - k]]--;
        res += p[pref[i]];
        p[pref[i]]++;
    }
    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 15872
n, c = [int(i) for i in input().split()]
D = [[int(i) for i in input().split()] for j in range(c)]
C = [[int(i) for i in input().split()] for j in range(n)]

X = [[0]*c for i in range(3)]

for i in range(n):
    for j in range(n):
        X[(i+j+2)%3][C[i][j]-1] += 1

cost = [[0]*c for i in range(3)]

for i in range(c):
    for j in range(c):
        cost[0][j] += X[0][i] * D[i][j]
        cost[1][j] += X[1][i] * D[i][j]
        cost[2][j] += X[2][i] * D[i][j]

ans = []

for i in range(c):
    for j in range(c):
        for k in range(c):
            if i != j and j != k and k != i:
                ans.append(cost[0][i] + cost[1][j] + cost[2][k])

print(min(ans))

Measured memory_bytes: 6388
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    priority_queue<int> pq;
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        int c;
        cin>>c;
        pq.push(c);
    }
    for(int i=0;i<m;i++)
    {
        int c=pq.top();
        pq.pop();
        pq.push(c/2);
    }
    ll sum=0;
    while(!pq.empty())
    {
        int c=pq.top();
        pq.pop();
        sum+=c;
    }
    cout<<sum;
}


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


typedef long long ll;

int main(){
    ll a,b,x;
    cin >> a >> b >> x;
    if(b==0)
        cout << 1 << endl;
    else if(a==0)
        cout << b/x+1 << endl;
    else
        cout << b/x-(a-1)/x << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int a[100];
  cin >> n;
  for(int i=0;i<n;i++) cin >> a[i];
  int mi = 1<<30;
  
  for(int i=-100;i<=100;i++){
    int sum = 0;
    for(int j=0;j<n;j++){
      sum += abs(a[j]-i)*abs(a[j]-i);
    }
    mi = min(mi,sum);
  }
  cout << mi << endl;
}
  


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

ll a,b,c;

int main(){
	cin.sync_with_stdio(false);
  cin>>a>>b>>c;
  int cnt=0;
  while(a%2==0&&b%2==0&&c%2==0){
    ll na=b/2+c/2;
    ll nb=a/2+c/2;
    ll nc=a/2+b/2;
    a=na; b=nb; c=nc;
    cnt++;
    if(a==b&&b==c){
      cnt=INF;
      break;
    }
  }
  if(cnt==INF)cout<<-1<<endl;
  else cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 256
n, y = map(int, raw_input().split())

for i in range(0, n + 1): 
    if(i * 10000 > y): 
        break
    for j in range(0, n - i + 1): 
        if(i * 10000 + j * 5000 > y): 
            break
        if ((i*10 + j*5 + n - i - j)*1000 == y): 
            print i, j, n - i - j 
            exit()
print -1, -1, -1

Measured memory_bytes: 2692
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define assign(x,val) memset(x,val,sizeof(x))
#define motherfucker  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define for0(i,n) for(ll i=0;i<n;++i)
#define for1(i,n) for(ll i=1;i<=n;++i)
#define ford(i,n) for(ll i=n;i>=1;--i)
#define forg(i,a,b) for(ll i=a;i<b;++i)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpl;
long long mod = 1000000007;
const long double PI = (long double)(3.1415926535897932384626433832795);
 
 
void solve(){
	int n;cin>>n;
	string s = "";
	for1(i,n) s+= i + '0';
	string p = "", q = "";
	for0(i,n){
		char a;cin>>a;
		p+=a;
	}
	for0(i,n){
		char b;cin>>b;
		q+=b;
	}
	int a = 0, b = 0;
	int i = 0;
	while(next_permutation(all(s))){
		++i;
		if(s==p)  a = i;
		if(s==q) b = i;
	}
	cout<<abs(a - b)<<endl;
}
 
int main(){
	
	motherfucker
	ll t = 1;
	//cin>>t;
	for0(i, t){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,f,t) for(int i=f;i<t;i++)
#define P(r) do{cout<<#r": ";for(const auto &i:r){cout<<i<<" ";}cout<<endl;}while(0)
int main()
{
    string s; cin >> s;
    cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
ll mpow2(ll a)
{
  if(a == 0) return 1;
  return (2*mpow2(a-1))%mod;
}
ll binpow(ll n,ll pow)
{
	ll res = 1ll;
	while(pow)
	{
		if(pow&1)	res = (res*n)%mod;
		pow/=2;
		n = (n*n)%mod;
	}
	return  res;
}
int main()
{
	int i,n,zero=0;
	scanf("%d",&n);
	map<pair<ll,ll>,pair<int,int>> mp;
	for(i=0;i<n;++i)
	{
    	ll a,b;
    	scanf("%lld %lld",&a,&b);
    	if(a==0&&b==0)		zero ++;
    	else
    	{
		    ll g = __gcd(a,b);
		    a /= g;
		    b /= g;
		    bool rev = 0;
		    if(b < 0)
			{
		    	a = -a;
		    	b = -b;
		    }
		    if(a <= 0)			rev = 1;
		    if(rev == 0) 		mp[{a,b}].first++;
		    if(rev == 1) 		mp[{b,-a}].second++;
	  	}
	}
  	ll ans = 1;
  	for(auto p : mp)
	{
	    ll s = p.second.first;
	    ll t = p.second.second;
	    ll tmp = (binpow(2,s)+binpow(2,t)-1+mod)%mod;
	    ans = (ans*tmp)%mod;
  	}
  	cout << (ans+zero-1+mod)%mod << endl;
}


Measured memory_bytes: 16132
import sys

input = sys.stdin.readline
N, M = map(int, input().split())

import heapq

ABs = [[] for _ in range(M + 1)]
for i in range(N):
    A, B = map(int, input().split())
    if A <= M:
        ABs[A].append(-B)
heapq.heapify(ABs[0])

As = 0
for i in range(M + 1):
    if i > 0:
        for b in ABs[i]:
            heapq.heappush(ABs[0], b)
    if len(ABs[0]) > 0:
        As -= heapq.heappop(ABs[0])
print(As)

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

int main() {
  int n;
  cin >> n;
  vector<ll> cnt(100001, 0);
  rep(i,n) {
    int a;
    cin >> a;
    cnt[a]++;
  }
  ll tot = 0;
  rep(i,100001) tot += i*cnt[i];

  int q;
  cin >> q;
  rep(i,q) {
    int b, c;
    cin >> b >> c;
    tot -= b*cnt[b];
    tot -= c*cnt[c];
    cnt[c] += cnt[b]; 
    cnt[b] = 0;
    tot += b*cnt[b];
    tot += c*cnt[c];
    cout << tot << endl;
  }
  return 0;
}


Measured memory_bytes: 4048
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
#define int long long
    int n, m; cin >> n >> m;
    
    vector<int> factor;
    for(int i = 1 ; i < (int)sqrt(m)+5 ; i++) {
        if(m%i == 0) {
            factor.push_back(i);
            factor.push_back(m/i);
        }
    }
    sort(factor.begin(), factor.end());
    factor.resize(unique(factor.begin(), factor.end())-factor.begin());
    
    for(int i = factor.size()-1 ; i >= 0 ; i--) {
        if(n*factor[i] <= m) {
            cout << factor[i] << "\n";
            return 0;
        }
    }
    
    return 0;
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);
    vi b(N);


    Rep(i,N-1) Scd(b[i]);
    int ans = b[0]+b[N-2];
    Rep(i,N-2){
        ans += min(b[i],b[i+1]);
    }

    printf ("%d\n", ans );

    return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int p[n],i;
  for(i=0;i<n;i++)
  {
    cin>>p[i];
  }
  sort(p,p+n);
  int a,b;
  b=n/2;
  a=b-1;
  
  if(p[a]<p[b]) cout<<p[b]-p[a];
  else cout<<0;
  return 0;
}

Measured memory_bytes: 640