akhauriyash/Code-Regression huggingface dataset:
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);
char a[2333],b[2333];
int n,ans,pre[2333],nxt[2333];
int dis(int x,int y){if(x<=y)return y-x;else return y+n-x;}//x to y
int calc()
{
	for(int i=1;i<=n;i++)
	{
		int t=i;
		while(b[t]=='0')
		{
			t--;
			if(t==0)t=n;
		}
		pre[i]=t;
		t=i;
		while(b[t]=='0')
		{
			t++;
			if(t==n+1)t=1;
		}
		nxt[i]=t;
	}
	int ret=inf;
	for(int sh=0;sh<n;sh++)
	{
		vector<pii> all;
		int cur=0,cmx=0,mn=inf;
		for(int i=1;i<=n;i++)
		{
			int ni=i+sh;if(ni>n)ni-=n;
			if(a[i]==b[ni])continue;
			cur++;
			if(ni>=i&&nxt[i]<=ni&&nxt[i]>=i)continue;
			if(ni<i&&(nxt[i]>=i||nxt[i]<=ni))continue;
			all.pb(mp(dis(pre[i],i),dis(ni,nxt[ni])));
//			printf("i= %d ni= %d\n",i,ni);
		}
		if(all.size()==0)mn=0;
		all.pb(mp(0,0));
		sort(all.begin(),all.end());
		for(int i=all.size()-1;i>=1;i--)
		{
			mn=min(mn,cmx+all[i].ff);
			cmx=max(cmx,all[i].ss);
		}
//		printf("shift = %d cur= %d mn= %d\n",sh,cur,mn);
		ret=min(ret,cur+mn*2+sh);
	}
	return ret;
}
int main()
{
	scanf("%s%s",a+1,b+1);n=strlen(a+1);
	
	bool ok=1;
	for(int i=1;i<=n;i++)if(b[i]=='1')ok=0;
	if(ok)
	{
		for(int i=1;i<=n;i++)if(a[i]=='1')
		{
			puts("-1");
			return 0;
		}
		puts("0");
		return 0;
	}
	
	ans=calc();
	reverse(a+1,a+n+1);reverse(b+1,b+n+1);ans=min(ans,calc());
	printendl(ans);
	return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
edges = [[] for i in range(N)]
edges_2 = []
for i in range(M):
    a,b = map(int,input().split())
    a,b = a-1, b-1
    edges[a].append(b)
    edges[b].append(a)
    edges_2.append([a,b])

def search(remove_edge):
    Q = [(-1,0)]
    visited = [False for j in range(N)]
    visited[0] = True
    while Q:
        a,b = Q.pop()
        for e in edges[b]:
            if remove_edge[0] == b and remove_edge[1] == e:
                pass
            elif remove_edge[1] == b and remove_edge[0] == e:
                pass
            elif e == a:
                pass
            elif visited[e]:
                pass
            else:
                visited[e] = True
                Q.append((b,e))
    if False in visited:
        return True
    else:
        return False

ans = 0
for e in edges_2:
    if search(e):
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

using namespace std;

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

    int tmp = 7;
    for(int i=1; i<=10000000; i++) {
        if(tmp % K == 0) {
            cout << i << endl;
            return 0;
        } else {
            tmp *= 10;
            tmp += 7;
            tmp %= K;
        }
    }

    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3628
from collections import Counter
import math

def ncr(n, r):
  if r > n:
    return 0
  return math.factorial(n) // math.factorial(n-r) // math.factorial(r)

input()
As = list(map(int, input().split()))
counter = Counter(As)
res = {}
total = 0
for k, v in counter.items():
  x = ncr(v, 2)
  res[k] = (x, (x * (v-2) // (v)))
  total += x
for a in As:
  v1, v2 = res[a]
  print(total - v1 + v2)

Measured memory_bytes: 35252
#include <iostream>
#include <algorithm>

#define int long long

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)

#define INF (3e9)

using namespace std;

int N;
int T[103];

int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main()
{
    cin >> N;
    REP(i,N) cin >> T[i];

    int ans = T[0];
    for (int i = 1; i < N; ++i)
    {
        ans = ans / gcd(ans, T[i]) * T[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
if n<3*5*7:
    ans=0
elif n<3**3*5:
    ans=1
elif n<3*5*11:
    ans=2
elif n<3**3*7:
    ans=3
elif n<3*5*13:
    ans=4
else:
    ans=5
print(ans)


Measured memory_bytes: 2940
// C++ 14
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <math.h>

#define ll long long
#define Int ll
#define loop(x, start, end) for(Int x = start; x < end; x++)
#define loopdown(x, start, end) for(int x = start; x > end; x--)
#define span(a,x,y) a.begin()+x,a.begin()+y
#define span_all(a) a.begin(),a.end()
#define len(x) (x.size())
#define last(x) (*(x.end()-1))

using namespace std;

#define EPS 0.000000001
#define fequals(a,b) (fabs((a) - (b)) < EPS)

class Vector2 {
public:
  double x, y;
  
  Vector2(double x = 0, double y = 0): x(x), y(y) {}
  
  Vector2 operator + (const Vector2 v) const { return Vector2(x + v.x, y + v.y); }
  Vector2 operator - (const Vector2 v) const { return Vector2(x - v.x, y - v.y); }
  Vector2 operator * (const double k) const { return Vector2(x * k, y * k); }
  Vector2 operator / (const double k) const { return Vector2(x / k, y / k); }
  
  double length() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  double dot (Vector2 const v) { return x * v.x + y * v.y; }
  double cross (Vector2 const v) { return x * v.y - y * v.x; }
  
  bool parallel(Vector2 &other) {
    return fequals(fabs(dot(other)), length() * other.length());
  }
  
  bool orthogonal(Vector2 &other) {
    return fequals(0, dot(other));
  }
  
  bool operator < (const Vector2 &v) {
    return x != v.x ? x < v.x : y < v.y;
  }
  
  bool operator == (const Vector2 &v) {
    return fabs(x - v.x) < EPS && fabs(y - v.y) < EPS;
  }
};

ostream & operator << (ostream & out, Vector2 const & v) { 
  out<< "Vector2(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Vector2 & v) { 
  double x, y;
  in >> x;
  in >> y;
  v.x = x;
  v.y = y;
  return in;
}


void reflection(Vector2 start_, Vector2 end_, Vector2 p) {
    Vector2 v = end_ - start_;
    Vector2 b = start_ + v * (v.dot(p - start_) / v.norm());
    Vector2 op = p + ((b - p) * 2);
    cout << op.x << ' ' << op.y << endl;
}

#define MAX_N 1001
Int N;
Vector2 start_, end_, p;

void input() {
  cin >> start_ >> end_ >> N;
  while (cin >> p) {
    reflection(start_, end_, p);
  }
}

int main() {
  cout.precision(15);
  input();
}


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

const int Size=1e6+5;
const int Mod=998244353;

int N,M,Ans;
int Fac[Size],Inv[Size];

int C(int n,int m){
	return 1llu*Fac[n]*Inv[m]%Mod*Inv[n-m]%Mod;
}

int Get_Inv(int x){
	return x<2?1:1llu*(Mod-Mod/x)*Get_Inv(Mod%x)%Mod;
}

int main(){
	int i;
	scanf("%d%d",&N,&M);
	if(N<M)
		swap(N,M);
	Fac[0]=Inv[0]=Fac[1]=Inv[1]=1;
	for(i=2;i<=N+M;i++){
		Fac[i]=1llu*Fac[i-1]*i%Mod;
		Inv[i]=1llu*(Mod-Mod/i)*Inv[Mod%i]%Mod;
	}
	for(i=2;i<=N+M;i++)
		Inv[i]=1llu*Inv[i-1]*Inv[i]%Mod;
	for(i=1;i<=M;i++)
		Ans=(Ans+1llu*C(2*i,i)*C(N+M-2*i,N-i))%Mod;
	Ans=1llu*Ans*Get_Inv(2llu*C(N+M,M)%Mod)%Mod;
	printf("%d\n",(Ans+N)%Mod);
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

typedef vector<ld> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

#define INF INT_MAX
#define MOD 1000000007
#define all(x) x.begin(), x.end()

int N;
vi A(4);
vector<vvi> dp(305, vvi(305, vi(305, -1)));

ld f(int a, int b, int c){
    if(a < 0 or b < 0 or c < 0) return 0;
    if(dp[a][b][c] != -1) return dp[a][b][c];

    int v = (a+b+c);

    dp[a][b][c] = N + a*f(a-1,b,c) + b*f(a+1,b-1,c) + c*f(a,b+1,c-1);
    dp[a][b][c] /= ld(v);
    return dp[a][b][c];
}

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

    cin >> N;
    for(int x = 0; x < N; x++){
        int i; cin >> i;
        A[i]++;
    }
    dp[0][0][0] = 0;
    cout << fixed << setprecision(10) << f(A[1], A[2], A[3]) << endl;

    return 0;
}

Measured memory_bytes: 450816
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)
const int INF = (1<<30);
const ll INFLL = 1LL<<62;
const long double EPS = 1e-12;

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

class HOGE{
  public:
    ll index;
    ll value;
    HOGE(ll index, ll value){
      this->index = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "index : " << index << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  cin >> N;
  ll S = 0;
  ll N_copy = N;
  while(N_copy>0){
    S += N_copy%10;
    N_copy/=10;
  }

  if(N%S==0){
    cout << "Yes\n";
  }else{
    cout << "No\n";
  }

  return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back

#define rep(i, N) for(ll i = 0; i < N; i++)
#define repa(i, a, N) for(ll i = a; i < N; i++)
#define repr(i, N) for(ll i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

#define all(A) A.begin(), A.end()

const double PI = 3.141592653589793;

// const ll mod = 1e9 + 7;
const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

ll id(char c) {
	return c - 'a';
}

bool isOK(vi& a, ll k, ll index) {
	return a[index] < k * (index + 1);
}

ll binary_search(vi& a, ll k) {
	ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	ll right = (ll)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		ll mid = left + (right - left) / 2;

		if (isOK(a, k, mid))
			right = mid;
		else left = mid;
	}

	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}

template<class t, class u>
ostream& operator<<(ostream& os, const pair<t, u>& p) {
	return os << "{" << p.first << "," << p.second << "}";
}

template<class t> ostream& operator<<(ostream& os, const vector<t>& v) {
	os << "{";
	for (auto e : v)os << e << ",";
	return os << "}";
}

int main() {
	string S;

	cin >> S;

	ll N = S.size();
	vi B(N);

	rep(i, N) {
		if (S[i] == '<') {
			B[i] = true;
		}
		else {
			B[i] = false;
		}
	}

	ll top = 0;
	ll num = 0;
	bool up = B[0];

	ll ans = 0;
	repa(i, 1, N) {
		// cout << up << endl;
		num++;
		if (up) {
			if(B[i]){
			}
			else {
				top = num;
				ans += num * (num - 1) / 2;
				num = 0;
			}
		}
		else {
			if (B[i]) {
				top = max(top, num);

				ans += num * (num - 1) / 2;
				ans += top;
				num = 0;
			}
		}
		up = B[i];
	}

	num++;
	if (up) {
		ans += num * (num - 1) / 2;
		ans += num;
	}
	else {
		ans += max(top, num);
		ans += num * (num - 1) / 2;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4740
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

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

	map<int,int> m;
	rep(i,n){
		int a;
		cin >> a;
		m[a]++;
	}

	vector<int> v;
	for(auto i : m){
		v.emplace_back(i.second);
	}
	sort(all(v));

	long long ans = 0;
	auto it = v.begin();
	range(i,k,m.size()){
		ans += *it;
		it++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 10748
import java.util.Scanner;
public class Main {

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

        int a=scan.nextInt();
        int b=scan.nextInt();
        int c=scan.nextInt();
        int cnt=0;
        if(a!=b && b!=c && c!=a)
            cnt=3;
        else if(a==b && b==c)
            cnt=1;
        else
            cnt=2;
        System.out.println(cnt);


    }
}

Measured memory_bytes: 9808
#include<iostream>
#include<algorithm>
#include<map>
#include<set>
using lint=int64_t;
using namespace std;

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

	map<int,lint> indexof;
	for(lint i=1;i<=N;i++)
	{
		lint val;
		cin >> val;
		indexof[val]=i;
	}

	multiset<lint> ipool;
	ipool.insert(0);
	ipool.insert(0);
	ipool.insert(N+1);
	ipool.insert(N+1);
	
	lint ans=0;
	for(lint i=N;i>=1;i--)
	{
		lint l2,l1,r1,r2;
		auto itr=ipool.lower_bound(indexof[i]);
		r1=*itr;
		++itr;
		r2=*itr;
		--itr;--itr;
		l1=*itr;
		--itr;
		l2=*itr;

		ans+=(indexof[i]-l1)*(r2-r1)*i;
		ans+=(l1-l2)*(r1-indexof[i])*i;

		ipool.insert(indexof[i]);
	}

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



Measured memory_bytes: 11136
import Control.Arrow
import Data.List
import qualified Data.ByteString.Char8 as B
import Control.Monad 
--import Data.Ord

main :: IO ()
main = readLn >>= main'
    where
        main' n = replicateM n breads >>= printRes . solve -- . sortBy cmpf
        printRes = putStrLn . unwords . map show
        --cmpf = flip (comparing (!! 2))

solve :: [[Int]] -> [Int]
solve xyhs = calcLoop [(x, y) | x <- [0..100], y <- [0..100]]
    where
        calcLoop ((cx, cy) : rs) = judge (Left 10000000000) $ map calcH xyhs
            where
                judge (Right ans) (Right v : res)
                    | ans == v = judge (Right v) res
                    | otherwise = calcLoop rs
                judge (Right ans) (Left v : res)
                    | ans <= v = judge (Right ans) res
                    | otherwise = calcLoop rs
                judge (Left ans) (Right v : res)
                    | v <= ans = judge (Right v) res
                    | otherwise = calcLoop rs
                judge (Left ans) (Left v : res) = judge (Left $ min ans v) res
                judge (Right ans) _ = [cx,  cy, ans]
                judge _ _ = calcLoop rs

                calcH [x, y, h]
                    | h > 0 = Right $ h + z
                    | otherwise = Left $ z
                    where
                        z = zf x y

                zf x y = abs (x - cx) + abs (y - cy)


breads :: IO [Int]
breads = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

Measured memory_bytes: 1532
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
//cin.tie(0);ios::sync_with_stdio(false);


signed main()
{
    int n;cin>>n;
    cout<<n*(n+1)/2<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int ketasuu = 0, N, ans = inf;
vector<int> v;
void dfs(int level, int num) {
	if(num >= N) ans = min(ans, num);
	if(level >= ketasuu) {
		return;
	}
	for(int i = 0; i < v.size(); i++) {
		dfs(level + 1, num + v[i] * pow(10, level));
	}
}

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

	bool ban[10];
	for(int i = 0; i < 10; i++) ban[i] = false;
	for(int i = 0; i < K; i++) {
		int D;
		cin >> D;
		ban[D] = true;
	}
	for(int i = 0; i < 10; i++)
		if(!ban[i]) v.push_back(i);

	int tmp = N;
	while(tmp) {
		ketasuu++;
		tmp /= 10;
	}
	ketasuu++;

	dfs(0, 0);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var QHSD = Sarray();
            var Q = QHSD[0];
            var H = QHSD[1];
            var S = QHSD[2];
            var D = QHSD[3];
            var N = Sarray()[0];
            var Qp2l = Q * 8;
            var Hp2l = H * 4;
            var Sp2l = S * 2;
            var Dp2l = D;
            var min = Min(Min(Min(Qp2l, Hp2l), Sp2l), Dp2l);
            var ans = 0L;
            if (min == Dp2l)
            {
                ans = N / 2 * Dp2l;
                if (N % 2 != 0)
                {
                    var min2 = Min(Min(Qp2l, Hp2l), Sp2l);
                    ans += min2 / 2;
                }
            }
            else
                ans = min / 2 * N;
            WriteLine(ans);

            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
#include<iostream>
#include<queue>
using namespace std;
const int N=1010;
int main()
{
    priority_queue<int> pq[N];
    int aa,T;
    cin>>aa>>T;
    while(T--)
    {
        int t,x;
        int c;
        cin>>c;
        if(c==0)
        {
            
            cin>>t>>x;
            pq[t].push(x);
        }
        else if(c==1)
        {
            cin>>t;
            if(pq[t].size())
            {
                cout<<pq[t].top()<<endl;
            }
        }
        else
        {
            cin>>t;
            if(pq[t].size())
            {
                pq[t].pop();
            }
        }
    }
}


Measured memory_bytes: 4136
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int):
    L = [A,B,C]
    L.sort()
    res = L[2]*2 - L[0] - L[1]
    if res % 2 == 1:
        res += 3

    print(res//2)



# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)

if __name__ == '__main__':
    main()


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

using namespace std;

const int MAXN = 87;
int a[MAXN][MAXN];
int b[MAXN][MAXN];

const int SZ = 15000;

bitset<30000> dp[MAXN][MAXN];

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            cin >> b[i][j];
        }
    }
    dp[0][0][a[0][0] - b[0][0] + SZ] = true;
    dp[0][0][b[0][0] - a[0][0] + SZ] = true;
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            if (i != 0)
            {
                for (int k = 0; k < SZ * 2; ++k)
                {
                    if (dp[i - 1][j][k])
                    {
                        dp[i][j][k + a[i][j] - b[i][j]] = true;
                        dp[i][j][k + b[i][j] - a[i][j]] = true;
                    }
                }
            }
            if (j != 0)
            {
                for (int k = 0; k < SZ * 2; ++k)
                {
                    if (dp[i][j - 1][k])
                    {
                        dp[i][j][k + a[i][j] - b[i][j]] = true;
                        dp[i][j][k + b[i][j] - a[i][j]] = true;
                    }
                }
            }
        }
    }
    int ans = SZ;
    for (int i = 0; i < SZ * 2; ++i)
    {
        if (dp[n - 1][m - 1][i])
        {
            ans = min(ans, abs(SZ - i));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 26752
/*
 * Contents   : AOJ DPL 1 G
 * Author     : KitauraHiromi
 * LastUpdate : 20180619
 * Since      : 20180619
 */
#include <iostream>
#include <algorithm>
using namespace std;
int dp[10001]; // dp[w]: 重さwまでの荷物を作ったときの最大価値
int v[101], m[101], w[101];
int N, W;
int main(void){
    fill(dp, dp+10001, 0);
    cin >> N >> W;
    for(int i=0; i<N; ++i) cin >> v[i] >> w[i] >> m[i];

    for(int i=0; i<N; ++i){
        for(int k=0; m[i]>0; ++k){
            int key = min(m[i], (int)(1<<k));
            m[i] -= key;
        // for(int key=0; key<=m[i]; ++key){
            for(int j=W; j>=key*w[i]; --j){
                dp[j] = max(dp[j], dp[j-key*w[i]] + key*v[i]);
            }
        }
    }
    int ret = 0;
    for(int j=0; j<=W; ++j) ret = max(ret, dp[j]);
    cout << ret << endl;
}


Measured memory_bytes: 3132
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = long long;
using u32 = unsigned long long;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using vi32 = vector<i32>;
using vu32 = vector<u32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf64 = vector<f64>;
using vstr = vector<string>;
using vvi32 = vector<vi32>;
using vvu32 = vector<vu32>;
using vvi64 = vector<vi64>;
using vvu64 = vector<vu64>;
using vvf64 = vector<vf64>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

bool compare(string a, string b) {
  if (a.size() > b.size()) return true;
  else if (a.size() < b.size()) return false;
  return a > b;
}

int dp[10010];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  int n, m;
  cin >> n >> m;
  vi32 a(m);
  rep(i, m) cin >> a[i];
  map<int, char> stick;
  rep(i, m) {
    switch (a[i]) {
      case 1: stick[1] = 2; break;
      case 2: stick[2] = 5; break;
      case 3: stick[3] = 5; break;
      case 4: stick[4] = 4; break;
      case 5: stick[5] = 5; break;
      case 6: stick[6] = 6; break;
      case 7: stick[7] = 3; break;
      case 8: stick[8] = 7; break;
      case 9: stick[9] = 6; break;
    }
  }
  rep(i, 10010) dp[i] = -1e9;
  dp[0] = 0;
  reps(i, n) {
    rep(j, m) {
      if (i - stick[a[j]] < 0) continue;
      amax(dp[i], dp[i - stick[a[j]]] + 1);
    }
  }
  sort(all(a), greater<i32>());
  string ans = "";
  int remain = dp[n];
  int match = n;
  while (match) {
    rep(i, m) {
      if (match - stick[a[i]] >= 0 && dp[match - stick[a[i]]] == remain - 1) {
        ans += char(a[i] + '0');
        remain--;
        match -= stick[a[i]];
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 

int main(){
int N;
cin >> N;
vector<double> A(N);
REP(i, N) cin >> A[i];

double bo = 0;
REP(i, N){
bo += 1 / A[i];
}

double ans = 1 / bo;

cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
X, K, D = map(int, input().split())

#0をまたげないとき
if abs(X)-K*D >= 0:
    print(abs(X) - K*D)
else:#0をまたげるとき
    if X > 0:
        t = K - (X // D)
        X = X % D
    else:
        t = K - (-X // D) -1
        X = -(-X % D) + D
    
    if t % 2 == 0:
        print(X)
    else:
        print(abs(X - D))


Measured memory_bytes: 9136
#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
using namespace std;
void solve()
{
    //Enter your code here Tanmay:)
    int n,k,c=0;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        if(arr[i]>=k)
            c++;
    }
    cout<<c;
    
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

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

		int N = sc.nextInt();
		int K = sc.nextInt();

		long A[] = new long[N];

		for (int i = 0; i < N; i++) {
			A[i] = sc.nextLong();
		}

		for (int i=0; i < N - K; i++) {
			if (A[i] < A[i+K]) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
		}
	}

	private static class FastScanner {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;

		public FastScanner(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
			tokenizer = null;
		}

		public String next() {
			if (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 long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 60140
/*
 Name    : sudhakar kandikattu
 Target  : Master in CF ,5* in CC
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mod 1000000007
ll power(ll base,ll pow);
void solve()
{
	int n;
	cin>>n;
	unordered_map<int,int> ump;
	for(int i=0,x;i<n;i++)
	{
		cin>>x;
		ump[x]++;
	}
	int ans=0;
	for(auto it:ump)
	{

		if(it.first<=it.second) ans+=(it.second-it.first);
		else ans+=it.second;
		//cout<<it.first<<" "<<ans<<endl;
	}
	cout<<ans;
}
int main() {
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}
ll power(ll base,ll pow)
{
   ll res=1;
   while(pow)
   {     
         if (pow%2!=0)  res=(res*base)%mod;
         base=(base*base)%mod;
         pow/=2;
   }
   return res;
}

Measured memory_bytes: 4260
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
const int MOD=998244353;
ULL pw(ULL a, ULL n){ ULL b=1; while(n){ if(n&1){ b=(b*a)%MOD; } a=(a*a)%MOD; n>>=1; } return b; }

int main(){
int N, M, i; cin >> N; int D[N], F[N]={}; ULL ans=1;
for(i=0; i<N; i++){ cin >> D[i]; F[D[i]]++; }
if(D[0]!=0||F[0]!=1){ cout << 0 << "\n"; return 0; }
for(i=2, M=F[1]+1; M<N; M+=F[i++]){
  if(F[i]!=0){ ans=(ans*pw(F[i-1], F[i]))%MOD; }
  else{ cout << 0 << "\n"; return 0; }
}
cout << ans << "\n";
}

Measured memory_bytes: 1024
N, Q, S, T = map(int, input().split())
A = [int(input()) for i in range(N+1)]
C = 0
for i in range(N):
    if A[i] < A[i+1]:
        C += S * (A[i] - A[i+1])
    else:
        C += T * (A[i] - A[i+1])
def add(k, x):
    if x >= 0:
        if B[k] <= 0:
            if B[k] + x <= 0:
                return - T * x
            return T * B[k] - S * (B[k] + x)
        return - S * x
    if B[k] >= 0:
        if B[k] + x >= 0:
            return - S * x
        return S * B[k] - T * (B[k] + x)
    return - T * x

B = [A[i+1] - A[i] for i in range(N)]
ans = []
for q in range(Q):
    l, r, x = map(int, input().split())
    C += add(l-1, x); B[l-1] += x
    if r < N:
        C += add(r, -x); B[r] -= x
    ans.append(C)
print(*ans, sep='\n')


Measured memory_bytes: 31848
program main
  implicit none
  integer(8) :: l, r, i, j, res
  read (*, *) l, r
  if (r - l >= 2018) then
    write (*, "(i0)") 0
  else
    res = 2019
    do i = l, r - 1
      do j = i + 1, r
        res = min(res, mod(i * j, 2019_8))
      end do
    end do
    write (*, "(i0)") res
  end if
end program main


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool palindrome(string s, int st, int en)
{
	bool res=true;
	for(int i=st;i<=(en/2);i++ )
	{
		if(s[i]!=s[en-i])return false;
	}
	return res;
}
int main()
{
  string s;
  cin>>s;
  bool c1=palindrome(s,0, s.length()-1);
  int n=s.length();
  bool c2=palindrome(s,0,(n-2)/2);
  bool c3=palindrome(s,(n+2)/2, n-1);
  if(c1 and c2 and c3)cout<<"Yes";
  else cout<<"No";
}

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

using namespace std;

int main() {
    int A,B,C;
    cin >> A >> B >> C;
    string ans;
    if ((A < C && C < B) || (B < C && C < A))
    {
        ans = "Yes";
    } else {
        ans = "No";
    }
    cout << ans << endl;
    return 0;
}

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

#define ll long long
#define endl "\n"

inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m;
    cin>>m;
    return m;
}
void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
int n;
ll a[100005],b[100005],c[100005];
ll dp[100005][5];
ll solve(int i,int prv){
 if(i==n)return 0;
 if(dp[i][prv]!=-1)return dp[i][prv];
 ll x=0;
 if(prv!=1){
 x=a[i]+solve(i+1,1);
 }
 ll y=0;
 if(prv!=2)
 y=b[i]+solve(i+1,2);
 ll z=0;
 if(prv!=3)
 z=c[i]+solve(i+1,3);
 return dp[i][prv]=max({x,y,z});
}
int main()
{
    memset(dp,-1,sizeof dp);
    fast();
    n=D();
    for(int i=0;i<n;++i){
        a[i]=D();b[i]=D();c[i]=D();
    }
    cout<<solve(0,10)<<endl;
}

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

int main(){
int n,A[100];
cin>>n;

for(int i=0;i<n;i++)cin>>A[i];


for(int i=n-1;i>=0;i--){
if(i !=n-1)cout<<" ";
cout<<A[i];

}
cout<<endl;
return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <unordered_map>
#include <map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int pts[51][51];

int count(int x1, int x2, int y1, int y2) {
    return pts[x2][y2] - pts[x1-1][y2] - pts[x2][y1-1] + pts[x1-1][y1-1];
}

int main() {
    int n, k;
    vector<P> v;
    VI xs;
    VI ys;
    cin >> n >> k;
    REP(i,n) {
        long x, y;
        cin >> x >> y;
        v.push_back(P(x,y));
        xs.push_back(x);
        ys.push_back(y);
    }
    
    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());
    unordered_map<long, long> mx, my, Mx, My;
    REP(i,n) {
        mx[xs[i]] = i + 1;
        Mx[i + 1] = xs[i];
        my[ys[i]] = i + 1;
        My[i + 1] = ys[i];
    }
    
    vector<P> w;
    REP(i,n) {
        w.push_back(P(mx[v[i].first], my[v[i].second]));
    }
    
    REP(i,n) {
        pts[w[i].first][w[i].second] = 1;
    }
    
    REPI(i,1,51) {
        REPI(j,1,51) {
            pts[i][j] = pts[i][j] + pts[i-1][j] + pts[i][j-1] - pts[i-1][j-1];
        }
    }
    
    long ans = 4e18;
    REPI(x,1,n+1) {
        REPI(i,x,n+1) {
            REPI(y,1,n+1) {
                REPI(j,y,n+1) {
                    int cnt = count(x,i,y,j);
                    if (cnt >= k) {
                        long area = (Mx[i] - Mx[x]) * (My[j] - My[y]);
                        ans = min(ans, area);
                    }
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Max(a,b,c) max(max(a,b),c)
#define int long long
using namespace std;
inline int read() {
	int x=0,f=1; char ch=getchar();
	while(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=(x<<3)+(x<<1)+(ch^48); ch=getchar(); }
	return x * f;
}
const int N = 1e5+7;
int n,K,R,S,P,ans;
int f[N][3];
char s[N];
signed main()
{
	n = read(), K = read();
	R = read(), S = read(), P = read();
	scanf("%s",s+1);
	for(int i=1,last=0;i<=K;++i) {	//0±íÊ¾RÊ¯Í·£¬1±íÊ¾S¼ôµ¶£¬2±íÊ¾P²¼ 
		f[i][0] = last + (s[i]=='s'?R:0);
		f[i][1] = last + (s[i]=='p'?S:0);
		f[i][2] = last + (s[i]=='r'?P:0);
		//last = Max(f[i][0],f[i][1],f[i][2]);
		//printf("last=%d\n",last);
	}
	for(int i=K+1;i<=n;++i) {
		f[i][0] = max(f[i-K][1],f[i-K][2]) + (s[i]=='s'?R:0);
		f[i][1] = max(f[i-K][0],f[i-K][2]) + (s[i]=='p'?S:0);
		f[i][2] = max(f[i-K][0],f[i-K][1]) + (s[i]=='r'?P:0);
	}
	//for(int i=1;i<=n;++i) printf("f[i] = %d %d %d\n",f[i][0],f[i][1],f[i][2]);
	for(int i=n;i>=n-K+1;--i) ans += Max(f[i][0],f[i][1],f[i][2]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  int ans = 0;
  for (int i = 1; i < n - 1; i++){
    if (max(p[i - 1],p[i + 1]) > p[i] && min(p[i - 1],p[i + 1]) < p[i]) ans++;
  }
  cout << ans;
}

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

int main(){
  int i;
  string S;
  int N, K;
  cin >> N >> K >> S;
  K--;
  if(S[K]=='A') S[K]='a';
  else if(S[K]=='B') S[K]='b';
  else S[K]='c';
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
int main(){
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    long long p;
    /*
    a->b
    a->b   *2 1 1
    a->cc
    a->dd  *2 1 0
    aa->c
    bb->c  *1 0 1
    aa->cc *3
    bb->dd    0 0
    */
    p = 3;
    int i = 0;
    int b = 1;//一つ前の状態
    if(n == 1)cout << p << endl;
    else{
        //初期状態
        if(s[0] == s[1]){
            p = 6;
            b = 0;
            i += 2;
        }else{
            p = 3;
            b = 1;
            i++;  
        }
        while(i < n){
            if(i < n-1 && s[i] == s[i+1]){
                if(b == 0)p *= 3;
                else p *= 2;
                b = 0;
                i += 2;
            }else{
                if(b == 1)p *= 2;
                b = 1;
                i++;
            }
            p %= MOD;
        }
        cout << p << endl;
    }
    //cin >> n;
}

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

int main(){
	while(1){	
		int h, w; //h<w
		
		scanf(" %d %d", &h, &w);
		if(h==0) break;
		
		int r=h*h+w*w;
		int p=20000;
		int a, b;
		
		for(int i=1; i<=100; ++i){
			int j=i+1;
			while(i*i+j*j<r) ++j;
			//printf(" %d %d\n", i, j);
			if(i*i+j*j==r){
				if(i<=h) ++j;	
			}
			
			int tmp=i*i+j*j;
			if(tmp<p){
				p=tmp;
				a=i;
				b=j;
			}
		}
		
		printf("%d %d\n", a, b);
	}
	return 0;
}

Measured memory_bytes: 1188
# -*- coding: utf-8 -*-
S = raw_input()
T = raw_input()

N, M = len(S), len(T)
SA, SB = [0]*(N + 2), [0]*(N + 1)
TA, TB = [0]*(M + 1), [0]*(M + 1)
for i in xrange(1, N + 1):
    SA[i] = SA[i - 1] + (1 if S[i - 1] == "A" else 0)
    SB[i] = SB[i - 1] + (1 if S[i - 1] == "B" else 0)
for i in xrange(1, M + 1):
    TA[i] = TA[i - 1] + (1 if T[i - 1] == "A" else 0)
    TB[i] = TB[i - 1] + (1 if T[i - 1] == "B" else 0)

q = int(raw_input())
for loop  in xrange(q):
    a, b, c, d = map(int, raw_input().split())
    A0 = SA[b] - SA[a - 1]
    B0 = SB[b] - SB[a - 1]
    A1 = TA[d] - TA[c - 1]
    B1 = TB[d] - TB[c - 1]
    A0 += 2*B0
    A1 += 2*B1
    A0 %= 3
    A1 %= 3

    if A0 == A1:
        print "YES"
    else:
        print "NO"


Measured memory_bytes: 15876
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
const int N = 11000;
int n,k,len,mx,vis,l[N << 1];
char s[N << 1],res[N << 1],c = 'z';
void copy(int p){for(int i = 1;i <= n;i ++) res[i] = s[p + i - 1];}
void check(int p)
{
	if(!vis) copy(p),vis = 1;
	for(int i = 1;i <= n;i ++)
	{
		if(res[i] < s[p + i - 1]) return;
		if(res[i] > s[p + i - 1]) return copy(p);
	}
}
int main()
{
	n = read(); k = read(); scanf("%s",s + 1);
	for(int i = 1;i <= n;i ++) c = min(c,s[(n << 1) + 1 - i] = s[i]);
	if(k >= 15){for(int i = 1;i <= n;i ++) putchar(c); return 0;}
	if(k == 1)
	{
		for(int i = 1;i <= n + 1;i ++) check(i);
		for(int i = 1;i <= n;i ++) putchar(res[i]);
		return 0;
	}
	for(int i = 1;i <= (n << 1);i ++) if(s[i] == c) mx = max(l[i] = l[i - 1] + 1,mx);
	if((len = mx << k - 1) >= n) {for(int i = 1;i <= n;i ++) putchar(c); return 0;}
	for(int i = 1;i <= n + mx;i ++) if(l[i] == mx) check(i - l[i] + 1);
	for(int i = 1;i <= len;i ++) putchar(c);
	for(int i = len + 1;i <= n;i ++) putchar(res[i - len + mx]);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main() {
    string s;
    int a,b;
    cin>> a>>b;
    cin >> s;
    bool flag = true;
    for (int i = 0; i < a; ++i) {
        if(s[i] == '-') {
            flag = false;
        }
    }
    if(s[a] != '-') flag = false;

    for (int i = a+1; i < a+b+1; ++i) {
        if(s[i] == '-') {
            flag = false;
        }
    }
    if(flag) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
  #include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
  using namespace std;
using namespace __gnu_pbds;
  #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define double long double
  #define all(v) v.begin(),v.end()
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const double PI = acos(-1);
  const int N = 1e6 + 7;
  int mod = 1e9 + 7;
 
int32_t main()
{
       



     int n;
     cin >> n;

     int dp[n+1][3];
     int a[n+1],b[n+1],c[n+1];
     rep(i,1,n)
     {
      cin >> a[i] >> b[i] >> c[i];
     }
     dp[1][0] = a[1];
     dp[1][1] = b[1];
     dp[1][2] = c[1];
     rep(i,2,n)
     {
      dp[i][0] = max(dp[i-1][1] + a[i],dp[i-1][2]+a[i]);
      dp[i][1] = max(dp[i-1][0] + b[i],dp[i-1][2]+b[i]);
      dp[i][2] = max(dp[i-1][0] + c[i],dp[i-1][1]+c[i]);
     }
     cout << max({dp[n][0],dp[n][1],dp[n][2]});

   return 0;
}       


Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
int main()
{
	long long k = 0, s = 0, rate[100] = {}, last = 0,  ans= 0, ansb = 0, x = 0, y = 0,z=0;
	std::string  c;
	std::cin >> k>>s;
	bool okada = true;
	for (int i = 0; i <= k; i++) {
		for (int j = 0; j <= k; j++) {
			x = i;
			y = j;
			z = s - i - j;
			if (x + y + z == s&&z<=k&&z>=0) {
				ans++;
	
			
			}
		}
	}

	std::cout << ans << std::endl;
}







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

int dp[1000][1000];
char b[1000][1000];

int main() {
	int n;
	while (cin >> n , n) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				cin >> b[i][j];
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				dp[i][j] = (b[i][j] == '.') ? 1 : 0;
			}
		}

		int ans = 0;
		for (int i = 1; i < n; i++) {
			for (int j = 1; j < n; j++) {
				if (b[i][j] == '*') continue;
				int len = min(dp[i - 1][j - 1], dp[i - 1][j]);
				len = min(len, dp[i][j - 1]);
				dp[i][j] = len + 1;
				ans = max(ans, dp[i][j]);
			}
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 6044
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int n, d;
  readf("%s %s\n", &n, &d);
  auto x = new int[][](n, d);
  foreach (i; 0..n) {
    x[i] = readln.chomp.split.to!(int[]);
  }
  int cnt;
  foreach (i; 0..n) {
    foreach (j; i+1..n) {
      int sum;
      foreach (k; 0..d) {
        sum += (x[i][k] - x[j][k]) ^^ 2;
      }
      if (sum == sqrt(sum.to!double).to!int ^^ 2) {
        cnt++;
      }
    }
  }
  cnt.writeln;
}


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

int main(void){
  int n,v[100005],w[100005],elem1[100005]={},elem2[100005]={},i,k=0,l=0,max1,max2,a,b;
  int maxvalue1,maxvalue2,num1=0,num2=0,next,nextvalue,next1,nextvalue1,answer,minanswer;
  char str[1000000],*p;
  
  fgets(str,sizeof(str),stdin);
  n=atoi(str);
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  v[l]=atoi(p),l++,num1=v[0];
  for(i=1;i<n;i++){
    p=strtok(NULL," \n");
    if(i%2==1){
      w[k]=atoi(p);
      if(num2<w[k]){
        num2=w[k];
      }
      k++;
    }else{
      v[l]=atoi(p);
      if(num1<v[l]){
        num1=v[l];
      }
      l++;
    }
  }
  
  for(i=0;i<n/2;i++){
    elem1[v[i]]++;
  }
  for(i=0,max1=0,maxvalue1=0,next1=0,nextvalue1=0;i<=num1;i++){
    if(max1<=elem1[i]){
      next1=max1,nextvalue1=maxvalue1,max1=elem1[i],maxvalue1=i;
    }else if(next1<elem1[i]){
      next1=elem1[i],nextvalue1=i;
    }
  }
  for(i=0;i<n/2;i++){
    elem2[w[i]]++;
  }
  for(i=0,max2=0,maxvalue2=0,next=0,nextvalue=0;i<=num2;i++){
    if(max2<elem2[i]){
      next=max2,nextvalue=maxvalue2,max2=elem2[i],maxvalue2=i;
    }else if(max2<=elem2[i] && i!=maxvalue1){
      next=max2,nextvalue=maxvalue2,max2=elem2[i],maxvalue2=i;
    }else if(next<elem2[i]){
      next=elem2[i],nextvalue=i;
    }
    
  }
  
  if(maxvalue1!=maxvalue2){
    answer=n-max1-max2;
    minanswer=answer;
    printf("%d\n",minanswer);
    return 0;
  }
  if(maxvalue1==maxvalue2){
    a=n-max1-next;
    b=n-next1-max2;
    if(a<b){
      minanswer=a;
    }else{
      minanswer=b;
    }
  }
  
  printf("%d\n",minanswer);
  
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    ll a,b;
    cin >> a >> b;
    if(a <= 0 && 0 <= b) cout << "Zero" << endl;
    else if(a > 0 && b > 0) cout << "Positive" << endl;
    else if((b - a) % 2 == 0) cout << "Negative" << endl;
    else cout << "Positive" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
int n;
ll a[N], s[N], ans;
ll calc(ll a, ll b, ll c, ll d) {
    return max(max(a, b), max(c, d)) - min(min(a, b), min(c, d));
}
int main() {
    scanf("%d", &n);
    for(int i = 1 ; i <= n ; ++ i) scanf("%lld", &a[i]), s[i] = s[i - 1] + a[i];
    ans = calc(a[1], a[2], a[3], s[n] - s[3]);
    for(int i = 2, j = 1, k = 3 ; i <= n - 2 ; ++ i) {
        // [1, i]                   [i + 1, n]
        // [1, j] [j + 1, i]        [i + 1, k] [k + 1, n]
        while(j + 1 <= i && s[j + 1] <= s[i] - s[j + 1]) ++ j;
        while(k + 1 <= n && s[k + 1] - s[i] <= s[n] - s[k + 1]) ++ k;
        ll a = s[j], b = s[i] - s[j], c = s[k] - s[i], d = s[n] - s[k];
        ll tmp = calc(a, b, c, d);
        ll L = tmp, R = tmp;
        if(j + 1 <= i) L = min(L, calc(a + :: a[j + 1], b - :: a[j + 1], c, d));
        if(k + 1 <= n) R = min(R, calc(a, b, c + :: a[k + 1], d - :: a[k + 1]));
        if(j + 1 <= i && k + 1 <= n) ans = min(ans, calc(a + :: a[j + 1], b - :: a[j + 1], c + :: a[k + 1], d - :: a[k + 1]));

        ans = min(ans, min(L, R));
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n; cin >> n;
    vector<float> Cock(n);
    REP(i, n) cin >> Cock[i];
    whole(sort, Cock);
    float ans = (Cock[1] + Cock[0]) / 2;
    FOR(i, 2, n){
        ans = (ans + Cock[i]) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256