akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
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(){
  ll n,m; cin >> n >> m;
  map<ll,ll,greater<int>> mp;
  rep(i,n){
    int a; cin >> a;
    mp[a]++;
  }
  rep(i,m){
    int b,c; cin >> b >> c;
    mp[c] += b;
  }
  ll ans = 0;
  for(auto x : mp){
    if(n == 0) break;
    ans += min(n,x.second)*x.first;
    n -= min(n,x.second);
  }
  cout << ans;
  cout << "\n";
  return 0;
}


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

int main(){
 int N,n,m;
  
  cin>>N;
  n=N-((N/100)*100);
  m=n-((n/10)*10);
  if(N/100==7 || n/10==7 ||m==7)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
}



Measured memory_bytes: 3588
w = input()
w = list(w)
length = len(w)
w.sort()

ans = 'No'

if length % 2 == 0:
    for a in range(0, length, 2):
        if w[a] == w[a+1]:
            ans = 'Yes'
        else:
            ans = 'No'
            break

print(ans)


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

#define REPEAT(i, N) for (int i = 0; i < (N); i++)

using namespace std;

int main() {
  int N, X;
  
  cin >> N >> X;
  
  vector<int> L;
  
  REPEAT(i, N) {
    int _in;
    
    cin >> _in;
    
    L.push_back(_in);
  }
  
  int coord = 0;
  int cnt   = 1;
  
  REPEAT(i, N) {
    coord = coord + L[i];
    
    if (coord <= X) {
      cnt++;
    }
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    X = list(map(int,input().split()))
    X.sort()
    min = float("inf")
    s = X[0]
    g = X[N-1]
    for p in range(s,g+1):
        s = 0
        for x in X:
            s += (x-p)**2
        if min >= s:
            min = s
    print(min)

if __name__ == "__main__":
    main()

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

int main(){
    string x,y;
    cin>>x>>y;

    if(x>y){
        cout<<">";
    }else if(x<y){
        cout<<"<";
    }else{
        cout<<"=";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    double R;
    cin >> R;
    cout << setprecision(12) << 2 * R * M_PI;

    return 0;
}


Measured memory_bytes: 3800
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int N,W;
  cin >> N >> W;
  vector<ll> dp(N*1000+1,1000000000100);
  dp[0]=0;
  for(int i=0;i<N;i++){
    int w,v;
    cin >> w >> v;
    for(int i=N*1000;0<=i;i--){
      dp[i]=min(dp[i],dp[max(0,i-v)]+w);
    }
  //for(int i=0;i<150;i++) cout << dp[i] << " "; cout << endl;  
  }


  cout << distance(dp.begin(),upper_bound(dp.begin(),dp.end(),W))-1 << endl;

  return 0;
}


Measured memory_bytes: 1024
t=[int(x) for x in input().split()]
a=t[0]
b=t[1]
c=t[2]
k=t[3]
if k<=a:
    print(k)
else:
    ans=a
    rem=k-a
    if rem<=b:
        print(ans)
    else:
        rem=rem-b
        val=-1*rem
        ans=ans+val
        print(ans)

Measured memory_bytes: 9192
import qualified Data.List as L
type Pairs a = [(a, Int)]

main = do
    n <- readLn :: IO Integer
    print $ solve n

solve n = sum . favs $ n where
    divs = n : (tail . divisors $ n)
    favs n = [d-1 | d <- divs, d > 1, n `mod` (d-1) == n `div` (d-1)]

primes :: Integral a => [a]
primes = 2 : filter ((==1) . length . primeFactors) [3,5..]

primeFactors :: Integral a => a -> [a]
primeFactors n = factor n primes where
    factor m (p:ps)
        | m < 0          = -1 : factor (abs m) (p:ps)
        | p*p > m        = [m]
        | m `mod` p == 0 = p : factor (m `div` p) (p:ps)
        | otherwise      = factor m ps

isPrime :: Integral a => a -> Bool
isPrime 1 = False
isPrime n = case (primeFactors n) of
    (_:_:_)     -> False
    _           -> True

isOddComposit :: Integral a => a -> Bool
isOddComposit n = case (primeFactors n) of
    (2:_:_)     -> False
    (_:_:_)     -> True
    _           -> False

factorize :: Integral a => a -> [a]
factorize 1 = []
factorize n = v : factorize (n `div` v)
    where v = head . primeFactors $ n

primeVectors :: Integral a => a -> Pairs a
primeVectors = count . primeFactors
    where count = map (\xs@(x:_) -> (x, length xs)) . L.group

combExp :: Integral a => a -> [Pairs a]
combExp n = map (zip primes') . combs $ exps
    where
        pvs = primeVectors n
        primes' = fst . unzip $ pvs
        exps   = snd . unzip $ pvs
        combs [] = [[]]
        combs (x:xs) = [a:as| a <- [0..x], as <- combs xs]

divisors :: Integral a => a -> [a]
divisors n = init . L.sort . map pvsToNum . combExp $ n
    where pvsToNum = product . map (uncurry (^))


Measured memory_bytes: 4860
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
ll a[N];
ll n,k;
bool ck(ll x)
{
    ll res=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]%x==0) res+=a[i]/x-1;
        else          res+=a[i]/x;
    }
    if(res>k) return false;
    else      return true;
}

int main()
{
    ll ans=1e9;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
    }
    ll l=1,r=1e9;
    while(l<=r)
    {
        ll mid=(l+r)>>1;
        if(ck(mid))
        {
            r=mid-1;
            ans=min(ans,mid);
        }
        else l=mid+1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5136
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String Ns = String.valueOf(N);
		
		int f = 0;
		
		for(int i = 0; i < Ns.length(); i++) {
			f += N / (int)Math.pow(10, i) % 10;
		}
		if(N % f == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21972
def _gcd(a, b)
  if a > b
    return a if b == 0

    _gcd(b, a % b)
  else
    return b if a == 0

    _gcd(a, b % a)
  end
end

def gcd(numbers)
  ans = numbers.first

  numbers[1..-1].each do |n|
    ans = _gcd(ans, n)
  end

  return ans
end

def _lcm(a, b)
  return a * b / _gcd(a, b)
end

def lcm(numbers)
  ans = numbers.first

  numbers[1..-1].each do |n|
    ans = _lcm(ans, n)
  end

  return ans
end

n = gets.to_i
A = gets.split.map(&:to_i)
lcm = lcm(A)

ans = A.inject(0) do |sum, a|
  sum + (lcm - 1) % a
end

puts ans


Measured memory_bytes: 16124
#include "bits/stdc++.h"
using namespace std;
using i64 = long long;
const i64 MOD = 1e9+7;
const i64 INF = 1e18+7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


signed main(){
    i64 n, a;
    cin >> n >> a;

    i64 ans = INF;
    for(i64 k = 1; k < 62; ++k){
        i64 p = pow(n, 1.0L / k) + 1e-12;
        vector<i64> v(k, p);
        i64 val = accumulate(v.begin(), v.end(), 1LL, [](auto x, auto y){return x * y;});
        for(int j = 0; j < k; ++j){
            if(val >= n)
                break;
            val /= v[j];
            ++v[j];
            val *= v[j];
            if(val >= n)
                break;
        }

        chmin(ans, accumulate(v.begin(), v.end(), 0LL) + (k - 1) * a);
    }
    cout << ans << endl;

}


Measured memory_bytes: 384
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long max1 = 0;
    long max2 = 0;
    long A[] = new long[N];
    for (int i=0; i<N; i++) {
      A[i] = sc.nextLong();
    }
    for (int i=0; i<N; i++) {
      if(max1 <= A[i]){
        max2 = max1;
        max1 = A[i];
      } else if(max2 <= A[i]){
        max2 = A[i];
      }
    }
    for (int i=0; i<N; i++) {
      if(max1 != A[i]){
        System.out.println(max1);
      } else {
        System.out.println(max2);
      }
    }
  }
}

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

public class Main {

	static int n;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];
		for(int i = 0 ; i < n ; i++) {
			a[i] = sc.nextInt();
		}
		for(int i = 0 ; i < n ; i++) {
			b[i] = sc.nextInt();
		}
		for(int i = 0 ; i < n ; i++) {
			c[i] = sc.nextInt();
		}
		long ans = 0;
		Arrays.sort(a);
		Arrays.sort(c);
		for(int i  = 0 ; i < n ; i++) {
			ans += binary_search(a, b[i]) * binary_search2(b[i], c);
		}
		System.out.println(ans);
	}

	public static long binary_search(int[] a, int x) {
		int l = 0;
		int r = n;
		while(r - l >= 1) {
			int i = (l + r) / 2;
			if(x <= a[i]) r = i;
			else l = i + 1;
		}
		return l;
	}

	public static long binary_search2(int x, int[] c) {
		int l = 0;
		int r = n;
		while(r - l >= 1) {
			int i = (l + r) / 2;
			if(x >= c[i]) l = i + 1;
			else r = i;
		}
		return n - l;
	}
}


Measured memory_bytes: 95592
#include<stdio.h>
int sum (int n,int s,int cnt);

int N,S,latte;

int main (void)
{
    int i;
    while(1){
        scanf("%d%d",&N,&S);
        if(N==0&&S==0)break;
        latte = 0;
        printf("%d\n",sum(0,0,0));
        //printf("latte = %d\n",latte);
    }
    return 0;
}
int sum(int n,int s,int cnt)
{
    latte++;
    if(s>S || cnt>N || s+(n+9)*(9-n+1)/2<S) return 0;
    if(n>9){
        if(cnt==N && s==S) return 1;
        else return 0;
    }
    return sum(n+1,s+n,cnt+1)+sum(n+1,s,cnt);
}

Measured memory_bytes: 1028
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>

using namespace std;

int main() {
    int A[3][3]={0};
    int a = 0;

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a;
            A[i][j]=a;
        }
    }
    int ans[3][3]={0};
    int n = 0;
    cin >> n;
    int b[n];
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (A[j][k] == b[i]) {
                    ans[j][k] = 1;
                }
            }
        }
    }
    for (int i = 0; i < 3; i++) {
        if (ans[i][0]+ans[i][1]+ans[i][2] == 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    for (int i = 0; i < 3; i++) {
        if (ans[0][i]+ans[1][i]+ans[2][i] == 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    if (ans[0][0]+ans[1][1]+ans[2][2] == 3 /*&& ans[0][0] != ans[1][1] != ans[2][2]*/) {
        cout << "Yes" <<endl;
        return 0;
    }
    if (ans[0][2]+ans[1][1]+ans[2][0] == 3 /*&& ans[0][0] != ans[1][1] != ans[2][2]*/) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int x;
	cin>>x;
	cout<<10-x/200<<endl;
	return 0;
}

Measured memory_bytes: 3632
//It doesn't matter how slow you go, Unless you don't stop.
#include<iostream>
#include<algorithm>
#include<bitset>
 
#include<cmath>
#include<cstring>
#include<climits>
 
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
 
#include<fstream>
#include<chrono>
using namespace std;
 
typedef long long LL;
typedef pair<LL,LL> p64;
typedef vector<LL> v64;
typedef map<LL,LL> mp64;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(long long i=s;i<=e;i++)
#define brep(i,s,e) for(long long i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
 
void solve()
{
     int n;cin>>n;
     vector<int> a(n);
     for(int i=0;i<n;i++){
         cin>>a[i];
     }
     LL res=0;
     for(int i=1;i<n;i++){
         if(a[i] < a[i-1]){
             int diff = abs(a[i]-a[i-1]);
             res += diff;
             a[i] += diff;
         }
     }
     cout<<res<<endl;
}
 
int main()
{
    DANGER;
    ofstream out("output.txt");
 
    auto start = chrono::high_resolution_clock::now();
    
    LL t = 1;
    // cin>>t;
    rep(test,1,t)
    {
        solve();
    }
    
    auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout << "Time taken by function: " << duration.count() << " milliseconds" << endl;
}


Measured memory_bytes: 4012
#include <bits/stdc++.h>
#define int long long
#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
using namespace std;
const int INF = 1e18;

void solve()
{

    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    double a[n];
    rep(i, n) cin >> a[i];

    priority_queue<double> pq;
    rep(i, n)
        pq.push(a[i]);

    rep(i, m)
    {
        double now = pq.top();
        pq.pop();
        now /= 2;
        pq.push(now);
    }

    int ans = 0;
    while (!pq.empty())
    {
        ans += pq.top();
        pq.pop();
    }

    cout << ans << endl;
}

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


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

int main() {
  int n, m, j=0, r;
  bool c = true;
  cin >> n >> m;
  vector<long long> a(n);
  vector<pair<int, int>> b(m);
  for(int i = 0; i < n; i++) 
    cin >> a.at(i);
  sort(a.begin(), a.end());
  for(int i = 0; i < m; i++) 
    cin >> b.at(i).second >> b.at(i).first;
  sort(b.rbegin(), b.rend());
  for(int i = 0; i < m; i++) {
    r = b.at(i).second;
    while(r){
      if(a.at(j) < b.at(i).first){
        r--;
        a.at(j) = b.at(i).first;
        j++;  
        if(j >= n) goto end;
      }else goto end;
    }
  }
  end:
  long long ans = 0;
   for(int i = 0; i < n; i++){
       ans += a.at(i);
   }
   cout << ans;
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;

    if (u == s)
        cout << a - 1 << " " << b << "\n";
    else
        cout << a << " " << b - 1 << "\n";

    return 0;
}


Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String name=br.readLine();
		int num;
		int compare;

		while(true){

			try{
				StringTokenizer st=new StringTokenizer(name," ");
				compare=Integer.parseInt(st.nextToken())+Integer.parseInt(st.nextToken());
				System.out.println(String.valueOf( compare ).length());
				name=br.readLine();
			}

			catch(Exception e){
				System.exit(0);
			}
		}
	}
}

Measured memory_bytes: 24244
S = input()

a = ''
for i in range(len(S)//2):
    a += '0'
    a += '1'
if len(S)/2 % 1 != 0:
    a += '0'
b = ''
for i in range(len(S)//2):
    b += '1'
    b += '0'
if len(S)/2 % 1 != 0:
    b += '1'

count_a = 0
for i in range(len(S)):
    if S[i] != a[i]:
        count_a += 1

count_b = 0
for i in range(len(S)):
    if S[i] != b[i]:
        count_b += 1

print(min(count_a, count_b))


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

int main() {
  long long n,k,sum=0;
  cin>>n>>k;
  for(long long i=k; i<=n+1; i++){
    sum+=(2*n-i+1)*i/2-i*(i-1)/2+1;
    sum%=1000000007;
  }
  cout<<sum%1000000007<<endl;
  
      
      
  
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef pair<ll,ll> pll;
typedef vector<string> vs;
typedef vector<pll> vpl;
typedef vector<int> vi;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0 ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
 
}

const int MAXN = 200100;

int32_t main(){
  fastio;
  int n;
  cin>>n;
  int s=0;
  for(int i=1;i<=n;i++){
    if(i%3!=0 && i%5!=0)s+=i;
  }
  cout<<s<<endl;
  // Math -> gcd it all // chack MAXN // check ll
  //did you check N=1? Did you mix up N,M?
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)     for(long long int i=a; i<n; i++)
#define loop(i,a,n)     for(long long int i=a; i>=n; i--) 

int main()
{
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	
	int a;
	cin>>a;
	if(a>=400 and a<=599)
		cout<<8;
	else if(a>=600 and a<=799)
		cout<<7;
	else if(a>=800 and a<=999)
		cout<<6;
	else if(a>=1000 and a<=1199)
		cout<<5;
	else if(a>=1200 and a<=1399)
		cout<<4;
	else if(a>=1400 and a<=1599)
		cout<<3;
	else if(a>=1600 and a<=1799)
		cout<<2;
	else
		cout<<1;
			
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

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

    int n, m1, m2;
    cin >> n >> m1 >> m2;
    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; i++)
        cin >> a[i] >> b[i] >> c[i];
    int dp[500][500], nxt[500][500];
    for (int i = 0; i < 500; i++)
    {
        for (int j = 0; j < 500; j++)
        {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 500; j++)
        {
            for (int k = 0; k < 500; k++)
            {
                nxt[j][k] = INF;
            }
        }
        for (int j = 0; j < 500; j++)
        {
            for (int k = 0; k < 500; k++)
            {
                if (j - a[i] < 0 || k - b[i] < 0)
                    nxt[j][k] = dp[j][k];
                else
                    nxt[j][k] = min(dp[j][k], dp[j - a[i]][k - b[i]] + c[i]);
            }
        }
        for (int j = 0; j < 500; j++)
        {
            for (int k = 0; k < 500; k++)
            {
                dp[j][k] = nxt[j][k];
            }
        }
    }
    int ans = INF;
    for (int i = 1; m1 * i < 500 && m2 * i < 500; i++)
        ans = min(ans, dp[m1 * i][m2 * i]);
    if (ans == INF)
        ans = -1;
    cout << ans << endl;
}

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

	int n;
	vector<int> val;
	while(cin>>n) val.push_back(n);
	sort(val.begin(),val.end());
	int ans=0;
	for(int i=1;i<val.size();i++) ans+=val[i]-val[i-1];
	cout<<ans<<endl;
}

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

#define pb push_back
#define ff first
#define ss second

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

const int MAXN = 2 * 100 * 1000 + 17;

int n, k;
double p[MAXN], mx, cur;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		cin >> p[i], p[i] = (p[i] + 1) / 2;
	for (int i = 1; i <= k; i++)
		cur += p[i];
	mx = max(mx, cur);
	for (int i = k + 1; i <= n; i++)
		cur -= p[i - k], cur += p[i], mx = max(mx, cur);
	cout << fixed << setprecision(6) << mx << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> net(n);
    REP(i, m){
        int si, ti;
        cin >> si >> ti;
        si--; ti--;
        net.at(si).push_back(ti);
    }

    vector<double> dp(n, 0);
    for(ll i = n - 2; i >= 0; --i){
        double tmp = 0;
        for(ll j : net.at(i)){
            tmp += dp.at(j);
        }
        dp.at(i) = 1.0 + tmp / net.at(i).size();
    }

    vector<double> prob(n, 0);
    prob.at(0) = 1;
    for(ll i = 0; i < n; ++i){
        for(ll j : net.at(i)){
            prob.at(j) += prob.at(i) / net.at(i).size();
        }
    }

    double ans = dp.at(0);
    for(ll i = 0; i < net.size(); ++i){
        if(net.at(i).size() <= 1){ continue; }
        for(ll j : net.at(i)){
            const double delta = (dp.at(i) - 1.0 - dp.at(j)) / (net.at(i).size() - 1);
            ans = min(ans, dp.at(0) + prob.at(i) * delta);
        }
    }
    printf("%.8f\n", ans);
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <string>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int n; cin >> n;int array[n+1]; for(int i = 1; i<=n; ++i)cin >> array[i];
    map <int, int> mp;
    int index = 1, count_b_pushed = 0;
    for(;;){
        ++count_b_pushed;
        if(array[index] == 2){ cout << count_b_pushed << endl; return 0;}
        if(mp.count(array[index])){ cout << -1 << endl; return 0;}
        else{mp[array[index]] = 1; index = array[index];}
    }
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define 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; }

signed main(){
  int n;
  cin >> n;
  if(n % 10 == 2 || n % 10 == 4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9) cout << "hon" << endl;
  else if(n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) cout << "pon" << endl;
  else cout << "bon" << endl;
}

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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	int year, month, day;
	char c1, c2;
	
	cin >> year >> c1 >> month >> c2 >> day;
	
	if(month <= 4)
		cout << "Heisei";
	else
		cout << "TBD";
	
	return 0;
}

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

using namespace std;

const int N = 80;

int a[N+10][N+10], b[N+10][N+10];
bool f[N+10][N+10][N*N*2+10];

int myabs(int x)
{
	if (x < 0) return -x; else return x;
}

int main()
{
	int res, h, w, i, j, k;
	cin>>h>>w;
	for (i=1; i<=h; i++) for (j=1; j<=w; j++) cin>>a[i][j];
	for (i=1; i<=h; i++) for (j=1; j<=w; j++) cin>>b[i][j];
	f[0][1][N*N] = f[1][0][N*N] = true;
	for (i=1; i<=h; i++)
		for (j=1; j<=w; j++)
			for (k=0; k<2*N*N; k++)
				f[i][j][k] = k + a[i][j] - b[i][j] >= 0 && k + a[i][j] - b[i][j] <= 2 * N * N && (f[i-1][j][k+a[i][j]-b[i][j]] || f[i][j-1][k+a[i][j]-b[i][j]]) || k - a[i][j] + b[i][j] >= 0 && k - a[i][j] + b[i][j] <= 2 * N * N && (f[i-1][j][k-a[i][j]+b[i][j]] || f[i][j-1][k-a[i][j]+b[i][j]]);
	res = N * N + 1;			
	for (i=0; i<=2*N*N; i++) if (f[h][w][i]) res = min(res, abs(i - N * N));
	cout<<res<<endl;			
	return 0;
}

Measured memory_bytes: 91392
from bisect import bisect_left, bisect_right
from collections import Counter
N = int(input())
L = list(map(int, input().split()))
L.sort()
m = Counter(L)

ans = 0
for i, x in enumerate(L[:-2]):
    for j, y in enumerate(L[i+1:-1]):
        ans += bisect_left(L, x+y) - (i+j+2)
print(ans)

Measured memory_bytes: 9692
fun main(args: Array<String>) = IO().exec {
    val k = int()
    val x = int()
    println((Math.max(-1000000, x-(k-1))..Math.min(x+(k-1), 1000000)).joinToString(" "))
}

// region template
operator fun Int.iterator() = 0.until(this).iterator()

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = java.io.PrintWriter(System.out)
    fun hasNextByte(): Boolean = if (ptr < buflen) true else {
        ptr = 0
        buflen = System.`in`.read(buffer)
        buflen > 0
    }

    fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }

    fun string(): String {
        if (!hasNext()) throw java.util.NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun long(): Long {
        if (!hasNext()) throw java.util.NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }

    fun double(): Double = string().toDouble()
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}
// endregion

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n; cin >> n;

    ll ans = 0;

    ll before; cin >> before;
    int increase = 0;

    for (ll i = 1; i < n; ++i) {
        ll a; cin >> a;

        if (before < a) {
            if (increase == 0) {
                increase = 1;
            }

            if (increase == 2) {
                ans++;
                increase = 0;
            }

            before = a;
            continue;
        }

        if (before > a) {
            if (increase == 0) {
                increase = 2;
            }

            if (increase == 1) {
                ans++;
                increase = 0;
            }

            before = a;
            continue;
        }
    }

    ans++;

    cout << ans << endl;
}

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

#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;

TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM T> inline istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }
TPL<TNM V, TNM H> void resize(vector<V>& _v, const H _h) { _v.resize(_h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& _v, const H& _h, const T& ... _t) { _v.resize(_h); for (auto& __v : _v) resize(__v, _t ...); }
TPL<TNM V, TNM T> TNM enable_if<!is_class<V>::value>::type fill(vector<V>& _v, const T &_t) { std::fill(ALL(_v), _t); }
TPL<TNM V, TNM T> TNM enable_if<is_class<V>::value>::type fill(vector<V>& _v, const T &_t) { for (auto &_e : _v) fill(_e, _t); }
TPL<TNM T> inline void UNIQUE(vector<T>& _v) { sort(ALL(_v)); _v.erase(unique(ALL(_v)), _v.end()); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

int main(void) {
	const ll K = 1'000'000'007;
	int N, M;
	cin >> N >> M;
	vec<int> A(M);
	for (int i = 0; i < M; ++i) {
		cin >> A[i];
	}
	
	vec<ll> dp(N + 1, 0);
	for (int i = 0; i < M; ++i) {
		dp[A[i]] = -1;
	}

	dp[0] = 0;
	if (dp[1] >= 0) {
		dp[1] = 1;
	}
	if (N == 1) {
		cout << dp[1] << endl;
		return 0;
	}
	if (dp[2] >= 0) {
		if (dp[1] != -1) {
			dp[2] = 2;
		}
		else {
			dp[2] = 1;
		}
	}
	if (N == 2) {
		cout << dp[2] << endl;
		return 0;
	}
	for (int i = 3; i <= N; ++i) {
		if (dp[i] >= 0) {
			if (dp[i - 1] > 0 && dp[i - 2] > 0) {
				dp[i] += ((dp[i - 1]) % K) + ((dp[i - 2]) % K) % K;
			}
			else {
				if (dp[i - 1] > 0) {
					dp[i] += dp[i - 1];
					dp[i] %= K;
				}
				if (dp[i - 2] > 0) {
					dp[i] += dp[i - 2];
					dp[i] %= K;
				}

			}
			
		}
	}

	cout << dp[N] % K << endl;
	return 0;
}

Measured memory_bytes: 1408
n = int(input())
t = [0 for i in range(n)]
x = [0 for i in range(n)]
y = [0 for i in range(n)]
for i in range(n):
    t[i],x[i],y[i] = map(int, input().split(" "))

for i in range(n):
    if i == 0:
        sum = abs(x[i]) + abs(y[i])
        time = t[i]
    else:
        sum = abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
        time = t[i]-t[i-1]
    if sum > time:
        print("No")
        quit()
    if sum%2 != time%2:
        print("No")
        quit()
print("Yes")

Measured memory_bytes: 11828
#include <iostream>
#include <vector>
#include <map>
#include <cmath>

using namespace std;
// template for creating 2d vector
template<typename T>
vector<vector<T>> make_2d_vector(size_t rows, size_t cols, T init)
{ return vector< vector<T> >(rows, vector<T>(cols, init)); }

#define debug(x) cout << #x << "==" << x << endl;

const int inf = 1e+8;

typedef long long ll;


// http://stackoverflow.com/questions/1489830/efficient-way-to-determine-number-of-digits-in-an-integer
int num_digits(int x)
{
    x = abs(x);
    return (x < 10 ? 1 :
        (x < 100 ? 2 :
        (x < 1000 ? 3 :
        (x < 10000 ? 4 :
        (x < 100000 ? 5 :
        (x < 1000000 ? 6 :
        (x < 10000000 ? 7 :
        (x < 100000000 ? 8 :
        (x < 1000000000 ? 9 :
        10)))))))));
}

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

  ll N;
  cin >> N;

  ll lim = sqrt(N);

  int ans = inf;
  for(ll A = 1; A <= lim; A++ ) {
    if( (N % A) == 0 ) {
      int B = N / A;
      int x = max(num_digits(A), num_digits(B));
      if( x < ans ) { ans = x; }
    }
  }

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] a) {
		Scanner input = new Scanner(System.in);
		int loop=input.nextInt();
		int max=0;
		int minInput=0;
		
		
		for(int i=0;i<loop;i++){
			int newNum=input.nextInt();
			
			if(i==0){
				minInput=newNum;
				max=newNum;
			}
			else if(i==1){
				max=newNum-max;
				minInput= newNum<minInput ? newNum : minInput;
			}
			else{
				max=newNum-minInput > max ? newNum-minInput : max;
				minInput= newNum<minInput ? newNum : minInput;
				
			}
			
		}
		
		System.out.println(max);
		
	}

}

Measured memory_bytes: 100648
def main():
    result = sub()
    print(result)


def sub():
    n = int(input())
    heights = [int(x) for x in (input().split())]
    count = 0

    maxHeight = 0
    for index, item in enumerate(heights):
        if item >= maxHeight:
            count = count + 1
            maxHeight = item
    return count


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long   ll;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<ll, ll>    pll;
typedef pair<ull, ull>    pull;
typedef pair<ll, ll>  pii;
typedef pair<ld, ld>  pld;
ll n;
ll a[409];
ll dp[409][409];
ll pre[409];
inline ll get(ll x, ll y){
    return pre[y] - pre[x-1];
}
ll f(ll x, ll y){
    if(dp[x][y] != 1e18)
        return dp[x][y];
    if(x >= y)
        return dp[x][y] = 0;
    for(ll i = x; i < y; ++i){
        ll tmp = f(x, i) + f(i+1, y) + get(x, y) ;
        dp[x][y] = min(dp[x][y], tmp);
    }
    return dp[x][y];
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);

    cin >> n;
    for(ll i = 1; i <= n; ++i)
        cin >> a[i];
    for(ll i = 1; i <= n; ++i)
        pre[i] = pre[i-1] + a[i];
    for(ll i = 1; i <= n; ++i)
        for(ll j = 1; j <= n; ++j)
            dp[i][j] = 1e18;
    cout << f(1, n) << "\n";
}

Measured memory_bytes: 1536
import java.util.Scanner;
 
public class Main {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        StringBuilder s = new StringBuilder();
        s.append(a * b);
        s.append(" ");
        s.append(2*(a + b));
        System.out.println(s);
    }
}

Measured memory_bytes: 17352
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
using ll = long long;
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
int main() {
	string s;
	cin >> s;
	if (s == "SUN")
		cout << 7 << endl;
	else if (s == "MON")
		cout << 6 << endl;
	else if (s == "TUE")
		cout << 5 << endl;
	else if (s == "WED")
		cout << 4 << endl;
	else if (s == "THU")
		cout << 3 << endl;
	else if (s == "FRI")
		cout << 2 << endl;
	else
		cout << 1 << endl;
	return 0;
}

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

using namespace std;


int main(int argc, char** argv) {
    int W, H, x, y, r = 0;
    int right, left, top, bottom = 0;
    bool p = true;
    
    cin >> W >> H >> x >> y >> r;
    
    right = x+r;
    left = x-r;
    top = y+r;
    bottom = y-r;
    
    if (left < 0 || right > W) {
        p = false;
    } 
    
    if (bottom < 0 || top > H) {
        p = false;
    }
    
    if (p) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
n=int(input())
s=input()
c=s.count
a=c("R")*c("G")*c("B")
for i in range(n-2):
    for j in range((n-i+1)//2):
        if s[i]!=s[i+j] and s[i+j]!=s[i+2*j] and s[i+2*j]!=s[i]:
            a-=1
print(a)

Measured memory_bytes: 9172
#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, cnt = 0;
  cin >> n;
  vector<int> v(n);
  rep(i, n){
  	cin >> v.at(i);
  }
  for(int i = 1; i <= n-2; i++){
  	int max_n = max(v[i-1], max(v[i], v[i+1]));
    int min_n = min(v[i-1], min(v[i], v[i+1]));
    if(v[i] != max_n && v[i] != min_n){
    	cnt++;
    }
  }
  cout << cnt << endl;
  return 0; 
}

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

int main() {
  string N;
  int c1, c2, c3, c4;
  
  cin >> N;
  
  c1 = N[0];
  c2 = N[1];
  c3 = N[2];
  c4 = N[3];
  
  if (c1 == c2 && c2 == c3 && c3 == c4) {
    cout << "Yes" << endl;
  } else if (c1 == c2 && c2 == c3) {
    cout << "Yes" << endl;
  } else if (c2 == c3 && c3 == c4) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

using namespace std;

int main(){

    int k;
    string s;

    cin >> k >> s;

    int n=s.size();

    if(n<=k){
        cout << s << endl;
    }
    else{
        string t;
        t=s.substr(0,k);
        cout << t << "..." << endl;
    }

}



Measured memory_bytes: 3640
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

ans = min(a)+min(b)
for i in range(M):
    x,y,c = map(int,input().split())
    ans = min(ans,a[x-1]+b[y-1]-c)
    
print(ans)

Measured memory_bytes: 18736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<17;
const ll INF=1LL<<40;
int bit[MAX+1],N;

//1-indexed

int sum(int i){
    int s=0;
    while(i>0){
        s+=bit[i];
        i-=i&-i;
    }
    return s;
}

//sからtの和=sum(t)-sum(s-1)

void add(int i,int x){
    while(i<=N){
        bit[i]+=x;
        i+=i&-i;
    }
}

struct edge{
    double a;
    double b;
    double c;
};

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    vector<edge> S(N);
    for(int i=0;i<N;i++) cin>>S[i].a>>S[i].b>>S[i].c;
    
    sort(all(S),[](edge a,edge b){
        return -a.a/a.b<-b.a/b.b;
    });
    
    double left=-INF,right=INF,ansx,ansy;
    
    for(int k=0;k<100;k++){
        double mid=(left+right)/2;
        map<double,int> MA;
        vector<double> Y(N);
        for(int i=0;i<N;i++){
            Y[i]=(-S[i].a*mid+S[i].c)/S[i].b;
            MA[Y[i]]++;
            //cout<<Y[i]<<" ";
        }
        int cnt=1;
        for(auto it=MA.begin();it!=MA.end();it++){
            (*it).second=cnt;
            cnt++;
        }
        for(int i=0;i<N;i++) Y[i]=MA[Y[i]];
        
        memset(bit,0,sizeof(bit));
        
        ll res=0;
        
        for(int i=0;i<N;i++){
            res+=sum(N)-sum(Y[i]-1);
            add(Y[i],1);
        }
        
        if(res>=N*(N-1)/2/2+1) left=mid;
        else right=mid;
        
        //cout<<mid<<" "<<res<<endl;
    }
    ansx=left;
    
    for(int i=0;i<N;i++){
        swap(S[i].a,S[i].b);
        S[i].b*=-1;
    }
    
    sort(all(S),[](edge a,edge b){
        return -a.a/a.b<-b.a/b.b;
    });
    
    left=-INF;right=INF;
    
    for(int k=0;k<100;k++){
        double mid=(left+right)/2;
        map<double,int> MA;
        vector<double> Y(N);
        for(int i=0;i<N;i++){
            Y[i]=(-S[i].a*mid+S[i].c)/S[i].b;
            MA[Y[i]]++;
            //cout<<Y[i]<<" ";
        }
        int cnt=1;
        for(auto it=MA.begin();it!=MA.end();it++){
            (*it).second=cnt;
            cnt++;
        }
        for(int i=0;i<N;i++) Y[i]=MA[Y[i]];
        
        memset(bit,0,sizeof(bit));
        
        ll res=0;
        
        for(int i=0;i<N;i++){
            res+=sum(N)-sum(Y[i]-1);
            add(Y[i],1);
        }
        
        if(res>=N*(N-1)/2/2+1) left=mid;
        else right=mid;
        
        //cout<<mid<<" "<<res<<endl;
    }
    ansy=left;
    
    cout<<setprecision(25)<<ansx<<" "<<ansy<<endl;
    
}



Measured memory_bytes: 6596
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;

#define INF 10000000

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n, x, y;
  cin >> n >> x >> y;
  x--, y--;
  vector<vector<int> > a(n);
  for(int i = 0; i < n; i++){
    if(i < n-1)a[i].push_back(i+1);
    if(i > 0) a[i].push_back(i-1);
  }
  a[x].push_back(y);
  a[y].push_back(x);
  vector<vector<int> > used_pair(n, vector<int>(n, INF));
  vector<int> cnt(n, 0);
  for(int i = 0; i < n; i++){
    vector<int> used(n, INF);
    pair<int, int> p = {i, 0};
    queue<pair<int, int>> q;
    q.push(p);
    used[i] = 0;
    while(!q.empty()){
      pair<int, int> now = q.front();
      q.pop();
      for(int j = 0; j < a[now.first].size(); j++){
        if(used[a[now.first][j]] > now.second+1){
          used_pair[i][a[now.first][j]] = min(used_pair[i][a[now.first][j]], now.second+1);
          used_pair[a[now.first][j]][i] = min(used_pair[a[now.first][j]][i], now.second+1);
          used[a[now.first][j]] = now.second+1;
          q.push({a[now.first][j], now.second+1});
          // cout << i << ' ' << a[now.first][j] << ' ' << now.second+1 << endl;
        }
      }
    }
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(used_pair[i][j] != INF) cnt[used_pair[i][j]]++;
    }
  }
  for(int i = 1; i < n; i++){
    cout << cnt[i]/2 << endl;
  }

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 16128
#include <cmath>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <bitset>
#include <set>
const int maxlongint=2147483647;
const int mo=1e9+7;	
const int N=100005;
using namespace std;
int n,m,ans,deep[N],a[N];
int tot,nt[N*2],lt[N*2],to[N*2];
bool bz[N];
void link(int x,int y)
{
	nt[++tot]=lt[x];
	lt[x]=tot;
	to[tot]=y;
}
int dg(int x,int fa)
{
	deep[x]=deep[fa]+1;
	int mx=deep[x];
	for(int i=lt[x];i;i=nt[i]) mx=max(dg(to[i],x),mx);
	if(x==1) return 0;
	if(fa!=1 && mx-deep[x]+1==m) ans++,mx=0;
	return mx;
}
int main()
{
	//freopen("agc004d.in","r",stdin);
	//freopen("agc004d.out","w",stdout);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(i!=1) link(a[i],i);
	}
	if(a[1]!=1) ans++;
	deep[0]=-1;
	dg(1,0);
	printf("%d",ans);
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

    string s,t;
    cin >> s >> t;

    if (t.length()-s.length()==1)
    {
        for (int i=0;i<=s.length()-1;i++)
        {
            if (s[i]!=t[i])
            {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

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

#define mem(a,n) memset(a,n,sizeof(a))
#define rep(i,a,n) for(int i=a;i<n;i++)

typedef long long ll;
const double eps=1e-5;
const int N=1e5+5;
const int INF=0x3f3f3f3f;
const int dir[4][2]= {1,0,-1,0,0,1,0,-1};

int main()
{
    int T;
    int a,b,c,x,y;
    while(cin>>a>>b>>c>>x>>y)
    {
        int minx=min(x,y);
        int maxx=max(x,y);
        ll ans=0;
        if(a+b>c*2)
        {
            ans+=c*minx*2;
            int t;
            if(minx==x) ans+=(y-x)*b;
            else ans+=(x-y)*a;
        }
        else
        {
            ans+=x*a+b*y;
        }
        if(ans>maxx*c*2) ans=maxx*c*2;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.awt.Point;
import java.util.Scanner;

class Main{
	public static void main(String[]$){
		Scanner s=new Scanner(System.in);
		Point p=new Point();
		int n=s.nextInt(),t=0;
		for(int i=0;i<n;++i) {
			int dt=-t+(t=s.nextInt()),d=d(p,p=new Point(s.nextInt(),s.nextInt()));
			if(dt<d||(dt-d)%2==1) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
	static int d(Point f,Point t) {
		return Math.abs(f.x-t.x)+Math.abs(f.y-t.y);
	}
}

Measured memory_bytes: 89156
#include <iostream>
using namespace std;
int main()
{
int k,n;
cin>>k;
cin>>n;
int a[300000];

int maxl=0;
for (int i=0;i<n;i++)
cin>>a[i];

for (int i=0;i<n-1;i++)
{if(maxl<a[i+1]-a[i])maxl=a[i+1]-a[i];}
if(maxl<(k-(a[n-1]-a[0])))maxl=k-(a[n-1]-a[0]);
cout<<k-maxl;
}

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

int main() {
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    double ans1;
    int ans2;

    ans1 = w * h / 2.0;
    if (w / 2.0 == x && h / 2.0 == y) ans2 = 1;
    else ans2 = 0;

    cout << ans1 << " " << ans2 << endl;
    return 0;
}

Measured memory_bytes: 256