akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.rbegin(),a.rend())
#define lb(a,b) lower_bound(a.begin(),a.end(),b)
#define ub(a,b) upper_bound(a.begin(),a.end(),b)
#define MOD ((int)(1000000007))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double
#define sqrt sqrtl
#define cbrt cbrtl
typedef vector<int> vi;
typedef vector<float> vf;
typedef pair<float,int> fi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<fi> vfi;
typedef vector<vi> vvi;
typedef vector<vf> vvf;
typedef vector<vii> vvii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef priority_queue<fi> pqfi;
typedef priority_queue <int, vector<int>, greater<int> > rpqi; 
typedef priority_queue <ii, vector<ii>, greater<ii> > rpqii; 
typedef priority_queue <fi, vector<fi>, greater<fi> > rpqfi; 

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.rbegin(),a.rend())
#define lb(a,b) lower_bound(a.begin(),a.end(),b)
#define ub(a,b) upper_bound(a.begin(),a.end(),b)
#define MOD ((int)(1000000007))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double
#define sqrt sqrtl
#define cbrt cbrtl
typedef vector<int> vi;
typedef vector<float> vf;
typedef pair<float,int> fi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<fi> vfi;
typedef vector<vi> vvi;
typedef vector<vf> vvf;
typedef vector<vii> vvii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef priority_queue<fi> pqfi;
typedef priority_queue <int, vector<int>, greater<int> > rpqi; 
typedef priority_queue <ii, vector<ii>, greater<ii> > rpqii; 
typedef priority_queue <fi, vector<fi>, greater<fi> > rpqfi; 





int32_t main()
{
	IOS
	int n;cin>>n;
	vi a(n+1),b(n+1);
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=n;i>=1;i--)
	{
		if(a[i]==1)
		{
			int cnt=0;
			for(int j=2;j*i<=n;j++)
			{
				cnt+=b[j*i];
			}
			if(cnt%2==0)b[i]=1;
			else b[i]=0;
		}
		else
		{
			int cnt=0;
			for(int j=2;j*i<=n;j++)
			{
				cnt+=b[j*i];
			}
			if(cnt%2==0)b[i]=0;
			else b[i]=1;
		}	
	}
	
	map<int,int>M;
	for(int i=1;i<=n;i++)
	{
		if(b[i])M[i]++;
	}
	cout<<M.size()<<endl;
	for(auto it:M)
	cout<<it.first<<" ";
	cout<<endl;
	
	
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    queue<pair<ll,ll>> p;
    ll ans=a[0];
    p.push({a[0],a[1]});
    p.push({a[0],a[1]});
    for(int i=2;i<n;++i){
        ll x=p.front().first, y=p.front().second;
        p.pop();
        ans+=y;
        p.push({x,a[i]});
        p.push({y,a[i]});
    }
    cout << ans << "\n";
    return 0;
}   

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

int main(){
  int N;  cin >> N;
  vector<int>result(4);
  for(int i=0;i<N;i++){
    string s;
    cin >> s;
    if(s == "AC") result.at(0)++;
    else if(s == "WA")  result.at(1)++;
    else if(s == "TLE") result.at(2)++;
    else  result.at(3)++;
  }
  cout << "AC x " << result.at(0) << endl;
  cout << "WA x " << result.at(1) << endl;
  cout << "TLE x " << result.at(2) << endl;
  cout << "RE x " << result.at(3) << endl;
}


Measured memory_bytes: 3628
import math

x = int(input())
ans = 1

for i in range(int(math.sqrt(x)), 1, -1):
    tans = i
    while tans <= x:
        tans *= i
        if tans == x:
            print(tans)
            exit()
        else:
            continue
    ans = max(ans, tans//i)

print(ans)

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

#define FOR(x,to) for(int x=0;x<(to);x++)
#define F0R(x,in,to) for(int x=(in);x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))

typedef long long ll;
using namespace std;
ll MOD = 998244353;

typedef pair<int,int> ii;
typedef struct {int a,b,c;}iii;
typedef vector<int> vi;

void mosA(vector<ll> a){
	for(int i=0; i<a.size(); i++) printf("%lld ",a[i]);
	printf("\n");
}
void mosP(vector<ii> a){
	for(int i=0; i<a.size(); i++) printf("%d %d\n",a[i].first,a[i].second);
	printf("\n");
}

ll min_especial(ll a, ll b){
  if(a!=-1 && b!=-1) return min(a,b);
  else return max(a,b);
}
/*
bool ord(ii a, ii b){
	if(a.first == b.first){
		return a.second < b.second;
	}
	return a.first < b.first;
}*/

bool ord(ll a, ll b){
	return a>b;
}

ll ans = 0;
int a,n,w,t,k,m,z,q,l,r,x,b;
int C[200005];
char S[200005];
vector<ii> G[100005];


void dfs(int v, int ant){
	for(auto &x:G[v]){
		if(ant!=x.first){
			if(x.second == 0){
				C[x.first] = C[v];
			} else C[x.first] = (C[v]+1)%2;
			dfs(x.first,v);
		}
	}

}


int main(){
	scanf("%d",&n);
	FOR(i,n-1){
		scanf("%d%d%d",&a,&b,&w);
		w = w%2;
		G[a].pb({b,w});
		G[b].pb({a,w});
	}

	C[1] = 1;
	dfs(1,-1);
	
	F0R(i,1,n+1) printf("%d\n",C[i]);
}




// REVISATE ESTO:
// - memset(A,-1,SIZEOF()*n)
// - (x-y+MOD)%MOD
// - int o ll?

Measured memory_bytes: 8320
#include<cstdio>
#include<algorithm>
int main(){
	int n;
	scanf("%d",&n);
	int c[n]={};
	int s[n]={};
	int t[n]={};
	for(int i=1;i<n;i++){
		scanf("%d%d%d",&c[i], &s[i], &t[i]);
	}
	for(int i=1;i<=n;i++){
		int ans=0;
		for(int j=i;j<n;j++){
			int k=std::max(ans,s[j]);
			ans=((k-1)/t[j]+1)*t[j]+c[j];
		}
		printf("%d\n",ans);
	}
	return 0;
}
		

Measured memory_bytes: 128
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    V<int> x(5);
    for (int i = 0; i < 5; i++) cin >> x[i];
    for (int i = 0; i < 5; i++) {
        if (x[i] == 0) {
            cout << i + 1 << '\n';
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3532
s = input()
t = input()

def solve(S, T):
    L1 = len(S)
    L2 = len(T)
    dp = [[0]*(L2+1) for i in range(L1+1)]

    for i in range(L1-1, -1, -1):
        for j in range(L2-1, -1, -1):
            r = max(dp[i+1][j], dp[i][j+1])
            if S[i] == T[j]:
                r = max(r, dp[i+1][j+1] + 1)
            dp[i][j] = r

    res = []
    i = 0; j = 0
    while i < L1 and j < L2:
        if S[i] == T[j]:
            res.append(S[i])
            i += 1; j += 1
        elif dp[i][j] == dp[i+1][j]:
            i += 1
        elif dp[i][j] == dp[i][j+1]:
            j += 1
    return "".join(res)
print(solve(s, t))

Measured memory_bytes: 112988
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val V = readLine()!!.split(" ").map { it.toInt() }

    val mapForOdd = mutableMapOf<Int, Int>()
    val mapForEven = mutableMapOf<Int, Int>()
    // O(n)
    V.forEachIndexed { index, v ->
        // even
        if (index % 2 == 0) {
            if (!mapForEven.containsKey(v)) {
                mapForEven[v] = 0
            }
            mapForEven[v] = mapForEven[v]!! + 1
        }

        // odd
        if (index % 2 == 1) {
            if (!mapForOdd.containsKey(v)) {
                mapForOdd[v] = 0
            }
            mapForOdd[v] = mapForOdd[v]!! + 1
        }
    }

    // O(n)
    val oddMax = mapForOdd.maxBy { it.value  }!!
    val evenMax = mapForEven.maxBy { it.value  }!!

    var oddRep : Int?
    var evenRep : Int?

    if (oddMax.key == evenMax.key) {
        val even = mapForEven.entries.sortedBy { it.value * - 1 }
        val odd = mapForOdd.entries.sortedBy { it.value * - 1 }

        if (even.map { it.value }.joinToString("") >= odd.map { it.value }.joinToString("")) {
            evenRep = if (even.size == 1) null else even[1].key
            oddRep = oddMax.key
        } else {
            evenRep = evenMax.key
            oddRep = if (odd.size == 1) null else odd[1].key
        }
    } else {
        oddRep = oddMax.key
        evenRep = evenMax.key
    }

    mapForOdd.remove(oddRep)
    mapForEven.remove(evenRep)

    // O(n)
    val ans = mapForOdd.values.sum() + mapForEven.values.sum()
    println(ans)
}


Measured memory_bytes: 58060
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}

	return i
}
func nextStr() string {
	sc.Scan()
	i := sc.Text()

	return i
}
func main() {
	sc.Split(bufio.ScanWords)
	var s string

	var t string
	fmt.Scanf("%s", &s)
	fmt.Scanf("%s", &t)

	a := nextInt()
	b := nextInt()
	u := nextStr()

	//fmt.Println(s, t, a, b, u)

	if u == s {
		fmt.Println(a-1, b)
		//fmt.Printf("suteta: %s", s)
	} else {
		fmt.Println(a, b-1)
		//fmt.Printf("suteta: %s", t)
	}

}


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

int main(void){
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<ll> p(A+1), q(B+1), r(C);
    for (int i = 0; i < A; i++)
        cin >> p[i+1];
    for (int i = 0; i < B; i++)
        cin >> q[i+1];
    for (int i = 0; i < C; i++)
        cin >> r[i];
    p[0] = 1000000001;
    q[0] = 1000000001;
    
    sort(p.begin()+1, p.end(), greater<ll>());
    sort(q.begin()+1, q.end(), greater<ll>());
    sort(r.begin(), r.end(), greater<ll>());
    
    int a_idx = X, b_idx = Y;
    for (int i=0; i < C; i++) {
        if (p[a_idx] > q[b_idx]) {
            if (q[b_idx] < r[i]) {
                q[b_idx] = r[i];
                b_idx--;
            }
            else
                break;
        }
        else {
            if (p[a_idx] < r[i]) {
                p[a_idx] = r[i];
                a_idx--;
            }
            else
                break;
        }
    }
    
    ll ans = 0;
    for (int i = 1; i <= X; i++)
        ans += p[i];
    for (int i = 1; i <= Y; i++)
        ans += q[i];
    cout << ans;
}

Measured memory_bytes: 2560
use std::fmt;
use std::io::stdin;
use std::io::BufRead;
use std::str;
use std::str::FromStr;

fn main() {
    let stdin = stdin();
    let mut scan = InputScanner::new(stdin.lock(),256);

    let n:usize = scan.next();
    let p:Vec<usize> = (0..(n-1)).map(|_| scan.next::<usize>()-1).collect();
    let x:Vec<usize> = (0..n).map(|_| scan.next()).collect();

    let mut tree:Vec<Vec<usize>> = Vec::with_capacity(n);
    tree.resize(n,Vec::new());

    for i in 0..(n-1) {
        tree[p[i]].push(i+1);
    }

    if search(0,n,&tree,&x).is_some() {
        println!("POSSIBLE");
    } else {
        println!("IMPOSSIBLE");
    }
}
fn search(i:usize,n:usize,tree:&Vec<Vec<usize>>,x:&Vec<usize>) -> Option<(usize,usize)> {
    let sub_tree = &tree[i];

    if sub_tree.is_empty() {
        Some((x[i],0))
    } else {
        let mut children = Vec::with_capacity(sub_tree.len());

        let mut sw = 0;
        let mut sb = 0;

        for &j in sub_tree {
            let child = search(j,n,tree,x)?;
            let &(w,b) = &child;
            children.push(child);
            sw += w;
            sb += b;
        }

        let sum = sw + sb;

        if x[i] == 0 {
            if sw == 0 {
                return Some((0, sb));
            } else {
                return Some((0, sw));
            }
        }

        let mut dp:Vec<bool> = (0..(x[i]+1)).map(|_| false).collect();

        dp[0] = true;

        for child in &children {
            let prev = dp;
            dp = (0..(x[i]+1)).map(|_| false).collect();

            let &(w,b) = child;

            for j in 0..(x[i]+1) {
                if w <= j {
                    dp[j] |= prev[j-w];
                }

                if b <= j {
                    dp[j] |= prev[j-b];
                }
            }

            if w > 0 && b > 0 {
                dp[0] = false;
            }
        }

        for j in (0..(x[i] + 1)).rev() {
            if dp[j] {
                return Some((x[i],sum - j))
            }
        }

        None
    }
}
struct InputScanner<R: BufRead> {
	reader: R,
	buf: Vec<u8>, // Should never be empty
	pos: usize,   // Should never be out of bounds as long as the input ends with '\n'
}
impl<R: BufRead> InputScanner<R> {
	fn new(reader: R, capacity: usize) -> Self {
		InputScanner {
			reader: reader,
			buf: Vec::with_capacity(capacity),
			pos: 0,
		}
	}

	#[inline]
	fn next<T: FromStr>(&mut self) -> T
	where
		T::Err: fmt::Debug,
	{
		if self.buf.is_empty() {
			self._read_next_line();
		}
		let mut start = None;
		loop {
			match (self.buf[self.pos], start.is_some()) {
				(b' ', true) | (b'\n', true) | (b'\r', true) => break,
				(_, true) | (b' ', false) => self.pos += 1,
				(b'\n', false) | (b'\r', false) => self._read_next_line(),
				(_, false) => start = Some(self.pos),
			}
		}
		let target = &self.buf[start.unwrap()..self.pos];
		unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
	}

	#[inline]
	fn _read_next_line(&mut self) {
		self.pos = 0;
		self.buf.clear();
		if self.reader.read_until(b'\n', &mut self.buf).unwrap() == 0 {
			panic!("Reached EOF");
		}
	}
}


Measured memory_bytes: 2336
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn a() {
    let s: String = read!(String);

    if &s == "Sunny" {
        println!("Cloudy");
        return;
    }
    if &s == "Cloudy" {
        println!("Rainy");
        return;
    }
    if &s == "Rainy" {
        println!("Sunny");
        return;
    }
}

fn b() {
    let s: String = read!(String);
    let c: Vec<char> = s.chars().collect();

    for i in 0..c.len() {
        let j = i + 1;
        if j % 2 == 0 {
            if c[i] == 'R' {
                println!("No");
                return;
            }
        } else {
            if c[i] == 'L' {
                println!("No");
                return;
            }
        }
    }
    println!("Yes");
}

fn c() {
    let (n, k, q): (usize, i64, usize) = read!(usize, i64, usize);
    let a: Vec<usize> = read!(usize; q);

    let mut points = vec![k; n]; // 初期ポイント

    let mut resolves = vec![0; n]; // 正解数
    for v in a {
        resolves[v - 1] += 1;
    }

    // 累積和
    let mut s = vec![0; n + 1];
    for i in 1..(n + 1) {
        s[i] = s[i - 1] + resolves[i - 1];
    }

    // ポイント計算
    for i in 0..n {
        // iさん以外の正解数
        let another = s[i] + s[n] - s[i + 1];
        points[i] -= another;
        if points[i] > 0 {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}

fn d() {
    let (n, m) = read!(usize, usize);
    let a: Vec<usize> = read![[usize]];

    let mut bh = BinaryHeap::with_capacity(n);
    for &v in &a {
        bh.push(v);
    }

    for i in 0..m {
        let p = bh.pop().unwrap();
        bh.push(p / 2);
    }

    let mut ans = 0;
    for &v in &bh {
        ans += v;
    }
    println!("{}", ans);
}

fn e() {
    unimplemented!();
}

fn f() {
    unimplemented!();
}

fn main() {
    d();
}


Measured memory_bytes: 8444
def cnte(h,w)
  cnt = 0
  0.upto(H-1) do |i|
    0.upto(W-1) do |j|
      if h.include?(i) || w.include?(j)
        next
      else
        if $c[i][j] == "#"
          cnt += 1
        end
      end
    end
  end
  return cnt
end

H,W,K = gets.split(" ").map(&:to_i)
$c = []
H.times do
  $c.push(gets.chomp)
end
cnt = 0
0.upto((2**H)-1) do |dh|
  bs = dh.to_s(2)
  bh = "0" * (H - bs.size)
  bh += bs
  l1 = []
  0.upto(bh.size-1) do |i|
    l1.push(i) if bh[i] == "1"
  end
  numh = l1.size
  0.upto((2**W)-1) do |dw|
    bss = dw.to_s(2)
    bw = "0" * (W - bss.size)
    bw += bss
    l2 = []
    0.upto(bw.size-1) do |i|
      l2.push(i) if bw[i] == "1"
    end
    numw = l2.size
    next if numh + numw > H + W
    if cnte(l1,l2) == K
      cnt += 1
    end
  end
end
    
puts cnt

Measured memory_bytes: 14324
def main():
  s = tuple(map(int, input()[::-1]))

  mod = 2019

  counts = [0] * mod
  counts[0] = 1
  t = 0
  x = 1
  for i in range(len(s)):
    t = (t + s[i] * x) % mod
    counts[t] += 1
    x = (x * 10) % mod

  ans = 0
  for count in counts:
    if count > 1:
      ans += count * (count - 1) // 2

  print(ans)

main()


Measured memory_bytes: 10960
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>
#include <cmath>

using namespace std;

// rep(i, 100) { cout << i << endl; } => 0 1 2 ... 99
#define rep(i, n) for(int i = 0, i##_len = (n); i < (int)n; i++)

// std::sort(all(v));
#define all(x) (x).begin(), (x).end()

// long long int
using ll = long long;

// utility to cast return value of size function to int
#define SZ(x) ((int)(x).size())

// VS defines "_DEBUG" macro when debug configuration.
#if _DEBUG
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define dump(x)
#define debug(x)
#endif

// update max
template<class T>bool chmax(T & prov, const T & cur)
{
	if (cur > prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

// update min
template<class T>bool chmin(T & prov, const T & cur)
{
	if (cur < prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

ll gcd(ll lhs, ll rhs)
{
	return rhs == 0 ? lhs : gcd(rhs, lhs % rhs);
}

ll lcm(ll lhs, ll rhs)
{
	ll t = gcd(lhs, rhs);
	return (lhs / t) * (rhs / t) * t;
}

bool is_prim(ll v)
{
	if (v == 2) { return true; }
	if (v % 2 == 0) { return false; }
	ll end = sqrt(v);
	for (ll i = 3; i <= end; i += 2)
	{
		if (v % i == 0)
		{
			return false;
		}
	}
	return true;
}

int main()
{
	ll A, B;
	cin >> A >> B;
	ll x = gcd(B, A);
	vector<ll> u;

	/*
	if (x == 1)
	{
		cout << 1 << endl;
		return 0;
	}
	else if (is_prim(x))
	{
		cout << 2 << endl;
		return 0;
	}
	*/

	int ans = 0;

	ll end = sqrt(x) + 1;
	if (end * end != x)
	{
		end++;
	}

	for (ll i = 1; i <= x + 1; i++)
	{
		if (x % i == 0)
		{
			// u.push_back(i);
			ans++;
			do
			{
				x = x / i;
			} while (i != 1 && x % i == 0);
		}

		if (end > 10 && i + 1> end)
		{
			ans++;
			break;
		}
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N=parse(Int,readline())
A=sort(map(x->parse(Int,x),split(readline())))
B=sort(map(x->parse(Int,x),split(readline())))
C=sort(map(x->parse(Int,x),split(readline())))
x=[0 for _=1:N]
id=1
for a=A
	while id<=N&&B[id]<=a
		id+=1
	end
	if id<=N
		x[id]+=1
	end
end
y=[0 for _=1:N]
now=0
id=1
for i=1:N
	now+=x[i]
	while id<=N&&C[id]<=B[i]
		id+=1
	end
	if id<=N
		y[id]+=now
	end
end
now=0
ans=0
for i=1:N
	now+=y[i]
	ans+=now
end
println(ans)


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

using namespace std;

typedef long long LL;

const int N = 1010;


int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    for(int i = 1; i <= 1000000; i++)
        if(i * a % b == c % b)
        {
            puts("YES");
            return 0;
        }

    puts("NO");

    return 0;
}


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

using std::string;
using std::vector;

int main() {
    int n, m;
    std::cin >> n >> m;

    vector<string> a(n), b(n);
    for (auto& s : a) std::cin >> s;
    for (auto& s : b) std::cin >> s;

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (a[i][j] != b[i][j]) ++ans;
        }
    }

    std::cout << ans << std::endl;
    return 0;
}



Measured memory_bytes: 11128
import java.util.*;
 
class Main {
  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
    
    int x = sc.nextInt(); //next(文字列), nextDouble, nextLine(1行)とか
    int y = sc.nextInt();
    
    if(y >= x){
      System.out.println("unsafe");
    }else{
      System.out.println("safe");
    }
    
  }
}

Measured memory_bytes: 35808
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}


class Magatro
{
    private int N;
    private int[] A;
    public void Solve()
    {
        N = int.Parse(Console.ReadLine());
        A = new int[N];
        for (int i = 0; i < N; i++)
        {
            A[i] = int.Parse(Console.ReadLine());
        }
        int l = 1;
        for(int i = 0; i < N; i++)
        {
            if(l == 2)
            {
                Console.WriteLine(i);
                return;
            }
            l = A[l - 1];
        }
        Console.WriteLine(-1);
    }
}


Measured memory_bytes: 13280
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      System.out.println(a * b + " " + 2 * (a + b));
    }
    
  
    
}



Measured memory_bytes: 26396
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> H(n);
    for(int i=0; i<n; i++){
        cin >> H.at(i);
    }
    for(int i=n-1; i>0; i--){
        if(H.at(i)+1==H.at(i-1)){
            H.at(i-1)--;
        }
    }
    
    int count=0;
    for(int i=0; i<n-1; i++){
        if(H.at(i)<=H.at(i+1)){
            count++;
        }
    }
    
    if(count==n-1){
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;
}

Measured memory_bytes: 640
import java.util.HashMap;
import java.util.Scanner;


public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int max=0;
		String longest="";
		int maxx=0;
		String most="";

		String[] s=sc.nextLine().split(" ");
		HashMap<String,Integer> map = new HashMap<String,Integer>();
		for(int i=0; i<s.length; i++){
			if(map.containsKey(s[i])){
				int c=map.get(s[i]).intValue();
                map.put(s[i],Integer.valueOf(c+1));
			}else{
				map.put(s[i],Integer.valueOf(1));
			}
		}


		for(int i=0; i<s.length; i++){
			if(s[i].length()>max){
				max=s[i].length();
				longest=s[i];
			}
			if(map.get(s[i]).intValue()>maxx){
				maxx=map.get(s[i]).intValue();
				most=s[i];
			}

		}
		System.out.println(most+" "+longest);

	}

}



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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b;cin>>n>>a>>b;
    ll t=(b-a)*(n-2)+1;
    if(t<=0)cout<<0<<endl;
    else cout<<t<<endl;
    return 0;
}


Measured memory_bytes: 256
import math

A,B = [int(i) for i in input().split()]
emax = (A + 1) / 0.08
emin = math.ceil(A / 0.08)
tmax = (B + 1) / 0.1
tmin = B / 0.1

if emin < tmax and emin >= tmin:
    print(emin)
elif tmin < emax and tmin >= emin:
    print(int(tmin))
else:
    print(-1)


Measured memory_bytes: 38384
#include <stdio.h>

int main(void) {
	int S, h, m, s;
	
	scanf("%d", &S);
	s = S % 60;
	h = S / 3600;
	m = (S - h * 3600 - s) / 60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

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

int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);

  for (int i = 0; i < n; i++) { //a(n)の生成
    cin >> a.at(i);
  }

   for (int k = 0; k < n; k++) { //display
      cout << a.at(k);
      if (k != n-1)
      cout << " ";
    }
    cout << endl;

  for (int i = 1; i < n; i++) {
    int v = a.at(i);
    int j = i - 1;
    while (j >= 0 && a.at(j) > v) {
      a.at(j+1) = a.at(j);
      j--;
      a.at(j+1) = v;
    }

    for (int k = 0; k < n; k++) { //display
      cout << a.at(k);
      if (k != n-1)
      cout << " ";
    }
    cout << endl;
  }

}


Measured memory_bytes: 3092
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>
 
using namespace std;
 
typedef long long ll;
 
const ll MODULO = 1e9 + 7;
 
map<vector<int>, ll> ans;
ll Solve(int at, int sum, int want, int len, int was, const vector<int>& a) {
  if (at == a.size()) {
    if (sum == want) return 1;
    return 0;
  }
 
  vector<int> state = {at, sum, want, len, was};
  if (ans.count(state)) return ans[state];
 
  ll& result = ans[state];
  
  result = 0;
  
  if (sum == want && want != 0 && (len == 1 || was)) {
    for (int w = 0; w < 3; ++w) result = (result + Solve(at, 0, w, 0, 0, a)) % MODULO;
    return result;
  }
 
  int newLen = min(len + 1, 2);
  int newWas = was;
  if (len != 0) newWas |= (a[at] == a[at - 1]);
  int newSum = (sum + a[at]) % 3;
 
  result = (result + Solve(at + 1, newSum, want, newLen, newWas, a)) % MODULO;
 
  return result;
}
 
int main()
{
  string s;
  cin >> s;
  int n = s.size();
  bool found = false;
  for (int i = 0; i < n - 1; ++i) if (s[i] == s[i + 1]) found = true;
  if (!found) {
    cout << 1 << endl;
    return 0;
  }
  vector<int> a(n, 1);
  for (int i = 0; i < n; ++ i) if (s[i] == 'b') a[i] = 2;
  ll result = (Solve(0, 0, 1, 0, 0, a) + Solve(0, 0, 2, 0, 0, a)) % MODULO;
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 161536
from collections import deque
import sys
l = int(input())
a = deque(range(1, 10))
count = 0
while True:
	x = a.popleft()
	count += 1
	if count==l:
		print(x)
		sys.exit(0)
	mod = x%10
	if mod !=0:
		a.append(x*10 + mod -1)
	a.append(x*10 + mod)
	if mod !=9:
		a.append(x*10 + mod +1)



Measured memory_bytes: 11944
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

ll C[2100][2100];

int main(){
  for(int i=0;i<2100;i++){
    C[i][0]=1;
  }
  C[1][1]=1;
  for(int i=2;i<2100;i++){
    for(int j=1;j<=i;j++){
      C[i][j]=C[i-1][j]+C[i-1][j-1];
      C[i][j]%=MOD;
    }
  }
  int N,K;
  cin>>N>>K;

  for(int i=1;i<=K;i++){
    cout<<C[N-K+1][i]*C[K-1][i-1]%MOD<<endl;
  }
}


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

using namespace std;

#define ll long long
#define fix cout << fixed; cout << setprecision(0)





void solve() {

	int a, b;
	cin >> a >> b;
	bool ok = 0;
	for(int i = 1; i <= 125000; i++) {
		if(floor(i * 0.08) == floor(a) && floor(i * 0.1) == floor(b)) {
			cout << i << "\n";
			ok = 1;
			break;
		}
	}
	if(!ok) {
		cout << "-1";
	}
	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	fix;
	solve();

	return 0;
}

Measured memory_bytes: 256
// Problem : C - A x B + C
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀🌙｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 🚶ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)
#define vt vector
#define bug(x) cout<<#x<<"="<<x<<endl;

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char cl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int n;
	cin>>n;
	int ans=0;
	l00p(i,1,n){
		if(n%i==0){
			ans+=n/i-1;
		}
		else{
			ans+=n/i;
		}
	}
	cout<<ans;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343


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

int main() {
  ll N,i,x;
  map<ll,ll> l;
  cin >> N;
  for(i=0; i<N; i++) {
    cin >> x;
    if(l.count(x))
      l.at(x)++;
    else
      l[x]=1;
  }
  
  if(l.size()==3) {
    ll c[3];
    i=0;
    for(pair<ll,ll> p : l) {
      c[i]=p.first;
      i++;
    }
    if(l.at(c[0])==l.at(c[1])
       && l.at(c[1])==l.at(c[2])
      && ((c[0]^c[1]^c[2])==0))
      cout << "Yes";
    else
      cout << "No";
  } else if(l.size()==2) {
	ll c[2];
    i=0;
    for(pair<ll,ll> p : l) {
      c[i]=p.first;
      i++;
    }
    if(c[0]==0 && l.at(c[0])*2==l.at(c[1]))
      cout << "Yes";
    else
      cout << "No";
  } else if(l.size()==1) {
    for(pair<ll,ll> p : l) {
      if(p.first==0)
        cout << "Yes";
      else
        cout << "No";
    }
  } else
    cout << "No";
  cout << endl;
}

Measured memory_bytes: 5120
package main

import "fmt"

func main(){
	var N int
	fmt.Scan(&N)
	X := make([]int, N)
	for i := 0 ; i < N ; i++ {
		fmt.Scan(&X[i])
	}
	min := -1
	rep := 0
	//fmt.Println(rep)
	for i := 1 ; i <= 100 ; i++ {
		rep = 0
		for j := 0 ;  j < N ; j++ {
			rep += (X[j]- i) * (X[j] - i)
		}
		if rep < min || min == -1 {
			min = rep
		}
	}
	fmt.Println(min)
}

Measured memory_bytes: 512
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    long long h, w;
    cin >> h >> w;
    if (w == 1 || h == 1) {
        cout << 1;
        return 0;
    }
    else if (w == 2) {
        cout << h;
        return 0;
    }
    long long ans = h / 2 * ((w + 1) / 2 + w / 2);
    if (h % 2) {
        ans += (w + 1) / 2;
    } 
    cout << ans;
    return 0;
}

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

int main(void)
{
    char s[101],t[101],a;
    int i,j;
    scanf("%s%s",s,t);
    for(i=0;i<strlen(s)-1;i++){
        for(j=strlen(s)-1;j>i;j--){
            if(s[j-1]>s[j]){
                a=s[j-1];
                s[j-1]=s[j];
                s[j]=a;
            }
        }
    }
    for(i=0;i<strlen(t)-1;i++){
        for(j=strlen(t)-1;j>i;j--){
            if(t[j-1]<t[j]){
                a=t[j-1];
                t[j-1]=t[j];
                t[j]=a;
            }
        }
    }
    if(strcmp(t,s)>0)puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 128
N = int(input())
L = list(map(int,input().split()))

L.sort()
ans = 0

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            a = L[i]
            b = L[j]
            c = L[k]
            if a != b and b != c and c != a and c < a + b:
                ans += 1

print(ans)

Measured memory_bytes: 9192
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
#define ll long long
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define in(a) a=read()
inline int read(){
    int X=0,w=1; char ch=0;
    while(ch<'0' || ch>'9') {if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0' && ch<='9') X=(X<<3)+(X<<1)+ch-'0',ch=getchar();
    return X*w;
}
int a[10];
int main(){
	FOR(i,1,4)in(a[i]);
	ll c=min(min(min(a[1]*8,a[2]*4),a[3]*2),a[4]);
	int n;
	in(n);
	ll ans=c*(n/2);
	n%=2;
	if(n)ans+=min(min(min(a[1]*4,a[2]*2),a[3]),a[1]*2+a[2]);
	printf("%lld",ans);
}
	
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int a, b, c;
  cin >> a>> b>> c;
  int d = max(a,max(b, c));
  cout << d*10 + a + b + c -d << endl;

}


Measured memory_bytes: 256
#include"iostream"
#include"string"
using namespace std;

int main() {
	int n;
	cin >> n;
	string s = "";
	long a = 1;
	int PM = 1;
	if (n == 0)
	{
		cout << 0 << endl;
	}
	else
	{
		while (n != 0)
		{
			if (n % (2 * a) == 0)
			{
				s = "0" + s;
			}
			else
			{
				s = "1" + s;
				n = n - PM * a;
			}
			a = 2 * a;
			PM = (-1) * PM;
		}
		cout << s << endl;
	}
}

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

int main() {
    int a, b, c, d;
    cin >>a>>b>>c>>d;
    
    int ab = a * b;
    int cd = c * d;
    
    if (ab > cd) {
        cout << ab <<endl;
    } else {
        cout << cd << endl;
    }
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define lcm(a,b) (a/__gcd(a,b)*b)

main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << b - b/c - b/d + b/lcm(c,d) - ((a-1) - (a-1)/c - (a-1)/d + (a-1)/lcm(c,d));
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())

min=-1
#最大値=N/2
for a in range(1, int(N/2)+1):
	b=N-a
	#各位の和は・・・
	sum=0
	for i in range(5):
		sum+=a%10
		sum+=b%10
		a=int(a/10)
		b=int(b/10)
	
	if min==-1 or min>sum:
		min=sum

print(min)
	

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int main(){
    cin.sync_with_stdio(false);
    int h, w;
    cin >> h >> w;

    rep(i, h) {
        string s;
        cin >> s;
        cout << s << endl << s << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
const int INF=1e9+7;

int main(){
  ll n,ans=0;cin>>n;
  vll a(n);
  rep(i,0,n){
    cin>>a[i];
  }
  rep(i,0,n){
    rep(j,0,i){
      ans=max(ans,abs(a[i]-a[j]));
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int LS(int X[], int n, int key){
  int i=0;
  while(i<n){
    if(X[i]==key)return 1;
    i++;
  }
  return 0;
}
int main(){
  int i, n, q, key, ans=0;
  int Y[10001];

  scanf("%d", &n);
  for(i=0 ; i<n ; i++){
    scanf("%d", &Y[i]);
  }
  scanf("%d", &q);
  for(i=0 ; i<q ; i++){
    scanf("%d", &key);
    if(LS(Y, n, key)==1)ans++;
  }
  printf("%d\n",ans);
  return 0;
}


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

int main(){
  
  int N,K,ans = 0;
  cin >> N >> K;
  
  for(int i = 0; i < N; ++i){
  
    int x;
    cin >> x;
    if(x < K-x){
    
      ans += 2*x;
    
    }else{
    
      ans += 2*(K-x);
    
    }
  
  }
  
  cout << ans << endl;
  
  return 0;

}

Measured memory_bytes: 256
import math

a, b, C = map(float, input().split())

h = math.sin(math.radians(C))*b

S = a*h/2
if C <= 90:
    a1 = (b**2 - h**2)**0.5
    a2 = a - a1
    d = (a2**2 + h**2)**0.5
    L = a + b + d
else:
    a1 = (b**2 - h**2)**0.5
    a2 = a + a1
    d = (a2**2 + h**2)**0.5
    L = a + b + d


print(S, L, h, sep="\n")


Measured memory_bytes: 5700
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> p;
const int inf=(1<<30);
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
	
	ll v[10][10];
	ll x[10];
	ll ans=0;
	ll n,m;

	void solve(ll a,ll b){
		x[a]++;
		if(b==n){
			rep(i,0,n){
				if(x[i]==1)continue;
				else {
					x[a]--;
					return;
				}
			}
			ans++;
			x[a]--;
		}
		else{
			
			rep(i,0,n){
				if(v[a][i]==1&&x[i]!=1){
					solve(i,b+1);
				}
				else continue;
			}
		x[a]--;
		}
	}
	
	
int main(){
	cin>>n>>m;
	rep(i,0,m){
		ll f,t;
		cin>>f>>t;
		f--;
		t--;
		v[f][t]++;
		v[t][f]++;
	}
	solve(0,1);
	cout<<ans<<endl;
}

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

int main(void) {
  int n;
  cin >> n;
  int a[n];
  int max = -100, min = 100;
  for(int i = 0; i < n; i++) {cin >> a[i]; if (max < a[i]) max = a[i]; if (min > a[i]) min = a[i]; }
  int costmin = 100*100*100;
  int cost = 0;
  for (int i = min; i <= max; i++) {
    for (int j = 0; j < n; j++) {
      cost += (a[j]-i) * (a[j]-i);
    }
    if (costmin > cost) costmin = cost;
    cost = 0;
  }
  cout << costmin << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long 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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

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

    ll tmp = x;
    ll len = 1;

    while(tmp*2 <= y){
        tmp *= 2;
        len++;
    }

    cout << len << endl;
}

Measured memory_bytes: 256
coma, prot = map(int, input().split())
nums = list(map(int, input().split()))


if coma >= prot:
    print(0)
    exit()

nums.sort()

intervals = []
for i in range(prot-1):
    intervals.append(nums[i+1] - nums[i])

intervals.sort()
li = len(intervals)
print(sum(intervals[:li-(coma-1)]))


Measured memory_bytes: 13968
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        abc139_b solver = new abc139_b();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc139_b {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();
            int socket = 0;
            int cnt = 0;
            int taps = 0;
            while (true) {
                if (B == 1) {
                    break;
                }
                socket += A;
                if (socket >= B) {
                    taps++;
                    break;
                }
                socket--;
                taps++;
            }
            out.println(taps);
        }

    }
}



Measured memory_bytes: 21844
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;

int main()
{
    int N, M, X;
    std::cin >> N >> M >> X;

    cerr << N << " " << M << " " << X << endl;
    std::vector<int> A;
    A.resize(N+1);
    for (size_t i = 0; i < M; ++i) {
        int t;
        std::cin >> t;
        A[t] = 1;
    }

    for (auto a: A) {
        cerr << a;
    }

    int l = 0;
    for (int i = 0; i < X; ++i) {
        l += A[i];
    }
    int r = 0; 
    for (int i = X; i < N; ++i) {
        r += A[i];
    }


    std::cout << std::min(l, r) << std::endl;

    return 0;
}


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

int main() {
  int k;
  string S;
  cin>>k>>S;
  if(S.size()<=k){
    cout<<S<<endl;
  }
  else{
    for(int i=0;i<k;i++){
      cout<<S.at(i);
    }
    cout<<"..."<<endl;
  }
}

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

using namespace std;

int main()
{
    int a , b;

    cin >> a >> b;

    if(a == 1 && b != 1){
        cout << "Alice\n";
        return 0;
    }else if(b == 1 && a != 1){
        cout << "Bob\n";
        return 0;
    }

    if(a == b){
        cout << "Draw\n";
    }else if(a > b){
        cout << "Alice\n";
    }else if(b > a){
        cout << "Bob\n";
    }

    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
input=sys.stdin.readline

n, q = map(int, input().split())

edge = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    edge[a-1].append(b)
    edge[b-1].append(a)

cnt = [0 for _ in range(n)]
for i in range(q):
    p, x = map(int, input().split())
    cnt[p-1] += x


def dfs(now, bef):
    for nxt in edge[now-1]:
        if nxt != bef:
            cnt[nxt-1] += cnt[now-1]
            dfs(nxt, now)


dfs(1, -1)
print(*cnt)


Measured memory_bytes: 230892
#include<stdio.h>
#include<stdlib.h>

/* ????????????????????£?¨? */
int insertionSort(int* A, int n, int g);
int shellSort(int* A, int n);

/* main??¢??° */
int main(void){
	int* A = NULL;
	int n, cnt, i;

	scanf("%d", &n);
	A = (int*)malloc(sizeof(int)*n);
	if(A == NULL)exit(1);

	for(i = 0;i < n;i++)
		scanf("%d", &A[i]);

	cnt = shellSort(A, n);
	if(cnt == -1){
		free(A);
		exit(1);
	}
	printf("%d\n", cnt);

	for(i = 0;i < n;i++)
		printf("%d\n", A[i]);

	free(A);

	return 0;
}

/* g????????¢??????????´?????£???§??????????????°??????????????§?????\????????????????????¢??° */
int insertionSort(int* A, int n, int g){
	int cnt = 0, v, i, j;

	for(i = g;i < n;i++){
		v = A[i];
		j = i - g;
		while(j >= 0 && A[j] > v){
			A[j + g] = A[j];
			j = j - g;
			cnt++;
		}
		A[j + g] = v;
	}

	return cnt;
}

/* ?????§?????????????????????????????¢??° */
int shellSort(int* A, int n){
	int *G = NULL;
	int cnt = 0, m, Gm = 1, i;

	for(m = 0;Gm <= n;m++)
		Gm = 3*Gm + 1;
	printf("%d\n", m);

	G = (int*)malloc(sizeof(int)*m);
	if(G == NULL)return -1;

	G[m-1] = 1;
	for(i = m - 2;i >= 0;i--)
		G[i] = 3*G[i+1] + 1;

	printf("%d", G[0]);
	for(i = 1;i < m;i++)
		printf(" %d", G[i]);
	printf("\n");

	for(i = 0;i < m;i++)
		cnt += insertionSort(A, n, G[i]);

	free(G);

	return cnt;
}

Measured memory_bytes: 5492
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>

using namespace std;

int main(){
	char s[4];
	scanf("%s", s);
	int len = strlen(s);
	for(int i = len - 1; i >= 0; i--)
	{
		if(len == 3) printf("%c", s[i]);
	}
	 if(len == 2) printf("%s\n", s);
}


Measured memory_bytes: 256