akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#define bogo_sort std::sort
#define bozo_sort std::stable_sort
#define alles(obj) obj.begin(), obj.end()
#define elif else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo std::cout <<
#define read std::cin >>
#define endl std::endl
#define fin << '\n'
#define bash push_back
#define makePair std::make_pair
#define _ << ' ' <<
// type-define
#define Stack std::stack
#define Queue std::queue
#define Set std::set
#define PQueue std::priority_queue
#define Vector std::vector
#define Pair std::pair
#define Map std::map
#define HashMap std::unordered_map
#define Greater std::greater
using String = std::string;
using llong = long long;
using boolean = bool;
using Pii = Pair<int, int>;
using Vi = Vector<int>;
using Vii = Vector<Pii>;
// utils
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    template<class A, class B> A power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    template<class A, class B> A power ( A x, B n ) { return power( x, n, 1000000007 ); }
    template<class A> A gcd ( A x, A y ) { return x % y ? gcd( y, x % y ) : y; }
    template<class A, class B> A lcm ( A x, B y ) { return ( x / gcd(x, y) * y ); }
//    template<class A> inline A abs ( A n ) { return ( n < 0 ) ? -n : n; }
    template<class A, class B> inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B> inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    int l[16];

    int n, A, B, C;

    int dfs ( int pos, int a, int b, int c ) {
        if ( pos == n ) {
            unless ( a && b && c ) return INF;
            return abs(a-A) + abs(b-B) + abs(c-C) - 30;
        }
        int rec  = dfs(pos+1, a, b, c);
        chmin(rec, dfs(pos+1, a+l[pos], b, c) + 10);
        chmin(rec, dfs(pos+1, a, b+l[pos], c) + 10);
        chmin(rec, dfs(pos+1, a, b, c+l[pos]) + 10);
        return rec;
    }

    signed call_of_Cthulhu( signed datum ) {

        read n >> A >> B >> C;
        for ( int i = 0; i < n; i++ ) {
            read l[i];
        }

        echo dfs(0, 0, 0, 0) fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

int main() {
  i64 H, W, K;
  cin >> H >> W >> K;
  i64 sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  vector<string> f(H + 2, string(W + 2, '@'));
  rep(i,0,H) {
    string s;
    cin >> s;
    f[i + 1] = "@" + s + "@";
  }
  using P = pair<i64, i64>;
  struct info {
    P p;
    i64 d;
    bool operator<(const info& b) const {
      return p < b.p;
    }
  };
  using PP = pair<P, info>;
  priority_queue<PP, vector<PP>, greater<PP>> que;
  auto dist = ndvec(H + 2, W + 2, 5, P(1e18, 0));
  dist[sx][sy][4] = P(0, 0);
  que.push({P(0, 0), { {sx, sy}, 4}});

  vector<i64> dx{ 1, 0, -1, 0};

  while(!que.empty()) {
    P di = que.top().first;
    P p = que.top().second.p;
    i64 pd = que.top().second.d;
    que.pop();
    if(di > dist[p.first][p.second][pd]) continue;
    if(pd == 4) {
      auto cost = P(di.first + 1, 0);
      rep(d,0,4) {
        auto next = P(p.first + dx[d], p.second + dx[d ^ 1]);
        if(f[next.first][next.second] == '.' && dist[next.first][next.second][d] > cost) {
          dist[next.first][next.second][d] = cost;
          que.push({ cost, { next, d } });
        }
      }
    }
    else {
      {
        auto cost = P(di.first, 0);
        if(dist[p.first][p.second][4] > cost) {
          dist[p.first][p.second][4] = cost;
          que.push({ cost, { p, 4 } });
        }
      }
      [&](){
        auto cost = P(di.first, di.second + 1);
        if(cost.second >= K) return;
        auto next = P(p.first + dx[pd], p.second + dx[pd ^ 1]);
        if(f[next.first][next.second] == '@') return;
        if(dist[next.first][next.second][pd] > cost) {
          dist[next.first][next.second][pd] = cost;
          que.push({ cost, { next, pd } });
        }
      }();
    }
  }
  i64 ans = dist[tx][ty][4].first;
  if(ans == i64(1e18)) ans = -1;
  cout << ans << endl;

}



Measured memory_bytes: 474876
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define maxn 10004
#define mod 1000000007
#include <bits/stdc++.h>
using namespace std;

ll nxt(ll n){
    ll keep = n;
    vector<ll> v;
    while(n){
        v.pb(n%10);
        n /= 10;
    }
    ll sz = v.size();
    if(sz == 1) return keep + 1;
    bool ok = false;
    for(ll i=0;i<sz;i++){
        if( (i==sz-1) &&  (v[i] != 9) && abs(v[i-1]- (v[i]+1) )<=1){
            v[i]++;
            ll val = v[i];
            for(ll j=i;j>=0;j--){
                v[j] = val;
                val --;
                val = max(0LL, val);
            }
            ok = true;
            break;
        }
        if( (i==0) &&  (v[i] != 9) && abs(v[i+1]- (v[i]+1) )<=1){
            v[i]++;
            ll val = v[i];
            for(ll j=i;j>=0;j--){
                v[j] = val;
                val --;
                val = max(0LL, val);
            }
            ok = true;
            break;
        }
        if( (v[i] != 9) && abs(v[i+1]- (v[i]+1) )<=1 && abs(v[i-1]- (v[i]+1) )<=1 ){
            v[i] ++;
            ll val = v[i];
            for(ll j=i;j>=0;j--){
                v[j] = val;
                val --;
                val = max(0LL, val);
            }
            ok = true;
            break;
        }
    }
    if(!ok) {
        //cout << keep << " "<< keep+1<< endl;
        return keep+1;
    }
    ll temp = 1;
    ll res = 0;
    for(auto x: v){
        res += temp * x;
        temp *= 10;
    }
    //cout << keep << " "<< res << endl;
    return res;

}


int main() {
    int tc = 1;
    while(tc--){
        ll cur = 0, n;
        cin >> n;
        while(n--){
            cur = nxt(cur);
        }
        cout << cur  << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
from collections import Counter

def main():
    n=int(input())
    S=[input().strip() for _ in range(n)]
    C=Counter(S)
    cnt=C.most_common()[0][1]
    Ans=[]
    for key,val in C.items():
        if val==cnt:
            Ans.append(key)
    Ans.sort()
    print(*Ans,sep='\n')
    
if __name__=='__main__':
    main()

Measured memory_bytes: 116564
#include <stdio.h>
#include <stdlib.h>
#include "time.h"
#include "unistd.h"
#include "string.h"
#include <math.h>
int ans=0;
long long sort(long long d[],int NumberArrays,int up){
  int tmp;
  for (int i = 0; i < NumberArrays-1; i++) {
    if (up && d[i]<d[i+1]) {
      d[i]=tmp;
      d[i]=d[i+1];
      d[i+1]=tmp;
    }else if (d[i]>d[i+1]) {
      d[i]=tmp;
      d[i]=d[i+1];
      d[i+1]=tmp;
    }
  }
}
long long int getgcd(long long n, long long m)
{
  int r;
  if (n > m) {
    long long t = m;
    m = n;
    n = t;
  }
  while ((r = m % n) != 0) {
    m = n;
    n = r;
  }
return n;
}

//nの階乗を計算
long long factorial(long long n){
    int answer = 1;
while(n > 1){
  answer *= n;
  n--;
}
    return answer;
}

//組み合わせの数nCrを計算
long long calcNumOfCombination(long long  n, long long r){
    return factorial(n) / (factorial(r) * factorial(n-r));
}


int main(int argc, char* argv[]){
	long long int a = 0, b = 0, c = 1,d=1;
  char f[3];
	scanf("%lld",&a);
  a++;
  for (int i = 1; i < a; i++) {
    for (int j = 1; j < a; j++) {
      for (int k = 1; k < a; k++) {
        b+=getgcd(getgcd(i,j),k);
      }
    }
  }
  printf("%lld\n",b);
}


Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
const int maxn=2e5+7;
ll base[maxn],cf[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    cin>>n>>m;
    vi a(n),d(n);
    ll ans=0;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=1;i<n;i++) 
    {
        d[i]=(a[i]-a[i-1]+m)%m,ans+=d[i];
        if(a[i]>a[i-1])
        {
            cf[a[i-1]+2]++;
            cf[a[i]+1]--;
            base[a[i]+1]-=d[i]-1;
        }
        else{
            base[1]+=d[i]-a[i];
            cf[2]++;
            cf[a[i]+1]--;
            base[a[i]+1]-=d[i]-1;
            cf[a[i-1]+2]++;
        }
    }
    ll mx=0;
    ll cur=0,cc=0;
    for(int i=1;i<=m;i++)
    {
        cc+=cf[i];
        cur+=base[i];
        cur+=cc;
        mx=max(mx,cur);
        //dbg(i,cur);
    }
    cout<<ans-mx<<'\n';

}

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

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while (true) {

			String str[] = br.readLine().split(" ");

			int n = Integer.parseInt(str[0]);
			int x = Integer.parseInt(str[1]);

			if (n == 0 && x == 0)
				break;

			long ans = 0;
			for (int i = 1; i <= n; i++) {
				for (int j = i + 1; j <= n; j++) {
					for (int k = j + 1; k <= n; k++) {
						if (i == j || j == k || k == i)
							continue;

						if (i + j + k == x) {
							ans++;
						}
					}
				}
			}
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 24796
#include <stdio.h>
#include <map>
#include <queue>

using namespace std;

int n,m;
map<int,map<int,bool>> edges[100000];
int dp[100000]{};
map<int,map<int,bool>> arrived;
queue<int> q;

void calc(int now, int pre, int cost, int comp, int count) {
  //printf("%d,%d,%d,%d,%d\n",now,pre,cost,comp,count);
  if(arrived[now][comp]) return;
    //printf("%d,%d,%d,%d\n",now,pre,cost,comp);

  if(dp[now]==0) {
    dp[now] = cost;
    q.push(now);
  }
  //printf("size=%d\n",q.size());

  arrived[now][comp] = true;

  for(auto next_itr = edges[now][comp].begin(); next_itr != edges[now][comp].end(); next_itr++) {
    int next = next_itr->first;
    //printf("  %d\n",next);
  }
  for(auto next_itr = edges[now][comp].begin(); next_itr != edges[now][comp].end(); next_itr++) {
    int next = next_itr->first;
    calc(next,now,cost,comp,count+1);
  }
/*
  if(pre!=-1) {
    edges[now][comp].erase(edges[now][comp].begin(),edges[now][comp].end());
    edges[pre][comp].erase(edges[pre][comp].begin(),edges[pre][comp].end());
  }
  */
}

int main() {
  scanf("%d%d",&n,&m);
  for(int i = 0; i < m; i++) {
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    a--;b--;c--;
    //printf("-- %d,%d,%d\n",a,b,c);
    edges[a][c][b] = true;
    edges[b][c][a] = true;
  }

  q.push(0);
  int ans = 0;
  while(dp[n-1]==0&&q.size()!=0) {
    ans++;
    int size = q.size();
    for(;size>0;size--) {
      int node = q.front();q.pop();
      //edges[node]
      for(auto com_itr = edges[node].begin(); com_itr != edges[node].end(); com_itr++) {
        int company = com_itr->first;
        calc(node,-1,ans,company,0);
      }
    }
  }
  printf("%d\n",(dp[n-1]>0)?ans:-1);
}


Measured memory_bytes: 84096
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] mochi = new int[n];
        for (int i = 0; i < mochi.length; i++) {
            mochi[i] = sc.nextInt();
        }

        Arrays.sort(mochi);
        int step = 1;
        int max_mochi = mochi[mochi.length - 1];
        for (int i = mochi.length - 2; i >= 0; i--) {
            if (mochi[i] < max_mochi) {
                step++;
                max_mochi = mochi[i];
            }
        }

        System.out.println(step);
    }
}

Measured memory_bytes: 23380
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;


struct point
{
	long long x; long long y;
	bool operator<(const point& rhs) const {
		if (y != rhs.y) {
			return y < rhs.y;
		}
		else {
			return x < rhs.x;
		}
	}
};

ll const MAX = 200005;
point p[MAX];


int main() {
	ll w, h, n;
	cin >> h >> w >> n;
	ll ans = h;
	REP(i, 1, n) {
		ll x, y;
		cin >> x >> y;
		p[i] = { x,y };
	}
	sort(p + 1, p + 1 + n);
	ll pen = 0;
	REP(i, 1, n) {
		point cur = p[i];
		ll curx = cur.x; ll cury = cur.y;
		//cout << curx << " # " << cury << " " << " ";
		if (curx - 1  >= cury + pen) {
			ans = min(ans, curx - 1);
			//cout << '&' << " ";
			if (ans == curx - 1) {
				//cout << "!";
			}
		}
		if (curx == cury + pen) {
			pen++;
			//cout << "?";
		}
		//cout << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

const lint MOD = pow(10, 9) + 7;

/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/


int main() {
	vector<int>V(4);
	rep(i, 4) {
		cin >> V[i];
	}
	sort(V);
	if (V[0] == 1 && V[1] == 4 && V[2] == 7 && V[3] == 9) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int s[101];
int main(){
	int n,k;
	int ans=0;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>s[i];
	}
	sort(s+1,s+1+n);
	for(int i=n;i>=n-k+1;i--)
	ans+=s[i];
	cout<<ans;
}


Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as M


-- [a] <- map read . words <$> getLine => [1] -> a == 1
-- 1
-- a <- readLn
-- 1 2 3
-- lst <- map read . words <$> getLine => [1, 2, 3]
-- 1 2 3
-- [l, m, n] <- map read . words <$. getLine :: IO [Int] => [1, 2, 3]
-- 'a'
-- c <- getChar => c == 'a'
--
-- slst <- replicateM h getLine

getBysplit = map read . words <$> getLine

countBySame' :: (Ord a) => [a] -> [Int]
countBySame' [] = []
countBySame' lst = let x:xs = lst
                       (n, list) = samelist x xs 0
                   in n : countBySame' list
  where
    samelist ::(Ord a) => a -> [a] ->  Int -> (Int, [a])
    samelist a [] n = (n+1, [])
    samelist a (x:xs) n
                  | a == x = samelist a xs (n+1)
                  | a /= x = (n+1, x:xs)

--累積和を表すListを作成する関数
cumSum :: [Int] -> [Int]
cumSum lst = 0 : makeSums 0 lst
    where
      makeSums :: Int -> [Int] -> [Int]
      makeSums acc [] = []
      makeSums acc (x:xs) = (acc+x) : makeSums (acc+x) xs

reshape :: String -> [Int] -> [Int]
reshape _ [] = undefined
reshape xs ys = case (h, t) of
                  ('1', '1') -> ys
                  ('1', '0') -> ys ++ [0]
                  ('0', '1') -> 0 : ys
                  _ -> [0] ++ ys ++ [0]
    where
      h = head xs
      t = head xs

kadd :: Int -> Int
kadd k = 2 * k + 1

solve :: Int -> Int -> M.Map Int Int -> Int
solve k limit mmap = f [0,2..limit] mmap
      where
        f :: [Int] -> M.Map Int Int -> Int
        f lst mmap = foldl g 0 lst
          where
            add :: Int
            add = kadd k

            g :: Int -> Int -> Int
            g acc left = let
              Just value1 = M.lookup left mmap
              Just value2 = M.lookup (min (left + add) limit) mmap
              in max (value2 - value1) acc

main :: IO()
main = do
  [n, k] <- getBysplit :: IO [Int]
  s <- getLine
  let nums = reshape s $ countBySame' s
  let sums = cumSum nums
  let sumsMap = M.fromList $ zip [0..] sums
  print $ solve k (length nums) sumsMap


Measured memory_bytes: 41724
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>

using namespace std;


int main(int argc, char **argv) {
    int N, L;
    cin >> N >> L;
    priority_queue<pair<int, int>, std::vector<pair<int, int>>, greater<pair<int, int>>> que;

    for (int i=1; i<=N; ++i) {
        int g = i + L -1;
        que.push(std::make_pair(abs(g), g));
    }

    que.pop();
    int ans{0};
    while(! que.empty()) {
        ans += que.top().second;
        que.pop();
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	string _S, T;
	cin >> _S >> T;

	bool matched;
	for (int32_t i = (int32_t)_S.size() - (int32_t)T.size(); i >= 0; i--) {
		matched = true;
		for (size_t j = 0; j < T.size(); j++) {
			if (_S[i + j] != T[j] && _S[i + j] != '?') {
				matched = false;
				break;
			}
		}
		if (!matched)
			continue;

		for (size_t j = 0; j < T.size(); j++) {
			_S[i + j] = T[j];
		}
		break;
	}
	if (matched) {
		for (int32_t i = 0; i < (int32_t)_S.size(); i++) {
			if (_S[i] == '?')
				_S[i] = 'a';
		}
		cout << _S << endl;
	} else {
		cout << "UNRESTORABLE" << endl;
	}

	return 0;
}

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

#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
#define MP make_pair
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;

signed main(){
    int n; cin >> n;
    cout<<ceil((double)n/2)<<endl;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    LL n;cin>>n;
    VL a(n+1);
    REP(i,n+1){
        cin>>a[i];
    }
    if(n==0){
        if(a[0] == 1){
            cout<<1<<endl;
            return;
        }
        else{
            cout<<-1<<endl;
            return;
        }
        return;
    }

    VL c(n+1);
    c[n]=a[n];
    PER(i,n){
        c[i] = a[i]+c[i+1];
    }

    LL node=0;
    LL now=1;
    REP(i,n+1){
        node += now;
        now-=a[i];
        if(i!=n){
            if(now<=0){
                cout<<-1<<endl;
                return;
            }
            if(now>c[i+1]){
                cout<<-1<<endl;
                return;
            }
            now = min(now*2, c[i+1]);
        }
    }
    if(now != 0){
        cout<<-1<<endl;
    }
    else{
        cout<<node<<endl;
    }


}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 4784
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():
    N, K = map(int, input().split())


    H=[]
    for i in range(N):
        H.append(int(input()))

    H.sort()
    mm = 10**9+7
    for i in range(N-K+1):
        mm=min(mm,H[i+K-1] -H[i] )

    print(mm)


if __name__ == "__main__":
    main()


Measured memory_bytes: 77092
using System;
using System.Linq;

namespace ABC088B_CardGameForTwo
{
    public class MainClass
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] cards = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            Array.Sort(cards);
            Array.Reverse(cards);

            int aliceTotal = 0;
            int bobTotal = 0;
            for (int i = 0; i < n; i++)
            {
                if (i%2 == 0)
                {
                    aliceTotal += cards[i];
                }
                else
                {
                    bobTotal += cards[i];
                }
            }
            Console.WriteLine(aliceTotal - bobTotal);
        }
    }
}


Measured memory_bytes: 11220
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

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

using namespace std;

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

    ll X, Y;
    cin >> X >> Y;

    if (X % Y != 0) cout << X << "\n";
    else cout << -1 << "\n";
}

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

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

map<vector<int>, int> mp; // mp[パズルの状態] = その状態になるまでの手数

void bfs(vector<int> origin) {
  queue<vector<int>> que;
  que.push(origin);
  mp[origin] = 0;

  while (que.size()) {
    vector<int> axis = que.front(); que.pop();

    int zeroPos = 0;
    for (int i = 0; i < axis.size(); i++) {
      if (axis[i] == 0) zeroPos = i;
    }
    int y = zeroPos / 4, x = zeroPos % 4;
    int pos = 4 * y + x;

    for (int i = 0; i < 4; i++) {
      int ny = y + dy[i], nx = x + dx[i];
      if (ny < 0 || ny >= 2 || nx < 0 || nx >= 4) continue;

      int npos = ny * 4 + nx;
      vector<int> next = axis;
      swap(next[pos], next[npos]);
      if (mp.count(next)) continue;
      mp[next] = mp[axis] + 1;
      que.push(next);
    }
  }
}

signed main() {
  // 前処理
  vector<int> origin(8);
  iota(origin.begin(), origin.end(), 0);
  bfs(origin);

  string s;
  while (getline(cin, s)) {
    // 文字列の入力を数値の配列にする
    vector<int> v;
    for (int i = 0; i < s.size(); i+=2) {
      v.push_back(s[i] - '0');
    }
    // 前計算の結果を出力するだけ
    cout << mp[v] << endl;
  }

  return 0;
}


Measured memory_bytes: 5648
#include <bits/stdc++.h>
using namespace std;
int main(){
    int M1,D1,M2,D2;
    cin >> M1 >> D1 >> M2 >> D2;

    if(M1 == M2){
        cout << 0 << endl;
    }
    else{
        cout << 1 << endl;
    }
}

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

int main() {
int n,i,u,v,ans=0;
cin>>n;
int dp[n+1][4];
int x[n+1],y[n+1];
for(i=1;i<=n;i++){
    cin>>x[i]>>y[i];
}
dp[1][0]=-x[1]-y[1];
dp[1][3]=x[1]+y[1];
dp[1][1]=x[1]-y[1];
dp[1][2]=-x[1]+y[1];
for(i=2;i<=n;i++){
    ans=max(ans,x[i]+y[i]+dp[i-1][0]);
    ans=max(ans,x[i]-y[i]+dp[i-1][2]);
    ans=max(ans,y[i]-x[i]+dp[i-1][1]);
    ans=max(ans,-y[i]-x[i]+dp[i-1][3]);
    dp[i][0]=max(dp[i-1][0],-x[i]-y[i]);
    dp[i][3]=max(dp[i-1][3],x[i]+y[i]);
    dp[i][1]=max(dp[i-1][1],x[i]-y[i]);
    dp[i][2]=max(dp[i-1][2],-x[i]+y[i]);
}cout<<ans;
	return 0;
}


Measured memory_bytes: 8320
#include <iostream>
using namespace std;
#define MAX 1000000
int sosu[MAX];

int main()
{
  sosu[0] = 0;
    sosu[1] = 0;
    for(int i = 2 ; i < MAX ; i++) sosu[i] = 1;
    for(int i = 2 ; i*i < MAX ; i++){
      if(sosu[i] == 1){
	for(int j = i*2 ; j <= MAX ; j+=i){
	  sosu[j] = 0;
	}
      }
    }
    
  while(true){
    int a, d, n;
    cin >> a >> d >> n;
    if(a == 0 && d == 0 && n == 0) break;
    int cnt = 0;
    for(int i = a ; ; i += d){
      if(sosu[i] == 1) cnt++;
      if(cnt == n){	
	break;
      }
      a += d;
    }
    cout << a << endl;
  }
}

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

#include <iostream>
#include <fstream>

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

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, _begin, _end) for (__typeof(_end) end = _end, begin = _begin,  i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0, _len = (end); i < (_len); i += 1)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define readint ({int t;cin >> t;t;})

const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


//#define int ll

class BOrdinaryNumber {
public:
    int A[55];
void solve(std::istream& cin, std::ostream& cout) {
    int N;
    cin >> N;
    _for(i,N)cin >> A[i];
    int sum = 0;
    rep(i,1,N-1)if(A[i] != min({A[i-1], A[i], A[i+1]}) && A[i] != max({A[i-1], A[i], A[i+1]}))sum ++;
    cout << sum << endl;


}
};


#undef int
int main() {
	BOrdinaryNumber solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	in.tie(0); ios::sync_with_stdio(0); out<<fixed<<setprecision(20);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int n,nx, s=0;

	cin >> n;

	nx = n;

	while (nx > 0) {
		s += nx % 10;
		nx /= 10;
	}

	cout << (n%s == 0 ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 256
N=int(input())
P=list(map(int, input().split()))
Q=P[:]
Q.sort()

not_equal_count=0
for i in range(N):
  if P[i] != Q[i]:
    not_equal_count += 1
if not_equal_count in [0, 2]:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n;
   cin >> n;
    vector<long long int>A;
  for(long long int i=0;i<n;i++)
  {
      int x;
      cin >> x;
      A.push_back(x);
  }
  unordered_map<long long int,long long int>mp;
   long long int sum = 0;
    for(int i=0;i<A.size();i++)
    {
        mp[A[i]]++;
        sum+=A[i];
    }
   long long int m;
    cin >> m;
    while(m--)
    {
       long long int x ,y;
        cin >> x >> y;
    if(mp[x]!=0)
    {
        long long  int occur = mp[x];
        sum = sum-occur*x;
        mp[x]=0;
        mp[y]+=occur;
       sum+=occur*y;
        cout<<sum << endl;
    }
        else
        {
            cout<<sum<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 7944
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

//定数
#define MOD 1000000007
//マクロ
#define rep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))

#define vsort(v) sort((v).begin, (v).end);


typedef unsigned long long int ull;
typedef long long lint;

using namespace std;














int main(){
    int N, K, Q, A;

    //入力
    cin >> N >> K >> Q;
    vector<lint> point(N, K);
    
    rep(i, Q){
        cin >> A;
        point[A-1]++;
    }
    rep(i, N) point[i] -= Q;

    
    rep(i, N)   cout << (point[i]>0 ? "Yes\n" : "No\n");

    return 0;
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

i64 H;

i64 f(i64 n) {
    if (n <= 1) return 1;
    return f(n / 2) * 2 + 1;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    read(H);

    print(f(H));

    return 0;
}


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

const ll MOD = 1000000007;

ll modpow(ll x, ll n){
    ll res = 1;
    ll mul = x;
    while(n){
        if(n % 2) res = res * mul % MOD;
        mul = mul * mul % MOD;
        n /= 2;
    }
    return res;
}

struct Combination
{
    int maxn;
    vector<ll> fmemo;
    vector<ll> imemo;
    vector<ll> ifmemo;
    
    Combination(int maxn) : maxn(maxn){
        fmemo.resize(maxn + 1);
        imemo.resize(maxn + 1);
        ifmemo.resize(maxn + 1);
        for(ll i = 1; i <= maxn; i++){
            imemo[i] = modpow(i, MOD - 2);
        }
    }

    ll fact(ll n){
        if(n == 0) return 1;
        if(fmemo[n]) return fmemo[n];
        return fmemo[n] = n * fact(n - 1) % MOD;
    }

    ll ifact(ll n){
        if(n == 0) return 1;
        if(ifmemo[n]) return ifmemo[n];
        return ifmemo[n] = imemo[n] * ifact(n - 1) % MOD;
    }

    ll com(ll n, ll k){
        if(k > n) return 0;
        if(k == n || k == 0) return 1;
        return (fact(n) * ifact(k) % MOD) * ifact(n - k) % MOD;
    }
};

int main()
{
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    Combination com(200000);
    ll ans = 0;
    for(int i = 1; a + i <= h && b + i <= w; i++){
        ans = (ans + com.com(b + h - a - 1, b + i - 1) * com.com(a + w - b - 1, a + i - 1)) % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 12696
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
 
import java.util.*;
import java.lang.*;
import java.io.*;

@SuppressWarnings("unchecked")
public class Main implements Runnable {

  static BufferedReader in;
  static PrintWriter out;
 
  public static void main(String[] args) {
      new Thread(null, new Main(), "whatever", 1<<29).start();
  }


  /* Iterative Function to calculate 
    (x^y)%p in O(log y) */
    static long power(long x, long y, long p) 
    { 
          
        // Initialize result 
        long res = 1L; 
      
        // Update x if it is more than or 
        // equal to p 
        x = x % p; 
                      
        while (y > 0L) 
        { 
              
            // If y is odd, multiply x 
            // with result 
            if (y % 2 == 1L) 
                res = (res * x) % p; 
      
            // y must be even now 
            y = y >> 1L; // y = y/2 
            x = (x * x) % p; 
        } 
          
        return res; 
    } 

    // Returns n^(-1) mod p 
    static long modInverse(long n, long p) 
    { 
        return power(n, p-2, p); 
    } 
      
    // Returns nCr % p using Fermat's 
    // little theorem. 
    static long nCrModPFermat(long n, long r, 
                                    long p) 
    { 
          
        // Base case 
        if (r == 0L) 
            return 1L; 
      
        // Fill factorial array so that we 
        // can find all factorial of r, n 
        // and n-r 
        long fac = 1L;
          
        for (int i = 1 ;i <= r; i++) {
          fac = (fac * (n-(i-1))) % p;
          fac = (fac * modInverse(i, p)) % p;
        }
      
        return fac; 
    }
 
  public void run() {
    in = new BufferedReader(new InputStreamReader(System.in));
    out = new PrintWriter(System.out, false);
 
    try
    {
      // in = new BufferedReader(new FileReader("class_treasurer.txt"));
      // out = new PrintWriter("output.txt");

      int t,x1,n,aCnt,bCnt,i;
      String str;
      String[] token;

      str=in.readLine().trim();
      n=str.length();
      boolean valid=true;
      
      for(i=0;i<n;i+=2) {
        if(i+1<n && str.charAt(i)=='h' && str.charAt(i+1)=='i') {

        }
        else {
          valid=false;
        }
      }

      if(!valid) {
        out.println("No");
      }
      else {
        out.println("Yes");
      }


      out.flush();
      out.close();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
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; }
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); i++)

int main() {
  string S;
  cin >> S;
  int ans=0;
  int cnt=0;
  rep(i,S.size()){
    cnt=0;
      for(int j=i;j<S.size();j++){
      if(S[j] =='A' || S[j] =='C' || S[j] =='G' || S[j] =='T'){
        cnt++;

      }else break;
    }
    chmax(ans,cnt);
    
  }
  cout << ans << endl;
}


Measured memory_bytes: 3592
M, N = map(int, input().split())
A = [int(i) for i in input().split()]

if M == 2 :
  a, b = 0, 0
  for i in range(N) :
    if (i % 2) == (A[i] % 2) :
      a += 1
    else :
      b += 1
  print(min(a, b))
  
else :
  ret = 0
  for i in range(1, N) :
    if A[i] == A[i - 1] :
      ret += 1
      A[i] = 0
      
  print(ret)


Measured memory_bytes: 16668
using System;

class Program{
  static void Main(){
    var i1 = Console.ReadLine();
    var i2 = Console.ReadLine();
    string[] point1 = i1.Split(' ');
    string[] point2 = i2.Split(' ');
    int n1 = 0,n2 = 0;
    for(int m = 0;m<4;m++){
      n1 += int.Parse(point1[m]);
      n2 += int.Parse(point2[m]);
    }
    Console.WriteLine(Math.Max(n1,n2));
  }
}

Measured memory_bytes: 9184
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#include <assert.h>
#include <numeric>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)(1e5)
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){fast;
	int i,c=0;string a,b;cin>>a>>b;
	for(i=0;i<a.size();i++) c+=(a[i]!=b[i]);
	cout<<c<<endl;
}


Measured memory_bytes: 3844
#include<stdio.h>

int Partition(int A[], int p, int r){
  int x = A[r], i = p-1, j;
  int sw;

  for(j = p ; j < r ; j++){
    if(A[j] <= x){
      i++;
      sw=A[i], A[i]=A[j], A[j]=sw;
    }
  }
  sw=A[i+1], A[i+1]=A[r], A[r]=sw;

  return i+1;
}

int main(void){
  int m,n,i;

  scanf("%d", &n);

  int A[n];

  for(i = 0 ; i < n ; i++){
    scanf("%d", &A[i]);
  }
  m = Partition(A, 0, n-1);

  for(i = 0 ; i < m ; i++){
    printf("%d ", A[i]);
  }
  printf("[%d]", A[m]);

  for(i = m+1 ; i < n ;i++){
    printf(" %d", A[i]);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 2128
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>
#include <set>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d\n",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

//最大公約数
ll gcd(ll a, ll b) {
	if (a%b == 0)
		return b;
	return gcd(b, a%b);
}

int main(void)
{

	char a, b, c;

	cin >> a >> b >> c;

	int d[3] = {};

	d[a - 'a'] = 1;
	d[b - 'a'] = 1;
	d[c - 'a'] = 1;

	if (d[0] + d[1] + d[2] == 3) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


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

int main() {
  int N, A, tmp = 0, min = 0;
  cin >> N;
  
  for(int i = 0; i < N; i++){
    cin >> A;
    while(!(A % 2)){
      tmp++;
      A /= 2;
    }
    if(tmp < min || i == 0){
      min = tmp;
    }
    if(min == 0){
      break;
    }
    tmp = 0;
  }
  
  cout << min << endl;
}


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

using namespace std;

#define f first
#define s second
#define pb push_back
#define np next_permutation
#define bs binary_search
#define mp make_pair
#define all(x) x.begin(), x.end()
#define bp __builtin_popcountll
#define sqr(x) ((llong)sqrt (x))
#define b_ctz __builtin_ctzll
#define b_clz __builtin_clzll

#define y1 road_to_respa_top_6
#define prev road_to_respa_top_6
#define Abdrakhman abcdefghijklmnopqrstuvwxyzRakhman
#define left kotoriy_levee_chem_right
#define right kotoriy_pravee_chem_left

#define android ios_base::sync_with_stdio(0), cin.tie (0), cout.tie (0)
#define fn ""

typedef long long llong;
typedef long double ldouble;
typedef unsigned long long ullong;

typedef vector <int> vi;
typedef vector <string> vs;
typedef vector <vector <llong> > matrix;

typedef pair <llong, llong> pll;

typedef map <int, int> mii;

typedef set <llong> sl;

const int MXN = 1e6 + 1;
const llong MNN = 1e3 + 1;
const llong MOD = 1e9 + 7;
const int INF = 1e9;
const llong LINF = 1e18;
const llong MAGIC = 1000;
const ldouble EPS = 1e-9;
const ldouble PI = 3.1415926536;
const string TIME = "rovno_ushten_push_ketti";

inline llong log2 (llong x) {return 64 - b_clz (x) - 1;};
inline llong __lcm (llong a, llong b) {return a / __gcd (a, b) * b;}

llong a, b, c;

int main () {
    android;
    //freopen ("input.txt", "r", stdin);
    cin >> a >> b >> c;
    if (a == b && b == c && a % 2 == 0) return cout << -1, 0;
    int cnt = 0;
    while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
        llong aa = a / 2, bb = b / 2, cc = c / 2;
        a = bb + cc;
        b = aa + cc;
        c = aa + bb;
        cnt ++;
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MAX_N = 100010;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
int main(){
    string s; cin >> s;
    ll k; cin >> k;
    ll n = s.size();
    set<char> se;
    rep(i, n) se.insert(s[i]);
    if(se.size() == 1){
        cout << n * k / 2 << endl;
        return 0;
    }
    ll count_inner = 0, count_outer = 0;
    ll count;

    for(int i = 1; i < n; i++){
        count = 0;
        if(s[i] == s[i - 1]){
            while(i < n and s[i] == s[i - 1]){
                count++, i++;
            } 
        }
        count_inner += (count + 1) / 2;
    }
    string t = s + s;
    for(int i = 1; i < 2 * n; i++){
        count = 0;
        if(t[i] == t[i - 1]){
            while(i < 2 * n and t[i] == t[i - 1]){
                count++, i++;
            } 
        }
        count_outer += (count + 1) / 2;   
    }
    ll ans = count_inner + (count_outer - count_inner) * (k - 1);
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include <stdio.h>

int main(void) {
	int A, B, K;
	int s1, e1, s2, e2;
	int i;
	if (scanf("%d%d%d", &A, &B, &K) != 3) return 1;
	s1 = A;
	e1 = A + K;
	s2 = B - K + 1;
	e2 = B + 1;
	if (B + 1 < e1) e1 = B + 1;
	if (s2 < A) s2 = A;
	if (s2 < e1) e1 = s2;
	for (i = s1; i < e1; i++) printf("%d\n", i);
	for (i = s2; i < e2; i++) printf("%d\n", i);
	return 0;
}


Measured memory_bytes: 128
D = int(input())
C = [int(x) for x in input().split()]
S = []
for i in range(D):
    S.append([int(x) for x in input().split()])
T = [int(input()) for i in range(D)]


def last(d, i):
    l = 0
    for j in range(1, d + 1):
        if T[j - 1] == i + 1:
            l = j
    return l


score = 0

for d in range(1, 1 + D):
    score += S[d - 1][T[d - 1] - 1] - \
        sum([C[i]*(d - last(d, i)) for i in range(26)])
    print(score)


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll r,g,b,n;

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

  cin>>r>>g>>b>>n;
  ll res=0;
  rep(i,n+1)rep(j,n+1){
    ll rest=n-(i*r+j*g);
    if(rest<0||rest%b!=0)continue;
    res++;
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256