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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

bool check(vector<int> &x)
{
    int m=x.size();

    bool alternate=true;
    rep(i,m-1) if(x[i]==x[i+1]) alternate=false;

    if(alternate) return x[0]==1;

    for(int i=m/2; i<m-1; ++i)
    {
        if(x[i]==x[i+1]) return x[i]==1;
        int j=m/2-(i-m/2);
        if(x[j]==x[j-1]) return x[j]==1;
    }

    return false;
}

int main()
{
    int n;
    scanf(" %d", &n);
    int m=2*n-1;
    vector<int> a(m);
    rep(i,m) scanf(" %d", &a[i]);

    int l=1, r=m+1;
    while(r-l>1)
    {
        int mid=(l+r)/2;
        vector<int> t(m,0);
        rep(i,m) if(a[i]>=mid) t[i]=1;
        if(check(t)) l=mid;
        else r=mid;
    }
    printf("%d\n", l);
    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
int main () {
  int A, B;
  cin >> A >> B;
  int count = 0;
  string a;
  for (int i = 0; i < B - A + 1; i++) {
    a = to_string(i + A);
    if(a.at(0) == a.at(4) && a.at(1) == a.at(3)) count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "YES" : "NO";
}


int main(){
    int n; cin >> n;
    int h = 0;
    int ans = 0;
    rep(i,n){
        int tmp; cin >> tmp;
        if(tmp >= h){
            ans++;
            h = tmp;
        }
    }

    cout << ans << endl;

}



Measured memory_bytes: 256
N,M = gets.split.map(&:to_i)
a = []
M.times {
  a << gets.to_i
}

dp = Array.new(N+1, 0)
dp[0] = 1

ai = 0
1.upto(N) { |i|
  if a[ai] == i
    dp[i] = 0
    ai += 1
  else
    dp[i] = dp[i-1] + dp[i-2]
  end
}

p dp[N] % (10**9+7)


Measured memory_bytes: 433020
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()) {
            String[] sarr = sc.next().split(",");
            int[] x = new int[15];
            for(int i=0;i<12;i++) {
                x[i] = Integer.valueOf(sarr[i]);
            }
            int v = x[10];
            int v2 = x[11];
            for(int i=1;i<10;i++) {
                x[i] += x[i-1];
            }
            for(int i=0;i<10;i++) {
                if (x[9]*v<=x[i]*(v+v2)) {
                    System.out.println(i+1); break;
                }
            }
        }
    }
 
}

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

namespace ABC121
{
    class C
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            long N = long.Parse(input[0]);
            long M = long.Parse(input[1]);

            Dictionary<long, long> dict = new Dictionary<long, long>();

            long A = 0;
            long B = 0;
            for (long i = 0; i < N; i++)
            {
                input = Console.ReadLine().Split();
                A = long.Parse(input[0]);
                B = long.Parse(input[1]);

                if (!dict.ContainsKey(A)) { dict.Add(A, 0); }
                if (dict.ContainsKey(A)) { dict[A] += B; }
            }

            var res = dict.OrderBy(x => x.Key);

            long total = 0;
            foreach (var item in res)
            {
                if (M <= item.Value)
                {
                    total += item.Key * M;
                    break;
                }
                total += item.Key * item.Value;
                M -= item.Value;
            }
            Console.WriteLine(total);
        }
    }
}


Measured memory_bytes: 27084
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
int main()
{
    int n;
    string s;
    cin >> n >> s;
    int a=0, b=0;
    rep(i, n) if(s[i]=='R') ++a;
    int ans = max(a, b);
    rep(i, n) {
        if(s[i] == 'R') --a;
        else ++b;
        int now = max(a,b);
        ans = min(ans, now);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

int N;
queue<int> Q[1010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) rep(j, 0, N - 1) {
        int a;
        cin >> a;
        a--;
        Q[i].push(a);
    }

    set<pair<int, int>> buf;
    rep(cu, 0, N) {
        int to = Q[cu].front();
        if (Q[to].front() == cu)
            buf.insert({min(cu, to), max(cu, to)});
    }

    int ans = 0;
    while(!buf.empty()) {
        ans++;
        set<pair<int, int>> buf2;
        fore(p, buf) {
            int a = p.first;
            int b = p.second;

            Q[a].pop();
            Q[b].pop();

            if(!Q[a].empty()) {
                int cu = Q[a].front();
                if(!Q[cu].empty()) {
                    if(Q[cu].front() == a)
                        buf2.insert({min(a, cu), max(a, cu)});
                }
            }

            if(!Q[b].empty()) {
                int cu = Q[b].front();
                if(!Q[cu].empty()) {
                    if(Q[cu].front() == b)
                        buf2.insert({min(b, cu), max(b, cu)});
                }
            }
        }
        swap(buf, buf2);
    }

    rep(i, 0, N) if(!Q[i].empty()) {
        cout << -1 << endl;
        return;
    }
    cout << ans << endl;
}



Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);
template <class T1, class T2>
void vadd(vector<T1> &v, T2 x);

#define int long long int

void solve(long long N)
{
  lli sum = 0;
  vector<lli> ans;
  ans.push_back(N);
  ans.push_back(2);
  set<int> a;
  for (lli i = 2; i * i <= N; i++)
  {
    for (lli j = i; j <= N; j *= i)
    {
      if (j == N)
      {
        sum++;
        ans.push_back(i);
        break;
      }
      if (N % j == 0)
      {
        if ((N / j) % i == 1)
        {
          ans.push_back(i);
        }
      }
    }
  }
  lli M = N - 1;
  if (M != 1)
    ans.push_back(M);
  for (lli i = 2; i * i <= M; i++)
  {
    if (M % i == 0)
    {
      lli cand = M / i;
      ans.push_back(i);
      if (M != i)
        ans.push_back(M / i);
    }
  }
  sort(ans.begin(), ans.end());
  ans.erase(std::unique(ans.begin(), ans.end()), ans.end());
  // for (auto s : ans)
  // {
  //   cout << s << endl;
  // }
  cout << ans.size() << endl;
}

signed main()
{
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2>
void vadd(vector<T1> &v, T2 x)
{
  for (auto &s : v)
    s += T2(x);
}


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

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var a = cin.nextInt()-1;
            var b = cin.nextInt()-1;
            var t = new int[] { 100,2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 };
            Console.WriteLine(t[a]==t[b]?"Draw": (t[a]>t[b])?"Alice":"Bob");
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


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

ll gcd(ll a,ll b){
    while(b>0){
        ll x=a;
        a=b;
        b=x%a;
    }
    return a;
}

int main() {
    ll A,B;
    cin >> A >> B;
    ll g=gcd(A,B);
    g=A*(B/g);
    cout << g << endl;
}

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

using namespace std;

typedef long long ll;

int main()
{
  int n;
  cin >> n;
  vector<int> vs(n);
  for(int i = 0; i < n; i++)
  {
	cin >> vs[i];
  }
  sort(vs.begin(), vs.end());
  cout << (vs.back() - vs[0]) << endl;  

  return 0;
}


Measured memory_bytes: 256
# スペース区切りの整数の入力
n, m = gets.chomp.split(" ").map(&:to_i);

stores = []

(1..n).each do |_|
    a, b = gets.chomp.split(" ").map(&:to_i);
    stores.push({ 'num' => b, 'price' => a })
end

stores.sort! {|a, b| a['price'] <=> b['price'] }

result = 0
num = 0
stores.each do |store|
    buy_num = [m - num, store['num']].min
    num += buy_num
    result += store['price'] * buy_num
    if num == m then
        break
    end
end

# 出力
p result


Measured memory_bytes: 32376
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#include <numeric>
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)




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

	string S, T;
	cin >> S >> T;
	

	for (int i = 0; i < S.size(); i++) {
		if (S[i] != T[i]) { puts("No"); return 0; }
	}
	puts("Yes");
	
	return 0;
}

Measured memory_bytes: 3580
import sys
input = sys.stdin.readline
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    if N <= K:
        ans = 1
    else:
        ans = 1 + ((N-K)+K-2)//(K-1)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 13876
n = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(1,n-1):
  l = []
  l.append(p[i-1])
  l.append(p[i])
  l.append(p[i+1])
  ll = sorted(l)
  if ll[1] == p[i]:
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 2000;
const double c = 20.0 - 3.14159265358979323846 * 2 * 10 / 4.0;
const double C = 3.14159265358979323846  * 10  - 20.0;
int x1, Y, x2, y2;

int g(int y) {
	return abs(Y - y);
}

struct point {
	int x, y;
	bool operator < (const point q) const {
		if(this->x < q.x && g(this->y) < g(q.y))return true;
		return false;
	}
	bool operator >= (const point q) const {
		if(this->x >= q.x && g(this->y) >= g(q.y))return true;
		return false;
	}
};

int binary_search(point key, point *g, int low, int high)
{
    while (low < high)
    {
        int mid = (low + high) >> 1;
        if (key >= g[mid])
            low = mid + 1;
        else
            high = mid;
    }
    return low;
}


point a[maxn], d[maxn];

bool cmp(point w, point q) {
	if(w.x < q.x)return true;
	else if(w.x == q.x)return g(w.y) < g(q.y);
	return false;
}

int main()
{	
	//freopen("in.txt","r",stdin);
    int n, j, len;
    cin>>x1>>Y>>x2>>y2;
    if(x1 > x2) {
    	swap(x1, x2);
    	swap(Y, y2);
	}
	cin>>n;
	int cnt = 0;
	for(int i=0;i<n;i++) {
		scanf("%d%d",&a[i].x,&a[i].y);
		if(a[i].x <= x2 && a[i].x >= x1 && 
		(ll)(a[i].y - Y) * (ll)(a[i].y - y2) <= 0)
			a[cnt++] = a[i];
	}
	sort(a, a + cnt, cmp);
    //memset(g, 0, sizeof(g));
    //cout<<cnt<<endl;
    d[1] = a[0], len = 1;//初始化子序列长度为1，最小右边界
    for (int i = 1; i < cnt; i++)
    {
        if (d[len] < a[i])//(如果允许子序列相邻元素相同 g[len]<=a[i],默认为不等）
            j = ++len; //a[i]>g[len],直接加入到g的末尾,且len++
        else
            j = binary_search(a[i], d, 1, len + 1);
        d[j] = a[i];//二分查找,找到第一个比a[i]小的数g[k],并g[k+1]=a[i]
    }
    if(cnt == 0)len = 0;
	//cout << len << endl;
	
	double ans = fabs(x1 - x2) + fabs(Y - y2);
	ans = ans * 100.0;
	int t1 = min(abs(Y - y2), abs(x1 - x2)), t2 = 0;
	if(len > t1)t2 = 1;
	t1 = min(t1, len);
	ans -= (double)t1 * c;
	ans += (double)t2 * C;
	
	printf("%.13lf\n",ans);
    return 0;
}

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

int main()
{
  int n, k, sum = 1;
  cin >> n >> k;

  for (int i = 0; i < n; i++)
  {
    int buf1 = sum * 2;
    int buf2 = sum + k;

    sum = min(buf1, buf2);
  }
  cout << sum << endl;
}


Measured memory_bytes: 3632
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

Q = int(input())
lis = []
for i in range(Q):
    lis.append(list(map(int,input().split())))

qu = [0]
now = 0
for i in range(0,50000):
    if is_prime(2*i+1) and is_prime(i+1):
        now+=1
        qu.append(now)
    else:
        qu.append(now)

for i in range(Q):
    qlis = lis[i]
    minin = int((qlis[0]-1)/2)
    maxin = int((qlis[1]+1)/2)
    print(qu[maxin]-qu[minin])

Measured memory_bytes: 68824
#include <bits/stdc++.h>
using namespace std;
typedef                 long long ll;
typedef                 unsigned long long ull;
#define mkp             make_pair
#define pii             pair<int,int>
#define piii            pair<pii,int>
#define vi              vector<int>
#define PI              acos(-1)
#define all(v)          v.begin(),v.end()
#define mmset(a,val)    memset(a,val,sizeof(a))
#define sc(a)           scanf("%d",&a)
#define sc2(a,b)        scanf("%d%d",&a,&b)
#define sc3(a,b,c)      scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d)    scanf("%d%d%d%d",&a,&b,&c,&d)
#define sc5(a,b,c,d,e)  scanf("%d%d%d%d%d",&a,&b,&c,&d,&e)
#define scll(a)         scanf("%I64d",&a)
#define scll2(a,b)      scanf("%I64d%I64d",&a,&b)
#define scll3(a,b,c)    scanf("%lld%lld%lld",&a,&b,&c)
#define scll4(a,b,c,d)  scanf("%I64d%I64d%I64d%I64d",&a,&b,&c,&d)
#define Pr(a)           printf("%d\n",a)
#define Prll(a)         printf("%I64d\n",a)
#define pb(a)           push_back(a)
#define SZ              size()
#define tcs(t)          for(int tc=1;tc<=t;tc++)
#define INF             0x3f3f3f3f
#define hash_val        347
#define popcount        __builtin_popcount
#define MOD             1000000007
#define MX              2005
//int fx[]={-1,-1,0,1,1,1,0,-1};
//int fy[]={0,1,1, 1,0,-1,-1,-1};
int Set(int n,int pos){return n=n|(1<<pos);}
int reset(int n,int pos){return n=n& ~ (1<<pos);}
bool check(int n,int pos){return (bool) (n& (1<<pos));}
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);};
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);};
ll l[105];
int main()
{
             //       freopen("input.txt","r",stdin);
            //  freopen("output.txt","w",stdout);

        l[0]=2;
        l[1]=1;
        for(int i=2;i<=90;i++)
            l[i]=l[i-1]+l[i-2];
            int n;
            sc(n);
            printf("%lld\n",l[n]);



}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x, i = 1;
		while(true){
			x = i;
			if (x % 3 == 0) System.out.printf(" %d", i);
			else{
				while (true){
					if (x % 10 == 3){System.out.printf(" %d", i); break;}
					else{ x /= 10; if (x == 0) break;}
				}
			}
			if (++i <= n) continue;
			else break;
		}
		System.out.print("\n");
	}
}

Measured memory_bytes: 38928
import math
from functools import reduce
K = int(input())

def gcd(*numbers):
  return reduce(math.gcd, numbers)

ans = 0
for a in range(1,K+1):
  if (a==1):
    ans += K*K
    continue
  for b in range(1,K+1):
    t = gcd(a,b)
    if(t==1):
      ans += K
      continue
    for c in range(1,K+1):
      ans += gcd(t,c)
print(ans)

Measured memory_bytes: 9556
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(alias fun)(int n) {
    foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = fun();
    return res;
}
// fold was added in D 2.071.0.
template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
        static if (S.length < 2) {
            return reduce!fun(seed, r);
        } else {
            return reduce!fun(tuple(seed), r);
        }
    }
}

void main() {
    int N, K, X, Y;
    readf("%d\n%d\n%d\n%d\n", &N, &K, &X, &Y);
    writeln(X*min(K, N) + Y*max(0, N-K));
}


Measured memory_bytes: 256
### constant

N = 4
N2 = N * N / 2

### subroutines

def count_rec(rem, x, y)
  return 1 if rem == 0

  while $used[y][x]
    x += 1
    if x >= N
      y += 1
      x = 0
    end
  end

  count = 0
  $used[y][x] = true

  for xy in $xys
    x0 = x + xy[0]
    y0 = y + xy[1]
    if x0 >= 0 && x0 < N && y0 < N && ! $used[y0][x0]
      $used[y0][x0] = true
      count += count_rec(rem - 1, x, y)
      $used[y0][x0] = false
    end
  end

  $used[y][x] = false
  count
end

### main

loop do
  line = gets.strip
  break if line.to_i > N

  ds = line.split.map(&:to_i)

  $xys = []
  N.times do
    xi = ds.shift
    yi = ds.shift
    $xys << [xi, yi]
  end
  #p $xys

  $used = N.times.map{N.times.map{false}}

  count = count_rec(N2, 0, 0)

  p count
end

Measured memory_bytes: 6128
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <sstream>
using namespace std;

int toNum(char num){
  if(num >= '0' && num <= '9') return num - '0';
  return num - 'a' + 10;

}

string toBit(int num){
  string str = "";
  while(num){
    str += (num % 2) + '0';
    num /= 2;
  }
  int size = str.size();
  for(int i=0; i<4-size; i++) str += "0";
  reverse(str.begin(),str.end());

  return str;
}

string toStr(double a){
  string str;
  while(a){
    int num = a * 10;
    str += num + '0';
    a *= 10;
    a -= num;
  }
  return str;
}

int main(){
  int n;
  cin >> n;
  for(int t=0; t<n; t++){
    string s,bits;
    cin >> s;
    for(int i=0; i<s.size(); i++){
      int num = toNum(s[i]);
      string bit = toBit(num);
      bits += bit;
    }
    bool minus = false;
    if(bits[0] == '1') minus = true;
    long long a = 0;
    double b = 0;

    for(int i=24; i>=1; i--){
      if(bits[i] == '1')
	a += pow(2.0,23-i+1);
    }
    
    for(int i=25; i<32; i++){
      if(bits[i] == '1'){
	b += (double)pow(0.5,i-24);
      }
    }

    if(minus) cout << "-";
    cout << a;
    if(b == 0) cout << ".0" << endl;
    else {
      string tmp = toStr(b);
      cout << "." << tmp << endl;
    }

  }
  return 0;
}

Measured memory_bytes: 1220
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
using namespace std;
char in[10][10];
int dx[]={-1,-1,-1,0,0,1,1,1};
int dy[]={-1,0,1,-1,1,-1,0,1};
int f2(char a,char b,int c,int d,int q){
	int sum=0;
	rep(i,8){
		int co=1;
		int x=c+dx[i],y=d+dy[i];
		if(in[x][y]!=a)continue;
		while(1){
			x+=dx[i];
			y+=dy[i];
			if(in[x][y]==b){
				sum+=co;
				if(q){
					int xx=c,yy=d;
					rep(j,co){
						xx+=dx[i];
						yy+=dy[i];
						in[xx][yy]=b;
					}
				}
				break;
			}
			if(in[x][y]=='.')break;
			co++;
		}
	}
	return sum;
}
bool f(char a,char b){
	int ma=0,x,y;
	loop(i,1,9)loop(j,1,9)if(in[i][j]=='.'){
		int d=f2(a,b,i,j,0);
		if(a=='x'&&ma<d){ma=d;x=i;y=j;}
		if(a=='o'&&ma<=d){ma=d;x=i;y=j;}
	}
	if(!ma)return false;
	in[x][y]=b;
	f2(a,b,x,y,1);
	return true;
}
int main(){
	rep(i,10)rep(j,10)if(!i||!j||i==9||j==9)in[i][j]='.';
	else cin>>in[i][j];
	while(f('x','o')+f('o','x')!=0);
	rep(i,8){rep(j,8)cout<<in[i+1][j+1];cout<<endl;}
}

Measured memory_bytes: 1136
#include <iostream>
using namespace std;
int main(void){
    
    int A, B, C;
    int count5, count7;
    
    count5 = 0;
    count7 = 0;
    
    cin >> A >> B >> C;
    
    if (A == 5) ++count5;
    else if (A == 7) ++count7;
    
    if (B == 5) ++count5;
    else if (B == 7) ++count7;
    
    if (C == 5) ++count5;
    else if (C == 7) ++count7;
    
    if (count5 == 2 && count7 == 1) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}


Measured memory_bytes: 256
var s:array[1..4]of char;
    i,j,k:int64;
begin
  for i:=1 to 4 do read(s[i]);
  if (s[1]=s[2])and(s[3]=s[4])and(s[2]=s[3]) then writeln('No')
  else if (s[1]=s[2])and(s[3]=s[4]) then writeln('Yes')
  else if (s[1]=s[3])and(s[2]=s[4]) then writeln('Yes')
  else if (s[1]=s[4])and(s[3]=s[2]) then writeln('Yes')
  else writeln('No')
end.


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <tuple>
#include <cctype>
#include <set>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <queue>
#include <climits>
#include <cmath>
#include <numeric>
#include <string>
#include <cstdio>
#include <ctype.h>



using namespace std;

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

	long long n = (long long)sqrt(N);
	long long res = N;
	for (long long i = 1; i <= n; ++i)
	{
		long long m = N / i;
		if (m * i == N)
		{
			res = min(res, m + i - 2);
		}

	}
	cout << res;


	return 0;
}

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

int main(){
    int A;
    int B;

    cin >> A >> B;

    if (A + B == 3){
        cout << 3;
    }

    if (A + B == 4){
        cout << 2;
    }

    if (A + B == 5){
        cout << 1;
    }
}

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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<double> v(N);
	for (auto &x : v) {
		cin >> x;
	}

	sort(v.begin(), v.end());
	double ans = v[0];
	for (int i = 1; i < N; ++i) {
		ans = (ans + v[i]) / 2;
	}
	printf("%.10f\n", ans);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
const int maxn=400005;

struct {
	ll sum,lazy;	
} S[maxn];
int n,q;

void update(int id,int ql,int qr,int v,int l,int r) {
	if (ql==l && qr==r) {
		S[id].lazy+=v;
		return;
	}
	int m=l+r>>1;
	if (qr<=m) update(id<<1,ql,qr,v,l,m);
	else if (ql>m) update(id<<1|1,ql,qr,v,m+1,r);
	else update(id<<1,ql,m,v,l,m), update(id<<1|1,m+1,qr,v,m+1,r);
	S[id].sum=S[id<<1].sum+S[id<<1|1].sum+S[id<<1].lazy*(m-l+1)+S[id<<1|1].lazy*(r-m);
}

ll query(int id,int ql,int qr,int l,int r) {
	int m=l+r>>1;
	ll lz=S[id].lazy*(qr-ql+1);
	if (ql==l && qr==r) return lz+S[id].sum;
	if (qr<=m) return lz+query(id<<1,ql,qr,l,m);
	else if (ql>m) return lz+query(id<<1|1,ql,qr,m+1,r);
	else return lz+query(id<<1,ql,m,l,m)+query(id<<1|1,m+1,qr,m+1,r);
}

int main() {
	cin>>n>>q;
	for (int i=0;i<q;i++) {
		bool op; cin>>op;
		int s,t,x;
		if (op) {
			cin>>s>>t;
			cout<<query(1,s,t,1,n)<<'\n';
		}
		else {
			cin>>s>>t>>x;
			update(1,s,t,x,1,n);
		}
	}
}


Measured memory_bytes: 7192
n = int(input())
h = list(reversed(list(map(int, input().split()))))
ans = 'Yes'
for i in range(1, len(h)):
    if h[i] - h[i-1] > 1:
        ans = 'No'
        break
    if h[i] - h[i-1] == 1:
        h[i] -= 1
print(ans)

Measured memory_bytes: 14252
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;(i)>=0;(i)--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;
int main(){
    
    ll a,b;
    cin>>a>>b;
    
    if(a==0||b==0){
        cout<<"Zero"<<endl;
        return 0;
    }
    
    if(a<0&&b>0){
        cout<<"Zero"<<endl;
        return 0;
    }
    
    if(a>0){
        cout<<"Positive"<<endl;
        return 0;
    }
    
    if(b<0){
        if(abs(a+b)%2==0){
            cout<<"Negative"<<endl;
            return 0;
        }else{
            cout<<"Positive"<<endl;
            return 0;
        }
    }
    
    return 0;
}


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

int main(){
    vector<int> vec(5);
    for(int i = 0; i < vec.size(); i++){
        cin >> vec[i];
        if(vec[i]==0){
            cout << i+1 << endl;
        }

    }
}


Measured memory_bytes: 3608
import java.io.*;
import java.util.*;

public class Main {

        private static void solve(InputReader in, PrintWriter out) {
            Integer m=in.nextInt(),n=in.nextInt();
            long sum=0;
            for(int i=0;i<n;i++){
                sum+=in.nextInt();
            }
            System.out.print((m-sum>=0)?m-sum:-1);
        }
        public static void main(String args[]){
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            InputReader in = new InputReader(inputStream);
            PrintWriter out = new PrintWriter(outputStream);
            solve(in,out);
            out.close();
        }
        private static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
            public Double nextDouble() {
                return Double.parseDouble(next());
            }
    }
}

Measured memory_bytes: 34088
import sys
import math
from collections import Counter
import itertools
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

N=II()
H=LI()

m=H[0]
ans =1
for i in range(1,N):
    if m<=H[i]:
        m=H[i]
        ans+=1
print(ans)

Measured memory_bytes: 3316
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        s: chars, _t: chars,
        a: i64, b: i64,
        u: chars,
    }
    let (mut a, mut b) = (a, b);
    if s == u {
        a -= 1;
    } else {
        b -= 1;
    }
    puts!("{} {}\n", a, b);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < (int)(x); i++)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    int n; cin >> n;
    string s;cin >> s;
    string alp = "";
    rep(i,26)alp += 'A'+i;
    alp += alp;
    // cout << alp << endl;
    string ans = s;
    rep(i,s.size()){
        int temp = s[i]-'A';
        ans[i] = alp[temp+n];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  char c;
  cin>>c;
  if(isupper(c)) cout<<'A'<<newl;
  if(islower(c)) cout<<'a'<<newl;
  return 0;
}


Measured memory_bytes: 3620
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
ans = float("inf")
def sub(x, base):
    if x==0:
        return 0
    i = 0
    while pow(base, i+1)<=x:
        i += 1
    return sub(x-pow(base,i), base) + 1
for i in range(n+1):
    ans = min(ans, sub(i,6)+sub(n-i,9))
print(ans)

Measured memory_bytes: 75228
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
   
   string s;
   int K;
   cin >> s >> K;
   
   vector<string> S;

   for (int i = 0; i < s.size(); i++) {
      for (int j = 1; j <= 5; j++) {
         S.push_back(s.substr(i, j));
      }
   }
   
   sort(S.begin(), S.end());
   S.erase(unique(S.begin(), S.end()), S.end());
   
   cout << S.at(K-1) << endl;
   return 0;
}


Measured memory_bytes: 1660
n, k = map(int, input().split())
h = [int(i) for i in input().split()]

inf = 10**5
dp = [inf for i in range(n)]
dp[0] = 0

for i in range(1, n):
    tmp = []
    for j in range(i-k, i):
        if j >= 0:
            tmp.append(dp[j] + abs(h[j] - h[i]))
    dp[i] = min(tmp)

print(dp[-1])

Measured memory_bytes: 56672
PROGRAM DIGITS

      INTEGER N,K
      READ(*,*) N,K

      DO 100 I=1,100

      N=N/K
!      WRITE(*,*) N
      if( N.LT.1 ) THEN
        GOTO 200
      ENDIF

  100 CONTINUE

  200 WRITE(*,*)I

      STOP
      END


Measured memory_bytes: 256
n = int(input())
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
m = 0
for i in range(n-1):
    s = sum(a1[:i+1]) + sum(a2[i:])
    m = max(m,s)
if n == 1:
    m = sum(a1) + sum(a2)
print(m)

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

int a[4][13];
char suit;
char s[4] = {'S','H','C','D'};
int N,num;
int main() {
	cin >> N;
	for(int i=0; i<N; ++i) {
		cin >> suit >> num;
		if(suit == 'S') a[0][num] = 1;
		else if(suit == 'H') a[1][num] = 1;
		else if(suit == 'C') a[2][num] = 1;
		else a[3][num] = 1;
	}
	for(int i=0; i<4; ++i) {
		for(int k=0 ; k<13 ; ++k) {
			if(! a[i][k+1]) cout << s[i] << " " << k+1 << endl;
		}
	}
}

Measured memory_bytes: 1160
#define _USE_MATH_DEFINES
#pragma region include

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////
bool runrun(int X) {
	vector<int> A;
	while (X) {
		A.push_back(X % 10);
		X /= 10;
	}
	int len = A.size();
	if (len == 1) {
		return true;
	}

	bool ans = true;
	for (int i = 0; i < len - 1; ++i) {
		if (abs(A[i] - A[i + 1]) > 1) {
			return false;
		}
	}
	
	return ans;
}
void solve() {
	int K;
	cin >> K;
	vector<LL> A(1001000, 0);
	for (int i = 1; i < 10; ++i) {
		A[i-1] = i;
	}
	int L, R;
	L = 0;//例外
	R = 8;
	int cnt = 9;
	K;
	if (K <= 9) {
		cout << A[K-1] << endl;
		return;
	}
	while (cnt < K) {
		int nextL = R + 1;
		int nextR;
		for (int i = L; i <= R; ++i) {
			LL ter = A[i];
			int base = ter % 10;

			if (base > 0) {
				A[cnt] = ter * 10 + base - 1; ++cnt;
			}
			A[cnt] = ter * 10 + base + 0; ++cnt;
			if (base < 9) {
				A[cnt] = ter * 10 + base + 1; ++cnt;
			}
		}
		nextR = cnt - 1;
		L = nextL;
		R = nextR;
	}
	//sort(A.begin(), A.begin()+K);
	cout << A[K - 1] << endl;
	/*
	int cnt = 0;
	int no = 1;
	while (cnt < 100010) {
		if (runrun(no)) {
			++cnt;
			cout << cnt << " " << no << endl;
		}
		++no;
	}
	*/
}

#pragma region main
signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 8064
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
 
    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define int long long
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define deb(x) cout<<#x<<" "<<x<<endl;
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int MOD =  1000000007 ;
    const int MAX = 2e6 + 7;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    
    int x,ans,res;
    int a[MAX];
    
    void solve()
    {
       cin>>n;
       fo(i,1,n+1)
       {
           cin>>a[i];
       }
       
       sort(a+1,a+n+1);
       
       l=1;
       r=n;
       x=a[(n+1)/2];
       fo(i,1,n)
       {
           if(i&1)
           {
               ans+=abs(a[l]-x);
               x=a[l++];
           }
           else
           {
               ans+=abs(a[r]-x);
               x=a[r--];
           }
       }
       
       l=1;
       r=n;
       x=a[(n+1)/2];
       fo(i,1,n)
       {
           if(!(i&1))
           {
               res+=abs(a[l]-x);
               x=a[l++];
           }
           else
           {
               res+=abs(a[r]-x);
               x=a[r--];
           }
       }
       cout<<max(res,ans)<<endl;
       
       
        
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //
 
    int32_t main() 
      {
        
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        
        // cin>>t;while(t--)
        solve();
        
      return 0;
      }


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<(#a)<<':'<<(a)<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key < value;
}

int binary_search(vector<ll> a,ll key){
  ll ok = a.size();
  ll ng = -1;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}


int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  vector<int> a(100001,0);
  rep(i,n){
    int tmp;cin>>tmp;
    a[tmp]++;
  }
  int ans = 0;
  rep(i,100001){
    int tmp = a[i];
    if(i > 0)tmp += a[i-1];
    if(i < n-1)tmp += a[i+1];
    ans = max(ans,tmp);
  }
  print(ans);
  return 0;
} 


Measured memory_bytes: 640
#include <iostream>

const int NMAX = 100005;

using namespace std;

int N;
int p[NMAX];
int answer;

int main()
{
    cin >> N;
    for (int i = 1; i <= N; ++i)
    {
        cin >> p[i];
    }

    for (int i = 1; i <= N; ++i)
    {
        if (p[i] == i)
        {
            if (i < N && ( p[i+1] == (i+1) ))
            {
                answer++;
                i++;
            }
            else
            {
                answer++;
            }
        }
    }

    cout << answer << '\n';

    return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <cstdlib>
#include <random>
#include <map>
#include <string>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <cassert>
#include <iomanip>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;

const int M = (int)1e5 + 1;
const ld EPS = 1e-9;
const ll MOD = (ll)1e9 + 7;
const ll INF = (ll)1e9 + 10;
const ld PI = acosl(-1);
const int N = (int)1e6 + 2;



void solve() {
	int n;
	cin >> n;
	multiset<pair<int, int>> m;
	for (int i = 0; i < n; i++) {
		int x, l;
		cin >> x >> l;
		m.insert({ x + l, x - l });
	}

	int ans = 0;
	ll cur = -INF;
	while (m.size()) {
		while (!m.empty() && m.begin()->second < cur) {
			m.erase(m.begin());
		}
		if (m.empty()) break;
		ans++;
		cur = m.begin()->first;
		m.erase(m.begin());
	}
	cout << ans << endl;

}

int main() {
	//auto trash = freopen("a.in", "r", stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	solve();
}

Measured memory_bytes: 4992
S = input()
N = len(S)

def is_kaibun(kaibun):
    for i in range(len(kaibun)//2):
        if kaibun[i] != kaibun[-i-1]:
            return False
    return True
  
if is_kaibun(S)&is_kaibun(S[:int((N-1)/2)])&is_kaibun(S[int((N+3)/2)-1:]):
  print('Yes')
else:
  print('No')

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

int main() {
	int a;
    a = 1 < a;
  int b;
    b = b < 100;
  cin >> a;
  cin >> b;
double ax = a + b;
double bx = ax / 2 + 0.5;
int x = bx;
  cout << x << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

vector<int64_t> divisor(int64_t n) {
  vector<int64_t> ret;
  for (int64_t i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.emplace_back(i);
      if (i * i != n) ret.emplace_back(n / i);
    }
  }
  sort(ret.rbegin(), ret.rend());
  return (ret);
}

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  int64_t K;
  cin >> N >> K;
  vector<int64_t> A(N);
  int64_t sum = 0;
  rep(i, N) {
    cin >> A[i];
    sum += A[i];
  }

  int64_t answer = 0;
  for (auto tmp_ans : divisor(sum)) {
    vector<int64_t> mod(N);
    rep(i, N) mod[i] = A[i] % tmp_ans;
    sort(mod.begin(), mod.end());

    vector<int64_t> ssum(N + 1);
    ssum[0] = 0;
    rep(i, N) { ssum[i + 1] = ssum[i] + mod[i]; }

    rep(i, N) {
      int64_t tmp = (N - i) * 1LL * tmp_ans - (ssum[N] - ssum[i]);
      if (max(ssum[i], tmp) <= K) {
        answer = max(answer, tmp_ans);
        break;
      }
    }
  }
  cout << answer << endl;
  return 0;
}


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

int main(void){
  char s[101], t[101];
  scanf("%s", s);
  scanf("%s", t);
  int i, j;
  char tmp;
  int flag;
  
  for(i = 0; i < strlen(s) - 1; i++){
    for(j = i + 1; j < strlen(s); j++){
      if(s[i] > s[j]){
        tmp = s[i];
        s[i] = s[j];
        s[j] = tmp;
      }
    }
  }
  for(i = 0; i < strlen(t) - 1; i++){
    for(j = i + 1; j < strlen(t); j++){
      if(t[i] < t[j]){
        tmp = t[i];
        t[i] = t[j];
        t[j] = tmp;
      }
    }
  }
  
  if(strcmp(s, t) < 0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin >> s;
	if(s=="Sunny") cout<<"Cloudy\n";
	else if(s=="Cloudy") cout<< "Rainy\n";
	else cout << "Sunny\n"; 
	return 0;
}


Measured memory_bytes: 256