akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int dp[21][(1 << 21)], f[21][(1 << 21)];

int main ()
{
int n, k;
cin >> n >> k;
for(int i = 0 ; i <= n ; ++i){
	string s;
	cin >> s;
	for(int j = 0 ; j < s.size() ; ++j){
		if(s[j] == '1'){
			dp[i][j] = 1;
		}
	}
}
for(int i = 1 ; i <= n ; ++i){
	for(int j = 0 ; j < (1 << i) ; ++j){
		int u = (j >> (i - 1)) & 1;
		int br = 0;
		while(br < i && ((j >> (i - br - 1)) & 1) == u){
			br++;
		}
		if(br == i){
			f[i][j] = -1;
		}
		else{
			f[i][j] = br;
		}
	}
}
for(int i = 0 ; i <= n ; ++i){
	for(int j = i + 1 ; j <= n ; ++j){
		int mask = (1 << (j - i)) - 1;
		for(int w = 0 ; w < (1 << j) ; ++w){
			dp[i][w >> (j - i)] += dp[j][w];
			int x = f[j - i][w & mask];
			if(x != -1){
				dp[j - x][((w >> (j - i)) << (j - i - x)) + (w & ((1 << (j - i - x)) - 1))] += dp[j][w];
			}
		}
	}
}
int sol, vel = -1;
for(int i = 0 ; i <= n ; ++i){
	for(int j = 0 ; j < (1 << i) ; ++j){
		if(dp[i][j] >= k){
			if(i > vel){
				vel = i;
				sol = j;
			}
		}
	}
}
for(int i = vel - 1 ; i >= 0 ; --i){
	cout << ((sol >> i) & 1);
}

return 0;
}


Measured memory_bytes: 96580
fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

fn main() {
    let mut a = readn::<usize>(" ");
    a.sort();
    if a == vec![5, 5, 7] {
        println!("YES");
    } else {
        println!("NO");
    }
}

Measured memory_bytes: 4352
#include<stdio.h>
int main()
{
    int a;
    while(~scanf("%d",&a))
    {
        int flag=1;
        while(a)
        {
            if(a%10==9)
            {
                printf("Yes\n");
                flag=0;break;
            }
            a/=10;
        }
        if(flag)
            printf("No\n");
    }
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

bool dp[81][81][30000];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll h,w;
    cin>>h>>w;

    VV ga(h+1,Vec(w+1,0));
    VV gb(h+1,Vec(w+1,0));

    rep(i,h){
        rep(j,w){
            cin>>ga[i+1][j+1];
        }
    }
    rep(i,h){
        rep(j,w){
            cin>>gb[i+1][j+1];
        }
    }
    VV g(h+1,Vec(w+1,0));
    REP(i,1,h+1){
        REP(j,1,w+1){
            g[i][j] = abs(ga[i][j]-gb[i][j]);
        }
    }

    dp[0][0][0]=true;
    dp[0][1][0]=true;
    dp[1][0][0]=true;
    REP(i,1,h+1){
        REP(j,1,w+1){
            rep(k,15000+1){
                ll cur = g[i][j];
                dp[i][j][k] |=dp[i-1][j][abs(k-cur)];
                dp[i][j][k] |=dp[i-1][j][abs(k+cur)];
                dp[i][j][k] |=dp[i][j-1][abs(k-cur)];
                dp[i][j][k] |=dp[i][j-1][abs(k+cur)];
            }
        }
    }

    ll ans=INF;
    rep(k,15000){
        if(dp[h][w][k]){
            chmin(ans,abs(k));
        }
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 189952
//////////////////////////
/*      _        ____   */
/*  U  /"\  u U /"___|  */
/*   \/ _ \/  \| | u    */
/*   / ___ \   | |/__   */
/*  /_/   \_\   \____|  */
/*   \\    >>  _// \\   */
/*  (__)  (__)(__)(__)  */
/*  Compro by NULL_CT©  */
//////////////////////////
/*STL Libs*/
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

/*Boost*/
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#define REP(i, lower, upper) for (long long i = lower; i < upper; i++)
#define ALL(list) (list.begin()), (list.end())

using namespace std;
using bint = boost::multiprecision::cpp_int;
typedef long long ll;

constexpr int MOD = 10000007;

vector<long long> divisor(long long n) {
  vector<long long> head, tail;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      head.push_back(i);
      if (i * i != n)
        tail.push_back(n / i);
    }
  }
  head.insert(head.end(), tail.rbegin(), tail.rend());
  return (head);
}

//--------------------------------

void execute() {
  int n;
  string s,t;
  cin>>n>>s>>t;

  string ans="";
  REP(i,0,n){
    ans+=s[i];
    ans+=t[i];
  }
  cout<<ans<<endl;
}

//--------------------------------

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  // cout<<fixed<<setprecision(20);

  execute();

  return (0);
}


Measured memory_bytes: 3112
def d_joisino_travel(N, M, R, Route, Road):
    # N:国の中の町の数
    # M:町を結ぶ道の総数
    # R:訪れる町の数
    # Route:訪れる町の番号
    # Road:町の結び方とその間の距離
    from itertools import permutations
    from scipy.sparse import csgraph

    graph = [[float('inf')] * N for j in range(N)]  # 町同士の距離
    for i in range(N):
        graph[i][i] = 0
    for m, n, c in Road:
        graph[m - 1][n - 1] = c
        graph[n - 1][m - 1] = c
    dist = csgraph.floyd_warshall(graph)

    ans = float('inf')
    for route in permutations([x - 1 for x in Route]):
        cost = 0
        for j in range(R - 1):  # route(行く町の順列)の先頭から2つ要素を拾う
            cost += dist[route[j]][route[j + 1]]
        ans = min(ans, cost)
    return int(ans)

N, M, R = [int(i) for i in input().split()]
Route = [int(i) for i in input().split()]
Road = [[int(i) for i in input().split()] for j in range(M)]
print(d_joisino_travel(N, M, R, Route, Road))

Measured memory_bytes: 21180
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

struct mint {
	ll x;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
	bool operator==(const mint a) const {
		return x == a.x;
	}
	bool operator!=(const mint a) const {
		return x != a.x;
	}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }


int main() {
    ll s;
    cin >> s;
    vector<vector<mint>> dp(s, vector<mint>(s+1, 0));
    dp[0][0] = 1;
    rep(i, s-1){
        vector<mint> sum(s+2);
        sum[0] = dp[i][0];
        REP(j, s)sum[j] += sum[j-1] + dp[i][j];
        rep(j, s+1){
            if(j < 3)continue;
            dp[i+1][j] += sum[j-3];
        }
    }
    mint ans = 0;
    rep(i, s)ans += dp[i][s];
    cout << ans << endl;
}

Measured memory_bytes: 34508
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, maxint


def main():
    num = int(stdin.readline())

    M = []
    for _ in xrange(num):
        M.append([int(s) for s in stdin.readline().split()])

    g = set(xrange(1, num+1))
    index = g.pop()
    h = {index}
    gravity = 0

    while g:
        minimum = maxint
        for j in h:
            mj = M[j-1]
            for i in g:
                if 0 <= mj[i-1] < minimum:
                    index = i
                    minimum = mj[i-1]
        h.add(index)
        g.remove(index)
        gravity += minimum

    print(gravity)


main()

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;using vb=vector<bool>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;

bool solve() {
  int N;
  scanf("%d", &N);
  vi A(N);
  rep(i, N) scanf("%d", &A[i]);

  int ma = *max_element(ALL(A));
  int mi = (ma + 1) / 2;

  map<int, int> co;
  forr(a, A) {
    if (a < mi) return false;
    co[a]++;
  }

  if (ma % 2) {
    if (co[mi] != 2) return false;
  }
  else {
    if (co[mi] != 1) return false;
  }

  rrep(i, mi+1, ma+1) {
    if (co[i] < 2) return false;
  }

  return true;
}

void Main() {
  puts(solve() ? "Possible" : "Impossible");
}
int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 256
R,G,B,N = list(map(int, input().split()))

B,G,R = sorted([R,G,B])

ans = 0
for r in range(N//R + 1):
  for g in range(N//G + 1):
    if r*R + g*G > N:
      break
    if (N - r*R - g*G) % B == 0:
      ans += 1
      
print(ans)

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

const int INF = 0x3f3f3f3f;

typedef double DB;
typedef long long LL;
#define pb push_back
#define mp make_pair

const int maxN = 444;
const int maxE = maxN * maxN * 2;
int n, m, c[maxN];
int h[maxN], to[maxE], nxt[maxE], ec;

struct Node {
	int u, w;
	LL p;
	bool operator < (const Node&rhs) const {
		return w > rhs.w;
	}
	Node() {}
	Node(int u, int w, LL p):u(u), w(w), p(p) {}
};

priority_queue<Node> que;

vector<int> adj[maxN];
int dis[maxN];

int main() {
#ifdef lol
	freopen("hd.in", "r", stdin);
	freopen("hd.out", "w", stdout);
#endif

	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &c[i-1]);
	ec = 0;
	memset(h, -1, sizeof h);
	for (int i = 1; i <= m; ++i) {
		int u, v;
		scanf("%d %d", &u, &v);
		--u, --v;
		adj[u].pb(v);
		adj[v].pb(u);
		to[ec] = v, nxt[ec] = h[u], h[u] = ec++;
		to[ec] = u, nxt[ec] = h[v], h[v] = ec++;
	}

	que.push(Node(0, c[0], 1LL));
	int ans = INF;
	
	while (!que.empty()) {
		int u = que.top().u;
		int w = que.top().w;
		LL p = que.top().p;
		que.pop();
		for (int i = h[u]; i != -1; i = nxt[i]) {
			int v = to[i];
			int vw = w;
			LL vp = p;
			if (!((vp>>v)&1)) {
				for (int j = 0; j < (int)adj[u].size(); ++j) {
					if (!((vp>>adj[u][j])&1)) {
						vp |= 1LL<<adj[u][j];
						vw += c[adj[u][j]];
					}
				}
				que.push(Node(v, vw, vp));
				if (v == n-1) {
					for (int j = 0; j < (int)adj[v].size(); ++j) {
						if (!((vp>>adj[v][j])&1)) {
							vp |= 1LL<<adj[v][j];
							vw += c[adj[v][j]];
						}
					}
					ans = min(ans, vw);
				}
			}
		}
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 19284
#include <bits/stdc++.h>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;


int main(){
    string s ;cin>>s;
    string ans = "";
    rep(i,3){
        char x = s[i];
        ans+=x;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 3592
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int a,b;
    scanf("%d%d", &a, &b);

    if(a<6) {
        printf("%d\n", 0);
    }
    else if(a<=12) {
        printf("%d\n", b/2);
    }
    else {
        printf("%d\n", b);
    }



    return 0;
}



Measured memory_bytes: 128
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int n,minN,q=0;
        n=scan.nextInt();
        int[] sort=new int[n];
        for(int i=0; i<n; i++){
            sort[i]=scan.nextInt();
        }
        //System.out.println(Arrays.toString(sort));
        
        for(int i=0; i<n; i++){
            minN=i;
            for(int j=i+1; j<n; j++){
                if(sort[minN]>sort[j]){
                    minN=j;
                }
            }
            if(minN!=i){
                sort[i]^=sort[minN];
                sort[minN]^=sort[i];
                sort[i]^=sort[minN];
                q++;
            }
        }
        for(int i=0; i<n; i++){
            System.out.print(sort[i]);
            if(i!=n-1)
                System.out.print(" ");
            else
                System.out.println();
        }
        System.out.println(q);
    }
}


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

struct Xfi {
  bool operator<(const Xfi &xfi) const {
    return x - w < xfi.x - xfi.w;
  }
  int x, w;
};

struct Yfi {
  bool operator<(const Yfi &yfi) const {
    return y - w < yfi.y - yfi.w;
  }
  int y, w;
};

int main() {
  int N, W, H;
  cin >> N >> W >> H;

  vector<Xfi> xfis(N);
  vector<Yfi> yfis(N);

  for (int i = 0; i < N; i++) {
    int x, y, w;
    cin >> x >> y >> w;

    xfis[i].x = x;
    yfis[i].y = y;
    xfis[i].w = yfis[i].w = w;
  }

  bool flg = false;

  sort(xfis.begin(), xfis.end());
  int x = 0;
  for (int i = 0; i < N; i++) {
    if (xfis[i].x - xfis[i].w > x) {
      flg = true;
      break;
    }
    x = max(xfis[i].x + xfis[i].w, x);
  }
  flg = x < W || flg;

  if (flg) {
    flg = false;
    sort(yfis.begin(), yfis.end());
    int y = 0;
    for (int i = 0; i < N; i++) {
      if (yfis[i].y - yfis[i].w > y) {
        flg = true;
        break;
      }
      y = max(yfis[i].y + yfis[i].w, y);
    }
    flg = y < H || flg;
  }

  cout << (!flg ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 4416
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node {
    int key;
    Node *prev, *next;
};

Node *nil;
int size = 0, np = 0, nd = 0;

void init() {
    nil = (Node *) malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void insert(int key) {
    Node *x = (Node *) malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
    np++;
    size++;
}

void deleteNode(Node *t) {
    if (t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
    size--;
}

Node *listSearch(int key) {
    Node *cur = nil->next;
    while (cur != nil && cur->key != key) {
        cur = cur->next;
    }
    return cur;
}

void deleteKey(int key) {
    deleteNode(listSearch(key));
    nd++;
}

void deleteFirst() {
    deleteNode(nil->next);
}

void deleteLast() {
    deleteNode(nil->prev);
}

char *df = "deleteFirst";
char *dl = "deleteLast";
char *d = "delete";
char *in = "insert";

int main() {
    int key, N;
    char c[20];
    scanf("%d", &N);
    init();

    for (int i = 0; i < N; i++) {
        scanf("%s%d", c, &key);
        char *cs = c;
        if (strcmp(cs, df) == 0) {
            deleteFirst();
        } else if (strcmp(cs, dl) == 0) {
            deleteLast();
        } else if (strcmp(cs, d) == 0) {
            deleteKey(key);
        } else if (strcmp(cs, in) == 0) {
            insert(key);
        }
    }

    Node *cur = nil->next;
    int f = 0;
    while (1) {
        if (cur == nil) break;
        if (f++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");

    return 0;
}



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

int main() {
  int k,n;
  int ans=0;

  cin >> k >> n;

  vector<int> a(n,0);
  vector<int> dis(n,0);

  for(int i=0;i<n;i++) {
    cin >> a[i];
    if(i==0) {
      dis[0] = a[0];
    }
    else {
      dis[i] = a[i]-a[i-1];
    }
    if(i==n-1) {
      dis[0] += (k-a[i]);
    }
  }

  // for(int i=0;i<n;i++) {
  //   cout << dis[i] << " " <<endl;
  // }

  sort(dis.begin(),dis.end());

  ans = k-dis[n-1];

  cout << ans << endl;

  return 0;
}


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



int main() {

  int64_t a,b,c,d;
  cin>>a>>b>>c>>d;

  //a*c,a*d,b*c,b*d
  cout<<max(max(a*c,a*d), max(b*c,b*d))<<endl;

  return 0;
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

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

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

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

ll lcm(ll a, ll b)
{
  return a * b / gcd(a, b);
}

//実行部
void Main()
{
  str s; cin >> s;
  for(ll i = 0;;i++)
  {
    s.pop_back();
    if(s.size() % 2 != 0) continue;
    str e = s.substr(0, s.size() / 2);
    e += e;
    if(e == s)
    {
      fin(s.size()) exit(0);
    }
  }
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


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





using namespace std;



template < class BidirectionalIterator >
bool next_combination ( BidirectionalIterator first1 ,
  BidirectionalIterator last1 ,
  BidirectionalIterator first2 ,
  BidirectionalIterator last2 )
{
  if (( first1 == last1 ) || ( first2 == last2 )) {
    return false ;
  }
  BidirectionalIterator m1 = last1 ;
  BidirectionalIterator m2 = last2 ; --m2;
  while (--m1 != first1 && !(* m1 < *m2 )){
  }
  bool result = (m1 == first1 ) && !(* first1 < *m2 );
  if (! result ) {
    // テ「ツ堕?
    while ( first2 != m2 && !(* m1 < * first2 )) {
      ++ first2 ;
    }
    first1 = m1;
    std :: iter_swap (first1 , first2 );
    ++ first1 ;
    ++ first2 ;
  }
  if (( first1 != last1 ) && ( first2 != last2 )) {
    // テ「ツ堕。
    m1 = last1 ; m2 = first2 ;
    while (( m1 != first1 ) && (m2 != last2 )) {
      std :: iter_swap (--m1 , m2 );
      ++ m2;
    }
    // テ「ツ堕「
    std :: reverse (first1 , m1 );
    std :: reverse (first1 , last1 );
    std :: reverse (m2 , last2 );
    std :: reverse (first2 , last2 );
  }
  return ! result ;
}
 
template < class BidirectionalIterator >
bool next_combination ( BidirectionalIterator first ,
  BidirectionalIterator middle ,
  BidirectionalIterator last )
{
  return next_combination (first , middle , middle , last );
}


void push_string(vector<string>& ss, set<string>& hoge){
  do{
    string tmp="";
    for(int i=0; i<ss.size(); i++)
      tmp += ss[i];
    //    cout << tmp << "\n";
    hoge.insert(tmp);
  }while(next_permutation(ss.begin(),ss.end()));
}



int main(){
  while(1){
    int n,k; cin >> n >> k;
    if(n==0 && k==0) break;
    vector<string> ss;
    set<string> hoge;
    for(int i=0; i<n; i++){
      string x; cin >> x;
      ss.push_back(x);
    }
    sort(ss.begin(),ss.end());
    
    do{
      for(int i=0; i<k; i++){
	vector<string> tmp;
	for(int i=0; i<k; i++)
	  tmp.push_back(ss[i]);
	push_string(tmp,hoge);
      }
    }while(next_combination(ss.begin(), ss.begin()+k, ss.end()));
    cout << hoge.size() << "\n";
  }

}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;


int main(){

    double N;
    cin>>N;
    cout<<ceil(N/2)<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 256
s = [c for c in input()]
k = int(input())
l = len(s)
for i in range(l):
    t = (ord('z')-ord(s[i])+1)%26
    if t <= k:
        k -= t
        s[i] = 'a'
s[-1] = chr((ord(s[-1]) - ord('a') + k) % 26 + ord('a'))
print(''.join(s))

Measured memory_bytes: 4212
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Sumo
            string s = Console.ReadLine();

            if(s.Count(x=>x== 'x') < 8)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }            
        }
    }
}

Measured memory_bytes: 13268
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a * b % 2 ? "Odd" : "Even") << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int mo=1000000007,mx=17;
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
void add(int &x,int y){x+=y;if(x>=mo)x-=mo;}
int bin[mx],jc[1<<mx],inv[1<<mx],jv[1<<mx];
int C(int n,int m){if(n<m)return 0;return 1ll*jc[n]*jv[m]%mo*jv[n-m]%mo;}
int a[mx],n,m,ans,f[mx+1][1<<mx],cnt[1<<mx];
int main()
{
	n=read();m=read();cnt[0]=jc[0]=bin[0]=jv[0]=inv[0]=inv[1]=1;
	for(int i=1;i<=n;++i)bin[i]=bin[i-1]<<1;
	for(int i=1;i<=bin[n];++i)jc[i]=1ll*jc[i-1]*i%mo;
	for(int i=2;i<=bin[n];++i)inv[i]=1ll*inv[mo%i]*(mo-mo/i)%mo;
	for(int i=1;i<=bin[n];++i)jv[i]=1ll*jv[i-1]*inv[i]%mo;
	for(int i=1;i<=bin[n];++i)cnt[i]=(i&1)?mo-cnt[i>>1]:cnt[i>>1];
	for(int i=1;i<=m;++i)a[i]=read();sort(&a[1],&a[m+1]);
	f[m+1][0]=1;
	for(int i=m;i;--i)
		for(int t=0;t<bin[n];++t)
			if(f[i+1][t])
			{
				add(f[i][t],f[i+1][t]);
				int p=bin[n]-1-t;
				for(int j=0;j<n;++j)
					if(!(t&(1<<j)))
						add(f[i][t|(1<<j)],1ll*C(p-a[i]+1,(1<<j)-1)*f[i+1][t]%mo*jc[1<<j]%mo);
			}
	for(int i=0;i<bin[n];++i)
		add(ans,1ll*f[1][i]*jc[bin[n]-1-i]%mo*cnt[i]%mo);
	ans=1ll*ans*bin[n]%mo;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 8192
K, N = map(int, input().split())
a = list(map(int, input().split()))
maxEl = a[0] + K - a[N - 1]
for i in range(1, N):
    if (a[i] - a[i - 1]) > maxEl:
        maxEl = a[i] - a[i - 1]
print(K - maxEl)

Measured memory_bytes: 25836
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int n,a,b; cin >> n >> a >> b;
	int count = 0;
	rep(i,n+1){
		int d = i;
		int c = 0;
		while(d > 0){
			c += d%10;
			d = d/10;
		}
		if (a <= c && c <= b){
			count += i;
		}
	}
	print(count);
}

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N; cin >> N;
    vector<ll> d;
    for (int i = 0; i < N; i++) {
        ll a; cin >> a;
        d.pb(a);
    }
    asort(d);
    if(d[d.size()/2-1] == d[d.size()/2]){
        cout << "0" << endl;
    } else {
        cout << d[d.size()/2]-d[d.size()/2-1] << endl;
    }
}

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

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

    if(n%2 == 0){
        for(int i=n-1;i>0;i -= 2){//偶数番目（添え字は奇数）
            cout << vec[i] << " ";
        }
        for(int i=0;i<n-1;i += 2){
            cout << vec[i] << " ";
        }cout << endl;
    }else {
        for(int i=n-1;i>=0;i -= 2){
            cout << vec[i] << " ";
        }
        for(int i=1;i<n;i += 2){
            cout << vec[i] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define D(a) (double)(a)
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define vb vct<bool>
#define vs vector<string>
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define print(v) for(auto it:v)cout<<it<<' '; cout<<endl;
#define PI acos(-1.0)
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
#define rt return true
#define rf return false
///................function.....................///
#define siz(s) (int)(s.size())
#define mod 1000000007
#define dbg(a) cout << #a << " = " << a << " ";
int main()
{
    ///freopen("input.txt","r",stdin);
    ///freopen("input15.txt","w",stdout);
    int n,i,j;
    cin>>n;
    vi a(n),b(n);
    vi cnt(n+1);
    read(a,0,n);
    read(b,0,n);
    for(i=0; i<n; i++)
    {
        cnt[a[i]]++;
        cnt[b[i]]++;
        if(cnt[a[i]]>n||cnt[b[i]]>n)
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    int l=n+1,r=-1;
    reverse(all(b));
    for(i=0; i<n; i++)
    {
        if(a[i]==b[i])
        {
            l = min(i,l);
            r=i;
        }
    }
    for(i=l; i<=r; i++)
    {
        swap(b[i],b[(i+n/2)%n]);
    }
    cout<<"Yes"<<endl;
    print(b);
}


Measured memory_bytes: 5632
fun main(args: Array<String>) {
  val N = readLine()!!.toInt()
  val A = readLine()!!.split(" ").map { it.toInt() }
  var num = 1
  var count = 0
  for (a in A) {
    if (a == num) {
      num++
    } else {
      count++
    }
  }
  println(if (count == N) -1 else count)
}


Measured memory_bytes: 82700
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 2019;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}
 
int main(){
  
  ll L,R;
  ll ans=0;
  cin>>L>>R;
  
  if(R-L+1>=2019)
    cout<<0<<endl;
  else{
    ll mini=INF;
    for(ll i=L;i<R;i++){
      for(ll j=R;j>i;j--){
        ll Lm=i%mod;
        ll Rm=j%mod;
        ans=(Lm*Rm)%mod;
        mini=min(mini,ans);
      }
    }
    
    cout<<mini<<endl;
  }
}
        
        
        
        

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>       // for next_permutation
#include <vector>
#include <queue>
#include <bits/stl_numeric.h>

#define DEBUG 0
#define REP(i, n) for (long long i = 0; i < (n); i++) 
using namespace std;

typedef long long ll;
typedef pair <int, int> pii;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;


int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector <string> s(N);
    vector <ll> t(N);
    REP(i,N)
    {
        cin >> s[i] >> t[i];
    }
    string tar;
    cin >> tar;
    
    int cnt;
    REP(i, N)
    {
        if(tar == s[i])
        {
            cnt = i;
            break;
        }
    }
    ll res = 0;
    for(int i = cnt + 1; i < N; ++i)
    {
        res += t[i];
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

int main() {
	ll N;
	scanf("%lld", &N);

	if (N % 2 == 0) printf("%lld\n", N);
	else printf("%lld\n", 2 * N);
	return 0;
}

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

using ll = long long;
#define int long long
using P = pair<int, int>;

#define LOG(variable) cerr << #variable":\t" << (variable) << "\n"
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cerr << (i) << ":\t" << (container)[(i)] << "\n"
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
template<typename T = int>
T in() {T a; cin >> a; return a;}
int cum_sum_a[200005], cum_sum_b[200005];
/***** MAIN *****/
signed main() {
  int n, m, k; cin >> n >> m >> k;
  vector<int> cuma(n+1,0LL), cumb(m+1,0LL);
  for(int i = 0; i < n; ++i) {
    int a; cin >> a;
    cuma[i+1] = cuma[i] + a;
  }
  for(int i = 0; i < m; ++i) {
    int b; cin >> b;
    cumb[i+1] = cumb[i] + b;
  }
  int ans = 0;
  for(int i = 0; i < n+1; ++i) {
    if(cuma[i] > k) break;
    int rest = k - cuma[i];
    int index = upper_bound(ALL(cumb), rest) - cumb.begin();
    ans = max(ans, i + index-1);
    cerr << i << " " << index << endl;
}
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/

Measured memory_bytes: 6384
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
    int n;
    int m;
  
   cin >> n >> m;
   int a[n];
  
for(int i = 0;i<n;i++){
     
  cin >> a[i];

}
  
  int sum = 0;
  
  for(int i = 0;i<n;i++){
     
   sum = sum + a[i];

}
   sort(a, a + n); 
   
   
   int amari =  m-sum;
   int ans = n+amari/a[0];
   
   
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
while True:
    try:
        ax, ay, bx, by, cx, cy, px, py = map(float, input().split())
        a = (bx - ax) * (py - ay) - (by - ay) * (px - ax)
        b = (cx - bx) * (py - by) - (cy - by) * (px - bx)
        c = (ax - cx) * (py - cy) - (ay - cy) * (px - cx)
        if (a < 0 and b < 0 and c < 0) or (a > 0 and b > 0 and c > 0):
            print("YES")
        else:
            print("NO")
    except:
        break

Measured memory_bytes: 7376
#既存のもの頼み
#最小値でなく最大値なのでマイナスつける
import heapq

n, q = map(int, input().split( ))
Q = [[] for _ in range(n)]
for _ in range(q):
    cmd = list(map(int, input().split( )))
    if cmd[0] == 0:
        t = cmd[1]
        x = cmd[2]
        heapq.heappush(Q[t],-x)
    elif cmd[0] == 1:
        t = cmd[1]
        if Q[t]:##
            mx = - heapq.heappop(Q[t])
            print(mx)
            heapq.heappush(Q[t],-mx)
    else:##
        t = cmd[1]
        if Q[t]:
            heapq.heappop(Q[t])
        


Measured memory_bytes: 13184
#include <iostream>
#include <stack>
using namespace std;
static const int N = 100;
static const int WHITE = 0;
static const int GRAY  = 1;
static const int BLACK = 2;

int n, M[N][N];
int color[N], d[N], f[N], tt;
int nt[N];

int next(int u)
{
    for (int v = nt[u]; v < n; v++) {
        nt[u] = v + 1;
        if (M[u][v]) return v;
    }
    return -1;
}

void dfs_visit(int r)
{
    for (int i = 0; i < n; i++) {
        nt[i] = 0;
    }

    stack<int> S;
    S.push(r);
    color[r] = GRAY;
    d[r] = ++tt;

    while (!S.empty()) {
        int u = S.top();
        int v = next(u);
        if (v != -1) {
            if (color[v] == WHITE) {
                color[v] = GRAY;
                d[v] = ++tt;
                S.push(v);
            }
        } else {
                S.pop();
                color[u] = BLACK;
                f[u] = ++tt;
        }
    }
}

void dfs()
{
    for (int i = 0; i < n; i++) {
        color[i] = WHITE;
        nt[i] = 0;
    }
    tt = 0;

    for (int u = 0; u < n; u++) {
        if (color[u] == WHITE) dfs_visit(u);
    }
    for (int i = 0; i < n; i++) {
        cout << i+1 << " " << d[i] << " " << f[i] << endl;
    }
}

int main(int argc, char const *argv[])
{
    int u, k, v;

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

    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    dfs();

    return 0;
}



Measured memory_bytes: 3112
#define __USE_MINGW_ANSI_STDIO
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef long long ull;
typedef pair<int, int> ii;

#define all(v)		((v).begin()), ((v).end())
#define sz(v)		((int)((v).size()))
#define endl		"\n"
#define fx(n)		fixed<<setprecision(n)
#define mk			make_pair	

void fast()
{
	ios::sync_with_stdio(NULL);
	cout.tie(NULL);
	cin.tie(NULL);
/*#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
#ifdef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("pyramid.in", "r", stdin);
#endif*/
}
const double pi = 2 * acos(0.0);
const ll oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int nn = 1e6 + 15;
int dx[8] = { -1, 0, 0, 1, 1, -1, 1, -1 };
int dy[8] = { 0, -1, 1, 0, 1, -1, -1, 1 };

int main()
{
	fast();
	int n, l;
	cin >> n >> l;
	vector<string>arr(n);
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	sort(all(arr));
	for (int i = 0; i < n; i++)
		cout << arr[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

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

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll LNF = __LONG_LONG_MAX__;

constexpr int INF = 1e9+7;

vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,k; cin >> n >> k;
    ll m = 50;
    vector<int> bk(m);
    rep(i,0,m){
        if(k & (1ll<<i)){
            bk[i] = 1;
        }
    }
    vector<ll> bit(m,0);
    rep(i,0,n){
        ll a; cin >> a;
        int index = 0;
        rep(j,0,m){
            if(a & (1ll<<j)){
                bit[j]++;
            }
        }
    }
    vector<vector<ll>> dp(m+1,vector<ll>(2,-1));
    reverse(all(bit));
    reverse(all(bk));
    dp[0][0] = 0ll;
    Rep(i,0,m){
        ll x = 1ll<<(m-i-1ll);
        rep(j,0,2){
            if(dp[i][j]==-1) continue;
            chmax(dp[i+1][j||bk[i]],dp[i][j]+bit[i]*x);
            if(j==1) chmax(dp[i+1][j],dp[i][j]+(n-bit[i])*x);
            else if(bk[i]) chmax(dp[i+1][0],dp[i][0]+(n-bit[i])*x);
        }
    }
    ll ans = max(dp[m][0],dp[m][1]);
    debug(bit);
    debug(bk);
    cout << ans << endl;
}

Measured memory_bytes: 256
import math

s = input()
n = len(s)

l = math.floor(n/2)
if n % 2 == 0:
  k = l
else:
  k = l+1
  

s_f = s[:l]
s_r = s[k:]
j = 0

#print(s_f)
#print(s_r)

for i in range(0,l):
  if s_f[i] != s_r[(l-1)-i]:
    #print(s_f[i] + " " + s_r[(l-1)-i])
    j+=1
    
print(j)

Measured memory_bytes: 3060
x,n = map(int,input().split())
if n == 0:
    print(x)
else:
    mp = set(range(-1,102))
    p = set(list(map(int,input().split())))
    lp = list(mp-p)
    sub_lp = [abs(i-x) for i in lp]
    print(lp[sub_lp.index(min(sub_lp))])

Measured memory_bytes: 9132
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
  vector<int> numbers = {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};
  int K;
  cin >> K;
  cout << numbers.at(K - 1) << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
 
using namespace std;
typedef long long int ll;typedef pair<int, int> P;
const long long mod = 1e9 + 7;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
 
 
int main(void) {
	int n; cin >> n;
	vector<char> v;
	char a; cin >> a;
	int ans = 1;
	for (int i = 1; i < n; i++) {
		char b; cin >> b;
		if (a != b)ans++;
		a = b;
	}
	cout << ans << endl;
	return 0;
}

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

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

	vector<ll> a(n);
	for(ll &i : a){
		cin >> i;
	}

	vector<ll> dp(n , 0);
	dp[0] = 0;
	dp[1] = abs(a[0] - a[1]);
	for(ll i = 2 ; i < n ; i++){
		dp[i] = min(dp[i-1] + abs(a[i]-a[i-1]) , dp[i-2] + abs(a[i]-a[i-2]));
	}

	cout << dp[n-1] << endl;

	return 0;
}


Measured memory_bytes: 4824
n, k = map(int, input().split())
s = str(input())

start = s[0]
end = s[-1]

count = 0
flag = 0
answer = 0
for i in range(1,n):
    if s[i-1] == start and s[i] != start and flag == 0:
        flag += 1
    elif s[i-1] != start and s[i] == start and flag == 1:
        flag = 0
        count += 1
    if s[i-1] == s[i]:
        answer += 1
#%%
answer += min(count,k)*2
if k > count:
    answer += flag

print(answer)

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

using namespace std;

int main()
{
 int a, b;
 scanf("%d %d", &a, &b);
 double re = (a + b) / 2.0;
 double x = re - (int) re;
 double ans = 0;
 if(x >= .50) ans = ceil(re);
 else ans = floor(re);
 printf("%.0lf\n", ans);
 
 return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{ 
  const int END = -1;
  const int NUM = 50022;
  int num;
  int i,index,index2,index3;
  
  cin >> num;

  vector<int> eratos(NUM);

  for(i = 0;i < NUM - 1 ; i++)
    eratos[i] = i+2;
  eratos[i] = END;
 
  while(!cin.eof()){
    i = 0;
    index3 = 0;
  while(eratos[i]!=END)
    {
      if(eratos[i]!=0)
        {
          index = i + 1;
          index3 = i + 1;
          while(eratos[index]!=END)
            {
              if(eratos[index]%eratos[i] != 0)
                {
                  eratos[index3] = eratos[index];
                  index3++;
                }
              index++;
            }
          eratos[index3] = END;
        }
      i++;
    }
 
  for(i = 0; i < index3; i++)
    {
      if(eratos[i]==num)
        {
          cout << eratos[i-1] << " " << eratos[i+1] << endl;
          break;
        }
      else if(eratos[i] > num)
        {   
              cout << eratos[i-1] << ' ' << eratos[i] << endl;
              break;
        }
    }
    cin >> num;
  }
  return 0;
}

Measured memory_bytes: 1268