akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
using P = pair<ll, ll>;

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

const int MOD = 1000000007;


int main()
{
    int n; cin >> n;
    int a[n];
    int maxa = -1;
    rep(i,n){
        cin >> a[i];
        maxa = max(maxa, a[i]);
    }

    int num[maxa+1];
    rep(i,maxa+1) num[i] = 0;
    num[0] = 3; // 最初は三色の帽子がどれも使われていない

    ll res = 1;
    rep(i,n){
        if(num[a[i]] == 0){
            res = 0;
            break;
        }
        res *= num[a[i]];
        res %= MOD;
        num[a[i]+1]++;
        num[a[i]]--;
    }
    cout << res << endl;
}

Measured memory_bytes: 4356
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
ll n,a,b,c,d,e;
cin >>n>>a>>b>>c>>d>>e;
ll k=n%min({a,b,c,d,e});
if(k!=0) k=1;
cout <<(n/min({a,b,c,d,e}))+k+4<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    ll n; cin >> n;
    string s; cin >> s;
    vector<ll> w(n+1,0), r(n+1,0);
    rep(i,n){
        if(s[i] == 'W') w[i+1]++;
        else r[i+1]++;
    }
    rep(i,n){
        w[i+1] += w[i];
        r[i+1] += r[i];
    }
    ll ans = 1ll<<60;
    rep(i,n+1){
        ll rr = w[i];
        ll ww = r[n]-r[i];
        ll ch = max(rr,ww);
        chmin(ans,ch);
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
const int N = 200010;
int _w;

int n, a[N], b[N][20], s[20];

bool ok() {
	for( int i = 0; i < 20; ++i )
		if( s[i] > 1 ) return false;
	return true;
}

int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for( int i = 1; i <= n; ++i ) {
		cin >> a[i];
		for( int j = 0; j < 20; ++j )
			if( a[i] & (1<<j) )
				b[i][j] = 1;
	}
	int L = 1, R = 1;
	ll ans = 0;
	for( ; R <= n; ++R ) {
		for( int i = 0; i < 20; ++i )
			s[i] += b[R][i];
		while( !ok() ) {
			for( int i = 0; i < 20; ++i )
				s[i] -= b[L][i];
			++L;
		}
		ans += R-L+1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 16640
N, K = map(int, input().split())
s = list(input())

cnt = 1
cntlist = []
for i in range(1, N):
    if s[i - 1] != s[i]:
        cntlist.append(cnt)
        cnt = 1
    else:
        cnt += 1

cntlist.append(cnt)
if s[0] == "0":
    cntlist = [0] + cntlist

ans = 0
for i in range(2 * K + 1):
    if i >= len(cntlist):
        break
    ans += cntlist[i]
anslist = [ans]
s = 0
g = 2 * K + 1
while g < len(cntlist):
    ans -= cntlist[s]
    ans -= cntlist[s + 1]
    s += 2
    ans += cntlist[g]
    g += 1
    if g >= len(cntlist):
        anslist.append(ans)
        break
    ans += cntlist[g]
    g += 1
    anslist.append(ans)

print(max(anslist))

Measured memory_bytes: 5540
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    K=I()
    A,B=MI()
    if(A%K==0 or A//K!=B//K or B%K==0):
        print("OK")
    else:
        print("NG")
if __name__ == '__main__':
    main()

Measured memory_bytes: 77984
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

int cond(int n,int *d){
  while(n>0){
    if(d[n%10]) return 0;
    n/=10;
  }
  return 1;
}

void run(void){
  int n,k;
  scanf("%d%d",&n,&k);
  int d[10]={0};
  int i;
  for(i=0;i<k;i++){
    int c;
    scanf("%d",&c);
    d[c]=1;
  }
  while(!cond(n,d)) n++;
  printf("%d\n",n);
  return;
}

int main(void){
  run();
  return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << (b?"YES\n":"NO\n");}
void Yes(bool b) {cout << (b?"Yes\n":"No\n");}
void yes(bool b) {cout << (b?"yes\n":"no\n");}
void Yay(bool b) {cout << (b?"Yay!\n":":(\n");}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n;
	cin >> n;
	vll a(n),ans(n);
	rep(i,n){
		cin >> a[i];
		ans[0]+=(i%2==0?a[i]:-a[i]);
	}
	rep(i,n-1) ans[i+1]=2*a[i]-ans[i];
	for(auto&& e:ans) cout << e << " ";
	cout << "\n";
	return 0;
}


Measured memory_bytes: 2944
N, x = map(int, input().split())
a = list(map(int, input().split()))

Sum = 0
if a[0] - x > 0:
    Sum += a[0] - x
    a[0] = x
if a[N - 1] - x > 0:
    Sum += a[N - 1] - x
    a[N - 1] = x
for i in range(1, N):
    d = max(a[i] + a[i - 1] - x, 0)
    a[i] -= d
    Sum += d

print(Sum)



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

using namespace std;

int main() {
    int n, m, p, y, cont[100001] = { 0 };
    vector<string> ans(100001);
    pair<pair<int, int>, int> input[100001];

    cin >> n >> m;
    for (int i=0; i<m; i++) {
        cin >> p >> y;
        input[i] = make_pair(make_pair(y, p), i);
    }

    sort(input, input+m);

    for (int i=0; i<m; i++) {
        char id[15];
        sprintf(id, "%06d%06d", input[i].first.second, ++cont[input[i].first.second]);
        ans[input[i].second] = string(id);
    }

    for (int i=0; i<m; i++) {
        cout << ans[i] << endl;
    }


    return 0;
}

Measured memory_bytes: 8576
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    if(n % 1000 == 0) cout << 0;
    else cout << 1000 - n % 1000;
    cout << endl;
    return 0;
}

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

int main(){
    while(1){
        int w;
        cin >> w;
        if(w == -1) break;

        int ans = 1150;
        if(10 < w) ans += 125 * min(w - 10, 10);
        if(20 < w) ans += 140 * min(w - 20, 10);
        if(30 < w)  ans += 160 * (w - 30);

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

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>


int main(){

  int N,i,j,k,v;
  int *A;

 /* Using loop to check input numbers are in constrants or not */
  while(1){  
    scanf("%d", &N);
    if (N<1 && N>100) printf("error!\n");
    else break;
  }

  /* doing dynamic storange allocation */
  A=(int *)malloc(sizeof(int) * N);
 
 for(i=0 ; i<N ; i++){
    scanf("%d", &A[i]);
  }

 /* output the contents of A */
  for(i=0 ; i<N ; i++){
    printf("%d",A[i]); 
    if(i==N-1)printf("\n");
    else printf(" ");
  }

  /* doing insertion sort and output the machineries */
  for(i=1 ; i<=N-1 ; i++){
    v=A[i];
    j=i-1;
    while(j >= 0 && A[j] > v){
      A[j+1]=A[j];
	j--;
	A[j+1]=v;
    }

    for(k=0 ; k<N ; k++){
      printf("%d",A[k]);
      if(k==N-1)printf("\n");
      else printf(" ");
    }
  }
 
  return 0;
}



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

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

	bool can = false;

	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			if (i * j == n) can = true;
		}
	}

	if (can) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
    #include<vector>
    #include<string>
    #include<algorithm>
    #include<cmath>
    #include<random>
     
    //使い方がよくわからない
    #include<stack>
    #include<queue>
    #include<bitset>
    #include<sstream>
     
    #define rep(i,n) for(int i=0;i<(n);i++) 
    #define rep1(i,n) for(int i=1;i<(n);i++)
    #define co(x) cout << x << endl
    #define cosp(x) cout << x << " "
     
    using namespace std;
    using ll = long long;
     
    int main(int argc, const char *argv[]){
        ll n;
        cin >> n;
        ll ans = (n-1)/2;
        co(ans);
        return 0;
    }

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
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*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return ;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
const double pi=acos(-1.0);
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n=read();
	printf("%.10lf\n",pi*2*n);
	return 0;
}

Measured memory_bytes: 1728
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    public static void Main()
    {
        String[] input = Console.ReadLine().Split();
        int N = int.Parse(input[0]);
        int K = int.Parse(input[1]);
        long ans = 0;
        long min=0, max=0;
        for(int i = K; i <=N+1 ; i++)
        {
            if (i == K) {
                for (int j = 0; j < i; j++) { min += j; max += N - j; }
            }
            else
            {
                min += i - 1; max += N - i + 1;
            }
            ans += (max - min + 1) % (1000000000 + 7);
        }
        Console.WriteLine(ans%(1000000000+7));
    }
}

Measured memory_bytes: 27556
read n
read -a a
c=(`yes 0 | head -8`)
na=0
for x in ${a[@]}
do
    i=$((x/400))
    if((i<8))
    then
        c[$i]=1
    else
        na=$((na+1))
    fi
done
s=$((`echo ${c[@]} | tr ' ' '+'`))
echo $((s?s:1)) $((s+na))

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>>graph;
vector<int>visited(100005,0),ans(100005,0);
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	cin>>n>>m;
	graph.assign(n+1,vector<int>());
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	queue<int>q;
	q.push(1);
	visited[1]=1;
	while(!q.empty()){
		int tp = q.front();
		q.pop();
		for(auto i:graph[tp]){
			if(!visited[i]){
			visited[i]=1;
			ans[i] = tp;
			q.push(i);
			}
		}
	}
	for(int i=1;i<=n;i++){
		if(!visited[i]){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	for(int i=2;i<=n;i++) cout<<ans[i]<<endl;
}


Measured memory_bytes: 10708
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:256000000")
#include<utility>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head
#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

// belik's shit
ll const mod = 1e9 + 7;
namespace {
	ll mult(ll& a, ll& b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) {
			val += mod;
		}
		if (val >= mod) {
			val -= mod;
		}
		return val;
	}
	ll poww(ll a, ll b)
	{
		ll val = 1;
		a %= mod;
		while (b > 0){
			if (b % 2) val = mult(a, val);
			a = mult(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 5e5 + 5;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n, a, b; cin >> n >> a >> b;
	cout << min(n * a, b);


	return 0;
}
/*

*/

Measured memory_bytes: 256
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    ans = []
    for i in range(k, n):
        if a[i] > a[i-k]:
            ans.append("Yes")
        else:
            ans.append("No")
    for s in ans:
        print(s)

if __name__ == "__main__":
    main()

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

int main(){
    ll n;
    cin>>n;
    ll A[n];
    for(ll i = 1; i <= n; i++){
        cin>>A[i];
    }
    ll dp[n+1];
    dp[0] = 0;
    dp[1] = 0;
    for(ll i = 2; i <= n; i++){
        if(i > 2)
        dp[i] = min(dp[i-1] + abs(A[i]-A[i-1]),
                    dp[i-2] + abs(A[i]-A[i-2]));
        else
            dp[i] = dp[i-1] + abs(A[i]-A[i-1]);
    }
    cout<<dp[n];
    return 0;
}




//freopen("input.in","r",stdin);
//freopen("output.out","w",stdout);
//ios::sync_with_stdio(0);cin.tie(0);


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

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

	if (n >= 10) {
		cout << r << endl;
	}
	else {
		int b = 100 * (10 - n);
		cout << r+ b << endl;
	}
	

	return 0;
}

Measured memory_bytes: 256
N=gets.to_i
a = case N%4
when 0,2
  [N/2, N, N]
when 1
  a=4r/N
  (N/4+1).upto(3500){|i|
    b=a-1r/i
    i.upto(3500){|j|
      c=b-1r/j
      if c.numerator==1
        puts [i, j, c.denominator] * ?\s
        exit
      end
    }
  }
when 3
  g=N/4+1
  [g, N*g+1, N*g*(N*g+1)]
end
puts a * ?\s


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

using namespace std;

typedef long long  ll;

bool BinarySearch(const vector<int> &s, int x)
{
    int l = 0, r = s.size();

    while (l < r) {
        int mid = (l + r) * 0.5;

        if (x == s[mid])
            return true;

        if (x < s[mid])
            r = mid;
        else
            l = mid + 1;
    }

    return false;
}

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

    int n, q, t, ans = 0;

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

    cin >> q;
    for (int i = 0; i < q; ++i) {
        cin >> t;
        if (BinarySearch(s, t))
            ++ans;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1524
#include<stdio.h>
#include<math.h>
int main(void)
{
	int n,a,s,w,i,x,c;
	while(scanf("%d %d",&n,&a)!=EOF)  {
//		c=0;
		w=n+a;	
		for(i=0;w!=0;i++){		
			w=w/10;
//			c++;	
		}
		printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 1028
import sys

table = [0]*26
 
letters = "abcdefghijklmnopqrstuvwxyz"

sentence = sys.stdin.read()


for A in sentence:
    index = int(0)
    
    for B in letters:

        if A == B or A == B.upper():
            table[index]  += 1
            break
        index += 1


for i in range(len(letters)):

    print("%s : %d" %( letters[i], table[i]) )

    



Measured memory_bytes: 5564
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

//vector//
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

typedef pair<int,int> P;  //q(p.first,p.second)

const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000

int main (){
    int h, w ,k; cin >> h >> w >> k;
    vector<string> c(h);
    for(int i=0; i<h; i++){
        cin >> c[i];
    }

    int ans = 0;
    // bit全探索
    for(int bit_h=0; bit_h < (1<<h); bit_h++){
        for(int bit_w=0; bit_w < (1<<w); bit_w++){
            int kk=0;
            for(int i=0; i<h; i++){
                for(int j=0; j<w; j++){
                    if(!(bit_h & (1<<i)) && !(bit_w & (1<<j))){
                        if(c[i][j] == '#'){
                            kk++;
                        }
                    }
                }
            }
            if(kk==k) ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 3600
h, w = map(int, input().split())
if h%3 == 0 or w%3 == 0:
    print(0)
else:
    m = 100000000000
    for i in range(1, h):
        if m > max([i*w, (h-i)*(w//2), (h-i)*(w-(w//2))]) - min([i*w, (h-i)*(w//2), (h-i)*(w-(w//2))]):
            m = max([i*w, (h-i)*(w//2), (h-i)*(w-(w//2))]) - min([i*w, (h-i)*(w//2), (h-i)*(w-(w//2))])
    for i in range(1, w):
        if m > max([i*h, (w-i)*(h//2), (w-i)*(h-(h//2))]) - min([i*h, (w-i)*(h//2), (w-i)*(h-(h//2))]):
            m = max([i*h, (w-i)*(h//2), (w-i)*(h-(h//2))]) - min([i*h, (w-i)*(h//2), (w-i)*(h-(h//2))])
    if m > max([w//3, (w-(w//3))//2, w-w//3-(w-(w//3))//2])*h - min([w//3, (w-(w//3))//2, w-w//3-(w-(w//3))//2])*h:
        m = max([w//3, (w-(w//3))//2, w-w//3-(w-(w//3))//2])*h - min([w//3, (w-(w//3))//2, w-w//3-(w-(w//3))//2])*h
    if m > max([h//3, (h-(h//3))//2, h-h//3-(h-(h//3))//2])*w - min([h//3, (h-(h//3))//2, h-h//3-(h-(h//3))//2])*w:
        m = max([h//3, (h-(h//3))//2, h-h//3-(h-(h//3))//2])*w - min([h//3, (h-(h//3))//2, h-h//3-(h-(h//3))//2])*w
    print(m)


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

using namespace std;

string to_s(int m) {
    char buf[256];
    sprintf(buf, "%d:%02d", m / 60, m % 60);
    return string(buf);
}

ostream& operator<<(ostream& os, vector<string> ss) {
    os << ss[0];
    for (int i = 1; i < ss.size(); i++) {
        os << ' ' << ss[i];
    }
    return os;
}

#define uniq(xs) (xs.erase(unique(xs.begin(), xs.end()), xs.end()))

int main() {
    int N, M;
    vector<int> T;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int h, m; cin >> h >> m;
        T.push_back(h * 60 + m);
    }
    cin >> M;
    for (int i = 0; i < M; i++) {
        int h, m; cin >> h >> m;
        T.push_back(h * 60 + m);
    }
    sort(T.begin(), T.end());
    uniq(T);
    vector<string> A;
    for (int i = 0; i < T.size(); i++) {
        A.push_back(to_s(T[i]));
    }
    cout << A << endl;
    return 0;
}

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

int main() {
	string s; cin >> s;
	int n = s.size();

	for (int i = 0; i < n; i++) {
		s.erase(s.begin() + s.size() - 1);
		if (s.size() % 2 != 0)continue;
		if (s.substr(0, s.size() / 2) == s.substr(s.size() / 2, s.size() / 2)) {
			cout << s.size(); return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }

int main()
{
//    freopen("in.txt","r", stdin);
//    freopen("output.txt", "w", stdout);
//    cout << fixed << setprecision(10);
    ios_base::sync_with_stdio(false);

    int res = 0;
    int n;
    cin >> n;
    while (n--)
    {
        int a;
        cin >> a;
        while (a % 2 == 0)
        {
            ++res;
            a >>= 1;
        }
    }
    cout << res << endl;
}


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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

using namespace std;
#define ll  long long
#define PI  acos(-1)
#define pb  push_back
#define ins insert
#define INF 5000000000000000007 //1e18+7
#define mk  make_pair
#define ff  first
#define ss  second
#define endl "\n"
#define max3(x,y,z)  max(x,max(y,z))
#define min3(x,y,z)  min(x,min(y,z))
#define sz(a) (ll)a.size()
#define double long double
#define coud(a,b) cout << fixed << setprecision((b)) << (a)
#define mset(x,y)  memset(x,y,sizeof(x))
#define all(x)   (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bp(n)  __builtin_popcountll(n)
#define mxt(a)  *(max_element(a.begin(),a.end()))
#define mnt(a)  *(min_element(a.begin(),a.end()))
#define unique_sort(c) (sort(all(c)), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define rep(i,a,b) for(ll i=(a);i<=(b);++i)
#define trav(a, x)    for(auto &a : x)

const double eps=1e-7;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int d8x[8]={+1, +1, +1, 0, 0, -1, -1, -1};
int d8y[8]={+1, 0, -1, +1, -1, +1, 0, -1};
int d4x[4]={1, 0, 0, -1};
int d4y[4]={0, -1, 1, 0};
ll power(ll x,ll y){ll ans=1;x=x;while(y>0){if(y&1)ans=(ans*x);y=y>>1;x=(x*x);}return ans;}
ll sqr(ll x) { return x * x;}

template <typename T> T gcd(T a,T b){ if(a==0) return b; return gcd(b%a,a); }
template <class T> inline void chmax(T &x,T y){ x = max((x), (y));}
template <class T> inline void chmin(T &x,T y){ x = min((x), (y));}
template <class T> T abs(T x) { return x>0 ? x : -x;}
template <typename T> T powm(T a,T b, ll m){T cnt=1; while(b>0) { if(b%2==1) cnt=(cnt*a)%m; b/=2; a=(a*a)%m; }return cnt%m;}
typedef pair<int,int>  pii;
typedef pair<ll,ll>  pll;
typedef vector<pll>  vpll;
typedef vector<pii>  vpii;
typedef vector<ll>   vll;
typedef vector<int>  vii;
#define minpq priority_queue<T,vector<T>,greater<T> >;
// #define T int
// #define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
//*X.find_by_order(k) returns the kth largest element (0-based).
//X.order_of_key(val) returns the no. of values less than val.
ll ncr(ll n,ll r) {ll ans=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){ans*=(n-i);ans/=(i+1);}return ans;}
const int MOD = 1000000007;   
const int N = 200010;

struct compare{
    bool operator() (const int &a,const int &b) const {
        return a>b;
    }
};
// 🎲

int32_t main() {
  cin.sync_with_stdio(0);cin.tie(0);
  cin.exceptions(cin.failbit);
  
 ll x,k,d;
 cin >> x >> k >> d;
 ll X = abs(x);
 ll rem = X/d;
 if (rem > k) {
   cout << abs(X - k*d);
 } else {
   X = X%d;
   k -= rem;
   if(k%2 == 1) {
     X -= d;
   }
   cout << abs(X);
 }
 return 0; 
}

/* 
    stuff you shoulds look for
    * int overflow,array bounds.
    * special cases (n=1?).
    * N,MOD value.
*/

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

/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

using namespace std;

typedef long long ll;

const int NM_MAX = 8;

int n, m, k;

bool ma[NM_MAX][NM_MAX];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m >> k;
    for(int i = 1; i <= n; i++)
    {
        string s;
        cin >> s;
        for(int j = 1; j <= m; j++)
            ma[i][j] = (s[j - 1] == '#');
    }
    int ans = 0;
    for(int mask1 = 0; mask1 < (1 << n); mask1++)
        for(int mask2 = 0; mask2 < (1 << m); mask2++)
        {
            int cnt = 0;
            for(int i = 1; i <= n; i++)
                for(int j = 1; j <= m; j++)
                    if(ma[i][j] == true && ((mask1 >> (i - 1)) & 1) == 0 && ((mask2 >> (j - 1)) & 1) == 0)
                        cnt++;
            if(cnt == k)
                ans++;
        }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

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

    int A[N];
    for(int i=0; i<N; i++){
        cin >> A[i];
        A[i]--;
    }

    int now = 0;
    int ls = -1;
    map<int, int> m;
    int tc = 0;
    for(int i=0; i<N; i++){
        if(m.count(now) == 0) m[now] = 1;
        else m[now]++;
        if(m[now] == 2){
            ls = now;
            break;
        }
        if(i == K){
            cout << now+1 << endl;
            return 0;
        }
        now = A[now];
        tc++;
    }

    now = ls;
    vector<int> loop;
    do{
        loop.push_back(now);
        now = A[now];
    }while(ls != now);
    int cnt = loop.size();

    K = K - tc;
    ll pos = K%cnt;
    cout << loop[pos]+1 << endl;

    return 0;
}


Measured memory_bytes: 12536
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main(){
	fast;
	ll a,b; cin>>a>>b;
	string s="";
	s+=to_string(a);
	s+=to_string(b);
	(s.size()==2)?cout<<a*b:cout<<"-1";
	cout<<'\n';
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#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()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	rep(i,n)in[i]--;
	int co=0;
	rep(i,n)if(i==in[in[i]])co++;
	cout<<co/2<<endl;
}





Measured memory_bytes: 640
# -*- coding:utf-8 -*-
if __name__ == "__main__":
    import sys
    dp = [0.0] * 100001
    dp[1] = 1.0
    for i in xrange(2, 100001):
        p = 1.0
        w = 0.5
        for j in xrange(1,i):
            if p < 1e-13:
                break
            dp[i] += (p*(1-w))*(j+dp[max(0,i-j-1)])
            p *= w
            w *= 0.5
        dp[i] += i*p
    while True:
        N = int(raw_input())
        if N == 0:
            sys.exit()
        print "%.8f" % dp[N]

Measured memory_bytes: 9124
# アルゴリズムを思いつけなかった！

n = int(input())
l = [int(x) for x in input().split()]

for i in range(n-1)[::-1]: #右からループ
    if l[i] - 1 == l[i+1]:# 右より1大きい場合にのみ
        l[i] = l[i] - 1 # 1引く
    else:
        continue

a = 0
for j in range(1, n):
    if l[j-1] <= l[j]:
        continue
    else:
        print('No')
        break
else: # forをbreakすることなく完了した場合に稼働
    print('Yes')


Measured memory_bytes: 14396
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7;

int main() {
  int n,m; cin>>n>>m;
  vector<bool> isStairBroken(n+10,false);
  for(int i=0;i<m;i++) {
    int t; cin>>t;
    isStairBroken[t] = true;
  }
  vector<ll> dp(n+10,0);
  dp[0]=1;
  // 1つ前が壊れてない + 2つ前が壊れてない  dp[i] = dp[i-1]+dp[i-2]
  // 1つ前が壊れてない + 2つ前が壊れてる    dp[i] = dp[i-1]
  // 1つ前が壊れてる + 2つ前が壊れてない dp[i] = dp[i-2]
  for(int i=0;i<=n-1;i++) {
    // チェックする階段が壊れていない
    if(!isStairBroken[i]) {
      // 1段目ok 2段目ok
      if(!isStairBroken[i+1]) (dp[i+1]+=dp[i])%=MOD;
      if(!isStairBroken[i+2]) (dp[i+2]+=dp[i])%=MOD;
    }
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 3952
let () =
    let extgcd x y =
        let rec eg r0 r1 a0 a1 b0 b1 =
            if r1 = 0 then a0 else
                let q1 = r0 / r1 in
                eg r1 (r0 mod r1) a1 (a0 - q1 * a1) b1 (b0 - q1 * b1)
        in
        eg x y 1 0 0 1
    in
    let inv x y = (* 1/x in mod y *)
        let c = extgcd x y in
        if c < 0 then c + y else c
    in
    let z = 1_000_000_000 + 7 in
    (*
    let () =
        for i = 0 to z - 1 do
            let c = inv i z in
            if c < 0 then Printf.printf "%d %d!!\n%!" i c
        done
    in
    *)
    let ( *@) a b = ((a mod z) * (b mod z)) mod z in
    let binomial a b =
        let rec loop i j acc =
            if j > b then acc else
                let acc = acc *@ i *@ inv j z in
                loop (i - 1) (j + 1) acc
        in
        loop a 1 1
    in
    let main () =
        let x, y = Scanf.sscanf (read_line ()) "%d %d" (fun x y -> x, y) in
        let ans = if (2*y - x) mod 3 <> 0 ||
           (2*x - y) mod 3 <> 0 then 0 else (
               let m = (2 * y - x) / 3 in
               let n = (2 * x - y) / 3 in
               if m < 0 || n < 0 then 0 else
                binomial (m + n) m
        )
        in
        Printf.printf "%d\n" ans
    in
    main ()

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <functional>


using namespace std;

int main() {
  long long  n,q;
  cin>>n;
  vector<long long> b(n);
  map<long long ,long long > ma;
  long long  ans=0;
  for(int i=0;i<n;i++){
    long long  s;
    cin>>s;
    b[i] = s;
    ma[s]++;
    ans+=s;
  }
  cin>>q;

  long long  B,C;
  for(int i=0;i<q;i++){
    cin>>B>>C;
    decltype(ma)::iterator it = ma.find(B);
    if (it != ma.end()){ // 見つかった
    long long  tem = C-B;
    ans = ans + ma[B]*tem;
    ma[C] += ma[B];
    ma[B] = 0;
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 8848
#include <stdio.h>
#include <stdlib.h>
#include "time.h"
#include "unistd.h"
#include "string.h"
#include <math.h>
int ans;
int main(int argc, char* argv[]){
  long int a,b,c;
  scanf("%ld %ld",&a,&b);
  if (a-b>=0) {
    printf("%d\n",a-b);
  }else{
    printf("0");
  }
}


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

int main()
{
    string s;
    cin >> s;
    if (s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi")
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

vb seen;
Graph g;

int main() {
    int h, w;
    cin >> h >> w;
    vs s(h);
    rep(i, h) cin >> s[i];

    queue<P> q;
    vvi dist(h, vi(w, -1));
    auto update = [&](int i, int j, int x) {
        if(dist[i][j] != -1) return;
        dist[i][j] = x;
        s[i][j] = '#';
        q.push(P(i, j));
    };

    rep(i, h) rep(j, w) if(s[i][j] == '#') update(i, j, 0); 

    while(!q.empty()) {
        int y = q.front().first, x = q.front().second;
        q.pop();

        rep(i, 4) {
            int ny = y + dy[i], nx = x + dx[i];

            if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
            if(s[ny][nx] == '#') continue;

            update(ny, nx, dist[y][x] + 1);
        }
    }

    int ans = 0;
    rep(i, h) rep(j, w) ans = max(ans, dist[i][j]); 

    cout << ans << endl;

    return 0;
}

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

string s;
int ans, N, W, S, E;

int main()
{
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'N'){
            N++;
        }
        else if(s[i] == 'W'){
            W++;
        }
        else if(s[i] == 'S'){
            S++;
        }
        else if(s[i] == 'E'){
            E++;
        }
    }
    if(N > 0 && S > 0 && W + E == 0){
        printf("Yes\n");
        return 0;
    }
    else if(W > 0 && E > 0 && N + S == 0){
        printf("Yes\n");
        return 0;
    }
    else if(W > 0 && E > 0 && S > 0 && N > 0){
        printf("Yes\n");
        return 0;
    }
    printf("No\n");



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define sz(s) (int)s.size()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e5+10;
const ll INF = 1e18;

ll power(ll x,ll y){
	ll t=1;
	while(y>0){
		if(y%2) y-=1,t=t*x%mod;
		else y/=2,x=x*x%mod;
	}
return t;
}

int pres[N];

int main(){
	int n,ans=0,x,e=0,o=0;
	scanf("%d",&n);
	REP(i,n) {scanf("%d",&x); pres[x]++;}
	REP(i,N) if (pres[i]) {if (pres[i]%2) {pres[i]%=2; o++;} else {pres[i]=2; e++;}}
	if (e%2) o--;
	printf("%d\n",e+o);
	return 0;
}

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

int main()
{
    int n, d, x;
    int i, ans = 0, key;
    
    cin >> n >> d >> x;
    
    int a[n];
    
    for(i = 0; i < n; i++) {
        cin >> a[i];
        
        ans++;
        key = a[i];
        while(key+1 <= d) {
            ans++;
            key += a[i];
        }
    }
    
    cout << ans+x << endl;
    
    return 0;
}


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

using namespace std;

int main() {
    
	int n;
	int h[20];
	int max = 0;
	int ans = 0;

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

	for (int i = 0; i < n; i++) {
		if (h[i] >= max) {
			ans++;
			max = h[i];
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
INF = 10 ** 18

def solve():
    for i in range(N):
        if A[i] == 0:
            print(0)
            return
        
    ans = 1
        
    for i in range(N):
        ans *= A[i]
        if ans > INF:
            print("-1")
            return
    print(int(ans))
        
solve()

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



int main()
{
    ll n,k,x=INT_MAX;
    cin>>n;
    ll l1[n+1],l2[n+1];l2[0]=0;
    for(int i=1;i<=n;i++){
        cin>>l1[i];
        l2[i]=l2[i-1]+l1[i];
    }
    for(int i=1;i<=n-1;i++){
        //for(int j=i+1;j<=n;j++){
            x=min(x,abs(l2[i]-(l2[n]-l2[i])));
            //cout<<l2[i]<<" "<<(l2[j]-l2[i])<<endl;
        //}
    }
    cout<<x;

    return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);


using ll = long long;
using pint = pair<int, int>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

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; }
template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){

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

    vector<ll> x(n), y(n);
    vector<ll> xx(n), yy(n);

    rep(i, n){
        cin >> x[i] >> y[i];
    }
    xx = x; yy = y;
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    ll ans = (x[n-1]-x[0])*(y[n-1]-y[0]);

    for(int x1 = 0; x1 < n; ++x1){
        for(int x2 = x1+1; x2 < n; ++x2){
            for(int y1 = 0; y1 < n; ++y1){
                for(int y2 = y1+1; y2 < n; ++y2){
                    int cnt = 0;
                    rep(i, n){
                        if(x[x1] <= xx[i] and xx[i] <= x[x2] and y[y1] <= yy[i] and yy[i] <= y[y2]) ++cnt;
                    }
                    if(cnt >= k) ans = min(ans, (x[x2]-x[x1])*(y[y2]-y[y1]));
                }
            }
        }
    }

    ppp(ans);







    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int n, m;
vector<int > a, b;
vector<bool > check;
void dfs(int x0, int j){
  ////////////
  bool flag = true;
  REP(i, n){
    if(!check[i]){
      flag = false;
      break;
    }
  }
  if(flag){
    return;
  }
  ////////////
  REP(i, m){
    if(i != j && a[i] - 1 == x0 && !check[b[i] - 1]){
      // cout << x0 << " " << b[i] - 1 << endl;
      check[b[i] - 1] = true;
      dfs(b[i] - 1, j);
    }else if(i != j && b[i] - 1 == x0 && !check[a[i] - 1]){
      // cout << x0 << " " << a[i] - 1 << endl;
      check[a[i] - 1] = true;
      dfs(a[i] - 1, j);
    }
  }
}
int main()
{
  cin >> n>> m;
  a.resize(m);
  b.resize(m);
  REP(i,m){
    cin >> a[i] >> b[i];
  }
  check.resize(n);
  int ans = 0;
  REP(i,m){
    ///initialize check///
    REP(j,n){
      check[j] = false;
    }
    ///initialize check///

    /// check 0 ///
    check[0] = true;
    /// check 0 ///
    // cout << "dfs: i = " << i << ",  (a,b) = " << a[i] << " " << b[i] << endl;
    dfs(0, i);

    bool ok = true;
    REP(j,n){
      if(!check[j]){
	ok = false;
	break;
      }
    }
    if(!ok){
      ans ++;
    }
  }
  cout << ans << endl;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

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

ll N, M, S[100], C[100];
ll mk[100];
ll i, j, k;

ll calc(ll ii,ll ans){
    if(ii==N){
        return ans;
    }
    ll i = 0;
    if(mk[ii]!=-1){
        return calc(ii + 1, ans * 10 + mk[ii]);
    }
    if(ii==0)
        return calc(ii + 1, 1);
    return calc(ii + 1, ans * 10);
}
int main(){
    scanf("%lld%lld", &N, &M);
    ll flg = 0;
    fornum(i,0,N+1){
        mk[i] = -1;
    }
    fornum(i,0,M){
        scanf("%lld%lld", &S[i], &C[i]);
        if(mk[S[i]-1]!=-1&&mk[S[i]-1]!=C[i]){
            flg = 1;
        }
        mk[S[i] - 1] = C[i];
        if(N>1&&S[i]==1&&C[i]==0){
            flg = 1;
        }
    }
    if(flg){
        printf("-1");
        return 0;
    }
    if(N==1){
        if(mk[0]==-1){
            printf("0");
        }else{
            printf("%lld", mk[0]);
        }
        return 0;
    }
    printf("%lld", calc(0, 0));
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define pp pair<ll,ll>
#define maxn 100005
#define db double
#define mod 998244353
using namespace std;
void solve()
{
	db x;
	cin >> x;
	x = x*x*x;
	x = x/(db)27;
	cout << x ;
}
int main()
{
	ll t=1,i=1;
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
    std::cout.precision(10);
    std::cout.setf( std::ios::fixed, std:: ios::floatfield ); 
	//cin >> t;
	//cin >> n;
	while(i<=t)
	{
		solve();
		i++;
	}
	return 0;
}

Measured memory_bytes: 256
n,m,l = map(int,input().split())
a = [[0 for i in range(m)] for j in range(n)]
b = [[0 for i in range(l)] for j in range(m)]
i = 0
while i < n:
    a[i] = list(map(int,input().split()))
    i+=1

i = 0
while i < m:
    b[i] = list(map(int,input().split()))
    i+=1

for i in range(n):
    for j in range(l):
        res = 0
        for k in range(m):
            res = res + a[i][k] * b[k][j]
        if j == l-1:
            print(f"{res}",end="")
        else:
            print(f"{res} ",end="")
        #print(f"{a[0][0] * b[0][j] + a[0][1] * b[1][j]} ",end="")
    print()



Measured memory_bytes: 6596
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define int long long
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;

#ifndef LOCAL
#pragma GCC optimize ("O2")
#define endl '\n'
#endif

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

ll pwr(ll a,ll b, ll mod){
    a %= mod;
    int ans = 1;
    while(b){
        if(b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int N = (1 << 18);
const int LOGN = 20;
int dp[LOGN][N], dp1[LOGN][N];
void solve(){
	int n;
	cin >> n;
	int tot = (1 << n);
	fr(i, 0, tot - 1){
		int x;
		cin >> x;
		dp1[0][i] = x;
	}
	fr(k, 1, n){
		fr(mask, 0, tot - 1){
			dp1[k][mask] = dp1[k - 1][mask];
			dp[k][mask] = dp[k - 1][mask];
			if(mask & (1 << (k - 1))){
				dp1[k][mask] = max(dp1[k][mask], dp1[k - 1][mask ^ (1 << (k - 1))]);
				dp[k][mask] = max(dp[k][mask], dp1[k - 1][mask] + dp1[k - 1][mask ^ (1 << (k - 1))]);
			}
		}
	}
	int maxi = 0;
	fr(i, 1, tot - 1){
		maxi = max(maxi, dp[n][i]);
		cout << maxi << endl;
	}
}
signed main(){
    IO;
    #ifdef LOCAL
        freopen("inp.txt","r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    cout << setprecision(10) << fixed;
    int t = 1;
    // cin >> t;
    fr(tt, 1, t){
        solve();
    }
    return 0;
}

Measured memory_bytes: 82944