akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.trim_right();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

const FACT_MAX: usize = 300000;
const MOD: i64 = 1000000007;

#[allow(dead_code)]
fn pow_mod(base: i64, power: i64, modulo: i64) -> i64 {
    let mut base = base;
    let mut power = power;
    let mut ans = 1;
    while power > 0 {
        if power & 1 == 1 {
            ans = ans * base % modulo;
        }
        power >>= 1;
        base = base * base % modulo;
    }
    ans
}

thread_local! {
    #[allow(unused)]
    pub static FACT: Vec<i64> = {
        let mut fac: Vec<i64> = vec![1; FACT_MAX+1];

        for i in 1..FACT_MAX+1 {
            fac[i] = (fac[i-1] * i as i64) as i64 % MOD;
        }
        fac
    };

    #[allow(unused)]
    pub static RFACT: Vec<i64> = {
        let mut rfac = vec![1; FACT_MAX+1];
        rfac[FACT_MAX] = FACT.with(|fact| {
            pow_mod(fact[FACT_MAX], MOD-2, MOD)
        });

        for i in (1..FACT_MAX).rev() {
            rfac[i] = (rfac[i+1] * (i+1) as i64) % MOD;
        }
        rfac
    }
}

#[allow(dead_code)]
fn combi(n: usize, m: usize) -> i64 {
    let mut a = 1i64;
    let mut r = n as i64;
    for _ in 0..m {
        a *= r;
        a %= MOD;
        r -= 1;
    }

    RFACT.with(|rfact| (a % MOD) * rfact[m] % MOD)
}

fn main() {
    let (n, a, b) = parse_line!(usize, usize, usize);

    let mut v = vec![0; 100];

    let mut t = 2i64;
    for i in 1..v.len() {
        t %= MOD;
        v[i] = t;
        t = t * t;
    }

    let mut ans = 1i64;
    let mut m = n;
    for i in 1..v.len() {
        if m == 0 {
            break;
        }

        if m & 1 == 1 {
            ans *= v[i];
            ans %= MOD;
        }

        m >>= 1;
    }

    ans = ans - 1;
    if ans < 0 {
        ans += MOD;
    }
    ans %= MOD;

    ans -= combi(n, a);
    if ans < 0 {
        ans += MOD;
    }
    ans %= MOD;

    ans -= combi(n, b);
    if ans < 0 {
        ans += MOD;
    }
    ans %= MOD;

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


Measured memory_bytes: 12668
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int m1, m2, d1, d2;
  cin >> m1 >> d1 >> m2 >> d2;

  cout << ((m1 + 1 == m2 && d1 + 1 != d2 ? 1 : 0)) << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scn = new Scanner(System.in)) {
			int K = scn.nextInt();
			int A = scn.nextInt();
			int B = scn.nextInt();

			int tmp = K;
			while(tmp < A) {
				tmp = tmp + K;
			}
			if(A <= tmp && tmp <= B) {
				System.out.println("OK");
			} else {
				System.out.println("NG");
			}
		}
	}
}

Measured memory_bytes: 27084
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    char ch[10];
    scanf("%s",ch);
    int sum=0;
    for(int i=0;ch[i]!='\0';i++)
    {
        sum+=ch[i]-'0';
    }
    if(sum==1)  cout<<10<<endl;
    else cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

import jdk.nashorn.internal.runtime.regexp.joni.ScanEnvironment;

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

		int n = Integer.parseInt(sc.nextLine());
		String[] aString = sc.nextLine().split(" ");
		byte count = 0;
		boolean flag = true;
		List<Integer> a = new ArrayList<>();

		do{
			if(aString!=null){
				for(int i=0;i<n;i++){
					a.add(Integer.parseInt(aString[i]));
				}
				aString = null;
			}
			for(int i = 0;i < n;i++){
				int target = a.get(i);
				if(target % 2 != 0){
					flag = false;
					break;
				}
				a.set(i, target/2);
			}
			if(flag){
				count++;
			}
		}while(flag);

		System.out.println(count);
	}
}


Measured memory_bytes: 24404
#include <algorithm> //STLͨ���㷨
#include <cmath> //������ѧ����
#include <cstdio> //��������/�������
#include <iostream> //����������/���
#include <cstring> //�ַ�������
#include <string> //�ַ�����
#include <ctime> //�������ʱ��ĺ���
#define itn int
#define fro for
#define ll long long
#define reg register
#define inf 1234567890
#define rep(i,a,b,c) for (int i=a;i<=b;i+=c)
/*#include <bitset> //STLλ������
#include <cstype> //�ַ�����
#include <cerrno> //���������
#include <complex> //������
#include <clocale> //���屾�ػ�����
#include <cstdlib> //������������ڴ���亯��
#include <deque> //STL˫�˶�������
#include <exception> //�쳣������
#include <fstream> //�ļ�����/���
#include <functional> //STL�������㺯��(���������)
#include <limits> //�����������������ֵ����
#include <list> //STL�����б�����
#include <map> //STLӳ������
#include <iomanip> //����������/���
#include <ios> //��������/���֧��
#include <iosfwd> //����/���ϵͳʹ�õ�ǰ������
#include <istream> //����������
#include <ostream> //���������
#include <queue> //STL��������
#include <set> //STL��������
#include <sstream> //�����ַ�������
#include <stack> //STL��ջ����
#include <stdexcept> //��׼�쳣��
#include <streambuf> //�ײ�����/���֧��
#include <utility> //STLͨ��ģ����
#include <vector> //STL��̬��������
#include <cwchar.h>//���ַ�����������/���
#include <cwctype.h> //���ַ�����*/

using namespace std;

int ans;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

int gcd(int x,int y){return (!y)?x:gcd(y,x%y);}

void exgcd(int a,int b,int &d,int &x,int &y){if (!b){d=a,x=1,y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}

int quick_power(ll a,int b){ll r=1;for (;b;b>>=1,a=a*a)if (b&1) r=r*a;return r;}

inline char read() {
	static const int IN_LEN = 1000000;
	static char buf[IN_LEN], *s, *t;
	return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
	static bool iosig;
	static char c;
	for (iosig = false, c = read(); !isdigit(c); c = read()) {
		if (c == '-') iosig = true;
		if (c == -1) return;
	}
	for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0');
	if (iosig) x = -x;
}

char sr[10000000],z[20];int C=-1,Z=0;
void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(int x){
	if (x<0) sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
//int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);}

//void add(int x,int y,int z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;}
ll a[100100];
int main()
{
	ll n,k;
	read(n);read(k);
	for (int i=1;i<=n;i++) 
	{
		int q,w;
		read(q);read(w);
		a[q]+=w;
	}
	for (int i=1;;k-=a[i],i++)
		if (k<=0)
		{
			cout<<i-1;
			break;
		}
	return 0;
}









Measured memory_bytes: 2048
def p_c():
    N = int(input())
    before = [0] * 3

    for _ in range(N):
        abc = list(map(int, input().split()))
        idx, mv = max(enumerate(before), key=lambda x: x[1])
        before.pop(idx)
        for i in range(len(abc)):
            if i == idx:
                abc[i] += max(before)
            else:
                abc[i] += mv

        before = abc

    print(max(abc))


if __name__ == '__main__':
    p_c()


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

int main(void){
    // Your code here!
    int A,B,K;
    scanf("%d %d %d",&A,&B,&K);
    for(int i=0; i < K; i++)
    {
        if(i%2 == 0)
        {
            if(A%2 == 1)
                A = A-1;
                
            B += A/2;
            A /= 2;
        }
        else
        {
            if(B%2 == 1)
                B = B-1;
                
            A += B/2;
            B /= 2;
        }
    }
    printf("%d %d\n",A,B);
}


Measured memory_bytes: 128
import Control.Monad
import Data.List
import Data.Maybe
import Text.Printf

main = do
  n <- readLn
  let ans =
        head
          [ [a, b, c] | a <- [1 .. 3500 :: Int], b <- [1 .. 3500 :: Int], let ue = n * a * b, let sita = if 4 * a * b - n * (a + b) == 0 then 9999 else 4 * a * b - n * (a + b), let c = div ue sita, mod ue sita == 0 && c > 0
          ]

  printf "%d %d %d" (head ans) (ans !! 1) (ans !! 2)

Measured memory_bytes: 4044
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		Integer[] d = new Integer[n];
		for(int i = 0 ; i < n ; i++) {
			d[i] = sc.nextInt();
		}
		Arrays.sort(d, Comparator.reverseOrder());
		int ans = 0;
		for(int i = 0 ; i < k ; i++) {
			ans += d[i];
		}
		System.out.println(ans);
		sc.close();

	}

}


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

using namespace std;
using ll=long long;

int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    if((b-a)%2==0){
        cout<<(b-a)/2<<endl;
    }
    else{
        ll ans=min(a-1,n-b);

        cout<<ans+(b-a+1)/2<<endl;

    }
    return 0;
}


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

unsigned long long sum = 0;
void out(std::string msg, int* a, int left, int right)
{
    cout << msg << "[" << left << ":" << right  << "): ";
    for(int i=left; i<right; i++) cout << a[i] << " ";
    cout << endl;
}
void merge(int* a, int left, int mid, int right)
{
    //out("merge ", a, left, right);
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1+1], R[n2+1];
    for(int i=0; i<n1; i++){
        L[i] = a[left+i];
    } 
    for(int i=0; i<n2; i++){
        R[i] = a[mid+i];
    }
    //out("L", L, 0, n1);
    //out("R", R, 0, n2);
    L[n1] = 1000000001; /*std::numeric_limits<int>::infinity();*/
    R[n2] = 1000000001; /*std::numeric_limits<int>::infinity();*/
    int i=0, j=0;
    for(int k=left; k<right; k++){
        if(L[i] <= R[j]){
            a[k] = L[i]; i++;
        }else{
            a[k] = R[j]; j++;
            sum += (n1-i);
        }
    }
    //out("merged", a, left, right);
}
void mergeSort(int* a, int left, int right)
{
    //out("mergeSort", a, left, right);
    if(left+1 >= right) return;
    int mid = (left+right)/2;
    mergeSort(a, left, mid);
    mergeSort(a, mid, right);
    merge(a, left, mid, right);
}
int main()
{
    int n;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int left = 0;
    int right = n;
    mergeSort(a, left, right);
/*
    for(int i=0; i<n; i++){
        cout << a[i];
        if(i != n-1) cout << " ";
        else cout << endl;
    }
 */
    cout << sum << endl;
}


Measured memory_bytes: 4672
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define vl vector<long long>
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mod 1000000007
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define F first
#define S second
int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
long long INF = 1e9;


int main(){
    int n; cin >> n;
    vector<int> w(n); rep(n) cin >> w[i];
    //cumlative c(w);
    int ans = INF;
    for(int i = 1;i <= n-1;i++){
        int a=0,b=0;
        for(int j = 0;j < i;j++) a+= w[j];
        for(int j = i;j < n;j++) b+= w[j];
        ans = min(ans,abs(a-b));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

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

    cout<<n*(n-1)/2<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int a,b,c,x,check,count = 0;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&x);

    for (int i = 0; i < a + 1; ++i) {
        for (int j = 0; j < b + 1; ++j) {
            for (int k = 0; k < c + 1; ++k) {
                check = (500 * i) + (100 * j)  + (50 * k);
                if (check == x)count++;
            }
        }
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 1708
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>

#define P 1000000007

using namespace std;

int main() {
  unsigned long long k;
  vector<unsigned long long> v;
  v.resize(50);
  cin >> k;
  cout << 50 << endl;
  if(k <= 50) {
    for(int i = 0; i < 50 - k; i++) {
      v[i] = 0;
    }
    for(int i = 49; i >= 50 - k && i >= 0; i--) {
      v[i] = i + 1;
    }
  } else {
    k -= 50;
    for(int i = 1; i <= 50; i++) {
      v[i - 1] = i + (k / 50);
      if(i > 50 - k % 50) {
        v[i - 1] += 1;
      }
    }
  }
  cout << v[0];
  for(int i = 1; i < 50; i++) cout << " " << v[i];
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		int[] po;
		while(true) {
			int sets=sc.nextInt();
			if(sets==0) {
				break;
			}
			else {
				po=new int[sets];
				int syurui=0;
				boolean ni_aru=false;
				int tmp=0;
				for(int i=0; i<sets; i++) {
					tmp=sc.nextInt();
					if(tmp>0) {
						syurui++;
					}
					if(tmp>=2) {
						ni_aru=true;
					}
				}

				if(ni_aru==false) {
					System.out.println("NA");
				}
				else {
					System.out.println(syurui+1);
				}
			}
		}
	}
}


Measured memory_bytes: 162876
N, Q = [int(_) for _ in input().split()]
a = input()

s = [0] * (len(a) + 5)
for i in range(len(a) - 1):
    if a[i] == 'A' and a[i + 1] == 'C':
        s[i + 1] += 1
for i in range(len(s) - 1):
    s[i + 1] += s[i]

for i in range(Q):
    l, r = [int(_) for _ in input().split()]
    print(s[r-1] - s[l-1])


Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[100001],aa[100001];
int main(void){
	ll i,j,n,p,pp,f,mx,t;
	cin>>n;
	for(i=0;i<n;i++) cin>>a[i];
	p=0; mx=2;
	for(i=0;i<n;){
		f=a[i]; aa[p]=1;
		while(1){
			i++;
			if(i>=n)break;
			if(a[i]!=f) aa[p]++,f=a[i];
			else break;
		}
		mx=max(mx,aa[p]);
		p++;
	}
//	cout<<mx<<endl;
//	for(i=0;i<p;i++)cout<<aa[i]<<' '<<aa[i]<<' '<<aa[i]<<endl;
	t=aa[0]+aa[1];
	mx=max(mx,t);
	t=aa[p-1]+aa[p-2];
	mx=max(mx,t);
	for(i=1;i<p-1;i++){
		t=aa[i]+aa[i-1]+aa[i+1];
		mx=max(mx,t);
	}
	cout<<mx<<endl;
	return 0;
}


Measured memory_bytes: 4248
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int x, y, a, b, c; cin >> x >> y >> a >> b >> c;
  vector<int> p(a), q(b), r(c);
  REP(i, a) cin >> p[i];
  sort(ALL(p), greater<int>());
  REP(i, b) cin >> q[i];
  sort(ALL(q), greater<int>());
  REP(i, c) cin >> r[i];
  sort(ALL(r), greater<int>());
  ll ans = accumulate(p.begin(), p.begin() + x, 0LL) + accumulate(q.begin(), q.begin() + y, 0LL);
  int p_idx = x - 1, q_idx = y - 1;
  REP(i, c) {
    if (p_idx < 0 && q_idx < 0) break;
    if (p_idx < 0) {
      if (r[i] >= q[q_idx]) {
        ans -= q[q_idx--];
        ans += r[i];
      }
    } else if (q_idx < 0) {
      if (r[i] >= p[p_idx]) {
        ans -= p[p_idx--];
        ans += r[i];
      }
    } else if (p[p_idx] < q[q_idx]) {
      if (r[i] >= p[p_idx]) {
        ans -= p[p_idx--];
        ans += r[i];
      }
    } else {
      if (r[i] >= q[q_idx]) {
        ans -= q[q_idx--];
        ans += r[i];
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a+b>c+d)cout<<"Left"<<endl;
    if(a+b<c+d)cout<<"Right"<<endl;
    if(a+b==c+d)cout<<"Balanced"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;

int main()
{
    int a[3];
    int i;
    int ans;
    
    for(i = 0; i < 3; i++) {
        cin >> a[i];
    }
    
    sort(a, a+3);
    
    ans = a[2] - a[1];
    
    if((a[1] - a[0]) % 2 == 0) {
        ans += (a[1] - a[0]) / 2;
    } else {
        ans += 2 + ((a[1] - a[0]) / 2);
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  string a[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> a[i][j];
      if(a[i][j]=="snuke") cout << char(j+65) << i+1 <<endl;
    }
  }
}

Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 29.12.2019 23:10:39       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ar = -1;
  long long ans = -(long long) 1e18;
  vector<int> awho;
  for (int r = 0; r < 2; r++) {
    long long s = 0;
    vector<int> who;
    for (int x = r; x < n; x += 2) {
      s += max(a[x], 0);
      if (a[x] > 0) who.push_back(x);
    }
    if (s == 0) {
      s = -(long long) 1e18;
      for (int x = r; x < n; x += 2) {
        s = max(s, (long long) a[x]);
      }
      for (int x = r; x < n; x += 2) {
        if (s == a[x]) {
          who.push_back(x);
          break;
        }
      }
    }
    if (s > ans) {
      ans = s;
      ar = r;
      awho = who;
    }
  }
  cout << ans << '\n';
  vector<int> seq;
  auto Go = [&](int x) {
    seq.push_back(x);
    if (x == 0 || x == (int) a.size() - 1) {
      a.erase(a.begin() + x);
    } else {
      a[x] = a[x - 1] + a[x + 1];
      a.erase(a.begin() + x + 1);
      a.erase(a.begin() + x - 1);
    }
  };
  int L = 0, R = n - 1;
  while (awho.back() < R) {
    Go(R);
    --R;
  }
  while (awho[0] > 0) {
    Go(0);
    for (int& x : awho) --x;
  }
  while (true) {
    bool any = false;
    for (int i = 2; i < (int) a.size(); i += 2) {
      if (a[i] < 0) {
        Go(i);
        any = true;
        break;
      }
    }
    if (!any) break;
  }
  while (a.size() > 1) {
    Go(1);
  }
  cout << seq.size() << '\n';
  for (int x : seq) cout << x + 1 << '\n';
  return 0;
}


Measured memory_bytes: 256
import math

text = input()
a_str, b_str, h_str, m_str = text.split()
a = int(a_str)
b = int(b_str)
h = int(h_str)
m = int(m_str)
h_x = math.sin((h + m / 60) / 12 * 2 * math.pi)*a
h_y = math.cos((h + m / 60) / 12 * 2 * math.pi)*a
m_x = math.sin(m / 60 * 2 * math.pi)*b
m_y = math.cos(m / 60 * 2 * math.pi)*b
z = math.sqrt(pow(h_x - m_x, 2) + pow(h_y - m_y, 2))
print(z)

Measured memory_bytes: 9592
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')
from itertools import accumulate


N, K = MI()
A = LMI()

for _ in range(min(50, K)):
    accum = [0] * (N + 1)
    for i, a in enumerate(A):
        l, r = max(0, i - a), min(N - 1, i + a)
        accum[l] += 1
        accum[r + 1] -= 1
    A = list(accumulate(accum))[:-1]
print(*A)



Measured memory_bytes: 180896
#include <stdio.h>

int main( void )
{
	char string[256];
	int i;
	
	fgets( string, 256, stdin );
	for( i = 0; string[i] != '\0'; i++ )
	{
		if( string[i] >= 'a' && string[i] <= 'z' )
		{
			string[i] += ('A' - 'a');
		}
	}
	printf( "%s", string );
	
	return (0);
}

Measured memory_bytes: 524
//I am so vegetable
//#define _LOCAL_
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define CT count
#define EP empty
#define _for(i,a,b) for(ll i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll N = 2e5 + 5;
const int MOD = 998244353;
const double eps = 1e-6;
const double pi = acos(-1);
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(int x, int y) { ll ans = 1; for (; y; y >= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll comb(int n, int m) {
	if(n<m)return 0;
	ll ans = 1;
	if (m > n - m)m = n - m;
	_for(i, n - m + 1, n + 1)ans *= i;
	_for(i, 1, m + 1)ans = ans /i;
	return ans;
}
int main(){
	FIO;
	bool flag = false;
	string s;cin>>s;
	string t = s;
	int len = s.size();
	reverse(t.begin(),t.end());
	if(s==t){
		string q = s.substr(0,(len-1)/2);
		//cout<<q<<'\n';
		t = q;
		reverse(t.begin(),t.end());
		if(q==t){
			q = s.substr((len+3)/2-1);
			//cout<<q<<'\n';
			t =q;
			reverse(t.begin(),t.end());
			if(q==t)flag = true;
		}
	}
	if(flag)cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	int N;
	cin >> N;
	bool ans = true;
	for (int i = 0; i < N; i++)
	{
		int A;
		cin >> A;
		if (A%2 == 0)
		{
			if (!(A%3 == 0 || A%5 == 0))
			{
				ans = false;
			}
		}
	}
	cout << (ans ? "APPROVED" : "DENIED") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define mod 1000000007
#define F first
#define S second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
const int N = 2e5+5;
int main()
{
	sync;
	ll x,y;
	cin >> x >> y;
	ll b = (y - 2 * x);
	if(b % 2 || b < 0)
		return cout << "No", 0;
	b /= 2;
	ll a = x - b;
	if(a >= 0)
		cout << "Yes";
	else
		cout << "No";
	}
	

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }



using pll = pair<long long, long long>;
int N;
long long D, A;
vector<pll> v;

long long solve() {
    sort(v.begin(), v.end());
    long long res = 0;
    queue<pair<long long, long long>> que;
    long long num = 0;
    for (int i = 0; i < N; ++i) {
        while (!que.empty() && v[i].first > que.front().first) {
            num -= que.front().second;
            que.pop();
        }
        v[i].second -= num;
        if (v[i].second <= 0) continue;
        res += v[i].second;
        que.push({v[i].first + D*2, v[i].second});
        num += v[i].second;
    }
    return res;
}

int main() {
    while (cin >> N >> D >> A) {
        v.resize(N);
        for (int i = 0; i < N; ++i) {
            cin >> v[i].first >> v[i].second;
            v[i].second = (v[i].second + A - 1) / A;
        }
        cout << solve() << endl;
    }
}


Measured memory_bytes: 4992
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
using namespace boost::multiprecision;  
using namespace boost::math;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
constexpr int MOD = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
//inline int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
//inline int lcm(int a,int b){ return a / gcd(a,b) * b;}
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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

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

    int h,n;
    cin >> h >> n;
    int sum = 0;

    rep(i,n){
        int a;
        cin >> a;
        sum += a;
    }

    cout << (sum >= h ? "Yes\n" : "No\n");

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<ull> vul;
#define For(i, n) for(ll i = 0; i < n; i++)
#define len(n) (ll)(n).size()
#define FAST_IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define Sort(a) sort(a.begin(), a.end())

bool dp[(ll)1e5 + 1];
vl a;

int main() {
    FAST_IO;
    ll n, k;
    cin >> n >> k;
    For(i, n) {
        ll elem;
        cin >> elem;
        a.push_back(elem);
    }
    for (ll i = 0; i <= k; i++) {
        For(j, len(a)) {
            if (i - a[j] >= 0) {
                if (!dp[i]) {
                    dp[i] = 1;
                    if (dp[i - a[j]]) dp[i] = 0;
                }
            }
        }
    }
    cout << (dp[k] ? "First\n" : "Second\n");
    return 0;
}

Measured memory_bytes: 3756
A,B,C,X,Y = list(map(int,input().split()))
min_xy = min(X, Y)
cost = 0
if A + B > C * 2:
    cost += C * 2 * min_xy
    X -= min_xy
    Y -= min_xy

if A > C*2:
    cost += C*2*X
else:
    cost += A*X
    
if B > C*2:
    cost += C*2*Y
else:
    cost += B*Y
    
print(cost)

Measured memory_bytes: 3064
sieve = [0] * 300001
for i in range(6, 300000, 7):
    sieve[i] = sieve[i+2] = 1

MSprimes = []
for i in range(6, 300000, 7):
    if sieve[i] == 1:
        MSprimes.append(i)
        for j in range(2*i, 300000, i):
            sieve[j] = 0
    if sieve[i+2] == 1:
        MSprimes.append(i+2)
        for j in range(2*(i+2), 300000, i+2):
            sieve[j] = 0

while True:
    N = int(input())
    if N == 1: break
    ansp = [x for x in MSprimes if N % x == 0]
    print('{}: {}'.format(N, ' '.join(map(str, ansp))))

Measured memory_bytes: 11008
def dfs(A):
    x ="".join(A)
    if 3 <=len(A) :
        
        if int(x) <=N :
            if x.count("3") >=1 and x.count("5") >=1 and x.count("7") >=1:
                c.append(int(x))
    if len(x) ==len(str(N)): #終了条件
        return

    for i in ["3","5","7"] :
        A.append(i)
        dfs(A)
        A.pop()
 
N = int(input())
c =[]
a =dfs([])
print(len(c))

Measured memory_bytes: 9984
object Main extends App {
  val scanner = new java.util.Scanner(System.in)

  val n = scanner.nextInt()

  type Station = (Int, Int, Int)

  val csf = (1 to (n-1)).map { _ =>
    (scanner.nextInt(), scanner.nextInt(), scanner.nextInt())
  }

  def go(time: Int, nexts: Seq[Station]): Int =
    nexts match {
      case Nil   => time
      case x +: xs =>
        val (c, s, f) = x
        if(time <= s) {
          go(s + c, xs)
        } else {
          val just = (time - s) % f
          val next = (f - just) % f
          go(time + next + c, xs)
        }
    }

  csf.tails.map(go(0, _)).foreach(println)
}


Measured memory_bytes: 42872
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
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;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n,m,k,ans;
signed main(){
	cin>>n>>m>>k;
	init_fact(200000);
	for(int i=1;i<n;i++){
		ans+=i*(n-i)%MOD*m*m%MOD;
		ans%=MOD;
	}
	for(int i=1;i<m;i++){
		ans+=i*(m-i)%MOD*n*n%MOD;
		ans%=MOD;
	}
	cout<<ans*comb(n*m-2,k-2)%MOD<<endl;
	return 0;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main {
  public static void main(String... args) {
    Scanner input = new Scanner(System.in);
    
    int n = input.nextInt();
    int[] p = new int[n + 1];
    
    Map<Integer, Integer> tree = new HashMap<>();
    
    for (int i = 2; i <= n; i++) {
      tree.merge(input.nextInt(), 1, Integer::sum);
    }
    
    for (int i = 1; i <= n; i++) {
      System.out.println(tree.getOrDefault(i, 0));
    }
  }
}

Measured memory_bytes: 75756
#include <bits/stdc++.h>
using namespace std;
// types
typedef long long ll; 
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
// IO
#define fo(i, n) for (int i = 0; i < n; i++)
#define fo1(i, n) for (int i = 1; i <= n; i++)
#define sc(n) scanf("%d", &n) 
#define sca(a, n) fo(i, n) sc(a[i])
#define pd(a) printf("%d ", a)
#define pld(a) printf("%d\n", a)
#define pda(a, n) fo(i, n) pd(a[i])
#define pl printf("\n")
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b) 
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
// math
const ll mod = 1e9+7;
template<typename T> T gcf(T a, T b) {return (b == 0) ? a : gcf(b, a%b);} 
template<typename T> T lcm(T a, T b) {return (a*b)/gcf(a, b);}
template<typename T> T sumTo(T x) {return x * (x+1) / 2;}
template<typename T> T sumSquaresTo(T x) {return x * (x+1) * (2*x+1) / 6;}
template<typename T> T ceilDiv(T n, T d) {return (n+d-1)/d;}

void solve() {
    int n; sc(n);
    if (n < 30) {
        cout << "No";
    }
    else {
        cout << "Yes";
    }

}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3692
package main

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

func main() {
	io, flush := NewIO()
	defer flush()
	n, k := io.ScanInt(), io.ScanInt()
	eh := io.ScanInts(n)
	sort.Ints(eh)
	var sum int
	for i := 0; i < n-k; i++ {
		sum += eh[i]
	}
	io.Println(sum)
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	vector<int>v(N); rep(i, 0, N) { cin >> v[i]; }
	int p = accumulate(all(v), 0ll);

	auto f = [&](int x) {
		return accumulate(all(v), 0ll, [&](int a, int b) {return a + (x - b)*(x - b); });
	};

	cout << min(f(p / N), f((p + N - 1) / N)) << endl;

	return 0;
}


Measured memory_bytes: 256
//--satori--
#include <algorithm>
#include <cstdio>

const int Maxv = 200010; 

int num[Maxv], n; 
long long ans; 

int main() {
    scanf("%d", &n); 
    for (int i = 0; i < n; i++) {
        scanf("%d", &num[i]); 
        num[i] -= i + 1; 
    }
    
    std::sort(num, num + n); 
    int tmp = num[(n >> 1)]; 

    for (int i = 0; i < n; i++) 
        ans += abs(num[i] - tmp); 

    printf("%lld\n", ans); 

    return 0; 
}


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

int main(void){
    long n;
    cin >> n;
    
    if( n&1 ){
        cout << 0 << endl;
        return 0;
    }

    long nTmp = n/2;
    long ans = 0, multiple = 5;
    while( nTmp >= multiple ){
        ans += nTmp / multiple;
        multiple *= 5;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int A = sc.nextInt();
      int B = sc.nextInt();
      int ans = A - (2*B);
      if(ans>0){
      System.out.println(ans);
      }else{
        System.out.println("0");
      }
    }
  
  private static long lcm(long m, long n) {
    return m * n / gcd(m, n);
}
  
  private static long gcd(long m, long n) {
    if(m < n) return gcd(n, m);
    if(n == 0) return m;
    return gcd(n, m % n);
}
}

Measured memory_bytes: 21844
#include <iostream>

int main()
{
	int a = 0, b = 0, S = 0, P = 0; //Initialisation
	std::cin >> a >> b;
	S = a * b;
	P = 2 * (a + b);
	std::cout << S << " " << P <<std::endl;
	return 0;	
}

Measured memory_bytes: 1164
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from operator import mul


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


k = I()
s = S()
if len(s) > k:
    print(s[:k] + '...')
else:
    print(s)

Measured memory_bytes: 76644
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
using namespace std;
template<typename T>
void get(T& t){cin >> t;}
int main(void){
	string s;
	get(s);
	if(s.find("AC") < s.size())cout << "Yes"<<endl;
	else cout << "No"<<endl;return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char S[10];
int A[300];
int main() {
	scanf("%s",S+1);
	for(int i=1; i<=4; i++)A[S[i]]++;
	for(int i=1; i<=4; i++)if(A[S[i]]!=2) {
			printf("No");
			return 0;
		}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define ll long long

ll N, K;

bool check(ll m, vector<ll>& A, vector<ll>& F) {
  ll cost = 0, B;
  for(ll i=0; i<N; ++i){
    B = m/F[i];
    cost += max<ll>(A[i]-B, 0);
  }
  return cost<=K;
}

int main(){
  cin >> N >> K;

  vector<ll> A(N);
  vector<ll> F(N);
  for(ll i=0; i<N; ++i) cin >> A[i];
  for(ll i=0; i<N; ++i) cin >> F[i];

  sort(A.begin(), A.end());
  sort(F.begin(), F.end(), std::greater<int>() );

  ll mmax = A[N-1]*F[0] + 1;
  ll mmin = -1;
  ll mtgt = mmax/2;
  ll ans;

  while(true) {
    bool ok = check(mtgt, A, F);
    if(ok) {
      if(mtgt-mmin==1) { ans = mtgt; break; }
      mmax = mtgt;
      mtgt = (mmax+mmin)/2;
    }else{
      if(mmax-mtgt==1) { ans = mmax; break; }
      mmin = mtgt;
      mtgt = (mmax+mmin)/2;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

const int N=101000;
int n,m,l,r,ret[N],c[N];
VI v[N],q[N];
void modify(int x) { for (;x<=m;x+=x&-x) c[x]++; }
int query(int x) { int s=0; for (;x;x-=x&-x) s+=c[x]; return s;}
int main() {
	scanf("%d%d",&n,&m);
	rep(i,1,m+1) {
		for (int j=i;j<=m;j+=i) v[j].pb(j-i);
	}
	rep(i,1,n+1) {
		scanf("%d%d",&l,&r);
		q[r].pb(l);
	}
	per(i,1,m+1) {
		for (auto x:q[i]) modify(x);
		for (auto x:v[i]) ret[i-x]+=query(i)-query(x);
	}
	rep(i,1,m+1) {
		printf("%d\n",ret[i]);
	}
}


Measured memory_bytes: 16896
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

string N;
int main(){
    cin>>N;
    cout<<((N[1]=='R')?"ABC":"ARC")<<endl;

    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

#define INF INT_MAX/2;
ll dp[55][55][2505];
int x[55]={};

int main(){
  int n,a;
  cin>>n>>a;
  for(int i=0;i<n;i++) cin>>x[i];
  for(int i=0;i<51;i++){
    for(int j=0;j<51;j++){
      for(int k=0;k<2501;k++){
        dp[i][j][k]=0;
      }
    }
  }
  dp[0][0][0]=1;
  for(int i=0;i<=50;i++){
    for(int j=0;j<=50;j++){
      for(int k=0;k<=2500;k++){
        if(dp[i][j][k]){
          dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
          dp[i+1][j][k]+=dp[i][j][k];
        }
      }
    }
  }
  ll ans=0;
  for(int i=1;i<=n;i++){
    ans+=dp[n][i][a*i];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 57472
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n; cin >> n;
  vi cnt(n, 0);
  for(int i = 1;i*i <= n; i++){
    for(int j = 1; j*j <= n; j++){
      for(int k = 1; k*k <= n; k++){
        if(i*i + j*j + k*k + i*j + j*k + k*i <= n){
          cnt[i*i + j*j + k*k + i*j + j*k + k*i - 1]++;
        }
      }
    }
  }
  for(int i = 0; i < n; i++){
    cout << cnt[i] << endl;
  }

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


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

void swap(int *a, int i, int j) {
    int tmp = a[i];
    a[i] = a[j];
    a[j] = tmp;
}

void selectionSort(int *a, int n, int &ans) {
    for (int i = 0; i < n; ++i) {
        int minj = i;
        for (int j = i; j < n; ++j) {
            if (a[j] < a[minj]) minj = j;
        }
        if (i == minj) continue;
        else swap(a, i, minj);
        ++ans;
    }
}

int main() {

    int n;
    cin >> n;

    int *a = new int[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    int ans = 0;
    selectionSort(a, n, ans);

    int _n = n - 1;
    for (int i = 0; i < n; ++i) {
        if (i != _n) cout << a[i] << " ";
        else cout << a[i] << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1188