akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 + 7;

vector<string> g;

vector<vector<ll>> dp;

ll search(ll i, ll j, const vector<ll>& w)
{
    if (i > w.size() - 1 || j > w.size() - 1)
    {
        return 0;
    }
    if (dp[i][j] > -1)
    {
        return dp[i][j];
    }
    if (i >= j)
    {
        return 0;
    }
    dp[i][j] = 0;
    if (j - i == 1)
    {
        if (abs(w[i] - w[j]) <= 1)
        {
            dp[i][j] = 1;
            return 1;
        }
    }
    ll ret = max(search(i + 1, j, w), search(i, j - 1, w));
    if (abs(w[i] - w[j]) <= 1 && (j - i) % 2)
    {
        ll cur = search(i + 1, j - 1, w);
        if (2 * cur == j - i - 1)
        {
            ret = max(ret, cur + 1);
        }
    }
    for (ll k = i + 1; k < j; ++k)
    {
        ret = max(ret, search(i, k, w) + search(k + 1, j, w));
    }
    dp[i][j] = ret;
    return ret;
}


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

    while (1)
    {
        ll n;
        cin >> n;
        if (n == 0)
        {
            break;
        }
        vector<ll> w(n);
        for (int i = 0; i < n; ++i)
        {
            cin >> w[i];
        }
        
        dp = vector<vector<ll>>(n, vector<ll>(n, -1));
        
        ll ret = search(0, n - 1, w);
        
        cout << ret * 2 << endl;
    }
    
    

    return 0;
}


Measured memory_bytes: 4400
#include <cmath>
#include <iostream>
#include <string>
#include <utility>

using namespace std;

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

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

  long long pre(0), prepre(0);
  long long last_sousa(0);
  long long now;
  bool pre_sousazumi(false), prepre_sousazumi(false);
  bool res(true);
  FOR(i,n) {
    if (!res) {
      cin >> now;
      continue;
    }

    if (i == 0) {
      cin >> prepre;
      continue;
    } else if (i == 1) {
      cin >> pre;
      if (prepre - pre == 1) {
        if (prepre == 1) {
          res = false;
          continue;
        }
        --prepre;
        last_sousa = prepre;
        prepre_sousazumi = true;
      } else if (prepre - pre > 1) {
        res = false;
        continue;
      }
    } else if (i > 1) {
      cin >> now;
      if (now >= pre) {
        prepre = pre;
        prepre_sousazumi = pre_sousazumi;
        pre = now;
        pre_sousazumi = false;
        continue;
      } else if (now < pre) {
        if (pre - now > 1) {
          res = false;
          continue;
        } else if (pre - now == 1) {
          if (pre_sousazumi) {
            res = false;
            continue;
          } else {
            if (pre > prepre) {
              if (pre == 1) {
                res = false;
                continue;
              }
              --pre;
              last_sousa = pre;
              pre_sousazumi = true;
              prepre = pre;
              prepre_sousazumi = pre_sousazumi;
              pre = now;
              pre_sousazumi = false;
              continue;
            } else if (pre == prepre) {
                if (pre == 1) {
                  res = false;
                  continue;
                }
                if (last_sousa == pre) {
                  res = false;
                  continue;
                }
                --pre;
                last_sousa = pre;
                pre_sousazumi = true;
                prepre = pre;
                prepre_sousazumi = pre_sousazumi;
                pre = now;
                pre_sousazumi = false;
                continue;
            }
          }
        }
      }
    }
  }

  if (res)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
K,N = list(map(int,input().split()))
A = list(map(int,input().split()))
distances = [float('inf')]*N
distances[0] = A[0]+(K-A[-1])
for i in range(1,N):
    distances[i] = abs(A[i]-A[i-1])
print(K-max(distances))

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

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); ++i)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ELEM(array) (sizeof (array)/sizeof *(array))
#define MAX_N 100000
#define SAFE_FREE(ptr) if( ptr != NULL ){ free(ptr); ptr = NULL; }
typedef unsigned int UINT;
typedef long long ll;
typedef pair<int, int> P;

int S[MAX_N];
int T[505];
int A[505];
int n, q;
bool mysearch(int key);

int main()
{

	int j = 0;
	int ans = 0;
	bool over =false;

	cin >> n;
	REP(i, n)cin >> S[i];
	cin >> q;
	REP(i, q)cin >> T[i];

	REP(i, n){
		over = false;
		for (int k = 0; k < j; k++)
		{
			if (A[k] == S[i]){
				over=true; break;
			}
		}
		if (mysearch(S[i]) == true&&over==false)
		{
			ans++;
			A[j] = S[i];
			j++;
		}
		
	}
	cout << ans  << endl;
	return 0;
}

inline bool mysearch(int key){
	int i;
	T[q] = key;
	for (i = 0; i < q; i++){
		if (T[i] == key)break;
	}
	if (i == q){ return false; }
	return true;
}

Measured memory_bytes: 1204
#include <stdio.h>

int main(void)
{
	int n, tens, ones;

	scanf("%d", &n);

	tens = n % 100;
	ones = n % 10;

	if ((699 < n && n < 800) || (69 < tens && tens < 80) || (ones == 7))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 1624
#include "bits/stdc++.h"
using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,m,n) for(int i=m;i<(n);i++)
#define ALL(v) v.begin(),v.end()

template<typename flow_t>
struct edge {
	int to;
	flow_t cap;
	int rev;
	bool isrev;
	int idx;
	edge(int to, flow_t cap, int rev, bool isrev, int idx) :to(to), cap(cap), rev(rev), isrev(isrev), idx(idx) {}
};

template< typename flow_t >
struct Dinic {
	const flow_t INF;

	vector< vector< edge<flow_t> > > graph;
	vector< int > min_cost, iter;

	Dinic(int V) : INF(numeric_limits< flow_t >::max()), graph(V) {}

	void add_edge(int from, int to, flow_t cap, int idx = -1) {
		graph[from].push_back((edge<flow_t>) { to, cap, (int)graph[to].size(), false, idx });
		graph[to].push_back((edge<flow_t>){from, 0, (int)graph[from].size() - 1, true, idx});
	}

	bool bfs(int s, int t) {
		min_cost.assign(graph.size(), -1);
		queue< int > que;
		min_cost[s] = 0;
		que.push(s);
		while (!que.empty() && min_cost[t] == -1) {
			int p = que.front();
			que.pop();
			for (auto &e : graph[p]) {
				if (e.cap > 0 && min_cost[e.to] == -1) {
					min_cost[e.to] = min_cost[p] + 1;
					que.push(e.to);
				}
			}
		}
		return min_cost[t] != -1;
	}

	flow_t dfs(int idx, const int t, flow_t flow) {
		if (idx == t) return flow;
		for (int &i = iter[idx]; i < graph[idx].size(); i++) {
			edge<flow_t> &e = graph[idx][i];
			if (e.cap > 0 && min_cost[idx] < min_cost[e.to]) {
				flow_t d = dfs(e.to, t, min(flow, e.cap));
				if (d > 0) {
					e.cap -= d;
					graph[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}

	flow_t max_flow(int s, int t) {
		flow_t flow = 0;
		while (bfs(s, t)) {
			iter.assign(graph.size(), 0);
			flow_t f = 0;
			while ((f = dfs(s, t, INF)) > 0) flow += f;
		}
		return flow;
	}

	void output() {
		for (int i = 0; i < graph.size(); i++) {
			for (auto &e : graph[i]) {
				if (e.isrev) continue;
				auto &rev_e = graph[e.to][e.rev];
				cout << i << "->" << e.to << " (flow: " << rev_e.cap << "/" << e.cap + rev_e.cap << ")" << endl;
			}
		}
	}
};

void solve() {
	int V, E; cin >> V >> E;
	Dinic<int>g(V);
	REP(i, E) {
		int u, v, c; cin >> u >> v >> c;
		g.add_edge(u, v, c);
	}
	cout << g.max_flow(0, V - 1) << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}


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

using ll = long long;

using namespace std;

int main() {
    int n;
    cin >> n;
    set<string> st;
    for (int i=0; i<n; i++) {
        string s;
        cin >> s;
        st.insert(s);
    }
    cout << st.size() << '\n';
    return 0;
}

Measured memory_bytes: 19120
#include <iostream>
 
using namespace std;
 
 
#define MAX 500000
#define SENTINEL 2000000000
 
int L[MAX/2+2], R[MAX/2+2];
int cnt;
 
void merge(int A[],int n,int left, int mid, int right) {
  int n1 = mid -left;
  int n2 = right - mid;
  for(int i=0;i<n1;i++) L[i] = A[left + i];
  for(int i=0;i<n2;i++) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  int i=0, j=0;
  for(int k=left; k<right; k++) {
    cnt++;
    if(L[i]<=R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}
 
void mergeSort(int A[],int n,int left,int right) {
  if(left+1 < right) {
    int mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}
 
int main(void) {
  int A[MAX], n, i;
  cnt = 0;
 
    cin >> n;
  for(i=0;i<n;i++) cin >> A[i];
 
  mergeSort(A, n, 0, n);
  for(i=0;i<n;i++) {
    if(i)cout << " ";
    cout << A[i];
  }
  cout << endl;
 
  cout << cnt << endl;
 
  return 0;
}

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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define EACH(begin, end) for(auto itr = (begin); itr != (end); itr++)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
ll ret = 0;
ll head;
ll tail;
bool is_ym = false;
bool is_my = false;
string ans;

void input() {
  IN(N);
}

void solve() {
  head = N/100;
  tail = N%100;

  if (0 < tail && tail < 13) {
    is_ym = true;
  }
  if (0 < head && head < 13) {
    is_my = true;
  }

  if (is_ym && is_my){
    ans = "AMBIGUOUS";
  } else if(!is_ym && is_my) {
    ans = "MMYY";
  } else if(is_ym && !is_my) {
    ans = "YYMM";
  } else {
    ans = "NA";
  }
  cout << ans << endl;
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}


int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int cnt = 0;
	REP(i, s.size())
		cnt += s[i] == '1';
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) REP(i, 0, n)
#define REP(i, s, e) for (int i = (s); i < (int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for (int i = (int)(s - 1); i >= (int)(e); i--)
#define pb push_back
#define all(r) r.begin(), r.end()
#define rall(r) r.rbegin(), r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

template <typename T>
T chmax(T &a, const T &b) { return a = (a > b ? a : b); }
template <typename T>
T chmin(T &a, const T &b) { return a = (a < b ? a : b); }

template <typename T>
class BIT
{
private:
    int n, m;
    vector<vector<T>> bit;

public:
    void add(int i, int j, T val)
    {
        for (int i_ = i + 1; i_ < n; i_ += i_ & -i_)
            for (int j_ = j + 1; j_ < m; j_ += j_ & -j_)
                (bit[i_][j_] += val) %= MOD;
    }
    T sum(int i, int j)
    {
        T s = 0;
        for (int i_ = i + 1; i_ > 0; i_ -= i_ & -i_)
            for (int j_ = j + 1; j_ > 0; j_ -= j_ & -j_)
                (s += bit[i_][j_]) %= MOD;
        return s;
    }
    T sum(int lx, int rx, int ly, int ry)
    {
        return ((sum(rx - 1, ry - 1) - sum(lx - 1, ry - 1) - sum(rx - 1, ly - 1) + sum(lx - 1, ly - 1)) % MOD + MOD) % MOD;
    }
    BIT(int sz1, int sz2)
    {
        n = sz1 + 1, m = sz2 + 1;
        bit.resize(n, vector<T>(m, 0));
    }
    BIT(vector<vector<T>> &v)
    {
        n = (int)v.size() + 1, m = (int)v[0].size() + 1;
        bit.resize(n, vector<T>(m, 0));
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                add(i, j, v[i][j]);
    }
    void print()
    {
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < m; j++)
            {
                cout << sum(i - 1, i, j - 1, j) << " ";
            }
            cout << "\n";
        }
    }
    void print_sum()
    {
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < m; j++)
            {
                cout << sum(i - 1, j - 1) << " ";
            }
            cout << "\n";
        }
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> s(n), t(m);
    rep(i, n) cin >> s[i];
    rep(i, m) cin >> t[i];
    BIT<ll> bit(n+1, m+1);
    bit.add(0, 0, 1);
    rep(i, n) rep(j, m) {
        if(s[i] == t[j]) {
            // cout << i << " " << j << endl;
            bit.add(i+1, j+1, bit.sum(i, j));
        }
    }
    cout << bit.sum(n, m) << endl;
    // bit.print();
    // cout << endl;
    // bit.print_sum();
    return 0;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
//#include <conio.h>
#define fto(i,x,y) for(i=(x);i<=(y);i++)
#define fdto(i,x,y) for(i=(x);i>=(y);i--)
#define ftoi(i,x,y) for(int i=(x);i<=(y);i++)
#define fdtoi(i,x,y) for(int i=(x);i>=(y);i--)
#define ll long long
#define ld double
#define oo (ll) 2000000000
#define ull unsigned long long
#define ui unsigned int
#define zero 1E-6
#define ii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define miii map<int,int>::iterator
#define ftoimii(it,m) for(map<int,int>::iterator it=m.begin();it!=m.end();it++)
#define ftoimsi(it,m) for(map<string,int>::iterator it=m.begin();it!=m.end();it++)

#define bug(x) printf("%d ", x)
#define sbug(x) printf("%s ", x);
#define abug(a,x,y) ftoi(i,x,y){printf("%d ",a[i]);}
#define wait() getch()
using namespace std;

int main () {
  int A, B, C, X, i, j, k;
  scanf ("%d%d%d%d", &A, &B, &C, &X);
  int cnt = 0;
  fto (i, 0, A)
    fto (j, 0, B)
      fto (k, 0, C)
        if (i * 500 + j * 100 + k * 50 == X)
          cnt ++;
  printf("%d", cnt);
}


Measured memory_bytes: 256
N, K = (int(i) for i in input().split())
p = [int(i) for i in input().split()]
p_ex = [(i+1)/2 for i in p]
sum_list = [sum(p_ex[0:K]),sum(p_ex[N-K:N])]
tmp_num = sum_list[0]
if N == K:
  print(sum(p_ex))
else:
  for i in range(1,N-K):
    #print("i:"+str(i))
    tmp_num = tmp_num - p_ex[i-1] + p_ex[i+K-1]
    #print("  tmp_num = tmp_num - "+str(p_ex[i-1])+" + "+str(p_ex[i+K-1]))
    sum_list.append(tmp_num)
  print(max(sum_list))

Measured memory_bytes: 77576
#include<bits/stdc++.h>
using namespace std;
int a[60],b[60],c[60],d[60];
int t,k,n,m,ans;
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i];
    }
    for(int i=1;i<=m;i++)
    {
        cin>>c[i]>>d[i];
    }

    for(int i=1;i<=n;i++)
    {
        ans=1000000000;
        for(int j=1;j<=m;j++)
        {
            t=abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(t<ans){
                ans=t;
                k=j;
            }
        }
        cout<<k<<endl;
    }
    return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int wq[103][5];
ll st[103][100003];
ll dmc(int g,int rw)
{
    if(g<0||!rw)return 0;
    if(st[g][rw])return st[g][rw];
    if(wq[g][0]<=rw)
        st[g][rw]=max(dmc(g-1,rw),wq[g][1]+dmc(g-1,rw-wq[g][0]));
    else st[g][rw]=dmc(g-1,rw);
    return st[g][rw];
}
int main()
{
    int g,t,y;
    scanf("%d %d",&t,&y);
    for(g=0;g<t;g++)
        scanf("%d %d",&wq[g][0],&wq[g][1]);
    dmc(t-1,y);
    printf("%lld\n",st[t-1][y]);
    return 0;
}


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

namespace ABC088D
{
    class Program
    {
        static void Main(string[] args)
        {
            int whiteCount = 0;
            var HW = ReadInt();
            int H = HW[0];
            int W = HW[1];

            char[,] map = new char[H + 2, W + 2];
            int[,] d = new int[H + 2, W + 2];
            d[1, 1] = 1;

            for (int i = 0; i < H; i++)
            {
                var input = Console.ReadLine();
                for (int j = 0; j < W; j++)
                {
                    map[i + 1, j + 1] = input[j];
                    if (input[j] == '.') whiteCount++;
                }
            }

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

            Queue<int> queX = new Queue<int>();
            Queue<int> queY = new Queue<int>();
            queX.Enqueue(1);
            queY.Enqueue(1);
            while (queX.Count > 0)
            {
                int x = queX.Dequeue();
                int y = queY.Dequeue();

                if (map[y, x] == '#') continue;
                map[y, x] = '#';

                for (int i = 0; i < 4; i++)
                {
                    if (map[y + dy[i], x + dx[i]] == '.')
                    {
                        queX.Enqueue(x + dx[i]);
                        queY.Enqueue(y + dy[i]);
                        d[y + dy[i], x + dx[i]] = d[y, x] + 1;
                    }
                }
            }

            int ans = whiteCount - d[H, W];
            if (d[H, W] == 0) ans = -1;
            Console.WriteLine(ans);
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


Measured memory_bytes: 13396
#include<stdio.h>
using namespace std;
int main() {
	int a,b,c;
	
	scanf("%d %d %d", &a, &b, &c);
	
    if (a < b) {
		if (b < c) {
			printf("Yes\n");
		}
		else{
	    printf("No\n");
	}
	}
	else{
	    printf("No\n");
	}
}




Measured memory_bytes: 2628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

	Scanner sca = new Scanner(System.in);
	// 入力
	long a = sca.nextLong();
	long b = sca.nextLong();
	long k = sca.nextLong();

	// 処理
	a = a - k;
	if(a < 0) {
		k = -a;
		b = b - k;
		a = 0;
		if(b < 0) {
			b = 0;
		}
	}

	// 出力
	System.out.print(a);
	System.out.print(" ");
	System.out.println(b);

	// 後始末
	sca.close();
	}
}

Measured memory_bytes: 22100
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	
	scanf("%d%d",&a,&b);
	
	if(a == b){
		printf("a == b\n");
	}
	else if(a > b){
		printf("a > b\n");
	}
	else{
		printf("a < b\n");
	}
	
	return 0;
}

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

using namespace std;

const int N = 2e5 + 5;
const int mod = 998244353;
inline int pls( int a , int b ) { a += b - mod; return a + ( a >> 31 & mod ); }
inline int mns( int a , int b ) { a -= b; return a + ( a >> 31 & mod ); }
inline void inc( int & a , int b ) { a += b - mod; a += a >> 31 & mod; }
inline void dec( int & a , int b ) { a -= b; a += a >> 31 & mod; }
int _w;

int n , f[N];
char str[N] , tmp[N];
bool mark[N];

int solve( int k ) {
  int res = 0;
  for( int i = 1 ; i <= k ; ++i )
    inc( res , pls( res , str[i] - '0' ) );
  for( int i = 1 , cur = 1 ; i <= n ; ++i , cur = cur == 2 * k ? 1 : cur + 1 ) 
    if( cur > k ) tmp[i] = str[cur - k] ^ 1;
    else tmp[i] = str[cur];
  for( int i = 1 ; i <= n ; ++i )
    if( tmp[i] ^ str[i] )
      return tmp[i] < str[i] ? pls( res , 1 ) : res;
  return pls( res , 1 );
}

int main( void ) {
  _w = scanf("%d%s",&n,str+1);
  for( int i = 1 ; i <= n ; ++i )
    if( n % i == 0 && ( ( n / i ) & 1 ) )
      f[i] = i * 2 , mark[i] = 1;
  for( int i = n - 1 ; i ; --i ) if( mark[i] )
    for( int j = i + i ; j <= n ; j += i ) if( mark[j] )
      dec( f[i] , f[j] );
  int ans = 0;
  for( int i = 1 ; i <= n ; ++i )
    if( mark[i] )
      inc( ans , 1LL * solve( i ) * f[i] % mod );
  cout << ans;
  return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#include <cctype>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)

#define AAA (1000000007) 


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll powD(ll a, ll b) {
	ll ans = 1;
	a %= AAA;
	for (int i = 0; i < b; i++)
	{
		ans *= a;
		ans %= AAA;
	}
	return ans;
}


int main() {
	int i, j, k;

	int N, M, K;
	int A, B, C, D;
	string S;
	cin >> N >> A >> B >> C >> D >> S;


	A--, B--, C--, D--;
	S[A] = 'A';
	S[B] = 'B';
	

	rep(i, A, C - 1) {
		if (S[i] == '#' && S[i + 1] == '#') {
			cout << "No";
			return 0;
		}
	}
	rep(i, B, D - 1) {
		if (S[i] == '#' && S[i + 1] == '#') {
			cout << "No";
			return 0;
		}
	}
	int a=A, b=B;
	if (C < D) {
		cout << "Yes";
		return 0;
	}

	rep(i, b, min(D+1,N)) {
		if (S[i - 1] != '#' && S[i] != '#' && S[i + 1] != '#') {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MOD = 1e9+7;
const ll LINF = 1e18;
const int INF = 1e9;
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

int main()
{
    cin >> N;
    for (ll i = 2; i*i < N; i++)
    {
        for (ll j = i; j < N; j++)
        {
            if(N-i*j > 0) A += (i==j) ? 1 : 2;
            else break;
        }
        
    }
    A += 2*N-3;
    cout << A;
    
    return 0;
}

Measured memory_bytes: 3648
EPS=0.0001
while True:
 try:
  a,b,c,d,e,f = [float(item) for item in input("").split(" ")]

  x1=(e*c-b*f)/(a*e-b*d)+EPS
  y1=(-c*d+a*f)/(a*e-b*d)+EPS

#a,b,c,d,e,f = [float(item) for item in input("").split(" ")]
#x2=(e*c-b*f)/(a*e-b*d+EPS)
#y2=(-c*d+a*f)/(a*e-b*d+EPS)

  print('{0:.3f} {1:.3f}'.format(x1,y1))
 except EOFError:
  break


Measured memory_bytes: 5588
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define INTINF 1<<30
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

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

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll factorial(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {
	if (n == r) { return 1; }
	if (r > n) { return 0; }

	if (r > n / 2) { r = n - r; }

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

int main() {
	int N; cin>>N;
	int num[N+1]; for(int i=1; i<N+1; i++) num[i]=0;
	int jun[N+1];
	for(int i=1; i<N+1; i++) {
		int ai; cin>>ai;
		num[ai]++;
		jun[i]=ai;
	}
	
	ll allsum=0LL;
	for(int i=1; i<N+1; i++) {
		allsum += nCr(num[i],2);
	}

	for(int i=1; i<N+1; i++) {
		if(num[jun[i]]<=1) cout<<allsum<<endl;
		else cout<<allsum-num[jun[i]]+1<<endl;
	}
}


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

void solve() {
  int n;
  cin >> n;
  vector<int> a(n+1);
  for(int i = 1; i < n+1; i++) cin >> a[i];
  vector<int> v(n+1);
  for(int i = n; i >= 1; i--) {
    int temp = 0;
    for(int j = 2; j * i <= n; j++) {
      temp += v[j*i];
    }
    if(temp % 2 != a[i]) v[i] = 1;
  }
  int m = 0;
  rep(i, n+1) {
    if (v[i]) m++;
  }
  cout << m << endl;
  rep(i, n+1) {
    if(v[i]) cout << i << " " ;
  }
}

int main() {
  solve();
  return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <stdio.h>
#include <cctype>
#include <bits/stdc++.h>
using namespace std;

int main(){
    string st;
    getline(cin, st);
    int l = st.length();
    for (int i = 0; i < l; i++){
        if('a' <= st[i] && st[i] <= 'z'){
            st[i] += 'A' - 'a';
        }
        else if ('A' <= st[i] && st[i] <= 'Z'){
            st[i] += 'a' - 'A';
        }
    }
    cout << st << endl;
}


Measured memory_bytes: 3140
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;
using System.Linq;
class Program
{
static int result;
static List<int> s=new List<int>();
  static List<int> t=new List<int>();
  static int N,K;
    static void Main()
    {
      string[] tmp=Console.ReadLine().Split(' ');
  N=int.Parse(tmp[0]);
        K=int.Parse(tmp[1]);
            Modular[] mo=new Modular[K+1];
            for(int i=1;i<=K;i++){mo[i]=new Modular(1);
//青のみを抽出して考える。K-1個の境目の中からi-1個の区切り位置をチョイス。
mo[i]*=Modular.Ncr(K-1,i-1);
                                  //赤ボールも同じ手順
//N-K+1個(N-K-1個だが，こちらは両端もＯＫなので+2)の境目の中からi個の区切り位置をチェック
  mo[i]*=Modular.Ncr(N-K+1,i);                                
      Console.WriteLine(((int)mo[i]).ToString());
                                }

    }

static void Read()
{
  string[] tmp=Console.ReadLine().Split(' ');
for(int i=0;i<N;i++){s.Add(int.Parse(tmp[i]));}
}
}

 class Modular
{
    private const int M = 1000000007;
    private long value;
    public Modular(long value) { this.value = value; }
    public static implicit operator Modular(long a)
    {
        var m = a % M;
        return new Modular((m < 0) ? m + M : m);
    }
    public static Modular operator +(Modular a, Modular b)
    {
        return a.value + b.value;
    }
    public static Modular operator -(Modular a, Modular b)
    {
        return a.value - b.value;
    }
    public static Modular operator *(Modular a, Modular b)
    {
        return a.value * b.value;
    }
    private static Modular Pow(Modular a, int n)
    {
        switch (n)
        {
        case 0:
            return 1;
        case 1:
            return a;
        default:
            var p = Pow(a, n / 2);
            return p * p * Pow(a, n % 2);
        }
    }
    public static Modular operator /(Modular a, Modular b)
    {
        return a * Pow(b, M - 2);
    }
    private static readonly List<int> facs = new List<int> { 1 };
    private static Modular Fac(int n)
    {
        for (int i = facs.Count; i <= n; ++i)
        {
            facs.Add((int)(Math.BigMul(facs.Last(), i) % M));
        }
        return facs[n];
    }
    public static Modular Ncr(int n, int r)
    {
        return (n < r)  ? 0
             : (n == r) ? 1
                        : Fac(n) / (Fac(r) * Fac(n - r));
    }
    public static explicit operator int(Modular a)
    {
        return (int)a.value;
    }
}

Measured memory_bytes: 13396
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

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

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

	cin >> N;
	vector<int>v(N);
	for (auto &i : v)cin >> i;
	for (int i = 0; i < N; i++) {
		v[i] -= i;
	}
	long long int ans = 0;
	map<int, int>mp;
	mp[v[N - 1]]++;
	for (int i = N - 2; i >= 0; i--) {
		int box = -(v[i] + i - 1) - i - 1;
		ans += mp[box];
		mp[v[i]]++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 21040
def get_sequence(arr):
    if len(arr) == 0:
        return [], []
    elements = []
    nums = []
    n = 1
    prev = arr[0]
    for c in arr[1:]:
        if c == prev:
            n += 1
        else:
            elements.append(prev)
            nums.append(n)
            prev = c
            n = 1
    elements.append(prev)
    nums.append(n)
    return elements, nums

S = input()
ele, num = get_sequence(S)
ans = 0
s = (ele[0]=='>')

prev = 0
for n in num:
    if s:
        ans += max(n, prev)
    ans += n*(n-1)//2
    prev = n
    s = not s
if s:
    ans += n
print(ans)

Measured memory_bytes: 75208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll ch[100010];
ll same[32][100010];
int main() {
	ll n,c;
	cin>>n>>c;
	ll sum=0;
	for(ll i=0;i<n;i++){
		ll l,r,z;
		cin>>l>>r>>z;
		ch[l]++;
		ch[r+1]--;
		same[z][l]++;
		same[z][r]++;
		if(same[z][l]==2){
			ch[l]--;
			ch[l+1]++;
		}
		if(same[z][r]==2){
			ch[r]--;
			ch[r+1]++;
		}
	}
	ll ans=ch[0];
	for(ll i=1;i<100010;i++){
		ch[i]=ch[i-1]+ch[i];
		ans=max(ans,ch[i]);
	}
	cout <<ans-sum;
	// your code goes here
	return 0;
}

Measured memory_bytes: 24832
#include<stdio.h>

int main(void)
{
int i,n,sum=100000;

scanf("%d", &n);

for(i=0;i<n;i++)
{
sum*=1.05;
if((sum%1000)!=0)
{
sum=((sum/1000)+1)*1000;
}
}

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

return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;

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

int modo[200200] = {};
bool ans[200200] = {};

void update(int num)
{
  for (int i = 1; i * i <= num; i++)
  {
    if (num % i == 0)
    {
      if (i == 1)
      {
        if (modo[i] == 1)
          modo[i] = 0;
        else
          modo[i] = 1;
      }
      else if (i * i == num)
      {
        if (modo[i] == 1)
          modo[i] = 0;
        else
          modo[i] = 1;
      }
      else
      {
        if (modo[i] == 1)
          modo[i] = 0;
        else
          modo[i] = 1;

        if (modo[num / i] == 1)
          modo[num / i] = 0;
        else
          modo[num / i] = 1;
      }
    }
  }
}

int main()
{
  int n;
  cin >> n;
  int a[200200];
  repi(i, 1, n + 1)
  {
    cin >> a[i];
  }

  rep(i, n)
  {
    modo[i] = -1;
    ans[i] = false;
  }

  for (int i = n; i >= 1; i--)
  {
    if (modo[i] == -1)
    {
      if (a[i] == 0)
      {
        ans[i] = false;
        continue;
      }
      else
      {
        ans[i] = true;
        update(i);
        continue;
      }
    }
    else if (a[i] == 0)
    {
      if (modo[i] == 0)
      {
        ans[i] = false;
        continue;
      }
      else
      {
        ans[i] = true;
        update(i);
        continue;
      }
    }
    else if (a[i] == 1)
    {
      if (modo[i] == 0)
      {
        ans[i] = true;
        update(i);
        continue;
      }
      else
      {
        ans[i] = false;
        continue;
      }
    }
  }

  int count = 0;
  repi(i, 1, n + 1)
  {
    if (ans[i])
      count++;
  }

  cout << count << endl;
  repi(i, 1, n + 1)
  {
    if (ans[i])
      cout << i << " ";
  }
  return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if (A + B > C + D){
        cout << "Left" << endl;
    }
    else if (A + B == C + D){
        cout << "Balanced" << endl;
    }
    else if (A + B < C + D){
        cout << "Right" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;  
    int ans=t.size();
    //だけみればいい
    for(int i=0;i<=s.size()-t.size();i++){
        int diff=0;
        for(int j=0;j<t.size();j++){
            if(t[j]!=s[i+j]){
                diff++;
            }
        }
      ans=min(ans,diff);
    }
    cout<<ans<<endl;
    return(0);
}

Measured memory_bytes: 3656
//問題URL
//

//解き方メモ
//
    
#include<iostream>
using namespace std;

int main(){
  int n;

  cin >> n;

  if(n==1){
    cout << 1 << endl;
  }else{
    long long l_prev2 = 2;
    long long l_prev1 = 1;
    long long l;

    for (int i = 2; i <= n; i++) {
      l = l_prev2+l_prev1;
      l_prev2 = l_prev1;
      l_prev1 = l;
    }

    cout << l << endl;
  }

  return 0;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

ll dp[100500];
int n, k;
int a[100500];

ll f(int i){
	if(i == n - 1) return 0;
	if(i >= n) return inf;
	if(dp[i] != -1) return dp[i];
	ll ret = inf;
	for(int j = i + 1; j <= min(i + k, n - 1); j++){
		ret = min(ret, abs(a[i] - a[j]) + f(j));
	}
	return dp[i] = ret;
}

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

	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	memset(dp, -1, sizeof dp);
	cout << f(0);
}

Measured memory_bytes: 6144
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp {
	char name[100];
	int t;
} P;


P Q[LEN];
int head, tail, n;

void enqueue(P x) {
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

P dequeue() {
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

int main() {
	scanf("%d",&n);
	int q;
	scanf("%d",&q);

	for(int i=0; i<n; i++) {
		scanf("%s",Q[i].name);
		scanf("%d",&Q[i].t);
	}

	head = 0;
	tail = n;
	int time = 0;

	while(head != tail) {
		P temp = dequeue();
		if(temp.t > q) {          // プロセスがクオンタムより大きければ
			temp.t = temp.t - q;  // プロセスからクオンタムを引いてその残りを後ろに回す。
			enqueue(temp);
			time += q;            // time更新
		} else {                  // プロセスがクオンタムより小さければ
			time += temp.t;       // timeをプロセス分更新して
			printf("%s %d\n",temp.name,time);   // そのプロセスを出力
		}
	}

}



Measured memory_bytes: 12744
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <stdio.h>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <vector>
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second

using namespace std;

const int inf = 1e9 + 7;
const long long INF = 1e18 + 7;
const int maxn = 2e5 + 7;

int a, b, c, d;

int main(){
	ios_base::sync_with_stdio(NULL);
	cin.tie(0);
	cout.tie(0);
	cin >> a >> b >> c >> d;
	cout << max(a * b, c * d);
	return 0;
} 

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

#define Max 1000

struct card {
	char mark;
	int value;
}; typedef struct card card;

void  swap(card *x, card *y)
{
    card  buff;
	
	buff = *x;
	*x = *y;  
	*y = buff;
}

void printA(card A[Max], int N) {
	int i;

	for (i = 0; i < N - 1; i++)
		printf("%c%d ", A[i].mark, A[i].value);
	printf("%c%d\n", A[i].mark, A[i].value);
}

void bubbleSort(card A[Max], int N) {
	int j;
	int flag = 1;

	while (flag) {
		flag = 0;
		for (j = N - 1; j > 0; j--) {
			if (A[j].value < A[j - 1].value) {
				swap(&A[j], &A[j - 1]);
				flag = 1;
			}
		}
	}
}

void selectionSort(card A[Max], int N) {
	int i, j, minj;

	for (i = 0; i < N; i++) {
		minj = i;
		for (j = i; j < N; j++) {
			if (A[j].value < A[minj].value)
				minj = j;
		}
		if (i != minj) {
			swap(&A[i], &A[minj]);
		}
	}
}

int main( ) {
	int N, i;
	int true = 1;
	card A[Max];
	card B[Max];

	scanf("%d", &N);

	for (i = 0; i < N; i++) {
		scanf(" %c%d", &A[i].mark, &A[i].value);
		B[i] = A[i];
	}

	bubbleSort(A, N);

	printA(A, N);

	printf("Stable\n");

	selectionSort(B, N);

	printA(B, N);

	for (i = 0; i < N; i++)
		if (A[i].mark != B[i].mark) true = 0;

	if (true)	printf("Stable\n");
	else		printf("Not stable\n");

	return 0;
}

Measured memory_bytes: 624
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>


/* ---------- Namespace ---------- */

using namespace std;


/* ---------- Type Abbreviation ---------- */

template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

using ll = long long;
using PL = P<ll, ll>;
using PS = P<string, ll>;

using VI = V<int>;
using VVI = V<VI>;
using VL = V<ll>;
using VVL = V<VL>;
using VS = V<string>;
using VB = V<bool>;
using VVB = V<VB>;
using VPL = V<PL>;
using VPS = V<PS>;

#define fst first
#define snd second


/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)


/* ---------- container ---------- */

#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define GSORT(c) sort(ALL(c), greater<decltype((c).front())>())
#define SZ(x) (LL((x).size()))


/* ---------- repetition ---------- */

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// Usual REP runs from 0 to n-1 (R: n to 0)
// Natural REP runs from 1 to n (R: n to 1)


/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};


/* ---------- Debug ---------- */
#define GET_VAR_NAME(variable) #variable

#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

template <typename T>

void testVector(T& v) {
  REP(i, SZ(v)) {
    cout << i << ":" << v << endl;
  }
}


/* ^^^^^^^^^^^^^^^ Settting Part ^^^^^^^^^^^^^^^ */

/* ---------- Variances ---------- */

ll N;
VL X;
VL mid(2);

/* ---------- Functions ---------- */


/* ---------- Main Function ---------- */

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

  int N;
  cin >> N;
  X.resize(N);
  REP(i, N) {
    cin >> X[i];
  }

  VL cpX = X;
  SORT(cpX);
  mid[0] = cpX[N / 2 - 1];
  mid[1] = cpX[N / 2];

  REP(i, N) {
    if (X[i] <= mid[0]) {
      cout << mid[1] << endl;
    } else {
      cout << mid[0] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 5376
#include <stdio.h>

int main(void)
{

        int a,b,s;

        scanf("%d%d",&a,&b);

        if((a+b)%2==0)
                printf("%d\n",(a+b)/2);
        else
                printf("%d\n",(((a+b)/2)+1));

        return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
  cin>>s;
  int N=s.size();
  vector<int>A(N);
  for(int i=0;i<N;i++){
  char c=s.at(i); int a=c-'0';
    A.at(i)=a;
  }vector<int>U(N);
  vector<int>D(N);
  U.at(0)=min(11-(A.at(0)+1),A.at(0)+1);
  D.at(0)=min(11-A.at(0),A.at(0));
  for(int i=1;i<N;i++){
  if(A.at(i)!=9 && A.at(i)!=0){
  U.at(i)=min(10-(A.at(i)+1)+U.at(i-1),A.at(i)+1+D.at(i-1));
    D.at(i)=min(10-A.at(i)+U.at(i-1),A.at(i)+D.at(i-1));
  }else if(A.at(i)==0){
  U.at(i)=min(9+U.at(i-1),1+D.at(i-1));
      D.at(i)=D.at(i-1);        
  
  }else{
  U.at(i)=U.at(i-1);
      D.at(i)=min(1+U.at(i-1),9+D.at(i-1));       
  }
  
  
  }cout<<D.at(N-1)<<endl;
   return 0;
}


Measured memory_bytes: 13060
n = int(input())
a = list(map(int,input().split()))
m = 11111111111111111111111111111111111111111111111110;count = 0;check = False
for i in range(n):
    if a[i] == 0:check = True
    if m > abs(a[i]):
        m = abs(a[i])
    if a[i] < 0:count += 1
if count % 2 == 0:check = True
s = 0
for i in range(n):
    s += abs(a[i])
if check:print(s)
else:print(s-2*abs(m))

Measured memory_bytes: 64752
#include "bits/stdc++.h"
using namespace std;

char s[105][105];

int main() {
    int n;
    scanf("%d %*d", &n);
    for(int i = 1; i <= n; ++i) {
        scanf("%s", s[i]);
        puts(s[i]);
        puts(s[i]);
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int[] ary =new int[3];
    	ary[0]=sc.nextInt();
    	ary[1]=sc.nextInt();
    	ary[2]=sc.nextInt();

    	int reg=0;
    	for(int i=ary[0];i<ary[1]+1;i++){
    		if(ary[2]%i==0){
    			reg++;
    		}
    	}
    	System.out.println(reg);
    }
}


Measured memory_bytes: 26380
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <bitset>
#define M 2005
using namespace std;
int n,a[M],cnt;
bitset <4000005> F;
int read(){
	char c=getchar();int ans=0;
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') ans=(ans<<1)+(ans<<3)+(c^48),c=getchar();
	return ans;
}
int main(){
	n=read();F[0]=1;
	for (register int i=1;i<=n;i++) a[i]=read(),cnt+=a[i],F|=(F<<a[i]);
	for (register int i=(cnt+1)/2;i<=cnt;i++)
	    if (F[i]){printf("%d",i);break;}
	return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
int main(){
  int s;
  cin>>s;
  map<int,int> mp;
  mp[s]=1;
  int cnt=2;
  while(1){
    int ns;
    if(s%2==0) ns=s/2;
    else ns=3*s+1;
    s=ns;
    if(mp.find(ns)==mp.end()) mp[ns]=cnt;
    else {
      cout<<cnt<<endl;
      return 0;
    }
    cnt++;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);



int main()
{
	fastio;
		
	
	int n,x;
	cin>>x>>n;
	int a[n];
	int mini=INT_MAX;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}

	sort(a,a+n);
	int index=x;

	for (int i = -101; i <=101; ++i)
	{
		int flag=0;
		for(int j=0;j<n;j++)
		{
			if(a[j]==i)
			{
				flag=1;
				break;
			}
		}

		if(flag==0)
		{
			if(abs(i-x)<mini)
			{
				mini=abs(i-x);
				index=i;
			}
		}
	}

	cout<<index;

	return 0;
}







Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
/*cout <<setprecision(11)<<ret<<endl;で、数字部分を計11桁表示*/
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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; }

//Shift+Command+bでデバッグ
//その後ターミナルで./a.outを実行
//入力を貼り付ける

//////////////////
//  A
/*int main(void){
    int x,a;cin>>x>>a;
    if(x<a) cout<<"0"<<endl;
    else cout<<"10"<<endl;
    return 0;
}*/
//////////////////
//  B
/*int main(void){
    int n,x;cin>>n>>x;
    int sum=0,cnt=1;

    rep(i,n){
        int l;cin>>l;
        sum+=l;
        if(sum>x){
            break;
        }else{
            cnt++;
        }
    }

    cout<<cnt<<endl;

    return 0;
}*/
//////////////////
//  C
int main(void){
    double w,h,x,y;cin>>w>>h>>x>>y;
    bool ret=(2*x==w)&&(2*y==h);
    cout<<(double)((w*h)/2.0)<<" "<<ret<<endl;
    return 0;
}
//////////////////
//  D
/*int main(void){

    return 0;
}*/
//////////////////
//  E
/*int main(void){

    return 0;
}*/
//////////////////
//  F
/*int main(void){

    return 0;
}*/


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define float long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define endl '\n'
#define pii pair<int, int>
#define tii tuple<int, int, int>
#define min3(a,b,c) min(a, min(b, c))
#define max3(a,b,c) max(a, max(b, c))
#define all(x) x.begin(), x.end()
#define fill(a,b) memset(a, b, sizeof(a))
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define mex 100005
int freq[mex];

signed main()
{

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int n; cin>>n;
    int arr[n],ans=0;
    for(int i=0;i<n;i++){
    	cin>>arr[i];
    	ans^=arr[i];
    }
    for(int i=0;i<n;i++){
    	int ans1=ans^arr[i];
    	cout<<ans1<<" ";
    }

}

Measured memory_bytes: 5140
#include <iostream>
#include <vector>
#include <string>

#define rep(i,n) for(int (i) = 0; (i) != (n); (i)++)
using namespace std;

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

	vector<int> left, right;

	rep(i, n) {
		int temp; cin >> temp;
		if (i % 2 == 0)
			right.push_back(temp);
		else
			left.push_back(temp);
	}
	if (n % 2 == 0) {
		rep(i, left.size())
			cout << left[left.size() - 1 - i] << " ";
		rep(i, right.size()) {
			if (i == right.size() - 1)
				cout << right[i] << endl;
			else
				cout << right[i] << " ";
		}
	}
	else {
		rep(i, right.size())
			cout << right[right.size() - 1 - i] << " ";
		rep(i, left.size()) {
			if (i == left.size() - 1)
				cout << left[i] << endl;
			else
				cout << left[i] << " ";
		}
	}

	return 0;
}



Measured memory_bytes: 3188
function Main(input){
tmp = input.split(" ");
var A = parseInt(tmp[1]);
var N = parseInt(tmp[0]);
var B = parseInt(tmp[2]);
  
  if(A*N<B){console.log(A*N);}
  else if(A*N>B){console.log(B);}
else if(A*N==B){console.log(A*N);}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

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

    if (a == 2 || b == 2)
    {
        cout << "No";
    }
    else
    {
        cout << "Yes";
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int n[100001];
    std::cin >> n[0];
    for (int i = 1; (i <= n[0]); ++i) {
        std::cin >> n[i];
    }
    int cur = 1;
    for (int c = 1; (c <= n[0]); ++c) {
        cur = n[cur];
        if (cur == 2) {
            std::cout << c << std::endl;
            return 0;
        }
    }
    std::cout << -1 << std::endl;
    return 0;
}


Measured memory_bytes: 640