akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let (n, m): (usize, usize) = read();

    let mut cnt = vec![1; n+1];
    let mut has_red = vec![false; n+1];
    has_red[1] = true;

    for i in 0..m {
        let (a, b): (usize, usize) = read();
        if has_red[a] {
            has_red[b] = true;
        }
        cnt[a] -= 1;
        cnt[b] += 1;
        if cnt[a] == 0 {
            has_red[a] = false;
        }
    }

    let mut ans = 0;
    for i in 1..n+1 {
        if has_red[i] {
            ans += 1;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <iostream>

int main() {
  uint32_t A = 0, B = 0, C = 0, D = 0, E = 0, F = 0;
  std::cin >> A >> B >> C >> D >> E >> F;
  A *= 100;
  B *= 100;

  double max_concentration = 0.0;
  uint32_t ans_water = 0, ans_salt = 0;
  for (size_t a = 0; a <= F / A; a++) {
    for (size_t b = 0; b <= F / B; b++) {
      uint32_t water = a * A + b * B;
      if (water == 0 || water > F) break;

      for (size_t c = 0; c <= (F - water) / C; c++) {
        for (size_t d = 0; d <= (F - water) / D; d++) {
          uint32_t salt = c * C + d * D;
          if (salt > E * water / 100 || water + salt > F) break;

          double concentration = static_cast<double>(salt) / (water + salt);
          if (concentration > max_concentration || ans_water == 0) {
            max_concentration = concentration;
            ans_water = water;
            ans_salt = salt;
          }
        }
      }
    }
  }

  std::cout << ans_water + ans_salt << " " << ans_salt << std::endl;

  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	A := make([]int,N-1)
	B := make([]int,N)
	for i:=range A{
		fmt.Scan(&A[i])
	}

	for i:=range A{
		B[A[i]-1]++
	}
	for i:= range B{
		fmt.Println(B[i])
	}
}

Measured memory_bytes: 8552
import sys
sys.setrecursionlimit(10**6)
import numpy as np
N, M = map(int, input().split())

MOD = 1000000007
dp = np.zeros(N, dtype = int)
if M != 0:
    A = np.array([int(input()) for _ in range(M)], dtype = int)
    dp[A - 1] = -1


if dp[0] == -1 and dp[1] == -1:
    pass
else:
    if dp[0] == -1:
        dp[1] = 1
    elif N >= 2 and dp[1] == -1:
        dp[0] = 1
    elif N >= 2:
        dp[0] = 1
        dp[1] = 2
    else:
        dp[0] = 1


if N >= 3:
    for n in range(2, N):
        if dp[n] != -1:
            dp[n] = (max(dp[n-1], 0) + max(dp[n-2], 0)) % MOD

print (dp[-1])


Measured memory_bytes: 16976
n = gets.to_i
as = gets.split.map(&:to_i)

mv = as.max
mvi = as.index(mv)

hf = -1
sc = 10**9 + 1

as.size.times do |i|
    next if i == mvi
    a = as[i]
    if (a - mv/2).abs < sc
        sc = (a - mv/2).abs
        hf = a
    end
    if (mv - a - mv/2).abs < sc
        sc = (a - mv/2).abs
        hf = a
    end
end

printf("%d %d\n", mv, hf)

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------
const int INF = 1e9+1000;
ll n, a, b;
ll h[111111];

int main() {
   cin >> n >> a >> b;
   rep (i, n) cin >> h[i];

   ll c = a - b;
   ll left = 0, right = INF;
   while (left+1<right) {
      ll mid = (left+right)/2;
      ll t = 0;
      rep (i, n) {
         ll x = max(h[i] - b * mid, 0LL);
         t += (x+c-1)/c;
      }
      if (t <= mid) {
         right = mid;
      } else {
         left = mid;
      }
   }
   cout << right << endl;

   return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;

typedef long long ll;
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define memset(v, h) memset((v), h, sizeof(v))
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll m[20][20];

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; }

struct node
{
    public: ll x;
    public: ll y;

    node(ll xx, ll yy)
    {
        x = xx;
        y = yy;
    }
};

int main(){
    ll h;
    cin >> h;

    ll pow = 0;
    ll a = h;
    while(a > 1)
    {
        a /= 2;
        pow++;
    }

    ll f = 1;
    ll g = 2;
    rep(i, pow)
    {
        f += g;
        g *= 2;
    }

    cout << f << endl;
    return 0;
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define dump(x) cerr << #x " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define endl '\n'

#ifdef _DEBUG27_
    //#define STRESS 1
#endif

typedef long long llong;

const int INF = 2e9 + 999;
const llong LINF = 2e18 + 999;

void inv(bool e);
template<typename T> T sign(T a);
template<typename T> void die(T &a);
template<typename T> void umax(T &a, T b);
template<typename T> void umin(T &a, T b);

bool brute, alter;
int cnt_tests = 1;

// Improving csa rating

// Code below

int n;

vector<llong> arr;

void inp() {
    cin >> n;
    arr.resize(n);
    for (auto &x : arr) {
        cin >> x;
    }
}

llong lcm(llong a, llong b) {
    return max(a, b) / __gcd(a, b) * min(a, b);
}

void solve() {
    llong ans = arr[0];
    for (auto x: arr) {
        ans = lcm(ans, x);
    }
    cout << ans;
}

void stress() {

}

void naive() {

}

void run();
int main() {
    #ifdef _DEBUG27_
        if (1)
            freopen("input.txt", "r", stdin);
    #else
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        if (0) {
            freopen("palindrome.in", "r", stdin);
            freopen("palindrome.out", "w", stdout);
        }
    #endif
    srand(time(0));
    #ifdef STRESS
        brute = true;
    #else
        brute = false;
    #endif

    for (int i = 0; (i < cnt_tests); i++) {
        run();
    }
    cerr << endl << "Time: " << clock() / 1000.0 << " ms";
    return 0;
}

void run() {
    if (!brute) {
        inp();
    }
    else {
        stress();
    }
    solve();
    cout << endl;
}

template<typename T>
void die(T &a) {
    cout << a;
    exit(0);
}

template<typename T>
T sign(T a) {
    if (a == 0)
        return 0;
    if (a < 0)
        return -1;
    return 1;
}

template<typename T>
void umax(T &a, T b) {
    if (b > a)
        a = b;
}

template<typename T>
void umin(T &a, T b) {
    if (b < a)
        a = b;
}

void inv(bool e) {
    if (!e) {
        vector<int> a;
        a[-1] += 1;
    }
}

/** CLEARING BUFFER

    cout << VAL << flush;

    OR

    printf(VAL);
    fflush(stdout);
*/


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


int main() {
    string s;
    cin >> s;
    int lef, rig;
    lef = rig = -1;
    for (int i = 1; i < s.size() - 1; i++) {
        if (s[i] == s[i - 1]) {
            lef = i;
            rig = i + 1;
            break;
        } else if (s[i - 1] == s[i + 1]) {
            lef = i;
            rig = i + 2;
            break;
        }
    }
    if (s[s.size() - 2] == s[s.size() - 1]) {
        lef = s.size() - 1;
        rig = s.size();
    }
    cout << lef << " " << rig << endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#define MAX_V 100000
#define MAX_E 500000
#define INF 1e9
using namespace std;

int V;//頂点の数
int E;//辺の数

struct edge {
	int from, to, cost;
};
edge es[MAX_E];
int d[MAX_V];
bool find_negative_loop(int s)
{
	d[s] = 0;
	int count = 0;
	while (true)
	{
		bool update = false;
		count++;
		for (int i = 0; i < E; i++)
		{

			if (d[es[i].from] != INF && d[es[i].to] > d[es[i].from] + es[i].cost)
			{
				if (count == V)
				{
					return true;
				}
				d[es[i].to] = d[es[i].from] + es[i].cost;
				update = true;
			}
		}
		if (update == false)
		{
			break;
		}


	}
	return false;
}
int main() {
	int r;
	cin >> V >> E >> r;
	for (int i = 0; i < E; i++) {
		cin >> es[i].from >> es[i].to >> es[i].cost;
	}
	for (int i = 0; i <V; i++) {
		d[i] = INF;
	}
	if (find_negative_loop(r)) {
		cout << "NEGATIVE CYCLE" << endl;
	}
	else {
		for (int i = 0; i < V; i++) {
			if (d[i] == INF) {
				cout << "INF" << endl;
			}
			else {
				cout << d[i] << endl;
			}
		}
	}
	return 0;
}









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

signed main()
{
   int N,M; cin>>N>>M;
   vector<int> a(N);
   for(int i=0;i<N;i++) cin>>a[i];

   vector<int> sum(N+1);
   for(int i=0;i<N;i++){
      sum[i+1]=sum[i]+a[i];
   }

   map<int,int> cnt;
   for(int i=0;i<=N;i++){
      cnt[sum[i]%M]++;
   }

   int ans=0;
   for(pair<int,int> p:cnt){
      ans+=p.second*(p.second-1)/2;
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <cstdlib>

const int MAX_N = 100000;

struct Card {
  int order;
  int value;
  char kind;
};

void swap(std::vector<struct Card *> *A, int i, int j) {
  struct Card *tmp = A->at(i);
  A->at(i) = A->at(j);
  A->at(j) = tmp;
}

int partition(std::vector<struct Card *> *A, int p, int r) {
  struct Card *x = A->at(r);
  int i = p - 1;

  for (int j = p; j <= r - 1; j++) {
    if (A->at(j)->value <= x->value) {
      i++;
      
      swap(A, i, j);
    }
  }

  swap(A, i + 1, r);

  return i + 1;
}

void quick_sort(std::vector<struct Card *> *A, int p, int r) {
  if (p < r) {
    int q = partition(A, p, r);
    
    quick_sort(A, p, q - 1);
    quick_sort(A, q + 1, r);
  } 
}
  

int main(void) {
  std::ios_base::sync_with_stdio(false);

  int n = 0;

  std::cin >> n;

  std::vector<struct Card *> *A = new std::vector<struct Card *>();
  A->reserve(MAX_N);

  for (int i = 0; i < n; i++) {
    char c = 0;
    int v = 0;

    std::cin >> c;
    std::cin >> v;

    struct Card *card = (struct Card *) std::malloc(sizeof(struct Card));

    card->order = i;
    card->value = v;
    card->kind = c;
    
    A->push_back(card);
  }
  
  quick_sort(A, 0, A->size() - 1);

  bool prescendOrder = true;

  for (int i = 1; i < A->size(); i++) {
    if (A->at(i - 1)->value == A->at(i)->value) {
      if (A->at(i - 1)->order > A->at(i)->order) {
	prescendOrder = false;

	break;
      }
    }
  }  

  if (prescendOrder) {
    std::cout << "Stable" << std::endl;
  } else {
    std::cout << "Not stable" << std::endl;
  }

  for (int i = 0; i < A->size(); i++) {
    std::cout << A->at(i)->kind << " " << A->at(i)->value << std::endl;
  }

  return 0;
}

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

using namespace std;

int main()
{
    int S;
    int S1;
    int S2;
    int S3;
    int S4;
    cin >> S ;
    S1 = S/1000;
    S2 = (S-S1*1000)/100;
    S3 = (S-S1*1000-S2*100)/10;
    S4 = S-S1*1000-S2*100-S3*10;

    if(S1==S2 || S2==S3 || S3==S4)
    {
        cout << "Bad";/* code */
    }else
    {
        cout << "Good";/* code */
    }
    
    
    
    
}

Measured memory_bytes: 256
n=int(input())
s=list(input())
li=[0]
ans=n
for i in s:
    li+=[li[-1]+1] if i=='#' else [li[-1]]
b=li[-1]
for i in range(n+1):
    temp=li[i]+n-i-b+li[i]
    ans=min(ans,temp)
print(ans)

Measured memory_bytes: 12604
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
int main()
{
    int K;
    string S;
    cin >> K >> S;
    int l = S.length();
    
    REP(i,l){
        //fin(i);
        //fin(K);

        if(i < K){
            cout << S[i];
        }else{
            cout << "...";
            break;
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
int main(){
    string s;
    cin>>s;
    ll l=0,r=0,ans=0;
    rep(i,s.size()){
        if(s[i]=='<'){
            l=0;
            while(s[i]=='<'&&i<s.size()){
                l++;i++;
            }
            i--;
        }else{
            r=0;
            while(s[i]=='>'&&i<s.size()){
                r++;i++;
            }
            i--;
            if(r>l){
                ans+=l*(l-1)/2;
                ans+=(r+1)*r/2;
            }else if(l>=r){
                ans+=r*(r-1)/2;
                ans+=(l+1)*l/2;
            }
        }
    }
    if(s[s.size()-1]=='<'){
        if(r>l){
            ans+=l*(l-1)/2;
            if(l==1) ans++;
        }else if (l>=r){
            ans+=(l+1)*l/2;
            //if(l-1==0) ans+=1;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;
typedef tree<
    pair<int, int>,
    null_type,
    less_equal<pair<int, int>>,
    rb_tree_tag,
    tree_order_statistics_node_update>
    ordered_set;
#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define lb(v, z) lower_bound(all(v), z)
#define ub(v, z) upper_bound(all(v), z)
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define rdp(i, a, b) for (int i = (a); i >= (b); i--)
#define rlt(i, a, b) for (int i = (a); i < (b); i++)
#define cns(z) cout << (z) << ' '
#define cnl(z) cout << (z) << '\n'
#define M1 1000000007
#define M2 998244353
#define MAXN 300005
#define INF (1ll << 60)
#define endl "\n"
#define garr(ip)       \
    for (auto &x : ip) \
        cin >> x;
#define parr(ip)          \
    for (auto &x : ip)    \
        cout << x << " "; \
    cout << endl;
#define nl cout << endl
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vp;

void solve(int testCaseNumber = 1)
{
    int n, k;
    cin >> n >> k;
    vi arr(k + k);
    rlt(i, 0, k)
    {
        cin >> arr[i];
        arr[i + k] = arr[i] + n;
    }
    int ans = INF;
    rlt(i, 0, k)
        ans = min(ans, arr[i + k - 1] - arr[i]);
    cnl(ans);
}

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

Measured memory_bytes: 6360
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
typedef pair<int,int> P;
typedef pair<int,P> PP; 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1e9+7;

struct Dice{
  
  int t,s,e,w,n,b;
  
  Dice(int n1,int n2,int n3,int n4,int n5,int n6){
    t=n1;//top
    s=n2;//south
    e=n3;//east
    w=n4;//west
    n=n5;//north
    b=n6;//bottom
  }
  
  void roll(char direction){
    if(direction=='S'){
	 int tmp=s;
	 s=t,t=n,n=b,b=tmp;
    }
    if(direction=='N'){
	 int tmp=n;
	 n=t,t=s,s=b,b=tmp;
    }
    if(direction=='E'){
	 int tmp=e;
	 e=t,t=w,w=b,b=tmp;
    }
    if(direction=='W'){
	 int tmp=w;
	 w=t,t=e,e=b,b=tmp;
    }
  }

  int getTop(){
    return t;
  }
};

signed main(){
  int n1,n2,n3,n4,n5,n6;
  cin>>n1>>n2>>n3>>n4>>n5>>n6;
  string s;
  cin>>s;
  Dice dice(n1,n2,n3,n4,n5,n6);
  for(int i=0;i<sz(s);i++){
    dice.roll(s[i]);
  }
  cout<<dice.getTop()<<endl;
  return 0;
}



Measured memory_bytes: 3212
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        if(a == b && c != a || a == c && b != a || b == c && a!= b) {
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }
}

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

    int a[100];
    rep(i, n){
        cin >> a[i];
    }
    int max = a[0], min = a[0];
    rep(i, n-1){
        if(min > a[i+1]){
            min = a[i+1];
        }
        if(max < a[i+1]){
            max = a[i+1];
        }
    }
    cout << max - min << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int booknum;
    long long N,M,K,nowA=0,nowB=0;
    long long nowtime=0,ans=0;
    cin >> N >> M >> K;
    long long A[N];
    long long B[M];
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    for(int i=0; i<M; i++){
        cin >> B[i];
    }
    while(1){
        if(nowtime+B[nowB]>K || nowB==M) break;
        nowtime+=B[nowB];
        nowB++;
    }
    booknum=nowB;
    ans=booknum;
    while(1){
        if(nowtime+A[nowA]<=K){
            if(nowA==N) break;
            booknum++;
            nowtime+=A[nowA];
            nowA++;
        }else{
            if(nowB==0) break;
            nowB--;
            nowtime-=B[nowB];
            booknum--;
        }
        if(ans<booknum) ans=booknum;
    }
    cout << ans << endl;
    return 0;
}

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

namespace AtCoder
{
    public class A
    {
        public static void Main(string[] args)
        {
            string target = string.Join("", Console.ReadLine().Split(' '));

            var message = A.Execute(target);
            Console.WriteLine(message);
        }

        public static string Execute(string target)
        {
            // 5 -> 5 -> 7
            // 5 -> 7 -> 5
            // 7 -> 5 -> 5
            if (target.Equals("575") || target.Equals("755") || target.Equals("557"))
            {
                return "YES";
            }
            return "NO";
        }
    }
}

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

using namespace std;

int main(){
      int A,B;
      
      cin >> A >> B;
      
      if((A+B)>(A-B) and (A+B)>(A*B))
      {
          cout << A+B;
      }
      else if ((A-B)>(A+B) and (A-B)>(A*B)){
          cout << A-B;
      }
      else if ((A*B)>(A-B) and (A*B)>(A+B)){
          cout << A*B;
      }
      else if (A==0 and B<0){
          cout << A-B;
      }
      else if (A==0 and B>0){
          cout << A+B;
      }
      else if (B==0 and A<0){
          cout << A*B;
      }
      else if (B==0 and A>0){
          cout << A+B;
      }
      else if (B==0 and A==0){
          cout << 0;
      }
      
}

Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

string s;

int main(){
	cin >> s;
	cout << (s[0] == s[1] || s[1] == s[2] || s[2] == s[3] ? "Bad" : "Good") << endl;
}

Measured memory_bytes: 256
N = int(input())
pos = [list(map(int, input().split())) for _ in range(N)]
for cx in range(101):
    for cy in range(101):
        minH = 1 << 30
        se = set()
        for x,y,h in pos:
            a = -abs(x-cx)-abs(y-cy)
            if h == 0 and a == 0:
                break
            elif h == 0:
                minH = min(minH, -a)
            else:
                se.add(h-a)
        else:
            if len(se) == 0 and minH == 1:
                print(cx, cy, minH)
            elif len(se) == 1:
                hh = se.pop()
                if hh <= minH:
                   print(cx, cy, hh)

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

int main()
{
    string N;
    cin >> N;
    int ans = 0;
    for (int i = 0; i < 4; ++i)
    {
        if (N[i] == '2')
        {
            ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
vector<ll> divisors(ll n) {
    vector<ll> v;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            v.push_back(i);
            if (i * i != n) {
                v.push_back(n / i);
            }
        }
    }
    return v;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    ll n;
    cin >> n;

    set<ll> ans;
    auto d = divisors(n);
    for (auto k : d) {
        if (k == 1) continue;
        ll m = n;
        while (m % k == 0) {
            m /= k;
        }
        if (m % k == 1) ans.emplace(k);
    }
    auto d1 = divisors(n - 1);
    for (auto k : d1) if (k != 1) ans.emplace(k);

    cout << sz(ans) << endl;

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
    using namespace std;
    typedef long long int ll;
    #define LONGMAX 1e14
    #define dd double
    #define MOD 998244353  
    # define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
    #define nl cout<<endl
    #define fill(a,val) memset(a,val,sizeof(a))
    #define rt ll Q[100005]={0}
    #define mp make_pair
    #define endl "\n"
    #define test() ll t;cin>>t;while(t--)
    #define pb push_back
    #define ff first    
    #define ss second
    #define all(v) v.begin(),v.end()
    #define s(ar,n) sort(ar,ar+n)
    #define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
    #define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
    #define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
    #define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
    #define maxa(ar,N) *max_element(ar,ar+N)
    #define mina(ar,N) *min_element(ar,ar+N)
    #define INF 1e15
    #define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
    #define printclock cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
    ll power(ll x, ll y){ll res=1;while(y>0){if(y&1)res = (res*x);y = y>>1;x = (x*x);}return res;}  
    ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
    void ceilsearch(ll ar[],ll low,ll high,ll x,ll &y){if(low>high)return;ll mid=(low+high)/2;if(ar[mid]>=x){y=mid;ceilsearch(ar,low,mid-1,x,y);}else{ceilsearch(ar,mid+1,high,x,y);}}
    signed main()   
    {
        fastio();   
        ll N;
        cin>>N;
        ll ar[N];
        cn(ar,N);
        unordered_map<ll,ll> ma;
        for(ll i=0;i<N;i++)
            ma[ar[i]]++;
        ll ans=0;
        for(auto i:ma)
        {
            ans+=((i.ss*i.ss-i.ss)/2);
        }
        for(ll i=0;i<N;i++)
        {
            ll c=ans;
            c-=(ma[ar[i]]*ma[ar[i]]-ma[ar[i]])/2;
            ll f=ma[ar[i]]-1;
            c+=(f*f-f)/2;
            cout<<c<<endl;
        } 
    }   

Measured memory_bytes: 9160
#include <iostream>
#include <stdio.h>
using namespace std;
int main(){
    int a,b,c;
    int n = 0;
    cin >> a >> b >> c;
    for(a;a<=b;a++){
        if(c%a==0) n++;
    }
    cout << n << endl;
    return 0;
}


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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if (abs(c - a) <= d) {
		cout << "Yes" << endl;
	}
	else if ((abs(a - b) <= d) && (abs(b - c) <= d)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "\No" << endl;
	}
}


Measured memory_bytes: 256
# 6**6 < 10**5 < 6**7
# 9**5 < 10**5 < 9**6

def solve(n):
    if n < 6:
        return n
    elif n < 9:
        return n - 5
    else:
        now_6 = 6
        while now_6 * 6 <= n:
            now_6 *= 6

        now_9 = 9
        while now_9 * 9 <= n:
            now_9 *= 9
        
        ans = float('inf')
        for i in range(n // now_6 + 1):
            cnt = i + (n - now_6*i) // now_9 + solve((n - now_6*i) % now_9)
            if cnt < ans:
                ans = cnt
        
        return ans

print(solve(int(input())))

Measured memory_bytes: 9176
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [float('inf') for _ in range(n)]
dp[0] = 0


for i in range(n-1):
  for j in range(1, k+1):
    if i+j <= n-1 and dp[i] + abs(h[i+j]-h[i]) < dp[i+j]:
      dp[i+j] = dp[i] + abs(h[i+j]-h[i])

print(dp[n-1])

Measured memory_bytes: 56928
from collections import Counter
n,x,y = map(int, input().split())
x-=1
y-=1

dis=[]

for i in range(n-1):
    for j in range(i,n):
        dis.append(min(abs(i-j),abs(i-x)+abs(j-y)+1,abs(i-y)+abs(j-x)+1))
c=Counter(dis)
for i in range(1,n):
    print(c[i])


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

typedef long long int ll;

int main()
{
    ll h, w;
    cin >> h >> w;
    vector<string> s(h);
    for(ll i = 0;i < h;i++){
        cin >> s[i];
    }
    vector<vector<ll>> ans(h, vector<ll>(w));
    
    ll ud[3] = {-1, 0, 1}, lr[3] = {-1, 0, 1};
    for(ll i = 0;i < h;i++){
        for(ll j = 0;j < w;j++){
            ll cnt = 0;
            for(ll k = 0;k < 3;k++){
                for(ll n = 0;n < 3;n++){
                    if(i + ud[k] >= 0 && j + lr[n] >= 0 && i + ud[k] < h && j + lr[n] < w){
                        if(s[i + ud[k]][j + lr[n]] == '#' && !(i + ud[k] == i && j + lr[n] == j)){
                            cnt++;
                        }
                    }
                }
            }
            ans[i][j] = cnt;
        }
    }

    for(ll i = 0;i < h;i++){
        for(ll j = 0;j < w;j++){
            if(s[i][j] != '#'){
                cout << ans[i][j];
            }
            else{
                cout << '#';
            }
        }
        cout << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              emplace_back
#define mp              make_pair
#define bs              binary_search
#define pqb             priority_queue<int>
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define test(x)         int x; cin>>x; while(x--)
#define pi              3.14159265358979323846
void c_p_c()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
// int pow(int a, int b, int c)
// {
// 	int res = 1;
// 	while (b > 0)
// 	{
// 		if (b % 2)
// 			res = (res * a) % c;
// 		a = (a * a) % c;
// 		b >>= 1;
// 	}
// 	return res;
// }
/*********************CODE BEGINS*******************/
void solve()
{
	int num;
	cin >> num;
	int A[num];
	int sum = 0;
	map<int, int> m;
	for (int i = 0; i < num; i++)
	{
		cin >> A[i];
		sum += A[i];
		m[A[i]]++;
	}
	int q;
	cin >> q;
	while (q--)
	{
		int a, b;
		cin >> a >> b;
		int temp = m[a];
		m.erase(a);
		m[b] += temp;
		sum -= a * temp;
		sum += b * temp;
		cout << sum << endl;
	}
}
int32_t main()
{
	c_p_c();
	// test(x)
	solve();
}

Measured memory_bytes: 8352
def calc_trapezoid_area(top_length, under_length, height):    
    return (top_length + under_length) * height // 2

if __name__=='__main__':
    top_length, under_length, height = map(int, [input() for i in range(3)])
    print(calc_trapezoid_area(top_length, under_length, height))

Measured memory_bytes: 2940
s = input()


def is_even(n):
    return 0 == n % 2


def is_kaibun(s):
    n = len(s)
    max_index = (n // 2) if is_even(n) else (n-1) // 2
    for i in range(max_index):
        if s[i] != s[-1-i]:
            return False
    return True


n = len(s)
res = is_kaibun(s) and is_kaibun(s[0:(n-1)//2]) and is_kaibun(s[(n+2)//2:n])
print("Yes" if res else "No")


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

using namespace std;

int main()
{
   int n;

   cin >> n;



   for(int i = 1; i <= n; i++)
   {
    int x;

    cin >> x;

    if(x % 2 == 0)
        if(x % 3 != 0 && x % 5 != 0)
    {
        cout << "DENIED";
        return 0;
    }
   }

   cout << "APPROVED";


    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
int n,i,j;
  float nn;
  scanf("%f",&nn);
  n=(int)nn;
float x[n],y[n],d[n][n],sum;

  sum=0;
  for(i=0;i<n;++i)
  {
  scanf("%f %f",&x[i],&y[i]);
  }
  
  for(i=1;i<n;++i)
  {
   for(j=0;j<i;++j)
   {
   d[i][j]=sqrtf((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
   sum=sum+d[i][j]/nn*2;
   }
  }

  printf("%.6f",sum);
  
return 0;}

Measured memory_bytes: 2216
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    char[][] g = new char[h][];
    for(int i=0;i<h;i++)g[i]=sc.next().toCharArray();
    int[][] l = new int[h][w];
    int[][] r = new int[h][w];
    int[][] u = new int[h][w];
    int[][] d = new int[h][w];
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(g[i][j]=='#')l[i][j]=0;
        else if(j==0)l[i][j]=1;
        else l[i][j]=l[i][j-1]+1;
      }
    }
    for(int i=0;i<h;i++){
      for(int j=w-1;j>=0;j--){
        if(g[i][j]=='#')r[i][j]=0;
        else if(j==w-1)r[i][j]=1;
        else r[i][j]=r[i][j+1]+1;
      }
    }
    for(int j=0;j<w;j++)
      for(int i=0;i<h;i++){
        if(g[i][j]=='#')u[i][j]=0;
        else if(i==0)u[i][j]=1;
        else u[i][j]=u[i-1][j]+1;
      }
    for(int j=0;j<w;j++)
      for(int i=h-1;i>=0;i--){
        if(g[i][j]=='#')d[i][j]=0;
        else if(i==h-1)d[i][j]=1;
        else d[i][j]=d[i+1][j]+1;
      }
    int max = 0;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)max = Math.max(max,l[i][j]+r[i][j]+u[i][j]+d[i][j]-3);
    System.out.println(max);
  }
}

Measured memory_bytes: 111488
import java.util.*;
import java.io.*;

public class Main{
	public static void main(String[] args) throws IOException{
		Scanner stdIn = null;
		Map<String, Integer> result = new LinkedHashMap<String, Integer>();
		result.put("A", 0); result.put("B", 0); result.put("AB", 0); result.put("O", 0); 
		
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
			while( stdIn.hasNext() ){
				String str = stdIn.next();
				String[] s = str.split(",");
				Integer num = result.get(s[1]);
				result.put(s[1], num+1);
			}
			for(Integer num : result.values()){
				System.out.println(num);
			}
		} finally {
			if( stdIn != null ){
				stdIn.close();
			}
		}
	}
}

				

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#define MOD 10007
using namespace std;

int n,dp[1001][1 << 3];
string s,tmp = "JOI";

int rec(int idx,int prev){
  if(idx == n) return 1;
  if(dp[idx][prev]) return dp[idx][prev];
  int res = 0;
  for(int i=1;i<8;i++){
    if((i>>tmp.find(s[idx]))&1 && (prev & i)){
      res += rec(idx+1,i) % MOD;
    }
  }
  return dp[idx][prev] = res % MOD;
}
    

int main(){
  cin >> n >> s;
  int d;
  d = rec(0,1);
  cout << d << endl;
}

Measured memory_bytes: 1304
#include<cstdio>
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<utility>
#include<cmath>
using namespace std;
vector<int> a,v;
int dp[5010][5010];
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
int main(){
	int n,x,mid,s,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>x;
		if(x<k)a.push_back(x);
	}
	sort(a.begin(),a.end());
	s=a.size();
	int left=-1,right=s;
	while(right-left>1){
		v.clear();
		Fill(dp,0);
		mid = (left+right)/2;
		for(int i=0;i<s;i++){
			if(i!=mid)v.push_back(a[i]);
		}
		for(int i=s-2;i>=0;i--){
			for(int j=0;j<=k-1;j++){
				if(j<v[i]){
					dp[i][j]=dp[i+1][j];
				}else{
					dp[i][j] = max(dp[i+1][j],dp[i+1][j-v[i]]+v[i]);
				}
			}
		}
		if(dp[0][k-1]>=k-a[mid]){right=mid;}else{left=mid;}
	}
	cout<<right<<endl;
	return 0;
}

Measured memory_bytes: 98432
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
	string a, b, c; cin >> a >> b >> c;
	int cnt = 0;
	for(int i=0;i<n;i++){
		if(a[i]==b[i]&&b[i]==c[i]) continue;
		else if(a[i]!=b[i] && b[i]!=c[i] && c[i]!=a[i]){
			cnt += 2;
		}else{
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

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

using namespace std;

int main() {

	long n, k;
	cin >> n >> k;

	long d=0;
	long a = 0;
	vector<long> su(n + 1,0);
	for (long i = 1; i <= k; i++) {

		cin >> d;

		for (long j = 1; j <= d; j++) {
			cin >> a;
			su[a]++;
		}

	}
	
	long counter = 0;
	for (long i = 1; i <= n; i++) {
		if (su[i] == 0) { counter++; }
	}

	cout << counter << endl;
	return 0;

}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define mod 1000000007

ll n, k;
ll i, j;

vector<ll> dp;
vector<ll> divs;
ll ans;

void pre() {
    ll i, j;

    for (i = 1; i * i <= n; i++) {
        if (n % i != 0) continue;

        divs.pb(i);
        if (i < n / i)
            divs.pb(n / i);
    }

    dp = vector<ll>(divs.size() + 11, 0);
    sort(divs.begin(), divs.end());
}

ll poww(ll a, ll b) {
    ll ans = 1;

    while (b > 0) {
        if (b & 1) ans = (ans * a) % mod;
        b >>= 1;
        a = (a * a) % mod;
    }

    return ans;
}

int main()
{
  //  freopen("test.in","r",stdin);

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

    for (i = 0; i < divs.size(); i++) {
        dp[i] = poww(k, (divs[i] + 1) / 2);

        for (j = 0; j < i; j++)
            if (divs[i] % divs[j] == 0)
                dp[i] += mod - dp[j];

        dp[i] %= mod;
    }

    for (i = 0; i < divs.size(); i++) {
        if (divs[i] % 2 == 0) {
            ans += (dp[i] * (divs[i] / 2)) % mod;
        } else {
            ans += (dp[i] * divs[i]) % mod;
        }
    }

    ans %= mod;
    printf("%lld", ans);

    return 0;
}


Measured memory_bytes: 256
a,b,k=gets.split.map &:to_i
if b-a+1 <= 2 * k then
  puts (b-a+1).times.map{|n|n.to_i+a}.join("\n")
else
  puts k.times.map{|n|n.to_i+a}.join("\n")
  puts k.times.map{|n|b-n.to_i}.reverse.join("\n")
end

Measured memory_bytes: 1788
#include<cstdio>
#include<algorithm>
#include<queue>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int maxn=200000+10,inf=1000000000;
int ans[maxn],tree[maxn*4][2],f[maxn];
int i,j,k,l,r,s,t,n,m,tot,top;
struct dong{
	int l,r,u,v;
	friend bool operator <(dong a,dong b){
		return f[a.u]>f[b.u];
	}
} zlt;
priority_queue<dong> heap;
void update(int p){
	int i,j,k;
	fo(i,0,1){
		j=tree[p*2][i];k=tree[p*2+1][i];
		if (f[j]<f[k]) tree[p][i]=j;else tree[p][i]=k;
		//tree[p][i]=min(tree[p*2][i],tree[p*2+1][i]);
	}
}
void build(int p,int l,int r){
	if (l==r){
		tree[p][l%2]=l;
		return;
	}
	int mid=(l+r)/2;
	build(p*2,l,mid);build(p*2+1,mid+1,r);
	update(p);
}
int query(int p,int l,int r,int a,int b,int c){
	if (l==a&&r==b) return tree[p][c];
	int mid=(l+r)/2;
	if (b<=mid) return query(p*2,l,mid,a,b,c);
	else if (a>mid) return query(p*2+1,mid+1,r,a,b,c);
	else{
		int j=query(p*2,l,mid,a,mid,c),k=query(p*2+1,mid+1,r,mid+1,b,c);
		if (f[j]<f[k]) return j;else return k;
	}
}
void ins(int l,int r){
	int j,k;
	j=query(1,1,n,l,r,l%2);
	k=query(1,1,n,j+1,r,r%2);
	zlt.l=l;zlt.r=r;
	zlt.u=j;zlt.v=k;
	heap.push(zlt);
}
int main(){
	scanf("%d",&n);
	f[0]=inf;
	fo(i,1,n) scanf("%d",&f[i]);
	build(1,1,n);
	ins(1,n);
	while (!heap.empty()){
		zlt=heap.top();
		heap.pop();
		l=zlt.l;r=zlt.r;
		j=zlt.u;k=zlt.v;
		ans[++tot]=f[j];ans[++tot]=f[k];
		if (j!=l) ins(l,j-1);
		if (j+1!=k) ins(j+1,k-1);
		if (k!=r) ins(k+1,r);
	}
	fo(i,1,n) printf("%d ",ans[i]);
}

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef long double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define cerr if(true)cerr
void print(){cout<<endl;}
template<typename T,typename... Args>
void print(T a, Args... args) {cout<<a<<" ";print(args...);}
lli llipowerp(lli x, lli y, lli p=LLONG_MAX)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1) res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
template <typename T>
inline void printvec(vector<T> inp){
    for(auto it:inp) cout<<it<<" ";
    cout << endl;
}
//---------------------------------------------------------------------------------
int n, k;
const int N=1e5+10;
int dp[N];
set<int> a;
int get(int r){
    if(r==0) return 0;
    if(r<0) return 0;
    if(dp[r]!=-1) return dp[r];

    bool con=false;
    for(auto i:a){
        if(r-i>=0 && get(r-i)==0){
            con=true;
            break;
        }
    }
    if(con){
        dp[r]=1;
        return 1;
    }
    else{
        dp[r]=0;
        return 0;
    }

}
int main(){
    cin>>n>>k;
    memset(dp,-1,sizeof(dp));
    int x;
    fori(n) {
        cin>>x;
        a.insert(x);
    }
    // fori(k+1) cout<<get(i)<<" ";
    // cout<<endl;
    if(get(k)==1) cout<<"First"<<endl;
    else cout<<"Second"<<endl;

}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < b; i++)
int main() {
    int N, M, C;
    cin >> N >> M >> C;

    int a[21][21];
    int b[21];
    rep(i, 0, M) { cin >> b[i]; }
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < M; j++) {
            cin >> a[i][j];
        }
    }
    int ans = 0;
    ll sum = 0;
    for(int i = 0; i < N; i++) {
        sum = 0;
        for(int j = 0; j < M; j++) {
            sum += b[j] * a[i][j];
        }
        if(sum + C > 0) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3608
#include "bits/stdc++.h"

#define REP(i, n, N) for(int i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

int N;
int A,B;
int P[110];
int score[3];
int main() {
    cin>>N>>A>>B;
    REP(i,0,N){
        cin>>P[i];
        if(P[i]<=A){
            score[0]++;
        }else if(CK(P[i],A+1,B+1)){
            score[1]++;
        }else{
            score[2]++;
        }
    }
    p(min({score[0], score[1], score[2]}));

    return 0;
}


Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

signed main() {
    int K, Q;
    cin >> K >> Q;
    vector<int> D(K);
    for (int i = 0; i < K; i++) cin >> D[i];
    for (int q = 0; q < Q; q++) {
        int N, X, M;
        cin >> N >> X >> M;
        vector<int> E(K);
        int e = 0;
        for (int i = 0; i < K; i++) {
            E[i] = D[i] % M;
            if (E[i] == 0) E[i] = M;
            e += E[i];
        }
        int sum = X % M;
        sum += ((N-1) / K) * e;
        for (int i = 0; i < ((N-1) % K); i++) sum += E[i];
        cout << (N-1) - sum / M << endl;
    }
}

Measured memory_bytes: 384
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let nk: Vec<u32> = read_vec();
    let mut n = nk[0];
    let k = nk[1];

    let mut ans = 0;

    while n > 0 {
        ans += 1;
        n /= k;
    }

    println!("{}", ans);
}


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

int main() {
  int H,W;
  cin >> H >> W;
 
  vector<char> inData(H * W);
  int count = 0;
  
  //データ取得
  for (int i = 0; i < H * W; i++) {
	cin >> inData.at(i);
  }

  //1行目出力
  for (int i = 0; i < W + 2; i++) {
	cout << '#';
  }
  cout << endl;

  for (int i = 0; i < H; i++) {
	cout << '#';
	for (int j = 0; j < W; j++) {
		cout << inData.at(count);
		count++;
   	}
	cout << '#' << endl;
  }
  for (int i = 0; i < W + 2; i++) {
	cout << '#';
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
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;
}

ll mod = 1000000007;

int main(){
    ll N, M;
    cin >> N >> M;
    vector<ll> a(21000000);
    for(int i = 0; i < M; i++) cin >> a[i];
    vector<ll> dp(21000000);
    for (int i = 0; i < 21000000; i++) dp[i] = INF;
    for (int i = 0; i < M; i++){
      dp[a[i] - 1] = 0;
    }
      if (a[0] == 1)
        dp[0] = 0;
      else
        dp[0] = 1;
    if ((a[0] == 1 && a[1] == 2)||a[0]==2) dp[1] = 0;
    else  if(a[0]==1 && a[1]!=2)dp[1] = 1;
    else
      dp[1] = 2;
    for (int i = 2; i < N; i++) {
      if (dp[i] == 0) continue;
      else
        dp[i] = (dp[i - 1]%mod + dp[i - 2]%mod)%mod;
    }
    cout << dp[N - 1]%mod << endl;
    return 0;
}

Measured memory_bytes: 331396
import math
def prime_factorize(P):
    prime = list()
    for i in range(2, int(math.sqrt(P)) + 1):
        if P % i == 0:
            c = 0
            while P % i == 0:
                P //= i
                c += 1
            
            prime.append([i, c])
        else:
            continue

    if P != 1:
        prime.append([P, 1])

    return prime
def main2():
    N, P = map(int, input().split())

    prime = prime_factorize(P)
    ans = 1
    for p in prime:
        n, c = p
        ans *= (n ** (c // N)) 

    print(ans)

if __name__ == "__main__":
    main2()

Measured memory_bytes: 9196