akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(){
    int n,a;cin>>n;
    vector<int> vec(100010);
    for(int i=0;i<n;i++){
        cin>>a;vec[a]++;
    }
    int ans=0,tmp;
    for(int i=1;i<100000;i++){
        tmp=vec[i-1]+vec[i]+vec[i+1];
        if(tmp>ans)ans=tmp;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3736
use std::collections::HashMap;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
        a: [usize; n],
    }
    let mut s = vec![0; n + 1];
    for i in 0..n {
        s[i + 1] = (s[i] + a[i]) % k;
    }
    for i in 1..n + 1 {
        s[i] = (s[i] + k - (i % k)) % k;
    }
    // println!("{:?}", s);
    let mut result = 0u64;
    let mut count = HashMap::new();
    for i in 0..n + 1{
        if let Some(&c) = count.get(&s[i]) {
            result += c;
            *count.get_mut(&s[i]).unwrap() += 1;
        } else {
            count.insert(s[i], 1);
        }
        if k <= i + 1 {
            *count.get_mut(&s[i + 1 - k]).unwrap() -= 1;
        }
        // println!("{:?}", count);
    }
    println!("{}", result);
}


Measured memory_bytes: 19220
let rec power ( * ) e m n =
  if n <= 0 then e
  else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)

let m = 1000000007
let ( +^ ) x y = (x + y) mod m
let ( -^ ) x y = x +^ (m - y)
let ( *^ ) x y = (x * y) mod m

let () = Scanf.scanf "%d %d" @@ fun n k ->
  let ds = Array.init k succ in
  for d = 1 to k do
    for i = 2 to k / d do
      ds.(d * i - 1) <- ds.(d * i - 1) -^ ds.(d - 1)
    done
  done;
  Printf.printf "%d\n" @@
  List.fold_left ( +^ ) 0 @@
  List.init k @@ fun d ->
    power ( *^ ) ds.(d) (k / (d + 1)) n

Measured memory_bytes: 10552
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//オーバーフローに注意 long long　にする
//'1'+=16;      で大文字Aに
//'大文字'+=32;  で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);


 
int main() {

  long long a,b,n;
  cin >> a >> b >> n;
  
  int ans;
  
  if(b-1<=n) ans = a*(b-1)/b;

  else ans = (a*n)/b;
  
  cout << ans << endl ; 

}


Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <math.h>

#ifndef MAX
#define MAX(a,b) (( (a) > (b) ) ? (a) : (b))
#endif

using namespace std;

void core(){
	int K, T;
	cin >> K >> T;

	int max = 0;
	int tmp;
	for (int i = 0; i < T; i++){
		cin >> tmp;
		if (max < tmp){
			max = tmp;
		}
	}

	int ans = MAX(max - (K - max) - 1, 0);
	cout << ans << endl;
}

int main(){
	core();
	return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize "trapv"
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand rng
#define fios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define M_PI 3.14159265358979323846
typedef long long ll;

void dfs(vector<vector<int>>& adj, vector<bool>& vis, int u) {
	vis[u] = true;
	for(auto child: adj[u]) {
		if(vis[child] == false)
			dfs(adj, vis, child);
	}
}

int main() {
	//fios;
	int n, m;
	cin >> n >> m;

	vector<vector<int>> adj(n);

	for(int i = 0, u, v; i < m; i++) {
		cin >> u >> v;
		--u, --v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	int cnt = 0;
	vector<bool> vis(n, false);
	for(int i = 0; i < n; i++) {
		if(vis[i] == false) {
			dfs(adj, vis, i);
			cnt++;
		}
	}
	cout << cnt -1 << endl;

}

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


def rec(N, b):
    if N == 0:
        return []
    buf = -1
    for i in range(N):
        if b[i] > i+1:
            return [-1]
        if b[i] == i+1:
            buf = i
    if buf == -1:
        # ここはありえないはずではある
        print("ありえない")
        return [-1]
    a = b.pop(buf)
    return rec(N-1, b) + [a]


def solve(N, b):
    for x in rec(N, b):
        print(x)
    return

# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)


def main():
    N = int(input())
    b = [int(x) for x in input().split()]
    solve(N, b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
//package atcoder;
 
import java.util.*;
//import java.math.BigDecimal;
 
public class Main{
	static boolean[] targetNumbers;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		String T = sc.next();
		//System.out.println(S.charAt(0));
		
		for(int i=0;i<N;i++) {
			System.out.print(S.charAt(i));
			System.out.print(T.charAt(i));
		}
		
	}
}

Measured memory_bytes: 21844
N, M = map(int, input().split())
AB = []

for i in range(N):
  AB.append(list(map(int, input().split())))
  
AB.sort()

result = 0
cnt = 0

for i in range(N):
  B = AB[i][1]
  if cnt + B > M:
    result += AB[i][0]*(M-cnt)
    break
  result += AB[i][0]*B
  cnt += B
  
print(result)

Measured memory_bytes: 27760
A, B, C, D = map(int, input().split())

ans = 'Yes'
while True:
    # 高橋くんのターン
    C -= B
    if C <= 0:
        break

    # 青木くんのターン
    A -= D
    if A <= 0:
        ans = 'No'
        break

print(ans)


Measured memory_bytes: 9192
#include "stdio.h"
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <queue>
#include <algorithm>

#define MAX 4000
#define inf 1000000

using namespace std;

int main(){
    int n,ma,mb;
    cin >> n >> ma >> mb;
    vector<int>a(n),b(n),c(n);
    for(int i=0;i<n;i++)cin >> a[i] >> b[i] >> c[i];

    vector< vector< vector<int> > > 
    dp(n+1,vector< vector<int> > (40*10+1,vector<int> (40*10+1,inf)));

    dp[0][0][0] = 0;

    for(int i=0;i<n;i++){
        for(int j=0;j<=40*10;j++){
            for(int k=0;k<=40*10;k++){
                if(dp[i][j][k] == inf) continue; 
                dp[i+1][j][k] = min(dp[i+1][j][k],dp[i][j][k]);
                dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]],
                                              dp[i][j][k]+c[i]);
            }
        }
    }

    int ans = inf;
    for(int j=1;j<=n*10;j++){
        for(int k=1;k<=n*10;k++){
            if(ma*k == mb*j ){
                ans = min(ans,dp[n][j][k]);
            }
        }
    }

    if(ans == inf)ans = -1;

    cout << ans;

    return 0;
}


Measured memory_bytes: 27264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 5, P = 1e9 + 7;
int n;
int a[maxn], cnt[maxn];
ll power(ll x, ll t) {
	ll ret = 1;
	for(; t; t >>= 1, x = x * x % P) {
		if(t & 1) {
			ret = ret * x % P;
		}
	}
	return ret;
}
int main() {
	scanf("%d", &n);
	ll lcm = 1;
	for(int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
		ll t = a[i];
		for(ll j = 2; j * j <= t; ++j) {
			int c = 0;
			if(t % j == 0) {
				while(t % j == 0) {
					t /= j;
					++c;
				}	
			} 
			cnt[j] = max(cnt[j], c);
		}
		if(t > 1) {
			cnt[t] = max(cnt[t], 1);
		}
	}
	for(int i = 1; i <= (int)1e6; ++i) {
		if(cnt[i]) {
			lcm = lcm * power(i, cnt[i]) % P;
		}
	}
	ll ans = 0;
	for(int i = 1; i <= n; ++i) {
		ans = (ans + lcm * power(a[i], P - 2)) % P;
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main(){
	int H,W;
	while(1){
		cin>>H>>W;
		if(H == 0 && W == 0)break;
		for(int a = 0;a < H;a++){
			for(int b = 0;b < W;b++){
				cout<<"#";
			}
			cout<<endl;
		}
		cout<<endl;
	}
return 0;
}


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

int main()
{
    int H, W;
    
    while(true){
        cin >> H >> W;
        if( H==0 and W==0){
            break;
        }
        for(int i=0; i<H; ++i){
            for(int j=0; j<W; ++j){
                cout << '#';
            }
            cout <<endl;
        }
        cout << endl;
    }
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 1;
  for (int i = 1; i < n; i++) {
    if (s[i] != s[i - 1]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let a: i64 = input();
    let b: i64 = input();
    if a + b < 10 {
        println!("{}", a + b);
    } else {
        println!("error");
    }
}


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

int n, ans1 = 0, ans2 = 0;
string s;
string a1 = "";
string a2 = "";

int main() {
    cin >> s;

    n = s.size();

    for (int i = 0; i < n; ++i)
    {
        if (i%2 == 0)
        {
            a1 += '0';
            a2 += '1';
        } else {
            a1 += '1';
            a2 += '0';
        }
    }

    for (int i = 0; i < n; ++i)
    {
        if (s.at(i) != a1.at(i))
        {
            ans1 ++;
        }

        if (s.at(i) != a2.at(i))
        {
            ans2 ++;
        }
    }


    cout << min(ans1, ans2)<< endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int N, x;
  cin >> N >> x;
  if(x == 1 || x == 2*N-1) cout << "No" << endl;
  else {
    cout << "Yes" << endl;
    vector<int> ans(2*N-1);
    if(x != 2) {
      ans[N-2] = x-1;
      ans[N-1] = x;
      ans[N]   = x+1;
      ans[N+1] = x-2;
    } else {
      ans[N-2] = x+1;
      ans[N-1] = x;
      ans[N]   = x-1;
      ans[N+1] = x+2;
    }
    int tmp = 1;
    rep(i, 2*N-1) {
      if(i == N-2 || i == N-1 || i == N || i == N+1) continue;
      if((x != 2 && tmp == x-2) ||
	 (x == 2 && tmp == x-1)) tmp += 4;
      ans[i] = tmp;
      tmp++;
    }
    rep(i, 2*N-1) cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 2304
#include<iostream>
#include<vector>

using namespace std;

long long dp[100002][4];

void print_dp(long long n, long long k){
    for (long long i=0; i<k; i++){
        for (long long j=1; j<n; j++) {
            cout << dp[j][i] << " ";
        }
        cout << endl;
    }
    cout << endl;
}

int main (void) {
    long long n;
    long long a1, a2;

    cin >> n;

    cin >> a1;
    cin >> a2;
    dp[1][0] = a1 + a2;
    dp[1][1] = -(a1 + a2);
    for (long long i=2; i<n; i++) {
        a1 = a2;
        cin >> a2;

        dp[i][0] = max(dp[i-1][0] + a2, dp[i-1][1] + a2);
        dp[i][1] = max(dp[i-1][0] + -2*a1 + -a2, dp[i-1][1] + 2*a1 + -a2);
        // print_dp(n,2);
    }


    cout << max(dp[n-1][0], dp[n-1][1]) << endl;

    return 0;
}


Measured memory_bytes: 3328
require 'set'
require 'matrix'
include Math

class Circle
	def initialize(*args)
		@id, @x, @y, @r = args
	end

	def cross?(other)
		(@x - other.x) ** 2 + (@y - other.y) ** 2 < (@r + other.r) ** 2
	end

	def include?(x, y)
		(@x - x) ** 2 + (@y - y) **2 < @r ** 2
	end

	def inspect
		@id
	end

	attr_reader :id, :x, :y, :r
end

EPS = 1e-10
class Circuit
	def initialize(circles)
		@circles = circles
	end
	def include?(x, y)
		x += EPS
		return false if @circles.any?{|c| c.include?(x, y)}
		cross_count = 0
		@circles.each_cons(2) do |c1, c2|
			next if c1.x == c2.x
			c1, c2 = c2, c1 if c2.x < c1.x
			next if x < c1.x || c2.x < x
			cy = c1.y + (c2.y - c1.y) * (x - c1.x) / (c2.x - c1.x).to_f 
			cross_count += 1 if cy > y
		end
		return cross_count.odd?
	end
end

loop do
	n, m = gets.split.map(&:to_i)
	break if n == 0

	graph = {}
	circles = (1..n).map do |i|
		c = Circle.new(i, *gets.split.map(&:to_i))
		graph[c] = []
		c 
	end

	edges = Set.new
	circles.combination(2) do |c1, c2|
		if c1.cross?(c2)
			graph[c1] << c2
			graph[c2] << c1
			edges << Set[c1, c2]
		end
	end

	#delete branches
	loop do
		c = graph.keys.min_by{|c| graph[c].size}
		break if !c
		if graph[c].size <= 1
			graph.delete(c)
			graph.each do |u, neighbour|
				neighbour.delete(c)
			end
			edges.delete_if {|pair| pair.include?(c)}
		else
			break
		end
	end

	#find faces
	circuits = []
	scanned = {}

	loop do
		found = false
		if e0 = edges.find {|e| !scanned[[e, :left]]}
			found = true
			scanned[[e0, :left]] = 0
			u0, v0 = e0.to_a.sort_by(&:id)
			path = [u0, v0]
			u = u0
			v = v0
			until v == u0
				t = atan2(v.y - u.y, v.x - u.x)
				rot = Matrix[
					[cos(-t), -sin(-t)],
					[sin(-t), cos(-t)]
				]
				w = (graph[v] - [u]).max_by do |w|
					vec = rot * Vector[w.x - v.x, w.y - v.y]
					x, y = vec.to_a
					atan2(y, x)
				end
				e = Set[v, w]
				if v.id < w.id
					scanned[[e, :left]] = 0
				else
					scanned[[e, :right]] = 0
				end
				path << w
				u, v = v, w
			end
			circuits << Circuit.new(path)
		end
		if e0 = edges.find {|e| !scanned[[e, :right]]}
			found = true
			scanned[[e0, :right]] = 0
			u0, v0 = e0.to_a.sort_by(&:id).reverse
			path = [u0, v0]
			u = u0
			v = v0
			until v == u0
				t = atan2(v.y - u.y, v.x - u.x)
				rot = Matrix[
					[cos(-t), -sin(-t)],
					[sin(-t), cos(-t)]
				]
				w = (graph[v] - [u]).min_by do |w|
					vec = rot * Vector[w.x - v.x, w.y - v.y]
					x, y = vec.to_a
					atan2(y, x)
				end
				e = Set[v, w]
				if v.id < w.id
					scanned[[e, :right]] = 0
				else
					scanned[[e, :left]] = 0
				end
				path << w
				u, v = v, w
			end
			circuits << Circuit.new(path)
		end
		break if ! found
	end

	ans = []
	m.times do
		x1, y1, x2, y2 = gets.split.map(&:to_i)
		if circles.any? {|c| c.include?(x1, y1) ^ c.include?(x2, y2)}
			ans << 'NO'
		elsif circuits.any? {|c| c.include?(x1, y1) ^ c.include?(x2, y2)}
			ans << 'NO'
		else
			ans << 'YES'
		end
	end
	puts ans * ' '

end

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

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

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H;
	while(cin>>N) {
		bool ok=false;
		REP(i, 50001) {
			if((ll)(i*1.08)==N) {
				cout<<i<<endl;
				ok=true;
				break;
			}
		}
		
		if(!ok) cout<<":("<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;
using System.Runtime.InteropServices.ComTypes;
using System.Xml.Schema;
using System.ComponentModel.DataAnnotations;
using System.Security.Cryptography;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (A, B) = Slice2<long>();
            WriteLine(Max(Max(2 * A - 1, 2 * B - 1), A + B));
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 27384
import sys
sys.setrecursionlimit(10 ** 6)
import sys
def input():
    return sys.stdin.readline()[:-1]
N , Q = map(int,input().split())
graph = [[] for _ in range(N)]
point = [0] * N
for _ in range(N - 1):
    a , b = map(int,input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)
#print(graph)
for _ in range(Q):
    a , b = map(int,input().split())
    a = a - 1
    point[a] += b
# dfsを用いて累積和を計算する
# 初期状態だと前の値がないためデフォルト引数に-1を代入
def dfs(now , prev = -1):
    for next in graph[now]:
        # 次のノードが前に参照した値の時はcontinue
        if next == prev:
            continue
        # 現在の値を次のポイントに加算することで累積和をとる
        point[next] += point[now]
        # 次のノードと現在のノードを引数にdfsを継続する
        dfs(next , now)

dfs(0)
print(*point)

Measured memory_bytes: 268464
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    int n;
    cin >> n;
    vector<ll>x(n),y(n);
    rep(i,n){
        cin >> x[i] >> y[i];
        
    }
    bool flag =0;
    bool flag2 = 0;
    rep(i,n){
        if((x[i]+y[i])%2==0){
            flag = 1;
        }else{
            flag2 = 1;
        }
    }
    if(flag&&flag2){
        cout << -1 << endl;
        return 0;
    }
    vector<ll> d(40);
    if(flag){
        d[0] = 1;
        d[1] = 1;
        for(int i=2;i<40;i++){
            d[i] = d[i-1]*2LL;
        }
    }else{
        d[0] = 1;
        d[1] = 2;
        for(int i=2;i<40;i++){
            d[i] = d[i-1]*2LL;
        }
    }
    reverse(d.begin(),d.end());
    cout << 40 << endl;
    rep(i,40){
        cout << d[i] << " ";
    }
    cout << endl;
    rep(i,n){
        ll xx = -x[i];
        ll yy = -y[i];
        string ans;
        for(int k=0;k<40;k++){
            if(abs(xx)>=abs(yy)){
                if(xx>=0){
                    xx -=d[k];
                    ans.PB('L');
                }else{
                    xx += d[k];
                    ans.PB('R');
                }
            }else{
                if(yy>=0){
                    yy -=d[k];
                    ans.PB('D');
                }else{
                    yy += d[k];
                    ans.PB('U');
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <bitset>
#include <vector>

using namespace std;

const int MAX_N = 1000000;

bitset<MAX_N> sieve;
vector<int> primes;
void eratosthenes(){
	sieve[0] = sieve[1] = true;
	for(int i = 2; i < MAX_N; ++i){
		if(sieve[i]){ continue; }
		primes.push_back(i);
		for(int j = i + i; j < MAX_N; j += i){ sieve[j] = true; }
	}
}

int main(){
	eratosthenes();
	while(true){
		int a, d, n;
		cin >> a >> d >> n;
		if(a == 0 && d == 0 && n == 0){ break; }
		int answer = 0;
		for(int i = a, c = 0; i < MAX_N; i += d){
			if(!sieve[i]){
				if(++c == n){ answer = i; break; }
			}
		}
		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 0
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
    var input = chunk.split("\n");
    //console.log(input);
    var output = "";
    
    for(var i = 0; i < input.length; i ++){
        if(input[i] === ""){
            continue;
        }
        var r = calc(input[i]);
        if(r !== false){
            console.log(r);
        }
    }
    
    function calc(input){
        var nums = input.split(" ");
        nums[0] = Number(nums[0]);
        nums[2] = Number(nums[2]);
        if(nums[1] == "+"){
            return nums[0] + nums[2];
        }
        else if(nums[1] == "-"){
            return nums[0] - nums[2];
        }
        else if(nums[1] == "*"){
            return nums[0] * nums[2];
        }
        else if(nums[1] == "/"){
            return Math.floor(nums[0] / nums[2]);
        }
        else if(nums[1] == "?"){
            return false;
        }
        
    }
});

Measured memory_bytes: 7904
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            var answer = S;
            var count = 0;
            for (var i = 0; i < S.Length; i++)
            {
                if (S[i] == '(') count++;
                else count--;
                if (count < 0)
                {
                    answer = "(" + answer;
                    count++;
                }
            }
            for (var i = 0; i < Math.Max(0, count); i++)
            {
                answer += ")";
            }

            Console.WriteLine(answer);
        }
    }
}


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

int a, b, c, d, p;
int x, y; 

int main()
{  
  cin >> a >> b >> c >> d >> p;
  x = p * a;
  y = b;
  if (p - c > 0) {
    y += (p - c) * d;
  }
  if (x > y){
    x = y;
  }
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 3080
from collections import Counter
n = int(input())
s = [input() for i in range(n)]
c = Counter(s)
cks = list(c.keys())
cvs = c.values()
cvm = max(cvs)
l = []
for i,cvi in enumerate(cvs):
    if cvi==cvm:
        l.append(cks[i])
for ai in sorted(l):
    print(ai)

Measured memory_bytes: 36464
def solve():
    N = int(input())
    C, S, F = [0] * (N - 1), [0] * (N - 1), [0] * (N - 1)
    for i in range(N - 1):
        C[i], S[i], F[i] = map(int, input().split())
    
    ans = [0] * N
    for i in range(N - 1):
        t = C[i] + S[i]
        for j in range(i + 1, N - 1):
            if S[j] <= t and t % F[j] == 0:
                t += C[j]
            elif t < S[j]:
                t = C[j] + S[j]
            else:
                t += C[j] + F[j] - (t % F[j])
        ans[i] = t
    print('\n'.join(map(str, ans)))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
#include <stdio.h>

int main(){
    int N=0, data[3] ,c,i;
    scanf("%d",&N);
    char *judge[N];
    for (i=0; i<N; i++) {
        scanf("%d %d %d",&data[0],&data[1],&data[2]);
        if (data[0]<data[1]) {
            c=data[1];
            data[1]=data[0];
            data[0]=c;
        }
        if (data[0]<data[2]) {
            c=data[2];
            data[2]=data[0];
            data[0]=c;
        }
        if (data[0]*data[0]==(data[1]*data[1]+data[2]*data[2])) {
            judge[i]="YES";
        }
        else
            judge[i]="NO";
    }
    for (i=0; i<N; i++) {
        printf("%s\n",judge[i]);
    }
    
    return 0;
}

Measured memory_bytes: 584
#include <algorithm>
#include <iostream>
#include <list>
#include <map> //連想配列
#include <queue>
#include <set> //
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector> //動的配列

using namespace std;
using ll = long long;

ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a / g * b;
}
int main() {
  int N;
  cin >> N;

  ll ans = 1;
  for (int i = 0; i < N; ++i) {
    ll T;
    cin >> T;
    ans = lcm(ans, T);
  }

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


Measured memory_bytes: 256
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#define ll long long
#define ms(a,b) memset(a,b,sizeof(a))
char col[111][111];
using namespace std;

const int MAXN = 1e2 + 10;
int gel[MAXN][MAXN];
int a[MAXN * MAXN];

int main(void){
    int h, w, n;
    cin >> h >> w >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int cnt1 = 0, indx = 1;
    for(int i = 0; i < h; i++){
        if(i % 2 == 0){
            for(int j = 0; j < w; j++){
                gel[i][j] = indx;
                a[indx]--;
                if(a[indx] <= 0) indx++;
            }
        }else{
            for(int j = w - 1; j >= 0; j--){
                gel[i][j] = indx;
                a[indx]--;
                if(a[indx] <= 0) indx++;
            }
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cout << gel[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long LL;
const int N=200000+10;
const LL MOD=1e9+7;

char s[N];
int c[27],n;
int main(){
    scanf("%d%s",&n,s);
    for(int i=0;s[i];i++)
        c[s[i]-'a']++;
    LL ans=1;
    for(int i=0;i<26;i++)
        ans=ans*(c[i]+1)%MOD;
    ans=(ans-1+MOD)%MOD;
    cout<<ans<<endl;
}




Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**7)

def dfs(v, u, d):
    if d % 2 == 0:
        even.append(v)
    else:
        odd.append(v)
    for i in g[v]:
        if i == u:
            continue
        dfs(i, v, d + 1)
    return

N = int(input())
g = [[] for _ in range(N)]
odd = []
even =[]
ans = [-1] * N
nums = [[], [], []]
for i in range(1, N + 1):
    nums[i % 3].append(i)
sanlst = []
for i in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

dfs(0, -1, 0)
zCnt = len(nums[0])

if len(even) <= zCnt:
    for node in even:
        ans[node] = nums[0].pop()
    rest = nums[0] + nums[1] + nums[2]
    for node in odd:
        ans[node] = rest.pop()
elif len(odd) <= zCnt:
    for node in odd:
        ans[node] = nums[0].pop()
    rest = nums[0] + nums[1] + nums[2]
    for node in even:
        ans[node] = rest.pop()
else:
    for i in nums[1]:
        ans[even.pop()] = i
    for i in nums[2]:
        ans[odd.pop()] = i
    rest = nums[0]
    for i in even:
        ans[i] = rest.pop()
    for i in odd:
        ans[i] = rest.pop()

print(*ans)

Measured memory_bytes: 179376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (2147483647)
#define mod (1000000007)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)

void solve()
{
    int n;cin>>n;double v[n];REP(i,n)cin>>v[i];
    sort(v,v+n);
    double sum=v[0];
    rep(i,1,n)sum=(sum+v[i])/2;
    cout<<setprecision(10)<<sum<<endl;
}

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

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

using namespace std;
int main(){
    char date[10];
    cin >> date; 
    if((date[5]=='0') && (date[6]<='4')){
    cout << "Heisei" << endl;
    }
    else{
        cout << "TBD" << endl;
    }
}

Measured memory_bytes: 256
#include  <cmath>
#include  <fstream>
#include  <iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
using namespace std;

int main(void)
{
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;
    if(A1+A2+A3 >= 22)
    {
        cout << "bust" << endl;
    }
    else
    {
        cout << "win" << endl;
    }

    return 0;
}


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

int main(){
  int N,X,T;
  cin >> N >> X >> T;
  int a,b;
  a = N/X;
  b = N%X;
  if(b == 0)  cout << T*a << endl;
  else  cout << T*(a + 1) << endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
using Graph=vector<vector<int>>;
typedef long long ll;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int main(){
    ll n,k;cin>>n>>k;
    vector<ll> a(n+1);
    for(int i=1;i<n+1;i++) cin>>a[i];
    vector<int> visited(n+1,0);
    ll next=1;
    ll ans=0;
    ll count_a=0;
    ll d=1;
    ll flag=0;
    ll sp=0;
    while(true){
        if(visited[next]!=0){
            sp=next;
            count_a=visited[next];
            break;
        }
        visited[next]=d;
        if(d==k+1){
            flag=1;
            ans=next;
            break;
        }
        next=a[next];
        d++;
    }
    if(flag) cout<<ans<<endl;
    else{
        k-=(count_a-1);
        k=k%(d-count_a);
        while(true){
            if(k==0) break;
            else{
                sp=a[sp];
                k--;
            }
        }
        cout<<sp<<endl;
    }
}

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

int main() {
  int x;
  cin >> x;
  string ans = (x >= 30) ? "Yes" : "No";
  cout << ans << endl;
  return 0;
}
/*
*/


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T &a, T b) { if (a<b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (a>b) { a = b; return 1;} return 0;}
ll dp[100100];
const int MOD = 1000000007;


int main() {
    int N,M; cin >> N >> M;
    for (int i=0;i<=N;++i) dp[i] = 0;
    for (int i=0;i<M;++i) {
        int a; cin >> a;
        dp[a] = -1;
    }
    dp[0] = 1;

    for (int i=0;i<N;++i){
        if (dp[i]==-1) continue;
        if (dp[i+1]>=0) dp[i+1] = (dp[i+1] + dp[i]) % MOD;
        if (dp[i+2]>=0) dp[i+2] = (dp[i+2] + dp[i]) % MOD;
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        String t = in.next();

        if (s.equals(t.subSequence(0, t.length() - 1))) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 27012
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        long a = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next());
        
        long x = Long.parseLong(sc.next());
        
        long ans = 0;
        ans = (b/x)-(a/x);
        if(a%x==0){
            ans++;
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define forn(i, n) for(int i = 0; i < n; i++)

using namespace std;

// Aca empiezan los structs y funciones

struct Point {
    int x, y;

    Point operator-(const Point &punto) const {
		return {x-punto.x, y-punto.y};
	}

    Point operator+(const Point &punto) const {
        return {x+punto.x, y+punto.y};
    }

    bool operator<(const Point &punto) const{
		if(x == punto.x) return y < punto.y;
		return x < punto.x;
	}
};

int cross_product (Point a, Point b) {
    return ((a.x * b.y) - (b.x - a.y));
}

double orientation (Point p1, Point p2, Point p3) {
    return (double(p2.y) - double(p1.y)) * (double(p3.x) - double(p2.x)) - (double(p2.x) - double(p1.x)) * (double(p3.y) - double(p2.y));
    // Clockwise positivo, couterclockwise negativo y colineares cero.
}

// Aca terminan los structs y funciones

int main () {

    int n; cin >> n;
    vector<Point> points (n);

    forn (i, n) cin >> points[i].y >> points[i].x;

    sort(points.begin(), points.end());
    vector<Point> result;

    if (n == 3) {
        cout << 3 << "\n";
        for (auto g: points) cout << g.y << " " << g.x << "\n";
        return 0;
    }

    int cantMinima = 0;
    for (int i = 0; i < n; i++) {
        while (result.size() >= cantMinima + 2 && orientation(result[result.size()-2], result[result.size()-1], points[i]) < 0)
            result.pop_back();
        result.push_back(points[i]);
    }

    cantMinima = result.size();
    for (int i = n-2; i >= 0; i--) {
        while (result.size() >= cantMinima + 1 && orientation(result[result.size()-2], result[result.size()-1], points[i]) < 0)
            result.pop_back();
        result.push_back(points[i]);
    }

    result.pop_back();
    cout << result.size() << "\n";
    for (auto g: result) cout << g.y << " " << g.x << "\n";
    return 0;
}


Measured memory_bytes: 4408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll A, B, C;
    cin >> A >> B >> C;
    cout << B + min(A + B + 1, C) << endl;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var a = int.Parse(input[0]);
        var b = int.Parse(input[1]);
        var c = int.Parse(input[2]);

        int res;
        if (b > c)
        {
            res = b + c;
        }
        else
        {
            res = b * 2;
            c = c - b;
            res += Math.Min(a, c);
            if (c - a > 0)
            {
                res++;
            }
        }
        Console.WriteLine(res);
    }
}

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

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int R = 0;
  int L = 0;
  for (int i=0; i<N; i++){
    if (S[i]=='('){
      L++;
    } else {
      if (L>0){
        L--;
      }
      else {
        R++;
      }
    }
  }
  string ans = "";
  for (int i=0; i<R; i++) ans += '(';
  ans += S;
  for (int i=0; i<L; i++) ans += ')';
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;

int main(){
    int a,b,c,d;cin >> a >> b >> c >> d;
    int ans = a < b ? a : b;
    ans += c < d ? c : d;

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

Measured memory_bytes: 256
###############################################
#                                             #
#   author: raghav_0901 (Raghav Dalmia)       #
#   updated on: 27-06-2020,  5:30:55 pm IST   #
#                                             #
###############################################

from math import *


def _in():
    return [int(x) for x in input().split(' ')]


if __name__ == "__main__":
    a = int(input())

    print(a + (a * a) + (a * a * a))


Measured memory_bytes: 9020
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vii         vector<pair<int,int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define endl '\n'
#define int long long int
using namespace std;
unordered_map<int, vi> ind;
int tree[(int)3e5];
const int MaxIdx = 2e5 + 1;
int read(int idx){
    int sum = 0;
    while (idx > 0){
        sum += tree[idx];
        idx -= (idx & -idx);
    }
    return sum;
}


void update(int idx, int val){
    while (idx <= MaxIdx){
        tree[idx] += val;
        idx += (idx & -idx);
    }
}

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

    string s;cin >> s;
    const int n = s.length();
    FOR(i, s.length()){
        ind[s[i]].pb(i + 1);
    }
    vii temp;
    int mid = -1;
    for(auto val : ind){
        int i = 0; 
        vi var = val.second;
        while(var.size() > i + 1){
            temp.pb(mp(var[i], var.back())); 
            var.pop_back();
            i++;
        } 
        if(var.size() > i){
            if(mid != -1){
                cout << -1;
                return 0;
            }
            mid = var[i+1 - 1];
        }
    }
    sort(temp.begin(), temp.end(), [](pii& a, pii& b){
            return a.first < b.first;});
    vi pos(n + 1); 
    int t = 0;
    map<int, bool> mark;
    for(pii val: temp){
        t++;
        mark[val.first]  = mark[val.second] = true;
        assert(val.first != val.second);
        pos[val.first] = t;
        pos[val.second] = n - t +1;
    }
    if(mid != -1){
        mark[mid] = true;
        pos[mid] = n/2 + 1;
    }
    int ans = 0;
    FOR1(i ,n){
       ans += i-1 - read(pos[i]);
       update(pos[i], 1);
    }
    cout << ans;


}




Measured memory_bytes: 19484
// Problem : C - Maximum Volume
// Contest : AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()
using namespace std;
using namespace __gnu_pbds;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int md=1000000007;
template<class T>
T abst(T a)
{return a<0?-a:a;}
template<class T> using ordered_set=tree<
T,
null_type,
less_equal<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%md;n=(n*n)%md;x=x>>1;}
 return ans;}

 vi fact,inv;
void inverse(int n)
{inv.resize(n+1);inv[0]=1;
for(int i=1;i<=n;i++)inv[i]=Pow(fact[i],md-2);}
void factorial(int n)
{fact.resize(n+1);fact[0]=1;
for(int i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%md;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
void solve()
{
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
double l;cin>>l;
l=l/3.0;
cout<<setprecision(10)<<l*l*l;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
}


Measured memory_bytes: 256
#include<iostream>
int N;
int main(){
    std::cin>>N;
    int sum=0;
    int now=1;
    while(sum<N){
        sum+=now;
        now++;
    }
    for(int i=1;i<now;i++){
        if(i==sum-N)continue;
        std::cout<<i<<std::endl;
    }
    return 0;
}

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

int main() {
  int N,K;
  cin>>N>>K;
  set<int>name;
  for(int i=1;i<(K+1);i++){
    int d;
    cin>>d;
    for(int j=0;j<d;j++){
      int x;
      cin>>x;
      name.insert(x);
    }
  }
  int ans;
  ans=N-name.size();
  cout<<ans<<endl;
}

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


int main(){
    double h,w,x,y;
    cin >> w >> h >> x >> y;

    cout << fixed << w*h/2 << " " ;

    if(x+x==w && y+y==h){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }
    
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#define MAXN 1000010

struct edge{
	int to,next;
	edge(int _to=0,int _next=0):to(_to),next(_next){}
}e[MAXN];

int n,root;
int g[MAXN],nume;
int e2[MAXN][2],nume2;
int d[MAXN],d0[MAXN];
int c[MAXN];

void addEdge(int u,int v){
	e[nume]=edge(v,g[u]);
	g[u]=nume++;
}

int dfs(int x){
	int cnt=0;
	int last=0;
	for(int i=g[x];~i;i=e[i].next){
		cnt^=1;
		int temp=dfs(e[i].to);
		nume2++;
		if(last){
			e2[nume2][0]=last;
			e2[nume2][1]=temp;
			last=0;
		}else last=temp;
	}
	if(!last) last=x;
	d[x]^=cnt;
	d0[x]=cnt;
	return last;
}

void dfs2(int x){
	for(int i=g[x];~i;i=e[i].next)
		if(!c[e[i].to]){
			c[e[i].to]=-c[x];
			dfs2(e[i].to);
		}
}

int main(){
#ifdef DEBUG
	freopen("F.in","r",stdin);
#endif
	scanf("%d",&n);
	memset(g,-1,sizeof g);
	nume=0;
	for(int i=1;i<=n;i++){
		int t;
		scanf("%d",&t);
		if(t!=-1) addEdge(t,i);
		else root=i;
	}
	dfs(root);
	memset(g,-1,sizeof g);
	nume=0;
	for(int i=1;i<=n;i++){
		int t;
		scanf("%d",&t);
		if(t!=-1) addEdge(t,i);
		else root=i;
	}
	dfs(root);
	for(int i=1;i<=n;i++)
		if(d[i]){
			puts("IMPOSSIBLE");
			return 0;
		}
	memset(g,-1,sizeof g);
	nume=0;
	for(int i=1;i<=nume2;i++)
		addEdge(e2[i][0],e2[i][1]),addEdge(e2[i][1],e2[i][0]);
	for(int i=1;i<=n;i++)
		if(!d0[i] && !c[i]){
			c[i]=1;
			dfs2(i);
		}
	puts("POSSIBLE");
	for(int i=1;i<=n;i++)
		if(d0[i]) printf("0 ");
		else printf("%d ",c[i]);
}


Measured memory_bytes: 29312