akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using static System.Math;

namespace CSharpSpiral {
	class Program {
		static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush=
#if DEBUG
			true
#else
			false
#endif
			};
			Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ' '));
			Console.Out.Flush();
		}
		public void Solve(ConsoleInput cin) {
			var S = cin.ReadLine;
			var N = S.Length;
			var Res = 0L;
			var dest = N-1;
			for(int i = N-1; i>=0; i--) {
				if(S[i]=='B') 
					Res+=(dest--)-i;
			}
			Console.WriteLine(Res);
		}
	}
	static class ExtendClass {
		public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator=separator;
			this._stream=stream;
			inputStream=new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count!=0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i<tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i<N; ++i)
				ret[i]=Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i<N; ++i) ret[i]=ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i<N; ++i) ret[i]=ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i<N; ++i) ret[i]=ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek()==-1; }
		}
	}
}

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

int main() {
  string str;
  getline(cin,str);
  for(int i=0;i<str.size();i++) {
    if('a' <= str[i] && str[i] <= 'z') {
      str[i] = str[i] - 'a' + 'A';
    }
  }
  cout << str << endl;
}

Measured memory_bytes: 1172
#include<stdio.h>
#include<math.h>
int main(void)
{
	int a,b,c,d,e,f;
	int n = 0,i;
	double x[1000],y[1000];
	while(scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f) != EOF){
		x[n]=(double)(c*e-b*f)/(a*e-b*d);
		y[n]=(double)(d*c-a*f)/(b*d-e*a);
		if(fabs(x[n])<1e-6)x[n]=0;
		if(fabs(y[n])<1e-6)y[n]=0;
		n++;
	}
	for(i=0;i<n;i++){
		printf("%.3f %.3f\n",x[i],y[i]);
	}
	return 0;
}

Measured memory_bytes: 648
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define PB push_back
#define SP << " " <<

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;

__attribute__((constructor))
void initial(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed <<setprecision(15);
}


int main(void){
	ll N, A, B;
    cin >> N >> A >> B;
    ll C = A+B;
    ll D = N%C;
    if(D>=A){
        D = A;
    }
    ll ans = N/C * A + D;
    cout << ans << endl;
    return 0;
}


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

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

    int x = (INF - S % INF) % INF;
    int y = (S + x) / INF;

    cout << "0 0 1000000000 1 " << x << " " << y << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lc "\n"
#define fast_io ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define int long long
#define c(a,n) for(int i = 0; i < n; i++) cin >> a[i];
#define ffor(n) for(int i = 0; i < n; i++)
 
typedef vector<int> vi;
typedef vector<float> vf;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef map<string,int> msi;
typedef map<int,int> mii;
typedef unordered_map<string,int> umsi;
 
 
int32_t main()
{
    fast_io;
    int n,k;
    cin>>n>>k;
    vi a(n);
    c(a,n);
    vi dp(n,INT_MAX);
    dp[0]=0;
    if(n==1)
    {
        cout<<0<<lc;
        return 0;
    }
    dp[1]=abs(a[1]-a[0]);

    for(int i=2;i<n;i++)
    {
        for(int j=1;j<=k;j++)
        if(i-j>=0)
        dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
    }
    cout<<dp[n-1]<<lc;
    return 0;
}

Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define len(arr) (int)(sizeof(arr)/sizeof((arr)[0]))
#define Sort(arr) sort(arr,arr+len(arr))
#define For(i,s,n) for(int i=s;i<n;i++)	
#define Rep(i,n) for(int i=0;i<n;i++)
#define Per(i,n) for(int i=n;i>=0;i--)
#define All(x) (x).begin(),(x).end()
#define in(arr,n) Rep(i,n) cin >> arr[i];
#define in2(arr1,arr2,n) Rep(i,n) cin >> arr1[i] >> arr2[i];
#define in3(arr1,arr2,arr3,n) Rep(i,n) cin >> arr1[i] >> arr2[i] >> arr3[i];
#define LL_MAX 9223372036854775807
#define LL_MIN -9223372036854775808
#define MOD 1000000007
#define MOD9 1000000009

//{ ライブラリ

// 標準出力の高速化
#define endl "\n"

// 出力
template<typename Type>
void print(Type a[],int n){
	Rep(i,n) cout << a[i] << endl;
}
template<typename Type1,typename Type2>
void print(Type1 a[],Type2 b[],int n){
	Rep(i,n) cout << a[i] << " " << b[i] << endl;
}
template<typename Type1,typename Type2,typename Type3>
void print(Type1 a[],Type2 b[],Type3 c[],int n){
	Rep(i,n) cout << a[i] << " " << b[i] << " " << c[i] << endl;
}

// 配列の最大値
template<typename Type>
Type max(Type a[],int n){
	Type ret=a[0];
	For(i,1,n) ret=max(ret,a[i]);
	return ret;
}

// 配列の最小値
template<typename Type>
Type min(Type a[],int n){
	Type ret=a[0];
	For(i,1,n) ret=min(ret,a[i]);
	return ret;
}

// 最大公約数
template<typename Type>
Type gcd(Type a,Type b){return(b==0)?a:gcd(b,a%b);}
template<typename Type>
Type gcd(Type a[],int n){
	Type ret=a[0];
	For(i,1,n) ret=gcd(ret,a[i]);
	return ret;
}

// 最小公倍数
template<typename Type>
Type lcm(Type a,Type b){return (a/gcd(a,b))*b;}
template<typename Type>
Type lcm(Type a[],int n){
	Type ret=a[0];
	For(i,1,n) ret=lcm(ret,a[i]);
	return ret;
}

// aを元にしてペアでソート
template<typename Type1,typename Type2>
void PairSort(Type1 a[],Type2 b[],int left,int right){
	int i=left,j=right;
	Type1 p=a[(left+right)/2];
	while(true){
		while(a[i]<p) i++;
		while(p<a[j]) j--;
		if(i>=j) break;
		swap(a[i],a[j]);
		swap(b[i],b[j]);
		i++;j--;
	}
	if(left<i-1) PairSort(a,b,left,i-1);
	if(j+1<right) PairSort(a,b,j+1,right);
}
template<typename Type1,typename Type2,typename Type3>
void PairSort(Type1 a[],Type2 b[],Type3 c[],int left,int right){
	int i=left,j=right;
	Type1 p=a[(left+right)/2];
	while(true){
		while(a[i]<p) i++;
		while(p<a[j]) j--;
		if(i>=j) break;
		swap(a[i],a[j]);
		swap(b[i],b[j]);
		swap(c[i],c[j]);
		i++;j--;
	}
	if(left<i-1) PairSort(a,b,c,left,i-1);
	if(j+1<right) PairSort(a,b,c,j+1,right);
}

// 配列を逆順にする
template<typename Type>
void Reverse(Type a[],int n){Rep(i,n/2) swap(a[i],a[n-i-1]);}

// 文字列を逆順にする
// reverse(All(str));

//}

int main(){
	char S[4];
	scanf("%s",S);
	
	Sort(S);
	if(S[0]==S[1]&&S[1]!=S[2]&&S[2]==S[3]) cout << "Yes";
	else cout << "No";
}

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

int main() {
	char str[51];
	cin >> str;
	int len = strlen(str)-8;
	for (int i = 0; i < len; i++) {
		printf("%c", str[i]);
	}
	
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
#import math
#def combinations_count(n, r):
#    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
A_lst = list(map(int,input().split()))
S = Counter(A_lst)
sums = 0
#for i in S.keys():
#    if S[i] > 1:
#        sums += combinations_count(S[i], 2)
for c, i in S.items():
    sums += i*(i-1)//2

for j in range(1, N + 1):
    if S[A_lst[j-1]] == 2:
        print(sums - 1)
    elif S[A_lst[j-1]] > 2:
        print(int(sums - S[A_lst[j-1]] * (S[A_lst[j-1]]-1) * 0.5 + (S[A_lst[j-1]] - 1) * (S[A_lst[j-1]] - 2) * 0.5))
    else:
        print(sums)

Measured memory_bytes: 109940
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



int main(){
    ll x,y;
    cin >> x >> y;
    ll ans = 0;
    while(x <= y){
        ans++;
        x *= 2;
    }
    P(ans);
	return  0;
}

Measured memory_bytes: 256
function main(input) {
  var H = input[0].split(" ")[0]-0;
  var N = input[0].split(" ")[1]-0;
  var list = [];
  for(var i=1;i<=N;i++){
    list.push(input[i].split(" ").map(v=>v-0));
  }
  var dp = [0];
  var ans = Number.MAX_VALUE;
  for(var i=1;i<=H;i++){
    var min_mana = Number.MAX_VALUE;
    for(var j=0;j<N;j++){
      var a = list[j][0]; // power 
      var b = list[j][1]; // nama
      if(dp[i-a]){
        min_mana = Math.min(min_mana, dp[i-a] + b);
      }else{
        if(i<=a){
          min_mana = Math.min(min_mana, b);
        }
      }
    }
    dp[i] = min_mana;
  }
  console.log(dp[H]);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').split("\n"))


Measured memory_bytes: 11176
#include <iostream>

int
main(int argc, char** argv) {
    int N, K;
    std::string S;
    std::cin >> N >> K;
    std::cin >> S;

    const char* wp = S.c_str();
    const int gap = 'A' - 'a';
    for (int i = 0; i < N; i++) {
        if ((i + 1) == K) {
            std::printf("%c", *(wp + i) - gap);
        } else {
            std::printf("%c", *(wp + i));
        }
    }

    std::printf("\n");
    return 0;
}

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

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

signed main() {
    int n;cin>>n;

    vi c(n);
    rep(i, 1, n){
        int p;cin>>p;
        p--;
        c[p]++;
    }
    rep(i, n){
        cout << c[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 4784
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define STSIZE 1000

void push(int);
int pop(void);

int stack[STSIZE];
int top=0;
  

int main(){
  int num1,num2,num,s;
  char array[100];

  while(1){
    scanf("%s",array);
    
    if(array[0]=='+'){
      num1=pop();
      num2=pop();
      push(num1+num2);
      if(getchar()=='\n'){
	printf("%d\n",pop());
	break;
      }
    }
    else if(array[0]=='-'){
      num1=pop();
      num2=pop();
      push(-num1+num2);
      if(getchar()=='\n'){
	printf("%d\n",pop());
	break;
      }
    }
    else if(array[0]=='*'){
      num1=pop();
      num2=pop();
      push(num1*num2);
      if(getchar()=='\n'){
	printf("%d\n",pop());
	break;
      }
    }
    else push(atoi(array));
  }
 
 
  return 0;
}

void push(int num){
  if(top==STSIZE) exit(2);
  stack[top]=num;
  top++;
}

int pop(){
  if(top==0) exit(3);
  top--;
  return stack[top];
}



Measured memory_bytes: 2108
n = int(input())
a = [ int(x) for x in input().split() ]

l = []
if n % 2 == 1:
    i = n-1
    while i >= 0:
        l.append(a[i])
        i -= 2

    j = 1
    while j < n:
        l.append(a[j])
        j += 2
else:
    i = n-1
    while i >= 0:
        l.append(a[i])
        i -= 2

    j = 0
    while j < n:
        l.append(a[j])
        j += 2

print(' '.join(map(str, l)))


Measured memory_bytes: 34696
import sys, math
from itertools import combinations
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N, K = mi()
    if K%2==1:
        print((N//K)**3)
    else:
        print((math.floor((N//(K//2))/2))**3+(math.ceil((N//(K//2))/2))**3)

if __name__ == '__main__':
    main()

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

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main() {
    long long N;
    cin >> N;
    auto pf = prime_factorize(N);
    long long res = 0;
    for (auto p : pf) {
        long long e = p.second;
        long long tmp = 0, cur = 1;
        while (e >= cur) e -= cur++, ++tmp;
        res += tmp;
    }
    cout << res << endl;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
void YN(int a){if(a==1)printf("Yes\n");if(a==0)printf("No\n");}
LL lpow(LL a,LL n){LL ans=pow(a,n)*10;if(ans%10<5)return ans/10;return ans/10+1;}
LL dup(LL a,LL d){if(a%d==0)return a/d;else return a/d+1;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
int scmpr(const void* a,const void* b){return strcmp(*(char**)b,*(char**)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int main(){
  LL i,ans=0;
  char N[10000005];
  scanf("%s",N);
  LL n=strlen(N);
  for(i=n-1;i>=0;i--){
    if(N[i]-'0'<5)ans+=N[i]-'0';
    if(N[i]-'0'>5){
      if(i==0)ans+=11-(N[i]-'0');
      else N[i-1]++,ans+=10-(N[i]-'0');
    }
    if(N[i]-'0'==5){
      if(i>0){
        if(N[i-1]-'0'>4)N[i-1]++;
        /*if(N[i-1]-'0'==4){
          if(i>1)if(N[i-1]-'0'==4&&N[i-2]-'0'>4)N[i-1]++;
        }*/
      }
      ans+=5;
    }
  }

  printf("%lld\n",ans);
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  for (int i = 0; i < N; ++i) cin >> v.at(i);
  set<int> values; // insert するときに重複を取り除いてくれます
  for (int i = 0; i < N; ++i) {
    values.insert(v.at(i)); // 挿入します
  }
    // set のサイズを出力します
  cout << values.size() << endl;
}


Measured memory_bytes: 256
import numpy as np

x = input()
x = str(x)
y = 0
z = len(x)
for i in range(1, z):
  if int(x[0]) < int(x[i]):
    y = 1
if y == 0:
  w = int(x[0])
else:
  w = int(x[0]) + 1
y = 0
for i in range(z):
  y = y + int(w) * (10 ** (z - i - 1))
print(y)

Measured memory_bytes: 14440
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	int n, i;
	cin >> n >> i;

	cout << n - i + 1 << endl;

}

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

const int N = 100000 + 10;

bool f[N];

std::string s;

const std::string pat[4] = {"dream", "dreamer", "erase", "eraser"};

int main() {
  std::cin >> s;
  f[0] = true;
  for (int i = 0; i < s.length(); ++i) {
    if (!f[i]) continue;
    for (int j = 0; j < 4; ++j) {
      std::string cur = s.substr(i, pat[j].length());
      if (cur == pat[j]) f[i + pat[j].length()] = true;
    }
  }
  puts(f[s.length()] ? "YES" : "NO");
  return 0;
}


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

using namespace std;

int A[200001];

long long val(int b, int n) {
  long long res = 0;
  for(int i=1; i<=n; i++){
    res += abs<int>(A[i]-(b+i));
  }
  return res;
}
  
int main(void) {
  int N;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
  }

  int l = -N, r = 1e9+N, mid;
  while(r - l > 1) {
    mid = (l + r) / 2;
    if(val(mid-1,N) >= val(mid,N)) {
      l = mid;
    }else{
      r = mid;
    }
  }

  cout << val(l, N) << endl;
  return 0;
}


Measured memory_bytes: 1024
def print_ans(X,t):
    """Print max(X-t,0)

    Parameters
    --------------

    Examples
    ------------
    >>> print_ans(3,0)
    3
    >>> print_ans(3,2)
    1
    >>> print_ans(2,5)
    0
    """
    print(max(0,X-t))

if __name__ == '__main__':
    X,t = map(int,input().split())
    print_ans(X,t)


Measured memory_bytes: 38384
#include<stdio.h>
#include<string.h>
int main(){
    char x[1000] = {0};
    int hint[1000] = {0};
    int ans = 0;
    int j;
    while(1){
        scanf("%s",&x);
        if(x[0]==48){
            break;
        }
        for(j=0;j<strlen(x);j++){
            hint[j] = shori(x[j]);
            ans+=hint[j];
        }
        printf("%d\n",ans);
        ans = 0;
    }
    return 0;
}

int shori(int i){
    int back = i-48;
    //printf("%d\n",back);
    return back;
}

Measured memory_bytes: 536
#include<iostream>
#include<cmath>
#include<algorithm>
#include<set>
#include<vector>

using namespace std;

int main()
{
	int n,k;
	cin>>n>>k;
	
	vector<int> a(n+1);
	
	for(int i=1;i<n+1;i++)
	{
		cin>>a[i];
	}
	
	vector< pair<int,int> > data[n+1];
	vector<int> dist(n+1,1000000000);
	
	dist[1]=0;
	
	for(int i=1;i<=n-1;i++)
	{
		for(int j=i+1;j<=n && j<=i+k;j++)
		data[i].push_back({j,fabs(a[j]-a[i])});
		//data[i].push_back({i+2,fabs(a[i+2]-a[i])});
	}
	
	//data[n-1].push_back({n,fabs(a[n-1]-a[n])});
	
	multiset< pair<int,int> > s;
	
	s.insert({0,1});
	
	while(!s.empty())
	{
		pair<int,int> p=*s.begin();
		int ver=p.second;
		s.erase(s.begin());
		
		for(int i=0;i<data[ver].size();i++)
		{
			int v=data[ver][i].first;
			int d=data[ver][i].second;
			
			if(dist[ver]+d<dist[v])
			{
				dist[v]=d+dist[ver];
				s.insert({dist[v],v});
			}
		}
	}
	
	cout<<dist[n];
	
	return 0;
}


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

B = []
for i in range(N):
    if i == 0:
        B.append(A[i])
    else:
        B.append(A[i]+A[i-1])
B.append(A[-1])

ans = 0
for i in range(N):
    if B[i] > x:
        a = B[i] - x
        ans += a
        B[i] -= a
        B[i+1] -= a
if B[N] > x:
    ans += B[N]-x

print(ans)


Measured memory_bytes: 64356
#include<stdio.h>
#include<math.h>

int isprime(int x){
    if(x==2)            return 1;
    if(x<2 || x%2==0)   return 0;
    for(int i=3 ; i<=sqrt(x) ; i+=2){
        if(x%i==0)      return 0;
    }
    return 1;
}

int main(void){
    int n, x, c=0;
    scanf("%d", &n);
    for(int i=0 ; i<n ; i++){
        scanf("%d", &x);
        c += isprime(x);
    }
    printf("%d\n", c);
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using Graph = vector<vector<int>>;
const int MOD = 1e9 + 7;

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

    int N, M;
    cin >> N >> M;

    unordered_map<int, int> mp;
    mp[0] = 1;

    ll ans = 0;
    int sum = 0;
    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        (sum += A) %= M;
        ans += (mp[sum]++);
    }

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


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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 (a>b) { a = b; return 1; } return 0; }

int main(){
    ll a, b;
    cin >> a >> b;
    ll res = 0;
    if (a > b) res = a-1;
    else res = min(a, b);
    cout << res << "\n";
}


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

using LL = long long int;
constexpr LL MOD = 1e9 + 7;
pair<int, int> directions[] = { {0, 1}, {0, -1}, {1, 0}, {-1, 0} };

class Solution {
public:

};

void test() {
    Solution s;
}

void run() {
    Solution s;
}

int main() {
//    test();
//    run();
    int N;
    while(cin >> N) {
        vector<int> A(N);
        for (auto &a : A) { cin >> a; }
        int total = 1;
        for (int i = 0; i < N; ++i) {
            total *= 3;
        }
        int odd = 1;
        for (auto a : A) {
            if (a & 1) {
//            odd *= 1;
            }
            else {
                odd *= 2;
            }
        }
        cout << (total - odd) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from math import tan,atan,pi
a,b,x = map(int, input().split())

def check(t):
    if t < atan(b/a):
        s = a*a*b - a*a*a*tan(t)/2
    else:
        s = a*b*b/tan(t)/2
    return x<s

ok = 0
ng = pi/2

while ng-ok>10**-8:
    mid = (ok+ng)/2
    if check(mid):
        ok = mid
    else:
        ng = mid

print(ok*180/pi)

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

long int Euclid(long int A, long int B){
  if(A<B) return Euclid(B, A);
  while(B!=0){
    long int R = A%B;
    A = B; B = R;
  }
  return A;
}


int main(){
  int K;
  std::cin >> K;

  long long sum = 0;
  for(int i = 1 ; i <= K ; i++){
    for(int j = 1 ; j <= K; j++){
      for(int k = 1 ; k <= K ; k++){
	int A = Euclid(j, k);
	int B = Euclid(i, A);
	sum += B;
      }
    }
  }

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


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main()
{
	int n;
	int a[100000];
	int b[100000];
	int ans;
	int min;
	
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
	}
	min = 0;
	for(int i=0;i<n;i++)
	{
		if(b[min] > b[i])
		{
			min = i;
		}
	}

	ans = a[min] + b[min];


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

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int64_t n;
    cin >> n;
    vector<int64_t> a(n);
    rep(i,0,n) cin >> a[i];
    int64_t s=0;
    rep(i,0,n) s+=a[i];
    if(s%(n*(n+1)/2)!=0){
        //cerr << "BBBBBBBBBB" << endl;
        cout << "NO" << endl;
        return;
    }
    int64_t k=s*2/(n*(n+1));
    int64_t x=0;
    rep(l,0,n){
        int64_t d=a[(l+1)%n]-a[l];
        if(k-d<0 or (k-d)%n!=0 or (k-d)/n>k){
            cout << "NO" << endl;
            return;
        }
        int64_t i=(k-d)/n;
        x+=i;
    }
    if(x==k) cout << "YES" << endl;
    else cout << "NO" << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int mINF = 1e9;
const int MOD = 1e9+7;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(){
    int n;cin >> n;
    int k;cin >> k;
    vector<int> h(n);
    rep(i,n)cin >> h[i];
    int ans = 0;
    for(int i=0;i<n;i++){
        if(h[i]>=k)ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void){
  int n,q,i,l,r;
  scanf("%d %d",&n,&q);
  char s[n];
  int t[n];
  t[0]=0;
  scanf("%s",s);
  for(i=1;i<n;i++){
    if(s[i-1]=='A' && s[i]=='C') t[i]=t[i-1]+1;
    else t[i]=t[i-1];
  }
  for(i=0;i<q;i++){
    scanf("%d %d",&l,&r);
    printf("%d\n",t[r-1]-t[l-1]);
  }
  return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin >>n>>k;
	int sum=0;
	for(int i=1;i<=n;i++){
		int a;
		scanf("%d",&a);
		if(a>=k)sum++;
	}
	
	cout << sum;
}

Measured memory_bytes: 256
from sys import exit

n = int(input())
s = sorted([int(input()) for _ in range(n)])

sum_s = sum(s)

if sum_s % 10 > 0:
  print(sum_s)
  exit()

for v in s:
  if (sum_s - v) % 10 > 0:
    print(sum_s - v)
    exit()

print(0)

Measured memory_bytes: 62528
from collections import defaultdict


def solve(string):
    n, m, *a = map(int, string.split())
    for i in range(1, n):
        a[i] += a[i - 1]

    d = defaultdict(int)
    for i in range(n):
        d[a[i] % m] += 1
    ans = d[0]
    for v in d.values():
        ans += v * (v - 1) // 2
    return str(ans)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Measured memory_bytes: 66416
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn = 1e5+5;
struct node{
	int id;
	int p,y;
	int f6;
	int l6;
}nn[maxn];
bool cmp(node a,node b){
	if(a.p==b.p)
		return a.y<b.y;
	return a.p<b.p;
}
bool cmp2(node a,node b){
	return a.id<b.id;
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i = 1;i<=m;i++){
		scanf("%d%d",&nn[i].p,&nn[i].y);
		nn[i].id = i;
		nn[i].f6 = nn[i].p;
	}
	sort(nn+1,nn+m+1,cmp);
	int pp = nn[1].p;
	int cnt = 1;
	for(int i = 1;i<=m;i++){
		if(pp!=nn[i].p){
			cnt = 1;
			pp = nn[i].p;
		}
		nn[i].l6 = cnt++;
	}
	sort(nn+1,nn+m+1,cmp2);
	for(int i = 1;i<=m;i++){
		printf("%06d%06d\n",nn[i].f6,nn[i].l6);
	}
	return 0;
} 

Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#define ull int
using namespace std;

template <class T>
bool all_even(const vector<T>& vec);

template <class T>
void divide(vector<T>& vec);

int main()
{
	size_t N;
	cin >> N;
	vector<ull> A(N);
	for (size_t i = 0; i < N; ++i) {
		cin >> A.at(i);
	}

	int count = 0;
	while(all_even(A)) {
		++count;
		divide(A);
	}

	cout << count << endl;
	return 0;
}

template <class T>
bool all_even(const vector<T>& vec) {
	for (size_t i = 0; i < vec.size(); ++i) {
		if (vec.at(i) % 2 == 1) {
			return false;
		}
	}
	return true;
}

template <class T>
void divide(vector<T>& vec) {
	for (size_t i = 0; i < vec.size(); ++i) {
		vec.at(i) /= 2;
	}
}

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

int main() {
	//input
	int64_t A;
	string B;
	cin >> A >> B;

	//calculation
	int64_t Bt100 =  (B[0] - '0') * 100 + (B[2] - '0') * 10 + B[3] - '0';
	
	//output
	int64_t output = A * Bt100 / 100;
	cout << output << endl;


	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define ET cout << "\n"
#define SZ(a) ((int)a.size())
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#ifdef bbq
#define debug(...) {\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}
#define DB(a,s,e) {for(int _i=s;_i<e;++_i) cerr << a[_i] << " ";cerr << "\n";}
template<typename T>void _do(T &&x){cerr<<x<<endl;}
template<typename T,typename ...S> void _do(T &&x,S &&...t){cerr<<x<<", ";_do(t...);}
template<typename a,typename b> ostream& operator << (ostream &s,const pair<a,b> &p){return s<<"("<<p.X<<","<<p.Y<<")";}
#else
#define debug(...)
#define DB(a,s,e)
#endif

int arr[105];

int main()
{
    IOS();
    int n,ans=0;
    cin >> n,n<<=1;
    for(int i=0;i<n;++i)
        cin >> arr[i];
    sort(arr,arr+n);
    for(int i=0;i<n;i+=2)
        ans+=arr[i];
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define ld long double
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef vector <ll> vi;
#define out(x) return cout<<x,0;
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define lc(n) 2*n+1
#define rc(n) 2*n+2
#define fill(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL)); 
const ll N = 55, M = 35;

int main(){
    FAST;
    ll n, x = 0, m, k, i, t, ans = 1, j, y = 0, z = 0, c = 0;
    ld p;
    cin >> p;
    ld xx = (p/3)*(p/3)*(p/3);   
    precision(xx, 12);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  ll n; cin >> n;
  int len = ceil(log(n) / log(26));
  string ans = "";
  while (n > 0) {
    int d = n%26LL;
    char add = 'a' + d-1;
    if (d == 0) add = 'z';
    ans += add;
    n /= 26LL;
    if (d==0) n--;
  }
  reverse(ans.begin(), ans.end());
  cout << ans;
  int l = ans.size();
  if (l < len) {
    rep(i, len-l-1) cout << "z";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3848
n,k = map(int,input().split())
a = list(map(int,input().split()))

sum = 0

for i in range(0,k):
        sum += a[i]

was = sum
for i in range(n-k):
        now=was - a[i] + a[k+i]
        if was < now:
                print('Yes')
        else:
                print('No')
        was = now

Measured memory_bytes: 31548
#include<bits/stdc++.h>
using namespace std;
// make pair, tuple
// __gcd(int, int);
// bool isPrime(int n){
//       if(n <= 1)return false;
//       if(n <= 3)return true;
//       if(n % 2 == 0 || n % 3 == 0)return false;
//       for(int i = 5;i * i <= n;i += 6){
//             if(n % i == 0 || n % (i + 2) == 0)return false;
//       }
//       return true;
// }
// int countSubString(string s, string temp){
//       int ans = 0;
//       size_t f = s.find(temp);
//       while(f != string::npos){
//             ans++;
//             f = s.find(temp, f + 1);
//       }
//       return ans;
// }
// 
// #Count leading & trailing zero of an integer bits
// __builtin_clz(n);
// __builtin_clzll(n);
//
// #Count 1s bits of an integer
// __builtin_popcount(n);
// __builtin_popcountll(n);
//
// #Error checking
// assert(n == 3);
// 
// #Error Printing
// cerr << "Some thing";

int main(){
    int n;cin >> n;
    vector<int> arr(n);
    for(int i = 0;i < n;i++)cin >> arr[i];
    sort(arr.begin(), arr.end());
    if(lower_bound(arr.begin(), arr.end(), arr[n / 2]) - arr.begin() == n / 2){
        cout << arr[n / 2] - arr[n / 2 - 1];
    }
    else cout << 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mxn= 5e5+5;
#define mod 1000000007
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    int temp=arr[n/2]-arr[n/2-1];
    cout<<temp;
}



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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<vector<pair<int,int>>> xy(1000,vector<pair<int,int>>(1000)); 
  for(int i=0;i < n;i++){
    int h;
    cin >> h;
    a.at(i) = h;
    for(int j=0;j<h;j++){
      cin >> xy.at(i).at(j).first >> xy.at(i).at(j).second;
    }
  }
  int64_t beki = 1 << n;
  vector<int> bl(n);
  int onemax = 0;
  
  for(int i=0;i<beki;i++){
    int gyt = i;
    //
    for(int j=0;j<n;j++){
      if(gyt & 1){
        bl.at(j) = 1;
      }else{
        bl.at(j) = 0;
      }
      gyt = gyt >> 1;
    }

    int flag = 1;
    for(int j=0;j<n;j++){
      for(int k=0;k<a.at(j);k++){
        if((bl.at(j) == 1) && (bl.at(xy.at(j).at(k).first-1) == 1)&&(xy.at(j).at(k).second == 0)){
          flag = 0;
          //cout << bl.at(j) << "/" << xy.at(j).first-1 << "/" <<bl.at(xy.at(j).first-1);
        }
        if((bl.at(j) == 1) && (bl.at(xy.at(j).at(k).first-1) == 0)&&(xy.at(j).at(k).second == 1)){
          flag = 0;
          //cout << bl.at(j) << "/" << xy.at(j).first-1 << "/" <<bl.at(xy.at(j).first-1);
        }
      }
    }

    if(flag == 1){
      int plo = i;
      int onecnt = 0;
      while(plo){
        if(plo & 1){
          onecnt++;
        }
        plo = plo >> 1;
      }

      if(onemax < onecnt){
        onemax = onecnt;
      }
      //cout << bl.at(0) << bl.at(1) << bl.at(2) << endl;
    }
  }

  cout << onemax;
    
}


Measured memory_bytes: 8064
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

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

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"4 3 6"# => "safe",
r#"6 5 1"# => "delicious",
r#"3 7 12"# => "dangerous",
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        x: i64,
        a: i64,
        b: i64,
    }

    let ab = a - b;
    if ab >= 0 {
        "delicious"
    } else if x + ab >= 0 {
        "safe"
    } else {
        "dangerous"
    }.to_string()
}

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

int main(){
	int n,x;
	cin>>n>>x;
	vector<int> a(n);
	long long int ans = 0;
	for(int i = 0;i<n;i++){
		//cout<<i<<" "<<ans<<endl;
		cin>>a[i];
		if(i!=0){
			if(a[i]+a[i-1]>x){
				ans+=a[i]-(x-a[i-1]);
				a[i]=x-a[i-1];
			}
		}else if(a[0]>x){
				ans=a[0]-x;
				a[0]=x;
			}
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
struct node{int p,l,r;};
node t[100000];
int n,d[100000];
void dp(int p,int d1){
  d[p]=d1;
  if(t[p].l!=-1) dp(t[p].l,d1+1);
  if(t[p].r!=-1) dp(t[p].r,d1);
}
int main(){

  int tmp1,tmp2,cnt;
  cin>>n;

  for(int i=0;i<n;i++) t[i].p=t[i].l=t[i].r=-1;
  for(int i=0;i<n;i++){
    cin>>tmp1>>cnt;
    int tmpl=-1;
    for(int j=0;j<cnt;j++){
      cin>>tmp2;
      if(j==0) t[tmp1].l=tmp2;
      t[tmp2].p=tmp1;
      if(tmpl!=-1) t[tmpl].r=tmp2;
      tmpl=tmp2;
    }
  }
  int st;
  for(int i=0;i<n;i++) if(t[i].p==-1) st=i;

  dp(st,0);

  for(int i=0;i<n;i++){
    cout<<"node "<<i<<": parent = "<<t[i].p<<", depth = "<<d[i]<<", ";
    if(t[i].p==-1) cout<<"root, [";
    else if(t[i].l==-1){ cout<<"leaf, []"<<endl; continue;}
    else cout<<"internal node, [";
    tmp1=t[i].l;
    for(int j=0;tmp1!=-1;j++){
      if(j) cout<<", ";
      cout<<tmp1;
      tmp1=t[tmp1].r;
    }
    cout<<"]"<<endl;
  }

  return 0;

}

Measured memory_bytes: 4648
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
  vector<int> num;
  int input;
  
  for(int i = 0 ; i < 3 ; i++){
    cin >> input;
    num.push_back(input);
  }
  
  sort(num.begin(), num.end(), greater<int>());
  
  cout << num[0]*10 + num[1] + num[2] << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {

	int A;
	int P;
	cin >> A;
	cin >> P;

	int sum = 3 * A + P;

	int ans = sum / 2;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int N,M;
  cin>>N>>M;
  vector<int> A(M+1);
  rep(i,M) cin>>A[i];
  A[M]=N+1;
  ll ans=1;
  ll fib[100001]={};
  fib[0]=1,fib[1]=1;
  rep(i,100001) if(i>1) fib[i]=(fib[i-1]+fib[i-2])%1000000007;
  if(A[0]>1) ans=ans*fib[A[0]-1]%1000000007;
  rep(i,M){
    if(A[i+1]-A[i]>1) ans=ans*fib[A[i+1]-A[i]-2]%1000000007;
    else{
      ans=0;
      break;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1408
/*input

	*/


	// assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
	// #pragma GCC target ("avx2")
	// #pragma GCC optimization ("O3")
	// #pragma GCC optimization ("unroll-loops")
	#include<bits/stdc++.h>
	#include <ext/pb_ds/assoc_container.hpp>
	#include <ext/pb_ds/tree_policy.hpp>
	using namespace std;

	// order_of_key (k) : Number of items strictly smaller than k .
	// find_by_order(k) : K-th element in a set (counting from zero).
	using namespace __gnu_pbds;
	template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

	#define ll          long long int
	#define pb          push_back
	#define pii         pair<ll ,ll >
	#define vpii        vector< pii >
	#define vi          vector<ll >
	#define vs			vector< string >
	#define vvi         vector< vector< ll > >
	#define inf			(ll)1e18
	#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
	#define F           first
	#define S           second
	#define sz(x)       (ll )x.size()
	#define rep(i,a,b)	for(ll  i=a;i<b;i++)
	#define repr(i,a,b) for(ll  i=a;i>b;i--)
	#define lbnd        lower_bound
	#define ubnd        upper_bound
	#define mp          make_pair
	#define whatis(x)   cout << #x << " is " << x << "\n";
	#define graph(n)    adj(n,vector< ll > () )
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

	#define debug(x)     cout << #x << " " << x << endl;
	#define debug_p(x)   cout << #x << " " << x.F << " " << x.S << endl;
	#define debug_v(x)   {cout << #x << " "; for (auto ioi : x) cout << ioi << " "; cout << endl;}
	#define debug_vp(x)  {cout << #x << " "; for (auto ioi : x) cout << '[' << ioi.F << " " << ioi.S << ']'; cout << endl;}
	#define debug_v_v(x) {cout << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cout << ioi2 << " "; cout << '\n';} cout << "*/" << #x << endl;}

	int solve()
	{
		ll n;cin>>n;
		vpii pts(n);
		rep(i,0,n)
		{
			ll x,y;cin>>x>>y;
			pts[i] = mp(x,y);
		}

		// sorted on x
		sort(pts.begin(), pts.end());
		ll ans = 0;

		set<ll> st;

		st.clear();
		rep(i,0,n) st.insert(pts[i].F+pts[i].S);
		ans=max(ans,*st.rbegin()-*st.begin());

		st.clear();
		rep(i,0,n) st.insert(pts[i].F-pts[i].S);
		ans=max(ans,*st.rbegin()-*st.begin());

		st.clear();
		rep(i,0,n) st.insert(-1*pts[i].F+pts[i].S);
		ans=max(ans,*st.rbegin()-*st.begin());

		cout<<ans<<"\n";

		return 0;
	}

	int main()
	{
		auto start = chrono::high_resolution_clock::now();

	    // freopen("input.txt","r",stdin);
	    // freopen("output.txt","w",stdout);
		
		ios_base::sync_with_stdio(false);
		cin.tie(0);
		cout.tie(0);

		ll test_cases=1;
		//cin>>test_cases;
		while(test_cases--)
			solve();

		auto stop = chrono::high_resolution_clock::now();
		auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
		//cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
	}


Measured memory_bytes: 15908