akhauriyash/Code-Regression huggingface dataset:
def solve(queries):
    converted = [(x + y, x - y) for x, y in queries]
    oddeven = converted[0][0] % 2
    if any(q[0] % 2 != oddeven for q in converted):
        print(-1)
        return
    arms = [1 << i for i in range(35)]
    arms.reverse()
    if oddeven == 0:
        arms.append(1)

    buf = []
    for u, v in converted:
        tmp = []
        for d in arms:
            dx, dy = u >= 0, v >= 0
            if dx:
                u -= d
                if dy:
                    tmp.append('R')
                    v -= d
                else:
                    tmp.append('U')
                    v += d
            else:
                u += d
                if dy:
                    tmp.append('D')
                    v -= d
                else:
                    tmp.append('L')
                    v += d
        buf.append(''.join(tmp))
        # check(''.join(tmp), arms)
    print(len(arms))
    print(*arms)
    print('\n'.join(buf))


def check(s, arms):
    x, y = 0, 0
    for c, d in zip(s, arms):
        dx, dy = [(d, 0), (-d, 0), (0, d), (0, -d)]['RLUD'.index(c)]
        x += dx
        y += dy
    print(x, y)


n = int(input())
queries = [tuple(map(int, input().split())) for i in range(n)]
solve(queries)


Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>
#include <cmath>
#include <limits>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a + b == c or a + c == b or c + b == a) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
	ll n{0};
	cin>>n;

	ll arr[n];
	for(ll i=0;i<n;i++)
		cin>>arr[i];

	sort(arr,arr+n,greater<ll>());

	ll req=n-1;
	ll sum{0};
	ll i{1};

	sum=sum+arr[0];
	req--;

	while(req!=0){
		if(req>=2){
			sum=sum+arr[i]+arr[i];
			i++;
			req=req-2;
		}
		else if(req==1){
			sum=sum+arr[i];
			req--;
		}
	}
	cout<<sum<<endl;
	return 0;
}



Measured memory_bytes: 5156
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
int main(){
    int N;
    cin>>N;
    int d[N];
    for(int i=0;i<N;i++)cin>>d[i];

    int num[110]={0};
    for(int i=0;i<N;i++)num[d[i]]++;

    int ans;
    for(int i=1;i<=100;i++){
        if(num[i])ans++;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
p = int(input().split()[1])
s = input()
if 10 % p:
  s = reversed(s)
a = enumerate(map(int, s), 1)
if 10 % p == 0:
  r = sum(i for i, x in a if x % p == 0)
else:
  d = [1] + [0] * (p - 1)
  t, y = 0, 1
  for i, x in a:
    t = (t + x * y) % p
    d[t] += 1
    y = y * 10 % p;
  r = sum(i * (i - 1) // 2 for i in d)
print(r)


Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
int main(void){
	int a,b,c,i;
	string A,B,C;
	cin>>a>>b>>c;

	if(b>=c){
		cout<<"delicious"<<endl;
	}else if(c-b<=a){
		cout<<"safe"<<endl;
	}else{
		cout<<"dangerous"<<endl;
	}
	//cout<<A<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
#define int long long

signed main(){
    string S;
    cin >> S;
    
    string left,right;
    int ans = 0;
    for(int i=1;i<S.length()-i;i++){
        left = S.substr(0,i);
        right = S.substr(i,i);
        if(left==right){
            ans = max(ans,i*2);
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;
ll K,A,B;
ll ans=0;
int main()
{
  cin>>K>>A>>B;
  if(B-A<=2 || K<=A){ //A-1叩き 1kaseigi 1koukan
    cout<<K+1<<endl;
    return 0;
  }
  else{
    ans = A;
    K-=(A-1);
    ans += (B-A)*(K/2);
    ans += K%2;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
int main(){
  int n,k;
  cin>>n>>k;
  int ans=1;
  for(int i=0;i<n;i++){
    ans=min(ans*=2,ans+k);
  }
 
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
s = int(input())

if s < 3:
  print(4)
  exit(0)

cnt = 1
val = s
while True:
  if cnt > 1 and val == 1:
    break
  
  if val % 2 == 0:
    val = val//2
  else:
    val = val*3+1
    
  cnt += 1
             
print(cnt+1)

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

int main(){
   int n,a,b,c,d;
  cin >> n;
	a=n/1000;
	b=n/100-a*10;
	c=n/10-a*100-b*10;
	d=n%10;
	if(((a == b)&&(b == c))||((b == c)&&(c == d))){
	cout << "Yes" << endl;
         }else{
		cout << "No" << endl;
}
	return 0;
 }
 

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define PI acos(0)

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, x;
    cin >> a >> b >> x;
    if(a * a * b <= x * 2) {
        cerr << a << " " <<2*(a*a*b-x)/(a * a+0.0)<< endl;
        cout << fixed << setprecision(12) << atan2(2*(a*a*b-x)/(a * a+0.0), a) * 180.0/(2*PI) << endl;
    } else {
        cout << fixed << setprecision(12) << 90.0 - atan2(x*2/(a * b + 0.0),b) * 180.0/(2*PI) << endl;
    }

    return 0;
}


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

int func(int x){
  if(x%2==1) return 0;
  return func(x/2)+1;
}
int main(){
  int N;
  cin >> N;
  int ans=1;
  for (int i=1; i<=N; i++){
    if (func(i)>func(ans)){
      ans=i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
#define vb vector<bool>
#define vbb vector< vector<bool> >
#define vs vector<string>
#define vc vector<char>
#define vvc vector< vector<char> >

#define all(a) (a).begin(),(a).end()
using namespace std;

int main(){
	ll a, b; cin >> a >> b;
	if (a <= 8 && b <= 8) cout << "Yay!" << endl;
	else cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  char s[100];
  int i,a,j,c=0;
  while(scanf("%s",s)!=EOF){
    i=strlen(s)-1;
    a=1;
    for(j=0;j<=i-j;j++){//printf("%c%c ",s[j],s[i-j]);
      if(s[j]!=s[i-j]){
	a=0;
	break;
      }
    }
    if(a)c++;
  }
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 540
#include <bits/stdc++.h>
using namespace std;
using PII = pair<int, int>;
using ll = long long;
#define ff first 
#define ss second 
const int N = 100000 + 10;
vector<PII> v[N];
vector<int> S;
int n, m, a, b, col[N], C[4], ban, tot;
int fit(int x) {
    while (x > 3) x -= 3;
    while (x < 1) x += 3;
    return x;
}
void dfs(int x, int c) {
    if (col[x]) {
        if (col[x] != c) ban = 1;
        return;
    }
    S.push_back(x);
    col[x] = c;
    for (auto E : v[x]) {
        tot++;
        dfs(E.ff, fit(c + E.ss));
    }
}
int main() {
    scanf("%d%d", &n, &m);
    while (m--) {
        scanf("%d%d", &a, &b);
        v[a].push_back({b, 1});
        v[b].push_back({a, -1});
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        if (col[i]) continue;
        memset(C, 0, sizeof(C));
        S.clear();
        ban = tot = 0;
        dfs(i, 1);
        for (auto x : S) C[col[x]]++;
        if (ban)
            ans += 1ll * S.size() * S.size();
        else if (C[1] == 0 || C[2] == 0 || C[3] == 0)
            ans += tot / 2;
        else
            ans += 1ll * C[3] * C[1] + 1ll * C[1] * C[2] + 1ll * C[2] * C[3];
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 11256
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define pii pair<int,int>
#define prec(n) fixed<<setprecision(n)
#define MOD 1000000007
#define eps 1e-8
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");


signed main(){
    FASTER;
    int n,cnt=0;cin>>n;
    vi v(n);cin>>v;
    for(int i=1;i<n-1;i++){
        if((v[i]-v[i-1])*(v[i]-v[i+1])<0){
            cnt++;
        }
    }
    cout<<cnt;
            
}

Measured memory_bytes: 256
Module Module1

    Sub Main()

        Dim N As Integer = Console.ReadLine()
        Dim tmp As String() = Split(Console.ReadLine())
        Dim d(N) As Integer
        Dim i, j As Integer
        Dim wk As Integer = 0

        For i = 0 To N - 1
            For j = i + 1 To N - 1
                d(i) = CInt(tmp(i))
                wk += d(i) * CInt(tmp(j))
            Next
        Next

        Console.WriteLine(wk)
        'Console.Read()

    End Sub

End Module


Measured memory_bytes: 13532
/**
    And in the end, the love you take is equal to the love you make.

        I LOVE YOU LAURA.
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_DISABLE_PERFCRIT_LOCKS

#define findOrder find_by_order
#define orderKey order_of_key

#define isOn(mask, i) (mask & (1 << i))
#define turn(mask, i) (mask |= (1 << i))
#define switch(mask, i) (mask &= ~(1 << i))
#define change(mask, i) (mask ^= (1 << i))
#define lowbit(mask) (mask & (-mask))
#define turnAll(mask, n) (mask = (1 << n) - 1)
#define switchLastBit(mask) (mask & (mask - 1))
#define turnLastZero(mask) (mask | (mask + 1))
#define modulo(x, mod) ((x) & (mod - 1))
#define log2(x) (31 - __builtin_clz(x))

#define mkp make_pair
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define ins insert
#define rsz resize
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define debug(x) (cerr << x << " ")

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdb;
typedef pair<int, ii> tri;
typedef complex<ld> cd;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vdb;
typedef vector<cd> vcd;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vll> matrix;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_tree;

const ll mod = 1e9+7;
const int maxn = 2e5+2;
const int pi = 2 * acos(0.0);
const db eps = 1e-9;

ll dp[maxn], arr[maxn];

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

    int n, k; cin >> n >> k;

    for (int i = 1; i <= n; i++){
        cin >> arr[i];
    }

    memset(dp, 63, sizeof dp);

    dp[1] = 0;
    for (int i = 2; i <= n; i++){
        for (int j = 1; j <= i && j <= k; j++){
            dp[i] = min(dp[i], dp[i - j] + abs(arr[i] - arr[i - j]));
        }
    }

    cout << dp[n] << "\n";

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int a[26]={0};
    cin>>s;
    for(int i=0;i<4;i++){
        a[s[i]-'A']++;
    }
    int b[5]={0};
    for(int i=0;i<26;i++){
        b[a[i]]++;
    }
    if(b[2]==2){
        cout <<"Yes"<<endl;
    }
    else{
        cout << "No"<<endl;
    }
    return 0;
}




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

int top, S[1000];

void push(int x) { S[++top] = x; }

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

int main() {
  int a, b;
  top = 0;
  char s[100];

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

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

  return 0;
}


Measured memory_bytes: 3224
h,w = map(int,input().split())

ys,xs=2,2
yg,xg =h+1,w+1

a= []

a.append("".join(["#"]*(w+2)))
cnt=0
for i in range(h):
    arrc = input()
    #迷路中の黒の数
    m = int(list(arrc).count("#"))
    cnt +=m
    
    arrc = "#"+arrc+"#"
    a.append(arrc)

a.append("".join(["#"]*(w+2)))

n=[(ys-1,xs-1)]
route={n[0]:0}
p=[[1,0],[0,1],[-1,0],[0,-1]]
count=1
while route.get((yg-1,xg-1),0)==0 and count != 10000:
    n2=[]
    for i in n:
        for j in p:
            np=(i[0]+j[0],i[1]+j[1])
            if a[np[0]][np[1]]=='.' and route.get(np,-1)==-1:
                n2.append(np)
                route[np]=count
                
    n=n2
    count+=1
if list(route.keys()).count((h,w)) == 1:
    vv = h*w - max(list(route.values())) - cnt -1
    print(vv)
else:
    print(-1)

Measured memory_bytes: 40816
#include <stdio.h>
#include <string.h>
char t[1010];
int main(){
    int i;
    int n;
    int ans;
    while(scanf("%s",&t)){
        n=strlen(t);
        ans=0;
        if(n==1&&t[0]=='0') break;
        for(i=0;i<n;i++){
            ans+=t[i]-'0';
        }
        printf("%d\n",ans);
    }
    return 0;
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

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

    int ans = 0;
    if(a % 2 != 0 || b % 2 != 0 || c % 2 != 0) {
        cout << 0 << endl;
        return 0;
    }
    if(a == b && b == c) {
        cout << -1 << endl;
        return 0;
    }

    while(1) {
        if(a % 2 != 0 || b % 2 != 0 || c % 2 != 0) {
            break;
        }
        ans++;
        ll x = a, y = b, z = c;
        a = (y + z) / 2;
        b = (x + z) / 2;
        c = (x + y) / 2;
    }

    cout << ans << endl;

    return 0;
}

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

int main(){

	int N;
  	int K;
  	int number = 1;

  	cin >> N >> K;
  
    for(int i = 0;i < N;i++){
    
    	if(number * 2 < number + K){
        	number = number * 2;
        }else{
        	number = number + K;
        }
      
    }
  
  	cout << number << endl;
  
}

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

typedef long long ll;
typedef pair<int, string> pis;
typedef pair<ll, string> pls;
typedef pair<ll, pis> plis;

int main(void) {
    const ll inf = LLONG_MAX;
    ll ans = inf;
    vector<pls> e[2];
    map<pis, ll> d;
    //map<pis, bool> w;
    priority_queue<plis, vector<plis>, greater<plis>> q;
    int n; cin >> n;
    for (int i = 1; i <= n; ++i) {
        string s; ll c;
        cin >> s >> c;
        string t = s;
        reverse(t.begin(), t.end());
        if (s == t) ans = min(ans, c);
        else {
            e[0].emplace_back(c, s);
            if (!d.count({ 1, s })) d[{ 1, s }] = inf;
            d[{ 1, s }] = min(d[{ 1, s }], c);
            q.push({ c, { 1, s }});

            e[1].emplace_back(c, t);
            if (!d.count({ 0, t })) d[{ 0, t }] = inf;
            d[{ 0, t }] = min(d[{ 0 , t }], c);
            q.push({ c, { 0, t }});
        }
    }
    while (!q.empty()) {
        plis u = q.top(); q.pop();
        //if (d[u.second] != u.first) continue;
        int o = u.second.first;
        const string& su = u.second.second;
        string tu = su;
        reverse(tu.begin(), tu.end());
        if (tu == su)
            ans = min(ans, u.first);
        for (pls p : e[o]) {
            plis v; v.first = u.first + p.first;
            bool fail = 1;
            const string& sp = p.second;
            if (su.size() < sp.size() && sp.substr(0, su.size()) == su) {
                string sv = sp.substr(su.size());
                fail = 0;
                v.second = { !o, sv };
            }
            else if (su.size() > sp.size() && su.substr(0, sp.size()) == sp) {
                string sv = su.substr(sp.size());
                fail = 0;
                v.second = { o, sv };
            }
            else if (su == sp)
                ans = min(ans, v.first);
            if (fail) continue;
            auto x = d.insert({ v.second, v.first });
            if (x.second || v.first < x.first->second) {
                x.first->second = min(x.first->second, v.first);
                q.push(v);
            }
        }
    }
    printf("%lld\n", ans == inf ? -1 : ans);
    return 0;
}

Measured memory_bytes: 3888
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.arraycopy;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void solve() throws Exception {
		int n = scanInt();
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scanInt() - 1;
			if (a[i] > i) {
				out.print(-1);
				return;
			}
		}
		int ans[] = new int[n];
		for (int i = n - 1, j; i >= 0; i--) {
			for (j = i; a[j] != j; j--) { }
			ans[i] = j;
			arraycopy(a, j + 1, a, j, i - j);
		}
		for (int i = 0; i < n; i++) {
			out.println(ans[i] + 1);
		}
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

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

int main() {
  while(true){
    string s;
    cin >>s;
    int ans=0;
    
    if(s=="0") break;
    
    for(int i =0; i < s.size();i++){
        ans+=(int)(s.at(i)-'0');
    }
    cout << ans <<endl;
  }
}


Measured memory_bytes: 3124
import copy
N = int(input())
x_original = list(map(int,input().split()))
x = sorted(copy.copy(x_original))
n = int(N/2)
for i in range(N):
    if(x_original[i]>=x[n]):
        print(x[n-1])
    else:
        print(x[n])


Measured memory_bytes: 26068
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    string O,E;
    cin>>O>>E;
    REP(i,O.size()){
        if(O.size()!=E.size()&&i==O.size()-1)cout<<O[i];
        else cout<<O[i]<<E[i];
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
     
#define int  long long
#define endl '\n'
const int MOD = 1e9 + 7;
const int INF = 1e18;

int dp[10005][120][2];
string k;
int d;

int get(int idx, int sum, int tight){
  if (idx == (int)k.size()) 
    return sum == 0;
  auto &ans = dp[idx][sum][tight];
  if (ans != -1)
    return ans;
  ans = 0;
  int lim = tight ? k[idx] - '0' : 9;
  for (int i = 0; i <= lim; i++){
	int new_tight = k[idx] - '0' == i ? tight : 0;
	ans += get(idx + 1, (sum + i) % d, new_tight);
	ans %= MOD;  
  } 	
  return dp[idx][sum][tight] = ans;
}

void solve(){
  memset(dp, -1, sizeof dp);
  cin >> k >> d;
  int ret =	(get(0, 0, 1) - 1 + MOD) % MOD;
  cout << ret << endl;
}

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  solve();	
}


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

using namespace std;

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

  vector<int> counts(N + 1, 0);
  for (int x = 1; x <= 101; x++) {
    for (int y = 1; y <= 101; y++) {
      for (int z = 1; z <= 101; z++) {
	int f = x * x + y * y + z * z + x * y + y * z + z * x;
	if (f <= N) counts[f]++;
      }
    }
  }

  for (int i = 1; i <= N; i++) {
    cout << counts[i] << endl;
  }

  return 0;
}


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

using namespace std;

int n;
typedef long long ll;




int main() {
    ll n;cin>>n;
    ll solu=1e13;
    for (ll i = 1; i*i <=n ; ++i) {
        if(n%i==0)solu=min(solu,((i-1)+((n/i)-1)));
    }
    cout<<solu;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int i;
	char s[1201];
	fgets(s,sizeof(s),stdin);
	for(i=0;s[i]!='\n';i++){
		if('a'<=s[i]&&s[i]<='z')printf("%c",s[i]-'a'+'A');
		else if('A'<=s[i]&&s[i]<='Z')printf("%c",s[i]+'a'-'A');
		else printf("%c",s[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 524
import Text.Printf
import Data.List

main = do
  s1 <- getLine
  s2 <- getLine
  let l = sort . map (read :: String->Int) $ words s2
  putStr $ show $ head l
  ;putStr " "
  ;putStr $ show $ last l
  ;putStr " "
  ;putStrLn $ show $ sum l

Measured memory_bytes: 7644
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,a,b;
	cin>>n>>a>>b;
	if((b-a)%2==0)
	{
		cout<<(b-a)/2;
	}
	else
	{
		cout<<min(a-1+(b-a-1)/2+1,n-b+(b-a-1)/2+1);
	}
	return 0;	
}

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

using ll = long long;

int main() {
    int H, h0, m0, s0;
    while(cin >> H >> h0 >> m0 >> s0, H) {
        const ll d = 119 * H - 1;
        ll n = s0 * d;
        ll ho = h0, mo = m0;
        while(true) {
            ll ang_h = 3600 * ho * d + 60 * mo * d + n;
            ll ang_m = 60 * H * mo * d + n * H;
            ll ang_s = 60 * H * n;
            ang_m = (ang_m - ang_h) % (360 * 10 * H * d);
            ang_s = (ang_s - ang_h) % (360 * 10 * H * d);
            if(ang_m < 0) {
                ang_m += 360 * 10 * H * d;
            }
            if(ang_s < 0) {
                ang_s += 360 * 10 * H * d;
            }
            ang_h = 0;

            if(ang_h != ang_m) {
                ll ang1, ang2;
                if(ang_m < ang_s) {
                    ang1 = 360 * 10 * H * d - ang_s;
                    ang2 = ang_s - ang_m;
                } else {
                    ang1 = ang_s;
                    ang2 = ang_m - ang_s;
                }
                if(ang1 == ang2) {
                    break;
                }
            }

            n++;
            if(n == 60 * d) {
                n = 0;
                mo++;
            }
            if(mo == 60) {
                mo = 0;
                ho++;
            }
            if(ho == H) {
                ho = 0;
            }
        }
        ll g = __gcd(n, d);
        cout << ho << ' ' << mo << ' ' << n / g << ' ' << d / g << endl;
    }
}


Measured memory_bytes: 2984
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

char s[20];
int main() {
	scanf("%s", s);
	bool v = true;
	for (int i = 0; s[i]; i += 2) {
		v &= s[i] == 'h';
		v &= s[i + 1] == 'i';
	}
	printf(v ? "Yes\n" : "No\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
int main(){
string a,b;
int c;
b = '1';
int N;
cin >> a >> c;
c--;
N = a.length();
for(int i = 0; i < N; i++){
if(a[i] != '1'){
b = a[i];
goto res;
}
if(a[i] == '1' && i == c)
goto res;
}
res:
cout << b;
}

Measured memory_bytes: 256
N, M, K = map(int, input().split())
F = [list() for _ in range(N)]
B = [list() for _ in range(N)]

for _ in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    F[a].append(b)
    F[b].append(a)

for _ in range(K):
    c, d = map(int, input().split())
    c, d = c - 1, d - 1
    B[c].append(d)
    B[d].append(c)

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        self.size = [1] * n

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # すべての頂点に対して親を検索する
    def all_find(self):
        for n in range(len(self.par)):
            self.find(n)

UF = UnionFind(N)

for i in range(N):
    for friend in F[i]:
        UF.union(i, friend)

ans = [UF.size[UF.find(i)] - 1 for i in range(N)]

for i in range(N):
    ans[i] -= len(F[i])

for i in range(N):
    for block in B[i]:
        if UF.same(i,block):
            ans[i] -= 1

print(*ans)

Measured memory_bytes: 48452
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i,n) cin >> l.at(i);
  sort(l.begin(),l.end());
  int sum=0;
  rep(i,n-1) sum += l.at(i);
  if(sum > l.at(n-1)) {
      cout << "Yes";
      return 0;
  }
 cout << "No";
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<set>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define arep(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<char, ll> P;

vector<P> run_length(const string& s) {
    char now = s[0];
    ll cnt = 1;
    vector<P> res;
    rep(i, 1, s.size()) {
        if (s[i] != now) {
            res.push_back(P(now, cnt));
            now = s[i];
            cnt = 1;
        }
        else cnt++;
    }
    res.push_back(P(now, cnt));
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    ll K;
    cin >> S >> K;
    int N = (int)S.size();
    set<char> ss;
    rep(i, 0, N) {
        ss.insert(S[i]);
    }
    if (ss.size() == 1) {
        cout << ((ll)S.size() * K) / 2 << endl;
        return 0;
    }
    vector<P> rl = run_length(S);
    ll cnt = 0;
    rep(i, 0, rl.size()) {
        cnt += rl[i].second / 2;
    }
    ll ans = cnt * K;
    if (rl.begin()->first == rl.rbegin()->first) {
        ll a = rl.begin()->second;
        ll b = rl.rbegin()->second;
        ans -= (a / 2 + b / 2 - (a + b) / 2) * (K - 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = str(n)

ans = 0
if len(s) % 2 == 0:
    for i in range(int(len(s)/2)):
        ans += 9 * (10 ** (2 * i))

else:
    for i in range(int((len(s)-1)/2)):
        ans += 9 * (10 ** (2 * i))

    p = n - 10 ** (len(s)-1) + 1
    ans += p

print(ans)
    



                                        




    




        


    







        



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

int n, c;

int dp[35][1 << 16];
int a[35], b[35];

int main()
{
  while(true){
    scanf("%d%d", &n, &c);
    if(!n || !c){
      break;
    }
    memset(dp, -1, sizeof dp);
    memset(a, 0, sizeof a);
    memset(b, 0, sizeof b);
    dp[0][0] = 0;
    
    for(int i = 0; i < n; i++){
      for(int j = 0; j < 16; j++){
	int in;
	scanf("%d", &in);
	a[i] |= in << j;
      }
    }
    for(int i = 0; i < c; i++){
      for(int j = 0; j < 16; j++){
	int in;
	scanf("%d", &in);
	b[i] |= in << j;
      }
    }

    for(int i = 0; i < n; i++){
      for(int j = 0; j < 1 << 16; j++){
	if(dp[i][j] > -1){
	  int np = j | a[i];
	  for(int k = 0; k < c; k++){
	    int score = 0;
	    for(int l = 0; l < 16; l++){
	      score += !!(np & b[k] & 1 << l);
	    }
	    dp[i + 1][np & ~b[k]] = max(dp[i][j] + score, dp[i + 1][np & ~b[k]]);
	  }
	}
      }
    }

    int ans = 0;
    for(int i = 0; i < 1 << 16; i++){
      ans = max(ans, dp[n][i]);
    }

    printf("%d\n", ans);
  }
  return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> L(2*M);
  for(int i=0; i<M; i++) {
    cin >> L[2*i] >> L[2*i+1];
  }
  for(int i=1; i<=N; i++) {
    int X=0;
    for(int j=0; j<M; j++) {
      if(L[2*j] == i || L[2*j+1] == i) {
        X++;
      }
    }
    cout << X << endl;
  }
  return 0;
}

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

int main(){
  int n,p,l[100000];
  while(scanf("%d",&n),n){
    long long num = n,len = 0;
    for(int i=0;i<n;i++){ scanf("%d",&p); len += p;}

    for(int i=0;i<n-1;i++)scanf("%d",&l[i]);
    sort(l,l+n-1);
    
    for(int i=n-2;i>=0;i--){
      if( (num-1)*(len+l[i]) < num*len )break;
      num--; len += l[i];
    }
    printf("%lld\n",num*len);
  }
}
   

Measured memory_bytes: 1304
#include<iostream>
#define ll long long
using namespace std;

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

	ll n,k;
	cin >> n >> k;
	ll ans = n%k;
	if(abs(k-ans) < ans) ans = k-ans;
	cout << ans;

	return 0;
}

Measured memory_bytes: 3656
import java.util.*;
import java.lang.*;

/**
 * PrintAChessboard
 */
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        out_of_loop: while (true) {
            int h = Integer.parseInt(sc.next());
            int w = Integer.parseInt(sc.next());

            if (h == 0 && w == 0)
                break out_of_loop;

            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    if ((j + i) % 2 == 0) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }

                System.out.println("");
            }

            System.out.println("");
        }

        sc.close();

    }
}


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

//define-----------------------------------------------------------------------------------------------------------------------
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)

//typedef----------------------------------------------------------------------------------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
//const------------------------------------------------------------------------------------------------------------------------
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
//global-----------------------------------------------------------------------------------------------------------------------
int n, s;
VI a;
LL dp[ 100 ][ 21 ];

LL solve( int now, int f ) {
	if ( dp[ now ][ f ] >= 0 ) {
		return dp[ now ][ f ];
	}
	ull res = 0;
	if ( now == n - 1 ) {
		res = s == f;
	}
	else {
		if ( f + a[ now ] <= 20 ) {
			res += solve( now + 1, f + a[ now ] );
		}
		if ( f - a[ now ] >= 0 ) {
			res += solve( now + 1, f - a[ now ] );
		}
	}
	return dp[ now ][ f ] = res;
}
int main() {
	scanf( "%d", &n );
	a.resize( n - 1 );
	for ( int i = 0; i < n - 1; i++ ) {
		scanf( "%d", &a[ i ] );
	}
	scanf( "%d", &s );
	memset( dp, -1, sizeof( dp ) );
	printf( "%lld\n", solve( 1, a[ 0 ] ) );
	return 0;
}

Measured memory_bytes: 1216
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

func main() {
	scanner := Scanner()
	n := ReadInt(scanner)

	// ans := make(map[int]int, n)
	nMax := 10 * 10 * 10 * 10
	ans := make([]int, nMax+1)
	// count := 0

	for x := 1; x*x <= nMax; x++ {
		for y := 1; y*y <= nMax; y++ {
			for z := 1; z*z <= nMax; z++ {
				// fmt.Println(x, y, z)
				result := x*x + y*y + z*z + x*y + y*z + z*x
				if result <= nMax {
					// fmt.Println(x, y, z, x*x+y*y+z*z+x*y+y*z+z*x)
					ans[result-1]++
				}
			}
		}
	}

	for i := 0; i < n; i++ {
		fmt.Println(ans[i])
	}
}

func Scanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

func ReadInt(scanner *bufio.Scanner) int {
	var t string

	if scanner.Scan() {
		t = scanner.Text()
	}

	n, err := strconv.Atoi(t)
	if err != nil {
		log.Fatal(err)
	}

	return n

}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
int A,B,C,D,cnt;
int main(){
    cin>>A>>B>>C>>D;
    D/=50;
    for(int i=0;i<=A;i++){
        for(int j=0;j<=B;j++){
            if(D>=i*10+j*2&&D<=i*10+j*2+C){
                cnt++;
            }
        }
    }
    cout<<cnt;
    return 0;
}

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

constexpr int64_t MOD = 1e9 + 7;

int64_t MODpow(int64_t n, int64_t m) {
    int64_t result = 1;
    while (m) {
        if (m % 2 == 1) {
            result *= n;
            result %= MOD;
        }

        m /= 2;
        n *= n;
        n %= MOD;
    }

    return result;
}

class Combination {
public:
    Combination(int64_t max_num, int64_t mod) {
        fact_.resize(max_num + 1, 1);
        inv_fact_.resize(max_num + 1, 1);
        mod_ = mod;
        for (int64_t i = 2; i <= max_num; i++) {
            fact_[i] = i * fact_[i - 1] % mod_;
            inv_fact_[i] = MODpow(fact_[i], mod_ - 2);
            assert(fact_[i] * inv_fact_[i] % mod_ == 1);
        }
    }
    int64_t operator()(int64_t n, int64_t m) const {
        if (m < 0 || m > n) return 0;
        return fact_[n] * inv_fact_[n - m] % mod_ * inv_fact_[m] % mod_;
    }
private:
    int64_t MODpow(int64_t n, int64_t m) const {
        int64_t result = 1;
        while (m) {
            if (m % 2 == 1) {
                result *= n;
                result %= mod_;
            }

            m /= 2;
            n *= n;
            n %= mod_;
        }

        return result;
    }

    vector<int64_t> fact_, inv_fact_;
    int64_t mod_;
};

int main() {
    int64_t n, k;
    cin >> n >> k;

    Combination comb(n, MOD);
    int64_t ans = 0;
    for (int64_t i = 0; i < min(n, k + 1); i++) {
        //0人となる部屋がi個である場合の数を計算
        //0人となる部屋の選び方 -> n_C_i
        //i人がn - iの部屋のどこかへ移動 -> {n - 1}_C_{i}
        (ans += comb(n, i) * comb(n - 1, i) % MOD) %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3328
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  ll A[N];
  for(int i=0;i<N;++i) cin>>A[i];
  ll ans = A[0]-1;
  ll maxnum=1;
  for(int i=1;i<N;++i) {
    if(A[i]<=maxnum+1) maxnum = max(maxnum, A[i]);
    else {
      if(A[i]%(maxnum+1)==0) {
        ans += A[i]/(maxnum+1)-1;
      }
      else ans += A[i]/(maxnum+1);
      A[i] = maxnum;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4360
#include <bits/stdc++.h>
using namespace std;
int a, b;
int main() {
    cin >> a >> b;
    if (a > 0 && b > 0) {
        cout << "Positive" << endl;
    } else if (max(a, b) >= 0 && min(a, b) <= 0 || a == 0 || b == 0) {
        cout << "Zero" << endl;
    } else {
        if ((abs(min(a, b)) - abs(max(a, b))) % 2 == 0) {
            cout << "Negative" << endl;
        } else {
            cout << "Positive" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  string a;cin>>a;
  int cnt=0;
  REP(i,4){
    if (a[i]=='2') {
      cnt++;
    }
  }
  P(cnt);
  return 0;
}


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

int main() {
    string S;
    int Q;
    cin >> S >> Q;
    deque<char> deq;
    for(unsigned int i=0; i<S.size(); i++) {
        deq.push_back(S.at(i));
    }
    int flag_rev = 0;

    for(int i=0; i<Q; i++) {
        int Qi;
        cin >> Qi;
        if(Qi == 1) {
            flag_rev = 1-flag_rev;
        } else {
            int Fi;
            char Ci;
            cin >> Fi >> Ci;
            if((flag_rev ^ (Fi-1)) == 0) {
                deq.push_front(Ci);
            } else {
                deq.push_back(Ci);
          }
      }
      //printf("%d %s\n", flag_sort, S.c_str());
  }

  if(flag_rev == 0) {
      for(unsigned int i=0; i<deq.size(); i++) {
          cout << deq.at(i);
      }
  } else {
      for(unsigned int i=deq.size(); i>0; i--) {
          cout << deq.at(i-1);
      }
  }
  cout << endl;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

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

// 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(...) do{ } while(false)
#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; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin, n;
    cout << (n + 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[100005];
int main()
{
int n, ans=0;
cin>>n;
for(int a=1; a<=n; a++)
{
int x;
cin>>x;
dp[x]++;
}
for(int a=1; a<100005; a++)
ans=max(ans, dp[a]+dp[a-1]+dp[a+1]);
cout<<ans;
return 0;
}

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

int main(){
    stack<int> st;

    int n;

    while(cin >> n){
        if(n == 0){
            cout << st.top() << endl;
            st.pop();
        }else{
            st.push(n);
        }
    }
    return 0;
}

Measured memory_bytes: 0
program sample
	implicit none
    character(len=4) ::x
    integer ::count,i
    
    read(*,*) x
    do i=1,4
    	if(x(i:i)=='2') then
        	count = count+1
        end if
    end do
    
    write(*,*) count
    
    stop
end program sample

Measured memory_bytes: 2856
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int n;
char board[500][502];
char nboard[500][502];

void flip(int i, int j, char bb[][502]) {
	static char tmp[502];
	for (int k = 0; k < n; ++k) tmp[k] = bb[i][k];
	for (int k = 0; k < n; ++k) bb[k][j] = tmp[k];
}

int makeAnsWithAllBlack(int allblackRow, char bb[][502]) {
	int ret = 0;
	for (int j = 0; j < n; ++j) {
		bool remainWhite = false;
		for (int i = 0; i < n; ++i) {
			if (bb[i][j] == '.') {
				remainWhite = true;
				break;
			}
		}
		if (remainWhite) {
			++ret;
		}
	}
	return ret;
}

void proc() {
	scanf("%d", &n);
	bool blackExists = false, whiteExists = false;
	for (int i = 0; i < n; ++i) {
		scanf("%s", board[i]);
		for (int j = 0; j < n; ++j) {
			if (board[i][j] == '.') whiteExists = true;
			if (board[i][j] == '#') blackExists = true;
		}
	}
	if (!blackExists) {
		printf("-1\n");
		return;
	}
	if (!whiteExists) {
		printf("0\n");
		return;
	}

	int ans = 100000000;

	int allblackRow = -1;
	for (int i = 0; i < n; ++i) {
		bool ok = true;
		for (int j = 0; j < n; ++j) {
			if (board[i][j] == '.') {
				ok = false;
				break;
			}
		}
		if (ok) {
			allblackRow = i;
			break;
		}
	}

	if (allblackRow != -1) {
		ans = makeAnsWithAllBlack(allblackRow, board);
		printf("%d\n", ans);
		return;
	}

	for (int i = 0; i < n; ++i) {
		int cnt = 0;
		memcpy(nboard, board, sizeof(board));

		int findrow = -1;
		for (int k = 0; k < n; ++k) {
			if (nboard[k][i] == '#') {
				findrow = k;
				break;
			}
		}
		if (findrow == -1) {
			++cnt;
			flip(i, i, nboard);
			for (int k = 0; k < n; ++k) {
				if (nboard[k][i] == '#') {
					findrow = k;
					break;
				}
			}
			if (findrow == -1) {
				continue;
			}
		}

		for (int j = 0; j < n; ++j) {
			if (nboard[i][j] == '.') {
				++cnt;
				flip(findrow, j, nboard);
			}
		}
		cnt += makeAnsWithAllBlack(i, nboard);

		ans = min(ans, cnt);
	}

	printf("%d\n", ans);
}

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

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

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)
#define INF 1000000000
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;
ll kake;
ll a,b;
bool f(ll num){
	if(num == 0)return true;
	ll tmp = (num - 1) / 2;
	//if(tmp+1 == a || tmp+1 == b)return ((num)+(num-1)*tmp-tmp*tmp <= kake);
	//cout << tmp << ' ' << (num)+(num-1)*tmp-tmp*tmp << ' ' << kake << endl;
	return ((num)+(num-1)*tmp-tmp*tmp < kake);
}

int main()
{
	int q;cin >> q;
	
	REP(u,q){
		cin >> a >> b;
		if(a > b)swap(a,b);
		kake = a*b;
		ll tp = 2000001000LL;
		ll ub = 0;
		
		while(abs(tp - ub) > 1){
			ll mid = (tp + ub) / 2;
			if(f(mid))ub = mid;
			else tp = mid;
			//cout << mid << endl;
		}
		if(a == b)cout << ub << endl;
		else cout << ub-1 << endl;
	}
	return 0;
}

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

int main(){
    long long n, k;
    cin >> n >> k;
    long long arr[n];
    long long r = 0;
    for(long long i = 0; i < n; i++){
        cin >> arr[i];
    }
    sort(arr, arr+n, greater<long long>());
    for(long long i = k; i < n; i++){
        r += arr[i];
    }
    cout << r << '\n';
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

int month[]={
  0,
  31,//1
  28,//2
  31,//3
  30,//4
  31,//5
  30,//6
  31,//7
  31,//8
  30,//9
  31,//10
  30,//11
  31//12
};
/*
int day(int y,int m,int d){
  int base = y*365+d;
  REP(i,1,m)base+=month[i];
  int lim = m > 2 ? y+1:y;
  
  REP(i,1,y){
    if ( i %400 == 0 ||
	 (i % 100 !=0 && i % 4 == 0))base++;
  }
  return base;
}
*/
int day(int y,int m,int d){
  y += 4800;
  if (m < 3) --y, m += 12;
  return 365L*y+y/4-y/100+y/400+(153*m-457)/5+d-32045;
}

main(){
  int y1,m1,d1,y2,m2,d2;
  while(cin>>y1>>m1>>d1>>y2>>m2>>d2 ){
    if ( y1 < 0 || m1 < 0 || d1 < 0 || 
	 y2 < 0 || m2 < 0 || d2 < 0)break;
    int a=day(y1,m1,d1),b=day(y2,m2,d2);
    cout << b-a << endl;
  }
}

Measured memory_bytes: 0