akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    char a, b;
    cin >> a >> b;
    string aa(a - '0', b), bb(b - '0', a);
    cout << min(aa, bb) << endl;

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil, atan, pi
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left
MOD = int(1e9)+7
INF = float('inf')


def solve():
    # n, m = [int(x) for x in input().split()]
    # n, m = [int(x) for x in input().split()]
    n = int(input())
    a = []
    for i in range(n):
        a.append(int(input()))
    ans = 0
    
    x = 0
    for e in a:
        if e:
            x += e
        else:
            ans += x // 2
            x = 0
    ans += x // 2
    print(ans)




t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

"""


Measured memory_bytes: 13772
#include<bits/stdc++.h>
using namespace std;
int n,m,a[310][310],l,r,mid,mx,num[310],big[310],tag=0;
set<int>s;
queue<int>q;
bool check(int x)
{
	memset(num,0,sizeof num);
	for(int i=1; i<=n; i++)
	{
		big[i]=1;
		num[a[i][1]]++;
	}
	for(int i=1; i<=m; i++)
	{
		mx=max(mx,num[i]);
		s.insert(i);
	}
	while(mx>mid&&s.size())
	{
		for(int i=1; i<=m; i++)
			if(num[i]>mid)
				q.push(i);
		while(!q.empty())
		{
			s.erase(s.find(q.front()));
			q.pop();
		}
		for(int i=1; i<=n; i++)
			while(big[i]<=m&&s.count(a[i][big[i]])==0)
				big[i]++;
		memset(num,0,sizeof num);
		for(int i=1;i<=n;i++)
			num[a[i][big[i]]]++;
		mx=0;
		for(int i=1; i<=m; i++)
			mx=max(mx,num[i]);
	}
	return s.size();
}
int main(void)
{
	scanf("%d%d",&n,&m);
	r=n;
	for(int i=1; i<=n; i++)
		for(int j=1; j<=m; j++)
			scanf("%d",&a[i][j]);
	while(l!=r)
	{
		mid=l+r>>1;
		if(check(mid))
			r=mid;
		else
			l=mid+1;
	}
	printf("%d",l);
}

Measured memory_bytes: 640
#include <stdio.h>
     
    int main()
    {
      int x, a, b;
      scanf("%d %d %d", &x, &a, &b);
     
      if(b <= a) printf("delicious\n");
      else if(b <= (a + x)) printf("safe\n");
      else printf("dangerous\n");
     
      return 0;
    }

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD_CONST 1000000007
typedef long long int lli;

int find_perm_number(vector<int> &v);

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; ++i) cin >> p[i];
    vector<int> q(n);
    for(int i = 0; i < n; ++i) cin >> q[i];
    int a = find_perm_number(p);
    int b = find_perm_number(q);
    int ans = abs(a - b);
    cout << ans << endl;
    return 0;
}

int find_perm_number(vector<int> &v){
    vector<int> perm(v.size());
    for(size_t i = 0; i < v.size(); ++i) perm[i] = i + 1;
    int res = 0;
    do{
        ++res;
        if(v == perm) return res;
    }while(next_permutation(perm.begin(), perm.end()));
    return res;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

ll N, M, Q;
vector<vector<ll>> items;

int dfs(ll now, vector<int> &dice) {
    int tmp = 0;
    unordered_set<int> used;
    if (now == N) {
        rep(i, Q) {
            vector<ll> x = items[i];
            if (dice[x[1]] - dice[x[0]] == x[2]) {
                tmp +=x[3];
            }
        }
        return tmp;
    }
    int ans = 0;
    rep2(i, 1, M + 1) {
        if (now != 0 && dice[now - 1] > i) continue;
        dice[now] = i;
        ans = max(ans, dfs(now + 1, dice));
    }
    return ans;
}

void solve() {
    cin >> N >> M >> Q;
    items.resize(Q);
    rep(i, Q) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        a--;
        b--;
        vector<ll> x(4, 0);
        x[0] = a;
        x[1] = b;
        x[2] = c;
        x[3] = d;
        items[i] = x;
    }
    vector<int> dice(N, 1);
    cout << dfs(0, dice) << endl;
}

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


Measured memory_bytes: 3644
//まともに使い方を理解していないくせにincludeしまくる人間のクズ
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>

//using namespace stdしないと表記がめんどくさいからね、仕方ないね
using namespace std;

//可読性を上げるためのdefineが仇となる典型的パターン
#define rep(i,n) for(int i = 0; i < n; i++)

//ローカル変数とグローバル変数は使い分けよう！
short n;
int s;
unsigned long long int ans;

//関数って楽しいよね！（魔王スマイル）
int main(){
    scanf("%d", &n);
    rep(i, n){
        printf("Case %d:\n", i + 1);
        scanf("%d", &s);
        rep(j, 10){
            s *= s;
            s /= 100;
            s = s % 10000;
            printf("%d\n", s);
        }
    }
    return 0;
}

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

int main(){

    int n, p[10], max = 0, sum = 0;

    cin >> n;

    for(int i = 0;i < n; i++){

        cin >> p[i];

        if(p[i] > max*2)max = p[i]/2; 

    }

    for(int i = 0; i < n; i++)sum += p[i];

    sum -= max;

    cout << sum << endl;

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100010],n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	for(int i=n-1;i>=1;--i)
		if(a[i]>a[i+1]) --a[i];
	for(int i=1;i<n;++i)
		if(a[i]>a[i+1]) {
			printf("No");
			return 0;
		}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64

int check(vector<int> t){
  int res = 24;
  sort(t.begin(), t.end());
  t.erase(unique(t.begin(), t.end()), t.end());
  
  for(int i=0;i<t.size();++i){
    for(int j=0;j<i;++j) {
      res = min(min(24-abs(t[i]-t[j]), abs(t[i]-t[j])), res);
    }
  }
  
  if (res>12) return 0;
  return res;
}

signed main() {
  int n;cin>>n;
  vector<int> c(13,0);
  for(int i=0;i<n;++i){
    int f;cin>>f;
    ++c[f];
  }

  if(c[0]){
    cout<<0<<endl;
    return 0;
  }
  
  vector<int> single, db;
  for(int i=0;i<13;++i){
    if(c[i]>=3) {
      cout<<0<<endl;
      return 0;
    }
    else if(c[i]==2) db.push_back(i);
    else if(c[i]==1) single.push_back(i);
  }
  
  int ans = 0;
  vector<int> table;
  table.push_back(0);
  for(int i=0;i<db.size();++i){
    table.push_back(db[i]);
    if (db[i]!=12) table.push_back(24-db[i]);
  }
  
  if (single.size()==0) {
    ans = check(table);
  }
  
  for(int bit=0;bit<(1<<single.size());++bit){
    vector<int> p(single);
    for(int i=0;i<single.size();++i){
      if((bit>>i) & 1) {
        p[i] = 24 - p[i];
      }
    }

    vector<int> tt(table);
    for(int i=0;i<single.size();++i){
      tt.push_back(p[i]);
    } 
    ans = max(check(tt), ans);
  }

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


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){
	char str[21],reverse[21];
	int num,i;
	num=scanf("%21s",str);
	
	
	num=strlen(str)-1;
	
	for(i=0;i<=num;i++){
		reverse[i]=str[num-i];
	}
	
	reverse[i]='\0';
	
	printf("%s\n",reverse);
	
	return 0;
}

Measured memory_bytes: 0
/* ex4_3
	kanon */

#include <stdio.h>
#include <math.h>

//n番目の塔の高さを求める
int calculate_height(int n);

int main(void)
{

    //与えられる値を入れる数を宣言
    int height_a,height_b;

    //変数に値を入力する
    scanf("%d %d",&height_a,&height_b);
  
  	//高さを計算する
    int diff=height_b-height_a;
    
    int ans=calculate_height(diff-1)-height_a;
    printf("%d",ans);

    return 0;
}

int calculate_height(int n){
    int height=0;
    for(int i=1;i<=n;i++){
        height+=i;
    }
    return height;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

const int MAX_N = 210;
const int MAX_X = 100010;

int X, N;
int S[MAX_N];

long long dp[MAX_N][MAX_X];
long long MOD = 1000000007;

int main(int argc, char **argv) {
    std::cin >> N >> X;

    for (int i = 1; i <= N; i++) {
        std::cin >> S[i];
    }

    std::vector<int> vec;
    for (int i = 1; i <= N; i++) {
        vec.push_back(S[i]);
    }
    std::sort(vec.begin(), vec.end());
    for (int i = 0; i < vec.size(); i++) {
        S[i+1] = vec[i];
    }

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

    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= X; j++) {
            dp[i][j] = dp[i-1][j % S[i]] + ((i - 1) * dp[i-1][j]) % MOD;
            dp[i][j] = dp[i][j] % MOD;
        }
    }

    std::cout << dp[N][X] << std::endl;

    return 0;
}


Measured memory_bytes: 157952
#include <bits/stdc++.h>
#define rep(i, end) for (long long int i=0; i<end; i++)
#define repp(i, begin, end) for (long long int i=begin; i<end; i+)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;
using namespace std;
using ll = long long int;
using vi = vector<int>;
using vll = vector<long long int>;
using vllvll = vector<vll>;
using vs = vector<string>;
ll sm(vll x) {ll sum=0; rep(i, x.size()) sum+=x[i]; return sum;}
void vdeb(string s, vll x) {cout<<s<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<endl;}

//=======================================================================================================

int main()
{
    ll n;
    cin >> n;
    vll a(n);
    vll b(n);
    rep(i,n) {
        cin >> a[i];

        b[i] = a[i];
    } 

    rsrt(a);  
      
    rep(i,n) {
        ll x = b[i];
        if( a[0] == x ) cout << a[1] << endl;
        else cout << a[0] << endl;
    }

    return 0;
}

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

int main()
{
    int n, x, t;
    cin >> n >> x >> t;
    cout << ((n + (x - 1)) / x) * t << endl;
    return 0;
}


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

int main()
{
    int n;
    double score[1000];
    
    while(cin >> n, n)
    {
        double ave=0;
        for(int i=0; i<n; ++i)
        {
            cin >> score[i];
            ave += score[i];
        }
        ave /= n;
        double dif=0;
        for(int i=0; i<n; ++i)
        {
            dif += (score[i] - ave)*(score[i] - ave);
        }
        cout << (double)sqrt(dif/n) << endl;
    }
}


Measured memory_bytes: 3248
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define fast  ios_base::sync_with_stdio(0); cin.tie(0);
#define f(i,k) for(i=0;i<k;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define input(i,n,arr) for(i=0;i<n;i++) cin>>j, arr.push_back(j)
#define vect_ll vector<long long>
#define vect_ll_it vector<long long>::iterator
#define pb(p) push_back(p)
#define endl "\n"
#define mod 1000000007
const ll inf = 1e18;
ll i, j, k, n, m, x, y, p, q;
#define v 100000
int main()
{
	fast
	int t = 1;
	//cin >> t;
	while (t--)
	{
		string s, t; cin >> s >> t;
		n = s.size(), m = t.size();
		ll dp[n + 1][m + 1];
		for (i = 0; i <= n; i++)
		{
			for (j = 0; j <= m; j++)
			{
				if (i == 0 || j == 0)
				{
					dp[i][j] = 0;
					continue;
				}
				if (s[i - 1] == t[j - 1])
				{
					dp[i][j] = 1 + dp[i - 1][j - 1];
				}
				else
				{
					dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
				}

			}
		}
		//cout << dp[n][m] << endl;
		i = n, j = m;
		string ans = "";
		while (i > 0 && j > 0)
		{
			if (dp[i][j - 1] == dp[i][j])
			{
				j--;
			}
			else if (dp[i - 1][j] == dp[i][j])
			{
				i--;
			}
			else
			{
				ans = s[i - 1] + ans;
				i--, j--;
			}
		}
		cout << ans << endl;

	}
	//cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
	return 0;
}


Measured memory_bytes: 74008
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {

  public static void main(String[] args) throws Exception {
    try (final var stdin = new InputStreamReader(System.in);
         final var br = new BufferedReader(stdin)) {
      br.readLine();
      final var a = Arrays.stream(br.readLine().split(" "))
        .mapToInt(Integer::parseInt).toArray();

      final var lists = new ArrayList<List<Integer>>();
      var list = new ArrayList<Integer>();
      list.add(a[0]);
      for (int i = 1; i < a.length; i++) {
        if (list.get(list.size() - 1) > a[i]) {
          lists.add(list);
          list = new ArrayList<>();
        }

        list.add(a[i]);
      }
      lists.add(list);

      var sum = 1000L;
      for (final var phase : lists) {
        if (phase.size() <= 1) continue;

        var sumNext = sum;
        for (int i = 0; i < phase.size() - 1; i++) {
          // buy
          final var numBuy = sum / phase.get(i);

          final var result = sum -
                             phase.get(i) * numBuy +
                             phase.get(phase.size() - 1) * numBuy;

          sumNext = Math.max(sumNext, result);
        }

        sum = sumNext;
      }

      System.out.println(sum);
    }
  }
}


Measured memory_bytes: 34392
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

    vvint a(10, vint(10, 0));
    vint s(n), e(n);
    rep(i, n) {
        int num = i+1;
        e[i] = num%10;
        while (num >= 10) {
            num /= 10;
        }
        s[i] = num;
        a[s[i]][e[i]]++;
    }

    ll ans = 0;
    rep(i, n) {
        ans += a[e[i]][s[i]];
    }

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

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define f(i,a,b) for(long long i=a;i<b;i++)
#define pb(i) push_back(i)
#define mk(x,y) make_pair(x,y)
#define F first
#define S second
#define accu(i) fixed<<setprecision(i)
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
using namespace std;

int main(){
	ll n;cin>>n;
	ll od=n-(n/2);
	long double d=(od*1.0)/n;
	cout<<accu(9)<<d<<"\n";
	return 0;
}

Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

int h, w;
char a[111][111];
int cnt[30];
int main() {
	cin >> h >> w;
	REP(i, h)REP(j, w)cin >> a[i][j], cnt[a[i][j] - 'a']++;
	if (h % 2 && w % 2) {
		int num = (h - 1)*(w - 1) / 4;
		REP(i, 26) {
			int num2 = cnt[i] / 4;
			if (num2 >= num)num2 = num;
			num -= num2;
			cnt[i] -= num2 * 4;
		}
		if (num > 0) {
			cout << "No" << endl;
			return 0;
		}
		num = (h + w - 2) / 2;
		REP(i, 26) {
			int num2 = cnt[i] / 2;
			if (num2 >= num)num2 = num;
			num -= num2;
			cnt[i] -= num2 * 2;
		}
		if (num > 0) {
			cout << "No" << endl;
			return 0;
		}
		cout << "Yes" << endl;
		return 0;
	}
	else if (h % 2) {
		int num = (h - 1)*w / 4;
		REP(i, 26) {
			int num2 = cnt[i] / 4;
			if (num2 >= num)num2 = num;
			num -= num2;
			cnt[i] -= num2 * 4;
		}
		if (num > 0) {
			cout << "No" << endl;
			return 0;
		}
		num = w / 2;
		REP(i, 26) {
			int num2 = cnt[i] / 2;
			num -= num2;
		}
		if (num > 0) {
			cout << "No" << endl;
			return 0;
		}
		cout << "Yes" << endl;
		return 0;
	}
	else if (w % 2) {
		int num = (w - 1)*h / 4;
		REP(i, 26) {
			int num2 = cnt[i] / 4;
			if (num2 >= num)num2 = num;
			num -= num2;
			cnt[i] -= num2 * 4;
		}
		if (num > 0) {
			cout << "No" << endl;
			return 0;
		}
		num = h / 2;
		REP(i, 26) {
			int num2 = cnt[i] / 2;
			num -= num2;
		}
		if (num > 0) {
			cout << "No" << endl;
			return 0;
		}
		cout << "Yes" << endl;
		return 0;
	}
	else {
		int num = h*w / 4;
		REP(i, 26) {
			int num2 = cnt[i] / 4;
			num -= num2;
		}
		if (num > 0) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
	}
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1e9+7;

signed main()
{
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(n));
    for(auto& x : a)
        for(auto& y : x)
            cin >> y;
    vector<int> dp(1 << n, 0);
    dp[0] = 1;

    vector<vector<int>> v(n + 1);
    for(int i = 0; i < (1 << n); ++i){
        v[__builtin_popcount(i)].push_back(i);
    }

    for(int i = 0; i < n; ++i){
        vector<int> next(1 << n, 0);
        for(auto& j : v[i]){
            for(int k = 0; k < n; ++k){
                if(j & (1 << k) || !a[i][k])
                    continue;
                next[j | (1 << k)] = (next[j | (1 << k)] + dp[j]) % MOD;
            }
        }
        dp = move(next);
    }
    cout << dp.back() << endl;
}


Measured memory_bytes: 28360
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Data.List
import Control.Monad
import Data.Ord

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine



main :: IO ()
main = do
    [x,y,z] <- words <$> getLine
    putStrLn $ unwords $ [z,x,y]


Measured memory_bytes: 380
n, m = map(int, input().strip().split(' '))
store = []
for i in range(n):
    a, b = map(int, input().strip().split(' '))
    store.append([a,b])
store.sort()
price = 0
kosuu = 0
for i in range(n):
    if kosuu + store[i][1] > m:
        price = price + store[i][0]*(m-kosuu)
        break
    else:
        price = price + store[i][0]*store[i][1]
        kosuu = kosuu + store[i][1]
print(price)

Measured memory_bytes: 20072
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll maxn = 2*10e5+10;
ll a[maxn];
ll b[maxn];
int main(){
	int n;
	cin >> n;
	int x,y;
	for(int i = 1;i <= n;i++){
		cin >> x >> y;
		a[i] = x + y;
		b[i] = x - y;
	}
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	cout << max(a[n] - a[1],b[n] - b[1]);
}

Measured memory_bytes: 6316
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		Map<Integer,Integer> Amap = new HashMap<>();
		for(int i = 0;i < N;i++) {
			A[i] = sc.nextInt();
			if(Amap.containsKey(A[i])) {
				Amap.put(A[i], Amap.get(A[i])+1);
			}else {
				Amap.put(A[i],1);
			}
		}
		sc.close();
		int cnt = 0;
		for(Entry<Integer,Integer> Aentry : Amap.entrySet()) {
			if(Aentry.getValue()%2 != 0) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 63616
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>
#include <array>

using namespace std;
typedef long long ll;
int main()
{
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int ans = 0;
	auto it = a.cbegin();
	while (it != a.cend()) {
		int x = *it;
		auto it2 = upper_bound(it, a.cend(), x);
		int n = (int)(it2 - it);
		if (n >= x)
			ans += min(n, n - x);
		else
			ans += n;
		it = it2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  int n;
  long k;
  cin>>n>>k;
  vector<long> v(n);
  rep(i,n) cin>>v[i];

  vector<int> cnt(40,0);
  rep(i,40) rep(j,n) cnt[i] += (v[j]>>(39-i))%2;
dbg(cnt);
  vector<vector<long>> dp(41, vector<long>(2, 0));
  // [dig][just K or not]

  rep(i,40){
    long mul = (1L<<(39-i));
    long lg = max(cnt[i], n-cnt[i]) * mul;

    if(dp[i][0] > 0) dp[i+1][0] = dp[i][0] + lg;

    if((k>>(39-i))%2 == 0){
      dp[i+1][1] = dp[i][1] + cnt[i] * mul;
    } else {
      dp[i+1][0] = max(dp[i+1][0], dp[i][1] + cnt[i]*mul);
      dp[i+1][1] = dp[i][1] + (n-cnt[i]) * mul;
    }
    dbg(i+1,dp[i+1]);
  }

  cout << max(dp[40][0], dp[40][1]) << endl;

  return 0;
}


Measured memory_bytes: 1024
x,y = map(int,input().split())

if x==0:
  if y==0:
    ans=0
  elif y>0:
    ans = y
  else:
    ans = (-1)*y +1
elif y==0:
  if x==0:
    ans=0
  elif x>0:
    ans = 1+x
  else:
    ans = (-1)*x
else:
  if x>0 and y>0:
    if y>=x:
      ans=y-x
    else:
      ans= 1 + (x-y) +1
  elif x>0 and y<0:
    if x<(-1)*y:
      ans= (-1)*y-x +1
    else:
      ans= 1+(x+y)
  elif x<0 and y>0:
    if x<(-1)*y:
      ans=(-1)*y-x+1
    else:
      ans=1+ (x+y)
  else:
    if x<y:
      ans = y-x
    else:
      ans = 1 + ( (-1)*y+x) +1

print(ans)

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

#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define pii pair<int,int> 
#define pll pair<ll,ll> 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int> 
#define vll vector<ll>
#define all(c) c.begin(),c.end()
#define tr(it,c) for( typeof(c.begin()) it = c.begin() ; it!=c.end() ; it++)

ll modulo(ll num){ return ((num%mod)+mod)%mod;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),mod-2,MOD); }

vi adj[N] ;
int comp[N]={},cnt=0;

void dfs(int u)
{
    comp[u]=cnt;
    for(int i=0;i<adj[u].size();i++)
    {
        if(!comp[adj[u][i]]) dfs(adj[u][i]);
    }
}

int main()
{
    boost;
    
    int n,m,a[N],x,y,i,ans=0; 
    cin>>n>>m; 
    
    for(i=1;i<=n;i++) cin>>a[i];
    
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    
    for(i=1;i<=n;i++)
    {
        if(!comp[i])
        {
            cnt++;
            dfs(i);
        }
    }
       
    for(i=1;i<=n;i++)
    {
        if(a[i]==i) ans++ ; 
        else
        {
            if(comp[i]==comp[a[i]]) ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8576
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
int N;
cin>>N;
int a;
vector<int> v;
for(int i=0;i<N;++i){
  cin>>a;
  v.push_back(a);
}
std::sort(v.begin(),v.end());
long long ans=0;
int tmp,tmp_2;
int point=0;
//全部負の時
if(v[0]<=0 && v[N-1]<=0){
  for(int i=0;i<N;++i){
    if(i==N-1){
      ans+=v[i];
    }
    else{
      ans-=v[i];
    }
  }
  cout<<ans<<"\n";
  //最後の一個だけせいにする
  tmp=v[N-1]-v[N-2];
  cout<<v[N-1]<<" "<<v[N-2]<<"\n";
for(int i=0;i<N-2;i++){
  cout<<tmp<<" "<<v[i]<<"\n";
  tmp=tmp-v[i];
}
}
//全部せいの時
else if(v[0]>=0 && v[N-1]>=0){
  for(int i=0;i<N;++i){
    if(i==0){
      ans-=v[i];
    }
    else{
      ans+=v[i];
    }
  }
  cout<<ans<<"\n";
  //最初の一個だけ負にする
  tmp=v[0]-v[1];
  cout<<v[0]<<" "<<v[1]<<"\n";
for(int i=2;i<N-1;i++){
  cout<<tmp<<" "<<v[i]<<"\n";
  tmp=tmp-v[i];
}
cout<<v[N-1]<<" "<<tmp<<"\n";
}
//途中でchangeする時
else{
  for(int i=0;i<N;++i){
    if(v[i]<=0){
      ans-=v[i];
    }
    else{
      if(point==0){
        //せいになるポイント(>=1のhazu)
        point=i;
      }
      ans+=v[i];
    }
  }
  cout<<ans<<"\n";
  //最大はそこから引く要因に
  //最小はそこからせいを引いて最後に反転
  tmp=v[N-1];
  for(int i=1;i<point;++i){
    cout<<tmp<<" "<<v[i]<<"\n";
    tmp=tmp-v[i];
  }
  tmp_2=v[0];
  for(int i=point;i<N-1;++i){
    cout<<tmp_2<<" "<<v[i]<<"\n";
    tmp_2=tmp_2-v[i];
  }
  cout<<tmp<<" "<<tmp_2<<"\n";
}

return 0;
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod =1000000007;



int main() {

	int n, k;
	cin >> n >> k;
	cout << n + 1 - k << endl;

}


Measured memory_bytes: 256
import java.io.*;

public class Main{
  public static void main(String... args) throws Exception {
    BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
    String line = stdin.readLine();
    long n = Long.parseLong(line);
    System.err.println(n);

    if (n == 3) {
      System.out.println(2);
      return;
    }
    
    long sum = 0;
    long max = (int)Math.sqrt(n);
    System.err.println(max);
    for (int i=1; i <= max; i++) {
      long fab = (n - i) / i;
      if  (fab == 0) {
        continue;
      }
      if (i == n % fab) {
	    //System.err.println(fab);
        sum += fab;
      }
    }
    
/*
    for (int i=(int)Math.sqrt(n); i < n; i++) {
      long div = n / i;
      long mod = n % i;
      if (div == mod) {
        sum += i;
      }
    }
*/
    System.out.println(sum);
  }
}

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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const long long MOD = 1e9 + 7;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

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

///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|

string S;
ll N,Q;

ll solve(ll k){
    ll ret = 0;
    ll d = 0;
    ll m = 0;
    ll dm = 0;
    REP(i,k){
        if (S[i] == 'D') d++;
        if (S[i] == 'M') {
            m++;
            dm += d;
        }
        if (S[i] == 'C'){
            ret += dm;
        }
    }

    for (size_t i = k; i < N; i++) {
        char prev = S[i-k];
        char next = S[i];
        if (prev == 'D'){
            d--;
            dm -= m;
        }

        if (prev == 'M'){
            m--;
        }

        if (next == 'D') d++;
        if (next == 'M'){
            m++;
            dm += d;
        }
        if (next == 'C'){
            ret += dm;
        }
    }

    return ret;
}

int main() {
    cin >> N >> S >> Q;
    while(Q--){
        ll k; cin >> k;
        cout << solve(k) << "\n";
    }
}

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

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

    int n;
    ll k;
    cin >> n >> k;

    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<int> point;
    vector<int> num(n+1, -1);
    int v = 1;
    while(num[v] == -1) {
        num[v] = point.size();
        point.emplace_back(v);
        v = a[v-1];
    }
    int c = point.size() - num[v];
    int gar = num[v];
    

    if(k < ll(gar)) {
        cout << point[k] << endl;
    }
    else {
        k -= gar;
        k %= c;
        cout << point[gar+k] << endl;
    }
    return 0;

}

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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  cout << ((N + 1) / 2 >= K ? "YES" : "NO") << '\n';
  return 0;
}


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

using namespace std;

typedef pair<int, int> P;

#define MAX 129
#define MAR (MAX-1) / 2
#define INF 128

int main()
{
	const int dx[6] = {1, 1, 0, -1, -1, 0}, dy[6] = {1, 0, -1, -1, 0, 1};
	while(1) {
		bool is_wall[MAX][MAX] = {false};
		int d[MAX][MAX] = {0};
		queue<P> que;
		int t, n;
		int px, py;
		int ans = 0;
	
		for(int i = 0; i < MAX; i++) {
			for(int j = 0; j < MAX; j++) {
				d[i][j] = INF;
			}
		}
		scanf("%d %d", &t, &n);
		if(!t && !n) break;
		while(n--) {
			int wx, wy;
			scanf("%d %d", &wx, &wy);
			is_wall[wx+MAR][wy+MAR] = true;
		}
		scanf("%d %d", &px, &py);
		que.push(P(px, py));
		d[px+MAR][py+MAR] = 0;
		while(!que.empty()) {
			int x = que.front().first, y = que.front().second;
			que.pop();
			if(d[x+MAR][y+MAR] == t) continue;
			for(int i = 0; i < 6; i++) {
				int xx = x + dx[i], yy = y + dy[i];
				if(-MAR <= xx && xx <= MAR && -MAR <= yy && yy <= MAR && !is_wall[xx+MAR][yy+MAR] ) {
					if(d[xx+MAR][yy+MAR] > d[x+MAR][y+MAR] + 1) {
						d[xx+MAR][yy+MAR] = d[x+MAR][y+MAR] + 1;
						que.push(P(xx, yy));
					}
				}
			}
		}
		for(int i = 0; i < MAX; i++) {
			for(int j = 0; j < MAX; j++) {
				if(d[i][j] <= t) ans++;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1140
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        List<BigDecimal> list = new ArrayList<>();

        for (int i = 0; i < N; i++) {
            list.add(new BigDecimal(sc.next()));
        }
        list = list.stream().sorted(Comparator.naturalOrder()).collect(Collectors.toList());

        BigDecimal result = list.get(0);
        for (int i = 1; i < N; i++) {
            BigDecimal sum = result.add(list.get(i));

            result = sum.divide(new BigDecimal("2"), 7, RoundingMode.HALF_EVEN);
        }

        System.out.println(result.toPlainString());
        sc.close();
    }
}

Measured memory_bytes: 26964
//ll _(){
//    map<ll,ll> cnt;
//    ll n;
//    cin >> n;
//    vl arr(n);
//    cin >> arr;
//    for(ll x : arr){
//        cnt[x]++;
//        cnt[x+1]++;
//        cnt[x-1]++;
//    }
//    ll ans = 0;
//    for(auto _ : cnt)
//        ans = max(ans,_.Y);
//
//    return ans;
//}
//
//
//
#include <map>
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define all(v) (v).begin(), (v).end()
#define Y second
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
T1 istream& operator>>(istream& stream, vector<T>& t){
    return read(all(t), stream);
}
T1 istream& read(T b, T e, istream& stream){
    for(T it = b; it != e; ++it)
        stream >> *it;
    return stream;
}
ll _(){
    map<ll,ll> cnt;
    ll n;
    cin >> n;
    vl arr(n);
    cin >> arr;
    for(ll x : arr){
        cnt[x]++;
        cnt[x+1]++;
        cnt[x-1]++;
    }
    ll ans = 0;
    for(auto _ : cnt)
        ans = max(ans,_.Y);
    return ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        cout << _() << '\n';
}


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

vector<int> dig;
int64_t ans;	

int main(){
	string s;	cin >> s;
	dig = vector<int>(s.size());
  	for(int i = 0; i < s.size(); i++){
    	dig.at(i) = s.at(i) - '0';
//    	cout << dig.at(i) << endl;
    }
  
  	reverse(dig.begin(), dig.end());
  
  	ans = 0;
  	for(int i = 0; i < (1 << (s.size() - 1)); i++){
    	bitset<9> bt(i);
//    	cout << bt << endl;
      	int cnt = 0;
      	for(int j = 0; j < s.size() - 1; j++){
        	if(bt.test(j)){
              ans += pow(10,cnt)*dig.at(j);
            cnt = 0;}
          	else{
              ans += pow(10,cnt)*dig.at(j);
            	cnt++;}
		}
      	ans += dig.at(s.size()-1)*pow(10,cnt);	
    }
  	
  	cout << ans << endl;
}

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

typedef long long ll;
typedef pair<int, int> pii;

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) (x).begin(), (x).end()

const int mod = 1e9 + 7;
const double eps = 1e-9;

int main()
{
	int n, t, res = mod;
	cin >> n >> t;
	while (n--) {
		int a, b;
		cin >> a >> b;
		if (b <= t)
			res = min(res, a);
	}
	if (res == mod)
		cout << "TLE";
	else 
		cout << res;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vi vector<int>
#define pb push_back
#define sz(x) int(x.size())
using namespace std;
const int maxn = 12;
const int maxm = 1010;
int n, m, k;
int pref[maxn][maxm];
string maze[maxn];

int get_val(int x1, int y1) {
	if(x1 >= 0 && y1 >= 0) return pref[x1][y1];
	else return 0;
}

int get_sum(int x1, int y1, int x2, int y2) {
	return pref[x2][y2] - get_val(x2,y1-1) - get_val(x1-1,y2) + get_val(x1-1, y1-1);
}

int solve(vi a) {
	int st = 0;
	int br = 0;

	for(int j=0;j<m;j++) {
		int maxv = 0;
		for(int i=1;i<sz(a);i++) {
			int x1 = a[i-1] + 1;
			int x2 = a[i];

			maxv = max(maxv, get_sum(x1, st, x2, j));
		}

		if(maxv > k) {
			if(st == j) return n-1+m-1;
			else {
				st = j;
				br++;
			}
		}
	}

	return br;
}

int main() {
	//ifstream fin("test_case.in");
	cin>>n>>m>>k; 
	for(int i=0;i<n;i++) {
		cin>>maze[i];

		for(int j=0;j<m;j++) {
			if(i - 1 >= 0)
				pref[i][j] += pref[i-1][j];
			if(j - 1 >= 0) 
				pref[i][j] += pref[i][j-1];
			if(i - 1 >=0 && j - 1 >= 0)
				pref[i][j] -= pref[i-1][j-1];

			if(maze[i][j] == '1') pref[i][j]++;
		}
	}

	int result = n-1+m-1;
	for(int mask=0;mask<(1<<(n-1));mask++) {
		vector<int>v;

		v.pb(-1);
		for(int i=0;i<n-1;i++) {
			if(mask & (1<<i)) {
				v.pb(i);
			}
		}
		v.pb(n-1);

		result = min(result, solve(v) + sz(v) - 2);
	}

	cout<<result<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <sstream>

#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>

#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>

#include <chrono>
#include <random>

using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<i64>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<i64, i64>;

//////////////////////////////////////////////////

int main(){
    int a, p;
    cin >> a >> p;
    cout << (3 * a + p) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
list($N,$x) = explode(" ",trim(fgets(STDIN)));
$a = explode(" ",trim(fgets(STDIN)));
sort($a);
$res = 0;
for($i=0;$i<$N;$i++) {
 $x = $x - $a[$res];
 if ($x < 0) break;
 if ($x >= 0) {
   $res++;
 }
 //printf("%d %d\n",$x,$res);
}
if ($x > 0) {
  $res--;
}
printf("%d\n",$res);


Measured memory_bytes: 3576
#include <iostream>
#include <string>

using namespace std;
     
int main(void){
  int n;

  cin >> n;

  int p[n];

  for (int i; i<n; i++) {
    cin >> p[i];
 }

  int jc = 0;

  for (int i=2; i<n; i++) {
    //cout << p[i-2] << " " << p[i-1] << " " << p[i] << "\n";
    if (p[i-2] < p[i-1] && p[i-1] < p[i]) {
      jc += 1;
    } else if (p[i-2] > p[i-1] && p[i-1] > p[i]) {
      jc += 1;
    }
  }

  cout << jc;

  return 0;
}

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

#define FOR(i,b,e) for(int i=(b); i <= (e); ++i)
#define FORD(i,b,e) for(int i=(b); i >= (e); --i)
#define SIZE(c) (int) (c).size()
#define FORE(i,c) FOR(i,0,SIZE(c)-1)
#define FORDE(i,c) FORD(i,SIZE(c)-1,0)

#define pb push_back
#define mp make_pair
#define st first
#define nd second


using namespace std;

typedef long long ll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

typedef vector <int> VI;
typedef vector <bool> VB;
typedef vector <pii> VP;
typedef vector <ll> VL;
typedef vector <pll> VPL;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;


/*************************************************************************/

int main() {
    ios_base::sync_with_stdio(0);
    
    int n;
    cin >> n;
    
    VB val(n);
    FOR(i,0,n-1) {
        char c;
        cin >> c;
        
        val[i] = (c == 'x');
    }
    
    VB ans(n);
    FOR(i,0,1) FOR(j,0,1) {
        ans[0] = i;
        ans[1] = j;
        
        FOR(k,1,n-2) {
            ans[k+1] = ans[k-1] xor ans[k] xor val[k];
        }
        
        bool ok = true;
        FOR(k,0,n-1) {
            int prv = (k + n - 1) % n;
            int nxt = (k + 1) % n;
            
            bool res = ans[prv] xor ans[k] xor ans[nxt];
            if (res != val[k]) ok = false;
        }
        
        if (ok) {
            FOR(k,0,n-1) {
                cout << (ans[k] ? 'W' : 'S');
            }
            
            return 0;
        }
    }
    
    cout << -1;

    return 0;
}

/*************************************************************************/


Measured memory_bytes: 384
N,K = map(int,input().split())
S = list(input())
a = S[0]
cur = 0
cnt = 0
for i in range(N):
    if S[i] != a:
        cnt += i-cur-1
        a = S[i]
        cur = i
if S[N-1]==a:
    cnt += N-cur-1
print(min(cnt+2*K,N-1))

Measured memory_bytes: 4024
#include <stdio.h>
#include <math.h>
#define MAXAL 1000000
#define MAX 10000

int isprime(int);

int main()
{
  int x[MAXAL],i,m,count=0;
  scanf("%d",&i);
  for(m=0;m<i;m++)
    {
      scanf("%d",&x[m]);
      if(isprime(x[m])==1)
	count++;
    }
  printf("%d\n",count);
  return 0;
}

int isprime(int x)
{
  int i,route;
  if(x==2 || x==3)
    return 1;
  if(x<2 || x%2==0)
    return -1;
  i=3;
  route=sqrt(x);
  while(i<=route)
    {
      if(x%i==0)
	return -1;
      i=i+2;
    }
  return 1;
  }



Measured memory_bytes: 2084
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define pow5(i) i * i * i * i * i
#define MAX 100001
#define MOD 1000000007
#define INF 1000000000
typedef long long int lli;

int main(void) {
  int x;
  scanf("%d", &x);
  int lim;
  for (long long i = 1; ;i++) {
    if (i * i * i * i * i - (i-1) * (i-1) * (i-1) * (i-1) * (i-1) < INF) continue;
    lim = i;
    break;
  }
  rep(i, -lim, lim) {
    rep(j, -lim, lim) {
      if (pow5(i) - pow5(j) == x) {
        printf("%d %d\n", i, j);
        goto exit;
      }
    }
  }
  exit:;
  return 0;
}


Measured memory_bytes: 1732
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
using namespace std;
int main(){
	int d,n;
	cin>>d>>n;
	int c=1;
	if(d==1)c*=100;
	if(d==2)c*=10000;
	if(n==100)n++;
	cout<<c*n<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())
#define MOD 1000000007 
#define mx 100003

bool p[10000003], ya[10000003];
// int x[103];
vector<int> prima;
vector<int> genap, ganjil;
int sama[103];
int sudah[103];

int dfs(int now){
	for(int j = 0; j < sz(ganjil); j++){
		if(sudah[j])
			continue;
		if(p[abs(genap[now] - ganjil[j])])
			continue;
		sudah[j] = true;
		if(sama[j] == -1 || dfs(sama[j])){
			sama[j] = now;
			return 1;
		}
	}
	return 0;
}


int match(){
	int ret = 0;
	for(int i = 0; i < sz(ganjil); i++)
		sama[i] = -1;
	for(int i = 0; i < sz(genap); i++){
		for(int j = 0; j < sz(ganjil); j++)
			sudah[j] = false;
		ret += dfs(i);
	}
	return ret;
}

int main(){
	p[1] = true;
	for(int i = 2; i <= 1e7 + 1; i++){
		if(p[i])
			continue;
		if(i > 2)
			prima.pb(i);
		for(int j = i + i; j <= 1e7 + 1; j += i)
			p[j] = true;
	}
	int n;
	cin >> n;	
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		ya[x] = true;
	}
	for(int i = 1; i <= 1e7 + 1; i++){
		if(ya[i] ^ ya[i - 1]){
			if(i % 2 == 0)
				genap.pb(i);
			else ganjil.pb(i);
		}
	}
	// debug(sz(genap));
	// debug(sz(ganjil));
	// for(int i : genap)
	// 	debug(i);
	// for(int i : ganjil)
	// 	debug(i);
	int aa = match();
	int sisaGenap = sz(genap) - aa;
	int sisaGanjil = sz(ganjil) - aa;
	int jaw = aa + (sisaGenap / 2) * 2 + (sisaGanjil / 2) * 2;
	if(sisaGanjil % 2 > 0){
		assert(sisaGenap % 2 > 0);
		jaw += 3;
	}
	cout << jaw << endl;
}

Measured memory_bytes: 21996
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string S, T;
    cin >> S >> T;
    bool res = true;
    if(S.size() + 1== T.size()){
        for(int i = 0; i < S.size(); i++){
            if(S.at(i) != T.at(i)){
                res = false;
                break;
            }
        }
    }else{
        res = false;
    }
    if(res == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3632