akhauriyash/Code-Regression huggingface dataset:
def min(a,b); a < b ? a : b; end
def max(a,b); a > b ? a : b; end

D, G = gets.split.map(&:to_i)
P = (1 .. D).map do |w|
  c,b = gets.split.map(&:to_i)
  [w,c,b]
end

ans = (1 << D).times.inject(1000_000) do |min_solve, complete|
  unused, used = D.times.partition{|i| complete[i].zero? }

  solved_offset = used.inject(0){|s,i| s + P[i][1]}
  next min_solve if solved_offset >= min_solve
  
  point = used.inject(0){|s, i| s + 100 * P[i][0] * P[i][1] + P[i][2] }
  next min(min_solve, solved_offset) if point >= G
  
  rest = unused.reverse_each.inject([0, G - point]) do |s, i|
    solved_count, rest = s
    w,c,b = P[i]
    r = min((rest + 100 * w - 1) / (100 * w), c - 1)
    if rest - 100 * w * r <= 0
      break [solved_count + r, 0]
    else
      [solved_count + r, rest - 100 * w * r]
    end
  end
  
  if rest[1].zero?
    min(min_solve, solved_offset + rest[0]) 
  else
    min_solve
  end
  
end

puts ans



Measured memory_bytes: 2044
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-8;

long long int N, M, K, L, R, H, W;
//int N, M, K, L, R, H, W;


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

	cin >> N;
	for (int i = 1; i <= N; i++) {
		if (i % 3 == 0)continue;
		if (i % 5 == 0)continue;
		M += i;
	}
	cout << M << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>

using namespace std;


int main() {

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

    int c = 1;
    int b1 = b;

    while (b1 != 0) {
        b1 /= 10;
        c *= 10;
    }

    int t = a * c + b;

    bool ok = false;

    for (int i = 1; i < 100100; i++) {
        if (i * i == t) {
            ok = true;
        }
    }

    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;

}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

def solve(K: int):
    from math import gcd
    from itertools import product
    from functools import reduce
    def f():
        for abc in product(range(1, K+1), repeat=3):
            yield reduce(gcd, abc)
    print(sum(f()))


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    int n;
    cin >> n;
    vector<ll> v(n);
    ll sum = 0;
    for (ll &x : v) {
        cin >> x;
        sum += x;
    }
    vector<ll> r = v;
    for (int i = 1; i < n; i++) {
        r[i] += r[i-1];
    }

    ll ans = 1e18;
    for (int i = 0; i < n-1; i ++) {
        ans = min(ans, abs(r[i] - (sum - r[i])));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <math.h>
#include <vector>
#include <iomanip>
#include <limits>
#include <map>
using namespace std;

int main()
{
    int h, w;
    while (cin >> h >> w)
    {
        if (h == 0 && w == 0)
        {
            break;
        }
        for (int i = 0; i < h; i++)
        {
            for (int i = 0; i < w; i++)
            {
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


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

int main() {
    int x, a, b;
    std::cin >> x >> a >> b;

    if (std::abs(x - a) < std::abs(x - b)) {
        std::cout << "A\n";
    } else {
        std::cout << "B\n";
    }

    return 0;
}


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

signed main() {
  int N, M;
  cin >> N >> M;
  
  set<int> tochu;
  vector<pair<int, int>> hune(M);
  int A, B;
  for( int i = 0; i < M; i++ ){
    cin >> A >> B;
    hune.at(i) = make_pair(A, B);
    if( A == 1 ) tochu.insert(B);
  }
  
  for( int i = 0; i < M; i++ ){
    if( hune.at(i).second == N ){
      if( tochu.count(hune.at(i).first) ){
        cout << "POSSIBLE" << endl;
        return 0;
      }
    }
  }
  cout << "IMPOSSIBLE" << endl;
      
}



Measured memory_bytes: 8064
#include "bits/stdc++.h"
using namespace std;


//wierd debugging stuff
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << "\n" ; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
//end of weird debugging stuff
using ll = long long;
using vi = vector<int>;
using ii = pair<int,int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define invec(v) for(auto& x : v)cin>>x;
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
 
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define ar array
// no change 

const ll MOD = 1e9+7;   // it is an prime...

template<typename T,typename L>
T power(T a, L b);				// to find reverse modulo its power(a,MOD-2);
template < typename T ,typename L> 
L coefficient(T n, T k);  // computing nCk

//const int MxN = 1e9+5;
vector<int> ans(10001);
int main() {
	FASTER;
	int n;
	cin >> n;
	for(int i = 1;i<=100;i++){
		FOR(j,1,100){
			FOR(k,1,100){
				int val = i*i + j*j + k*k + i*j + i*k + j*k;
				if(val <= 10000){
					ans[val]++;
				}
			}
		}
	}
	for(int i = 1;i<=n;i++){
		cout << ans[i] << endl;
	}
}


template<typename T,typename L>
T power(T a, L b){
	
	T result = 1;
	while(b){
		if(b&1) result = (result% MOD * a%MOD) % MOD;
	   	a = (a%MOD * a%MOD) % MOD;
   		b/=2;	   
	}
	return result;
}

template < typename T ,typename L> 
L coefficient(T n, T k){  // computing nCk
	k = min(k,(n-k));
	L res = 1;
	for(T i = 0; i< k;i++){
		res *= (n-i);
		res /= (i+1);

	}
	return res;
}


Measured memory_bytes: 3584
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}



int main(){
    int n,k;
    cin >> n >> k;
    vector<int> u,v;
    int m = 0;
    REP(i,n-1){
        u.push_back(i+1);
        v.push_back(n);
        m++;
    }
    int dif = (n-1)*(n-2)/2-k;
    if(dif<0){
        put(-1);
        return 0;
    }
    vector<int> c(n,0);
    REP(i,2){
        c[n-1-i]=1;
    }
    do{
        if(dif--<=0)break;
        int fir=-1,sec;
        REP(i,n){
            if(c[i]){
                if(fir<0){
                    fir = i;
                }else{
                    sec = i;
                }
            }
        }
        u.push_back(fir);
        v.push_back(sec);
        m++;
    }while(next_permutation(all(c)));
    put(m);
    REP(i,m){
        cout << u[i] << " " << v[i] << endl;
    }
    return 0;
}


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


int main(){
  string s,t;
  cin >> s >> t;
  int ns=s.size();
  int nt=t.size();
  int csa[ns+1],cta[nt+1];
  int csb[ns+1],ctb[nt+1];

  csa[0]=cta[0]=csb[0]=ctb[0]=0;
  rep1(i,ns){
    csa[i]=csa[i-1];
    csb[i]=csb[i-1];
    if(s[i-1]=='A') csa[i]++;
    else csb[i]++;
  }

  rep1(i,nt){
    cta[i]=cta[i-1];
    ctb[i]=ctb[i-1];
    if(t[i-1]=='A') cta[i]++;
    else ctb[i]++;
  }
   
  int q;
  cin >> q;
  int a[q],b[q],c[q],d[q];
  rep(i,q){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;b[i]--;
    c[i]--;d[i]--;
  }
  //  rep(i,nt+1) cout << ctb[i] << endl;
  //  cout << "  "<< endl;
  rep(i,q){
    int tmp_cs =  (csa[b[i]+1]-csa[a[i]])%3;
    tmp_cs += (((csb[b[i]+1]-csb[a[i]])%3)*2)%3;
    tmp_cs %=3;
    int tmp_ct =  (cta[d[i]+1]-cta[c[i]])%3;
    tmp_ct += (((ctb[d[i]+1]-ctb[c[i]])%3)*2)%3;
    tmp_ct %=3;
    //    cout << tmp_cs << " " <<tmp_ct << endl;
    if(tmp_cs==tmp_ct)cout << "YES" << endl;
    else cout << "NO" << endl;
  }

  return 0;

}


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

int T;
long long N;
int A, B, C, D;
map<long long, long long> m;
array<int,3> w = {2,3,5};
array<int,6> cost;

long long dfs(long long n) {
  assert(n>=0);
  if(m.count(n)) return m[n];
  long long r = 1LL << 60;
  for(auto i : w) {
    if(n%i) {
      long long minus = n % i;
      long long plus = i - (n % i);
      assert((n-minus) % i == 0);
      assert((n+plus) % i == 0);
      r = min(r, minus * D + cost[i] + dfs((n-minus)/i));
      r = min(r, plus  * D + cost[i] + dfs((n+plus)/i));
    }
    else {
      r = min(r, cost[i] + dfs(n/i));
    }
  }
  if((long double) D * (long double) n < r) r =n*D;
  return m[n] = r;
}

signed main() {
  cin >> T;
  for(int i=0; i<T; i++) {
    cin >> N >> A >> B >> C >> D;
    cost[2] = A;
    cost[3] = B;
    cost[5] = C;
    m.clear();
    m[0] = 0;
    m[1] = D;
    cout << dfs(N) << endl;
  }
}


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


ds = {}
for _ in range(N):
    A = input()
    if A not in ds:
        ds[A] = 0
    else:
        ds[A] += 1

cnt = 0
for d in ds:
    if ds[d] % 2 == 0:
        cnt += 1

print(cnt)


Measured memory_bytes: 17888
#include <stdio.h>
int main() {int RB[105],N,i,j,ans;while (1) {scanf("%d",&N);if (!N) return 0;for (i=0;i<N;scanf("%d",&RB[i++]));for (i=1,ans=0;i<N;i++) for (j=N-1;j>=i;j--) if (RB[j-1]>RB[j]) ans++,RB[j]+=RB[j-1],RB[j-1]=RB[j]-RB[j-1],RB[j]-=RB[j-1];printf("%d\n",ans);}}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,l,i;
	string a[101];
	cin>>n>>l;
	for (i=1;i<=n;i++)
	    cin>>a[i];
	sort (a+1,a+n+1);
	for (i=1;i<=n;i++)
	    cout<<a[i];
	return 0;
}


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

using namespace std;

int main(){
	int N,A,B;
    cin>>N>>A>>B;
    vector<int> v;
    int tmp;
    int a,b,c;
    a=b=c=0;
    int min;
    for(int i=0;i<N;i++){
        cin>>tmp;
        if(tmp<=A){
            a++;
        }else if(tmp>B){
            c++;
        }else{
            b++;
        }
        //v.pushback(tmp);
    }

    if(a>b){
        if(b>c){
            min = c;
        }else{
            min = b;
        }
    }else{
        if(a>c){
            min = c;
        }else{
            min = a;
        }
    }

    cout<<min<<endl;

    
	
	
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


// ----------------------------------------------------------------------------

int main(){
  double a,b,c;
  cin >> a >> b >> c;
  cout << fixed << setprecision(10) << a*b*sin(c/180*PI)/2 << endl;
  cout << fixed << setprecision(10) << sqrt(a*a+b*b-2*a*b*cos(c/180*PI))+a+b << endl;
  cout << fixed << setprecision(10) << b*sin(c/180*PI) << endl;
  return 0;
}



Measured memory_bytes: 3460
N=int(input())
a=[0,0,0,0,0]
for i in range(N):
    c=input()[0]
    if c=='M':
        a[0]+=1
    elif c=='A':
        a[1]+=1
    elif c=='R':
        a[2]+=1
    elif c=='C':
        a[3]+=1
    elif c=='H':
        a[4]+=1

ans=0
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            ans+=a[i]*a[j]*a[k]
print(ans)

Measured memory_bytes: 44264
#include <bits/stdc++.h>
 
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
 
const int N=1e6+5,MAX=3e7,MOD=1e9+7;
 
using namespace std;

int occ[40],K[40],n;
ll k;
ll memo[40][2];
ll solve(int indx,bool flag){

	if(indx==-1)return 0;
	ll &ret = memo[indx][flag];
	if(~ret)return ret;
	if(!flag){
		if(!K[indx]){
			ret = solve(indx-1,0)+(1LL<<indx)*occ[indx];
		}
		else{
			ret = solve(indx-1,0)+(1LL<<indx)*(n-occ[indx]);
			ret = max(ret,solve(indx-1,1)+(1LL<<indx)*occ[indx]);
		}
	}
	else{

		ret = solve(indx-1,1)+(1LL<<indx)*max(n-occ[indx],occ[indx]);
	}

	return ret;
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);


     	scanf("%d %lld",&n,&k);

     	for(int i=0;i<n;i++){
     		ll x;
     		scanf("%lld",&x);
     		for(int j=0;j<40;j++)if(x&(1LL<<j))occ[j]++;
     	}

     	for(int i=0;i<40;i++)if(k&(1LL<<i))K[i]++;
     	memset(memo,-1,sizeof(memo));
     	printf("%lld\n",solve(39,0));
 }

Measured memory_bytes: 256
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;




//#[proconio::fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        x: usize,
        c:[(usize,[usize;m]);n],
    }

    let mut v = Vec::new();
    for bitpat in 0..(1<<n) {
        let mut rikai = vec![0;m];
        let mut cost = 0;
        for i in 0..n {
            if (1<<i) & bitpat != 0 {
                for j in 0..m {
                    rikai[j] += c[i].1[j];
                }
                cost += c[i].0;
            }
        }
        let mut complete = true;
        for j in 0..m {
            if rikai[j] < x {
                complete = false;
                break;
            }
        }
        if complete {
            v.push(cost);
        }
    }

    if let Some(ans) = v.iter().min() {
        println!("{}", ans);
    } else {
        println!("{}", -1);
    }

}



Measured memory_bytes: 2164
#include <iostream>
#include <functional>
#include <type_traits>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T, class F>
    void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};

int main()
{
    input in;

    int x = 0;
    in.online<char>(3, [&](char c) {if (c == '1')++x; });

    std::cout << x;

    return 0;
}


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

int N;
string S;
unordered_set<int> ret;


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

    bool chk1[10] = {};
    for(int i = 0; i < N; i++){
        if(!chk1[S[i] - '0']){
            chk1[S[i] - '0'] = true;
            bool chk2[10] = {};
            for(int j = i + 1; j < N; j++){
                if(!chk2[S[j] - '0']){
                    chk2[S[j] - '0'] = true;
                    bool chk3[10] = {};
                    for(int k = j + 1; k < N; k++){
                        if(!chk3[S[k] - '0']){
                            chk3[S[k] - '0'] = true;
                            ret.insert(100 * (S[i] - '0') + 10 * (S[j] - '0') + (S[k] - '0'));
                        }
                    }
                }
            }
        }
    }
    cout << ret.size() << endl;
}



Measured memory_bytes: 384
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nk = readln.split.to!(int[]);
    auto N = nk[0];
    auto K = nk[1];

    auto as = readln.split.to!(long[]);

    long[] ss;
    foreach (i; 0..N) {
        long s;
        foreach (j; i..N) {
            s += as[j];
            ss ~= s;
        }
    }

    long r;
    foreach_reverse (i; 0..42) {
        auto x = 1L<<i;
        long[] nss;
        foreach (s; ss) if (s & x) {
            nss ~= s;
        }
        if (nss.length >= K) {
            ss = nss;
            r |= x;
        }
    }
    writeln(r);
}

Measured memory_bytes: 11260
#include<iostream>
using namespace std;
long long arr[1001]={0};
int *sushubiao()
{
	int i,j;
	int MAX=2000;				//0x3f3f3f=1061109567
	int *shu= new int [MAX];
	int *sushu= new int [1000];	//一共有292676个素数 
	for(i=0;i<MAX;i++)
		shu[i]=1;
	int count=0;
	for(i=2;i<MAX;i++)
	{
		if(shu[i]==1)
		{
			for(j=2;j*i<MAX;j++)
			{
				shu[i*j]=0;
			}
			sushu[count++]=i;
			
		}
	}
	delete [] shu;				//释放数组shu的内存 
	return sushu;
}
int main()
{
	int n;
	int *p=sushubiao();
	cin>>n;
	int t;
	for(int i=1;i<=n;i++)
	{
		t=i;
		for(int j=0;p[j]<=i;j++)
		{
			if(t%p[j]==0)
			{
				t=t/p[j];
				arr[p[j]]++;
				arr[p[j]]=arr[p[j]]%1000000007;
				j--;
			}
		}
	}
	long long sum=1;
	for(int i=0;i<=n;i++)
	{
		if(arr[i]!=0)
		{
			sum*=arr[i]+1;
			sum%=1000000007;
		}
	}
	cout<<sum;
}



Measured memory_bytes: 256
# include <bits/stdc++.h>
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define DEBUG

using namespace std;

const int N = 1e5 + 7;
const int mod = 1e9 + 7;

int n, k, x, cnt;
pair < int, int > pr[N];

int main()
{
    speed;
    /// Author: Dilshod--Imomov
    #ifdef DEBUGd
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // DEBUG
    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        cin >> x;
        pr[i] = make_pair(x, i + 1);
    }
    sort(pr, pr + n);
    for ( int i = 0; i < n; i++ ) cout << pr[i].se << ' ';
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
//#define num 1000000007
#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define vi vector<int>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define avg(a,b) ((a)+(b))/2
#define pb push_back
#define pob pop_back
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define f first
#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
#define all(x) x.begin(), x.end()
#define M_PI 3.14159265358979323846
#define epsilon (double)(0.00000000001)
#define watch(x) cout << (#x) << " is " << (x) << endl
//#define endl "\n"
typedef long long ll;
ll mod(ll a, ll b)
{
	if(a%b<0)
	{
		return a%b + b;
	}
	return a%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll mymod(ll a,ll b)
{
    return ((a%b)+b)%b;
}
bool prime[200001];
void SieveOfEratosthenes() 
{ 
    //memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=200000; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=200000; i += p) 
                prime[i] = false; 
        } 
    } 
    return;
}
ll powe[200005];
void power()
{
    powe[0]=1;
    REP(i,1,200005)
    {
        powe[i]=mymod(2*powe[i-1],num);
    }
}
ll gcdExtended(ll,ll,ll *,ll *);
ll modInverse(ll a, ll m) 
{ 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
        ll res = (x%m + m) % m;
        return res;
} 
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
    return gcd; 
}
map<pll,ll> edgeweight;
struct node
{
	vll adj;
    ll colour;
    ll subtree_size;
};
void dfs(node N[], bool vis[], ll i)
{
    vis[i]=true;
    N[i].subtree_size=1;
    for(auto x: N[i].adj)
    {
        if(!vis[x])
        {
            dfs(N,vis,x);
            N[i].subtree_size+=N[x].subtree_size;
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll s,w;
    cin>>s>>w;
    cout<<((w>=s)?"unsafe\n":"safe\n");
    return 0;
}


Measured memory_bytes: 3656
N, K = map(int, input().split())
s = [0] * (N+1)
s[0] = 1
for i in range(K):
  d = int(input())
  A = list(map(int, input().split()))
  for j in range(d):
    s[A[j]] += 1
ans = 0
for i in range(N+1):
  if(s[i] == 0):
    ans += 1
print(ans)

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

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

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

  ll l, r;
  cin >> l >> r;

  ll mini = 2019;

  r = min(r, l + 2019);

  for (ll i = l; i < r; i++) {
    for (ll j = i + 1; j <= r; j++) {
      mini = min(mini, (i * j) % 2019);
    }
  }

  cout << mini << endl;
  return 0;
}


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

struct point
{
  int n, d;
  bool inc;
  point(int x, int y, bool z) : n(x), d(y), inc(z) {}
  bool operator<(const point& that) const
  {
    const int x = n*that.d;
    const int y = that.n*d;
    if (x == y) {
      return !inc && that.inc;
    } else {
      return x < y;
    }
  }
};

int main()
{
  int H, W;
  cin >> H >> W;
  vector<string> grid(H);
  for (int i = 0; i < H; i++) {
    cin >> grid[i];
  }

  vector<point> ps;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (grid[i][j] == '#'
          && (i == 0 || grid[i-1][j] == '.')
          && (j == 0 || grid[i][j-1] == '.')) {
        ps.push_back(point(j, H-i, true));
      } else if (grid[i][j] == '#'
          && (i == H-1 || grid[i+1][j] == '.')
          && (j == W-1 || grid[i][j+1] == '.')) {
        ps.push_back(point(j+1, H-i-1, false));
      } else if (grid[i][j] == '.'
          && (i != 0 && grid[i-1][j] == '#')
          && (j != 0 && grid[i][j-1] == '#')) {
        ps.push_back(point(j, H-i, true));
      } else if (grid[i][j] == '.'
          && (i != H-1 && grid[i+1][j] == '#')
          && (j != W-1 && grid[i][j+1] == '#')) {
        ps.push_back(point(j+1, H-i-1, false));
      }
    }
  }
  sort(ps.begin(), ps.end());
  int ans = 0;
  int acc = 1;
  for (vector<point>::const_iterator it = ps.begin(); it != ps.end(); ++it) {
    if (it->inc) {
      ++acc;
      ans = max(ans, acc);
    } else {
      --acc;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

int main() {
	int a, b, c; cin >> a >> b >> c;
	if (a <= c && c <= b)cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}

Measured memory_bytes: 256
var s,n;
var count;

function Merge(left,mid,right){
    var n1 = mid - left;
    var n2 = right - mid;
    var L = new Array(n1 + 1),R = new Array(n2 + 1);
    for(var i = 0;i < n1;i++)
        L[i] = s[left + i];
    for(var i = 0;i < n2;i++)
        R[i] = s[mid + i];
    L[n1] = 2000000000;
    R[n2] = 2000000000;
    var i = 0;
    var j = 0;
    for(var k = left;k < right;k++){
        if(L[i] <= R[j])
            s[k] = L[i++];
        else
            s[k] = R[j++];
        count++;
    }
}

function MergeSort(left,right){
    if(left + 1< right){
        var mid = Math.floor((left + right)/2);
        MergeSort(left,mid);
        MergeSort(mid,right);
        Merge(left,mid,right);
    }
}

function Main(input){
    input = input.split("\n");
    n = parseInt(input[0],10);
    s = new Array(n);
    input[1] = input[1].split(" ");
    for(var i = 0;i < n;i++){
        s[i] = parseInt(input[1][i],10);
    }
    count = 0;
    MergeSort(0,n);
    for(var i = 0;i < n;i++)
        String(s[i]);
    var ans = s[0];
    for(var i = 1;i < n;i++)
        ans += " " + s[i];
    console.log(ans);
    console.log(count);
}
 
Main(require("fs").readFileSync("/dev/stdin","utf8"));

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

if X <= 599:
  print(8)
elif X <= 799:
  print(7)
elif X <= 999:
  print(6)
elif X <= 1199:
  print(5)
elif X <= 1399:
  print(4)  
elif X <= 1599:
  print(3)
elif X <= 1799:
  print(2)
else:
  print(1)

Measured memory_bytes: 9176
//Utkarsh-raj

#include<bits/stdc++.h>

#define ll long long int
#define vc vector
#define mod 100000000007
#define mp make_pair
#define pb push_back
#define nl cout<<endl;
#define ff first
#define ss second

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ifstream myFile("task.in");
    if(!myFile.fail())
    {
        assert(freopen("task.in", "r", stdin));
    }

    ll n, w;
    cin>>n>>w;

    ll weight[n+1];
    ll profit[n+1];
    for(ll i=1; i<=n; i++){
        cin>>weight[i]>>profit[i];
    }

    vector<vector<ll> > dp(n+1, vector<ll> (w+1, 0));

    for(ll i=1; i<=n; i++){
        for(ll j=1; j<=w; j++){
            dp[i][j] = dp[i-1][j];
            if(weight[i] <= j){
                dp[i][j] = max(dp[i][j], profit[i] + dp[i-1][j-weight[i]]);
            }
        }
    }

    cout<<dp[n][w]<<endl;

    return 0;
}


Measured memory_bytes: 83152
# ABC103b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

s = input()[:-1]
t = input()[:-1]

tt = t

for _ in range(len(t)):
    tt = tt[1:]+tt[0]
    if (s == tt):
        print('Yes')
        exit()
print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	int h[n+2000];
	long long cs[n+20];
	for(int i=1;i<=n;i++)
		cin>>h[i];
	cs[0]=0;
	for(int i=1;i<=n;i++)
		cs[i]=10000000000000;
	cs[1]=0;
	for(int i=2;i<=n;i++)
		for(int j=1;j<=k&&i-j>=1;j++)
			cs[i]=min(cs[i],cs[i-j]+abs(h[i-j]-h[i]));
	cout<<cs[n];
	return 0;
}

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

//template
#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 ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    string s; cin>>s;
    string now,pre;
    int ans=0;
    rep(i,0,s.size()){
        now+=s[i];
        if(now!=pre){
            pre=now,now="";
            ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
}


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




int main() {
 string s;
  cin>>s;
  int anumber, znumber,N;
  N=s.size();
  
  for (int i=0;;i++){
    if (s.at(i)=='A'){
      anumber=i;
      break;
    }
  }
  for (int i=N-1;;i--){
    if (s.at(i)=='Z'){
      znumber=i;
      break;
    }
  }
  
  cout<<znumber-anumber+1<<endl;
  
 
}







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

using namespace std;

#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define Endl '\n'
#define cont continue
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/__gcd(a,b)
#define pb push_back
#define mp make_pair
#define mem(x) memset(x, 0, sizeof(x))

const ll inf=1e18;
const int mod=1e9+7;
inline ll bigmod(ll B,ll P){ll R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
const ll mxn = 2e6+10;
ll fact[mxn];
ll in_fact[mxn];
ll c(ll n,ll r) {
	ll ans = (fact[n] * (in_fact[r] * in_fact[n-r]%mod))%mod;
	return ans;
}
int main(){
    fast;
	//freopen ("input.txt", "r", stdin);
	//freopen ("output.txt", "w", stdout);
    int tt = 1;
    //cin>>tt;
    for(int tc = 1; tc <= tt; tc++) {
        ll k;
        ll ans = 0;
        string s;
        cin>>k>>s;
        ll n = s.size();
		fact[0] = 1;
		for(ll i = 1; i < mxn; i++) {
			fact[i] = (i*fact[i-1])%mod;
		}
		in_fact[mxn-1] = bigmod(fact[mxn-1],mod-2);
		for(ll i = mxn-2; i >= 0; i--) {
			in_fact[i] = (in_fact[i+1] * (i+1))%mod;
		}
		for(ll i = 0; i <= k; i++) {
			ll tmp = (bigmod(26,i) * bigmod(25,k-i)) % mod;
			tmp = (tmp * c(n+k-i-1,n-1))%mod;
			ans = (ans+tmp)%mod;
		}
		cout<<ans<<endl;
        
        
    }



return 0;
}


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

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0; i<n; i++) {
        cin>>a[i];
    }

    int dp[n];
    dp[0] = 0;
    dp[1] = abs(a[1]-a[0]);
    
    for(int i=2; i<n; i++) {
        int mini = INT_MAX;
        for(int j = i-1; j>=i-k&&j>=0; j--) {
            mini = min(mini, dp[j]+abs(a[j]-a[i]));
        }
        dp[i] = mini;
    }

    cout<<dp[n-1];
}

Measured memory_bytes: 1024
#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
#define lld long double
#define F first
#define S second
#define f(i,a,b) for(int i=a;i<=b;i++)
#define g(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mh make_heap
#define ph push_heap
#define pq priority_queue
#define bits(x) __builtin_popcountll(x)
#define op(x) cout<<"Case #"<<x<<": "
#define op1(x) cout<<"Scenario #"<<x<<": "
#define endl "\n"
using namespace std;
const ll mod = 1000000007;
const ll INF = LLONG_MAX;
const ll NEGINF = LLONG_MIN;
const int N = 18;
const ll MAXN = 1000001;


void solve(int t)
{
	int n;
	cin >> n;

	ll x[n], y[n];

	for (int i = 0; i < n; i++) cin >> x[i] >> y[i];

	for (int i = 0; i + 2 < n; i++)
	{
		if (x[i] == y[i] and x[i + 1] == y[i + 1] and x[i + 2] == y[i + 2])
		{
			cout << "Yes" << endl;
			return;
		}

	}

	cout << "No" << endl;



}



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);




	int t = 1;
	//cin >> t;



	for (int i = 1; i <= t; i++)
	{
		solve(i);

	}
}

Measured memory_bytes: 3608
#include <stdio.h>
#define NOT_FOUND -1
int A[10000];
int main() {
  int i, j, n, m, l, count=0;
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }
  scanf("%d", &m);
  int B[m];
  for(i = 0; i < m; i++) {
    scanf("%d", &B[i]);
    l = linearSearch(n, B[i]);
    if(l != NOT_FOUND) count++;
  }
  printf("%d\n", count);
  return 0;
}

int linearSearch(int n, int key) {
  int i=0;
  A[n] = key;
  while(A[i] != key) {
    i++;
  }
  if(i == n) {
    return NOT_FOUND;
  }
  return i;
}

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

using namespace std;

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

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

const ll mod = 1e9+7;
ll add(ll a, ll b) {
    return (a + b) % mod;
}
ll mul(ll a, ll b) {
    return a * b % mod;
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n, T; cin >> n >> T;
    vector<ll> v(n); cin >> v;
    sort(ALL(v));
    ll ans = 1;
    set<ll> s;
    REP(i, n) {
        ll a = v.begin()+i - lower_bound(v.begin(), v.begin()+i, v[i]-T);
        ans = mul(ans, a+1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3516
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl
#define COUT(x) cerr<<#x<<" = "; cout<<(x)<<endl

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

signed main()
{
   int n; cin >> n;
   string s, t; cin >> s >> t;

   for (int k = n; k >= 0; k--) {
      bool flag = true;
      for (int i = 0; i < k; i++) {
         if (s[i+n-k] != t[i]) {
            flag = false;
            break;
         }
      }
      if (flag) {
         COUT(2*n - k);
         break;
      }
   }

   return 0;
}


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

int main(){
  int n;
  long long a;
  long long max = -10000000;
  long long min = 10000000;
  long long sum = 0;

  cin >> n;
 
  for( int i = 0; i < n; i++){
    cin >> a;
    
    if( a > max ) max = a;
    if( a < min ) min = a;

    sum += a;
  }

  cout << min << " " << max << " " << sum << endl;

  return 0;
}

Measured memory_bytes: 3060
from math import factorial as f
x,y=map(int,input().split())
if(x<2):
    a=0
else:
    a=f(x)//(f(x-2)*2)
if(y<2):
    b=0
else:    
    b=f(y)//(f(y-2)*2)
print(a+b)

Measured memory_bytes: 3060
#include <iostream>
#include <string>

using namespace std;

typedef struct
{
    int parent;
    int left;
    int right;
} Node;

const int MAX = 25;
const int NIL = -1;
Node nodes[MAX];

void preParse(int u)
{
    if (u == NIL) return;
    cout << " " << u;
    preParse(nodes[u].left);
    preParse(nodes[u].right);
}
void inParse(int u)
{
    if (u == NIL) return;
    inParse(nodes[u].left);
    cout << " " << u;
    inParse(nodes[u].right);
}
void postParse(int u)
{
    if (u == NIL) return;
    postParse(nodes[u].left);
    postParse(nodes[u].right);
    cout << " " << u;
}

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

    for (int i = 0; i < MAX; i++)
    {
        nodes[i].parent = nodes[i].left = nodes[i].right = NIL;
    }

    // 入力データの登録
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        // nodesの添え字がそのノードのidとなっている
        int id, left, right;
        cin >> id >> left >> right;
        nodes[id].left = left;
        if (left != NIL) nodes[left].parent = id;

        nodes[id].right = right;
        if (right != NIL) nodes[right].parent = id;
    }

    // ルート
    int root;
    for (int i = 0; i < n; i++)
    {
        if (nodes[i].parent == NIL)
        {
            root = i;
            break;
        }
    }

    cout << "Preorder" << endl;
    preParse(root);
    cout << endl;

    cout << "Inorder" << endl;
    inParse(root);
    cout << endl;

    cout << "Postorder" << endl;
    postParse(root);
    cout << endl;


    return 0;
}


Measured memory_bytes: 3172
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var N=Arr.shift()-0;
for(var i=0;i<N;i++){
   var arr=(Arr.shift()).split(" ").map(Number);
   var x=arr[0];
   var y=arr[1];
   var b=arr[2];
   var p=arr[3];
   var A=(x*b)+(y*p);
   while(b<5)b++;
   while(p<2)p++;
   var B=((x*b)+(y*p))*0.8;
   console.log(Math.min(A,B));
}

Measured memory_bytes: 9936
import qualified Data.Map as M
main=print.solve.map(map read.words).lines=<<getContents
solve([n,ma,mb]:abcs)=if null r then -1 else minimum r where
  r=map snd.filter(\((a,b),_)->a*b/=0&&a*mb==b*ma).M.toList$foldr g (M.singleton(0,0)0)abcs
  g[a,b,c]m=foldr(\((x,y),z)m->M.insertWith min(a+x,b+y)(c+z)m)m.M.toList$m

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

using namespace std;

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

#define X real()
#define Y imag()

typedef long double D;
typedef complex<D> P;
struct L{P a, b;};
typedef vector<P> Pol;

const D EPS = 1e-8;

int sig(D a, D b = 0) {return a < b - EPS ? -1 : a > b + EPS ? 1 : 0;}
bool near(P a, P b) {return !sig(norm(a - b));}
namespace std {
  bool operator<(P a, P b) {return sig(a.X, b.X) ? a.X < b.X : a.Y < b.Y;}
}

D dot(P a, P b) {return a.X * b.X + a.Y * b.Y;}
D det(P a, P b) {return a.X * b.Y - a.Y * b.X;}

P vec(L a) {return a.b - a.a;}

bool eqL(L a, L b) {return !sig(det(vec(a), vec(b))) && !sig(det(vec(a), b.a - a.a));}
bool iLS(L a, L b) {return sig(det(vec(a), b.a - a.a)) * sig(det(vec(a), b.b - a.a)) <= 0;}

P pLL(L a, L b) {return a.a + vec(a) * (det(vec(b), b.a - a.a) / det(vec(b), vec(a)));}

int sAP(P a, P b, P c) {return sig(det(a, c)) - sig(det(b, c)) - sig(det(a, b));}

bool iGS(Pol pol, L s) {
  int n = pol.size();
  vector<int> sa(n + 1), sb(n + 1), sab(n + 1);
  pol.push_back(pol[0]);
  pol.push_back(pol[1]);
  rep (i, n + 1) {
    sa[i] = sig(det(pol[i + 1] - pol[i], s.a - pol[i]));
    sb[i] = sig(det(pol[i + 1] - pol[i], s.b - pol[i]));
    sab[i] = sig(det(s.b - s.a, pol[i] - s.a));
  }
  rep (i, n) if (sa[i] * sb[i] < 0 && sab[i] * sab[i + 1] < 0) return true;
  rep (i, n) {
    if (sa[i] == 0 && sb[i] > 0 && sig(dot(s.a - pol[i], s.a - pol[i + 1])) < 0) return true;
    if (sb[i] == 0 && sa[i] > 0 && sig(dot(s.b - pol[i], s.b - pol[i + 1])) < 0) return true;
  }
  rep (i, n) if (sab[i + 1] == 0 && sig(dot(pol[i + 1] - s.a, pol[i + 1] - s.b)) <= 0) {
    if (!near(pol[i + 1], s.a) && sAP(pol[i + 2] - pol[i + 1], pol[i] - pol[i + 1], s.a - pol[i + 1]) > 0) return true;
    if (!near(pol[i + 1], s.b) && sAP(pol[i + 2] - pol[i + 1], pol[i] - pol[i + 1], s.b - pol[i + 1]) > 0) return true;
  }
  return false;
}

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;
    Pol pol(n);
    rep (i, n) {
      D x, y;
      cin >> x >> y;
      pol[i] = P(x, y);
    }
    reverse(pol.begin(), pol.end());
    vector<P> vp[n];
    rep (i, n) vp[i].push_back(pol[i]);
    rep (i, n) vp[i].push_back(pol[(i + 1) % n]);
    rep (i, n) rep (j, n) rep (k, j) if (j != i && j != (i + 1) % n && k != i && k != (i + 1) % n) {
      L l1 = (L){pol[i], pol[(i + 1) % n]};
      L l2 = (L){pol[j], pol[k]};
      if (!eqL(l1, l2) && iLS(l2, l1)) vp[i].push_back(pLL(l1, l2));
    }
    rep (i, n) sort(vp[i].begin(), vp[i].end());
    rep (i, n) if (i > 0) {
      int comb = (1 << i) - 1;
      while (comb < (1 << n)) {
	rep (j, n) rep (k, vp[j].size() - 1) {
	  bool ok = false;
	  rep (p, n) if ((comb & 1 << p) && !iGS(pol, (L){pol[p], (vp[j][k] + vp[j][k + 1]) / (D)2})) {
	    ok = true;
	    break;
	  }
	  if (!ok) goto next;
	}
	cout << i << endl;
	goto end;
      next:;
	int x = comb & -comb, y = comb + x;
	comb = ((comb & ~y) / x >> 1) | y;
      }      
    }
  end:;
  }
}

Measured memory_bytes: 1288
n = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

ans = 0
f_arr = factorization(n)
for item in f_arr:
    if item[0] == 1: break

    i = 1
    d = item[1]
    while d > 0:
        d -= i
        if d >= 0:
            ans += 1
        i += 1

print(ans)


Measured memory_bytes: 9508
import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')

x,n = (int(a) for a in input().split())
seq = set((int(i) for i in input().split()))
i = 0
while True:
    if x - i not in seq:
        ans = x-i
        break
    if x + i not in seq:
        ans = x + i
        break
    i += 1
print(ans)


Measured memory_bytes: 69176
object Main {
  
  def main(args: Array[String]) {
    readLine()
    var (min, max, sum) = (Int.MaxValue, Int.MinValue, 0L)
    readLine().split(" ").map(_.toInt).foreach(x => {
      min = Math.min(min, x)
      max = Math.max(max, x)
      sum += x
    })
    println(s"$min $max $sum")
  }
}


Measured memory_bytes: 48632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define pbds tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define _ ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define mod 1000000007
#define deb(x) cerr << "\n" \
					<< #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
						<< #x << "=" << x << "\n" \
						<< #y << "=" << y << "\n";
#define w(x)  \
	int x;    \
	cin >> x; \
	while (x--)

int32_t main()
{

	int n;
	cin >> n;
	bool c = 0;
	while (n > 0)
	{
		if (n % 10 == 7)
		{
			c = 1;
			break;
		}
		n /= 10;
	}

	if (c)
		cout << "Yes";
	else
	{
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

long long dp[100010][2];
int main(){
    int n; cin>>n;
    long long a[n]; rep(i,n) cin>>a[i];
    dp[0][1]=-LINF;
    for(int i=1;i<=n;i++){
        dp[i][0]=max(dp[i-1][0]+a[i-1],dp[i-1][1]-a[i-1]);
        dp[i][1]=max(dp[i-1][0]-a[i-1],dp[i-1][1]+a[i-1]);
    }
    cout<<dp[n][0]<<endl;
    return 0;
}


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

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

	int N, K; cin >> N >> K;
	vector<int> H(N);
	rep(i, N) cin >> H[i];

	sort(all(H), greater<>());

	ll ans = 0;
	rep(i, N) {
		if (K>0) {
			K--;
			continue;
		}
		else ans += H[i];
	}

	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s == "RL"){
		cout<<"1 1";
		return 0; 
	}
	int n= s.size();
	int curr = 1;
	//search for next left and then next right
	vector<int> ans(n,0);
	int start = 0;
	while(curr != n-1){
		//debi;
		int temp1;
		while(s[curr] != 'L'){
			curr++;
		}
		temp1 = curr;
		// next right
		deb(temp1);
		int temp2 = temp1;
		bool ok  = false;
		if(temp1 != n-1){
			while(s[curr] != 'R'&& curr != n-1){
				curr++;
			}
			
			temp2 = curr;
			if(s[curr] == 'R'){
				ok = true;
			}
			else{
				ok = false;
				temp2++;
			}
		}
		//one set goes to temp1 -1 and other to temp1
		int tot;
		if(temp1 != n-1)
			tot = temp2 - start;
		else
			tot = temp1 - start+1;
		
		if(tot%2 == 0){
			ans[temp1-1] = tot/2;
			ans[temp1] = ans[temp1-1];
		}
		else{
			if((temp1 - start)%2 == 1){
				ans[temp1] = tot/2;
				ans[temp1-1]  = ans[temp1]+1;
			}
			else{
				ans[temp1 - 1] = tot/2;
				ans[temp1]  = ans[temp1-1]+1;
			}
		}
		
		start = temp2;
	}
	for(auto it : ans){
		cout<<it<<" ";
	}
	
	return 0;
}


Measured memory_bytes: 1024