akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Scanner;

class Main{


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		long c = sc.nextLong();
		long[]x = new long[n+2];
		long[]v = new long[n+2];

		for(int i = 1;i <= n;i++){
			x[i] = sc.nextLong();
			v[i] = sc.nextLong();
		}
		x[n+1] = c;
		long[] sumtokei = new long[n+1];
		long[] sumhantokei = new long[n+1];


		for(int i = 1;i <= n;i++){				//累積和
			sumtokei[i] = v[i] + sumtokei[i-1];
			//	System.out.println(sumtokei[i]);
		}

		ArrayList<Pair> pairs = new ArrayList<Pair>();
		ArrayList<Pair> hanpairs = new ArrayList<Pair>();

		long asum = 0l;
		long xx = 0l;
		
		
		for(int i = 0;i <= n;i++){				//B固定
			if(asum < sumtokei[i] - x[i]){
				asum = sumtokei[i] - x[i];
				xx = x[i];
			}
			Pair pair = new Pair();
			pair.from = asum;
			pair.end = xx;
			pairs.add(pair);
		}

		asum = 0;
		xx = 0;
		for(int i = 0;i <= n;i++){				//B固定
			if(asum < sumtokei[n]-sumtokei[n-i] -(c- x[n-i+1])){
				asum = sumtokei[n]-sumtokei[n-i] -(c- x[n-i+1]);
				xx = c-x[n-i+1];
			}
			Pair pair = new Pair();
			pair.from = asum;
			pair.end = xx;
			hanpairs.add(pair);
		}
//		for(int i = 0;i <= n;i++){
//			System.out.println(hanpairs.get(i).from+" "+hanpairs.get(i).end);
//		}
		
		long ans = 0l;
		long left = pairs.get(n).from;
		long right =  pairs.get(n).from;;
		ans = left;

		for(int i = 1;i <= n;i++){
			left = pairs.get(n-i).from - pairs.get(n-i).end + (sumtokei[n] - sumtokei[n-i]) - (c-x[n-i+1]);
			right = sumtokei[n] - sumtokei[n-i]  - 2*(c-x[n-i+1]) + pairs.get(n-i).from;
			ans = (long)Math.max(ans, (long)Math.max(left, right));
		//	System.out.println(left + " " + right);
		}
		for(int i = 0;i <= n;i++){
			left = hanpairs.get(n-i).from - hanpairs.get(n-i).end + sumtokei[i] - x[i];
			right = sumtokei[i] - 2*x[i] + hanpairs.get(n-i).from;
			ans = (long)Math.max(ans, (long)Math.max(left, right));
		//	System.out.println(left + " " + right);
		}
		System.out.println(ans);


	}
	static int lowerbond(int k, int[] data){		//kより小さい最小の値をdataの中から探し、返す二分探索
		int min = -1;
		int max = data.length;

		while(max-min > 1){
			int mid = (max+min)/2;
			if(data[mid] >= k){
				max = mid;
			}else{
				min = mid;
			}
		}
		return max;
	}





}

class UnionFind{
	int[] parent;
	public UnionFind(int N){
		this.parent = new int[N];
		for(int i = 0; i < N;i++){
			parent[i] = i;
		}
	}
	public int root(int x){			//根要素を取得
		if(parent[x] == x){			//初期状態
			return x;
		}else{
			return parent[x] = root(parent[x]);    	//再帰によって根を取得
		}
	}
	public void unite(int x,int y){ 	//統合メソッド
		if(same(x,y)){					//同じ根なら終了
			return;
		}
		int xroot = root(x);
		int yroot = root(y);
		parent[xroot] = yroot;			//統合
		return;

	}

	public boolean same(int x,int y){			//根が同じか（同じグループに属しているか）を判定
		return(root(x) == root(y));
	}
}



class Pair implements Comparable{
	long from;		//p
	long end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return num - otherpair.num;
	}
}



Measured memory_bytes: 96344
/*input
10
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i,j,k)     for(int i = j ; i < k ; ++i)
#define RREP(i,j,k)    for(int i = j ; i >=k ; --i)
#define A    first
#define B    second
#define mp   make_pair
#define pb   emplace_back
#define PII pair<int , int>
#define MEM(i,j)   memset(i , j , sizeof i)
#define ALL(i)     i.begin() , i.end()
#define DBGG(i,j)     cout << i << " " << j << endl
#define DB4(i,j,k,l)  cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie(0) , cout.sync_with_stdio(0)
#define endl "\n"
///------------------------------------------------------------
#define int long long
#define MAX 
#define INF 0x3f3f3f3f

int V(int now){
    int cnt = 0;
    while(now) cnt += now % 10 , now /= 10;
    return cnt;
}
vector<int> v;
int32_t main(){
    IOS;
    int val = 0 , base = 1;
    
    while(1){

        int now = val + base;
        int nxt = val + base * 10;

        if(now > 1e15) break;

        int a = nxt , b = V(nxt);
        int v1 = now , v2 = V(now);
        if(v1 * b <= a * v2){
        	v.pb(now);
        	val = now;
        	// cout << now << endl;
        }
        else{
        	// cout << nxt << endl;
        	v.pb(nxt);
        	val = nxt;
        	base *= 10;
        }

    }
    int n;
    cin >> n;
    REP(i , 0 , n) cout << v[i] << endl;
    // RREP(i , 6000000 , 1){
    //     int v1 = i , v2 = V(i);
    // }
    // REP(times , 0 , 500){

    //     double val = i , res = V(i);
    //     cout << i << " = " << val / res << endl;
    //     i += 10;
    // }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
const long long MOD = 1e9 + 7, INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}



signed main(){
	int N;
	cin >> N;
	vector<int>b(N-1);
	REP(i,N-1)cin>>b[i];
	int ans = 0;
	vector<int>a(N,INF);
	REP(i,N-1){
		CHMIN(a[i],b[i]);
		CHMIN(a[i+1],b[i]);
	}
	REP(i,N)ans+=a[i];
	cout<<ans<<endl;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int Rec(int x){  
  static int mem[200001];
  static int used[200001];
  if(used[x])return mem[x];
  used[x] = 1;
  if(x == 0)return 0;
  int cnt = __builtin_popcount(x);
  return mem[x]=Rec(x%cnt)+1;
}


int main(){
  int n;
  cin >> n;
  string s; cin >> s;
  int cnt = 0;
  for(int i = 0; i < n; ++i)cnt += s[i] == '1';
  int cnti = cnt+1;
  int cntd = cnt-1;
  int xi = 0,xd = 0, yi = 1 , yd = 1;
  int xx = 0,yy = 1;
  for(int i = n-1; i >= 0; --i){
    if(s[i] == '1'){
      xx += yy;
      xi = (xi+yi)%cnti;
      if(cntd>0)xd = (xd+yd)%cntd;
    }
    yi = (yi*2)%cnti;
    if(cntd>0)yd = (yd*2)%cntd;
    yy = yy*2;
  }
  yi = yd = 1;
  vector<int>ans; 
  for(int i = n-1; i >= 0; --i){
    if(s[i] == '1'){
      if(cntd == 0){
	ans.push_back(0);
      }else{
	int x = (xd + cntd - yd)%cntd;
	ans.push_back(Rec(x)+1);
      }
    }else{
      int x = (xi + yi)%cnti;
      ans.push_back(Rec(x)+1);
    }
    yi = (yi*2)%cnti;
    if(cntd>0)yd = (yd*2)%cntd;
  }
  for(int i = n-1; i >= 0; --i){
    cout << ans[i] << endl;
  }
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  for(int i=0;i<s.size();i++){
    if(i%2==0){
      cout << s.at(i);
    }
    else{
      continue;
    }
  }
    cout << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define pb push_back
#define MAX 1000000000
#define MOD 1000000007
typedef pair<int,int> Paint;
bool Pairfirst(const Paint& pf,Paint&ps){//sortCompare
  return (pf.first+pf.second) > (ps.first+ps.second);
}
int main(){
  int n;cin>>n;
  int a[n],b[n];
  vector<Paint> sa;
  
  rep(i,n){
    cin>>a[i]>>b[i];sa.push_back(Paint(a[i],b[i]));
  }
  sort(sa.begin(),sa.end(),Pairfirst);
  int turn = 0;
  long long kekka = 0;

  rep(i,n){
    if(turn == 0){
      kekka += sa[i].first;
    }else{
      kekka -= sa[i].second;
    }
    turn = (turn+1)%2;
  }
  cout << kekka << endl;
}

Measured memory_bytes: 1912
#include<iostream>
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll read(){
	ll x=0,w=1;
	char ch=0;
	while(ch<'0'||ch>'9'){
		if(ch=='-')
			w=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return w*x;
}
int main(){
	string ptr;
	cin>>ptr;
	int a=0,b=0;
	for(int i=0;i<ptr.length();i++){
		if(ptr[i]=='A'){
			a++;
		}
		if(ptr[i]=='B'){
			b++;
		}
	}
	if(a&&b){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

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

int main(int argc, char *argv[])
{
    int num[26] = {0};
    int index = 0;
    string str;
    while(getline(cin, str))
    {

        for (unsigned i = 0; i < str.size(); i++)
        {
            if (str[i] >= 'a' && str[i] <= 'z')
            {
                index = str[i] - 'a';
            }
            else if (str[i] >= 'A' && str[i] <= 'Z')
            {
                index = str[i] - 'A';
            }
            else
            {
                continue;
            }
            num[index]++;
        }

    }


    for(int i = 0; i < 26; i++)
    {
        printf("%c : %d\n", 'a' + i, num[i]);
    }
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vst;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;


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

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)




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

 ll n;
  cin >> n;
  string s,t;
  cin >> s >> t;
  
  rep(i,0,n) cout << s[i] << t[i];
  cout << endl;
  
  
} // main


Measured memory_bytes: 256
import sys
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

#print(factorization(24)) #[[2, 3], [3, 1]]

N=int(input())
if N==1:
    print(0)
    sys.exit()
A=factorization(N)
#print(A)
ans=0
for i in range(len(A)):
    p=0
    res=A[i][1]
    while res-p>0:
        p+=1
        res-=p
    #print(p)
    ans+=p
print(ans)

Measured memory_bytes: 9504
main=do
 n<-readLn;a<-words<$>getLine
 putStrLn$unwords(f n a)
  where f n a = if (mod n 2)==0 then(g 1 n a [] [])else(reverse(g 1 n a [] []))
        g i n a o e |i>n    =e++(reverse o)
                    |odd i  =g (i+1) n (tail a) ((head a):o) e
                    |even i =g (i+1) n (tail a) o ((head a):e)

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

int main() {
    int n, k;
    string s;
    cin >> n >> s >> k;

    for (int i = 0; i < s.size(); i++) {
        if (s[k - 1] != s[i]) {
            cout << '*';
        } else {
            cout << s[i];
        }
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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)*}
    };
}

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<_>>()
    };

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

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

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

// x ** n % mods を求める
pub fn mod_pow(x: i64, n: i64, mods: i64) -> i64 {
    if n == 0 {
        return 1;
    }
    let mut res = mod_pow(x * x % mods, n / 2, mods);
    if n % 2 == 1 {
        res = res * x % mods;
    }
    return res;
}

// (1/n) % mods を求める
pub fn mod_inv(n: i64, mods: i64) -> i64 {
    return mod_pow(n, mods-2, mods);
}

// nCk % mods を求める
pub fn mod_comb(n: i64, k: i64, mods: i64) -> i64 {
    let sum1 = (n-k+1..n+1).fold(1, |ac, x| ac * x % mods);
    let sum2 = (1..k+1).fold(1, |ac, x| ac * x % mods);
    return sum1 * mod_inv(sum2, mods) % mods;
}


fn main() {
    input!{
        n: i64,
        k: i64,
    }
    let rem = n % k;
    println!("{}", if rem < (rem - k).abs() {rem} else {(rem - k).abs()});
}


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

int main() {
  //左の重り
  int a,b;
  //右の重り
  int c,d;
  
  cin >> a >> b >> c >> d;
  
  int left = a + b;
  int right = c + d;
  
  if(left > right){
    cout << "Left" << endl;
  }else if(left < right){
    cout << "Right" << endl;
  }else{
    cout << "Balanced" << endl;
  }
}


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

int main(){
	int n,x,ans,temp=111;
	cin>>n;
	while(n--){
		cin>>x;
		ans+=x;
		if(x%10!=0&&x<temp) temp=x;
	} 
	if(ans%10!=0) cout<<ans<<endl;
	else if(temp!=111) cout<<ans-temp<<endl;
	else cout<<0<<endl;
	return 0;
}

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

#define debug 0

using namespace std;
typedef long long lint;

const int maxn = 1e5+5;

string answer(int x, int y)
{
    string s = "000000000000";
    int k = 11;
    while(y > 0) {
        s[k] = y % 10 + '0';
        k--;
        y /= 10;
    }
    k = 5;
    while(x > 0) {
        s[k] = x % 10 + '0';
        k--;
        x /= 10;
    }
    return s;
}

struct ab
{
    int i, x;
};

struct abc
{
    vector <ab> v;
    int k;
}pref[maxn];

int cmp(ab a , ab b) {
    if(a.x == b.x) {
        return a.i < b.i;
    }
    return a.x < b.x;
}

int n, m, a[maxn], c[maxn], i, x, j;
int main()
{
    #if debug
    freopen("f.in", "r", stdin);
    freopen("f.out", "w", stdout);
    #endif

    cin >> n >> m;
    for(i = 1; i <= m; i ++) {
        cin >> a[i] >> x;
        pref[a[i]].v.push_back({i, x});
    }

    for(i = 1; i <= n; i ++) {
        sort(pref[i].v.begin(), pref[i].v.end(), cmp);
        j = 0;
        for(auto u : pref[i].v) {
            c[u.i] = ++j;
        }
    }

    for(i = 1; i <= m; i ++) {
        cout << answer(a[i], c[i]) << '\n';
    }

    return 0;
}


Measured memory_bytes: 8576
#include <cstdio>
#include <cmath>
#include <algorithm>
#define maxn 200010
using namespace std;

long long a[maxn], sum[maxn], res;
int n;
int main(void) {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", a + i);
		sum[i] = sum[i - 1] + a[i];
	}
	res = abs(sum[1] - sum[n] + sum[1]);
	for (int i = 1; i <= n - 1; i++) {
		res = min(res, abs(sum[i] - sum[n] + sum[i]));
	}
	printf("%lld", res);
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string ch;
    cin>>ch;
    int len=ch.size();
    int a=0,c=0,sum=0;
    for(int i=0;i<len;i++)
    {
        if(ch[i]=='+')
        {
            c++;
        }
        else if(ch[i]=='-')
        {
            a++;
        }
    }
    sum=c-a;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define rep(a,b) for(int a=0;a<b;a++)
#define pb push_back
#define str string
#define INF
#define sf(a) scanf("%d",&a)

using namespace std;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    int a[3];
    str st;
    vector<str> s;
    cin >> n >> m;
    rep(i,n){
        cin >> st;
        s.pb(st);
    }
    sort(s.begin(),s.end());
    rep(i,n){
        cout << s[i];
    }
    cout << endl;
return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

    int n,k;
    cin >> n >> k;

    int cnt = 0;
    while(n!=0){
        cnt++;
        n /= k;
    }

    cout << cnt << endl;


    



	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://abc156.contest.atcoder.jp/tasks/abc156_b

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

using namespace std;

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

    int ans = 0;
    map<int, int> mp;
    for(int i=0; i<N; i++) {
        int a;
        cin >> a;
        if(a >= 3200) {
            ++ans;
        } else {
            mp[a/400]++;
        }
    }

    cout << max(1, (int)mp.size()) << " " << ans+mp.size() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >>  S;
  int start=-1;
  int end=0;
  for(int i=0;i<S.size();i++){
    if(start<0){
	    if(S.at(i)=='A'){
          start = i;
        }
    }
    if(S.at(i)=='Z'){
      end = i;
    }
  }
  cout << end-start+1 << endl;
}

Measured memory_bytes: 640
/***
 
                                Bismillahir Rahmanir Rahim
                                Rabbi Zidni Ilma
                                Author : Saidur Rahman
                                Department of CSE, City University, Bangladesh.
 
***/

#include<iostream>
using namespace std;


typedef         long long           ll;
#define         endl                "\n"
#define         ff                  first
#define         sf                  scanf
#define         pf                  printf
#define         ss                  second
const           int                 MAX=1e8;
#define         kaj_shesh           return 0
#define         pb                  push_back
#define         PI                  acos(-1.0)
#define         kaj_shuru           int main()
#define         vi                  vector<int>
#define         newline             printf("\n")
#define         pri                 pair<int,int>
#define         sff(a)              scanf("%d",&a)
#define         NO                  printf("NO\n")
#define         no                  printf("no\n")
#define         YES                 printf("YES\n")
#define         No                  printf("No\n")
#define         Yes                 printf("Yes\n")
#define         yes                 printf("yes\n")
#define         sfl(a)              scanf("%lld",&a)
#define         sfl(a)              scanf("%lld",&a)
#define         pff(a)              printf("%d\n",a)
#define         pfl(a)              printf("%lld\n",a)
#define         sfff(a,b)           scanf("%d%d",&a,&b)


#define         f0(i,b)             for(int i=0;i<(b);i++)
#define         sfll(a,b)           scanf("%lld%lld",&a,&b)
#define         sffff(a,b,c)        scanf("%d%d%d",&a,&b,&c)
#define         sflll(a,b,c)        scanf("%lld%lld%lld",&a,&b,&c)
#define         input               freopen("input.txt", "r", stdin)
#define         output              freopen("output.txt", "w", stdout)
#define         watch(x)            cout << (#x) << " is " << (x) << endl

int         ToggleBit (int n, int X)    { return n ^ (1 << X); }
int         SetBit (int n, int X)       { return n | (1 << X); }
int         ClearBit (int n, int X)     { return n & ~(1 << X); }
bool        CheckBit (int n, int X)     { return (bool)(n & (1 << X)); }



/******************************** Code Starts From Here **********************************/


kaj_shuru
{
   
 #ifndef ONLINE_JUDGE 
    input;
    output;
#endif
    int n;
    sff(n);
    string s,s1;
    
    for (int i = 0; i < n;i++)
    {
        s += "ACL";
    }
    cout << s << endl;
    kaj_shesh;
}


Measured memory_bytes: 3164
#include <iostream>
#include <vector>
#include <string>
#include <cstring>

using namespace std;

int main(int argc, char *argv[])
{
	long long int i, j;
	long long int k, n;
	long long int result = 0;
	long long int tmp_pattern_max, tmp_pattern_min;
	tmp_pattern_max = tmp_pattern_min = 0;
	cin >> n >> k;

	for (i = k; i <= n + 1; i++) {
		tmp_pattern_max = i * (n - i + 1 + n) / 2;
		tmp_pattern_min = i * (0 + i - 1) / 2;

		result += tmp_pattern_max - tmp_pattern_min + 1;
	}

	cout << result % (1000000000 + 7) << endl;

	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int max(int a,int b){
  if(a>b){
    return a;
  }else{
    return b;
  }


}
int main(){
  int a,b;
  cin>>a>>b;
  int s=max(a,b);
  if(s<9&&a+b<=16){
    cout<<"Yay!"<<endl;
  }else{
    cout<<":("<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
						
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long

const int nax = 305, inf = (int)1e15;
int n, m, L;
int dp[nax][nax], pre[nax][nax], g[nax][nax], g2[nax][nax], dp2[nax][nax];

void init() {
	for (int i = 0; i < nax; i++) {
		for (int j = 0; j < nax; j++) {
			dp[i][j] = (i == j)? 0 : inf;
			pre[i][j] = i;					// i -> ... -> pre[i][j] -> j
		}
	}
}

void FloydWarshall() {
	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				if (dp[i][k] + dp[k][j] < dp[i][j]) {
					dp[i][j] = dp[i][k] + dp[k][j];
					pre[i][j] = pre[k][j];
				}
			}
		}
	}
}

 
int32_t main()
{
	IOS
 
	init();

	cin >> n >> m >> L;	

	for (int i = 0, u, v, w; i < m; i++) {
		cin >> u >> v >> w;
		if (w > L) continue;
		dp[u][v] = dp[v][u] = w;
		g[u][v] = g[v][u] = w;
	}

	FloydWarshall();

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (i == j) {
                dp2[i][j] = 0;
            }
            else if (dp[i][j] <= L) {
                dp2[i][j] = 1;
            }
            else dp2[i][j] = inf;
        }
    }

    for (int k = 1; k <= n; k++)
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++)
                dp2[i][j] = min(dp2[i][j], dp2[i][k] + dp2[k][j]);
    

	int q;
	cin >> q;
	while (q--) {
		int s, t;
		cin >> s >> t;
		if (dp2[s][t] >= inf) {
			cout << -1 << endl;
			continue;
		}
		int ans = dp2[s][t] - 1;
        cout << ans << endl;
	}
 
	return 0;
}


Measured memory_bytes: 3456
N = int(input())
xl = [list(map(int,input().split())) for _ in range(N)]

itv = []
idx = 0
for x,l in xl:
    s = x-l
    t = x+l
    itv.append([t,s])
    
    idx += 1

itv.sort()
ass = 0
tt = -10**10
for i in range(N):
    if tt <= itv[i][1]:
        ass += 1
        tt = itv[i][0]
        
print(ass)


Measured memory_bytes: 43440
#include <bits/stdc++.h>
#define endl '\n'

#define SZ(x) ((int)x.size())
#define ALL(V) V.begin(), V.end()
#define L_B lower_bound
#define U_B upper_bound
#define pb push_back

using namespace std;
template<class T, class T1> int chkmin(T &x, const T1 &y) { return x > y ? x = y, 1 : 0; }
template<class T, class T1> int chkmax(T &x, const T1 &y) { return x < y ? x = y, 1 : 0; }
const int MAXN = 3042;
const int mod = 998244353;

int A, B, C, D;

void read() {
	cin >> A >> B >> C >> D;
}

int dp[MAXN][MAXN];

int rec(int a, int b) {
	if(a < A || b < B) return 0;
	if(a == A && b == B) return 1;

	int &memo = dp[a][b];
	if(memo != -1) return memo;
	
	memo = (rec(a - 1, b) * 1ll * b + rec(a, b - 1) * 1ll * a - (rec(a - 1, b - 1) * 1ll * (a - 1) * 1ll * (b - 1))) % mod;
	if(memo < 0) memo += mod;

	return memo;
}


void solve() {
	memset(dp, -1, sizeof(dp));
	cout << rec(C, D) << endl;
}

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

	read();
	solve();
	return 0;
}



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

typedef long long lint;
typedef unsigned long long ulint;
const int MOD=998244353;

int main(){
    int Q;
    cin >> Q;
    for(int i=0;i<Q;i++){
        lint A,B;
        cin >> A >> B;
        if(A>B){
            lint tmp=A;
            A=B;
            B=tmp;
        }
        if(A==B) cout << (A*2-2) << endl;
        else{
            lint ans;
            lint C=sqrt(A*B);
            if(A*B==C*C) ans=0;
            else ans=1;
            if(C*C+C<A*B) ans++;
            ans+=2*C-3;
            cout << ans << endl;            
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstdlib>

#define INF 100000

using namespace std;

int N, A, B, C, l[8];

int dfs(int i, int mp, int a, int b, int c) {
    if (i == N) return (a>0 && b>0 && c>0) ? mp + abs(A-a) + abs(B-b) + abs(C-c) : INF;
    int mpa = dfs(i+1, mp+(a>0 ? 10 : 0), a+l[i], b, c),
        mpb = dfs(i+1, mp+(b>0 ? 10 : 0), a, b+l[i], c),
        mpc = dfs(i+1, mp+(c>0 ? 10 : 0), a, b, c+l[i]),
        mp_ = dfs(i+1, mp, a, b, c);
    return min({mpa, mpb, mpc, mp_});
}

int main() {
    scanf("%d %d %d %d", &N, &A, &B, &C);
    for (int i=0; i<N; i++)
        scanf("%d", l+i);
    printf("%d\n", dfs(0, 0, 0, 0, 0));
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define Max 200
struct Node{int key;Node *p,*l,*r;};
Node *null,*root;
void init(){

	null=(Node*)malloc(sizeof(Node));
	null->p=null;
	null->l=null;
	null->r=null;
	root=null;
	
}
void inseart(int k){	
Node *y,*x,*z;
	y=null;x=root;
	z=(Node*)malloc(sizeof(Node));
	z->key=k;
	z->l=null;
	z->r=null;
	while(x!=null){
	y=x;
		if(z->key < x->key)
		  x=x->l;
		else 
		  x=x->r;
	}
	z->p=y;
	if(y==null)
	  root=z;
	else if(z->key<y->key)
	  y->l=z;
	else 
	  y->r=z;
}
void pre_walk(Node *a){
	if(a==null)
	return;
	printf(" %d",a->key);
	pre_walk(a->l);
	pre_walk(a->r);
}
void in_walk(Node *a){
	if(a==null)
	return;
	in_walk(a->l);
	printf(" %d",a->key);
	in_walk(a->r);
}
main(){
	int n,i,key;
	char ord[20];
	scanf("%d",&n);
		init();
	for(i=0;i<n;i++){
		scanf(" %s",ord);
		if(ord[0]=='i'){
			scanf("%d",&key);
			inseart(key);
		}
		else {
            in_walk(root);
			printf("\n");
			pre_walk(root);
			printf("\n");
		}
	}
	
	return 0;
}



Measured memory_bytes: 26644
//  s.at(0) = toupper(s.at(0));//小文字なら大文字へ//大文字の場合はそのまま
//  s.at(i) = tolower(s.at(i));//大文字なら小文字へ//小文字の場合はそのまま
//s配列に格納した単語を、辞書順にソートする
//getline(cin, s);
//  sort(s.begin(), s.end());
//  string t = "keyence";//で文字列入力ができる
//s.empty() //emptyなら1を出力 入っていれば0を出力
/*//ABC018-B 部分的にreverseをかける解法
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  rep(i,n) cin>>a.at(i)>>b.at(i);
  rep(i,n)a.at(i)--;
  rep(i,n)b.at(i)--;
  string t;
  rep(i,n){
    t = s;
    for(int k=0;k<=b.at(i)-a.at(i);k++){
      t.at(a.at(i)+k) = s.at(b.at(i)-k);
    }
    s = t;
  }
  cout << s << endl;
}
*///ABC018-B
//  string s;
//  cin >> s;
//  cout << s.at(0) <<endl;
//  cout << s.at(0)-'0' <<endl;
//  Aが16？
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}
int kan_hyaku(int n){
  int kurai = 0;
  for(int i=0;i<3;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}
int kan_ju(int n){
  int kurai = 0;
  for(int i=0;i<2;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}
int kan_ichi(int n){
  int kurai = 0;
  for(int i=0;i<1;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}
int main() {
  int n;
  cin >> n;
  vector<ll>a(n);
  vector<ll>b(n);
  rep(i,n) cin>> a.at(i) >> b.at(i);
  ll sum = 0;
  for(int i=n-1;i>=0;i--){
//    if( a.at(i) + sum < b.at(i) ){
//      sum += b.at(i) - (sum + a.at(i) );
//    }
//    else{
      ll num = b.at(i) - (a.at(i)+sum) % b.at(i);
      if(num != b.at(i)){
        sum += num;
//      }
    }
  }
  cout << sum << endl;
}
/*
  for(int i=n-1;i>=0;i--){
    if( a.at(i) + sum <= b.at(i) ){
      sum += b.at(i) - (sum + a.at(i) );
    }
    else{
      ll num = (a.at(i)+sum) % b.at(i);
      if(num != 0){
        sum += b.at(i) - num;
      }
    }
  }
  cout << sum << endl;
}
*/

/*
  for(int i=n-1;i>=0;i--){
    ll num = b.at(i) - (a.at(i) + sum ) % b.at(i);
    if(num != b.at(i)){
      sum += num;
    }
  }
  cout << sum << endl;
}
*/



Measured memory_bytes: 4844
{-#LANGUAGE FlexibleContexts#-}
import Control.Monad
import Control.Monad.State
import Control.Monad.Reader
import Control.Arrow
-- import Control.Comonad
import Data.Maybe
import Data.List
import Data.Bool
import Data.Fixed
import Data.Tuple
import Data.Ratio
import qualified Data.Map.Strict as M
import qualified Data.Array.IO as IA
import qualified Data.Vector as V

getI = read <$> getLine :: IO Int
getIs = map read . words <$> getLine :: IO [Int]
getD = read <$> getLine :: IO Double
getDs = map read . words <$> getLine :: IO [Double]
getInt = read <$> getLine :: IO Integer
getInts = map read . words <$> getLine :: IO [Integer]

type Row = Integer
type Col = Integer
type PointI = (Integer, Integer)
type Point = (Int, Int)

mmm = 1000000007
fact n
    | n < 1 = 1
    | True = foldr1 (*) [1..n]
ti = toInteger
fi = fromInteger
fig = fromIntegral
rf = realToFrac

(.<.) :: Integer -> Integer -> Integer
(.<.) f g -- combination
    | g < 1 || f < 1 || f < g = 1
    | True = foldr1 (*) (take (fi g) [f,f-1..]) `div` fact g
(.>.) f g --combination with repetition
    | g < 1 || f < 1 = 1
    | True = fact (f + g - 1) `div` (fact (f - 1) * fact g)
comb = (.<.)
combWp = (.>.)

unique a = unique_ (reverse . sort $ a) [] Nothing
    where
        unique_ [] arr _ = arr
        unique_ (x:xs) arr n
            | n == Just x = unique_ xs arr n
            | otherwise = unique_ xs (x:arr) $ Just x
 
zeroume keta num
    | (length . show $ num) > keta = show num
    | otherwise = do 
        let zeros = take keta $ repeat '0'
        reverse . take keta $ (reverse . show $ num) ++ zeros
 
i2b num
    | num < 2 = show num
    | otherwise = i2b_ num []
        where
            i2b_ num str
                | num == 0 = str
                | num == 1 = '1':str
                | otherwise = do
                    let next = num `div` 2
                    let this = if odd num then '1' else '0'
                    i2b_ next (this:str)

mapIncr = mapPlus 1
mapPlus n Nothing = Just n
mapPlus n a = (+) n <$> a

countIf f = length . filter f

enumDivisor :: Int -> [Int]
enumDivisor n = do
    let sqrted = floor $ sqrt (fromIntegral n)
        smaller = filter (\x -> mod n x == 0) [1..sqrted]
        bigger = reverse $ map (div n) smaller
    if head bigger == sqrted then smaller ++ (init bigger)
    else smaller ++ bigger

safeHead [] = Nothing
safeHead (x:_) = Just x

-- 
--
--

main = do
    _ <- getLine
    ts <- getIs
    m <- getI
    drinks <- replicateM m getIs
    let originalSum = sum ts
        v = V.fromList ts
        eachSums = map (\[x, y] -> show $ originalSum - (v V.! (x - 1)) + y)  drinks
    forM eachSums putStrLn >> return ()


Measured memory_bytes: 1020
using System;

namespace Aizu {
    class OnlineJudge {
        static void Main() {
            var dice = Console.ReadLine().Split();
            var rotate = new Action<int, int, int, int>((d1, d2, d3, d4) => {
                var tmp = dice[d1]; dice[d1] = dice[d2]; dice[d2] = dice[d3]; dice[d3] = dice[d4]; dice[d4] = tmp;
            });
            foreach (var c in Console.ReadLine()) {
                switch (c) {
                    case 'N':
                        rotate(4, 0, 1, 5);
                        break;
                    case 'E':
                        rotate(0, 3, 5, 2);
                        break;
                    case 'W':
                        rotate(2, 5, 3, 0);
                        break;
                    case 'S':
                        rotate(5, 1, 0, 4);
                        break;
                }
            }
            Console.WriteLine(dice[0]);
        }
    }
}

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

const int MAX_N=200005;
int n;
int a[MAX_N],b[MAX_N];

int main()
{
	ios::sync_with_stdio(false);
	while(cin>>n){
		for(int i=0;i<n;++i)
		{
			cin>>a[i];
			b[i]=a[i];
		}
		sort(b,b+n);
		int h1=b[n/2-1],h2=b[n/2],ans;
		for(int i=0;i<n;++i)
		{
			if(a[i]<=h1){
				ans=h2;
			}else	ans=h1;
			cout<<ans<<endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3712
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int MOD = (int)1e9 + 7;
int add(int &a, int b) { return (a += b) >= MOD ? a -= MOD : a; }

int main() {
    int N; cin >> N;
    vector<vector<int>> a(N, vector<int>(N));
    for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) cin >> a[i][j];

    vector<int> dp(1 << N, 0);
    dp[0] = 1;
    for (int s = 1; s < 1 << N; s++) {
        int i = __builtin_popcount(s) - 1;
        for (int j = 0; j < N; j++) if (s & (1 << j)) if (a[i][j]) {
            add(dp[s], dp[s ^ (1 << j)]);
        }
    }
    cout << dp[(1 << N) - 1] << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
const ll mx = 1000006;
ll sam[mx], pic[mx];

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

    sam[0] = a[0];

    for (ll i = 0; i < n; i++) {
        sam[i] = sam[i - 1] + a[i];
    }

   pic[n-1] = a[n - 1];

   for (ll i = n - 2; i >= 0; i--) {
    pic[i] = pic[i+1] + a[i];
   }

    ll ans = INT_MAX;

    for (ll i = 0; i < n - 1; i++) {
        ans = min(ans, abs(sam[i] - pic[i+1]));
    }

    cout << ans << endl;
}


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

using namespace std;
int main()
{
	int N,A;
	cin>>N;
	cin>>A;
	if(A>=N)
	{
		cout<<"Yes";
	}	
	else if(A==0)
	{
		if(N%500==0)
		{
			cout<<"Yes";
		}
		else
		{
			cout<<"No";
		}
	}
	else 
	{
		N%=500;
		if(N<=A)
		{
			cout<<"Yes";
		}
		else
			cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
using System.Linq;
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        var s = new List<int>();
        var t = new List<int>();
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        for (int i = 0; i < n; i++)
            s.Add(int.Parse(line[i]));
        var q = int.Parse(Console.ReadLine().Trim());
        string[] line2 = Console.ReadLine().Trim().Split(' ');
        for (int i = 0; i < q; i++)
            t.Add(int.Parse(line2[i]));
        var result = 0;
        foreach (var x in t)
            if (s.Any(xx => xx == x)) result += 1;
        Console.WriteLine(result);
    }
}

Measured memory_bytes: 10096
#include<iostream>
using namespace std;
main(){
  int n,k;
  cin>>n>>k;
  if((n-2)*(n-1)/2<k){cout<<-1;return 0;}
  int l=n-1+(n-2)*(n-1)/2-k;
  cout<<l<<"\n";
  for(int i=1;i<n&&l;++i)for(int j=i+1;j<=n&&l;++j)cout<<i<<" "<<j<<"\n",l--;
}

Measured memory_bytes: 256
N = input()

l = []

for i in range(N):
    l.append(input())

l.sort()

ptr = 0
res = 0
while ptr < N:
    cc = l[ptr]
    f = 0
    while (ptr < N and l[ptr] == cc):
        f += 1
        ptr += 1
    res += f%2

print res


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

#define INF (1<<27)
typedef pair<int,int> P;

int N,E,T;
vector<P> G[500];

struct Node{
  int c,g;
  vector<int> S;
 
  void init(int c,int g){
    this->c = c; if( c > 0 ) S = vector<int>(c,INF);
    this->g = g;
  }
  bool check(){
    for(int i=0;i<c;i++)
      if( S[i] >= INF) return false;
    return true;
  }
  bool update(int id,int x){
    if( S[id] > x ){
      S[id] = x; return true;
    } return false;
  }
  int value() const{
    if( S.empty() ) return 1;
    vector<int> s = S;
    sort(s.begin(),s.end());
    int ret = 0;
    for(int i=c-1,cnt=0;i>=0;i--,cnt++){
      ret = max ( cnt + s[i], ret );
    }
    return ret;
  }
  
  bool operator<(const Node& b)const{
    return value() > b.value();
  }

};

Node H[2000];

int main(){

  priority_queue<Node> q;

  cin >> N >> E >> T;
  for(int i=0;i<N;i++){
    int w;
    cin >> w;
    if( w == 1 ){
      Node n;
      n.init(0,i+1);
      H[i+E] = n;
      q.push( n );
    }
  }
  for(int i=0;i<E;i++){
    int g,c;
    cin >> g >> c;
    H[i].init(c,g);
    for(int j=0;j<c;j++){
      int s;
      cin >> s;
      G[s].push_back( P(i,j) );
    }
  }

  while( !q.empty() ){
    Node st = q.top(); q.pop();
    int val = st.value();
    int id = st.g;
    for(int i=0;i<(int)G[id].size();i++){
      P to = G[id][i];
      if( H[to.first].update(to.second,val) ){
	if( H[to.first].check() ){
	  q.push( H[to.first] );
	}
      }
    }
  }

  int res = INF;
  for(int i=0;i<N+E;i++){
    //  cout << H[i].g << " "<< H[i].value() << endl;
    if( H[i].g == T ) res = min( res, H[i].value() );
  }
  if( res >= INF ) cout << -1 << endl;
  else cout << res << endl;
}

Measured memory_bytes: 1476
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list> 
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
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; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
typedef pair<double,long long> pair_t;
bool comp(const pair_t& a, const pair_t& b) {
	if (a.first == b.first)return  a.second > b.second;
	else {
		return a.first > b.first;
	}
}

int main() {
	ll n,cnt=0,Mcnt=-INF;
	cin >> n;
	vector<ll>a(n);
	rep(i, n)cin >> a[i];
	unordered_map<ll, ll>bucket;
	for (ll i = 0; i < n; i++) {
		bucket[a[i] + 1]++;
		bucket[a[i]]++;
		bucket[a[i] - 1]++;
	}
	for (ll i = 0; i < pow(10, 5); i++) {
		cnt = bucket[i];
		Mcnt = max(Mcnt,cnt);
	}
	cout << Mcnt << endl;
}


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

using namespace std;

#define gc getchar_unlocked
#define foi(i,n) for(int i=0;i<n;i++)
#define Foi(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define fol(i,n) for(ll i=0;i<n;i++)
#define Fol(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pl;
typedef vector<int>     vi;
typedef vector<ll>      vl;
typedef vector<pii>     vpii;
typedef vector<pl>      vpl;
typedef vector<vi>      vvi;
typedef vector<vl>      vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

int mpow(int base, int exp) {
    base %= mod;
    int result = 1;
    while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
    }
    return result;
}

void ipgraph(int n, int m){
    int i, u, v;
    while(m--){
        cin>>u>>v;
        g[u-1].pb(v-1);
        g[v-1].pb(u-1);
    }
}

void dfs(int u, int par){
    for(int v:g[u]){
        if (v == par) continue;
        dfs(v, u);
    }
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll count=0;
    if(a<k)
    {
        count=a;
        k-=a;
        if(b<k)
        {
            k-=b;
            count-=k;
        }
    }   
    else
    {
        count=k;        
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 10696
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

def gcd(a, b)
  return gcd(b, a) if a>b
  while a != 0
     a, b = b % a, a
  end
  return b
end

ans = a[0]
1.upto(n-1) do |i|
  ans = gcd(ans, a[i])
end

puts ans

Measured memory_bytes: 9476
#include<iostream>
#include <algorithm>
#include <stdlib.h>
using namespace std;

int main(void) {
	int n;
	long long int y;
	cin >> n >> y;
	int a[3] = { 0,0,n };
	while (a[0] <= n) {
		while (a[2] >= 1) {
			if ((a[0] * 10000) + (a[1] * 5000) + (a[2] * 1000) >= y)break;
			a[1]++;
			a[2]--;
		}
		if ((a[0] * 10000) + (a[1] * 5000) + (a[2] * 1000) == y)break;
		a[0]++;
		a[1] = 0;
		a[2] = n - a[0];
	}
	if ((a[0] * 10000) + (a[1] * 5000) + (a[2] * 1000) != y) {
		a[0] = -1;
		a[1] = -1;
		a[2] = -1;
	}
	cout << a[0] << " " << a[1] << " " << a[2] << endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
A = np.asarray(input().split()).astype(np.int)

ind_maxA = A.argmax()

diffA = A.max() - A[ind_maxA:]
ind = np.where(diffA > 0)
cost = np.sum(diffA[ind])

maxA = 0
for n in range(1, ind_maxA):
    if A[n-1] > A[n]:
        diff = A[n-1] - A[n]
        cost += diff
        A[n] += diff 

print(cost) 

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

using namespace std;

int main(void){
  unsigned long long N;
  cin >> N;
  if(N % 2 == 1){
    cout << 0 << endl;
    return 0;
  }
  
  unsigned long long d = 5;
  unsigned long long ii = 1;
  unsigned long long ans = 0;
  N /= 2;
  while(d <= N){
    ans += ii * (N / d);
    d *= 5;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS             ios::sync_with_stdio(false); cin.tie(nullptr)
#define deb(x)          cout << #x << " = " << x << endl
#define deb2(x, y)      cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define f0(i, a, n)     for(i = a; i < n; i++)
#define f1(i, a, n)     for(i = a; i <= n; i++)
#define tc(t)           int t; cin >> t; while(t--)
#define ini(x, y)       memset(x, y, sizeof(x))
#define all(x)          x.begin(),x.end()
#define sz(x)           x.size()
#define ll              long long int
#define vi              vector<int>
#define si              set<int>
#define pb              emplace_back
#define ppb             pop_back
#define mp              make_pair
#define M               1000000007
#define endl            '\n'
#define bits(x)         __builtin_popcountll(x)
#define zrbits(x)       __builtin_ctzll(x)

using namespace std;

void solve() {
    int n, i, j, k, cnt = 0;
    cin >> n;
    int a[n];
    f0(i, 0, n) {
        cin >> a[i];
    }
    f0(i, 0, n-2) {
        f0(j, i+1, n-1) {
            f0(k, j+1, n) {
                if(a[i]!=a[j] && a[j]!=a[k] && a[k]!=a[i] && a[i]+a[j]>a[k] && a[i]+a[k]>a[j] && a[k]+a[j]>a[i]) {
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
}

int main () {
    IOS;
    // tc(t)
    solve();
    return 0;
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main(void){
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,0,n)cin>>a[i];
    descSort(a);

    ll ans=0;
    int t=n-1;
    rep(i,0,n){
        int li=2;
        if(i==0)li=1;
        rep(j,0,li){
            if(t>0){
                ans+=a[i];
                t--;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 4816