akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr double EPS = 1e-9;




int main() {

    ll k;
    cin>>k;
    ll n=50;
    ll t=k/n;
    ll r=k-t*n;
    vll v(n,n-1+t);
    rep(i,r){
        v[i]+=n-r+1;
    }
    for(int i=r;i<n;i++)v[i]-=r;
    fin(n);
    dump(v);

}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define TEST(...)                                                              \
    { printf("! "), printf(__VA_ARGS__); }
#else
#define TEST(...)
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
  public:
    void solve() {
        int k;
        cin >> k;
        i64 sum = 0;
        for (int i = 1; i <= k; ++i) {
            for (int j = 1; j <= k; ++j) {
                for (int ii = 1; ii <= k; ++ii) {
                    sum += __gcd(i, __gcd(j, ii));
                }
            }
        }
        cout << sum;
    }
} NSPACE;
int main() {
    FPEN;
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    NSPACE.solve();
}

Measured memory_bytes: 3656
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>

using namespace std;
using Int = long long;

constexpr double EPS = 1e-10;
constexpr long long MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

long long my_mod_pow(long long x, long long n) {
	long long ret = 1;
	for (; n > 0; n >>= 1, x = x * x % MOD) {
		if (n & 1) {
			ret = ret * x % MOD;
		}
	}
	return ret;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    int K; cin >> K;
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[K-1] << endl;
}

Measured memory_bytes: 888
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int k;
set<ll> st;

void dfs(ll s){
    if(s >= 10000000000) return;
    st.insert(s);
    rep(i,10){
        string t = to_string(s);
        int d = t[t.size()-1]-'0';
        if(abs(i-d) <= 1){
            char c = i+'0';
            ll a = stoll(t+c);
            dfs(a);
        }
    }
}

int main(){
    cin >> k;
    repr(i,1,10){
        st.insert(i);
        dfs(i);
    }
    vector<ll> v;
    for(auto u : st){
        v.push_back(u);
    }
    cout << v[k-1] << endl;
}


Measured memory_bytes: 11892
import java.util.*;

class Main{
    static int count = 0;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] S = new int[n];
        for(int i = 0;i < n;i++){
            S[i] = sc.nextInt();
        }

        mergeSort(S);

        for(int i = 0;i < n;i++){
            if(i != 0)  System.out.print(" ");
            System.out.print(S[i]);
        }
        System.out.println();
        System.out.println(count);
    }

    /* 2つの配列LとRを併合してAを作成 */
    static void merge(int[] L,int [] R,int[] A){
        int i = 0,j = 0;    //カウンタ
        while(i < L.length || j < R.length){
            if(j >= R.length || (i < L.length && L[i] < R[j])){
                A[i + j] = L[i];
                count++;
                i++;
            }
            else{
                A[i + j] = R[j];
                count++;
                j++;
            }
        }
    }

    /* データのソート */
    static void mergeSort(int[] A){
        if(A.length > 1){
            int m = A.length / 2;
            int n = A.length - m;
            int[] L = new int[m];
            int[] R = new int[n];
            for(int i = 0;i < m;i++)    L[i] = A[i];
            for(int i = 0;i < n;i++)    R[i] = A[m + i];
            mergeSort(L);
            mergeSort(R);
            merge(L,R,A);
        }
    }
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  double a, b, c;
  cin >> a >> b>> c;
  cout << a * b / 2.0;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3792
#include <iostream> 
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = 0;
	for (int i = 1; i < n-1; i++) {
		if (a[i - 1] < a[i] && a[i] < a[i + 1]) {
			ans++;
		}
		else if (a[i - 1] > a[i] && a[i + 1] < a[i]) {
			ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

char buf[SIZE];

int main(){

	scanf("%s",buf);

	int num_g = 0,num_p = 0;
	int win = 0,lose = 0;

	for(int i = 0; buf[i] != '\0'; i++){
		if(buf[i] == 'g'){

			if(num_p+1 <= num_g){
				num_p++;
				win++;
			}else{
				num_g++;
			}

		}else{	//buf[i] == 'p'


			if(num_p+1 <= num_g){
				num_p++;
			}else{
				num_g++;
				lose++;
			}
		}
	}

	printf("%d\n",win-lose);

	return 0;
}


Measured memory_bytes: 384
#![allow(non_snake_case)]

#[allow(unused_macros)]
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

fn main() {
    input!{
        N: usize,
        C: usize,
        stcs: [(usize,usize,usize);N]
    }
    let mut stcs = stcs;
    let mut REC_buff: Vec<(usize, usize, usize)> = Vec::with_capacity(C);
    let mut ans = 0;
    let mut buff = Vec::with_capacity(C);

    stcs.sort();
    for (s, t, c) in stcs {
        for (i, rec_p) in REC_buff.iter().enumerate() {
            let rec_t = rec_p.1;
            let rec_c = rec_p.2;
            if rec_t * 10 <= s * 10 - 5 || (rec_t <= s && c == rec_c) {
                buff.push(i);
            }
        }
        buff.reverse();
        for i in buff.iter() {
            REC_buff.remove(*i);
        }
        buff.clear();
        REC_buff.push((s, t, c));
        ans = std::cmp::max(REC_buff.len(), ans);
    }
    println!("{}", ans);
}

Measured memory_bytes: 8444
a, b, m = gets.chop.split.map(&:to_i)
as = gets.chop.split.map(&:to_i)
bs = gets.chop.split.map(&:to_i)

result = as.min + bs.min

m.times do
  x, y, c = gets.chop.split.map(&:to_i)

  result = (as[x-1] + bs[y-1]) - c if ((as[x-1] + bs[y-1]) - c) < result
end

puts result


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

int main()
{
	ll n,a,b;
	cin >> n >> a >> b;
	if(n==1||a>b)
	{
		if(a==b)cout<<1<<endl;
		else cout<<0<<endl;
		return 0;

	}
	ll ans = (b*(n-1)+a)-(a*(n-1)+b)+1;
	cout<<max(0LL,ans)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int w,h,x,y;
  cin>>w>>h>>x>>y;
  cout<<fixed<<stp(11)<<(double)w*(double)h/2<<' ';
  if(w==x+x && h==y+y){
    cout<<1<<'\n';
  }
  else{
    cout<<0<<'\n';
  }
  return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int i,n,k;
  cin >> n >> k;
  int p[1010];
  for(i=0;i<n;i++){
    cin >> p[i];
  }
  sort(p,p+n);
  int sum=0;
  for(i=0;i<k;i++){
    sum+=p[i];
  }
  cout << sum << endl;
}


Measured memory_bytes: 3612
def dfs(i, A, B, C):
    global ans
    if i == n:
        if A and B and C:
            ans = min(ans, abs(a - sum(A)) + abs(b - sum(B)) + abs(c - sum(C)) + (len(A) + len(B) + len(C) - 3) * 10)
    else:
        dfs(i + 1, A, B, C)
        dfs(i + 1, A + [L[i]], B, C)
        dfs(i + 1, A, B + [L[i]], C)
        dfs(i + 1, A, B, C + [L[i]])

n, a, b, c = map(int, input().split())
L = [int(input()) for i in range(n)]
ans = float("inf")
dfs(0, [], [], [])
print(ans)

Measured memory_bytes: 3064
# #!/usr/bin/env python3
# # -*- coding: utf-8 -*-
# # 問題：https://atcoder.jp/contests/abc126/tasks/abc126_f
# # 解説動画を見ながら実装

import sys

m, k = map(int, input().strip().split())
max_num = 2**m
if k >= max_num:
    print(-1)
    sys.exit()

if m == 0:
    print('0 0')
    sys.exit()

if m == 1:
    if k == 0:
        print('0 0 1 1')
    else:
        print('-1')
    sys.exit()

res = []
for i in range(max_num):
    if i == k:
        continue
    res.append(i)
res.append(k)
for i in range(max_num):
    j = max_num - i - 1
    if j == k:
        continue
    res.append(j)
res.append(k)
for i in range(2**(m+1)):
    print(res[i], end=' ')


Measured memory_bytes: 19628
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int n = sc.nextInt();
			
			int y, m, d, sum;
			for(int i=0;i<n;i++){
				sum = 0;
				y = sc.nextInt();
				m = sc.nextInt();
				d = sc.nextInt();
				
				sum += ((y-1)/3)*590;
				if(y%3==2)sum += 195;
				if(y%3==0)sum += 390;
				
				for(int j=1;j<m;j++){
					if(y%3!=0 && j%2==0)sum+=19;
					else sum+=20;
				}
				
				sum+=d;
				
				System.out.println(196471-sum);
			}
		}
	
	}	
}

Measured memory_bytes: 20496
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int h,w;
int a[55][55];
char s;
int ans;
int main(void){
    cin>>h>>w;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>s;
            if(s=='#'){
                a[i][j]=1;
            }
        }
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(a[i][j]==1){
                cout<<'#';
            }else{
                for(int k=-1;k<=1;k++){
                    for(int l=-1;l<=1;l++){
                        ans+=a[i+k][j+l];
                    }
                }
                cout<<ans;
                ans=0;
            }
        }
        cout<<endl;
    }

}


Measured memory_bytes: 3596
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
a, b, x  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()


def f(a, b, x):
    if a * a * b / 2 <= x:
        return math.atan(2 * (a * a * b - x) / (a * a * a))
    else:
        return math.pi / 2 - math.atan(2 * x / (a * b * b))

print(f(a, b, x) * 180 / math.pi)


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define print(x) cout << (x) << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
#define printd(x) printf("%.12f\n", ans);
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;


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

    cout << (n % 2 == 0 ? n / 2 : n / 2 + 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
	using namespace std;
	#define IOS ios::sync_with_stdio(false), cin.tie(0)
	#define REP(i, n) for (int i = 0; i < n; i++)
	#define FOR(i, a, b) for (int i = a; i < b; i++)
	#define ALL(x) (x).begin(), (x).end()
	#define dump(x) cout << (x) << endl
	#define LMAX 9223372036854775807LL
	#define LMIN -9223372036854775807LL

	using ll = long long;
	template<typename T>
	using vec = vector<T>;
	using P = pair<ll, ll>;

	template <typename A, size_t N, typename T>
	void Fill(A (&array)[N], const T &val){
		fill((T *)array, (T *)(array + N), val);
	}
	
	const ll INF = 1e18;
	const ll mod = 1e9 + 7;

	//int dx[4] = {1,0,-1,0};
	//int dy[4] = {0,1,0,-1};
	//ll pas[51][52];
	ll n, a, b;
	ll h[114514];
	bool ok(ll x){
		ll sum = b * x;
		ll cnt = 0;
		REP(i,n){
			cnt += max(0ll,(h[i] - sum  + a - b - 1) / (a - b));
		}
		if(cnt <= x)return true;
		else return false;
	}

	signed main(){
		IOS;
		cin >> n >> a >> b;
		REP(i,n)cin >> h[i];
		ll left = 0;
		ll right = mod;
		ll mid;
		while(1 < right - left){
			mid = (right + left) / 2;
			if(ok(mid))right = mid;
			else left = mid;
		}
		dump(right);
	}

Measured memory_bytes: 1024
#include <stdio.h>

struct dice {
	int area[6];
};

void diceroll(const char order, struct dice *dice)
{
	int temp;

	if (order == 'N') {
		temp = dice->area[0];
		dice->area[0] = dice->area[1];
		dice->area[1] = dice->area[5];
		dice->area[5] = dice->area[4];
		dice->area[4] = temp;
	}
	else if (order == 'W') {
		temp = dice->area[0];
		dice->area[0] = dice->area[2];
		dice->area[2] = dice->area[5];
		dice->area[5] = dice->area[3];
		dice->area[3] = temp;
	}
	else if (order == 'E') {
		temp = dice->area[0];
		dice->area[0] = dice->area[3];
		dice->area[3] = dice->area[5];
		dice->area[5] = dice->area[2];
		dice->area[2] = temp;
	}
	else if (order == 'S') {
		temp = dice->area[0];
		dice->area[0] = dice->area[4];
		dice->area[4] = dice->area[5];
		dice->area[5] = dice->area[1];
		dice->area[1] = temp;
	}
}

int main() {
	struct dice dice1;
	struct dice dice2;
	char order;
	int i, j, k;

	scanf("%d %d %d %d %d %d", &dice1.area[0], &dice1.area[1], &dice1.area[2], &dice1.area[3], &dice1.area[4], &dice1.area[5]);
	scanf("%d %d %d %d %d %d", &dice2.area[0], &dice2.area[1], &dice2.area[2], &dice2.area[3], &dice2.area[4], &dice2.area[5]);

	for (k = 0; k < 2; k++) {
		for (i = 0; i < 4; i++) {
			for (j = 0; j < 4; j++) {
				diceroll(order, &dice2);
				if (dice1.area[0] == dice2.area[0] && dice1.area[1] == dice2.area[1] && dice1.area[2] == dice2.area[2] && dice1.area[3] == dice2.area[3] && dice1.area[4] == dice2.area[4] && dice1.area[5] == dice2.area[5]) {
					printf("Yes\n");
					return 0;
				}
				order = 'W';
			}
			order = 'N';
		}
		for (i = 0; i < 4; i++) {
			for (j = 0; j < 4; j++) {
				diceroll(order, &dice2);
				if (dice1.area[0] == dice2.area[0] && dice1.area[1] == dice2.area[1] && dice1.area[2] == dice2.area[2] && dice1.area[3] == dice2.area[3] && dice1.area[4] == dice2.area[4] && dice1.area[5] == dice2.area[5]) {
					printf("Yes\n");
					return 0;
				}
				order = 'W';
			}
			order = 'S';
		}
	}

	printf("No\n");
	return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define pb push_back
#define sx 200007
int main()
{
   int x;
   cin>>x;
   for(int i=x;1;i++)
   {
       int flag=0;
       for(int j=2;j<=sqrt(i);j++)
       {
           if(i%j==0)
           {
               flag=1;
               break;
           }
       }
       if(!flag)
       {
           cout<<i<<endl;
           return 0;
       }
   }
   return 0;
}


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

using namespace std;

vector<uint64_t> compress(const string &S)
{
  vector<uint64_t> a;
  char ch = S[0];
  uint64_t counter = 1;
  
  for (uint64_t i = 1; i < S.size(); ++i) {
    if (ch != S[i]) {
      a.push_back(counter);
      
      ch = S[i];
      counter = 1;
    } else {
      ++counter;
    }
  }
  a.push_back(counter);
  
  return a;
}

int main()
{
  uint64_t N, K;
  cin >> N >> K;
  
  string S;
  cin >> S;
  
  vector<uint64_t> a = compress(S);
  transform(a.begin(), a.end(), a.begin(), [](uint64_t x){ return x - 1; });
  uint64_t ans = accumulate(a.begin(), a.end(), 0) + K * 2;
  cout << min(ans, N - 1) << endl;
  
  return 0;
}

Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
int main(){
int S;
  cin>>S;
 int a=S/100;
int b=S%100;
if(a>=1&&12>=a){
if(b>=1&&12>=b){
cout<<"AMBIGUOUS"<<endl;
}
  else{
  cout<<"MMYY"<<endl;
  }
}
  else{
  if(b>=1&&12>=b){
  cout<<"YYMM"<<endl;
  }else{
  cout<<"NA"<<endl;
  }
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int a,b,i,min,max;
    long sum;
    scanf("%d",&a);
    sum=0;
    max=-1000000;
    min=1000000;
    for(i=0;i<a;i++){
        scanf("%d",&b);
        sum += b;
        if(min>b){
        min=b;
        }
        if(max<b){
        max=b;
        }
    }
    printf("%d %d %ld\n",min,max,sum);
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

typedef pair<int,int>pi;
typedef vector<int>vi;

const int MAXN=100005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int ans = 0;
	string S, T; cin >> S >> T;
	FOR(i,0,(int) S.length() - 1){
		if (S[i]!=T[i]) ans++;
	}
	cout<<ans;
}


Measured memory_bytes: 3776
#include <iostream>
#include <string.h>
#include <algorithm>
#include <cstdio>
using namespace std;

struct Tnode
{
	long long On , Off , Keep;
};

struct Task
{
	int x , y;
};

const int dx[4] = { 0 , 0 , -1 , 1 };
const int dy[4] = { -1 , 1 , 0 , 0 };
const int maxn = 107 , maxq = 10007;
	  int n , m , q;
	  long long res , Time;
	  long long T[maxn][maxn];
	  Task ask[maxq];
	  Tnode node[maxn][maxn];
	  char Map[maxn][maxn];
	  bool use[maxn][maxn];
	  
void init()
{
	for ( int i = 1 ; i <= n ; i++ ) scanf( "%s" , Map[i]+1 );
	for ( int i = 1 ; i <= n ; i++ )
		for ( int j = 1 ; j <= m ; j++ ) cin >> node[i][j].Keep;
	for ( int i = 1 ; i <= n ; i++ )
		for ( int j = 1 ; j <= m ; j++ ) cin >> node[i][j].On;
	for ( int i = 1 ; i <= n ; i++ )
		for ( int j = 1 ; j <= m ; j++ ) cin >> node[i][j].Off;
	for ( int i = 1 ; i <= q ; i++ ) scanf( "%d %d" , &ask[i].x , &ask[i].y ) , ask[i].x++ , ask[i].y++;
}

bool check_map( int x , int y )
{
	if ( x < 1 || x > n ) return false;
	if ( y < 1 || y > m ) return false;
	if ( Map[x][y] == '#' ) return false;
	return use[x][y];
}

void put_time( int x , int y , long long TIME )
{
	if ( T[x][y] == 0 ) res += node[x][y].On;
	else				res += min(node[x][y].On+node[x][y].Off,node[x][y].Keep*(TIME-T[x][y]));
	T[x][y] = TIME;
}

bool dfs( int x , int y , Task End , long long TIME )
{
	use[x][y] = false;
	if ( End.x == x && End.y == y )
	{
		Time = TIME;
		return true; 
	}
	for ( int i = 0 ; i < 4 ; i++ )
	{
		int xx = x+dx[i] , yy = y+dy[i];
		if ( check_map(xx,yy) )
			if ( dfs(xx,yy,End,TIME+1) )
			{
				put_time(x,y,TIME);
				return true;
			}	
	}
	return false;
}

void work()
{
	init();
	memset( T , 0 , sizeof(T) ); 
	Time = 1 , res = 0;
	for ( int i = 1 ; i < q ; i++ ) 
	{
		memset( use , true , sizeof(use) );
		dfs(ask[i].x,ask[i].y,ask[i+1],Time);
	}
	put_time(ask[q].x,ask[q].y,Time);
	for ( int i = 1 ; i <= n ; i++ )
		for ( int j = 1 ; j <= m ; j++ )
			if ( T[i][j] > 0 ) res += node[i][j].Off;
	cout << res << endl;
}

int main()
{
	while ( scanf( "%d %d %d" , &n , &m , &q ) != EOF ) work();
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll d,s,t;
	cin>>d>>s>>t;
	if(d>s*t){
		cout << "No";
	}
	else{
		cout << "Yes";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,q; cin >> n >> q;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	while(q--){
		int l,r; cin >> l >> r;
		cout << upper_bound(a.begin(),a.end(),r)-lower_bound(a.begin(),a.end(),l) << endl;
	}
}



Measured memory_bytes: 3244
#include<iostream>
using namespace std;
int n,a[25];
bool solve(int i,int m){
	if(i>=n||m<1)return false;
	if(m==a[i])return true;
	return solve(i+1,m)||solve(i+1,m-a[i]);
}
int main(){
	int q,m;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>m;
		cout<<(solve(0,m)?"yes":"no")<<endl;
	}
	return 0;
}


Measured memory_bytes: 3092
n = int(input())
s = input()
d = {str(i):[] for i in range(10)}
for i,x in enumerate(s):
    d[x].append(i)
_sum = 0
for i in range(10):
    if len(d[str(i)]) != 0:
        for j in range(10):
            if len(d[str(j)]) != 0:
                for k in range(10):
                    if len(d[str(k)]) != 0:
                        st = d[str(i)][0]
                        en = d[str(k)][-1]
                        for idx in d[str(j)]:
                            if idx>st and idx<en:
                                _sum+=1
                                break
                            elif idx>=en:
                                break
print(_sum)

Measured memory_bytes: 4468
#include<iostream>
#include<vector>

using namespace std;

int main(void){
    int n;
    cin>>n;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    int cnt=0;
    for(int i=1;i<n-1;i++){
        if((p[i]<p[i+1]&&p[i]>p[i-1])||(p[i]>p[i+1]&&p[i]<p[i-1])){
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
import itertools

N = int(input())
L = list(map(int, input().split()))

cnt = 0
for pair in itertools.combinations(L, 3):
    t = list(pair)
    t.sort()
    if t[0]==t[1] or t[0] == t[2] or t[1] == t[2]:
        continue
    if t[2] < (t[0] + t[1]):
        cnt +=1

print(cnt)


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

/*
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#include <set>
*/

using namespace std;

typedef long long LL;
typedef double DB;
typedef unsigned int UI;
typedef pair<int, int> PII;

const int inf = 0x7f7f7f7f;

#define rdi() read<int>()
#define rdl() read<LL>()
#define rds(a) scanf("%s", a)
#define mk(i, j) make_pair(i, j)
#define pb push_back
#define fi first
#define se second
#define For(i, j, k) for (int i = j; i <= k; i ++)
#define Rep(i, j, k) for (int i = j; i >= k; i --)
#define Edge(i, u) for (int i = head[u]; i; i = e[i].nxt)

template<typename t> t read() {
	t x = 0; int f = 1; char c = getchar();
	while (c > '9' || c < '0') f = c == '-' ? -1 : 1 , c = getchar();
	while (c >= '0' && c <= '9') x = x * 10 + c - 48 , c = getchar();
	return x * f;
}

template<typename t> void write(t x) {
	if (x < 0){
		putchar('-'), write(-x);
		return;
	}
	if (x >= 10) write(x / 10);
	putchar(x % 10 + 48);
}

const int N = 100010;
struct pp {
	int x, y, i;
} p[N];
struct aa {
	int x, y, z;
} a[N * 2];

int f[N];
long long ans;

int i, n, cnt, x, y, fx, fy;

bool cmp1(pp a, pp b) {
	return a.x < b.x;
}
bool cmp2(pp a, pp b) {
	return a.y < b.y;
}
void add(int x, int y, int z) {
	a[++cnt].x = x, a[cnt].y = y, a[cnt].z = z;
}
bool cmp(aa a, aa b) {
	return a.z < b.z;
}
int getf(int x) {
	return f[x] == x ? x : f[x] = getf(f[x]);
}
int main() {
	n = rdi();
	for (i = 1; i <= n; i++) p[i].x = rdi(), p[i].y = rdi(), p[i].i = f[i] = i;
	sort(p + 1, p + n + 1, cmp1);
	for (i = 1; i < n; i++) add(p[i].i, p[i + 1].i, abs(p[i].x - p[i + 1].x));
	sort(p + 1, p + n + 1, cmp2);
	for (i = 1; i < n; i++) add(p[i].i, p[i + 1].i, abs(p[i].y - p[i + 1].y));
	sort(a + 1, a + cnt + 1, cmp);
	for (i = 1; i <= cnt; i++) {
		x = a[i].x, y = a[i].y;
		fx = getf(x), fy = getf(y);
		if (fx == fy) continue;
		ans += a[i].z;
		f[fx] = fy;
	}
	printf("%d\n", ans);
	return 0; 
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define int long long
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define ieps (int) 1e6
#define eps (int) 1e9
#define jmp exit(0)


int32_t main(){
	int n;
	int s = 0;
	cin>>n;
	vector<int> v(n);
	for(int i = 0;i<n;i++) cin>>v[i] , s+=v[i];
	if(s%10 != 0) cout<<s<<endl;
    else{
    	sort(v.begin() , v.end());
    	for(int i = 0;i<n;i++){
    		if((s - v[i])>= 0 && (s - v[i])%10 != 0){
    			cout<<s-v[i]<<endl;
    			return 0;
    		}
    	}
    	cout<<0<<endl;

    }
}

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

struct Point {
  int x;
  int y;
};

int main(int argc, char const *argv[])
{
  int N, M;
  cin >> N >> M;

  vector<Point> student(N);
  vector<Point> cp(M);


  for(int i = 0; i < N; ++i)
    cin >> student[i].x >> student[i].y;
  for(int i = 0; i < M; ++i)
    cin >> cp[i].x >> cp[i].y;

  for(int i = 0; i < N; ++i)
  {
    int shortest = 2 * pow(10, 8);
    int cp_num = 0;
    for(int j = 0; j < M; ++j)
    {
      int kyori = abs(student[i].x - cp[j].x) + abs(student[i].y - cp[j].y);
      if(kyori < shortest)
      {
        shortest = kyori;
        cp_num = j;
      }
    }
    cout << cp_num+1 << endl;
  }

  return 0;
}


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

namespace _0051
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = RInt();
            for (int i = 0 ; i < n ; i++)
            {
                string line = RSt();
                int min = int.Parse(string.Join("", line.OrderBy(x => x).ToArray()));
                int max = int.Parse(string.Join("", line.OrderByDescending(x => x).ToArray()));
                Console.WriteLine(max-min);
            }       
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
    }

}



Measured memory_bytes: 16252
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
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); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N, K;
  cin >> N >> K;
  string s;
  cin >> s;

  int ans = 0, r = 0, cont = 0;

  if (s[0] == '0') cont++;

  for (int l = 0; l < N; l++) {

    while (cont <= K && r < N) {
      if (r + 1 < N && s[r] == '1' && s[r + 1] == '0') cont++;
      r++;
    }

    ans = max(ans, r - l);

    if (l + 1 < N && s[l] == '0' && s[l + 1] == '1') cont--;
  }

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


Measured memory_bytes: 512
h, w, k = map(int,input().split())

field = [list(input()) for i in range(h)]

ans = 0
for maskr in range(0, 1<<h):
    for maskc in range(0, 1<<w):
        black = 0
        for i in range(h):
            for j in range(w):
                if ((maskr>>i) & 1) == 0 and ((maskc>>j) & 1) == 0 and field[i][j] == '#':
                    black +=1
        if black == k:
            ans += 1
print(ans)

Measured memory_bytes: 9092
//ITP1_5_D:   Structured Programming
#include <stdio.h>
int main(){
    int n, i, x;
    scanf("%d", &n);
    for (i=0; ++i<=n; ) {
        if (i%3==0){
            printf(" %d", i);
            continue;
        }
        x=i;
        do{
            if (x%10==3){
                printf(" %d", i);
                break;
            }
            x /= 10;
        }while(x);
    }
    putchar('\n');
}



Measured memory_bytes: 1924
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tommy6073
 */

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

class ABeginner {
public:
    void solve(std::istream &in, std::ostream &out) {
        int N, R;
        in >> N >> R;

        int inner_rating = R;
        if (N < 10) {
            inner_rating = R + 100 * (10 - N);
        }

        out << inner_rating;
    }
};


int main() {
	ABeginner solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long node[1000010];
long long mod=1e9+7;
long long cnt=0;
long long ans[20];
int main()
{
    long long h,w,n;
    cin >> h >> w >> n;
    long long cnt0=(h-2)*(w-2);
    while(n--)
    {
        long long x,y;
        cin >> x >> y;
        for(int i=-2;i<=0;i++)
        {
            for(int j=-2;j<=0;j++)
            {
                if(x+i>=1 && x+i<=h-2 && y+j>=1 && y+j<=w-2)
                {
                    node[cnt++]=mod*(x+i)+(y+j);
                }
            }
        }
    }
    sort(node,node+cnt);
    long long tmp=1;
    for(int i=0;i<cnt;i++)
    {
        if(node[i]==node[i+1])
            tmp++;
        else
        {
            ans[tmp]++;
            tmp=1;
            cnt0--;
        }
    }
    cout << cnt0 << "\n";
    for(int i=1;i<=9;i++)
    {
        cout << ans[i] << "\n";
    }
}


Measured memory_bytes: 7296
/* ***********************************************
Author        :yang12138
Created Time  :2017年05月18日 星期四 10时53分32秒
File Name     :C.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)

const int N=1e5+10;
pii p[N];

void solve(){
	int n;
	ll k;
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>p[i].first>>p[i].second;
	sort(p+1,p+n+1);
	int ans;
	for(int i=1;i<=n;i++){
		if(k<=p[i].second) { ans=p[i].first;break;}
		k-=p[i].second;
	}
	cout<<ans<<endl;
}

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
   	solve(); 
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
const int INF=1000000000;
const int MOD_2=998244353;

int main()
{
	LL N;
	LL A,B;
	cin>>N>>A>>B;
	
	LL shou=N/(A+B),amari=N%(A+B);
	if(amari<=A)cout<<shou*A+amari<<"\n";
	else cout<<shou*A+A<<"\n";
	return 0;
}
	

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

typedef long long ll;

long long powm(long long a, long long b, long long mod=1000000007){
    if(b<0) b+=mod-1;
    if(b>0){
        if(b%2==1) return a*powm(a*a%mod,b/2)%mod;
        else return powm(a*a%mod,b/2)%mod;
    }else{
        return 1;
    }
}


ll mod = 1e9+7;
int main(){
    ll n,m;
    cin>>n>>m;

    vector<ll> ptb(n+1,1);
    rep(i,n){
        ptb[0]*=m-i;
        ptb[0]%=mod;
    }
    rep(i,n){
        ptb[i+1]=ptb[i]*(n-i)%mod*powm(m-i,-1)%mod*powm(i+1,-1)%mod;
    }
    ll ans=ptb[0],tmp=0;
    rep(i,n+1){
        tmp+=(ptb[i]*(i%2 ? -1:1)+mod);
        if(tmp<0) tmp+=mod;
        tmp%=mod;
    }
    cout<<ans*tmp%mod<<endl;
    return 0;
}

Measured memory_bytes: 7152
N=int(input())
sum=0
f=-1
S=[int(input()) for _ in range(N)]
S.sort()        
for i in range(N):
        tmp=S[i]
        if tmp%10!=0 and f==-1:
                sum+=tmp
                f=tmp
        else:
                sum+=tmp
if sum%10==0:
        if f==-1:
                print(0)
        else:
                print(sum-f)
else:
        print(sum)


Measured memory_bytes: 3060
#include <iostream>
// B - ... (Triple Dots)

using namespace std;

int main() {
    int K;
    string S;

    cin >> K;
    cin >> S;

    if (S.size() <= K)
        cout << S << "\n";
    else
        cout << S.substr(0,K) << "..." << "\n";

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
long facctorialMethod(long k){
    long sum = 1;
    for (long i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000007;
    }
    return sum;
}
int main(){
    long n,m;
    std::cin >> n>>m;
    if(abs(n-m)>=2){
        std::cout << 0 << std::endl;
        exit(0);
    }
    long kain,kaim;
    kain=facctorialMethod(n);
    kaim=facctorialMethod(m);
    if(n==m){
        std::cout << (2*(kaim*kain) )%1000000007 << std::endl;
    }else{
        std::cout << (1*(kaim*kain) )%1000000007 << std::endl;
    }
    
    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

template<unsigned P> struct ModInt {
  using M = ModInt;
  unsigned v;
  constexpr ModInt() : v(0) {}
  constexpr ModInt(unsigned _v, int) : v(_v) {}
  template<class Z> ModInt(const Z& a) : v((a < 0 ? P - -a % P : a) % P) {}
  static constexpr unsigned p() { return P; }
  M operator+() const { return *this; }
  M operator-() const { return {v ? P - v : 0, 0}; }
  explicit operator bool() const noexcept { return v; }
  bool operator!() const noexcept { return !(bool)*this; }
  M& operator*=(M r) { v = (uint64_t)v * r.v % P; return *this; }
  M& operator/=(M r) { return *this *= r.inv(); }
  M& operator+=(M r) { if ((v += r.v) >= P) v -= P; return *this; }
  M& operator-=(M r) { if ((v += P - r.v) >= P) v -= P; return *this; }
  M inv() const {
    int a = v, b = P, x = 1, u = 0;
    while (b) {
      int q = a / b;
      swap(a -= q * b, b);
      swap(x -= q * u, u);
    }
    assert(a == 1);
    return x;
  }
  template<class Z> M pow(Z n) const {
    if (n < 0) return pow(-n).inv();
    M res = 1;
    for (M a = *this; n; a *= a, n >>= 1) if (n & 1) res *= a;
    return res;
  }
  friend M operator*(M l, M r) { return M(l) *= r; }
  friend M operator/(M l, M r) { return M(l) /= r; }
  friend M operator+(M l, M r) { return M(l) += r; }
  friend M operator-(M l, M r) { return M(l) -= r; }
  friend ostream& operator<<(ostream& os, M r) { return os << r.v; }
  friend bool operator==(M l, M r) { return l.v == r.v; }
  friend bool operator!=(M l, M r) { return !(l == r); }
};
using Mint = ModInt<(unsigned)1e9 + 7>;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  V< bitset<15> > g(n);
  for (int _ = 0; _ < m; ++_) {
    int u, v; cin >> u >> v, --u, --v;
    g[u][v] = g[v][u] = 1;
  }
  V<Mint> ipw(m + 1, 1);
  for (int i = 1; i <= m; ++i) {
    ipw[i] = ipw[i - 1] / 2;
  }

  auto fn = [&](int r) -> V<Mint> {
    V<Mint> dp(1 << n);
    for (int S = 0; S < 1 << n; ++S) if (S >> r & 1) {
      int c = 0;
      for (int u = 0; u < n; ++u) if (S >> u & 1) {
        for (int v = 0; v < n; ++v) if (~S >> v & 1) {
          c += g[u][v];
        }
      }
      dp[S] = ipw[c];
      V<> a(n);
      for (int u = 0; u < n; ++u) if (~S >> u & 1) {
        for (int v = 0; v < n; ++v) if (S >> v & 1) {
          a[v] += g[u][v];
        }
      }
      for (int T = (S - 1) & S; ; T = (T - 1) & S) {
        c = 0;
        for (int v = 0; v < n; ++v) if ((S ^ T) >> v & 1) {
          c += a[v];
        }
        dp[S] -= dp[T] * ipw[c];
        if (!T) break;
      }
    }
    return dp;
  };

  auto dp0 = fn(0);
  auto dp1 = fn(1);
  Mint res = 1;
  for (int S = 0; S < 1 << n; ++S) {
    int nS = S;
    for (int u = 0; u < n; ++u) if (S >> u & 1) {
      for (int v = 0; v < n; ++v) if (g[u][v]) {
        nS |= 1 << v;
      }
    }
    for (int T = nS ^ ~(~0U << n); ; T = (T - 1) & (nS ^ ~(~0U << n))) {
      res -= dp0[S] * dp1[T];
      if (!T) break;
    }
  }
  res *= Mint(2).pow(m);
  cout << res << '\n';
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];

  vi x(n);
  rep(i,n) {
    x[i] = a[i] - (i+1);
  }

  sort(x.begin(), x.end());
  int b = x[n/2];
  ll ans = 0;
  rep(i,n) {
    ans += abs(x[i] - b);
  }

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

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define pb emplace_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=998244353;

int32_t main(){
	int n;
	cin>>n;
	multiset<int> s;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		s.insert(a[i]);
	}	
	for(int i=0;i<n;i++){
		auto it=s.lower_bound(a[i]);
		s.erase(it);
		it=s.end();
		it--;
		cout<<*it<<endl;
		s.insert(a[i]);
	}
}

Measured memory_bytes: 12544
# -*- coding:utf-8 -*-


def main():
    n, m = map(int, input().split())
    c_num = n * 2

    if m - c_num < 0:
        result = m / 2
    else:
        result = n + ((m - c_num) / 4)
    print(int(result))


if __name__ == '__main__':
    main()


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

typedef long long int ll;
#define ent cout << "\n"
#define pb push_back
#define mp make_pair
#define sz(x) x.size()
#define pp pair < ll, ll > 
#define f(a, b) for(auto i = a;i < b;i++)
#define rev_f(a, b) for(auto i = b;i >= a;i--)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define fi first
#define se second  
#define st(x) sort(x.begin(), x.end()) 
#define rv(x) reverse(x.begin(), x.end()) 
#define cintc() ll tc;while(tc--) 
#define deb(x) cout << x << "\n";
#define cin() ll a; cin >> a;
#define cin2() ll a, b; cin >> a >> b
#define cin3() ll a, b, c; cin >> a >> b >> c
#define cinn(vect, n) def_v vect(n); f(0, n) cin >> vect[i]
#define coutn(vect, n)  f(0, n) {cout << vect[i] << " ";} cout << "\n";

typedef vector < ll > def_v;
typedef tuple< ll, ll, ll> def_tuple;
ll mod = 1e9 + 7,cnt = 0;

ll dist[1001][1001] = {0};
void bfs(vector < ll > graph[], ll start, ll n)
{
    ll vis[n + 1] = {0};

    vis[start] = 1;

    dist[start][start] = 0;
    queue < ll > q;
    q.push(start);

    while(!q.empty())
    {
        ll s = q.front();
        q.pop();

        for(ll j = 0;j < graph[s].size();j++)
        {
            ll x = graph[s][j];
            if(!vis[x])
            {
                vis[x] = 1;
                dist[start][x] = 1 + dist[start][s];
                q.push(x);
            }
        }
    }
}
void solve()
{
    ll n, m, cnt = 0;
    cin >> n >> m;

    cinn(obs, n);
    vector < ll > graph[n + 1];
    f(0, m)
    {
        cin2();

        auto it = lower_bound(graph[a].begin(), graph[a].end(), b);

        if(it != graph[a].end() && *it == b)
            continue;
        else
        {
            graph[a].pb(b);
            graph[b].pb(a);
        }
    }




    f(1, n + 1)
    {
        ll flag = 0, y = graph[i].size();
        if(y > 0)
        {
            for(ll j = 0;j < y;j++)
            {
                ll x = graph[i][j];

                if(obs[i - 1] > obs[x - 1])
                    flag++;
            }

            if(flag == y)
            {
                // cout << i << "\n";
                cnt++;
            }
        }
        else if(y == 0)
            cnt++;
    }

    cout << cnt << "\n";

    return ;
}
int main()
{
    fastio();
    ll tc = 1;
    // cin >> tc;
    while(tc--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 9772