akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;

 
const int MAX_N = int(1e6) + 10;
const long long int MOD=1e9+7;
const long long int INF=1e18;
 
typedef long long int ll;
typedef unsigned long long int llu;
 
 
 
inline ll mul(ll a,ll b){
 
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll c=a*b;
    c=(c+MOD)%MOD;
    return c;
}
inline ll add(ll a,ll b){
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll ans=(a+b);
    ans=(ans+MOD)%MOD;
    return ans;
}
ll power(ll a,ll b,ll c=0){
    ll ans=1;
    while(b){
        if(b&1){
            ans=mul(ans,a);
        }
        a=mul(a,a);
        b=b/2;
    }
    return ans;
}
 
  
 
 
#define all(x) (x).begin(),(x).end()




//s.reserve(32768); //updated !
//s.max_load_factor(0.25);











ll fact[1000005];
ll inv[1000005];


inline ll fun(ll x,ll y){
    return mul(mul(fact[x],inv[x-y]),inv[y]);
}

int main(){

    int n,m;
    cin>>n>>m;

    fact[0]=1LL;
    for(int i=1;i<=m;i++){
        fact[i]=mul(fact[i-1],i*1LL);
    }

    inv[m]=power(fact[m],MOD-2,MOD);

    for(int i=m-1;i>=0;i--){
        inv[i]=mul(inv[i+1],(i+1)*1LL);
    }

    ll ans=1;
    ans=mul(ans,fun(m,n));
    ans=mul(ans,fact[n]);

    ll ans22=0;
    for(int i=1;i<=n;i++){
        ll ans3=1;
        ans3=mul(ans3,fun(n,i));
        ans3=mul(ans3,fun(m-i,n-i));
        ans3=mul(ans3,fact[n-i]);
        if(i%2==1)ans22=add(ans22,ans3);
        else ans22=add(ans22,-ans3);
    }
    ans22=add(ans,-ans22);

    ans=mul(ans,ans22);

    cout<<ans;
   
   
   
    
}


 
    



    



    
    
    




    


    

    






    
    

    
 
    
 

 
 
    
 
 


Measured memory_bytes: 11392
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl;
#define rep(i,n) for(ll i = 0;i < n;++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0);

const ll INF = 1e9 + 7;

// 各桁の和
template<typename T>
T digit(T num) {
	T sum = 0;
	while (num) {
		sum += num % 10;
		num /= 10;
	}
	return sum;
}

template<typename T>T gcd(T a, T b) {
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
template<typename T>T lcm(T a, T b) {
	T g = gcd(a, b);
	return a / g * b;
}
template<typename T>T power(T a, T b) {
	T tmp = 1;
	rep(i, b) {
		tmp *= a;
	}
	return tmp;
}
int main() {
	int n, d; cin >> n >> d;
	int rn = d * 2 + 1;

	int ans = n / rn + (n % rn != 0);
	print(ans)
		return 0;
}


Measured memory_bytes: 256
def solve(A):
    # I + J + L
    res = 0
    I = A[0]
    J = A[3]
    L = A[4]

    O = A[1]
    if (I >= 1 and J >= 1 and L >= 1):
        tmp = 3 + ((I - 1) // 2 + (J - 1) // 2 + (L - 1) // 2) * 2 + O
        res = max(res, tmp)
    tmp = (I // 2 + J // 2 + L // 2) * 2 + O
    res = max(res, tmp)
    print (res)


if __name__ == "__main__":
    A = list(map(int, input().split()))
    solve(A)


Measured memory_bytes: 3064
import collections
s = str(input())
S = []
A = []
l = s.split(' ')
S.extend(l)
c = collections.Counter(S)
L = len(S)
for i in range(L):
    a = S[i]
    A.append(a)
    A.sort(key=len,reverse=True)
print(c.most_common()[0][0], A[0])


Measured memory_bytes: 5968
from operator import itemgetter
X = []
L = []

n = int(input())
for i in range(n):
    x, l = map(int, input().split())
    X.append(x)
    L.append(l)

robo = sorted([(X[i]-L[i], X[i]+L[i]) for i in range(n)], key=itemgetter(1))

ans = 0
end = -float("inf")
for i in range(n):
    if end <= robo[i][0]:
        ans += 1
        end = robo[i][1]

print(ans)


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

int main(){
    int N, L;
    cin >> N >> L;
    vector<string> S(N);
    for(int i=0; i<N; i++) cin >> S.at(i);
    sort(S.begin(), S.end());
    for(int i=0; i<N; i++) cout << S.at(i);
    cout << endl;
}

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

int main() {
  
  char n;
  cin >> n;
  
  cout << ('A' <= n && n <= 'Z' ? "A" : "a" ) << endl;

}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[100010];
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	ll ans1=2,ans2=2;
	for(int i=n-1;i>=0;i--){
		ll now=a[i];
		ll j=(ans1+a[i]-1)/a[i],k=(ans2)/a[i];
		ans1=j*a[i],ans2=(k+1)*a[i]-1;
		//cout << ans1<<" "<<ans2 <<endl;
		if(ans1>ans2){
			cout << -1 ;
			return 0;
		}
	}
	cout << ans1<<" "<<ans2 <<endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1024
use std::io::stdin;
use std::str::FromStr;

fn main(){
    let n: usize = get_one();
    let xs: Vec<usize> = get_vec();
    let mut cnt = vec![0; n];
    for &x in xs.iter() {
        cnt[x] += 1
    }
    let check_should2 = (1..n).filter(|i| i%2!= n%2)
        .map(|i| cnt[i] == 2)
        .fold(true, |acc, x| acc && x);
    let check_should0 = (0..n).filter(|i| i%2==n%2)
        .map(|i| cnt[i] == 0)
        .fold(true, |acc, x| acc && x);
    let check_should1 = if n%2==1 { cnt[0]==1 } else { true };

    if check_should2 && check_should1 && check_should0 {
        let mut ans = 1;
        for _ in 0..n/2 {
            ans *= 2;
            ans %= 1_000_000_007;
        }
        println!("{}", ans);
    } else {
        println!("0");
    }
}

#[allow(dead_code)]
fn get_line() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn get_vec<T: std::str::FromStr>() -> Vec<T> {
    let line = get_line();
    line.split_whitespace().filter_map(|x| x.parse().ok()).collect()
}

#[allow(dead_code)]
fn get_one<T: FromStr + Copy>() -> T {
    let v = get_vec();
    v[0]
}

#[allow(dead_code)]
fn get_pair<T: FromStr + Copy>() -> (T, T) {
    let v = get_vec();
    (v[0], v[1])
}

#[allow(dead_code)]
fn get_triple<T: FromStr + Copy>() -> (T, T, T) {
    let v = get_vec();
    (v[0], v[1], v[2])
}

#[allow(dead_code)]
fn get_chars() -> Vec<char> {
    get_line().chars().collect()
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<P> suzu;
    int border_l=-1,border_r=inf;
    for(int i=0; i<N; i++){
        int l,r;
        cin >> l >> r;
        r++;
        chmin(border_r,r);
        chmax(border_l,l);
        suzu.emplace_back(l,r);
    }
    int ans = 0;
    for(int i=0; i<N; i++){
        chmax(ans,suzu[i].second-suzu[i].first + max(0,border_r-border_l));
    }
    vector<P> p;
    for(int i=0; i<N; i++){
        int a,b;
        a = max(0,border_r - suzu[i].first);
        b = max(0,suzu[i].second - border_l);
        p.emplace_back(b,-a);
    }
    sort(p.begin(),p.end());
    int sec = inf;
    for(int i=0; i<N; i++){
        int a,b;
        tie(a,b) = p[i];
        b *= -1;
        if(i){
            chmax(ans,sec+a);
        }
        chmin(sec,b);
    }    
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 2548
#include<stdio.h>

int main(){
    int i,H;
    int A[250+1];

    scanf("%d",&H);
    for(i=1;i<=H;i++){
        scanf("%d",&A[i]);
    }

    for(i=1;i<=H;i++){
        printf("node %d: key = %d, ",i,A[i]);
        if((i/2) >= 1){
            printf("parent key = %d, ",A[i/2]);
        }
        if((2*i) <= H){
        printf("left key = %d, ",A[2*i]);
        }
        if((2*i+1) <= H){
            printf("right key = %d, ",A[2*i+1]);
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2116
#include <stdio.h>

#define Mod 1000000007

long long div_mod(long long x, long long y, long long z)
{
	if (x % y == 0) return x / y;
	else return (div_mod((1 + x / y) * y - x, (z % y), y) * z + x) / y;
}

long long pow_mod(long long n, long long k)
{
	if (k == 0 || n == 1) return 1;
	
	long long i, N;
	for (i = 1, N = n; i * 2 <= k; i *= 2) N = N * N % Mod;
	return N * pow_mod(n, k - i) % Mod;
}

int main()
{	
	char S[100001];
	scanf("%s", S);
	
	int l, count = 0;
	for (l = 0; S[l] != 0; l++) {
		if (S[l] == '?') count++;
	}
	long long p[4] = {pow_mod(3, count), div_mod(p[0], 3, Mod), div_mod(p[1], 3, Mod), div_mod(p[2], 3, Mod)};

	int i, tmp;
	long long ans = 0, num[3] = {};
	for (i = l - 1; i >= 0; i--) {
		if (S[i] == 'C') num[2]++;
		else if (S[i] == 'B') num[1] += num[2];
		else if (S[i] == 'A') num[0] += num[1];
	}
	ans = (ans + num[0] % Mod * p[0]) % Mod;
	if (count >= 1) {
		for (i = l - 1, num[0] = 0, num[1] = 0, num[2] = 0; i >= 0; i--) {
			if (S[i] == '?') num[2]++;
			else if (S[i] == 'B') num[1] += num[2];
			else if (S[i] == 'A') num[0] += num[1];
		}
		for (i = l - 1, num[1] = 0, num[2] = 0; i >= 0; i--) {
			if (S[i] == 'C') num[2]++;
			else if (S[i] == '?') num[1] += num[2];
			else if (S[i] == 'A') num[0] += num[1];
		}
		for (i = l - 1, num[1] = 0, num[2] = 0; i >= 0; i--) {
			if (S[i] == 'C') num[2]++;
			else if (S[i] == 'B') num[1] += num[2];
			else if (S[i] == '?') num[0] += num[1];
		}
		ans = (ans + num[0] % Mod * p[1]) % Mod;
	}
	if (count >= 2) {
		for (i = l - 1, tmp = 0, num[0] = 0; i >= 0; i--) {
			if (S[i] == '?') tmp++;
			else if (S[i] == 'A' && tmp >= 2) num[0] += (long long)tmp * (tmp - 1) / 2;
			else if (S[i] == 'B' && tmp >= 1 && count - tmp >= 1) num[0] += (long long)tmp * (count - tmp);
			else if (S[i] == 'C' && count - tmp >= 2) num[0] += (long long)(count - tmp) * (count - tmp - 1) / 2;
		}
		ans = (ans + num[0] % Mod * p[2]) % Mod;
	}
	if (count >= 3) ans = (ans + ((long long)count * (count - 1) * (count - 2) / 6 % Mod) * p[3]) % Mod;
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1760
import java.io.PrintWriter

//private val inp = java.io.File("in")
private val inp = System.`in`
private val reader = inp.bufferedReader()
private val wr = PrintWriter(System.out.bufferedWriter())

private fun readLn(): String = reader.readLine()
private fun readInt(): Int = readLn().toInt()
private fun readLong(): Long = readLn().toLong()
private fun readStrs(): List<String> = readLn().split(" ")
private fun readInts(): IntArray = readStrs().map { it.toInt() }.toIntArray()
private fun readChars(): CharArray = readStrs().map { it.single() }.toCharArray()

fun main() {
    val r = readInt()
    println(2*Math.PI*r)
}


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

ans = N
for i in range(N+1):
 cc = 0
 t = i
 while t>0:
  cc += t%6
  t //= 6
 t = N-i
 while t>0:
  cc += t%9
  t //= 9
 if ans>cc:
  ans = cc

print("{}".format(ans))

Measured memory_bytes: 3060
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

void main() {
    int n, k;
    scan(n, k);
    auto p = readln.split.to!(int[]).map!(pi => (pi + 1) / 2.0).array;

    debug {
        writeln(p);
    }

    auto r = new double[](n + 1);
    r[] = 0;

    foreach (i ; 1 .. n + 1) {
        r[i] += r[i - 1] + p[i - 1];
    }

    double ans = 0;
    foreach (i ; 0 .. n - k + 1) {
        ans = max(ans, r[k + i] - r[i]);
    }

    writefln("%.12f", ans);
}










void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 11560
import sys

#+++++

mod = 7 + (10**9)
		
def main():
	n, k = map(int, input().split())
	aa_list=list(map(int, input().split()))
	
	ret = 0
	for i, v in enumerate(aa_list):
		a=len([x for x in aa_list[:i] if x < v])
		b=len([x for x in aa_list[i+1:] if x <v])
		ret += a*k*(k-1)//2
		ret += b*k*(k+1)//2
	print(ret%mod)
	
	
#+++++


if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

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

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    string s; cin>>s;
    int n=s.size();
    int ncnt=0, wcnt=0, scnt=0, ecnt=0;
    for(int i=0; i<n; i++){
        if(s[i]=='N') ncnt++;
        else if(s[i]=='W') wcnt++;
        else if(s[i]=='S') scnt++;
        else ecnt++;
    }

    bool home;
    if(ncnt>0 && wcnt>0 && scnt>0 && ecnt>0) home=true;
    else if(wcnt==0 && ecnt==0 && ncnt>0 && scnt>0) home=true;
    else if(wcnt>0 && ecnt>0 && ncnt==0 && scnt==0) home=true;
    else home=false;

    if(home) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

const ll mod = 1e9+7;
struct combination {
    const int max = 510000;
    vector<long long> fact, ifact, inv;
    combination() {
        fact.resize(max);   // i!
        ifact.resize(max);  // (i!)^(mod-2)
        inv.resize(max);    // i^(mod-2)
        fact[0] = fact[1] = 1;
        ifact[0] = ifact[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < max; i++) {
            fact[i] = fact[i-1] * i % mod;
            inv[i] = mod - inv[mod%i] * (mod/i) % mod;
            ifact[i] = ifact[i-1] * inv[i] % mod;
        }
    }

    long long operator()(int n, int k) {
        if (n < k) return 0;
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]%mod*ifact[n-k]%mod;
    }
};

int main() {
    int n, k; cin >> n >> k;
    combination c;
    repf(i,1,k+1) {
        ll ans = c(n-k+1, i) * c(k-1, i-1) % mod;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 12160
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
using namespace std;
int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int func(int n){
  string s = to_string(n);
  int sum = 0;
  for(int i=0; i<s.size(); i++) sum += s[i]-'0';
  return sum;
}

int main() {
  int n;
  int a, b;
  cin >> n >> a >> b;

  int cnt = 0;
  for(int i=1; i<=n; i++){
    int tmp = func(i);
    if( a <= tmp && tmp <= b ) cnt+=i;
  }
  cout << cnt << endl;

  return 0;
}




//


Measured memory_bytes: 256
def contain(x, y, r):
    return x**2 + y**2 <= r**2
def outer_p(x0, y0, x1, y1):
    return (x0*y1 - y0*x1)
def line_segment_circle(x0, y0, x1, y1, r, border=True):
    A = x0**2 + y0**2
    B = x0*x1 + y0*y1
    C = x1**2 + y1**2 - r**2
    D = B**2 - A*C
    if border:
        if D < 0:
            return 0
        if B <= 0 and B**2 > D:
            return 0
        if B - A >= 0 and (B - A)**2 > D:
            return 0
    else:
        if D <= 0:
            return 0
        if B <= 0 and B**2 >= D:
            return 0
        if B - A >= 0 and (B - A)**2 >= D:
            return 0
    return 1

while 1:
    x1, y1 = map(int, input().split())
    if x1 == y1 == 0:
        break
    x2, y2 = map(int, input().split())
    x3, y3 = map(int, input().split())

    cx, cy = map(int, input().split())
    r = int(input())

    C1 = contain(x1-cx, y1-cy, r)
    C2 = contain(x2-cx, y2-cy, r)
    C3 = contain(x3-cx, y3-cy, r)
    if C1 and C2 and C3:
        print("b")
        continue
    if C1 or C2 or C3:
        print("c")
        continue
    p1 = outer_p(x2-x1, y2-y1, cx-x1, cy-y1)
    p2 = outer_p(x3-x2, y3-y2, cx-x2, cy-y2)
    p3 = outer_p(x1-x3, y1-y3, cx-x3, cy-y3)
    if 1 == (p1 < 0) == (p2 < 0) == (p3 < 0) or 1 == (p1 > 0) == (p2 > 0) == (p3 > 0):
        p1 = line_segment_circle(x2-x1, y2-y1, cx-x1, cy-y1, r, False)
        p2 = line_segment_circle(x3-x2, y3-y2, cx-x2, cy-y2, r, False)
        p3 = line_segment_circle(x1-x3, y1-y3, cx-x3, cy-y3, r, False)
        if p1 or p2 or p3:
            print("c")
        else:
            print("a")
        continue
    p1 = line_segment_circle(x2-x1, y2-y1, cx-x1, cy-y1, r, True)
    p2 = line_segment_circle(x3-x2, y3-y2, cx-x2, cy-y2, r, True)
    p3 = line_segment_circle(x1-x3, y1-y3, cx-x3, cy-y3, r, True)
    if p1 or p2 or p3:
        print("c")
        continue
    print("d")


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

using namespace std;

int main(){
    int N, M;

    cin >> N >> M;

    long long int days_needed = 0;
    for(int I = 0; I < M; I++){
        int ai;
        cin >> ai;
        days_needed += ai;
    }

    if(N < days_needed){
        cout << -1 << endl;
    } else{
        cout << N - days_needed << endl;
    }

    return 0;

}



Measured memory_bytes: 3636
#define _GLIBCXX_DEBUG
#include"bits/stdc++.h"

using namespace std;

//loops
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(int i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

//arrays
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define add push_back
#define ctif count_if
#define ctif_all ctif(ALL, )

template <class Container, class Exp>
void tf_all(Container &c, Exp exp) {
    transform(ALL(c), c.begin(), exp);
}
//#define tf_all(exp) tf(ALL(nums), nums.begin(), exp)

//pair
#define fir first
#define sec second

//types
#define ll long long
#define vec vector
//UNCOMMENT WHEN NEEDED
//#define int ll

//input
template <class T>
T get(){ T s; cin >> s; return(s);}
#define gi get<int>()
#define gs get<string>()
template <class T> vector<T> getv(int n) { vec<T> v(n); REP(i, n) cin >> v[i]; return v; }
#define gim(n) getv<int>(n)
#define gsm(n) getv<string>(n)

//output
void print(int a){ cout << a << endl; }
void print(string a){ cout << a << endl; }
void print(double a, int dig){ cout << std::setprecision(dig) << a << endl; }

template <class T = int>
void print(vec<T> v){ for (T item: v) { cout << item << " "; } cout << endl; }

void YesNo1(bool i = true){ return print(i?"Yes":"No"); }
void YESNO2(bool i = true){ return print(i?"Yes":"N1010o"); }

//debug output
#define var_name(var) #var
template <class T> void debug(T &var, string before = "", int nest = 0) { cout << string("          ", nest) << before <<  ": "; print(var); }

//name replacement
#define y0 y0__
#define y1 y1__
#define j0 j0__
#define j1 j1__
#define next next__
#define prev prev__

//bool lambdas
#define lamb(exp) [](auto i){return exp;}
#define isEven [](int i){return i % 2 == 0;}
#define isOdd [](int i){return i % 2 != 0;}

//constants
const ll INF = 1e18;
const int MOD = 10000007;

//variables
int n;
string s,str;
vec<int> nums;

void Main() {
    //code here
    n = gi;
    nums = gim(n);
    int count = 0;
    while (count_if(ALL(nums), isOdd) == 0) {
        tf_all(nums, lamb(i/2));
        count += 1;
    }
    print(count);
}

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

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

int main(void){
    int n,k; cin >> n >> k;
    vector<int> A(n);
    for(int i=0; i<n; ++i) cin >> A[i];

    if((n-1)%(k-1)==0) cout << (n-1)/(k-1) << endl;
    else cout << (n-1)/(k-1)+1 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int N,M;
cin >> N >> M;
vector<int64_t> hei(N);
for (int i = 0;i < N;i++) cin >> hei.at(i);
vector<int> vec(N);
for (int i = 0;i < M;i++) {
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    if (hei.at(a) < hei.at(b)) vec.at(a) = 1;
    else if (hei.at(a) > hei.at(b)) vec.at(b) = 1;
    else {
        vec.at(a) = 1;
        vec.at(b) = 1;
    }

}
int cnt = 0;
for (int i = 0;i < N;i++) {
    if (vec.at(i) == 0) cnt++;
}
cout << cnt << endl;


return 0;
}

Measured memory_bytes: 4564
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

void solve(){
 string s;
  cin >> s;
  
  cout <<((s[1]=='R')?"ABC":"ARC") << endl;
}

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

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,L;
  cin>>N>>L;
  int a=L+N-1;
  int b;
if(a<=0){
b=a;
}
  else if(L>=0){
  b=L;
  }
  else{
  b=0;
  }
  cout<<(a+L)*(a-L+1)/2-b<<endl;
}


Measured memory_bytes: 256
/*
    Author:zzugzx
    Lang:C++
    Blog:blog.csdn.net/qq_43756519
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define endl '\n'
#define SZ(x) (int)x.size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int mod=1e9+7;
//const int mod=998244353;
const double eps = 1e-10;
const double pi=acos(-1.0);
const int maxn=1e6+10;
const ll inf=0x3f3f3f3f;
const int dir[][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    char c;
    cin>>c;
    if(c>='A'&&c<='Z')cout<<"A";
    else cout<<'a';
    return 0;
}



Measured memory_bytes: 3600
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <math.h>
 
int main(void){
long long int a,b,c;
scanf("%lld %lld %lld",&a,&b,&c);
long long int d=c-a-b;
if(d>0&&d*d>4*a*b){printf("Yes\n");}
else{printf("No\n");}
 
}

Measured memory_bytes: 128
import java.util.*; 
import java.lang.*; 


public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                String N = scan.next();
                int sum = 0;
                
                for(int i=0; i<N.length(); i++){
                    char p = N.charAt(i);
                    int j = (int)p;
                    
                    sum += j;
                }
                
                if(sum%3==0){
                    System.out.println("Yes");
                }else{
                    System.out.println("No");
                }
        }
}

Measured memory_bytes: 40292
n = int(input())
x = [int(i) for i in input().split()]
for i in range(n): x[i]-=(i+1)
x,ans = sorted(x),0
if n%2==1: m = x[(n-1)//2]
else: m = (x[n//2]+x[n//2-1])//2
for i in x: ans+=abs(i-m)
print(ans)

Measured memory_bytes: 26128
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin>>n;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin>>vec[i];
  }
  sort(vec.begin(),vec.end());
  double ans=vec[0];
  for(int i=1;i<n;i++){
    ans=(ans+vec[i])/2;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
s=input()
r='R'
if s[0]==r and s[1]==r:
    if s[1]==s[2]:
        print(3)
    else:
        print(2)
elif s[1]==r and s[2]==r:
    print(2)
elif s[0]==r or s[1]==r or s[2]==r:
    print(1)
else:
    print(0)


Measured memory_bytes: 9108
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long int ll;

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

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int k, a, b;
    cin >> k >> a >> b;
    for (int i = a; i <= b; ++i) {
        if (i % k == 0 ) {
            cout << "OK\n";
            return 0;
        }
    }
    cout << "NG\n";

}




Measured memory_bytes: 3640
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;


namespace atcorder2
{
    class Program
    {
        public static long Read()
        {

            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {


            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       
       
        public static long gcd(long x,long y)
        {
            if (x < y) gcd(y, x);
            
            while (y > 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return x;
        }

        public static long lcm(long x,long y)
        {
            return x * y / gcd(x, y);
        }



        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var nk = Reads();
            var n = nk[0];
            var k = nk[1];
            var h = Reads();
            Array.Sort(h);
            long ans = 0;
            for (int i = 0; i < n-k; i++)
            {
                ans += h[i];
            }
            WriteLine(ans);
          
            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 44664
#include <bits/stdc++.h>
using namespace std;
# define ll long long int
#define mmm 1000000007
#define pb push_back

									//nestedcode

 int main(){
   ios::sync_with_stdio(0);
   cin.tie(0); cout.tie(0);
   ll a,b;
   cin>>a>>b;
   ll k = (a*b)/(__gcd(a,b));
  cout<<k;
 }   

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]

A.sort(reverse=True)

cur = 0
E = []
while cur < N:
    a = A[cur]
    count = 0
    while cur < N and A[cur] == a:
        count += 1
        cur += 1

    if 2 <= count:
        E.append(a)
    if 4 <= count:
        E.append(a)

    if len(E) >= 2:
        print(E[0] * E[1])
        quit()

print(0)

Measured memory_bytes: 14668
S=input()
acgt=["A", "C", "G", "T"]
count=0
max_count=0
for s in S:
    #print(s)
    if s in acgt:
        count += 1
    else:
        if count > max_count:
            max_count = count
        count=0
if count > max_count:
    print(count)
else:
    print(max_count)


Measured memory_bytes: 2940
n=int(input())
S=[]
for i in range(n):
    S.append(input())
from collections import Counter

d=Counter(S)
maxi=0
for i in d.keys():
    maxi=max(maxi,d[i])

ans=[]
for i in d.keys():
    if d[i]==maxi:
        ans.append(i)
ans=sorted(ans)
print('\n'.join(ans))

Measured memory_bytes: 105168
n=int(input())
A=list(map(int,input().split()))
for i in range(1,n):
    A[i]+=A[i-1]

ans=1000000
for i in range(n-1):
    now=abs(A[n-1]-2*A[i])
    if now<ans:
        ans=now
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//b>g>r

int main() {
  int x,ans,a,i;
  int r,g,b,k;
  cin >> r >> g >> b >> k;
  
  for(i=0;i<k;i++){
    if(r>=g){
      g*=2;
    }else{
      b*=2;
    }
  }
  if(b>g&&g>r){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define left mini4141

const int N = 1e5 + 10;
const int inf = 2e9;

int n, m;
char s[N], t[N];
vector<int> pos[322];
int left[322];

int main() {
  for (int i = 0; i < 322; i++)
    left[i] = inf;
  scanf("%s %s", s, t);
  n = strlen(s);
  m = strlen(t);
  for (int i = 0; i < n; i++) {
    pos[s[i] - 'a'].push_back(i);
    left[s[i] - 'a'] = min(left[s[i] - 'a'], i);
  }
  long long ans = 0;
  int cur_pos = -1;
  for (int i = 0; i < m; i++) {
    int x = t[i] - 'a';
    int at = lower_bound(pos[x].begin(), pos[x].end(), cur_pos + 1) - pos[x].begin();
    if (at < (int) pos[x].size()) {
      at = pos[x][at];
      ans += at - cur_pos;
      cur_pos = at;
    } else {
      if (left[x] == inf)
        return puts("-1"), 0;
      ans += n - cur_pos - 1;
      ans += left[x] + 1;
      cur_pos = left[x];
    }
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 1148
L, R = map(int, input().split())


#L, Rの間に2019の倍数が入っている時-->答え0(2019の倍数にできる)
if (R%2019 == 0) or (L%2019 == 0):
    print (0)
    exit()
if R//2019 > L//2019:
    print (0)
    exit()

ans = 2018
for i in range(L, R):
    for j in range(i+1, R+1):
        # print (i, j)
        ans = min((i * j)%2019, ans)
print (ans%2019)
    

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

int main(){
    int n,a;
    cin>>n;
    bool can=true;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a%2==0){
            if(a%3==0||a%5==0)can=true;
            else{
                can=false;
                break;
            }
        }
    }

    if(can)cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N;
vector<ll> c(500);
vector<ll> s(500);
vector<ll> f(500);

ll dfs(ll t, ll n){
  if(n+1==N)return t;
  if(s[n]<=t)t += t%f[n]+c[n];
  else t += s[n]-t+c[n];
  return dfs(t, n+1);
}

int main(){
  cin>>N;
  for(ll i=0;i<N;i++){
    cin >> c[i] >> s[i] >> f[i];
  }
  //for(ll i=0; i<N; i++){
  //  cout << dfs(0,i) << endl;
  //}
  for(ll i=0; i<N-1; i++){
    ll t=0;
    for(ll j=i; j<N-1; j++){
      ll tmp;
      if(t%f[j]==0)tmp=0;
      else tmp = f[j]-t%f[j];
      if(s.at(j)<=t)t += tmp+c.at(j);
      else t += s.at(j) - t + c.at(j);
    }
    cout << t << endl;
  }
  cout << 0 << endl;
}

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

int main(){
  int N;
  cin >> N;
  
  bool ans = false;
  
  rep(i, 10){
    rep(j, 10){
      if(N == i * j) ans = true;
    }
  }
  
  if(ans){
    cout << "Yes" << endl;
  } 
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b;
    cin>>n>>a>>b;
    double c;
    multiset<double> ms;
    multiset<double>::iterator itr;
    for(int i=0;i<n;i++){
        cin>>c;
        ms.insert(c);
    }
    double num=0;
    itr=ms.end();
    for(int i=0;i<a;i++){
        itr--;
        num+=*itr;
    }
    num/=a;
    doublecout(num);
    num=*itr;
    itr=ms.end();
    ll x=0,y=0;
    bool maki=false;
    for(int i=0;i<n;i++){
        itr--;
        if(*itr!=num){
            if(maki)break;
            else x++;
        }
        else{
            y++;
            maki=true;
        }
    }

    ll com[51];
    com[0]=1;
    for(ll i=1;i<=y;i++){
        com[i]=com[i-1]*(y-i+1)/i;
    }

    if(x==0){
        n=0;
        for(ll i=a;i<=min(b,y);i++){
            n+=com[i];
        }
        cout << n<<endl;
    }
    else{
        cout<<com[a-x]<<endl;
    }
    return 0;
}




Measured memory_bytes: 256
import itertools
n, m, R = map(int, input().split())
r = list(map(int, input().split()))
dis = [[0 for _ in range(n)] for _ in range(n)]
for _ in range(m):
    a, b, c = map(int, input().split())
    dis[a - 1][b - 1] = c
    dis[b - 1][a - 1] = c

def war(dis):
    size = len(dis)
    # 非接続要素が「float("inf")」なら省略可
    for i in range(size):
        for j in range(size):
            if i != j and dis[i][j] == 0:
                dis[i][j] = float("inf")
    for k in range(size):
        for i in range(size):
            for j in range(size):
                if dis[i][j] > dis[i][k] + dis[k][j]:
                    dis[i][j] = dis[i][k] + dis[k][j]
    return dis
dis = war(dis)
_min = float("inf")
it = itertools.permutations(r)
for iterR in it:
    _dis = 0
    start = iterR[0] - 1
    for end in iterR[1:]:
        _dis += dis[start][end - 1]
        start = end - 1
    _min = min(_min, _dis)
print(_min)


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

const int MXN = 3e3 + 20;

string a, b, res;
int dp[MXN][MXN];
int p[MXN][MXN];

void fill() {
	for (int i = 1; i <= a.size(); i++)
		for (int j = 1; j <= b.size(); j++) {
			if (a[i - 1] == b[j - 1]) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
				p[i][j] = 1;
			}
			else {
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
				if (dp[i - 1][j] > dp[i][j - 1])
					p[i][j] = 2;
				else
					p[i][j] = 3;
			}
		}
}

void pp() {
	int x = a.size(), y = b.size();
	while (x > 0 && y  > 0) {
		if (p[x][y] == 1) {
			res.push_back(a[x - 1]);
			x--;
			y--;
		}
		else if (p[x][y] == 2)
			x--;
		else if (p[x][y] == 3)
			y--;
	}
	reverse(res.begin(), res.end());
}

int main() {
	cin >> a >> b;
	fill();
	pp();
	cout << res << endl;
	return 0;
}


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

int main(void)
{
	int N;
	cin >> N;
	int sq = 0;
	int sum = 0;
	for (int i = 0; i < N; i++)
	{
		int t;
		cin >> t;
		sum += t;
		sq += t * t;
	}
	cout << (sum * sum - sq) / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};

void solve(){
    ll n;cin>>n;
    string s;cin>>s;
    ll q;cin>>q;
    vector<BinaryIndexedTree<ll>> g(26,BinaryIndexedTree<ll>(n+1));
    rep(i,n){
        ll idx=s[i]-'a';
        g[idx].add(i,1);
    }
    while(q--){
        ll t;cin>>t;
        if(t==1){
            ll i;cin>>i;
            i--;
            char c;cin>>c;
            ll idx=c-'a';
            ll idx2=s[i]-'a';
            g[idx2].add(i,-1);
            g[idx].add(i,1);
            s[i]=c;
        }else{
            ll l,r;cin>>l>>r;
            l--,r--;
            ll cnt=0;
            rep(i,26){
                ll tmp=g[i].sum(r);
                if(l>0)tmp-=g[i].sum(l-1);
                if(tmp>0)cnt++;
            }
            cout<<cnt<<endl;
        }
    }
}

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


Measured memory_bytes: 106396
def main():
    global visited, adj, sets
    print = out.append
    ''' Cook your dish here! '''
    q = get_int()
    points = []
    res = 0
    for _ in range(q):
        pt = get_list()
        for i in points:
            res += ((pt[0]-i[0])**2+(pt[1]-i[1])**2)**(1/2)
        points.append(pt)
    print(2*res/q)


''' Coded with love at India by Satyam Kumar '''
import sys
#from collections import defaultdict
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda: int(input())
get_list = lambda: list(map(int, input().split()))
main()
# [main() for _ in range(int(input()))]
print(*out, sep='\n')

Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}

signed main()
{
    int N; cin>>N;
    vint t(N);
    REP(i,N) cin>>t[i];

    int ans=t[0];
    REP(i,N){
        ans=lcm(ans,t[i]);
    }
    cout<<ans<<endl;
}


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


int main() {
	int n;
	int ac = 0, wa = 0, tle = 0, re = 0;

	scanf("%d", &n);
	char* s = (char*)malloc(sizeof(char) * n);

	for (int i = 0; i < n; i++) {
		scanf("%s", s + i);
	}

	for (int i = 0; i < n; i++) {
		if (*(s + i) == 'A') {
			ac++;
		}
		else if (*(s + i) == 'W') {
			wa++;
		}
		else if (*(s + i) == 'T') {
			tle++;
		}
		else if (*(s + i) == 'R') {
			re++;
		}
	}
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", ac, wa, tle, re);

	return 0;
}

Measured memory_bytes: 1800
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>

using namespace std;

int main() {
	int n, k; cin >> n >> k;
	int a = pow(k - 1, n - 1);
	cout << (unsigned long long)k*a << endl;
	
}



    

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

int main(){
    int n; ll m; cin >> n >> m;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> sum(n+1);
    map<int,ll> mp;
    sum[0] = 0;
    rep(i,n){
        sum[i+1] = (sum[i]+a[i])%m;
    }
    rep(i,n+1) mp[sum[i]]++;
    ll ans = 0;
    for(auto x : mp){
        ll y = x.second;
        ans += y*(y-1)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5376
N = int(input())
A = list(map(int,input().split()))

B = []
for i in range(N):
    B.append(A[i]-i)
B.sort()
b = B[N//2]-1

ans = 0
for i in range(N):
    ans += abs(A[i] - (b + i + 1))
print(ans)

Measured memory_bytes: 26836
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <map>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int n;
int maxn, minn = 2e9;
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int t;
		cin >> t;
		maxn = max(maxn, t);
		minn = min(minn, t);
	}
	cout << maxn - minn << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(50)
#define _popcnt __builtin_popcount

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

int fact[2000010], invfact[2000010];

int invmod(int a, int p){ // a^-1 mod p
  int b = p, u = 1, v = 0;
  while(b){
    int t = a / b;
    a -= t*b; swap(a, b);
    u -= t*v; swap(u, v);
  }
  u %= p;
  if(u < 0) u += p;
  return u;
}

void factmod(int m){
  fact[0] = invfact[0] = 1;
  for(int i = 1; i < 2000010; i++){
    fact[i] = (fact[i-1] * i) % m;
    invfact[i] = (invfact[i-1] * invmod(i, m)) % m;
  }
}

int nCrmod(int n, int r, int m){
  return (((fact[n] * invfact[r]) % m) * invfact[n-r]) % m;
}

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

  int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2;
  factmod(MOD);
  int ans = 0;
  for(int i = 1; i <= r2+1; i++){
    ans += nCrmod(i+c2, i, MOD);
    ans %= MOD;
  }
  for(int i = 1; i <= r1; i++){
    ans += nCrmod(i+c1-1, i, MOD);
    ans %= MOD;
  }
  for(int i = 1; i <= r1; i++){
    ans -= nCrmod(i+c2, i, MOD);
    if(ans < 0) ans += MOD;
  }
  for(int i = 1; i <= r2+1; i++){
    ans -= nCrmod(i+c1-1, i, MOD);
    if(ans < 0) ans += MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	string c;
  	cin >> c;
  	
  	if (c=="a"||c=="e"||c=="i"||c=="o"||c=="u"){
    	cout << "vowel" << endl;
    }
  	
  	else {
    	cout << "consonant" << endl;
    }
}

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

void textIO()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}


void fastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}

int main()
{
    //textIO();
    fastIO();

    long long n, a, b;
    cin >> n >> a >> b;
    cout << (n/(a+b))*a+min((n%(a+b)), a);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>

using namespace std;


int main() {

  int N;

  cin >> N;
  vector< vector<long long> > A(N, vector<long long>(N));

  for (auto i=0;i <N; i++)
  for (auto j=0;j <N; j++) cin >> A[i][j];

  vector<long long> F( 1<<17, 0);

  // consider all sub sets of {1..N}
  vector<int> l(16, 0);
  for (long long s = 1; s < (1<<N); s++) {
    l.resize(0);

    auto ss= s;
    int c = 0;
    while(ss != 0) {
      if (ss & 1 ) l.push_back(c);
      ss = ss >> 1;
      c++;
    }

    // for (auto tt=0; tt<l.size(); tt++) 
    // cout << "l" << l[tt] << "  ";
    // cout << endl;
    F[s] = 0;
    for (auto i=0; i < l.size(); i++)
    for (auto j=i+1; j < l.size(); j++) F[s] += A[l[i]][l[j]];

    auto L = l.size();

    for (auto i=0; i< (1<<L); i++) {
      long long a=0, b=0;
      for(auto bit=0; bit<L; bit++) {
        if ( (1<<bit) & i ) a |= (1 << (l[bit]) );
        else b |= ( 1 << (l[bit]) );

      }    
      F[s] = max( F[s],  F[a] + F[b] );
    }
    // cout << endl;
  }


  cout << F[ (1<<N)-1] << endl;

  return 0;
}

Measured memory_bytes: 1280
def pmod(a,b,m):
  ret=1
  while b>0:
    if b&1:
      ret=(ret*a)%m
    a=(a*a)%m
    b=b>>1
  return ret
  
def fmod(n,m):
  ret=1
  for i in range(n,0,-1):
    ret=(ret*i)%m
  return ret

def cmod(n,r,m):
  ret=1
  for i in range(r):
    ret=(ret*(n-i))%m
  return (ret*pmod(fmod(r,m),m-2,m))%m

def div(num):
  ret=[]
  for i in range(2,int(num**0.5)+1):
    if num%i==0:
      ret.append(i)
      num=num//i
      while num%i==0:
        ret.append(i)
        num=num//i
  if num!=1:
    ret.append(num)
  return ret

n,m=map(int,input().split())
MOD=10**9+7
d=div(m)
dic={}
for i in d:
  if i not in dic:
    dic[i]=1
  else:
    dic[i]+=1
ans=1
for i in dic.values():
  ans=(ans*cmod(n-1+i,n-1,MOD))%MOD
print(ans)

Measured memory_bytes: 3192
#include <iostream>
#include <math.h>
using namespace std;

int main(){

	double x1,y1,x2,y2,x3,y3,x,y;
	double a1,a2,b1,b2,c1,c2;
	int n,i;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		a1 = 2*(x2-x1);
		b1 = 2*(y2-y1);
		c1 = x1*x1-x2*x2+y1*y1-y2*y2;
		a2 = 2*(x3-x1);
		b2 = 2*(y3-y1);
		c2 = x1*x1-x3*x3+y1*y1-y3*y3;
		x=(b1*c2-b2*c1)/(a1*b2-a2*b1);
		y=(c1*a2-c2*a1)/(a1*b2-a2*b1);
		printf("%.3f %.3f %.3f\n",x,y,sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1)));
	}

	return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
  int n, k;
  cin >> n >> k;
  
  bool mark[10];
  memset(mark, 0, sizeof(mark));
  
  for (int i = 0; i < k; ++i)
  {
    int x;
    cin >> x;
    mark[x] = true;
  }
  
  bool ok = true;
  int t = n;
  while (ok)
  {
     int x = t;
     	
     ok = false;
     while (x)
	 {
   	 	if (mark[x % 10])
        {
          ok = true;
          break;
        }
        x /= 10;
     }
     t += ok;
  }
  cout << t;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define F first
#define S second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n;
PII a[55];
bool visit[55];
int res=1e9;
void dfs(int cur,int x,int y)
{
	visit[cur]=1;
	for (int i=0;i<n;i++)
	{
		if (visit[i]) continue;
		if (a[i].F-a[cur].F==x && a[i].S-a[cur].S==y)
		{
			dfs(i,x,y);
			return;
		} 
	}
}
int main()
{
	cin >>n;
	for (int i=0;i<n;i++) cin >>a[i].F>>a[i].S;
	if (n==1)
	{
		cout <<"1";
		return 0;
	}
	sort(a,a+n);
	for (int i=0;i<n;i++)
	{
		for (int j=i+1;j<n;j++)
		{
			fill(visit,visit+n,0);
			int x=a[j].F-a[i].F;
			int y=a[j].S-a[i].S;
			int t=0;
			for (int k=0;k<n;k++)
			{
				if (visit[k]) continue;
				dfs(k,x,y);
				t++;
			}
			res=min(res,t);
		}
	}
	cout <<res;
	return 0;
} 

Measured memory_bytes: 256
void main()
{
    int[] tmp = readln.split.to!(int[]);
    int r = tmp[0], g = tmp[1], b = tmp[2], n = tmp[3];

    int cnt;
    int x = n / r;
    foreach (i; 0 .. x+1)
    {
        int y = (n - r * i) / g;
        foreach (j; 0 .. y+1)
        {
            if ((n - r * i - g * j) % b == 0)
            {
                ++cnt;
            }
        }
    }

    cnt.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256