akhauriyash/Code-Regression huggingface dataset:
def fact(n)
    $fact_table ||= Array.new(n+1)
    return $fact_table[n] if $fact_table[n]
    if n <= 1
        ans = 1
    else
        ans = n * fact(n - 1)
    end
    $fact_table[n] = ans
    return ans
end

def comb(n, k)
    return 0 if n < k
    return fact(n) / fact(k) / fact(n - k)
end


N, A, B = gets.split.map(&:to_i)
vs = gets.split.map(&:to_i).sort.reverse

average = vs[0...A].inject(:+) / A.to_f

if A < N && vs[A] == average
    fixed = vs.count{|v| v > average}
    rest = (A - fixed)..(B - fixed)
    cand = vs.count(average.to_i)
    sum = 0
    rest.each do |i|
        sum += comb(cand, i)
    end
elsif A < N && vs[A - 1] == vs[A]
    fixed = vs.count{|v| v > vs[A]}
    rest = A - fixed
    cand = vs.count(vs[A])
    sum = comb(cand, rest)
else
    sum = 1
end

puts sprintf("%f", average)
puts sum

Measured memory_bytes: 1788
#include <iostream>
using namespace std;
int main()
{
	int n ,y;
	cin >> n >> y;
	for (int a = 0; a <= n; a++)
	{
		for (int b = 0; b <= n; b++)
		{
			int c = y - ((a * 10000) + (b * 5000));
			if (c < 0) {
				continue;
			}
			c /= 1000;
			if ((a + b + c) == n)
			{
				cout << a << " " << b << " " << c << endl;
				return 0;
			}

		}
	}
	cout << "-1 -1 -1" << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;

signed main(){
  int n;
  cin>>n;
  int a=0,b=0;
  bool f=true;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    if(s=="A")a++;
    else b++;
    if(a<b)f=false;
  }
  if(a==b&&f)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}



Measured memory_bytes: 3156
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

template<class T, class S>
bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S>
bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}

int main(){
    int N, P; cin >> N >> P;
    string S; cin >> S;
    ll ans = 0;
    if(P == 2){
        REP(i, N){
            if(!((S[i] - '0') % 2)) ans += i+1;
        }
        cout << ans << endl;
        return 0;
    }
    if(P == 5){
        REP(i, N){
            if(!((S[i] - '0') % 5)) ans += i+1;
        }
        cout << ans << endl;
        return 0;
    }
    VI m(N+1); m[N] = 0;
    int keta = 1;
   /* FOR(i, 1, N){
        m[i] = (10*m[i-1] + S[i] - '0') % P;
        if(m[i] < 0) m[i] += P;
    }*/
    VI cnt(P, 0);
    cnt[0] = 1;
    RREP(i, N-1){
        m[i] = (keta*(S[i]-'0') + m[i+1]) % P;
        if(m[i] < 0) m[i] += P;
        ans += cnt[m[i]];
        ++cnt[m[i]];
        keta = 10 * keta % P;
        if(keta < 0) keta += P;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1412
def update(ans, switch, i, prev_i):
    total = i - prev_i
    if (switch - prev_i) % 2 == 0:
        ans[switch - 1] = total // 2
        ans[switch] = total - total // 2
    else:
        ans[switch] = total // 2
        ans[switch - 1] = total - total // 2


s = input()
switch = -1  # RRR...RL...LLL の、'L'に切り替わったindex
prev_c = 'R'  # すぐ左のマスの文字
prev_i = 0  # 現在の区分の左端のindex
ans = [0] * len(s)
for i, c in enumerate(s):
    if prev_c == 'R' and c == 'L':
        switch = i
        prev_c = 'L'
        continue
    if prev_c == 'L' and c == 'R':
        update(ans, switch, i, prev_i)
        prev_i = i
        prev_c = c
update(ans, switch, len(s), prev_i)
print(*ans)


Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int a,b;
	cin>>a>>b;
	cout<<a*(a-1)/2+b*(b-1)/2<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

long long fac[51000], finv[51000], inv[51000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 51000; 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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
/*
int main() {
    // 前処理
    COMinit();

    // 計算例
    cout << COM(100000, 50000) << endl;
}*/

//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
*/

int main(){
    ll N;
    cin >> N;
    ll n;
    vector<ll> num(100001);
    rep(i,N){
        cin >> n;
        num[n]++;
    }
    ll ans = 0;
    for(ll i = 1;i < 100001;i++){
        ans = max(ans,num[i] + num[i-1] + num[i+1]);
    }
    cout << ans << endl;
    //rep(i,10)cout << i << ":" << num[i] << endl;
}
//2 1 1 1 1 0 0 0 1

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

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

  s = '1' + s + '1';

  vector<pair<int, int>> a;
  pair<int, int> handstand;
  handstand.first = 0;
  for(int i=1;i<s.size();i++) {
    if(s[i-1] == '0' && s[i] == '1') handstand.first = i;
    if(s[i-1] == '1' && s[i] == '0') {
      handstand.second = i;
      a.emplace_back(handstand);
      handstand = make_pair(0, 0);
    }
    if(i == s.size()-1) {
      handstand.second = s.size();
      a.emplace_back(handstand);
    }
  }

  int zeroNum = a.size() - 1;
  if(k >= zeroNum) cout << s.size() - 2 << endl;
  else {
    int ans = 0;
    for(int i=0;i<a.size()-k;i++) {
      int candidate = a[k+i].second - a[i].first;
      if(i == 0 || i == a.size()-k-1) candidate--;
      if(candidate > ans) ans = candidate;
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 1016
#include<stdio.h>
int main(){
  int i,j;
  double n,v[51],x=0,y,tmp;
  scanf("%lf",&n);
  for(i=0; i<n; i++){
    scanf("%lf",&v[i]);
  }
  for(i=0; i<n; i++){
    for(j=i+1; j<n; j++){
      if(v[j]<v[i]){
        tmp=v[i];
        v[i]=v[j];
        v[j]=tmp;
      }
    }
  }
  x=(v[0]+v[1])/2;
  for(i=2; i<n; i++){
    y=v[i];
    x=(x+y)/2;
  }
  printf("%lf\n",x);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define PI 3.1415926535897932
#define MOD 1000000007;
using namespace std;
long long GCD(long long A,long long B){
  if(B==0){
    return A;
  }
  else{
    return GCD(B,A%B);
  }
}
long long LCM(long long A,long long B){
  long long g=GCD(A,B);
  return A/g*B;
}
long long num_order(long long X){
  long long ans=0;
  while(true){
    if(X==0){
      break;
    }
    else{
      X/=10;
      ans++;
    }
  }
  return ans;
}
int main() {
  
  int N,K;
  string S;
  cin>>N>>S>>K;
  
  char x=S[K-1];
  
  
  for(int i=0;i<S.size();i++){
    if(S[i]==x){
      cout<<S[i];
    }
    else{
      cout<<'*';
    }
  }
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

vector<int> G[200001];
vector<int> ans[200001];
int g[200001];

int ret[100001];

void solve(int u) {
    for (int v : G[u]) {
        if (g[v] == 1) {
            ans[u].push_back(v);
        }
        else if (g[v] > 1) {
            g[v]--;
        }
    }
    for (int v : ans[u]) {
        solve(v);
    }
    return;
}

void ansf(int u, int prev) {
    ret[u] = prev;
    for (int v : ans[u]) {
        ansf(v, u+1);
    }
    return;
}

int main()
{
    int N, M;
    cin >> N >> M;

    rep(i, N - 1 + M) {
        int A, B;
        cin >> A >> B;
        A--; B--;
        G[A].push_back(B);
        g[B]++;
    }

    // 根を探す
    int root;
    rep(i, N) {
        if (g[i] == 0) {
            root = i;
            break;
        }
    }

    solve(root);
    ansf(root, 0);
    rep(i, N) cout << ret[i] << endl;

    return 0;
}


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

int main() {
  long A, B, C, D;
  cin >> A >> B >> C >> D;
  long CC, DD;
  CC = C;
  DD = D;
  A--;
  
  long r, x, tmp;
  x = C * D;
 
  /* 自然数 a > b を確認・入替 */
  if(C < D){
    tmp = C;
    C = D;
    D = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = C % D;
  while(r != 0){
    C = D;
    D = r;
    r = C % D;
  }
  
  long kobai = x/D;  
  long num_C, num_D, num_kobai;
  
  num_C = B/CC - A/CC;
  num_D = B/DD - A/DD;
  num_kobai = B/kobai - A/kobai;
  cout << B - A - num_C - num_D + num_kobai << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n,d;
  cin >> n >> d;
  int w = 2*d+1;
  cout << (n+w-1)/w << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        s: String
    };
    println!(
        "{}",
        s.split("S")
            .collect::<Vec<_>>()
            .iter()
            .map(|s| s.len())
            .max()
            .unwrap()
    );
}


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

const int MAX_N = 100004;
const int INF = 1<<24;

namespace RMQ {
  int n, dat[4*MAX_N-1];
  void init() {
    n = 1;
    while(n < MAX_N) n *= 2;
    for(int i = 0; i < 2*n-1; ++i) dat[i] = 0;
  }
  void update(int k, int a) {
    k += n-1;
    int d = a - dat[k];
    dat[k] = a;
    while(k > 0) {
      k = (k - 1) / 2;
      dat[k] += d;
    }
  }

  int query(int a, int b, int k, int l, int r) {
    if(r <= a || b <= l) return 0;
    if(a <= l && r <= b) return dat[k];
    else {
      return query(a, b, k*2+1, l, (l + r) / 2)
	+ query(a, b, k*2+2, (l + r) / 2, r);
    }
  }
}

int main() {
  int n, m;
  while(cin >> n >> m) {
    RMQ::init();
    for(int i = 0; i < n-1; ++i) {
      int a;
      cin >> a;
      RMQ::update(i, a);
    }
    int cost = 0;
    int p = 0;
    for(int i = 0; i < m; ++i) {
      int to;
      cin >> to;
      to += p;
      int l, r;
      l = min(p, to);
      r = max(p, to);
      cost += RMQ::query(l, r, 0, 0, RMQ::n);
      cost %= 100000;
      p = to;
    }
    cout << cost << endl;
  }
}

Measured memory_bytes: 1900
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N = int(input())

    def num_divisors_table(n):
        table = [0] * (n + 1)
        for i in range(1, n + 1):
            for j in range(i, n + 1, i):
                table[j] += 1
        
        return table

    print(sum(num_divisors_table(N-1)))

if __name__ == "__main__":
    main()

Measured memory_bytes: 75640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[][]G = new int[N][N];
		for(int i = 0; i < M; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			G[a][b]++;
			G[b][a]++;
		}
		sc.close();
		for(int i = 0; i < N; i++) {
			int cnt = 0;
			for(int j = 0; j < N; j++) {
				cnt += G[i][j];
			}
			System.out.println(cnt);
		}
	}
}

Measured memory_bytes: 23124
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	if n == 2 {
		fmt.Println(a[1] - a[0])
	} else {
		c1 := abs(a[0] - a[1])
		c2 := 0
		for i := 2; i < n; i++ {
			c1, c2 = min(c1+abs(a[i-1]-a[i]), c2+abs(a[i-2]-a[i])), c1
		}
		fmt.Println(c1)
	}
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

func min(x, y int) int {
	if x >= y {
		return y
	} else {
		return x
	}
}

Measured memory_bytes: 5504
//
//  main.cpp
//  ProCon
//
//  Created by hashimotoryoma on 2017/08/20.
//  Copyright © 2017年 hashimotoryoma. All rights reserved.
//


#include <iostream>
#include <fstream>
#include <algorithm>

using namespace std;

typedef long long ll;

int N;
ll C;
ll x[112345],v[112345];
ll vsum[112345];
ll ans;
ll f[112345];

int main() {
    // insert code here...    return 0;
  //////
    // input from txt
    /*
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
    std::ofstream out("output.txt");
    std::cout.rdbuf(out.rdbuf());
   ///////
     */
    cin >> N >> C;
    for(int i=1;i<=N;i++){
        cin >> x[i] >> v[i];
        vsum[i] = vsum[i-1] + v[i];
        f[i] = max(f[i-1],vsum[i]-x[i]);
    }
    x[N+1] = C;
    for(int i=N+1;i>=1;i--){
        ans = max(ans,(vsum[N]-vsum[i-1])-2*(C-x[i])+f[i-1]);
    }
    
    for(int i=N;i>=1;i--){
        f[i] = max(f[i+1],(vsum[N]-vsum[i-1])-(C-x[i]));
    }
    for(int i=0;i<=N;i++){
        ans = max(ans,vsum[i]-2*x[i]+f[i+1]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const int MAX_N=2e5+3;


const unsigned long long B=1e12+7;

LL MOD=1000000007;
int main(){
    string S;cin>>S;
    bool flag=true;
    if(SZ(S)%2==1)flag=false;
    for(int i=0;i<SZ(S)-1;i+=2){
        if(!(S[i]=='h'&&S[i+1]=='i'))flag=false;
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
N, A, B, C, D = map(int, input().split())
S = input()
if C < D:
    if S[A-1:C].count('##') > 0 or S[B-1:D].count('##') > 0:
        print('No')
    else:
        print('Yes')
else:
    if S[A-1:C].count('##') == 0 and S[B-2:D+1].count('...') > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3572
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

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

static const double eps = 10e-6;

int diagLLUR(int n,int** mat){
	int res = 0;
	for(int y=0;y<n;y++){
		int c = 0;
		for(int x=0,dy=y;x<n && dy>=0;x++,dy--){
			if(mat[dy][x] == 0) { res = max(res,c); c = 0; }
			else c++;
		}
		res = max(c,res);
	}

	for(int x=0;x<n;x++){
		int c=0;
		for(int dx=x,y=n-1;dx<n && y>=0;dx++,y--){
			if(mat[y][dx] == 0) { res = max(res,c); c = 0; }
			else c++;
		}
		res = max(c,res);
	}

	return res;
}

int diagULLR(int n,int** mat){
	int res = 0;
	for(int x=n-1;x>=0;x--){
		int c=0;
		for(int dx=x,y=0;dx<n && y<n;dx++,y++){
			if(mat[y][dx] == 0) { res = max(res,c); c = 0; }
			else c++;
		}
		res = max(c,res);
	}

	for(int y=0;y<n;y++){
		int c = 0;
		for(int x=0,dy=y;x<n && dy<n;x++,dy++){
			if(mat[dy][x] == 0) { res = max(res,c); c = 0; }
			else c++;
		}
		res = max(c,res);
	}

	return res;
}

int vert(int n,int** mat){
	int res = 0;
	for(int x=0;x<n;x++){
		int c=0;
		for(int y=0;y<n;y++){
			if(mat[y][x] == 0) { res = max(res,c); c = 0; }
			else c++;
		}

		res = max(c,res);
	}

	return res;
}

int hori(int n,int** mat){
	int res = 0;
	for(int y=0;y<n;y++){
		int c=0;
		for(int x=0;x<n;x++){
			if(mat[y][x] == 0) { res = max(res,c); c = 0; }
			else c++;
		}

		res = max(c,res);
	}

	return res;
}

int main(){

	int n;	

	while(~scanf("%d",&n)){
		if(n==0) break;

		int** mat = new int*[n];
		for(int i=0;i<n;i++) mat[i] = new int[n]();

		for(int y=0;y<n;y++){
			char buf[512];
			scanf("%s",buf);
			for(int x=0;x<n;x++){
				mat[y][x] = buf[x]-'0';
			}
		}

		printf("%d\n",max(max(diagLLUR(n,mat),hori(n,mat)),max(diagULLR(n,mat),vert(n,mat))));

		for(int i=0;i<n;i++) delete[] mat[i];
		delete[] mat;
	}
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
#define mod 1000000007
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define setA0(a) for(ull i =0;i<n;i++){a[i] = 0;}
#define aout(a) for(auto x : a){cout<<x<<' ';} 
#define ain(a) for(ull i =0;i<n;i++){cin>>a[i];}
#define NofSetBits(x) __builtin_popcount(x);
#define InpGrph(g,e) while(e--){ll x;ll y;cin>>x>>y ;g[x].pub(y);g[y].pub(x);}
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);







int main(){
  FastIO;
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<max(max(a*c,a*d),max(b*c,b*d));
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const int NS = 1e5 + 100;
ll N, m, a[NS];
typedef pair <ll, ll> cn;
std::vector<cn> z;

void bp() {
}

bool cmp(cn a, cn b) {
	return a.second < b.second;
}
int main() {
	ll sum = 0;
	//std::vector<cn> z;
	cin >> N >> m;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	sort(a, a + N);
	for (int i = 0; i < m; ++i) {
		cn a;
		cin >> a.first >> a.second;
		z.push_back(a);
	}
	//sort(z.begin(), z.end(), cmp);
	std::sort(z.begin(), z.end(), [](const cn &p1, const cn &p2) {
			return p1.second < p2.second;
			});
	int i = 0;
	for (; i < N; ++i) {
		cn t = z.back();
		if (a[i] >= t.second) { break; }
		sum += t.second;
		if (t.first == 1) {
			z.pop_back();
			if (z.size() == 0) {
				++i;
				break;
			}
			continue;
		}
		z.pop_back();
		t.first -= 1;
		z.push_back(t);
	}
	for (;i < N; ++i) {
		sum += a[i];
	}
	cout << sum;
	return 0;
}


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

#define int long long
#define double long double
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int) (x).size())
#define fr first
#define sc second
typedef long long ll;
typedef pair<int,int> pii;

void solve() {
    int k;
    cin >> k;
    queue<int> q;
    for (int i = 1; i < 10; ++i) {
        q.push(i);
    }
    vector<int> a;
    while (!q.empty()) {
        int cur = q.front();
        q.pop();
        a.push_back(cur);
        if (cur * 10 <= 3234566667) {
            int rem = cur % 10;
            if (rem > 0) {
                q.push(cur * 10 + rem - 1);
            }
            q.push(cur * 10 + rem);
            if (rem < 9) {
                q.push(cur * 10 + rem + 1);
            }
        }
    }
    sort(all(a));
    cout << a[k - 1] << endl;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef DK
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    while (cin.peek() != EOF) {
        solve();
        cout << endl << endl;
        string s("#");
        do getline(cin, s);
        while (!cin.eof() && !s.empty());
        while (isspace(cin.peek())) cin.get();
    }
#else
    solve();
#endif
    return 0;
}


Measured memory_bytes: 1784
#include<bits/stdc++.h>
#define lowbit(x) ((x)&(-x))
using namespace std;
typedef long long LL;

const int maxn = 1000009;
int a[maxn], x[maxn];
LL s1[maxn], s2[maxn], pre, res;
int n, m, cnt, last;

inline int read(){
	char ch = getchar(); int x = 0;
	while (ch < '0' || '9' < ch) ch = getchar();
	while ('0' <= ch && ch <= '9') { x = x*10 + ch-'0'; ch = getchar(); }
	return x;
}

int del(){
	int m = 0;
	for (int i=1; i<=n; i++)
		if (i == 1 || x[i] != x[m]) x[++m] = x[i];
	return m;
}

int search(int k){
	int l = 1, r = m, mid;
	while (l < r){
		mid = (l+r) >> 1;
		if (k <= x[mid]) r = mid;
		else l = mid+1;
	}
	return l;
}

void update(LL s[], int x, int y){
	for (; x<=m; x+=lowbit(x)) s[x] += y;
}

LL query(LL s[], int x){
	LL res = 0; for (; x; x-=lowbit(x)) res += s[x]; return res;
}

int main(){
	n = read();
	for (int i=1; i<=n; i++)
		x[i] = a[i] = read();
	sort(x+1, x+n+1); m = del();
	for (int i=1; i<=n; i++){
		a[i] = search(a[i]);
		update(s1, a[i], 1);
		update(s2, a[i], x[a[i]]);
	}
	pre = last = 0;
	for (int i=1; i<=n; i++)
		if (a[last] < a[i]){
			res = query(s2, a[i]) + 1LL*(n-query(s1, a[i]))*x[a[i]];
			printf("%lld\n", res-pre);
			last = i; pre = res;
		}
		else puts("0");
	return 0;
}

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

ll h;
map<ll,ll> mem;
ll INF = 1e15;

ll dp(ll h){
  if(h==1){
    return 1;
  }
  else if(mem[h]!=0){
    return mem[h];
  }
  else{
    ll res1 = dp(h/2);
    ll res2 = dp(h/2);
    ll res = res1 + res2 + 1;
    mem[h]=res;
    return res;
  }
}

int main(){
  cin >> h;
  ll res = dp(h);
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include<bits/stdc++.h>
#define ll long long
#define read freopen("input/test (4).txt","r",stdin)
#define write freopen("output/test (4).txt","w",stdout)
#define fr first
#define sc second
#include <sstream>
#define ii pair < int , int >
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int a[k];
    for(int i=0;i<k;i++)
        cin>>a[i];
    while(n)
    {
        int temp = n,yes = 1;
        while(temp > 0)
        {
            for(int i=0;i<k;i++)
                if(a[i] == temp%10)
                  yes = 0;
            temp = temp/10;
        }
        if(yes)
        {
            cout<<n;
            return 0;
        }
        n++;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        vll A(N);

        rep(i, 0, N)  cin >> A[i];

        ll mcnt = 0;
        rep(i, 0, N) {
                if (A[i] < 0) ++mcnt;
        }

        vll pos(N);
        rep(i, 0, N) {
                if (A[i] < 0) {
                        pos[i] = -A[i];
                } else {
                        pos[i] = A[i];
                }
        }
        sort(pos.rbegin(), pos.rend());

        if (even(mcnt)) {
                cout << accumulate(all(pos), 0LL) << endl;
        } else {
                cout << accumulate(all(pos), 0LL) - 2 * pos.back() << endl;
        }
}

Measured memory_bytes: 4800
def adjacent4(n , a):

    ans = "No"
    zero = 0
    iti = 0
    ni = 0

    for i in range(n):
        if a[i] % 2 == 1:
            zero += 1
        elif (a[i] / 2) % 2 == 0:
            ni += 1
        else:
            iti += 1

    if iti > 0 and zero <= ni:
        ans = "Yes"
    elif iti == 0 and zero <= ni + 1:
        ans = "Yes"
    return ans

def main():
    n = int(input())
    a = list(map(int,input().split()))
    print(adjacent4(n , a))

if __name__ == '__main__':
    main()

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

# 全結合netから一部を消すとうまくいく
# N:evenだと 1,2,3,4,5,6 なら、(1,6)(2,5)などのペアを消す
# N:odd だと 1,2,3,4,5 なら5を残して、(1,4)(2,3)のペアを消す

S = set()
for i in range(1,N):
  for j in range(i+1,N+1):
    S.add((i,j))
    
#print(S)
if N%2 == 0:
  for i in range(1,N+1):
    if i >= N-i+1:
      break
    S.remove((i,N-i+1))
    #print(i,N-i+1)
else:
  for i in range(1,N):
    if i >= N-i:
      break
    S.remove((i,N-i))
    #print(i,N-i+1)
print(len(S))
for item in S:
  print(" ".join(list(map(str, item))))
  

Measured memory_bytes: 3736
import java.io.*;

public class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		String s,t;
		String[] u;
		double[] q;
		double l,p;
		double xa,ya,ra,xb,yb,rb;
		int n;
		int[] ans;
		while((s=reader.readLine())!=null){
			n=Integer.parseInt(s);
			ans=new int[n];
			for(int i=0;i<n;i++){
				t=reader.readLine();
				u=t.split(" ");
				q=new double[6];
				for(int k=0;k<6;k++){
					q[k]=Double.parseDouble(u[k]);
				}
				xa=q[0];
				ya=q[1];
				ra=q[2];
				xb=q[3];
				yb=q[4];
				rb=q[5];
				l=Math.sqrt((xb-xa)*(xb-xa)+(yb-ya)*(yb-ya));
				if(ra<rb){p=rb-ra;}
				else{p=ra-rb;}
				if((ra+rb)<l){
					ans[i]=0;
				}else if(p<=l &&l<=(ra+rb)){
					ans[i]=1;
				}else if(ra>rb){
					ans[i]=2;
				}else{
					ans[i]=-2;
				}
				System.out.println(ans[i]);
			}
		}
	}
}

Measured memory_bytes: 16924
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
const ll inf=1e18;
const int N=2e5+5;
int n,m,i,x,y;ll ad,f[N],ans;
ll f1[N],f2[N];
int read(){
	char c=getchar();int k=0;for (;c<48||c>57;c=getchar());
	for (;c>47&&c<58;c=getchar()) k=(k<<3)+(k<<1)+c-48;return k;
}
void add1(int x,ll k){for (;x<=n&&k<f1[x];x+=x&-x) f1[x]=k;}
ll ask1(int x){ll k=inf;for (;x;x-=x&-x) k=min(k,f1[x]);return k;}
void add2(int x,ll k){for (;x&&k<f2[x];x-=x&-x) f2[x]=k;}
ll ask2(int x){ll k=inf;for (;x<=n;x+=x&-x) k=min(k,f2[x]);return k;}
void solve(){
	y=x;x=read();
	ll v=min(ask1(x)+x,ask2(x)-x)+ad;
	ad+=abs(x-y);
	if (v<f[y]+ad)
		f[y]=v-ad,add1(y,f[y]-y),add2(y,f[y]+y);
	
}
int main(){
	n=read();m=read();x=read();y=read();
	for (i=1;i<=n;i++) f[i]=f1[i]=f2[i]=inf;
	for (f[y]=0,add1(y,-y),add2(y,y);m--;) solve();
	for (ans=inf,i=1;i<=n;i++) ans=min(ans,f[i]);
	printf("%lld",ans+ad);
}

Measured memory_bytes: 4864
<?php

$rect = 0;
$dia = 0;
while($line = fgets(STDIN)){
	$arr = explode(",", $line);
	$l1 = intval($arr[0]);
	$l2 = intval($arr[1]);
	$r = intval($arr[2]);
	if($l1 == $l2){
		// ひし形
		$dia++;
	}else if($l1*$l1 + $l2*$l2 == $r*$r){
		// 長方形
		$rect++;
	}
}

echo $rect."\n";
echo $dia."\n";

Measured memory_bytes: 15124
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val c = Array(10) { IntArray(10) }
    for (i in 1..N) {
        val str = i.toString()
        val head = str.first() - '0'
        val tail = str.last() - '0'
        c[head][tail]++
    }
    var cnt = 0
    (0..9).forEach { i ->
        (0..9).forEach { j ->
            cnt += c[i][j] * c[j][i]
        }
    }
    println(cnt)
}

Measured memory_bytes: 36524
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = (1LL<<60);
ll N,X;

ll px[200005];
ll sx[200005];

int main(){
  cin>>N>>X;
  for(int i=0;i<N;i++){
    cin>>px[i];
    
    sx[i]=px[i];
    if(i)sx[i]+=sx[i-1];
    
  }
  
  ll ans=INF;
  for(int i=1;i<=N;i++){
    
    ll tmp=N*X+i*X;
    
    ll cc=0;
    for(int j=N-1;j>=0;j-=i){
      cc++;
      ll cx=5;
      if(cc>1)cx=2*cc+1;

      ll sum=sx[j];
      if(j-i>=0)sum-=sx[j-i];

      
      ll value = ( sum  < INF/cx ? sum*cx : INF );
      
      tmp += value;
      if( tmp > INF ) tmp = INF;
      
    }

    ans=min(ans,tmp);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
long long k;
int main()
{
    cin>>k;
    queue<long long> q;
  for(int i=1; i<10; i++){
    q.push(i);
  }
  while(!q.empty()){
    long x = q.front();
    q.pop();
    k--;
    if(k==0){
      cout << x << endl;
      break;
    }
    for(int y=x%10-1;y <= x%10+1; y++){
      if(y==-1)continue;
      else if(y==10)continue;
      q.push(10*x+y);
    }
  }

}

Measured memory_bytes: 1792
#! python3
# finding_missing_cards.py

cards = {mark: [] for mark in ['S', 'H', 'C', 'D']}

n = int(input())
for i in range(n):
    mark, num = [x for x in input().split(' ')]
    cards[mark].append(int(num))

for k, v in cards.items():
    for i in range(1, 14):
        if i not in v:
            print(k, i)



Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
int main() 
{
    ll n;
    cin>>n;
    string ans="";
    while(n)
    {
    	ll k = n/26;
    	ll rem = n%26;
    	if(rem == 0)
    	{
    		--k;
    		ans = 'z' + ans;
    	}
    	else{
    		ans = (char) ('a'+rem-1) + ans;
    	}
    	n = k;
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <sstream>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cmath>

#define ALL(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define each(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)

using namespace std;

typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef long long LINT;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef ostringstream OSS;
typedef vector<string> VS;

const int INF = 1 << 29;
const int MAX_WH = 30;
const int MAX_D = 4;

struct robot {
	int x, y, dir;
	robot ( int ix, int iy, int id ) : x(ix), y(iy), dir(id) {}
};
enum { R, D, L, U };
int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };

typedef vector<VVI> VVVI;

int main ( void )
{
	int w, h;
	while (cin >> w >> h, w|h) {
		VVI cmd(h, VI(w));
		for (int i = 0; i < h; ++i) {
			for (int j = 0; j < w; ++j) {
				cin >> cmd[i][j];
			}
		}
		VI changeCost(MAX_D);
		for (int i = 0; i < MAX_D; ++i) {
			cin >> changeCost[i];
		}
		VVVI mc(MAX_D, VVI(h, VI(w, INF)));
		queue<robot> que;
		que.push(robot(0, 0, R));
		mc[R][0][0] = 0;
		while (!que.empty()) {
			robot p = que.front(); que.pop();
			for (int d = 0; d < MAX_D; ++d) {
				int todir = (p.dir + d) % MAX_D;
				int mx = p.x + dx[todir];
				int my = p.y + dy[todir];
				if (mx < 0 || w <= mx || my < 0 || h <= my) { continue; }
				int cost = mc[p.dir][p.y][p.x] + (cmd[p.y][p.x] == d ? 0 : changeCost[d]);
				if (mc[todir][my][mx] > cost) {
					mc[todir][my][mx] = cost;
					que.push(robot(mx, my, todir));
				}
			}
		}
		int ans = INF;
		for (int i = 0; i < MAX_D; ++i) {
			ans = min(ans, mc[i][h-1][w-1]);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define BR "\n"
#define SP " "

int main() {
  ll M, F, R;
  string rate;

  while (1) {
    cin >> M >> F >> R;

    if (M == -1 && F == -1 && R == -1) break;
    if (M == -1 || F == -1) {
      rate = "F";
    } else if (M + F >= 80) {
      rate = "A";
    } else if (M + F >= 65) {
      rate = "B";
    } else if (M + F >= 50) {
      rate = "C";
    } else if (M + F >= 30) {
      if (R >= 50) {
        rate = "C";
      } else {
        rate = "D";
      }
    } else {
      rate = "F";
    }
    cout << rate << BR;
  }

  return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  int N;
  cin >> N;
  //いもす！！
  vector<int> P(1000, 0);

  for(int i = 0; i < N; i++) {
    int s, e;
    cin >> s >> e;
    P[s]++;
    P[e]--;
  }
  //るいせきわ(=いたにんずう) 1たしてつかう
  vector<int> S(1001);
  S[0] = 0;
  for(int i = 0; i < 1000; i++) {
    S[i + 1] = S[i] + P[i];
    // cout << "S" << i + 1 << ": " << S[i + 1] << endl;
  }
  bool flag = true;
  for(int i = a; i < b; i++) {
    // cout << "i: " << i;
    // cout << "S[i + 1]" << S[i + 1] << endl;
    if(S[i + 1] > 0) {
      flag = false;
      break;
    }
  }

  if(flag)
    cout << 0 << endl;
  else
    cout << 1 << endl;

  return 0;
}


Measured memory_bytes: 3168
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
template<class T>bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if (b<a){a=b;return 1;}return 0;}
// clang-format on

void solve(long long N) { cout << (double)((N + 1) / 2) / N << endl; }

int main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


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

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

using ll = long long;
using P = pair<int, int>;

const int mod = 998244353;

int main(int, char**)
{
    int x , y;
    cin >> x >> y;
    int d = y - 2*x;
    if (d<0 || d%2 != 0 || d/2>x) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3640
def solve():
    a,b,c,x,y = map(int, input().split())
    z = [a*x + b*y, c*2*x + b*max(0,y-x), c*2*y + a*max(0,x-y), c*2*max(x,y)]
    return min(z)
        
if __name__ == '__main__':
    print(solve())

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main()
{
	int n,max=0,tmp,sum=0;
	cin >> n;
	int p[n];
	for(int i=0;i<n;i++){
		cin >> p[i];
	}
	
	for(int j=0;j<n;j++){
		if(p[j] > max){
			max = p[j];
			tmp = j;
		}
	}
	
	for(int k=0;k<n;k++){
		if(k == tmp){sum += max/2;}
		else{sum += p[k];}
	}
	
	cout << sum <<endl;
	return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define For(i,m,n) for(int i=m;i<n;i++)
#define ll long long
#define l long
#define all(x) x.begin(),x.end()
#define pb push_back
#define len(x) x.len
int main()
{int x,y;
cin>>x>>y;
for(int i=0;i<=100;i++)
{
    for(int j=0;j<=100;j++)
    {
        if(i+j==x&&(2*i+4*j)==y){cout<<"Yes";goto end;}
    }
}
cout<<"No";
end:;


return 0;}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int vec[n];
  map<int,int> ma;
  for(int i=0;i<n;i++){
    cin>>vec[i];
    ma[vec[i]]++;
  }
  if(ma[1]>0){
    if(ma[1]==1){
      cout<<1<<endl;
      return 0;
    }
    cout<<0<<endl;
    return 0;
  }
  sort(vec,vec+n);
  int ans=0;
  int p;
  for(int i=0;i<n;i++){
    p=0;
    if(ma[vec[i]]>1){
      continue;
    }
    if(i<sqrt(vec[i])){
      for(int j=0;j<i;j++){
        if(vec[i]%vec[j]==0){
          p++;
          break;
        }
      }
    }
    else{
      for(int j=2;j*j<=vec[i];j++){
      if(vec[i]%j==0){
        if(ma[j]>0||ma[vec[i]/j]>0){
          p++;
          break;
        }
      }
    }
    }
    if(p==0){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 33140
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <deque>
#include <set>
#include <numeric>
using namespace std;
using ll = long long;

#define no "no"
#define No "No"
#define NO "NO"
#define yes "yes"
#define Yes "Yes"
#define YES "YES"
#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return (0)
#define rep(i, n) for (int(i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for (int(i) = (start); (i) < (end); (++i))
#define foreach(elem, _list) for (auto &(elem) : (_list))
#define view(_list)      \
    foreach (e, _list)   \
    {                    \
        cout << e << sp; \
    }                    \
    cout << next
#define FAST                     \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr)
#define size(s) (s).size()
#define ALL(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e)
#define INF 1e+9
#define PI acos(-1)
#define TAU PI * 2
#define EPS 0.00000001
const ll MOD = 1000000007;

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

    ll n = 100;
    ll year = 0;
    while(true){
        n += floor(n / 100);
        year++;
        if(n >= x){
            break;
        }
    }

    println(year);
}


Measured memory_bytes: 3600
#include <stdio.h>
int main(void){
int x,y,z;

scanf("%d%d%d", &x,&y,&z);

int p = 0;
if (x==y&& y!= z)p=1;
if(y==z&& z!= x)p =1;
if (z==x&& x!= y)p =1;

if (p) {
puts("Yes");
} else {
puts("No");
}
return 0;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int,input().split()))
l.sort()
#print(l)
cnt = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        if l[i]!=l[j]:
            for k in range(j+1,n):
                if l[j]!=l[k]:
                    if l[i]+l[j]>l[k]:
                        cnt += 1
print(cnt)

Measured memory_bytes: 9192
let _ = readInt()
let An = readInts()
let all = An.reduce(0, ^)
for a in An {
    print(all ^ a, terminator: " ")
}
print()

// MARK: -----------------------------------------------------------------------


func readInt() -> Int {
    Int(readLine()!)!
}

func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}

extension Collection {
    func mapToTuple() -> (Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!, i.next()!)
    }
}

struct DP<Argument: Hashable, Element> {
    var dictionary = [Argument: Element]()
    
    var expression: (Argument, (Argument) -> Element) -> Element
    
    init(expression: @escaping (_ argument: Argument, _ note: (Argument) -> Element) -> Element) {
        self.expression = expression
    }
    
    subscript(_ argument: Argument) -> Element {
        mutating get {
            if let note = dictionary[argument] {
                return note
            } else {
                let result = expression(argument) { self[$0] }
                dictionary[argument] = result
                return result
            }
        }
    }
}


Measured memory_bytes: 21468
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,count=0;
    cin>>n;
    long long int a[n];
    for(long long int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;i++)
    {
       if(a[i]==a[i+1])
       {
        count++;
        break;
       }
    }
    if(count==0)
    {
        cout<<"YES";
    }
    else
        cout<<"NO";
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define PII pair<int, int>
#define LL long long
using namespace std;
const int MAXN = 200005;
const LL INF = (LL)1e9 + 5;
const LL MOD = 1000000007;

#define val first
#define id second

int N, cnt[MAXN];
int x[MAXN], y[MAXN];
PII ord[MAXN*2];

LL test1() {
	if (N == 1) return 0;
	
	int l = 1, r = 1, cover = 0, res = INF;
	while (l < 2 * N - 1) {
		while (r < 2 * N - 1 && cover < N) {
			cnt[ord[r].id]++;
			if (cnt[ord[r].id] == 1) cover++;
			r++;
		}
		if (cover == N) {
			if (ord[r - 1].id != ord[l].id) {
				res = min(res, ord[r - 1].val - ord[l].val);
//				cout << "At " << l << ' ' << r << " get " << ord[l].val << ' ' << ord[r - 1].val << '\n';
			}
		}
		
		cnt[ord[l].id]--;
		if (cnt[ord[l].id] == 0) cover--;
		l++;
	}
	return (LL) res * (ord[2 * N - 1].val - ord[0].val);
}

LL test2() {
	if (N == 1) return 0;
	
	int mi = INF, ma = -INF;
	for (int i = 0; i < N; i++) {
		ma = max(ma, x[i]);
		mi = min(mi, y[i]);
	}
	return (LL) (ma - ord[0].val) * (ord[2 * N - 1].val - mi);
}

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

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i];
		if (x[i] > y[i]) swap(x[i], y[i]);
		ord[i << 1] = {x[i], i};
		ord[i << 1 | 1] = {y[i], i};
	}
	sort(ord, ord + 2 * N);
	
	LL ans = test2();
	if (ord[0].id != ord[2 * N - 1].id) {
		ans = min(ans, test1());
	}
	
	cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 5760
#ABC157.B
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))
N = int(input())
b = [int(input())for _ in range(N)]
if (A1[0] in b)and (A1[1]in b)and (A1[2] in b):
    print('Yes')
elif (A2[0]in b)and(A2[1] in b)and(A2[2]in b):
    print('Yes')
elif (A3[0]in b)and(A3[1]in b)and (A3[2]in b):
    print('Yes')
elif (A1[0]in b)and(A2[0]in b)and(A3[0]in b):
    print('Yes')
elif (A1[1]in b)and (A2[1]in b)and(A3[1]in b):
    print('Yes')
elif (A1[2] in b)and (A2[2]in b)and(A3[2]in b):
    print('Yes')
elif (A1[0]in b)and (A2[1]in b)and(A3[2]in b):
    print('Yes')
elif (A1[2]in b)and (A2[1]in b)and(A3[0]in b):
    print('Yes')
else:
    print('No')

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

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

    int d, r;
    double f;

    d = a / b;
    r = a % b;
    f = a / c;

  printf("%d %d %.8lf\n", d, r, f);
}



Measured memory_bytes: 3212
import sys
sys.setrecursionlimit(10 ** 9)

n = int(input())
LR = [tuple(map(int, input().split())) for _ in range(n)]

def quicksort(x):
    if x==[]: return []

    smallerSorted = quicksort([a for a in x[1:] if a[0] < x[0][0] or (a[0] == x[0][0] and a[1] >= x[0][1])])
    biggerSorted = quicksort([a for a in x[1:] if a[0] > x[0][0] or (a[0] == x[0][0] and a[1] < x[0][1])])

    return(smallerSorted+[x[0]]+biggerSorted)

LR = quicksort(LR)

e = [[] for _ in range(n+2)]

ans = [0] * (n+1)
temp = 10 ** 9
i = 1
for L, R in LR:
    temp = min(temp, R)
    if L > temp:
        break
    ans[i] = temp - L + 1
    i += 1

temp = 10 ** 9
i = n - 1
L = LR[-1][0]
for x, R in reversed(LR):
    temp = min(temp, R)
    if L > temp:
        break
    ans[i] += temp - L + 1
    i -= 1

res = max(ans)
for L, R in LR:
    res = max(res, R - L + 1 + ans[0])

#print(LR)
#print(ans)
print(res)


Measured memory_bytes: 28360
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()

	_, divlist := getDivlistSlow(n)

	minf := 100000 * 100000
	for _, a := range divlist {
		now := f(a, n/a)
		minf = min(minf, now)
	}

	fmt.Println(minf)

}

func f(a int, b int) int {
	return max(keta(a), keta(b))
}

// 約数列挙リストを作成(愚直)
func getDivlistSlow(a int) (cnt int, divlist []int) {
	for i := 1; i*i <= a; i++ {
		if a%i == 0 {
			cnt++
			divlist = append(divlist, i)
			if i*i != a {
				cnt++
				divlist = append(divlist, a/i)
			}
		}
	}
	sort.Ints(divlist) // 昇順ソート
	return cnt, divlist
}
func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// 正数の桁数を返す
func keta(n int) int {
	keta := 0
	if n == 0 {
		return 1
	}
	for n > 0 {
		keta++
		n /= 10
	}
	return keta
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1872
#include <bits/stdc++.h>
#define ll long long
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

signed main()
{
    ll n;
    cin >> n;
    vector<ll> v(n);
    map<ll, ll> mp;
    rep(i, 0, n)
    {
        cin >> v[i];
        mp[v[i]]++;
        // sum += v[i];
    }
    ll sum = accumulate(begin(v), end(v), 0LL);
    ll q;
    cin >> q;
    while(q--)
    {
        ll b, c;
        cin >> b >> c;
        ll cpt = mp[b];
        mp[c] += cpt;
        mp[b] = 0;
        sum -= b * cpt;
        sum += c * cpt;
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 10080