akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;
bool check(int x) {
    int k = x % 10;
    while (x > 0) {
        if (k != x % 10) return false;
        x /= 10;
    }
    return true;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    rep(i, n, 1000) {
        if (check(i)) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <numeric>
#include <iostream>
#include <array>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <math.h> 
#include <set>
#include <map>
#include <utility>
#include <deque>
#include <queue>


using namespace std;

#define ll long long int
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repp(i, n) for(ll i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define all(a)  (a).begin(),(a).end()
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const ll MOD = 1e9 + 7;
vi alphabet = { 'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z' };


int main() {
    ll n;
    cin >> n;
    vll a(n);
    ll sa = 0;
    rep(i, n) cin >> a[i];
    rep(i, n) {
        if (a[i] < 0)sa++;
    }
    ll sum = 0;
    rep(i, n) a[i] = abs(a[i]);
    rep(i, n) sum += a[i];
    if (sa % 2 == 0) cout << sum << endl;
    else {
        sort(a);
        cout << sum - 2*a[0] << endl;
    }
}

Measured memory_bytes: 1024
N, M = map(int,input().split())
An = list(map(int,input().split()))

flag = [0]*N
sumAn = sum(An)
threshold = sumAn/(4*M)
for i, A in enumerate(An):
  if A >= threshold: flag[i] = 1

print("Yes" if sum(flag) >= M else "No")  


Measured memory_bytes: 2940
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a >= 0 && b > 0 || a < 0 && b <= 0 || a == 0 && b == 0){
            if(a <= b){
                System.out.println(b-a);
            }else{
                System.out.println(a-b+2);
            }
        }else{
            System.out.println(Math.abs(Math.abs(b)-Math.abs(a))+1);
        }
    }
}


Measured memory_bytes: 21844
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();
        int[] eSum = new int[n + 1];
        for (int i = 0; i < n; i++)
            eSum[i + 1] = eSum[i] + (s[i] == 'W' ? 1 : 0);
        int[] wSum = new int[n + 1];
        for (int i = n - 1; i >= 0; i--)
            wSum[i] = wSum[i + 1] + (s[i] == 'E' ? 1 : 0);
        Console.WriteLine(wSum.Skip(1).Zip(eSum, (x, y) => x + y).Min());
    }
}


Measured memory_bytes: 14560
#include <stdio.h>
 
char prime[10000001];
 
void SetPrime(int max) {
	int i, j;
    
	for (i = 4; i <= max; i += 2){
    	prime[i] = 1;
    }
    
    for (i = 3; i * i <= max; i += 2){
        if (prime[i] == 0){
            for (j = i * 2; j <= max; j += i){
                prime[j] = 1;
            }
        }
    }
    
}
 
int main(void)
{
    long n;
     
    SetPrime(10000000);
    while (scanf("%ld", &n) * n != 0){
        long i;
        if(n%2==0) n--; 
         
        for (i = n; i >= 10; i-=2){
            if (prime[i] + prime[i - 2] + prime[i - 6] + prime[i - 8] == 0){
                printf("%ld\n", i);
                break;
            }
        }
    }
     
    return 0;
}

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

	public static void main(String[] args) {
		 String result = new Scanner(System.in).next();
		 if(result.equals("ARC")) {
			 result = "ABC";
		 }
		 else {
			 result = "ARC";
		 }
		 System.out.println(result);
		 
	}

}


Measured memory_bytes: 35684
#include<stdio.h>

int main(void)
{
	int a;
	int b;
	int c;
	
	for(a=1;a<10;a++)
	{
		for(b=1;b<10;b++)
		{
			c=a*b;
			printf("%dx%d=%d\n",a,b,c);
		}
	}
	
	
		
	
	return 0;
}
		
		
	

Measured memory_bytes: 524
#include <stdio.h>
#define N 100000

int a (int key);

int n;
int s[N];
int main() {

  int key, c = 0;
  int i, q;

  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d", &s[i]);
  }
  scanf("%d", &q);
  for(i=0;i<q;i++){
    scanf("%d", &key);
    if(a(key) == 1) c++;
  }
  printf("%d\n", c);
  return 0;
}

int a (int key) {
  int l = 0, r = n, mid;
  while(l<r){
    mid =(l+r)/2;
    if(key == s[mid]) return 1;
    if(key > s[mid]) l = mid+1;
    else if(key < s[mid]) r = mid;
  }
  return 0;
}

Measured memory_bytes: 988
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 入力値保持
		int h1 = sc.nextInt();
		int m1 = sc.nextInt();
		int h2 = sc.nextInt();
		int m2 = sc.nextInt();
		int k = sc.nextInt();
		int ans = 0;

		// 開始時間帯計算
		ans = (h2 * 60 + m2) - (h1 * 60 + m1) - k;

		// 結果出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 35764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int maxn = 1e5 + 5;
const int mod = 998244353;
int a[1<<18],m1[1<<18],m2[1<<18];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int N = (1<<n);
    memset(m2,0xc4,sizeof(m2));
    f(N) {
        cin >> a[i];
        m1[i] = a[i];
    }
    f(n) {
        fr(j,0,N) {
            if (j & (1<<i)) {
                int k = (j ^ (1<<i));
                if (m1[k] > m1[j]) {
                    m2[j] = max({m2[j],m1[j],m2[k]}),m1[j] = m1[k];
                }
                else {
                    m2[j] = max({m2[j],m1[k],m2[k]});
                }
            }
        }
    }
    int ans = 0;
    f1(N-1) {
        ans = max(ans,m1[i] + m2[i]);
        cout << ans << '\n';
    }
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned long;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

    void Solve() {
        UL Q; cin >> Q;
        deque<int> A;
        rep(i, Q) {
            UL c; cin >> c;
            if (c == 0) {
                UL d, x; cin >> d >> x;
                if (d == 0) A.push_front(x);
                else if (d == 1) A.push_back(x);
            }
            else if (c == 1) {
                UL p; cin >> p; cout << A[p] << endl;
            }
            else if (c == 2) {
                UL d; cin >> d;
                if (d == 0) A.pop_front();
                else if (d == 1) A.pop_back();
            }
        }
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    cout << fixed << setprecision(10);
    p->Solve();
    return 0;
}



Measured memory_bytes: 4672
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> Vint;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


ll solve(ll n, ll x){
  if(n < x)swap(n, x);
  if(n % x == 0)return x * (2 * n / x - 1);
  ll res = 0, q = n / x;
  ll r = n - x * q;
  res = q * x * 2;
  return res + solve(x, r);
}

signed main(void){
  int i, j, k;
  for(int testcase = 0;testcase >= 0;testcase++){
    ll n, x;
    cin >> n >> x;
    pri(n + solve(n - x, x));

/*/

//*/ break;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s, t;
    cin >> s >> t;
    int slen = s.length(), tlen = t.length();

    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<int>());

    bool flg = false;
     int min = 0;

    if(slen > tlen) {
        min = tlen;
        }else{ 
            min = slen;
        }

    for (int i = 0; i < min; i++) {
        if (s.at(i) < t.at(i)) {
            flg = true;
            break;
        }else if(s.at(i) > t.at(i)) {
            break;
        }

        if(i == min-1) {
            if(s.at(i) < t.at(i)) {
                flg = true;
                break;
            }
            if(s.at(i) > t.at(i)) {
                break;
            }
            else {
                if(slen < tlen) {
                    flg = true;
                    break;
                }
            }
        }
    }

    if (flg) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use proconio::fastout;
use proconio::input;
//use proconio::marker::*;
//use std::collections::HashSet;
// use std::cmp::*;
//use std::collections::VecDeque;

fn main() {
    input! {
       X:i32,Y:i32
    }

    println!("{}", X + Y / 2);
}


Measured memory_bytes: 2124
#include <iostream>
using namespace std;
int main()
{
  int H, W;
  cin >> H >> W;
  string S[H][W];
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
      cin >> S[i][j];
  }
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      if (S[i][j] == "snuke")
      {
        cout << (char)(j + 'A') << i + 1 << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "RRS" ].solve == 2 );
	assert( [ "SSS" ].solve == 0 );
	assert( [ "RSR" ].solve == 1 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	
	auto ans = 0L;
	foreach( c; s.group )
	{
		if( c[ 0 ] == 'R' ) ans = max( ans, c[ 1 ] );
	}
	return ans;
}


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

int main() {
  string S, T;
  cin >> S >> T;
  int ans = 2000;
  for (int i = 0; i <= S.length() - T.length(); i++) {
      int tmp = 0;
      for (int j = 0; j < T.length(); j++) {
          tmp += (S[i+j] != T[j]);
      }
      ans = min(ans, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll A,B;
  cin>>A>>B;
  A-=2*B;
  if(A>0) {
cout<<A<<endl;
  }
else {
cout<<0<<endl;
}
}
  

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
string s;
ll dp[100005][5];
int main(){
    cin>>s;
    memset(dp,0,sizeof dp);
    ll ans=0;
    for(int a=s.length();a>=0;a--){
        for(int b=3;b>=0;b--){
            if(a==s.length()){
                if(b==3) dp[a][b]=1;
                else dp[a][b]=0;
            }
            else{
                if(s[a]=='?') dp[a][b]=dp[a+1][b]*3;
                else dp[a][b]=dp[a+1][b];
                if(b<3&&s[a]=='?'||s[a]==('A'+b)) dp[a][b]+=dp[a+1][b+1];
            }
            dp[a][b]%=mod;
        }
    }
    printf("%lld\n",dp[0][0]);
}


Measured memory_bytes: 4352
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int a, b, c;
	cin >> a >>b >> c;
	int t = c - a - b;

	if (t>0&&4*a*b<t*t)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;

  while (k >= 0) {
    k--;
    if (c > b && b > a) {
      cout << "Yes";
      goto end;
    }
    if (b <= a) {
      b *= 2;
      continue;
    } else if (c <= b) {
      c *= 2;
      continue;
    }
  }
  // cout << a << b << c;
  cout << "No";
end:
  return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include <string>
#include <cstdlib> //絶対値利用のため
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)

//const int INF = INT_MAX / 2;

int main() {
	int n;
	int v[20], c[20];
	int cnt = 0;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> v[i];
	for (int i = 0; i < n; i++) cin >> c[i];
	for (int i = 0; i < n; i++) {
		if (v[i] > c[i]) cnt += v[i] - c[i];

	}


	cout << cnt << endl;


	return 0;
}

Measured memory_bytes: 256
S=input()
T=input()
d=[[] for i in range(26)]
for i,c in enumerate(S):
    d[ord(c)-ord('a')].append(i)
d2=[[]for i in range(26)]
for i,c in enumerate(T):
    d2[ord(c)-ord('a')].append(i)
print(['No','Yes'][set((tuple(x) for x in d))==set((tuple(x) for x in d2))])

Measured memory_bytes: 29680
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>

using namespace std;
 
typedef pair<string,int> P;
 
string change(string L,string R,int len){
    stringstream LL(L),RR(R),T;
    int l,r,t;
 
    LL >> l; RR >> r;
    t = l - r;
    T << t;
 
    string tmp,res = "";
    T >> tmp;
   
    for(int i = (int)tmp.size() ; i < len ; i++){
	res += "0";
    }
    res += tmp;
    return res;
}
 
int main(){
    int L;
    string a;
 
    while(cin >> a >> L){
	if(a == "0" && L == 0) break;
 
	vector<P> v;
	int cnt = 1;
	v.push_back(P(a,0));
 
	if((int)a.size() != L){
	    for(int i = (int)a.size() ; i < L ; i++){
		a += "0";
	    }
	}
 
	while(true){
	    sort(a.begin(),a.end());
	    string b = a;
	    reverse(a.begin(),a.end());
	    string c = a;
	    a = change(c,b,L);
       
	    if(cnt){
		for(int i = 0 ; i < (int)v.size() ; i++){
		    if(v[i].first == a){
			string d = "";
			int j;
  
			for(j = 0 ; j < (int)a.size() ; j++){
			    if(a[j] == '0') continue;
			    else break;
			}
			for(int k = j ; k < (int)a.size() ; k++){
			    d += a[k];
			}
			if(d == "") d += "0";
			a = d;
			cout << v[i].second << " " << d << " "
			     << (cnt - v[i].second) << endl;
			goto end;
		    }
		}
	    }
	    v.push_back(P(a,cnt));
	    cnt++;
	}
    end:;
    }
    return 0;
}

Measured memory_bytes: 3168
import numpy as np
if __name__ == "__main__":
    # 入力パターン．
    # 要素の数がわかっているパターン
    ### a b
    k = int(input())
    a, b = map(int, input().split())
    ans = 'NG'
    for i in range(a, b+1):
        if i % k == 0:
            ans = 'OK'
            break
    print(ans)



Measured memory_bytes: 27116
#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

void Yes()
{
	OUT("Yes");
}
void No()
{
	OUT("No");
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

#ifdef _DEBUG
	system("pause");
#endif

	return 0;
}

using namespace std;

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

void Main()
{
	inll n;
	instr s;

	vll a;

	REP(i, n)
	{
		if (s[i] == 'W')
		{
			if (i == 0)
				a.push_back(1);
			else
				a.push_back(a[i - 1] + 1);
		}
		else
		{
			if (i == 0)
				a.push_back(0);
			else
				a.push_back(a[i - 1]);
		}
	}

	ll m = 1234567;

	REP(i, n)
	{
		if (i == 0)
		{
			m = min(m, ((n - i) - (a.back() - a[i])) + 0);
		}else{
			m = min(m, ((n - i) - (a.back() - a[i])) + a[i - 1]);
		}
	}

	return OUT(m - 1);
}


Measured memory_bytes: 6792
#include<bits/stdc++.h>
#define fi first
#define se second
#define show(x) cerr<<#x<<"="<<x<<"\n"
typedef long long ll;
using namespace std;
const ll MOD=(ll)1e9+7;
const int inf=(ll)1e9;
//const ll inf=(ll)1e14;
const int dy[]={1,0,-1};
const int dx[]={1,0,-1};

int n,w;
int a[211];
int sum[202];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1=freopen("in","r",stdin);
  //stream2=freopen("out","w",stdout);
  if(stream1==NULL)return 0;
  //if(stream2==NULL)return 0;
#endif
  cin>>n>>w;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  a[n]=inf;
  n++;
  sort(a,a+n);
  ll ans=0;
  for(int i=0;i<n+1;i++){
    int sum=0;
    for(int j=0;j<i;j++){
      sum+=a[j];
    }
    int nokori=w-sum;
    if(nokori<0)continue;
    //show(nokori);
    int minw=a[i];
    //show(minw);
    ll dp[2][10001];
    for(int j=0;j<2;j++)for(int k=0;k<=w;k++)dp[j][k]=0;
    dp[(i+1)&1][0]=1;
    for(int j=i+1;j<n;j++){
      for(int k=0;k<=w;k++){
        dp[(j+1)&1][k]=0;
      }
      for(int k=0;k<=w;k++){
        if(dp[j&1][k]==0)continue;
        if(k+a[j]<=nokori){
          dp[(j+1)&1][k+a[j]]=(dp[(j+1)&1][k+a[j]]+dp[j&1][k])%MOD;
        }
        dp[(j+1)&1][k]=(dp[(j+1)&1][k]+dp[j&1][k])%MOD;
      }
      /*for(int k=0;k<=w;k++){
        cout<<dp[j&1][k]<<" ";
      }
      cout<<endl;*/
    }
    for(int j=0;j<=nokori;j++){
      if(nokori-j<minw)ans=(ans+dp[n&1][j])%MOD;
    }
  }
  cout<<ans<<endl;
#ifdef LOCAL_DEFINE
  cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}








Measured memory_bytes: 3332
"use strict";
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    var input = input.split("\n");
    var tmp = input[0].split(" ");
    var a = parseInt(tmp[0], 10);
    var b = parseInt(tmp[1], 10);
    var c = parseInt(tmp[2], 10);
    if(a + b >= c){
        console.log("Yes");
    }else{
        console.log("No");
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29512
///mAAria...
    #include<bits/stdc++.h>
     
    using namespace std;
     
    #define int long long
    typedef pair<int,int> pii;
    typedef vector<int> vi;
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define mod 1000000007
    #define inf 1000000000

    const long double PI = acos(-1);

    int powm(int a, int b) {
        int res=1;
        while(b) {
            if(b&1)
                res=(res*a)%mod;
            a=(a*a)%mod;
            b>>=1;
        }
        return res;
    }
    vector<vi> adj;
    int dist1[100005],dist2[100005];

    void dfs(int x, int par, int dist[]){

        dist[x] = dist[par] + 1;

        for(auto i: adj[x]){
            if(i!=par){
                dfs(i, x, dist);
            }
        }
    }

    
    void solve(){
        int n;
        cin >> n;

        adj.resize(n+1);

       int a,b;
       cin >> a >> b;

        //to find the vertex nearer to a and farther from vertex b

       for(int i = 1;i<n;i++){
        int x,y;
        cin >> x >> y;

        adj[x].push_back(y);
        adj[y].push_back(x);
       }

       dist1[0] = -1; //dist from a
       dist2[0] = -1; //dist from b

       dfs(a, 0, dist1);
       dfs(b, 0, dist2);

       int ans  = 0;
       for(int i = 1;i<=n;i++){
        if(dist1[i] < dist2[i]){
            ans = max(ans, dist2[i]-1);
        }
       }

       cout << ans << endl;

    } 

    signed main() 
    {   
        IOS;
        int t = 1;
        //cin >> t;

        for(int i = 1;i<=t;i++){
            solve();
        }
        return 0;
    } 

     


Measured memory_bytes: 11264
/*
    CP Submission
*/

#include<bits/stdc++.h>

using namespace std;

/* Shortcuts */
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(), x.end()
#define VAL(x) cout << #x << ": " << (x) << endl;
#define LOG(x) cout << (x) << endl;
#define SZ(x) (int)(x.size())
#define REP(i, a, b) for(int i = a; i < b; i++)

/* typedefs */
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <string,string> mss;

const ll INF = 1e11;

const int MAX_VAL = 1e5 + 1;
const int MAX_N = 105;

ll weights[100];
ll values[100];

ll dp[MAX_N][MAX_VAL]; // dp[i] = the minimum weight required to get to value i


int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    int w;
    cin>>n>>w;


    REP(i,0,MAX_N){
        REP(j,0,MAX_VAL) dp[i][j] = INF;
    }

    REP(i,0,n){
        cin>>weights[i]>>values[i];
        dp[i][0] = 0;
    }


    int k;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < MAX_VAL; j++){
            dp[i][j] = dp[i-1][j];
            k=i-1;
            if(j - values[k] >= 0){
                dp[i][j] = min(dp[i][j],
                        dp[i-1][j-values[k]] + weights[k]);
                //LOG(k);
            }
        }
    }

    int ans = 0;

    //for(int i = 0; i <= n; i++){
        //for(int j = 0; j < 200; j++){
            //if(dp[i][j] != INF){
                //cout << "VALUE " << j << " WITH THE FIRST " << i << " ITEMS\n" << " \tWEIGHTED " << dp[i][j] << endl;
            //}
        //}
    //}

    REP(i,0,MAX_VAL){
        if(dp[n][i] <= w && dp[n][i] > 0){
            ans = i;
        }
    }

    LOG(ans);




    return 0;
}


Measured memory_bytes: 82304
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int N, M, X;
int C[12];
int A[12][12];
int main(void){
    cin >> N >> M >> X;
    REP(i,N){
        cin >> C[i];
        REP(j, M) cin >> A[i][j];
    }
    int cost = -1;
    int p[12];
    REP(i, pow(2, N)){
        REP(k,M) p[k] = 0;
        int cost_t = 0;
        REP(j, N){
            if(((i>>j)&1)==1){
                REP(k,M) p[k] += A[j][k];
                cost_t += C[j];
            }
        }
        bool f = true;
        REP(k,M) f &= (p[k] >= X);
        if(f and cost == -1) cost = cost_t;
        else if(f) cost = min(cost, cost_t);
    }
    cout << cost << endl;
    return 0;
}



Measured memory_bytes: 4100
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    ll x, y;
    cin >> x >> y;

    if(x <= y) cout << min(abs(y-x), abs(y+x)+1) << endl;
    else cout<<min(abs(-y-x)+1,abs(-y+x)+2) << endl;

    return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(a, b):
	return a * b // gcd (a, b)

n=input()
A=list(map(int, input().split(" ")))
num=A[0]
#print(A)
for i in A:
    num = lcm(num, i)
    #print(num)
value=0
for i in A:
    value+=(num-1)%i

print(value)


Measured memory_bytes: 3316
#include <algorithm>
#include <cassert>
#include <iostream>
#include <queue>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef pair<int, int> BC;
#define mp(a, b) make_pair(a, b)

int main(int argc, char const *argv[]) {
  string s;

  cin >> s;

  for (int i = 0; i < s.size() - 1; i++) {
    if (s[i] == s[i + 1]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;

  return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define FORD(i,b,a) for (int i = (int)(b) - 1; i >= a; --i)
#define REP(i,N) FOR(i,0,N)
#define st first
#define nd second
#define pb push_back

typedef pair<int, int> PII;
typedef long long LL;

int d[200000];

int main() {
    int N, M;
    scanf("%d%d", &N, &M);
    REP(i,M) {
      int a, b;
      scanf("%d%d", &a, &b);
      d[--a]++, d[--b]++;
    }
    REP(i,N) if (d[i]%2) {
      printf("NO\n");
      return 0;
    }
    printf("YES\n");
}


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

using ll=long long;

int round_down(double f){
    return int(f);
}

int main()
{
    
    int A,B;
    cin>>A>>B;
    bool f=false;
    for (int i=0;i<10000; i++) {
        if (round_down(i*0.08)==A&&round_down(i*0.1)==B) {
            f=true;
            cout<<i<<endl;
            break;
    
        }
    }
    if (!f) {
        cout<<-1<<endl;
    }
   
    return 0;
}


Measured memory_bytes: 256
// abc.068 C - Cat Snuke and a Voyage

#include <bits/stdc++.h>
using namespace std;

int main( void ) {

    int n, m;
    cin >> n >> m;
    if( m == 1 ) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    int  num[ 200005 ] = {};
    bool flag          = false;
    for( int i = 0; i < m; i++ ) {
        int a, b;
        cin >> a >> b;

        //始点が１なら
        if( a == 1 ) {
            //添え字が終点にインクリメント.配列にするのは、a==1が複数個（個数不明）のため
            num[ b ]++;
            //制約から、(a,b)同じ組み合わせはありえない。
            if( num[ b ] == 2 ) flag = true;
        }
        //終点がnなら
        if( b == n ) {
            //上のnum[b]と添え字は同じになっている
            num[ a ]++;
            if( num[ a ] == 2 ) flag = true;
        }
    }
    puts( flag ? "POSSIBLE" : "IMPOSSIBLE" );
    return 0;
}


Measured memory_bytes: 1024
#include <string>
#include <vector>
#include <cstring>
#include <algorithm>
#include <iostream> 
 
using namespace std;
typedef long long ll;
typedef long double ld;

//repetition
#define REP(i,n)  for(ll i=0;i<n;i++)

unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
 
unsigned binarySearch(ll target, ll max, ll min) {
  while((max - min) > 1) {
      if((max + min)/2 > target) {
        max = (max + min)/2;
        min = min;
      } else {
        max = max;
        min = (max + min)/2;
      }
    }
}

ll n;

bool valid(ll bit, vector<pair<ll, pair<ll, ll>>> vp) {
  REP(i, vp.size()){
    
    cout << "bit: " << bit << endl;
    cout << "vp.at(i).first: " << vp.at(i).first << endl;
    cout << "n -1 -vp.at(i).first: " << n -1 -vp.at(i).first << endl;
    cout << "bit & (1 << n -1 -vp.at(i).first): " << (bit & (1 << n -1 -vp.at(i).first)) << endl;
    
    // 発言者が正直
    if(bit & (1 << n -1 -vp.at(i).first)) {
      // 発言内容と実際の値が異なる場合は不適
      if(bit & (1 << n - vp.at(i).second.first) != vp.at(i).second.second) return false;
    }
  }
  return true;
}
 

int main() {
  cin >> n;
  
  vector<vector<ll>> vp(n, vector<ll>(n, -1));
  
  REP(m, n) { //全ての集合
    ll r;
    cin >> r;
    
    REP(l, r) {
      ll p,q;
      cin >> p >> q;
      vp.at(m).at(p-1) = q;
    }
  }
  
  ll m = 0;
  
  REP(i, (1<<n)) {
    ll tmp = 0;

    bool isValid = true;
    
    //cout << "集合i: " << i << endl;
    
    REP(l, n) {
      if (1 & (i >> l)) {

        //cout << "正直者であるl人目: " << l+1 << endl;
        REP(x, vp.at(l).size()){
          //cout << "x人目に対する発言: " << x+1 << "xはvp.at(l).at(x): " << vp.at(l).at(x) << endl;

          if(vp.at(l).at(x) != -1 && (i >> x & 1) != vp.at(l).at(x)) {
            isValid = false;
          }
        }
        tmp++;
      }
    }
    if (isValid) {
      //cout << "発言が妥当なとき正直者の合計: " << max(m, tmp) << endl;
      m = max(m, tmp);
    }
  }
  cout << m << endl;
  
}


Measured memory_bytes: 256
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions

import copy

# import heapq
# from collections import deque
# import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    s = list(input())

    w_in_left_side_of_me = [0 for _ in range(n)]
    e_in_right_side_of_me = [0 for _ in range(n)]

    for i in range(1, n):
        w_in_left_side_of_me[i] = w_in_left_side_of_me[i - 1]
        if s[i - 1] == "W":
            w_in_left_side_of_me[i] += 1

    for i in range(n - 1 - 1, -1,-1):
        e_in_right_side_of_me[i] = e_in_right_side_of_me[i + 1]
        if s[i + 1] == "E":
            e_in_right_side_of_me[i] += 1

    ans = sys.maxsize
    for i in range(n):
        ans = min(ans, w_in_left_side_of_me[i] + e_in_right_side_of_me[i])

    print(ans)


if __name__ == '__main__':
    main()


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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

const int num = 3;

int main() {
    char arr[num];
    cin >> arr;
    set<char> S {begin (arr), end (arr)};
    cout << (1 < S.size() ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int a, ans = 0, max = 0;
	
	for (int i = 0; i < 3; i++) {
		cin >> a;
		ans += a;
		if (max < a) {
			max = a;
		}
	}
	cout << ans - max << endl;
	
	return 0;
}



Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
A=get_i
exc={}
A.sort.each_with_index do|a_,i|
    exc[a_]=i+1
end
b=array(N)
N.times do|i|
    b[i]=exc[A[i]]
end
K=b.max
ans=array(N)
c=array(K+1,0)
N.times do|i|
    c[b[i]]+=1
end
1.upto(K) do|i|
    c[i]+=c[i-1]
end
(N-1).downto(0) do|i|
  ans[c[b[i]]-1]=A[i]
  c[b[i]]-=1
end
puts ans.join(" ")


Measured memory_bytes: 204928
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>

using namespace std;
int n;

const int INF = 1 << 29;

int main(void)
{
	while (cin >> n)
	{
		int k;
		cin >> k;
		for (int i = 0; i < k; i++)
		{
			int x, y;
			cin >> x >> y;
			if(x > n / 2)
				x = n - x;
			else x--;
			if(y > n / 2)
				y = n - y;
			else y--;

			int place = min(x, y);
			cout << place % 3 + 1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <numeric>
using namespace std;

#define REP(i,b,n) for(int (i)=b; (i)<(int)(n); ++(i))
#define rep(i,n) REP(i,0,n)
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define all(a) (a).begin(),(a).end()
#define print(var) cout<<#var":"<<(var)<<endl;
#define printkv(key,var) cout<<#key":"<<(var)<<endl;
#define updatemax(dst,src) dst=max(dst,src);
#define updatemin(dst,src) dst=min(dst,src);

typedef long long ll;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
  if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}

int N;

int main() {
  while (cin >> N) {
    int back = N / 15;
    int ans = N * 800 - back * 200;
    cout << ans << endl;
  }
  return 0;
}


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

void q_sort(int numbers[], int left, int right)
{
    int pivot, l_hold, r_hold;

    l_hold = left;
    r_hold = right;
    pivot = numbers[left];
    while (left < right)
    {
        while ((numbers[right] >= pivot) && (left < right))
            right--;
        if (left != right)
        {
            numbers[left] = numbers[right];
            left++;
        }
        while ((numbers[left] <= pivot) && (left < right))
            left++;
        if (left != right)
        {
            numbers[right] = numbers[left];
            right--;
        }
    }
    numbers[left] = pivot;
    pivot = left;
    left = l_hold;
    right = r_hold;
    if (left < pivot)
        q_sort(numbers, left, pivot-1);
    if (right > pivot)
        q_sort(numbers, pivot+1, right);
}

int main(void){
    int n, m;
    scanf("%d %d", &n, &m);
    int x[m];
    for(int i = 0;i < m;i++){
        scanf("%d", &x[i]);
    }
    if(n >= m)printf("0\n");
    else{
        q_sort(x, 0, m-1);
        int y[m-1];
        for(int i = 0;i < m-1;i++){
            y[i] = x[i+1] - x[i]; 
        }
        q_sort(y, 0, m-2);
        int rem = m - n;
        int sum = 0;
        for(int i = 0;i < rem;i++){
            sum += y[i];
        }
        printf("%d\n", sum);
    }
    return 0;
}

Measured memory_bytes: 1408
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a;
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->X[] = $a;
  }
}
$A = $key->A[0];
$x = array();
foreach($key->X[0] as $k=>$a) {
  $x[]=$a;
}
printf("ABC%s\n",$A);


Measured memory_bytes: 3828
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w, k;
    cin, h, w, k;
    auto mp = make_v(h, w, '.');
    REP(i, 0, h) {
        REP(j, 0, w) {
            cin, mp[i][j];
        }
    }
    int ans = 0;
    const int sz = 1 << (h + w);
    REP(bits, 0, sz) {
        int cnt = 0;
        REP(i, 0, h) {
            REP(j, 0, w) {
                int hh = (bits >> i) & 1;
                int ww = (bits >> (j + h)) & 1;
                if (mp[i][j] == '#' && !hh && !ww) {
                    cnt++;
                }
            }
        }
        ans += (cnt == k);
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 3656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String readStr;
    while ((readStr = reader.readLine()) != null) {
      double[] list = new double[3];
      list[0] = Double.parseDouble(readStr.split(" ")[0]);
      double r = list[0];
      String a = String.format("%.5f", r*r*Math.PI);
      String b = String.format("%.5f", r*2*Math.PI);
      System.out.println(a + " " + b);
      break;
    }
  }

}

Measured memory_bytes: 17080
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



bool check[100005];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N; cin >> N ;

  vector<ll> A; 
  rep(i,N){
    ll inp; cin >> inp;
    A.pb(inp);
  }

  ll push = 1;
  rep(i,N){
    push--;
    if(push==1){ cout << i << endl; return 0;}
    push = A[push];
    if(check[push]) break;
    check[push] = true;
  }

  cout << "-1" << endl;

  
  
  //cout << fixed << setprecision(16) << ans << endl;
  
  return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
const long long M =1e3+2,MOD=1e9+7;
typedef long long ll;
#define pb push_back
#define Y printf("YES\n")
#define N printf("NO\n")
#define O printf("-1\n")
bool f_2=false,vis[M]= {false},f=false;
vector<ll>v,v_1,v_2,v_3,v_4,v_5;
string s,p,q,ok,ch;
map<ll,ll>mp,mp_2;
set<ll>st,st_1;
ll Rank[M],parent[M]= {-1};
ll cnt=0,cost=0,mx=0,NODE,t,par;
deque<ll>Q;
//vector< pair<ll,ll > >v,v_1;
struct node
{
    ll pa,ran,visit;

};
//node X[M];
int main()
{
    ios::sync_with_stdio(false);//ISHWAR
    cin.tie(0);//Tourist_Twin
   //freopen("kamona.txt","r",stdin);
    ll a,b,c=1,n,t,sum=0,mx=0,l,x,y,i=0,j=0,result=0,e,sum_2,ans=0,d,k;
    cin>>t;
    while(t--)
    {
        cin>>b;
        v.pb(b);
    }
    v_1=v;
    sort(v_1.begin(),v_1.end());
    for(i=0;i<v.size();i++)
    {
        if(v[i]!=v_1[i])
        {
            for(j=0;j<v.size();j++)
            {
                if(v_1[i]==v[j])
                {
                    ll temp=v[i];
                    v[i]=v[j];
                    v[j]=temp;
                    break;
                }
            }
            break;
        }
    }
    if(v==v_1)Y;
    else N;


        return 0;
    }


Measured memory_bytes: 256
#include<stdio.h>

typedef struct {
  int num;
  int parent_flag;
  int parent;
  int junban;
  int degree_num;
  int depth;
} Root;

int main(){

  int n, i, j, d_num, cnt = 0, temp;

  scanf("%d",&n);

  Root data[100000];
  
  for(i = 0; i < n; i++)
    {
      scanf("%d",&d_num);

      data[d_num].num = d_num;

      scanf("%d",&data[d_num].degree_num);
      
      for(j = 0; j < data[d_num].degree_num; j++)
	{
	  scanf("%d",&temp);
	  
	  data[temp].parent = d_num;
	  data[temp].parent_flag = 1;
	  data[temp].junban = j;
	}

      j = d_num;
      cnt = 0;
      
      while(1)
	{
	  if(data[data[j].parent].parent != -1)
	    {
	      data[d_num].depth = cnt;
	      break;
	    }
	  j = data[j].parent;
	  cnt++;
	}
      
    }

  for(i = 0; i < n; i++)
    {
      if(data[i].parent_flag != 1)
	{
	  data[i].parent = -1;
	  break;
	}
    }

  for(i = 0; i < n; i++)
    {
      j = i;
      cnt = 0;
      
      while(1)
	{
	  if(data[j].parent == -1)
	    {
	      data[i].depth = cnt;
	      break;
	    }
	  j = data[j].parent;
	  cnt++;
	}
    }
      
  for(i = 0; i < n; i++)
    {
      printf("node %d: parent = %d, depth = %d, ", i, data[i].parent, data[i].depth);

      if(data[i].degree_num == 0 && data[i].parent != -1)printf("leaf, [");
      else if(data[i].parent == -1)printf("root, [");
      else printf("internal node, [");

      cnt = 0;
      j = 0;
      
      while(2)
	{
	  if(data[i].degree_num == 0)break;
	  if(data[i].num == data[j].parent && data[j].junban == cnt)
	    {
	      printf("%d",data[j].num);
	      
	      if(cnt == data[i].degree_num - 1)break;
	       
	      printf(", ");
	      cnt++;
	    }
	  j++;
	  if(j == n)j = 0;
	}
      printf("]\n");
    }
  return 0;
}



Measured memory_bytes: 4200
n=int(input())
a=[]
b=[]
m=n+(n%2==0)
for i in range(1,n):
  for j in range(i+1,n+1):
    if i+j!=m:a.append(i);b.append(j)
print(len(a))
for i,j in zip(a,b):print(i,j)

Measured memory_bytes: 3736