akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
    
const int MXN=200005;
int n,h[MXN],a[MXN];
    
ll ft[MXN];
void upd(int x,ll v){
    for(;x<MXN;x+=x&-x)ft[x]=max(ft[x],v);
}

ll get(int x){
    ll ret=0;
    for(;x;x-=x&-x)ret=max(ret,ft[x]);
    return ret;
}
    
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;++i)scanf("%d",h+i);
    for(int i=0;i<n;++i)scanf("%d",a+i);

    for(int i=0;i<n;++i){
        upd(h[i],get(h[i])+a[i]);
    }
    printf("%lld\n",get(n));
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define fr(i,a,b) for(ll i=a;i <= b;i++)
#define sz(x) x.size()
#define pb push_back
#define N 100005

const ll pri = 1e9 + 7;
ll fact[N];

void pre() {
	fact[0] = 1;
	fr(i,1,N-1) {
		fact[i] = i * fact[i-1];
		fact[i] %= pri;
	}
}

int main() {
	pre();
	ll d,m,ans = 0; cin >> d >> m;
	if(d == m) {
		ans = fact[d]; ans *= fact[m]; ans %= pri;
		ans *= 2ll; ans %= pri;
	}
	else if(d == m+1) {
		ans = fact[d]; ans *= fact[m]; ans %= pri;
	}
	else if(d+1 == m) {
		ans = fact[d]; ans *= fact[m]; ans %= pri;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <queue>

using namespace std;

const int N=1010;

int a[N];

int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    int ans=0;
    for(int i=0;i<k;i++)
    {
        ans+=a[i];
    }
    cout<<ans<<endl;






    return 0;
}

Measured memory_bytes: 3636
require 'pp'

MOD = 10 ** 9 + 7

n, k = gets.chomp!.split(" ").map(&:to_i)
a_n = gets.chomp!.split(" ").map(&:to_i)

left = Array.new(n, 0)
right = Array.new(n, 0)

n.times do |i|
    n.times do |j|
        next if i == j

        if j < i && a_n[j] < a_n[i]
            left[i] += 1
        elsif j > i && a_n[j] < a_n[i]
            right[i] += 1
        end
    end
end

def ss(a, d, n)
    (n * (2 * a + (n - 1) * d)) / 2
end

sum = 0
right.each do |i|
    sum = (sum + ss(i, i, k)) % MOD
end
left.each do |i|
    sum = sum + ss(i, i, k - 1) % MOD
end

puts sum % MOD


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

int main(){
 double r, a, b, c, d;
 cin >> r;
 
 c = double(2);
 d = double(3.141592653589);

 a = r * r * d;
 b = r * c * d;

 cout << fixed << setprecision(6)<< a;
 cout << " ";
 cout << fixed << setprecision(6)<< b;
 cout << endl;

}


Measured memory_bytes: 3240
# B - Nice Shopping
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 _ 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: 97652
N, K = map(int, input().split())
D = list(map(int, input().split()))

d = []
for i in range(10):
    if i in D:
        pass
    else:
        d += [i]

def check(i):
    I = str(i)
    # print (I)
    n = len(I)
    for j in range(n):
        # print (I[j])
        if int(I[j]) in d:
            pass
        else:
            return False
    return True

# print (check(2000))

for i in range(10**5 + 1):
    if i >= N:
        if check(i):
            print (i)
            exit()


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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)

signed main () {
  cin.tie(0);
  cout << setprecision(10);

  int k; cin >> k;

  if(k%2 == 0) {
    cout << (k/2) * (k/2) << endl;
  } else {
    cout << (k/2) * (k/2 + 1) << endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  int N, x;
  cin >> N >> x;
  vector<int> A(N);

  for (int &a: A) {
    cin >> a;
  }

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

  int ans = 0;
  for (int a: A) {
    if (a <= x) {
      x-=a;
      ans++;
    }
  }
  if (N == ans && x > 0) {
    ans--;
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 256
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 基本はdouble
//map<キー,値> p は辞書。p[キー] = 値
//絶対値 abs()
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	int A, B; cin >> A >> B;
	if (A == 2 || B == 2)cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    a, b, c = map(int, input().split())
    if b - a == c - b:
        print(YES)
    else:
        print(NO)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
str = raw_input()
q = input()
for ans in range(q):
    ans = raw_input()
    ans1 = ans.split(' ')
    if ans1[0] == 'replace':
        str = str[0:int(ans1[1])]+ans1[3]+ str[int(ans1[2])+1:len(str)]
    if ans1[0] == 'reverse':
        str = str[0:int(ans1[1])]+ str[int(ans1[1]):int(ans1[2])+1][::-1] + str[int(ans1[2])+1:len(str)]
    if ans1[0] == 'print':
        print str[int(ans1[1]):int(ans1[2])+1]

Measured memory_bytes: 6476
use proconio::input;

fn main() {
    input! {
        n: usize,
        s: [String;n]
    }

    let ac = count_eq(&s, "AC");
    let wa = count_eq(&s, "WA");
    let tle = count_eq(&s, "TLE");
    let re = count_eq(&s, "RE");

    println!("AC x {}", ac);
    println!("WA x {}", wa);
    println!("TLE x {}", tle);
    println!("RE x {}", re);
}

fn count_eq(vec: &Vec<String>, num: &str) -> i64 {
    let mut counter = 0;
    for i in vec {
        if *i == num.to_string() {
            counter += 1;
        }
    }
    return counter;
}

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

int main(){
  string s1,s2,s3;

  cin >> s1 >> s2 >> s3;
  char o = char(int(s1[0] - 32)),t = char(int(s2[0] - 32)),thr = char(int(s3[0] - 32));
  cout << o << t << thr <<endl;
}


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

int main(){

  int in, ins;
  double x, y, sumins;
  char trash;

  x = 0;
  y = 0;
  sumins = 90;

  while(1){

    scanf("%d %c %d",&in,&trash,&ins);

    if(in == 0 && ins == 0){
      break;
    }
    
    x += in * cos(sumins / 180 * 3.14159265358979);
    y += in * sin(sumins / 180 * 3.14159265358979);
    sumins -= ins;

  }

  printf("%d\n%d\n",(int)x,(int)y);

  return 0;

}

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

int main() {
  int S, W;
  cin >> S >> W;
  
  //vector<vector<char>> matrix(H, vector<char>(W));
  //cout << hoge << endl;
  //vector<bool> hflag(0);

  if( W >= S) cout << "unsafe" << endl;
  else cout << "safe" << endl;
}


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

int main() {
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int cnt=0;
  
  while(a>=b){
    b*=2;
    cnt++;
  }
  while(b>=c){
    c*=2;
    cnt++;
  }
  if(cnt<=k){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}



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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;

// 二項係数ライブラリ---------------------------------------------------------------------------------------//
const ll MAX_COM = 1000007;
ll fac[MAX_COM], finv[MAX_COM], inv[MAX_COM];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1ll;
    finv[0] = finv[1] = 1ll;
    inv[1] = 1ll;
    for (int i = 2; i < MAX_COM; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] % MOD * finv[k] % MOD * finv[n - k] % MOD;
}

// Nが大きいときの二項係数計算
// N = 10^9, k = 2*10^5まで使える
const ll MAX_COM_NB = 200010;
vector<ll> COM_NB(MAX_COM_NB);
void COM_NBinit(int N) {
    // COMinit();
    COM_NB[0] = 1ll;
    rp(i, 1, MAX_COM_NB) {
        COM_NB[i] = COM_NB[i-1] * (N+1-i) % MOD * inv[i] % MOD;
    }
}

// 二項係数ライブラリここまで-----------------------------------------------------------------------------------//


int main() {
    COMinit();
    int n, k;
    cin >> n >> k;
    vector<ll> A;
    rp(i, 0, n){
        ll a; cin >> a;
        A.emplace_back(a);
    }
    sort(A.begin(), A.end());

    ll res = 0;
    rp(i, 0, n) {
        res -= A[i] * COM(n-1-i, k-1) % MOD;
        res += A[i] * COM(i, k-1) % MOD;
        res = (res + 3 * MOD) % MOD;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 29240
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vii = vector<int>;
using pii = pair<int, int>;

const ll INF = numeric_limits<ll>::max(),
         MOD = 1e9 + 7;

const int INF_i = numeric_limits<int>::max(),
          MAX = 1e6;

vii dp, v;
int n, k;
int f(int i = 0) {
    if (i == n - 1) return 0;
    if (dp[i] == -1) {
        dp[i] = INF_i;
        for (int j = i + 1; j < min(n, i + k + 1); j++) 
            dp[i] = min(dp[i], abs(v[i] - v[j]) + f(j));
    }
    return dp[i];
}

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    // freopen("in.in", "r", stdin);
    cin >> n >> k;
    v.resize(n);
    dp.assign(n, -1);
    for (int i = 0; i < v.size(); i++) {
        cin >> v[i];
    }
    cout << f() << '\n';
}

Measured memory_bytes: 7296
N, K = (int(i) for i in input().split())
R, S, P = (int(i) for i in input().split())
T = input()
hands = []
a = ['r', 's', 'p']

def add(s):
    if s == 'r': return P
    if s == 's': return R
    else: return S
   
def win(s):
    if s == 'r': return 'p'
    if s == 's': return 'r'
    else: return 's'
         
point = 0
for i in range(N):
    if i < K: 
        hands.append(win(T[i]))
        point += add(T[i])
    else:
        if win(T[i]) != hands[i-K]:
            hands.append(win(T[i]))
            point += add(T[i])
        else:
            if i+K < N:
                a.remove(win(T[i]))
                if win(T[i+K]) != win(T[i]):
                    a.remove(win(T[i+K]))
                
                hands.append(a[0])
                a = ['r', 's', 'p']
            else:
                hands.append(T[i])

print(point)

Measured memory_bytes: 4212
import sys
input = sys.stdin.readline
def print_ans(N, A):
    """Test Case
    >>> print_ans(3, [2, 2, 4])
    4 0 4
    >>> print_ans(5, [3, 8, 7, 5, 5])
    2 4 12 2 8
    >>> print_ans(3, [1000000000, 1000000000, 0])
    0 2000000000 0
    """
    # x0 = S - (a2 + a4 + ...)
    S = sum(A)
    xr = [0] * N
    xr[0] = S - 2 * (sum(A[1::2]))
    for i in range(1,N):
        xr[i] = 2 * A[i-1] - xr[i-1] 
    print(" ".join(list(map(str, xr))))

if __name__ == '__main__':
    N =  int(input().rstrip())
    A= list(map(int, input().rstrip().split()))
    print_ans(N, A)


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


int main()
{
    int N;
    cin >> N;
    
    vector<vector<int>> data(N);
    vector<vector<long>> value(N);
    
    for(int i=0;i<N;i++)
    {
        for(int j = 0;j<10;j++)
        {
            int t;
            cin >> t;
            data[i].push_back(t);
        }
    }
    for(int i=0;i<N;i++)
    {
        for(int j = 0;j<11;j++)
        {
            long t;
            cin >> t;
            value[i].push_back(t);
        }
    }
    
    long ans = LONG_MIN;
    
    
    
    for(int i = 0;i<(1<<10);i++) //1024
    {
        long tx = 0;
        bool nouse = true;
        bitset<10> temp(i);
        vector<int> used(N,0);
        for(int j = 0;j<10;j++)
        {
            if(temp[j] == 1)
            {
                nouse = false;
                for(int k = 0;k<N;k++)
                {
                    if(data[k][j] == 1)
                    {
                        used[k] ++;
                    }
                }
            }
        }
        
        for(int k = 0;k<N;k++)
        {
            tx += value[k][used[k]];
        }
        if(!nouse)
        {
            ans = max(ans,tx);
        }
        
    }
    
    
    
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,j,temp;
    int array[10];
    int n=10;
    for (i=0;i<n;i++)
    scanf("%d", &array[i]);

  for (i=0; i<(n-1);i++)
  {
    for (j=0;j<n-i-1;j++)
    {
      if (array[j] < array[j+1])
      {
        temp       = array[j];
        array[j]   = array[j+1];
        array[j+1] = temp;
      }
    }
  }
    for (i=0;i<3;i++)
     printf("%d\n", array[i]);
    return 0;
}

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

int main()
{
    int N;
    set < int > st;
    cin >> N;
    for(int i = 0; i < N; i++) {
        int a;
        cin >> a;
        if(st.find(a) != st.end()) {
            st.erase(a);
        } else {
            st.insert(a);
        }
    }

    cout << st.size() << endl;
    return (0);
}


Measured memory_bytes: 4864
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())

using namespace std;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}


using ll = long long;
constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

int clamp(int n, int a, int b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

int gcd(int u, int v) {
    int r;
    while (0 != v) {
        r = u % v; u = v; v = r;
    }
    return u;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    int N;
    cin >> N;
    vector<int>A(N);
    cin >> A;

    int ans = 0;
    vector<int>L(N + 1);
    vector<int>R(N + 1);
    FOR(i, 1, N + 1) {
        L[i] = gcd(L[i - 1], A[i - 1]);
    }
    FORR(i, N, 0) {
        R[i] = gcd(R[i + 1], A[i]);
    }

    REP(i, N) {
        ans = max(ans, gcd(L[i], R[i + 1]));
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 1408
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>


typedef long long ll;
const double Eps = 1e-6;

using namespace std;

typedef pair<double, vector<int> > P;
const double Inf = 1e100;

int n, no[15], dis[15], box[15];
int w[1 << 15];

double dp[1 << 15][15];
vector<int> path[1 << 15][15];

double recur(int visited, int current)
{
	if (dp[visited][current] != Inf)
		return dp[visited][current];

	double res = Inf;
	int next;
	for (int i = 0; i < n; ++i)
	{
		if (!(visited & 1 << i))
		{
			double t = recur(visited | 1 << i, i) 
				+ abs(dis[current]-dis[i]) / (2000.0 / (70.0 + w[visited]));
			if (t < res)
			{
				res = t;
				next = i;
			}
		}
	}
	path[visited][current] = path[visited | 1 << next][next];
	path[visited][current].push_back(no[current]);
	return dp[visited][current] = res;
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d %d %d", no+i, dis+i, box+i);

	for (int i = 0; i < 1 << n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			if (i & 1 << j)
				w[i] += 20*box[j];
			dp[i][j] = Inf;
		}
	}
	for (int i = 0; i < n; ++i)
	{
		dp[(1 << n) - 1][i] = 0;
		path[(1 << n) - 1][i].push_back(no[i]);
	}

	double ans = Inf;
	int v;
	for (int i = 0; i < n-1; ++i)
	{
		double t = recur(1 << i, i);
		if (t < ans)
		{
			ans = t;
			v = i;
		}
	}
	vector<int>& p = path[1 << v][v];
	for (int i = p.size()-1; i > 0; --i)
		printf("%d ", p[i]);
	printf("%d\n", p[0]);

	return 0;
}

Measured memory_bytes: 25000
#include<stdio.h>
int main()
{
  int m[10];
  int i,t,j;
  for(i=0;i<10;i++){
    scanf("%d",&m[i]);
  }
  for(i=0;i<9;i++){
    for(j=9;j>i;j--){
      if(m[j]<m[j-1]){
        t=m[j];
        m[j]=m[j-1];
        m[j-1]=t;
      }
    }
  }
  int a=9;
  for(i=0;i<3;i++){
    printf("%d\n",m[a]);
    a=a-1;
  }
  return 0;
}

Measured memory_bytes: 600
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#include<assert.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define INF 0x3f3f3f3f
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
const double PI = acos(-1.0);
const double epsilon = PI / 180.0;//角度转弧度 
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N = 2e5+10, M = 1e6+10;
struct node {
	int pos, val;
	bool operator < (node t) {
		if(pos == t.pos) return val < t.val;
		return pos < t.pos;
	}
};
bool operator < (node a, node b) {
	if(a.pos == b.pos) return a.val < b.val;
	return a.pos < b.pos;
}
int h, w;
int a[N], b[N];
set<node> s1;
multiset<int> s2;
int main() {
	cin>>h>>w;
	for(int i = 1;i <= h;i++) {
		scanf("%d %d", &a[i], &b[i]);
	}
	for(int i = 1;i <= w;i++) {
		s1.insert({i, 0});
		s2.insert(0);
	}
	for(int i = 1;i <= h;i++) {
		vector<node> tmp;
		set<node>::iterator it = s1.lower_bound({a[i], 0});
		int val = INF;
		while(it != s1.end()&&it->pos <= b[i] + 1) {
			tmp.pb({it->pos, it->val});
			val = min(val, it->val + b[i] + 1 - it->pos);
			it++;
		}
		for(int i = 0;i < tmp.size();i++) {
			s1.erase(tmp[i]);
			multiset<int>::iterator it = s2.lower_bound(tmp[i].val);
			s2.erase(it);
		}
		if(tmp.size() > 0&&b[i] + 1 <= w) {
			s1.insert({b[i] + 1, val});
			s2.insert(val);
		}
		if(s1.size() == 0) cout<<"-1\n";
		else cout<<i + *s2.begin()<<"\n";
	}
	return 0;
}


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

using namespace std;

int main(int argc, char* argv[]) {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  for (int i = 0; i < K; i++) {
    vector<int> tmp(N, 0);
    bool end = true;
    for (int j = 0; j < N; j++) {
      if (A[j] != N)
        end = false;

      int l = max(0, j - A[j]);
      int r = min(N - 1, j + A[j]);
      tmp[l]++;
      if (r + 1 < N)
        tmp[r + 1]--;
    }
    if (end)
      break;

    for (int j = 0; j < N - 1; j++) {
      tmp[j + 1] += tmp[j];
    }

    A.swap(tmp);
  }

  for (int i = 0; i < N - 1; i++) {
    cout << A[i] << " ";
  }
  cout << A[N - 1] << endl;

  return 0;
}

Measured memory_bytes: 5176
//Created by Aminul on 8/29/2020.

import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = in.nextInt(), m = in.nextInt();
        ArrayDeque<Integer> g[] = genDQ(n + 1);
        boolean[] vis = new boolean[n + 1];
        for (int i = 0; i < m; i++) {
            int u = in.nextInt(), v = in.nextInt();
            g[u].addLast(v);
            g[v].addLast(u);
        }

        int maxSize = 0;
        for (int i = 1; i <= n; i++) {
            maxSize = max(maxSize, dfs(i, vis, g));
        }

        pw.println(maxSize);

        pw.close();
    }

    static int dfs(int u, boolean vis[], ArrayDeque<Integer> g[]) {
        if (vis[u]) return 0;
        vis[u] = true;
        int cnt = 1;
        for (int v : g[u]) {
            if (!vis[v]) cnt += dfs(v, vis, g);
        }
        return cnt;
    }

    static <T> ArrayDeque<T>[] genDQ(int n) {
        ArrayDeque<T> list[] = new ArrayDeque[n];
        for (int i = 0; i < n; i++) list[i] = new ArrayDeque<T>();
        return list;
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}

Measured memory_bytes: 93888
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int n,m,ans=1;
	scanf("%d%d",&n,&m);
	int end=(int)sqrt((double)m);
	for(int i=end;i>=1;i--){
		if(m%i!=0) continue;
		int a=m/i,b=i;
		if(a>=n || b>=n){
			if(a>=n)
				ans=max(ans,b);
			if(b>=n)
				ans=max(ans,a);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int>A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  cout << A.at(N-1) - A.at(0) << endl;
}

Measured memory_bytes: 3576
S = str(input())
ans = 0
for i in range(0, 2**(len(S)-1)):
    s = ""
    for j in range(0, len(S)):
        s += S[j]
        if (i >> j) & 1:
            ans += int(s)
            s = ""
    ans += int(s)
print(ans)


Measured memory_bytes: 2940
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val s = readLine()!!
    val t = readLine()!!
    for (si in s.indices) {
        val subS = s.substring(si)
        val subT = t.substring(0, n - si)
        if (subS == subT) {
            println(n + si)
            return
        }
    }
    println(n * 2)
}

Measured memory_bytes: 33832
#include <stdio.h>



int gcd(int a, int b) {
	if (b==0) return a;
	else return gcd(b,a%b);
}
/*
int factorization(int num, int prime) {
	int a;
	while ((num%prime)==0) {
		num /= prime;
		a++;
	}
}
*/
int main(void) {
	int a,b,k,g,ans;
	int prime[15] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
	int factor[15];
	scanf("%d %d %d",&a,&b,&k);
	if (a<b) {
		g = a;
		a = b;
		b = g;
	}
	g = gcd(a,b);
//	printf("gcd= %d ",g);
	ans = g;
	while (k) {
		if ((g%ans)==0) k--;
		ans--;
	}
	printf("%d\n",ans+1);
	return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <set>
 
#define DEBUG 0
 
#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
 
using namespace std;
 
bool compare(const pair<lli,lli> &a,const pair<lli,lli> &b){
	return a.second > b.second;
}

int main(){
 
	lli n,k;
	cin>>n>>k;
	vector<pair<lli,lli>> t(n);
	vector<lli> num;
	REP(i,n)cin>>t[i].first>>t[i].second;
	sort(t.begin(),t.end(),compare);
 	vector<lli> a;
 	map<lli,lli> mp;
 	stack<lli>   s;
 	queue<lli>   q;
 	lli kind = 0;

 	lli sum = 0;

 	REP(i,k){
 		sum += t[i].second;
 		mp[t[i].first]++;
 		if(mp[t[i].first]==1)kind++;
 		else s.push(t[i].second);
 	}
 	for(lli i=k;i<n;i++){
		mp[t[i].first]++;
 		if(mp[t[i].first]==1)q.push(t[i].second);
 	}

 	lli ans = sum + kind*kind;
 	while(q.size() && s.size()){
 		sum = sum + q.front() -s.top();
 		kind++;
 		s.pop();
 		q.pop();
 		ans = max(ans,sum + kind*kind);
 	}
 	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 8448
#include<iostream>
using namespace std;
int main()
{
  string s;
  int a=0;
  int b=0;
  cin>>s;
  for(int i=0;i<3;i++)
  {
    if(s[i]=='A')
    {
      a++;
    }
    else if(s[i]='B')
    {
      b++;
    }
  }
    if(a>0&&b>0)
    {
      cout<<"Yes"<<endl;
    }
    else 
    {
      cout<<"No"<<endl;
    }
  
}

Measured memory_bytes: 256
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    int n;
    cin>>n;
    vector<ll> vec(n);
    for(int i = 0; i < n; i++)
        cin>>vec[i];
    vector<ll> suf(n+1, 0);
    for(int i = n-1; i >= 0; i--){
        suf[i] = suf[i+1] + vec[i];
        suf[i] %= mod;
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += vec[i]*(suf[i+1]%mod)%mod;
        ans %= mod;
    }
    cout<<ans;
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 6356
#include<bits/stdc++.h>                   // below comment for pbds
#include<ext/pb_ds/assoc_container.hpp>   // to use it make ordered_set
#include<ext/pb_ds/tree_policy.hpp>       // all set fnct + = 1. order_of_key(x); // number of 
#define ll long long                      //element strictly smaller than it;
#define ld long double                    // 2. find_by_order(x),pointer el at x pos after sort  use as s.f();
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;                     
using namespace __gnu_pbds;
// make less_equal in order to make a multiset pbds
ll CaseN=1;

ll tst()
{
ll ans=0;	


return ans;	
}


void solve()
{

	ll n,k;
	cin>>n>>k;
	ll a[n+2];
	ll ans=0;

	for(ll i=1;i<=n;i++)
	{
	cin>>a[i];	
	ans = max(ans,a[i]);
	}
	sort(a+1,a+1+n);
	
	ll l =1;
	ll h =10000000000000000ll ;
	// max ln 
	
	while(l<=h)
	{
		ll m = l+(h-l)/2;		
		
		
		
		//ll mx = 0;
		ll mi = 0;
		for(ll i=1;i<=n;i++)
		{
			if(a[i]>m)
			{
			ll z = a[i]/m;
			//if(a[i]%m!=0){}
			mi+=z; // min step	
			}
			
		}
		// mi and mx cut needed
		//cout<<"hello"<<endl;
		//cout<<mi<<" "<<mx<<" "<<m<<" "<<k<<endl;
		if( mi <= k)
		{
		ans = min(ans,m);
		h = m-1;	
		}
		else
		{
		l = m+1;	
		}
				
	}
	
	
	//ans = round(cnt);
	cout<<ans<<endl;
	//cout<<"Case #"<<CaseN<<": ";
	CaseN++;
		// print your ans below;
		
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.flush();
	ll t=1;
	//cin>>t;
	while(t--)
	{	
		
	    solve();
	    
	}

return 0;
}


Measured memory_bytes: 5140
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
using namespace std;

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

double const pi=3.1415926535;

int printint(int n){
	cout<<n<<endl;
	return 0;
}

int prints(string s){
	cout<<s<<endl;
	return 0;
}

int main(){
	int n;
	int l[114514],r[114514];
	cin>>n;
	rep(n)cin>>l[i]>>r[i];
	int ans=0;
	rep(n)ans+=r[i]-l[i]+1;
	printint(ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
	public static void main(String[] args){
		Runtime rt = Runtime.getRuntime();
		Scanner in = new Scanner(System.in);
		ArrayList<String> input = new ArrayList<String>();
		while(in.hasNext()){
			input.add(in.next());
		}
		String s=input.get(0);
		char[] s2=s.toCharArray();
		String a="";
		for (int i=0;i<s.length();i=i+2){
			a+=s2[i];
			if(i%1000==0)rt.gc();
		}
		System.out.println(a);
	}
}

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

int main() {
	int n,k ;
	cin>>n>>k;
	int arr[n];
	for(int i = 0;i<n;i++){
	    cin>>arr[i];
	}
	
	
	int dp[n];
	
	memset(dp,INT_MAX,sizeof(dp));
	dp[0]=0;
	
	
	for(int y = 1;y<n;y++){
	    int i = 1;
	    dp[y] = dp[y-1]+abs(arr[y-1]-arr[y]);
	    while(y-i>=0 && i<=k){
	    dp[y] = min(dp[y-i]+abs(arr[y-i]-arr[y]),dp[y]);
	    //cout<<dp[y-i]+abs(arr[y-i]-arr[y])<<endl;
	    //cout<<dp[y]<<endl;
	    i++;
	    }
	}
	
	//for(int i = 0;i<n;i++)cout<<dp[i]<<endl;
	cout<<dp[n-1]<<endl;
	return 0;
}

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

using namespace std;

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

  int n = atoi(N.c_str());
  int k;
  int sum = 0;
  for (int i = 0; i < N.size(); i++) {
    k = N[i] - '0';
    sum += k;
  }

  string ans = (n % sum == 0) ? "Yes" : "No";

  cout << ans << endl;

  return 0;
}


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

//----------------------------------------------------------------------------------
#define pb insert//                                                                 |
#define eb emplace_back//                                                           |
#define ff first//                                                                  |
#define ss second//                                                                 |
typedef long long int ll;//                                                         |
typedef long double ld;//                                                           |
#define all(a) a.begin(), a.end()//                                                 |
#define show(x) cerr << #x << " is " << x << "\n"//                                 |
#define show2(x, y) cerr << #x << " " << #y << " " << x << " " << y << "\n"//       |
typedef vector<ll> vl;//                                                            |
typedef vector<vl> vvl;//                                                           |
typedef pair<ll, ll> pp;//                                                          |
typedef vector<pp> vp;//                                                            |
typedef map<pp, ll> ipi;//                                                          |
typedef map<pp, char> ipc;//                                                        |
typedef map<ll, ll> ii;//                                                           |
typedef set<ll> sl;//                                                               |
typedef multiset<ll> msl;//                                                         |
typedef map<char, ll> ci;//                                                         |
typedef set<pair<ll, ll>> sp;//                                                     |
const ll mod = 1e9 + 7;//                                                           |
const ll N = 2e5 + 1;//                                                             |
//----------------------------------------------------------------------------------



//main func
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

    ll n;cin>>n;
    ll m;cin>>m;
    char c;cin>>c;
    ll d;cin>>d;
    m*=100;
    m+=d;
    n*=m;
    n/=100;
    cout<<n;
	return 0;
}

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

void chmin(int &x, int y){x=min(x,y);}

int dp[20101];

main()
{
    int h,n; cin>>h>>n;
    for(int i=1; i<=20100; ++i) dp[i]=1e8;
    while(n--)
    {
        int a,b; cin>>a>>b;
        for(int w=0; w<h; ++w)
        {
            chmin(dp[w+a],dp[w]+b);
        }
    }
    int ans=1e8;
    for(int w=h; w<20101; ++w) chmin(ans,dp[w]);
    cout << ans << "\n";
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;
typedef long long lli;
lli n,k;
vector<lli> a;
bool dp[5001][5001];
bool dpi[5001][5001];
int main(){
    cin >> n >> k;
    a = vector<lli> (n);
    for(lli i = 0;i < n;i++) cin >> a[i];
    dp[0][0] = true;
    for(lli i = 0;i < n;i++){
        lli j = 0;
        for(;j < k-a[i];j++){
            dp[i+1][j] += dp[i][j];
            dp[i+1][j+a[i]] += dp[i][j];
        }
        for(;j < k;j++){
            dp[i+1][j] += dp[i][j];
        }
    }
    dpi[n][0] = true;
    for(lli i = n;i > 0;i--){
        lli j = 0;
        for(;j < k-a[i-1];j++){
            dpi[i-1][j] += dpi[i][j];
            dpi[i-1][j+a[i-1]] += dpi[i][j];
        }
        for(;j < k;j++){
            dpi[i-1][j] += dpi[i][j];
        }
    }
    lli c = 0;
    for(lli i = 0;i < n;i++){
        dp[i][k] = true;
        for(lli x = 0,y = k;x < k && y >= 0;){
            while(!dp[i][x]) x++;
            while(!dpi[i+1][y]) y--;
            if(x + y >= k) y--;
            else{
                if(x + y + a[i] >= k){
                    c++;
                    break;
                }
                x++;
            }
        }
    }
    cout << a.size() - c << endl;
}

Measured memory_bytes: 49152
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef unsigned long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

int main(){
    ll k; cin >> k;
    
    string nines = "";
    map<ll, ll> m;
    REP(i, 15){
        FOR(j, 1, 1000){
            auto c_str = to_string(j) + nines;
            ll c = stoll(c_str);
            ll s = 0;
            REP(k, c_str.size()){
                s += stoll(c_str.substr(k, 1));
            }
            m[c] = s;
        }
        nines += "9";
    }

    vl ans;
    for(auto it = m.begin(); it != m.end(); it++){
        bool ok = true;
        for(auto tmp_it = it; tmp_it != m.end(); tmp_it++){
            if(it->ff * tmp_it->ss > it->ss * tmp_it->ff){
                ok = false; break;
            }
        }
        if(ok) ans.pb(it->ff);
    }
    REP(i, k) cout << ans[i] << endstr;
    return 0;
}


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

int main() {
	string s;
	cin >> s;
	bool flag = true;
	if (s[0] != 'A') flag = false;
	int cnt = 0;
	for (int i = 2; i <= s.size() - 2; i++) {
		if (s[i] == 'C') cnt++;
	}
	if (cnt != 1) flag = false;
	for (int i = 1; i < s.size(); i++) {
		if (s[i] == 'C') continue;
		if (('Z' - '0') >= (s[i] - '0')) flag = false;
	}
	if (flag) cout << "AC" << endl;
	else cout << "WA" << endl;
}

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

using namespace std;

#define INF ((1<<30)-1)  //int32_t
#define MOD 1000000007
#define MOD2 

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

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

int main(){

    bool flag=true;

    ll ans=0,sum=0;
    
    int n,m;
    cin >>n;
    vector<pii> stu(n);

    for (int i = 0; i < n; i++){
        int ai;
        cin >>ai;

        stu[i] = pii(ai,i+1);
    }
    
    sort(all(stu));

    for (int i = 0; i < n; i++){
        cout << stu[i].second <<" ";
    }
    

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

ll N, W, w[101], v[101];
vector<ll> V[4];
ll acc[4][101];

signed main(){
    cin >> N >> W;
    REP(i, N){
        cin >> w[i] >> v[i];
        V[w[i] - w[0]].push_back(v[i]);
    }
    REP(i, 4) sort(ALL(V[i]), greater<ll>());
    REP(i, 4){
        REP(j, V[i].size()) acc[i][j + 1] += acc[i][j] + V[i][j];
    }
    ll ans = 0;
    REP(i, V[0].size() + 1){
        REP(j, V[1].size() + 1){
            REP(k, V[2].size() + 1){
                REP(l, V[3].size() + 1){
                    if(i * w[0] + j * (w[0] + 1) + k * (w[0] + 2) + l * (w[0] + 3) > W) continue;
                    ans = max(ans, acc[0][i] + acc[1][j] + acc[2][k] + acc[3][l]);
                }
            }
        }
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <string.h>
int main(){
 int A,B,C;
  scanf("%d %d %d",&A,&B,&C);
  if((A==5 && B==7 && C==5)||(A==5 && B==5 && C==7)|| (A==7 && B==5 && C==5)){
    printf("YES");}
      else{
        printf("NO");
      }
      return 0;
     }

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

using namespace std;

int main(void) {
    int K;
    cin >> K;

    queue<int64_t> q;
    q.emplace(1);
    q.emplace(2);
    q.emplace(3);
    q.emplace(4);
    q.emplace(5);
    q.emplace(6);
    q.emplace(7);
    q.emplace(8);
    q.emplace(9);
    for(int i=0; i<K-1; i++) {
        int64_t tmp = q.front();
        q.pop();
        if(tmp%10 == 0) {
            q.emplace(tmp*10);
            q.emplace(tmp*10+1);
        } else if(tmp%10 == 9) {
            q.emplace(tmp*10 + 8);
            q.emplace(tmp*10 + 9);
        } else {
            q.emplace(tmp*10 + tmp%10 - 1);
            q.emplace(tmp*10 + tmp%10);
            q.emplace(tmp*10 + tmp%10 + 1);
        }
    }
    cout << q.front() << endl;
    // priority_queue<int64_t, vector<int64_t>, greater<int64_t> > pq;
    // pq.emplace(1);
    // pq.emplace(2);
    // pq.emplace(3);
    // pq.emplace(4);
    // pq.emplace(5);
    // pq.emplace(6);
    // pq.emplace(7);
    // pq.emplace(8);
    // pq.emplace(9);
    // priority_queue<int64_t, vector<int64_t>, greater<int64_t> > ans;
    // while(ans.size() < 1'000'000) {
    //     int tmp = pq.top();
    //     ans.emplace(tmp);
    //     if(tmp%10 == 0) {
    //         pq.emplace(tmp*10);
    //         pq.emplace(tmp*10+1);
    //     } else if(tmp%10 == 9) {
    //         pq.emplace(tmp*10+8);
    //         pq.emplace(tmp*10+9);
    //     } else {
    //         pq.emplace(tmp*10 + tmp%10 - 1);
    //         pq.emplace(tmp*10 + tmp%10);
    //         pq.emplace(tmp*10 + tmp%10 + 1);
    //     }
    //     pq.pop();
    // }

    // for(int i=0; i<K-1; i++) {
    //     ans.pop();
    // }
    // cout << ans.top() << endl;
    return 0;
}


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

int main(int argc, char const *argv[])
{
	long long w,h,x,y;
	cin>>w>>h>>x>>y;
	printf("%.10f ", (double)w*h/2.0);
	if (w==x*2LL&&h==y*2LL)
	{
		cout<<"1\n";
	}
	else
	{
		cout<<"0\n";
	}
	return 0;
}


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

int main() {
  int N,M,X,Left=0,Right=0;
  cin >> N >> M >> X;
  for (int i=0; i<M; i++) {
    int a;
    cin >> a;
    if (a<X) {
      Left++;
    }
    else {
      Right++;
    }
  }
  cout << min(Left,Right) << endl;
}


Measured memory_bytes: 256
import math
n,m=map(int,input().split())
n,m=max(n,m),min(n,m)
if n-m>=2:
  print(0)
else:
  mod=10**9+7
  v1=math.factorial(m)%mod
  if n==m:
    print(2*v1**2%mod)
  else:
    print(n*v1**2%mod)

Measured memory_bytes: 4080
import java.util.*;
import java.util.stream.Collectors;


public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        final int n=scanner.nextInt();
        boolean[] booleans=new boolean[10000];
        int[] ints=new int[n];
        boolean flag=true;
        int result=0;
        for(int i=0;i<n;i++){
            ints[i]=scanner.nextInt();
        }
        for(int i=0;i<n;i++){
            if(flag){
                flag=false;
                continue;
            }
            if(i==n-1){
                if(ints[n-2]==ints[n-1]){
                    result++;
                }
            }else{
                if(ints[i-1]==ints[i]){
                    result++;
                    flag=true;
                }
            }

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

Measured memory_bytes: 23508
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,v;
	while(cin>>N) {
		map<ll, ll> h;
		REP(i, N) {
			cin>>v;
			h[v]++;
		}
//		DD(h);
		VI cands;
		for(auto kv:h) {
			if(kv.second>=2) cands.PB(kv.first);
			if(kv.second>=4) cands.PB(kv.first);
		}
		sort(ALLR(cands));
		ll ans = 0;
		if(cands.size()>=2) ans = cands[0]*cands[1];
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <set>
#include <numeric>

using namespace std;
int main() {
    int a;
    cin >> a;
    if(a == 1){
        cout << "Hello World" << endl;
    }
    else{
        int b, c;
        cin >> b >> c;
        cout << b + c << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

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

    int x;

    cin >> x;

    cout << ((x >= 1200) ? "ARC" : "ABC") << endl;

    return 0;
}


Measured memory_bytes: 256
#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 fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

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

const long long mod = 1000000007;
const long long inf = 1e18;


int visited1[100001];
int visited2[100001];
vi arr[100001];

int main() {
    int n;
    cin>>n;
    for(int i=1;i<n;i++){
        int a,b;
        cin>>a>>b;
        arr[a].push_back(b);
        arr[b].push_back(a);
    }

    queue<int> q;
    visited1[1]=1;
    q.push(1);

    while(!q.empty()){
        int u=q.front();
        q.pop();
        for(int i=0;i<arr[u].size();i++){
            int node=arr[u][i];
            if(visited1[node]==0){
                visited1[node]=visited1[u]+1;
                q.push(node);
            }
        }
    }

    visited2[n]=1;
    q.push(n);

    while(!q.empty()){
        int u=q.front();
        q.pop();
        for(int i=0;i<arr[u].size();i++){
            int node=arr[u][i];
            if(visited2[node]==0){
                visited2[node]=visited2[u]+1;
                q.push(node);
            }
        }
    }

    ll ans=0;
    for(int i=1;i<=n;i++){
        //cout<<visited1[i]<<' '<<visited2[i]<<endl;
        if(visited1[i]<=visited2[i]){
            ans+=1;
        }
    }
    //cout<<ans<<endl;
    if(ans<=n-ans){
        cout<<"Snuke"<<endl;
    }
    else
        cout<<"Fennec"<<endl;
    return 0;
}


Measured memory_bytes: 6656
object Main {
  def main(args: Array[String]): Unit = {
    val ab = io.StdIn.readLine().split(" ").map(_.toInt)
    val a = ab(0)
    val b = ab(1)

    val d = a / b
    val r = a - b * d
    val f = a / b.toDouble

    println(f"$d $r $f%.5f")
  }
}

Measured memory_bytes: 44092