akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = ReadLine().Split().Select(int.Parse).ToArray();
        var d = new Dictionary<int, int>()
        {
            {2, 1},
            {3, 2},
            {4, 3},
            {5, 4},
            {6, 5},
            {7, 6},
            {8, 7},
            {9, 8},
            {10, 9},
            {11, 10},
            {12, 11},
            {13, 12},
            {1, 13},
        };
        if(d[n[0]] > d[n[1]])
            WriteLine("Alice");
        else if(d[n[0]] < d[n[1]])
            WriteLine("Bob");
        else
            WriteLine("Draw");
        ReadLine();
    }
}


Measured memory_bytes: 19304
// Date: 2020-04-04

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define IO freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout)
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define D(x) cout << #x << " = " << x << endl;
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int a[N], n, m;
int main() {
    FIO;
    cin >> n >> m;
    int sum = 0;
    rep(i, 1, n) cin >> a[i], sum += a[i];
    int ans = 0;
    rep(i, 1, n) {
        if(a[i] * 4 * m >= sum) ans++;
    }
    if(ans >= m) cout << "Yes";
    else cout << "No";

    return 0;
}

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

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

	if (a <= c && c <= b)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
long long dp[100005];
int main()
{
	memset(dp,-1,sizeof(dp));
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int a;
		cin>>a;
		dp[a]=0;
	}
	dp[0]=1;
	for(int i=1;i<=n;i++)
	{
		if(dp[i]==0) continue;
		if(i==1) dp[i]=dp[i-1];
		else dp[i]=dp[i-1]+dp[i-2];
		dp[i]%=1000000007;
	}
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template<class T> void read(T& x)
{
	char c = getchar(); T p = 1, n = 0;
	while(c < '0' || c > '9') {if(c == '-') p = -1; c = getchar();}
	while(c >= '0' && c <= '9'){n = n * 10 + c - '0'; c = getchar();}
	x = p * n;
}
template<class T,class U>void read(T&x,U&y){read(x),read(y);}
template<class T,class U,class V>void read(T&x,U&y,V&z){read(x),read(y),read(z);}
const int mod = 924844033, g = 5, maxn = 4e5 + 10, maxN = 1 << 22;
struct E{int v, n;}e[maxn << 1];
int h[maxn], ec = 1;
inline void add_edge(int u, int v){e[ec] = (E){v, h[u]}; h[u] = ec++;}
int size[maxn], cnt[maxn], n;
void dfs(int u = 1, int f = 0)
{
	size[u] = 1;
	for(int i = h[u], v = e[i].v; i; i = e[i].n, v = e[i].v) if(v != f)
	{
		dfs(v, u);
		size[u] += size[v];
	}
	if(f) ++cnt[size[u]], ++cnt[n - size[u]];
}
int power(int a, int b){int r = 1;for(; b; b >>= 1, a = 1ll * a * a % mod)if(b & 1)r = 1ll * r * a % mod; return r;}
int eps[maxN], ieps[maxN], bitrev[maxN];
void FFT(int *A, int n, int *w = eps)
{
	for(int i = 0; i < n; ++i) if(i < bitrev[i]) swap(A[i], A[bitrev[i]]);
	for(int s = 1; s < n; s <<= 1) for(int i = 0; i < n; i += s << 1)
	{
		int t = n / (s << 1), u, v;
		for(int j = i, k = 0; j < i + s; ++j, k += t) u = A[j], v = 1ll * w[k] * A[j + s] % mod, A[j] = (u + v) % mod, A[j + s] = (u + mod - v) % mod;
	}
}
void IFFT(int *A, int n)
{
	FFT(A, n, ieps);
	int inv = power(n, mod - 2);
	for(int i = 0; i < n; ++i) A[i] = 1ll * A[i] * inv % mod;
}
int A[maxN], B[maxN], fac[maxn], ifac[maxn];
int main()
{
	read(n);
	for(int i = 1, u, v; i < n; ++i) read(u, v), add_edge(u, v), add_edge(v, u);
	fac[0] = 1; for(int i = 1; i <= n; ++i) fac[i] = 1ll * fac[i - 1] * i % mod;
	ifac[n] = power(fac[n], mod - 2); for(int i = n - 1; ~i; --i) ifac[i] = 1ll * ifac[i + 1] * (i + 1) % mod;
	int N = 1, L = -1; for(; N <= n + n; N <<= 1, ++L);
	for(int i = 0; i < N; ++i) bitrev[i] = bitrev[i >> 1] >> 1 | ((i & 1) << L);
	int base = power(g, (mod - 1) / N), ibase = power(base, mod - 2);
	eps[0] = ieps[0] = 1; for(int i = 1; i < N; ++i) eps[i] = 1ll * eps[i - 1] * base % mod, ieps[i] = 1ll * ieps[i - 1] * ibase % mod;
	dfs();
	for(int i = 0; i <= n; ++i) A[i] = 1ll * cnt[i] * fac[i] % mod, B[i] = ifac[n - i];
	FFT(A, N); FFT(B, N);
	for(int i = 0; i < N; ++i) A[i] = 1ll * A[i] * B[i] % mod;
	IFFT(A, N);
	for(int i = 1; i <= n; ++i) 
	{
		int ans = 1ll * n * fac[n] % mod * ifac[i] % mod * ifac[n - i] % mod;
		ans = (ans + mod - 1ll * ifac[i] * A[n + i] % mod) % mod;
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 42112
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

std::string N;
ll n;

int main()
{
  std::cin >> N;

  ll ans = 0, p = 1;
  repd( i, N.size() )
  {
    ans += N[i]-'0';
    n += (N[i]-'0')*p;
    p *= 10;
  }

  puts( n % ans == 0 ? "Yes" : "No" );

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  const int n=4;
  int ans=0;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    ans+=x;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		
		int cnt = 0;
		for(int i = 1;i <= N;i++) {
			if(i%2 != 0) {
				 cnt++;
			}
		}
		double ans = (double)cnt  / N; 

		System.out.println(ans);

   		sc.close();
        return ;

    }
    
}


Measured memory_bytes: 23764
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<b?(a=b,1):0)
#define chmin(a,b) (a>b?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int tate[100000];
int yoko[100000];

int main() {
  int n,w,h;
  cin>>n>>w>>h;
  UnionFind uf(n);
  REP(i,100000)tate[i]=yoko[i]=-1;

  bool corner = 0;
  
  REP(i,n) {
    int x,y;
    cin >> x >> y;
    if (x==1||y==1||x==w||y==h) corner = 1;
    x--;y--;
    if (tate[x] >= 0) uf.unionSet(tate[x],i);
    tate[x] = i;
    if (yoko[y] >= 0) uf.unionSet(yoko[y],i);
    yoko[y] = i;
  }
  int ans = 0;
  set<int> seen;
  REP(i,n) {
    int r = uf.root(i);
    if (seen.count(r)) continue;
    seen.insert(r);
    ans += uf.size(i)-1;
  }
  if (seen.size() > 1) {
    ans += seen.size();
    ans += seen.size()-1;
    if (corner) ans--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#include <iostream>
#include <string.h>
#include <math.h>

using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
ll a[maxn], h[maxn], dp[maxn];
struct Tree {
    int l, r;
    ll mx;
}tree[maxn << 2];

void pushup(int i) {
    tree[i].mx = max(tree[i * 2].mx, tree[i * 2 + 1].mx);
}

void build(int i, int l, int r) {
    tree[i].l = l; tree[i].r = r;
    tree[i].mx = 0;
    if (l >= r) {
        return ;
    }
    int mid = (l + r) / 2;
    build(i * 2, l, mid); build(i * 2 + 1, mid + 1, r);
}

void update(int i, int pos, ll val) {
    if (tree[i].l == tree[i].r) {
        tree[i].mx = val; return ;
    }
    int mid = (tree[i].l + tree[i].r) / 2;
    if (mid >= pos) {
        update(i * 2, pos, val);
    } else {
        update(i * 2 + 1, pos, val);
    }
    pushup(i);
}

ll query(int i, int l, int r) {
    if (tree[i].l == l && tree[i].r == r) {
        return tree[i].mx;
    }
    int mid = (tree[i].l + tree[i].r) / 2;
    if (mid >= r) {
        return query(i * 2, l, r);
    } else if(l > mid) {
        return query(i * 2 + 1, l, r);
    } else {
        return max(query(i * 2, l, mid), query(i * 2 + 1, mid + 1, r));
    }
}

int main() {
   // freopen("in.in", "r", stdin);
//    freopen("o2.out", "w", stdout);
    int n;
    cin >> n;
    build(1, 1, n);
    for (int i = 1; i <= n; i++) {
        cin >> h[i]; h[i]++;
    }
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ll mx = query(1, 1, h[i] - 1);
        dp[h[i]] = max(dp[h[i]], a[i] + mx);
        update(1, h[i], dp[h[i]]);
        ans = max(ans, dp[h[i]]);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n,k,x,count=0;
  cin >> n >> k;
  vector<int> a(n+1,0);
  a[0]=0;
  for(int i=0;i<n;i++){
    cin >> x;
    a[x]++;
  }
  sort(a.begin(),a.end());
  //for(int i=0;i<=n;i++)cout << a[i] << "\n";
  for(int i=0;i<=n-k;i++){
    count += a[i];
  }
  cout << count;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
const int MOD = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

//-------------------ここから回答する-----------------------

void solve(void)
{
    int n;
    cin >> n;
    vector<int> t(n);
    rep(i, n) cin >> t[i];
    int m;
    cin >> m;
    vector<int> p(m), x(m);
    rep(i, m) cin >> p[i] >> x[i], --p[i];
    int all = accumulate(t.begin(), t.end(), 0);
    rep(i, m) cout << all - t[p[i]] + x[i] << endl;
}
int main(void)
{
    solve();
}


Measured memory_bytes: 3604
#include<iostream>

using namespace std;

void run(char c,int n){
 	for(int i = 0; i < n; i++)cout << c; 
}
int main(){
	int sx,sy,ty,tx;

	cin >> sx >> sy >> tx >> ty;

	run('U',ty-sy);
	run('R',tx-sx);
	run('D',ty-sy);
	run('L',tx-sx+1);
	run('U',ty-sy+1);
	run('R',tx-sx+1);
	run('D',1);
	run('R',1);
	run('D',ty-sy+1);
	run('L',tx-sx+1);
	run('U',1);

	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
  while (true) {
    int e;
    scanf("%d", &e);
    if (e == 0) break;
    int m = (1 << 30);
    for (ll z=0;z*z*z<=e;z++) {
      const ll z3 = z*z*z;
      for (ll y=0;y*y+z3<=e;y++) {
        const ll x = e-(y*y+z3);
        m = min(m, (int)(x+y+z));
      }
    }
    printf("%d\n", m);
  }
  return 0;
}

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

// katana-thrower.cpp
// author: Seong Yong-ju ( @sei40kr )
// Copyright (c) 2018 Seong Yong-ju

#define DEBUG(x) cout << #x << ": " << x << endl

#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i)

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)

#define ALL(a) (a).begin(), (a).end()

using namespace std;

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

  int N, H;
  cin >> N >> H;

  int as[N], bs[N];
  REP(i, N) {
    cin >> as[i] >> bs[i];
  }

  int a_max = *max_element(as, as + N);
  sort(bs, bs + N);

  int ans = 0;

  RREP(i, N) {
    if (H <= 0) {
      break;
    }

    int b = bs[i];
    if (b < a_max) {
      break;
    }

    ++ans;
    H -= b;
  }

  if (0 < H) {
    ans += ceil((double) H / a_max);
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long H=sc.nextLong();
		long W=sc.nextLong();
		if(H==1||W==1) {
			System.out.println(1);
			System.exit(0);
		}
		if(H*W%2==1) {
			System.out.println(H*W/2+1);
		}else {
			System.out.println(H*W/2);
		}
	}
}


Measured memory_bytes: 21332
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>

using namespace std;

int main(){

    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(Q);
    vector<int> point(N, K-Q);
    for (int i = 0; i < Q; i++){
        cin >> A[i];
        A[i]--;
    }

    for (int i = 0; i < Q; i++){
        point[A[i]]++;
    }

    for (int i = 0; i < N; i++){
        if (point[i] > 0){
            // cout << "Yes" << endl;
            puts("Yes");
        } else {
            // cout << "No" << endl;
            puts("No");
        }
    }

    return 0;
}


Measured memory_bytes: 1408
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE LambdaCase #-}

module Main where

import qualified Data.ByteString.Char8 as B8
import Data.Maybe (fromJust)
import Data.Char (toUpper,isDigit)
import Data.List
import qualified Data.Map as M
import Data.Array.IO
import Data.IORef
import Data.Ix (range)
import Control.Monad
import Control.Applicative
import Text.Printf
import Data.Time.Calendar
import Debug.Trace

readDigits = map read <$> words <$> getLine :: IO [Int]
readDigits' = map read <$> lines <$> getContents :: IO [Int]

--
main :: IO ()
main = do
    ab@[a,b] <- readDigits
    let d = a `div` b
    let r = a `mod` b
    let f = (\[a,b] -> a / b) $ map realToFrac ab
    printf "%d %d %.5f\n" d r (f :: Double)

Measured memory_bytes: 4004
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

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

int mod = 1000000007;
//int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod

struct edge{int to, cost;};

class Graph
{
public:
    int N;
    vector<vector<edge>> G;
    bools used;
    vec a;
    vec vv;

    Graph(int N, vec a): N(N), a(a){
        G = vector<vector<edge>>(N, vector<edge>(0));
        used = bools(N, false);
    }

    void add_edge(int from, int to, int cost = 0){
        G[from].push_back(edge({to, cost}));
    }

    void add_edge2(int v1, int v2, int cost = 0){
        add_edge(v1, v2, cost);
        add_edge(v2, v1, cost);
    }

    void dfs(int v, int p = -1){
        if(p == -1) vv.resize(0);
        vv.pb(a[v]);
        used[v] = true;
        for(auto e: G[v]) if(!used[e.to]) dfs(e.to, v);
    }

};

signed main(){

    int N, M; cin >> N >> M;
    vec a(N); readv(a);
    Graph G(N, a);
    int x, y;
    REP(i, M){
        cin >> x >> y;
        G.add_edge2(x, y);
    }
    int n = N - M;
    if(n == 1){
        cout << 0 << endl;
        return 0;
    }
    vec v;
    int ans = 0;
    int c = 2 * (n - 1);
    REP(i, N){
        if(!G.used[i]){
            G.dfs(i);
            Sort(G.vv);
            ans += G.vv[0];
            FOR(k, 1, n - 1){
                if(k < SZ(G.vv)) v.pb(G.vv[k]);
                else break;
            }
        }
    }
    if(SZ(v) < n - 2){
        cout << "Impossible" << endl;
        return 0;
    }
    Sort(v);
    REP(k, n - 2) ans += v[k];
    cout << ans << endl;

    return 0;
}


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

int main(){
	int n,k;
	cin>>n>>k;
	ll v[n];
	for(int i=0;i<n;i++)cin>>v[i];
	ll ans = 0;
	ll tmp=0;
	vector<int> mm;
	//memset(mm,0,sizeof(mm));
	for(int x=k;x>=0;x--){
		int l=0;
		if(x>n){
			x=n;
			l = x-n;
		}
		mm.clear();
		for(int r=0;r<=x;r++){
			for(int i=0;i<x-r;i++){
				tmp += v[i];
				mm.push_back(v[i]);
			}
			for(int j=n-1;j>n-1-r;j--){
				tmp += v[j];
				mm.push_back(v[j]);
			}

			sort(mm.begin(),mm.end());
			//for(int b=0;b<mm.size();b++){
				//cout<<mm[b]<<' ';
			//}
			int cnt=0;
			if(l>0)x=l;
			for(int i=0;i<k-x;i++){
				if(mm.empty())break;
				if(cnt==x)break;
				//cout<<"tmp:"<<tmp<<" mm:"<<mm[i]<<endl;
				if(mm[i]<0)tmp-=mm[i];
				cnt++;
			}
			if(tmp>1e9){
			//	cout<<"tmp:"<<tmp<<" r:"<<r<<" x:"<<x<<endl;
			}
			ans = max(ans,tmp);
			tmp=0;
			mm.clear();
		}
	}
	cout<<ans<<endl;
}


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

using namespace std;

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

    /* 各店の営業時間情報をbit列で表す */
    vector<int> shop(N, 0);
    for ( int i = 0; i < N; i++ ) {
        for ( int jk = 0; jk < 10; jk++ ) {
            int is_open;
            cin >> is_open;
            if ( is_open ) shop.at(i) |= 1 << jk;
        }
    }

    vector<vector<int>> P(N, vector<int>(11));
    for ( int i = 0; i < N; i++ ) {
        for ( int j = 0; j <= 10; j++ ) {
            cin >> P.at(i).at(j);
        }
    }

    /* 店のありうる開け方を全部試す */
    long long ans = LLONG_MIN;
    for ( int open = 1; open < (1 << 10); open++ ) {
        long long temp = 0;
        for ( int i = 0; i < N; i++ ) {
            bitset<10> both(open & shop.at(i));
            temp += P.at(i).at(both.count());
        }
        ans = max(ans, temp);
    }

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


Measured memory_bytes: 3640
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char a[100005],b[100005];
int main()
{
	int n;
	scanf("%d",&n);
	scanf("%s",&a);
	scanf(" %s",&b);
	for(int i=0;i<n;i++)
	{
		printf("%c%c",a[i],b[i]);
	}
}

Measured memory_bytes: 128
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<map>
#define LL long long
#define M 200020
using namespace std;
LL read(){
	LL nm=0,fh=1; char cw=getchar();
	for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return nm*fh;
}
LL n,m,D[M],sz[M],now,cur,u[M],v[M],tmp,tar;
LL fs[M],nt[M<<1],to[M<<1],F[M],G[M],mx[M];
map<LL,LL>K;
void fad(){puts("-1");exit(0);}
struct node{LL id,dst;}p[M];
bool cmp(node x,node y){return x.dst<y.dst;}
void e(LL x,LL y){cur++,u[cur]=x,v[cur]=y;}
void link(LL x,LL y){nt[tmp]=fs[x],fs[x]=tmp,to[tmp++]=y;}
void dfs1(LL x){
	for(LL i=fs[x];i!=-1;i=nt[i]){
//		printf("%lld   --> %lld\n",x,to[i]);
		dfs1(to[i]),F[x]+=F[to[i]]+sz[to[i]];
	}
}
void dfs2(LL x){
	for(LL i=fs[x];i!=-1;i=nt[i]){
		G[to[i]]=G[x]-sz[to[i]]-sz[to[i]]+n,dfs2(to[i]);
	}
}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),memset(fs,-1,sizeof(fs));
	for(LL i=1;i<=n;i++) p[i].id=i,D[i]=read(),p[i].dst=D[i],K[D[i]]=i;
	sort(p+1,p+n+1,cmp);
//	for(LL i=1;i<=n;i++) printf("%lld  %lld\n",p[i].id,p[i].dst);
	for(LL i=n;i>1;i--){
		sz[p[i].id]++;
		LL num=p[i].dst-n+sz[p[i].id]*2ll;
		if(K.count(num)){
//			printf("%lld\n",num);
			m=K[num];
			sz[m]+=sz[p[i].id];
			link(m,p[i].id);
			e(m,p[i].id);
		}
		else fad();
	}
	if(sz[p[1].id]!=n-1) fad();
//	puts("S");
	dfs1(p[1].id),G[p[1].id]=F[p[1].id],dfs2(p[1].id);
	for(LL i=1;i<=n;i++) if(G[i]!=D[i]) fad();
	for(LL i=1;i<n;i++) printf("%lld %lld\n",u[i],v[i]); 
	return 0;
}

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

#define  int long long

using namespace std;

int n, m;

void sum(int& result, vector<int> x, vector<int> y, vector<int> z) {
  vector<int> t;
  for(int i=0;i<n;i++) {
    t.push_back(x[i]+y[i]+z[i]);
  }
  sort(t.begin(), t.end(), greater<int>());
  int sum = 0;
  for(int i=0;i<m;i++) {
    sum += t[i];
  }
  result = max(result, sum);
}

signed main() {
  cin >> n >> m;
  vector<int> x, y, z, xminus, yminus, zminus;
  for(int i=0;i<n;i++) {
    int p, q, r;
    cin >> p >> q >> r;
    x.push_back(p);
    xminus.push_back(-p);
    y.push_back(q);
    yminus.push_back(-q);
    z.push_back(r);
    zminus.push_back(-r);
  }

  int result = 0;

  //+++
  sum (result, x, y, z);
  //++-
  sum (result, x, y, zminus);
  //+-+
  sum (result, x, yminus, z);
  //+--
  sum (result, x, yminus, zminus);
  //-++
  sum (result, xminus, y, z);
  //-+-
  sum (result, xminus, y, zminus);
  //--+
  sum (result, xminus, yminus, z);
  //---
  sum (result, xminus, yminus, zminus);
  
  cout << result << endl;
  
  
}

Measured memory_bytes: 384
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		char [] s = sc.next().toCharArray();
		int i, j;
		for(i = 0; s[i] != 'A'; i++){}
		for(j = s.length - 1; s[j] != 'Z'; j--){}
		System.out.println((j - i + 1));
	}
}


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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

template <unsigned long long mod> class modint {
public:
	unsigned long long v;
	modint(const long long x = 0) : v(x % mod) {}
	modint operator+(const modint rhs) { return modint(*this) += rhs; }
	modint operator-(const modint rhs) { return modint(*this) -= rhs; }
	modint operator*(const modint rhs) { return modint(*this) *= rhs; }
	modint operator/(const modint rhs) { return modint(*this) /= rhs; }
	modint operator-() { return modint(mod - this->v); }
	modint& operator+=(const modint rhs) {
		v += rhs.v;
		if (v >= mod) v -= mod;
		return *this;
	}
	modint& operator-=(const modint rhs) {
		if (v < rhs.v) v += mod;
		v -= rhs.v;
		return *this;
	}
	modint& operator*=(const modint rhs) {
		v = v * rhs.v % mod;
		return *this;
	}
	modint inverse(modint a) {
		unsigned long long exp = mod - 2;
		modint ret(1ULL);
		while (exp) {
			if (exp % 2) { ret *= a; }
			a *= a;
			exp >>= 1;
		}
		return ret;
	}
	modint& operator/=(modint rhs) {
		(*this) *= inverse(rhs);
		return *this;
	}
	friend ostream& operator<<(ostream& os, modint u) {
		os << u.v;
		return (os);
	}
	friend istream& operator>>(istream& is, modint& u) {
		is >> u.v;
		return (is);
	}
};

const int MOD = 998244353;
using mint = modint<MOD>;

const int MAX = 3000005;
mint fact[MAX], invfact[MAX], inv[MAX];

void facinit() {
	fact[0] = fact[1] = 1;	
	invfact[0] = invfact[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++){
		fact[i] = fact[i - 1] * i;
		inv[i] = - inv[MOD%i] * (MOD / i);
		invfact[i] = invfact[i - 1] * inv[i];
	}
}

mint nPr(int n, int r){
	return fact[n] * invfact[n-r];
}

mint nCr(int n, int r){
	if(n < 0|| r < 0 || n < r)return mint{0};
	return fact[n]*invfact[r]*invfact[n-r];
}

mint nHr(int n, int r){
	if(n == 0 && r == 0)return mint{1};
	return nCr(n+r-1, r);
}

class Solution {
public:
	void solve() {
		int n, m;
		cin >> n >> m;
		mint ok{0}, ng{0};
		facinit();
		for(int odd=m%2; odd <= min(n,m); odd+=2){
			ok += nCr(n, odd) * nHr(n, (3*m-odd)/2);
			ng += nCr(n, odd) * (nHr(n, (m-odd)/2) * odd + nHr(n, (m-odd-2)/2) * (n-odd));
		}

		cout << ok-ng << endl;
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 70528
#include <array>
#include <iostream>

int main() {
	int a, b, c, d, e, f, g, h;
	static const std::array<int, 8> capacity{1, 2, 1, 2, 1, 4, 1, 4};
	static const std::array<int, 8> index{ 0, 2, 6, 4, 1, 3, 7, 5 };
	while (std::cin >> a >> b >> c >> d >> e >> f >> g >> h) {
		const std::array<int, 8> wait{a, b, c, d, e, f, g, h};
		int min = 1 << 30;
		int mini = 0;
		for (const auto &idx : index) {
			int sum = 0;
			for (auto i = 0; i < 8  && sum < min; ++i) {
				sum += (capacity[(i + idx) % 8] > wait[i]) ? 0 : (wait[i] - capacity[(i + idx) % 8]);
			}
			if (sum < min) {
				min = sum;
				mini = idx;
			}
		}
		std::cout << capacity[mini];
		for (auto i = 1; i < 8; ++i) {
			std::cout << " " << capacity[(i + mini) % 8];
		}
		std::cout << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3116
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long MOD = 1000000007;

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

	string s;
	cin >> s;
	
	if (s.length() % 2 != 0) {
		cout << "No" << "\n";
		return 0;
	}
	
	for (int i = 0; i < s.length(); i += 2) {
		if (s[i] != 'h' || s[i + 1] != 'i') {
			cout << "No" << "\n";
			return 0;
		}
	}

	cout << "Yes" << "\n";

	return 0;
}


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

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {

            //問題161

            string[] line = Console.ReadLine().Split(' ');

            int x = int.Parse(line[0]);
            int y = int.Parse(line[1]);
            int z = int.Parse(line[2]);

            int tmp = y;
            y = x;
            x = tmp;

            tmp = z;
            z = x;
            x = tmp;

            Console.WriteLine(x + " " + y + " " + z);


        }

    }





    
}


Measured memory_bytes: 27232
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int len;
    string s, t;
    cin >> len >> s >> t;
    char start = t[0];
    for(int i = 0; i < len; i++) {
        if(start == s[i]) {
            int a = i + 1, b = 1;
            while(a < len && s[a] == t[b]) {
                a++;
                b++;
            }
            if(a == len) {
                cout << (2 * len) - (len - i);
                return 0;
            }
        }
    }
    cout << (2 * len);
}

Measured memory_bytes: 3656
def root a
	return a if @p[a] == a
	return (@p[a] = root(@p[a]))
end

def isSameSet a, b
	return root(a) == root(b)
end

def unite a, b
	@p[root(a)] = root(b)
end

while true
	n,m = gets.split(" ").map{|e|e.to_i}
	break if n==0 && m==0
	cost=0
	@p=[]
	n.times{|t|@p.push t}
	info=[]
	m.times{
		a,b,c=gets.split(" ").map{|e|e.to_i}
		info.push [c,a,b]
	}
	info.sort!

	info.each{|e|
		if !isSameSet(e[2],e[1])
			unite(e[2],e[1])
			cost+=e[0]
		end
	}

	p cost
end

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int k = sc.NextInt();
        int[] d = sc.IntArray();

        int answer = 0;

        for (int i = n; i <= 99999; i++)
        {
            string s = i.ToString();

            bool ok = true;
            foreach (var num in d)
            {
                if (s.Contains(num.ToString()))
                {
                    ok = false;
                }
            }
            if (ok)
            {
                answer = i;
                break;
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 30396
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    ll mini=1e9+1, maxi=0;
    for(int i=0; i<n; i++){
        ll a;
        cin >> a;
        mini = min(mini, a);
        maxi = max(maxi, a); 
    }
    out(abs(maxi - mini));
}


Measured memory_bytes: 256
s = input()
hug = 0
if len(s) % 2 == 0:
  # 回文にするために必要な文字数をカウントする＝s/2の文字列まで0からとmaxlengthから一致するか調べる
  for i in range(len(s) // 2):
    if s[i] != s[len(s) - 1 - i]:
     # print(s[i], s[len(s) - 1 - i])
      hug += 1
else:
  # 回文にするために必要な文字数をカウントする＝s-1/2の文字列まで0からとmaxlengthから一致するか調べる
  for i in range(len(s) // 2):
    if s[i] != s[len(s) - 1 - i]:
      #print(i, s[i], s[len(s) - 1 - i])
      hug += 1
print(hug)

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

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

#define READ(x) (cin >> (x))

#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N, K;
  cin >> N >> K;

  vector<int>A(N);
  for (auto i = 0; i < N; ++i) {
    READ(A[i]);
  }

  // main procedure
  int ans = 0;
  ll used_time = 1;

  vector<int> visited_town_vec{1};
  unordered_set<int> visited_town_set{1};

  int current_town = A[0];
  visited_town_vec.push_back(current_town);
  visited_town_set.insert(current_town);

  while(used_time < K) {
    used_time++;
    current_town = A[current_town - 1];

    visited_town_vec.push_back(current_town);
    if (visited_town_set.count(current_town) != 0) {
      break;
    }
    visited_town_set.insert(current_town);
  }

  // WRITE_N(used_time);
  // for (auto x: visited_town_vec){
  //   cout << x << " ";
  // }
  // cout << endl;

  // WRITE_N(current_town);

  if (used_time == K) {
    ans = *(visited_town_vec.end() - 1);
  } else {
    int loop_begin_index = find(ALL(visited_town_vec), current_town) - visited_town_vec.begin();
    int loop_length = used_time - loop_begin_index;
    ll remain_time = K - used_time;
    int remainder = remain_time % loop_length;
    ans = visited_town_vec[loop_begin_index + remainder];
    // WRITE_N(loop_begin_index);
    // WRITE_N(loop_length);
    // WRITE_N(remain_time);
    // WRITE_N(remaindtimetimetimetimeer);
  }

  // output
  WRITE_N(ans);

  return 0;
}


Measured memory_bytes: 11500
#include <iostream>
#include <cstdlib>
 
using namespace std;
// https://qiita.com/Clpsplug/items/81fe12400d4093a8fb5a
 
int main() {
    int N;
    cin >> N;

    int ans = 0;
    for (int i = 1; i < N+1; i++) {
        int counter = 0;
        for (int j = 1; j < i; j++) {
            if (i%j == 0 && j < i/j) {
                counter++;
            }
        }
        if (counter == 4 && i%2 != 0) {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3224
// マニ

#include<bits/stdc++.h>
#define ll            long long 
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)  for(ll int i=a;i<b;i++)
#define rrep(i,a,b) for(ll int i=a;i>=b;i--)
#define all(a)      (a).begin(),(a).end()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define PI 3.14159265358979323846
#define tr(i, cont) for(auto i=cont.begin();i!=cont.end();i++)
#define ios            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define trace(x)                 cerr << #x << ": " << x << "\n";
#define trace1(x)                cerr << #x << ": " << x << "\n";
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << "\n";
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << "\n";
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << "\n";
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << "\n";
#define ar array
#define endl "\n"
using namespace std;

int main(){
    ios;
    string s1,s2;
    cin>>s1>>s2;
    ll ans=0;
    rep(i,0,sz(s1)){
        if(s1[i]!=s2[i]) ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 3796
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] A = new int[N];
        int total = 0;
        double kijun = 1 / (double)(4 * M);
        
        //Aに格納
        for(int i = 0; i < N; i++){
            A[i] = sc.nextInt();
            total += A[i];
        }
        
        //昇順にソート
        int maxidx = 0;
        int w = 0;
        for(int i = 0; i < N; i++){
            maxidx = i;
            w = A[i];
            for(int j = i+1; j < N; j++) {
                if(A[maxidx] < A[j]) {
                    maxidx = j;
                }
            }
            A[i] = A[maxidx];
            A[maxidx] = w;
        }
        
        //判定
        String ans = "Yes";
        for(int i = 0; i < M; i++) {
            if(A[i] < kijun * total) {
                ans = "No";
            }
        }
        
        System.out.println(ans);
        
    }
}


Measured memory_bytes: 22996
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# 初項s, 交差dのn個の数列の和
def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N = int(input())
    S = input()
    K = int(input())

    t = S[K - 1]
    ans = ""
    for c in S:
        if c != t:
            ans += "*"
        else:
            ans += c
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
#include <iostream>
using namespace std;
int main(){
    int N,C,p[100],P=0;
    cin>>N>>C;
    N=N+1;
    for(int i = 0 ; i < C ; i++){
        cin>>p[i];
        P += p[i];
    }
    if(0==P % N){
        cout<<P/N<<endl;
    }else{
        cout<<(P/N)+1<<endl;
    }
}



Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

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

    std::string ans = "";
    int i = 0;
    if(0 == n){
        ans += "0";
    }else{
        while(0 != n){
            int remainder = n % 2;
            if(0 != remainder){
                ans.push_back('1');
                --n;
            }else{
                ans.push_back('0');
            }
            n /= -2;
        }
    }

    std::reverse(ans.begin(), ans.end());

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;

int main(){
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);

    int n;
    cin >> n;
    vi ai(n);
    rep(i,0,n){ cin >> ai[i]; }
    sort(all(ai));
    vi picked(n);
    int ans = 0;
    for(int i=30;i>=0;i--){
        ll s = 1<<i;
        int p1 = 0;
        int p2 = n-1;
        while(p1 < p2){
            if(picked[p1]) p1++;
            else if(picked[p2]) p2--;
            else{
                if(ai[p1] + ai[p2] == s){
                    picked[p1] = 1;
                    picked[p2] = 1;
                    ans++;
                    p1++;
                    p2--;
                }else if(ai[p1] + ai[p2] < s){
                    p1++;
                }else{
                    p2--;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include"stdio.h"
#include<stdlib.h>

int top, A[1000];

void push(int n)
{
	A[++top] = n;
	return;
}

int pop()
{
	--top;
	return A[top+1];
}

int main()
{
	int a, b;
	top = 0;
	char str[100] = { '\0' };

	while (scanf("%s", str) != EOF)
	{
		if (str[0] == '+')
		{
			push(pop()+pop());
		}
		else if (str[0] == '-')
		{
			a = pop();
			b = pop();
			push(b - a);
		}
		else if (str[0] == '*')
		{
			push(pop()*pop());
		}
		else
			push(atoi(str));
	}

	printf("%d\n", pop());

	return 0;
}


Measured memory_bytes: 2728
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

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

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

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

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

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

// End of template.

int main() {
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cin.read(buf, sizeof buf); // 注意: ./a.out < in か pbp | ./a.out で入力すること

    char c;
    cin >> c;
    cout << char (c+1) << '\n';

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>
#include <set>
#include <bitset>
#include <limits>
#include <queue>

using namespace std;

#define ll long long

int main(void){
    int h, w;
    cin >> h >> w;

    vector<vector<char>> s(h, vector<char>(w));
    int white_num = 0;
    for(int i = 0;i < h;++i){
        for(int j = 0;j < w;++j){
            cin >> s[i][j];
            if(s[i][j] == '.'){
                white_num += 1;
            }
        }
    }

    vector<vector<int>> flag(h, vector<int>(w, 0));
    queue<int> next_i, next_j;
    next_i.push(0);
    next_j.push(0);
    flag[0][0] = 1;

    while(next_i.size() > 0){
        int i = next_i.front(), j = next_j.front();
        next_i.pop();
        next_j.pop();

        if(i+1 < h && flag[i+1][j] == 0 && s[i+1][j] == '.'){
            next_i.push(i+1);
            next_j.push(j);
            flag[i+1][j] = flag[i][j] + 1;
        }
        if(i-1 > -1 && flag[i-1][j] == 0 && s[i-1][j] == '.'){
            next_i.push(i-1);
            next_j.push(j);
            flag[i-1][j] = flag[i][j] + 1;
        }
        if(j+1 < w && flag[i][j+1] == 0 && s[i][j+1] == '.'){
            next_i.push(i);
            next_j.push(j+1);
            flag[i][j+1] = flag[i][j] + 1;
        }
        if(j-1 > -1 && flag[i][j-1] == 0 && s[i][j-1] == '.'){
            next_i.push(i);
            next_j.push(j-1);
            flag[i][j-1] = flag[i][j] + 1;
        }
    }

    if(flag[h-1][w-1] == 0){
        cout << "-1" << endl;
    }else{
        cout << white_num-flag[h-1][w-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 256