akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

template<typename V> class segtree {
private:
    int n,sz;
    vector<V> node;
public:
    segtree(vector<V>& v){
        sz = (int)v.size();
        n = 1;
        while(n < sz){
            n *= 2;
        }
        node.resize(2*n-1);
        rep(i,sz){
            node[i+n-1] = v[i];
        }
        for(int i=n-2; i>=0; i--){
            node[i] = min(node[i*2+1],node[i*2+2]);
        }
    }
    void update(int k,V a)
    {
    	k += n-1;
    	node[k] = a;
    	while(k>0){
    		k = (k-1)/2;
    		node[k] = min(node[2*k+1],node[2*k+2]);
    	}
    }
    V query(int a,int b,int k=0,int l=0,int r=-1)
    {
        if(r < 0) r = n;
    	if(r <= a || b <= l){
    		return numeric_limits<V>::max();
    	}
    	if(a <= l && r <= b){
    		return node[k];
    	}else{
    		V vl = query(a,b,2*k+1,l,(l+r)/2);
    		V vr = query(a,b,2*k+2,(l+r)/2,r);
    		return min(vl,vr);
    	}
    }
    void print()
    {
        rep(i,sz){
            cout << query(i,i+1) << " ";
        }
        cout << endl;
    }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vl x(n),s(n);
    vl sm(n+1);
    rep(i,n){
        cin >> x[i] >> s[i];
    }
    sm[0] = 0;
    rep(i,n){
        sm[i+1] = sm[i] + s[i];
    }
    vl dp(n),tmp(n);
    rep(i,n){
        tmp[i] = sm[i+1] - x[i];
    }
    rep(i,n){
        dp[i] = sm[i] - x[i];
    }
    segtree<ll> st(dp);
    ll mx = 0;
    rep(i,n){
        cmx(mx,tmp[i]-st.query(0,i+1));
    }
    cout << mx << "\n";
    return 0;
}


Measured memory_bytes: 14208
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N;
	M = 2 * N - 1;
	vector<int>v(M);
	for (int i = 0; i < M; i++) {
		cin >> v[i];
	}
	L = 2;
	R = M;
	while (R - L > 1) {
		int mid = (R + L + 1) / 2;
		vector<bool>flag(M);
		for (int i = 0; i < M; i++) {
			if (v[i] >= mid) {
				flag[i] = true;
			}
		}
		int dif = 1000000;
		bool ret = flag[0];
		for (int i = 1; i < M - 1; i++) {
			if (flag[i] == flag[i - 1] || flag[i] == flag[i + 1]) {
				if (dif > abs(N - 1 - i)) {
					dif = abs(N - i - 1);
					ret = flag[i];
				}
			}
		}
		if (ret) {
			L = mid;
		}
		else {
			R = mid;
		}
	}
	cout << L << endl;
	return 0;
}

Measured memory_bytes: 1152
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    a, b = geta(int)

    if b == 1:
        print(0)
        exit()

    n = 1
    while a * n - n + 1 < b:
        n += 1

    print(n)


if __name__ == "__main__":
    main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define long long long
#define read cin >>
#define echo cout <<
#define fin << endl
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)

// for debug macro
bool global_debug_flag = true;
#define DEBUG(val) \
  if (global_debug_flag) cout << #val << " = " << val << endl

int main() {
  int n;
  cin >> n;
  vector<int> data;
  vector<double> xi;
  vector<double> yi;
  REP(i, n) { data.push_back(i); }
  REP(i, n) {
    double x, y;
    cin >> x >> y;
    xi.push_back(x);
    yi.push_back(y);
  }
  double sum = 0;
  double count = 0;
  do {
    REP(i, n - 1) {
      int from = data[i];
      int to = data[i + 1];
      sum +=
          sqrt(pow((xi[to] - xi[from]), 2.0) + pow((yi[to] - yi[from]), 2.0));
    }
    count++;
  } while (next_permutation(data.begin(), data.end()));
  std::cout << std::fixed << std::setprecision(10);
  cout << sum / count << endl;
}


Measured memory_bytes: 256
using System;
class clas{
    public static void Main(){
        int[] mountain = new int[10];
        int a, b, c, d = 0, e = 0, f = 0;
        string x;
        for (int i = 0; i < 10; i++){
            x = Console.ReadLine();
            mountain[i] = int.Parse(x);
        }
        a = mountain[0];
        b = mountain[1];
        c = mountain[2];
        for(int n = 3; n < 10; n++){
            if (a <= b && a <= c && a <= mountain[n]){
                a = mountain[n];
                continue;
            }
            if (b <= a && b <= c && b <= mountain[n]){
                b = mountain[n];
                continue;
            }
            if (c <= b && c <= a && c <= mountain[n]){
                c = mountain[n];
                continue;
            }
        }
        if (a <= b && a <= c ){
            f = a;
            if (b <= c){
                e = b;
                d = c;
            }else{
                e = c;
                d = b;
            }
        }
        if (b <= a && b <= c ){
            f = b;
            if (a <= c)
            {
                e = a;
                d = c;
            }
            else
            {
                e = c;
                d = a;
            }
        }
        if (c <= b && c <= a ){
            f = c;
            if (b <= a)
            {
                e = b;
                d = a;
            }
            else
            {
                e = a;
                d = b;
            }
        }
        Console.WriteLine(d);
        Console.WriteLine(e);
        Console.WriteLine(f);
    }
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

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

    N -= (N / K) * K;
    PR(MIN(N,abs(N-K)));

    return 0;
}

/*



*/

Measured memory_bytes: 3636
n = int(input())

ans = ""
# 0なら0
if n == 0:
    ans = "0"
else:
    while(n != 0):  # 2で割り切れないならその位は1
        if n % 2 != 0:
            ans = "1" + ans
            n -= 1  # "その位が1に決まった後の残りは-1した数
        else:  # 2で割り切れるならその位は0
            ans = "0" + ans
        n = n // (-2)
print(ans)


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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int a[2 * mx5], x[2 * mx5];

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

    for(int i = 1; i <= n; i++)
        cin >> a[i], x[i] = a[i];

    sort(a + 1, a + n + 1);

    int A = a[n / 2], B = a[n / 2 + 1];
    for(int i = 1; i <= n; i++){

        if(A == B){
            cout << A << '\n';
            continue;
        }

        if(x[i] < B)
            cout << B << '\n';
        else
            cout << A << '\n';
    }
    return 0;
}


Measured memory_bytes: 5124
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define REPI(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) REPI(i,0,n)

typedef long long ll;

int SURP = 1000000007;

int main(){
	int A,B;
	cin >> A >> B;
	string ret;
	if(A <=8 && B <= 8){
		ret = "Yay!";
	}else{
		ret = ":(";
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

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

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

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

ll gcds(ll a, ll b){
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

int main() {
    ll n, x, mo; cin >> n >> x >> mo;
    ll ans = x;
    vector<ll> ar = {x};
    map<ll,int> m;
    m[x] = 0;
    ll haba = 0; int le = 0; int cnt = 0;
    bool t = false;
    rep(i,n-1){
        ll ima = ar[i] * ar[i] % mo;
        if (m.find(ima) == m.end()){
            m[ima] = i+1;
            ar.emplace_back(ima);
            ans += ima;
        }
        else {
            haba = i+1 - m[ima];
            le = m[ima];
            t = true;
            cnt = i;
            break;
        }
    }
    if (t){
        ll k = (n-1-cnt) / haba;
        ll wa = 0LL;
        rep(i,haba) wa += ar[le+i];
        ans += k * wa;
        rep(i,(n-1-cnt) % haba) ans += ar[le+i];
        cout << ans << endl;
    }
    else cout << ans << endl;
}

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

int main(){
    int n,m,t,p;
    while(cin >> m >> n >> t >> p, n){
        vector<vector<int> > v(n,vector<int>(m,1));
        while(t--){
            int d,c;
            cin >> d >> c;
            n = v.size();
            m = v[0].size();
            if(d == 1){
                int x = max(m-c,c);
                vector<vector<int> > ne(n,vector<int>(x,0));
                rep(i,n)rep(j,x){
                    if(j+c < m)ne[i][j] += v[i][j+c];
                    if(c-j-1 >= 0)ne[i][j] += v[i][c-j-1];
                }
                v = ne;
            }else{
                int x = max(n-c,c);
                vector<vector<int> > ne(x,vector<int>(m,0));
                rep(i,x)rep(j,m){
                    if(i+c < n)ne[i][j] += v[i+c][j];
                    if(c-i-1 >= 0)ne[i][j] += v[c-i-1][j];
                }
                v = ne;
            }
            /*
            cout << endl;
            rep(i,v.size()){
                rep(j,v[0].size())cout << " " << v[i][j];cout << endl;
            }
        */
        }
        n = v.size();
        m = v[0].size();

        while(p--){
            int x,y;
            cin >> x >> y;
            cout << v[y][x] << endl;
        }
    }
}



Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

	ll n,sum=0;
	cin>>n;
	ll a[n+1],b[n+1]={0};
	map<ll,ll>m;
	for(ll i=1;i<=n;i++)
		{
			cin>>a[i];
			b[a[i]]++;
			sum-=m[a[i]];
			m[a[i]]=(b[a[i]]*(b[a[i]]-1))/2;
			sum+=m[a[i]];
		}
	for(ll i=1;i<=n;i++)
	{
		ll k=sum-m[a[i]];
		k+=((b[a[i]]-1)*(b[a[i]]-2))/2;
		cout<<k<<endl;
	}	




	
	
}


Measured memory_bytes: 12672
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define MAXN 200 + 5
const long long INF = 1LL << 60;
const int inf = 1 << 30;

void printVec(std::vector<int> &vec) {
  std::cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}
 
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; }

long long  mod = 1e9 + 7;

int main(){
  long long k, n; cin >> k >> n;
  vector<long long > a(n);
  rep(i, 0, n){
    cin >> a[i];
  }
  long long ans = INF;
  for(int i=0; i<n; i++){
    long long dist = INF;
    if(i == 0){
      dist = min(a[n-1] - a[0], k - (a[1] - a[0]));
    }else if(i == n-1){
      dist = min(a[n - 1] - a[0], k - (a[n-1] - a[n-2]));
    }else{
      dist = min(k - (a[i + 1] - a[i]), k - (a[i] - a[i - 1]));
    }
    ans = min(ans, dist);
  }
  cout << ans << endl;
}
     


Measured memory_bytes: 1792
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 1005

enum Type{
	FROM_S,
	FROM_T,
};


//辺を表す構造体(行先、容量、逆辺のインデックス)
struct Edge{
	Edge(int arg_to,int arg_capacity,int arg_rev_index,bool arg_is_rev){
		to = arg_to;
		capacity = arg_capacity;
		rev_index = arg_rev_index;
		is_rev = arg_is_rev;
	}
	int to,capacity,rev_index;
	bool is_rev;
};

int V,E;
int N,M,S,T;

vector<Edge> G[NUM]; //グラフの隣接リスト表現
bool used[NUM]; //DFSですでに調べたかのフラグ
bool can_reach[2][NUM]; //S,Tから各点へ到達できるかのチェック

//fromからtoへ向かう容量capacityの辺をグラフに追加する
void add_edge(int from,int to,int capacity){
	G[from].push_back(Edge(to,capacity,G[to].size(),false));
	G[to].push_back(Edge(from,0,G[from].size()-1,true)); //逆辺の、初期容量は0
}

//増加パスをDFSで探す
int dfs(int node_id,int sink,int flow){
	if(node_id == sink)return flow; //終点についたらflowをreturn
	used[node_id] = true;

	for(int i = 0; i < G[node_id].size(); i++){ //node_idから出ているエッジを調査
		Edge &e = G[node_id][i];
		if(used[e.to] == false && e.capacity > 0){ //エッジの先のノードに未訪問で、かつエッジに流す余裕がある場合
			int tmp_flow = dfs(e.to,sink,min(flow,e.capacity)); //流せるだけ流す
			if(tmp_flow > 0){ //流せた場合
				e.capacity -= tmp_flow; //流した分、エッジの容量を削減する
				G[e.to][e.rev_index].capacity += tmp_flow; //逆辺の容量を、流した分だけ増加させる
				return tmp_flow;
			}
		}
	}
	return 0;
}

void reach_check(Type type,int node_id){

	can_reach[type][node_id] = true;
	int base;

	if(type == FROM_S){
		base = 1;
	}else{
		base = 0; //★逆向きに進めれば良いため★
	}

	for(int i = 0; i < G[node_id].size(); i++){
		if(G[node_id][i].capacity == base && can_reach[type][G[node_id][i].to] == false){
			reach_check(type,G[node_id][i].to);
		}
	}
}


//sourceからsinkへの最大流を求める
int max_flow(int source,int sink){ //source:始点 sink:終点
	int flow = 0,add;
	while(true){ //増加パスが存在する限り、流量を追加し続ける
		for(int i = 0; i < V; i++)used[i] = false;
		add = dfs(source,sink,BIG_NUM);
		if(add == 0)break;
		flow += add;
	}
	return flow;
}

void func(){

	for(int i = 0; i < N; i++){
		G[i].clear();
		can_reach[FROM_S][i] = false;
		can_reach[FROM_T][i] = false;
	}

	S--;
	T--;

	int from,to;
	for(int loop = 0; loop < M; loop++){
		scanf("%d %d",&from,&to);
		from--;
		to--;
		add_edge(from,to,1);
	}

	V = N;

	int FLOW = max_flow(S,T);
	//printf("FLOW:%d\n",FLOW);
	//return;
	int MAX_FLOW = FLOW;

	reach_check(FROM_S,S);
	reach_check(FROM_T,T);

	int num_edge = 0,diff;

	for(int i = 0; i < N; i++){
		for(int k = 0; k < G[i].size(); k++){
			if(G[i][k].is_rev == true || G[i][k].capacity == 0 ||
					can_reach[FROM_S][G[i][k].to] == false || can_reach[FROM_T][i] == false)continue; //逆辺または、最大流達成のために使用した辺はSKIP

			//経路に重なりはないと仮定してみる
			num_edge++;
			MAX_FLOW = FLOW+1;

		}
	}

	printf("%d %d\n",MAX_FLOW,num_edge);
}


int main(){

	while(true){
		scanf("%d %d %d %d",&N,&M,&S,&T);
		if(N == 0 && M == 0 && S == 0 && T == 0)break;

		func();
	}

	return 0;
}



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

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> p.at(i);
        if(p.at(i)-1!=i){
            cnt++;
        }
    }
    if(cnt>2){
        cout << "NO" << endl;
    }else{
        cout <<"YES"<< endl;
    }

}

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

unordered_set<string> generate_lun(int n)
{
	if(n==1)
	{
		unordered_set<string> st;
		st.insert("0");st.insert("1");st.insert("2");
		return st;
	}
	else
	{
		unordered_set<string> r2;
		unordered_set<string> r = generate_lun(n-1);
		for(auto it:r)
		{
			r2.insert("0"+it);r2.insert("1"+it);r2.insert("2"+it);
		}
		return r2;
	}
}

bool check_lun(long long int k)
{
	long long int prev=k%10,cp=k/10;
	// if()
	while(cp>0)
	{
		if(abs(prev-cp%10)>1)
			return false;
		prev=cp%10;
		cp/=10;
	}
	return true;
}

int main()
{
	int n;
	cin>>n;
	set<long long int> v;
	for(int i=1;i<=9;i++)
	{	
		unordered_set<string> st = generate_lun(i);
		for(auto it:st)
		{
			int pref=0;
			int mn=20,mx=-20;
			for(int j=0;j<it.size();j++)
			{
				pref+=it[j]-48-1;
				mn=min(pref,mn);
				mx=max(pref,mx);
			}
			int s=0;
			if(mn>=0)
				s=1;
			else
				s=abs(mn);
			for(int j=s;j<=min(9-mx,9);j++)
			{
				long long int d=j;
				for(int k=0;k<it.size();k++)
				{
					d=d*10+(d%10+it[k]-48-1);
				}
				v.insert(d);
			}
		}
	}
	for (int i = 1; i <= 9; ++i)
	{
		v.insert(i);
	}
	auto it=v.begin();
	for (int i = 0; i < n-1; ++i)
	{
		it++;
	}
	cout<<*it;
	return 0;
}

Measured memory_bytes: 11520
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<vector>
using namespace std;
int main()
{
    int a,b; cin>>a>>b;
    if(b%2!=0)
    {
        cout<<"No";
    }
    else
    {
        if(b<=4*a && b>=2*a)
            cout<<"Yes";
        else
            cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define rep2(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
using ll = long long;

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(a>b){a=b;return true;}return false;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
vector<string> split(const string&s,char d){vector<string>r;stringstream ss(s);string k;while(getline(ss,k,d))if(!k.empty())r.pb(k);return r;}

// Template ends here

int main() {
    int n, a, b; string s; cin >> n >> a >> b >> s;
    int cnt = 0, overseas_students = 0;
    
    for (char x: s) {
        bool pass = 0;

        switch (x) {
        case 'a':
            pass = cnt < (a + b);
            break;

        case 'b':
            pass = (cnt < (a + b)) && (overseas_students < b);
            overseas_students += pass;
            break;

        default:
            break;
        }
        
        Yes(pass); cnt += pass;
    }
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <iomanip>
#include <math.h>
#define PI acos(-1)
#include <cmath>


using namespace std;

int main(){
	
	
	double R,A;
	cin >> R;
	A=2*R*PI;
	
//	Fahrenheit=Celsius*9/5+32;
//	cout << fixed;
	
	cout << setprecision(20) << A;
	
	return 0;
	
	
	
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

int n, q;
vi in;

vector<ll> s0, s1;
vector<ll> sum;

ll Sum(int l, int r){
  return sum[r] - (l == 0 ? 0 : sum[l - 1]);
}

int Fge(int to){
  return lower_bound(all(in), to) - in.begin();
}

pii Bounds(int x, int bp){
  if(bp == 0) return mp(0, 0);
  if(in[bp] <= x) return mp(0, 0);


  int re = bp - 1, le_need, le_poss;
  if(in[re] < x){
    le_poss = Fge(x - (in[bp] - x));
    return mp(0, re - le_poss + 1);
  } else {
    le_need = Fge(x - (in[re] - x));
    le_poss = Fge(x - (in[bp] - x));
    return mp(re - le_need + 1,
              re - le_poss + 1);
  }
}

const int LESS = 0;
const int MORE = 1;
const int FINE = 2;
int Side(int x, int bp){
  int me = n - bp;
  auto lo_hi = Bounds(x, bp);

  if(lo_hi.fi > me) return MORE;
  if(lo_hi.se < me - 1) return LESS;

  return FINE;
}

ll Solve(int x){
  if(x >= in[n - 1]) return s0[n - 1];

  int lo = 0, mid, hi = n - 1;
  while(true){
    if(lo + 1 >= hi){
      if(Side(x, lo) == FINE) mid = lo;
      else mid = hi;
      break;
    }

    mid = (lo + hi) / 2;
    int sd = Side(x, mid);
    if(sd == FINE) break;
    if(sd == LESS) lo = mid;
    else hi = mid;
  }

  ll me = Sum(mid, n - 1);

  int me_take = n - mid;
  int he_take = n - mid;
  if(he_take > Bounds(x, mid).se) --he_take;

  mid -= he_take + 1;
  if(mid >= 0){
    if((me_take + he_take) % 2 == 0)
      me += s0[mid];
    else
      me += s1[mid];
  }

  return me;
}

int main(){
  scanf("%d%d", &n, &q);
  in.resize(n);
  for(int& e : in) scanf("%d", &e);

  s0.resize(n);
  s1.resize(n);
  s0[0] = in[0];
  s1[0] = 0;
  for(int i = 1;i < n;++i)
    s0[i] = in[i] + s1[i - 1],
    s1[i] = s0[i - 1];

  sum.resize(n);
  sum[0] = in[0];
  for(int i = 1;i < n;++i)
    sum[i] = sum[i - 1] + in[i];

  for(int i = 0;i < q;++i){
    int x;
    scanf("%d", &x);
    printf("%lld\n", Solve(x));
  }

  return 0;
}


Measured memory_bytes: 4480
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <deque>
#include <stack>

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

using namespace std;

typedef long long ll;

struct T{
	bool t;
	ll v;
};

int pt[13][3] = {
	{0, 0, 0},
	{1, 0, 0},
	{0, 1, 0},
	{0, 0, 1},
	{0, 1, 1},
	{1, 0, 1},
	{1, 1, 0},
	{0, 1, 2},
	{0, 2, 1},
	{1, 0, 2},
	{1, 2, 0},
	{2, 0, 1},
	{2, 1, 0}
};

string str;

int main(){
	cin >> str;

	ll result;
	rep(a, 13){
		int* p = pt[a];

		deque<T> q;
		stack<int> s;
		string n = "";
		for(auto& c: str){
			if('0' <= c && c <= '9'){
				n += c;
				continue;
			}
			if(!n.empty()){
				q.push_back(T{false, stoll(n)});
				n = "";
			}
			if(c == '('){
				s.push(3);
				continue;
			}
			if(c == ')'){
				while(s.top() != 3){
					q.push_back(T{true, s.top()});
					s.pop();
				}
				s.pop();
				continue;
			}
			int type;
			if(c == '+'){
				type = 0;
			}
			else if(c == '-'){
				type = 1;
			}
			else{
				type = 2;
			}
			while(!s.empty() && p[s.top()] >= p[type] && s.top() != 3){
				q.push_back(T{true, s.top()});
				s.pop();
			}
			s.push(type);
		}
		if(!n.empty()){
			q.push_back(T{false, stoll(n)});
		}
		while(!s.empty()){
			q.push_back(T{true, s.top()});
			s.pop();
		}

		/*
		if(a == 6){
			rep(i, q.size()){
				auto v = q[i];
				if(v.t){
					if(v.v == 0){
						printf("+\n");
					}
					else if(v.v == 1){
						printf("-\n");
					}
					else{
						printf("*\n");
					}
				}
				else{
					printf("%lld\n", v.v);
				}
			}
		}
		*/

		stack<ll> calc;
		while(!q.empty()){
			auto v = q.front();
			q.pop_front();
			if(v.t){
				ll b = calc.top();
				calc.pop();
				ll a = calc.top();
				calc.pop();
				if(v.v == 0){
					calc.push(a + b);
				}
				else if(v.v == 1){
					calc.push(a - b);
				}
				else{
					calc.push(a * b);
				}
			}
			else{
				calc.push(v.v);
			}
		}

		if(a == 0){
			result = calc.top();
		}
		else{
			result = max(calc.top(), result);
		}
	}
	printf("%lld\n", result);
	return 0;
}

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

int main() {
  int N,D;
  cin >>N >>D;
  vector<vector<int>> X(N,vector<int>(D));
  for(int i=0;i<N; i++){
    for(int j=0;j<D; j++)
    cin >> X[i][j];
  }
  int answer=0;
  for(int i=0; i<N; i++){
    for(int j=0; j<i; j++){
      int r=0;
      //rは距離の二乗
      for(int k=0; k<D; k++){
        r=r+(X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
      }
      int s=sqrt(r);
    if(sqrt(r)==s)
      answer++;
    }
  }
  cout <<answer;  
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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


long long beki(long long a,int n)
{
  long long s=1LL;
  while(n){
    if(n%2)s=s*a;
    a=a*a;
    n/=2;
  }
  return s;
}

int main(void) {
  int i,j;
  int n,p;
  cin>>n>>p;
  int a=0,b=0;
  rep(i,n){
    int t;
    cin>>t;
    if(t%2)b++;
    else a++;
  }
  ll ans=beki(2,n);
  if(b)cout<<ans/2<<endl;
  else if(p)cout<<0<<endl;
  else cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> x(n), y(n), h(n);
  for(int i = 0; i < n; i++)
  {
    cin >> x[i] >> y[i] >> h[i];
  }

  int MAX = 100;

  for(int posY = 0; posY <= MAX; posY++)
  {
    for(int posX = 0; posX <= MAX; posX++)
    {
      int needH = -1;
      for(int i = 0; i < n; i++)
      {
        if(h[i] > 0) {
          int tmp = h[i] + abs(posY - y[i]) + abs(posX - x[i]);
          if(needH == -1) {
            needH = tmp;
          } else {
            if(needH != tmp) {
              needH = -2;
              break;
            }
          }
        }
      }

      if(needH == -2) continue;

      for(int i = 0; i < n; i++)
      {
        if(h[i] == 0) {
          int dist = abs(posY - y[i]) + abs(posX - x[i]);
          if(needH > dist) {
            needH = -2;
            break;
          }
        }
      }
      if(needH == -2) continue;

      cout << posX << " " << posY << " " << needH << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
from itertools import combinations as comb

N = int(input())
n = N-N%2
s = {(i, n+1-i) for i in range(1, N+1) if i<n+1-i}

l = [i for i in comb(range(1, N+1), 2) if not i in s]
print(len(l))
for i in l:
    print(*i)

Measured memory_bytes: 3996
N, M = map(int,input().split())
connect = [list(map(int,input().split())) for i in range(M)]
p = list(map(int,input().split()))

def JudgeDigitN(x,n):
    return x >> n & 1 == 1
ans = 0
for i in range(2**N):
    can = True
    for line,amari in zip(connect,p):
        count = 0
        for s in line[1:]:
            if JudgeDigitN(i,s-1):
                count += 1
        if count%2 != amari:
            can = False
    if can:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int MAX_N=1010;

int n,k; string ans;
vector<int> G[MAX_N];
int dep[MAX_N];
string M[MAX_N];

void dfs(int v,int p,string now){
    cout << now << M[v] << '\n';
    now+='.';
    for (int u:G[v]){
        if (u==p) continue;
        dep[u]=dep[v]+1;
        dfs(u,v,now);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    for (int i=0;i<n;++i){
        cin >> k >> M[i];
        if (i) G[--k].emplace_back(i);
    }
    dep[0]=0;
    dfs(0,-1,"");
}


Measured memory_bytes: 4064
N, K = map(int, input().split())
A = list(map(int, input().split()))

zero = [0] * 50
one = [0] * 50

for a in A:
  for d in range(40):
    r = a % 2
    if r:
      one[d] += 1
    else:
      zero[d] += 1
    a = int(a / 2)

k = [0] * 50
d = 0
while K:
  r = K % 2
  if r:
    k[d] = 1
  K = int(K / 2)
  d += 1

d = 49
flag = 0
max = 0
while d >= 0:
  if flag == 0:
    if k[d] == 0:
      max += one[d] * pow(2, d)
    else:
      if zero[d] >= one[d]:
        max += zero[d] * pow(2, d)
      else:
        max += one[d] * pow(2, d)
        flag = 1
  else:
    if zero[d] >= one[d]:
      max += zero[d] * pow(2, d)
    else:
      max += one[d] * pow(2, d)
  d -= 1

print(max)

Measured memory_bytes: 14700
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
for d1, d2, d3 in zip(D, D[1:], D[2:]):
    if d1[0] == d1[1] and d2[0] == d2[1] and d3[0] == d3[1]:
        print("Yes")
        exit()
print("No")


Measured memory_bytes: 9184
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll i,l=0,r,N,K,f=1,ans=0;
  string s;cin>>s;
  cin>>N;
  r=s.size()-1;
  K=s.size();
  while(l<K&&s[l]==s[0])l++;
  if(l==K){
    ans=N*K/2;
    cout<<ans<<endl;
    return 0;
  }
  if(s[0]!=s[K-1]){
    rep1(i,K){
      if(s[i]==s[i-1]){
        ans++;
        i++;
      }
    }
    cout<<ans*N<<endl;
    return 0;
  }
  while(s[r]==s[K-1])r--;
  For(i,l,r+1){
    if(s[i]==s[i-1]){
      ans++;
      i++;
    }
  }
  ans*=N;
  ans+=l/2;
  ans+=(K-r-1)/2;
  f=(l+K-r-1)/2;
  ans+=f*(N-1);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D[] = new int[N + 1];
		for (int i = 0; i < N; i++)
			D[i] = sc.nextInt();// initialized
		D[N] = N + 100;
		if (D[0] != 0) {
			System.out.println(0);
			return;
		}
		Arrays.sort(D);
		long sum = 1;
		long cnt = 0;
		long bcnt = 0;
		long memo = -1;
		long waru = 998244353;
		for (int i = 0; i <= N; i++) {
			if(D[i]==0&&i!=0) {
				System.out.println(0);
				return;
			}
			if (memo == D[i])
				cnt++;
			else {
				if (memo + 1 != D[i] && i != 0 && i != N) {
					System.out.println(0);
					return;
				}
				long tmp = 1;
				for (int j = 0; j < cnt + 1; j++) {
					tmp *= (bcnt + 1);
					tmp %= waru;
				}
				// tmp = (long)Math.pow(bcnt+1,cnt+1);
				long memosum = sum;
				if (Long.MAX_VALUE / tmp < sum) {
					for (int j = 1; j < tmp; j++) {
						sum += memosum;
						sum %= waru;
					}
				} else {
					sum *= tmp;
					sum %= waru;
				}
				bcnt = cnt;
				cnt = 0;
			}
			memo = D[i];
		}

		System.out.println(sum % waru);

	}
}

Measured memory_bytes: 60380
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var xy = xArray(-1,n,n);
  for(var i = 0; i < n; i++){
    var a = o.a();
    for(var j = 0; j < a; j++){
      var x = o.a(), y = o.a();
      x--;
      xy[i][x] = y;
    }
  }
  var ans = 0;
  for(var i = 1; i < 1 << n; i++){
    var set = new Set();
    var j = i, k = 0, mx = 0;
    while(j){
      if(j & 1)set.add(k), mx++;
      j >>= 1;
      k++;
    }
    if(mx <= ans)continue;
    var flag = 1;
    for(var j of set){
      for(var k = 0; k < n && flag; k++){
        var t = xy[j][k];
        if(t === -1)continue;
        if(t === 1 && set.has(k))continue;
        if(t === 0 && !set.has(k))continue;
        flag = 0;
      }
    }
    if(flag)ans = mx;
  }
  return ans;
}

Measured memory_bytes: 24992
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        int h=Integer.parseInt(st.nextToken());
        int w=Integer.parseInt(st.nextToken());
        System.out.println((h*w)+" "+((h+w)*2));
    }
}

Measured memory_bytes: 24280
#include<bits/stdc++.h>
using namespace std;
char c[101];
int main()
{
	int i=0;
	long long s;
	scanf("%s",&c);
	scanf("%lld",&s);
	while(i<strlen(c)&&c[i]=='1')
		i++;
	if(i>=s)
		printf("1",s);
	else
		printf("%c",c[i]);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = 3.14159265358979323846;
const ll MOD = 998244353;

int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string s;
	cin >> s;
	if (s.size() <= n) {
		cout << s;
	}
	else {
		for (int i = 0; i < n; i++) {
			cout << s[i];
		}
		cout << "...";
	}
}

Measured memory_bytes: 3616
import math
a, b = map(int, input().split())
result = 0
m = 99999
for i in range(1, 10001):
    temp1 = math.floor(i * (8/100))
    temp2 = math.floor(i * (10/100))
    if a == temp1 and b == temp2:
        result = i
        break
if result == 0:
    print(-1)
else:
    print(result)

Measured memory_bytes: 3060
str = [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]
k = gets.to_i
puts str[k-1]

Measured memory_bytes: 1788
#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>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

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

namespace std {
    template <>
    class hash<std::pair<int, int>> {
    public:
        size_t operator()(const std::pair<int, int>& x) const{
            return hash<int>()(x.first) ^ hash<int>()(x.second);
        }
    };
}

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

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

vector<long long> Divisor(long long n) {
    vector<long long> ret;
    for(long long i=1; i*i<=n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i*i!=n) ret.push_back(n / i);
        }
    }
    return ret;
}

const int INF = 100000005;
int dp[5000];

int main(void) {
    int N, M; cin >> N >> M;
    vector<vector<int>> keys(M);
    for (int i = 0; i < M; i++) {
        int a, b; cin >> a >> b;
        keys[i].push_back(a);
        for (int j = 0; j < b; j++) {
            int c; cin >> c;
            c--;
            keys[i].push_back(c);
        }
    }

    for (int i = 0; i < 5000; i++) {
        dp[i] = INF;
    }
    dp[0] = 0;

    vector<int> flags(N);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (j < i) {
                flags[j] = 1;
            } else {
                flags[j] = 0;
            }
        }
        sort(flags.begin(), flags.end());
        do {
            int state = 0;
            for (int j = 0; j < N; j++) {
                if (flags[j]) {
                    state += (1 << j);
                }
            }

            for (int j = 0; j < M; j++) {
                int next = state;
                int yen = keys[j][0];
                for (int k = 1; k < keys[j].size(); k++) {
                    if ((next & (1 << keys[j][k])) == 0) {
                        next += (1 << keys[j][k]);
                    }
                }
                dp[next] = min(dp[next], dp[state] + yen);
            }
        } while (next_permutation(flags.begin(), flags.end()));
    }
    // for (int i = 0; i < (1 << N); i++) {
    //     cout << dp[i] << endl;
    // }
    if (dp[(1 << N) - 1] >= INF) cout << -1 << endl;
    else cout << dp[(1 << N) - 1] << endl;

}


Measured memory_bytes: 888
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
	int x, y;
	while (1) {
		scanf("%d %d", &x, &y);
		if (!x && !y) break;
		printf("%d %d\n", min(x, y), max(x, y));
	}
	return 0;
}

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

int N, K;
int rec[110][110];

//primal-dual
struct edge { ll to, cap, cost, rev; };

const int MAX_V = 110;
int V;
vector<edge>G[MAX_V];
ll dist[MAX_V];
ll ans = inf;
int prevv[MAX_V], preve[MAX_V];

void add_edge(int from, int to, int cap, int cost) {
	edge fe = { to,cap,cost,(int)G[to].size() };
	edge toe = { from,0,-cost,(int)G[from].size() };
	G[from].pb(fe);
	G[to].pb(toe);
}

ll min_cost_flow(int s, int t, int f) {
	ll res = 0;
	while (f > 0) {
		//Bellman-Ford
		for (int i = 0; i < V; i++)dist[i] = inf;
		dist[s] = 0;

		for (int i = 0; i < V - 1; i++) {
			for (int j = 0; j < V; j++) {
				for (int k = 0; k < G[j].size(); k++) {
					edge &e = G[j][k];
					if (dist[j] == inf)continue;
					if (e.cap > 0 && dist[e.to] > dist[j] + e.cost) {
						dist[e.to] = dist[j] + e.cost;
						prevv[e.to] = j;
						preve[e.to] = k;
					}
				}
			}
		}

		if (dist[t] == inf)return -1;

		//s-t最短路に沿って目いっぱい流す
		ll d = f;
		for (int v = t; v != s; v = prevv[v]) {
			d = min(d, G[prevv[v]][preve[v]].cap);
		}
		f -= d;
		res += d * dist[t];
		for (int v = t; v != s; v = prevv[v]) {
			edge &e = G[prevv[v]][preve[v]];
			e.cap -= d;
			G[v][e.rev].cap += d;
		}

		//答えの記録&使われているマスをチェック
		if (ans > res) {
			ans = res;
			memset(rec,0,sizeof(rec));
			for (int i = 1; i <= N; i++) {
				for (int j = 0; j < G[i].size(); j++) {
					edge e = G[i][j];
					if (e.cap == 0)rec[i][e.to] = 1;
				}
			}
		}
	}
	return res;
}
//primal-dual　ここまで


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


	cin >> N >> K;
	V = 2 * N + 2;
	for (int i = 1; i <= N; i++)add_edge(0,i,K,0);
	for (int i = N + 1; i <= 2 * N; i++)add_edge(i,2*N+1,K,0);
	for (int i = 1; i <= N; i++) {
		for (int j = N+1; j <= 2*N; j++) {
			int A;
			cin >> A;
			add_edge(i,j,1,-A);
		}
	}
	min_cost_flow(0, 2 * N + 1, 60 * 60);


	puts(-ans);
	for (int i = 1; i <= N; i++) {
		for (int j = N+1; j <= 2*N; j++) {
			if(rec[i][j])cout << "X";
			else cout << ".";
		}
		puts("");
	}


	return 0;
}

Measured memory_bytes: 3492
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using ld = long double;

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

    int n, k;
    cin >> n >> k;
    vector<ld> E(n);
    vector<ld> S(n + 1);
    S[0] = 0;
    for(int i = 0; i < n; ++i){
        ld p;
        cin >> p;
        E[i] = (p + 1) * 0.5;
        S[i + 1] = S[i] + E[i];
    }
    ld ans = 0;
    for(int i = 0; i + k <= n; ++i){
        chmax(ans, S[i + k] - S[i]);
    }
    cout << fixed << setprecision(10);
    cout << ans << endl;
}

Measured memory_bytes: 6528
N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]
X.sort(key=lambda x: x[0])
s = [0] * 3

for i in range(N):
    sa = (X[i][0] - s[0]) - ((X[i][1] - s[1]) + (X[i][2] - s[2]))
    if sa >= 0 and sa % 2 == 0:
        start = X[i]
    else:
        print("No")
        quit()
print("Yes")

Measured memory_bytes: 28148
require 'pp'

n, k = gets.chomp!.split(' ').map(&:to_i)
x_n = gets.chomp!.split(' ').map(&:to_i).sort!

head = 0
tail = k - 1

ans = 10 ** 10

while tail < n
    score = 
        if x_n[head] > 0 # 全部正
            score = x_n[tail]
        elsif x_n[tail] < 0 # 全部負
            score = -x_n[head]
        else 
            min, max = [x_n[head].abs, x_n[tail].abs].minmax
            score = min * 2 + max
        end
    
    if score < ans
        ans = score
    end

    head += 1
    tail += 1
end

puts ans


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

using namespace std;

int main() {
    string s;
    cin >> s;
    vector<char> act_s;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] != 'B') {
            act_s.push_back(s[i]);
        } else {
            if (!act_s.empty()) {
                act_s.pop_back();
            }
        }
    }
    string new_s = "";
    for (int i = 0; i < act_s.size(); i++) {
        new_s += act_s[i];
    }
    cout << new_s;
}

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

int main()
{
	string s, t;
	cin >> s >> t;

	for (int i = s.size() - t.size(); i >= 0; i--){
		bool flag = true;
		for (int j = 0; j < t.size(); j++){
			if (s[i+j] == '?') continue;
			if (s[i+j] != t[j]) flag = false;
		}
		if (flag) {
			for (int j = 0; j < t.size(); j++){
				s[i+j] = t[j];
			}
			for (int j = 0; j < s.size(); j++){
				if (s[j] == '?') s[j] = 'a';
			}
			cout << s << endl;
			return 0;
		}
	}
	cout << "UNRESTORABLE" << endl;
}


Measured memory_bytes: 256
def inint(): return int(input())
def inlint(): return list(map(int, input().split()))
def infloat(): return float(input())
def inlffloat(): return list(map(float, input().split()))
def inl(): return list(input())
def putlint(): return "".join(list(map(str, ans)))

n = inint()

a =int( n/15)
print(n*800-a*200)

Measured memory_bytes: 3064