akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
 int n;
  string s;
  cin>>n>>s;
  int count=0;
  for(int i=0;i<1000;i++){
    string t;
    int x=i;
    for(int j=0;j<3;j++){
      t+='0'+x%10;
      x/=10;
    }
    int m1=0,m2=0;
    bool flag0=false,flag1=false;
    for(int k=0;k<n;k++){
      if(!flag0&&t[0]==s[k]) {m1=k; flag0=true;}
       if(k>m1&&flag0&&!flag1&&t[1]==s[k]) {m2=k; flag1=true;}
       if(k>m2&&flag0&&flag1&&t[2]==s[k]) {count++; break;}
    }
  }
  cout<<count<<endl;
}
    

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

int main() {
  string s,t;
  cin >> s >> t;
  
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  
  if(s<t) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N;
    string S;
    cin >> S;

    if(S.at(0)==S.at(1)&&S.at(1)==S.at(2)){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
}


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

int main(){
	string s;	cin >> s;	int mini=100000000, maxi=-1;
	for(int i=0;s.length()>i;i++){
    	if(s[i]=='A'){
        	mini=min(mini, i); 
        }
      	if(s[i]=='Z'){
        	maxi=max(maxi, i);
        }
    }
  cout << maxi-mini+1;
}

Measured memory_bytes: 640
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll=long long;

int main()
{
	int N;
	string S;
	cin>>N>>S;
	for(auto& c:S){
		c=(c-'A'+N)%26+'A';
	}
	cout<<S<<endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=5e2+50;
const ll mod=1e9+7;
using namespace std;
int dx[]={-1,1,0,0},dy[]={0,0,-1,1},n,p[nmax*nmax],f[nmax][nmax],a[nmax][nmax],x,y,nx,ny,i,j,rs,vl;
pair<int,int>pr[nmax*nmax];
queue<pair<int,int> >q;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	for(i=1;i<=n*n;i++)cin>>p[i];
	for(i=1;i<=n;i++)for(j=1;j<=n;j++)f[i][j]=min(min(i-1,j-1),min(n-i,n-j)),a[i][j]=1,pr[n*(i-1)+j]=mkp(i,j);
	for(i=1;i<=n*n;i++)
	{
		x=pr[p[i]].fr,y=pr[p[i]].sc;
		rs+=f[x][y];
		a[x][y]=0;
		q.push(mkp(x,y));
		while(!q.empty())
		{
			x=q.front().fr,y=q.front().sc;
			q.pop();
			vl=f[x][y]+a[x][y];
			for(j=0;j<4;j++)
			{
				nx=x+dx[j],ny=y+dy[j];
				if(nx<1 || nx>n || ny<1 || ny>n || f[nx][ny]<=vl)continue;
				q.push(mkp(nx,ny));
				f[nx][ny]=vl;
			}
		}
	}
	cout<<rs<<endl;
	return 0;
}


Measured memory_bytes: 8680
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,cnt[100005],c[100005];
queue<int> q;
ll sum[100005];
vector<int> v[100005];
int main(){
    scanf("%d",&n);
    for(int i=1;i<n;++i){
        int x,y;
        scanf("%d%d",&x,&y);
        v[x].pb(y),v[y].pb(x);
        ++cnt[x],++cnt[y];
        sum[x]+=y,sum[y]+=x;
    }
    for(int i=1;i<=n;++i)if(cnt[i]==1)q.push(i);
    while(!q.empty()){
        int x=q.front();
        q.pop();
        if(c[x]) continue;
        c[x]=-1;
        x=sum[x];
        if(c[x]==1){
            puts("First");
            return 0;
        }
        if(c[x]==-1) continue;
        c[x]=1;
        for(int i=0;i<v[x].size();++i){
            int y=v[x][i];
            if(c[y]) continue;
            --cnt[y];
            sum[y]-=x;
            if(!cnt[y]){
                puts("First");
                return 0;
            }
            if(cnt[y]==1)q.push(y);
        }
    }
    for(int i=1;i<=n;++i){
        if(c[i]==-1){
            for(int j=0;j<v[i].size();++j)c[v[i][j]]=0;
        }
    }
    for(int i=1;i<=n;++i){
        if(c[i]==1){
            puts("First");
            return 0;
        }
    }
    puts("Second");
    //system("pause");
    return 0;
}


Measured memory_bytes: 7424
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll n;
    ll a[100010];
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    ll result = 0;
    ll result2 = 0;

    ll sum = 0;
    ll sum2 = 0;

    for (int i = 0; i < n; i++) {
        sum += a[i];
        sum2 += a[i];
        if(i%2==0){
            if(sum>0){
                
            }else {
                result += (ll)abs(sum)+1;
                sum = 1;
            }
            if(sum2<0){
                
            }else {
                result2 += (ll)abs(sum2)+1;
                sum2 = -1;
            }
        }else{
            if(sum<0){
                
            }else {
                result += (ll)abs(sum)+1;
                sum = -1;
            }
            if(sum2>0){
                
            }else {
                result2 += (ll)abs(sum2)+1;
                sum2 = 1;
            }
        }
    }
    std::cout << min(result,result2) << std::endl;
    
}


Measured memory_bytes: 1024
# python3.4.2用
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def lprint(l): print(*l, sep='\n')
def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

H,W = imn()

s = [input() for _ in range(H)]
d = [[INF for _ in range(W)] for _ in range(H)]
d[0][0] = 0
if s[0][0] == '#': d[0][0] = 1

xd = [1, 0]
yd = [0, 1]
que = deque([(0, 0)])
cnt = 0
while len(que) > 0:
    cnt += 1
    point = que.popleft()
    x = point[0]
    y = point[1]
    if x == W-1 and y == H-1: continue
    for i in range(2):
        nx = x + xd[i]
        ny = y + yd[i]
        if nx >= W or ny >= H: continue
        if s[ny][nx] == '#' and s[y][x] == '.': 
            if d[ny][nx] > d[y][x]+1:
                d[ny][nx] = d[y][x]+1
                que.append((nx,ny))
        else:
            if d[ny][nx] > d[y][x]:
                d[ny][nx] = d[y][x]
                que.append((nx,ny))
print(d[H-1][W-1])






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

int main(){
    long long n,W;
    cin>>n>>W;
    long long w[n],v[n];
    long long w0;
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
        if(!i) w0=w[0];
        w[i]-=w0;
    }
    long long dp[101][310]={};
    long long ans=0;
    for(int i=0;i<n;i++){
        for(int j=100;j>0;j--){
            for(int k=300;k>=0;k--){
                if(k-w[i]>=0) dp[j][k]=max(dp[j][k],dp[j-1][k-w[i]]+v[i]);
                if(j*w0 + k<=W) ans=max(ans,dp[j][k]);
            }
        }        
    }

    cout<<ans<<endl;
    
}

Measured memory_bytes: 512
from fractions import gcd

n = int(input())
a = list(map(int, input().split()))
left = [0] * (n + 1)
right = [0] * (n + 1)
middle = [0] * (n + 1)

for i in range(0, n - 1):
    left[i + 1] = gcd(left[i], a[i])

for i in range(n - 1, 0, -1):
    right[i] = gcd(right[i + 1], a[i])

for i in range(n):
    middle[i] = gcd(left[i], right[i + 1])

print(max(middle))


Measured memory_bytes: 89580
let () = Scanf.scanf "%d %d %d\n" @@ fun n m l ->
  let dp = Array.make_matrix n n 1145141919810 in
  for i = 1 to m do
    Scanf.scanf "%d %d %d\n" @@ fun a b c ->
      dp.(a - 1).(b - 1) <- c;
      dp.(b - 1).(a - 1) <- c;
  done;
  for i = 0 to n - 1 do
    dp.(i).(i) <- 0;
  done;
  for k = 0 to n - 1 do
    for i = 0 to n - 1 do
      for j = 0 to n - 1 do
        dp.(i).(j) <- min dp.(i).(j) (dp.(i).(k) + dp.(k).(j))
      done
    done
  done;
  for i = 0 to n - 1 do
    for j = 0 to n - 1 do
      dp.(i).(j) <-
        if i = j then 0
        else if dp.(i).(j) <= l then 1
        else 1145141919810
    done
  done;
  for k = 0 to n - 1 do
    for i = 0 to n - 1 do
      for j = 0 to n - 1 do
        dp.(i).(j) <- min dp.(i).(j) (dp.(i).(k) + dp.(k).(j))
      done
    done
  done;
  Scanf.scanf "%d\n" @@ fun q ->
    for i = 1 to q do
      Printf.printf "%d\n" @@
      Scanf.scanf "%d %d\n" @@ fun s t ->
        if dp.(s - 1).(t - 1) = 1145141919810 then -1
        else dp.(s - 1).(t - 1) - 1
    done



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

//#define DEBUG

using namespace std;

constexpr uint32_t mxN = 2e5;
uint64_t A[mxN];

void solve(){
    uint32_t N ;
    cin >> N;
    for(uint32_t i = 0 ; i < N ; i++){
        cin >> A[i];
    }
    std::sort(A, A + N, std::greater<uint64_t>());
    //cout << "A " << endl;
    // for(uint32_t i = 0 ; i < N ; i++){
    //     cout << A[i] << " ";
    // }
    //cout << endl;

    uint64_t sum = A[0];  
    std::queue<uint32_t> q;
    q.push(1); 
    for( uint64_t i = 2 ; i  < N; i++){
        sum += A[q.front()];
        //cout << "Got " << A[q.front()] << endl;
        q.push(i);
        if( i % 2 ){
            q.pop();
        }
    }
    cout << sum << endl;
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2; 
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}


Measured memory_bytes: 5408
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int T = sc.nextInt();
   int A = sc.nextInt();
   int[] Hi = new int[N];
   for(int i =0;i<N;i++) Hi[i] = sc.nextInt();
   
   int ans =1;
   double min = Math.abs((double)(T-A)-Hi[0]*0.006);
   double di ;
   for(int i =1;i<N;i++) 
   {
     di = T-(double)Hi[i]*0.006-A;
     if(min > Math.abs(di)) 
     {
       ans = i+1;
       min = Math.abs(di);
     }
   }
   System.out.println(ans);
 }
}

Measured memory_bytes: 21972
#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
	int pm, pe, pj;
	int n;

	while (scanf("%d", &n), n != 0){
		for (int i = 0; i < n; i++){
			scanf("%d%d%d", &pm, &pe, &pj);
			if (pm == 100 || pe == 100 || pj == 100){
				cout << "A" << endl;
			}
			else if ((pm + pe) / 2 >= 90){
				cout << "A" << endl;
			}
			else if ((pm + pe + pj) / 3 >= 80){
				cout << "A" << endl;
			}
			else if ((pm + pe + pj) / 3 >= 70){
				cout << "B" << endl;
			}
			else if ((pm + pe + pj) / 3 >= 50 && (pm >= 80 || pe >= 80)){
				cout << "B" << endl;
			}
			else {
				cout << "C" << endl;
			}
		}
	}

	return (0);
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    const int n = 1e5;
    int p[n + 1];
    rep(i, n + 1) p[i] = 1;
    p[0] = 0, p[1] = 0;
    for (int i = 2; i <= (int)sqrt(n); i++)
    {
        if (p[i] == 1)
        {
            for (int j = 2; i * j <= n; j++)
            {
                p[i * j] = 0;
            }
        }
    }

    int t[n + 1] = {};

    for (int i = 2; i <= n; i++)
    {
        if (i % 2 == 0)
            continue;
        if (p[i] == 1 && p[(i + 1) / 2] == 1)
            t[i] = 1;
    }
    int s[n + 1] = {};
    rep(i, n) s[i + 1] += s[i] + t[i];

    int q;
    cin >> q;

    rep(i, q)
    {
        int l, r;
        cin >> l >> r;
        OP(s[r + 1] - s[l]);
    }

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
    ll A;
    ld B;
    cin >> A >> B;
    ll ans = floor(A*B);
    printf("%lld\n", ans);
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

const double TAU = atan2(0, -1) * 2.0;
const double PI  = atan2(0, -1);

int main() {
	IN(int, a, b, h, m);
	
	auto sq = [](auto v) { return v * v; };
	
	double x1 = a * cos(TAU * (60 * h + m) / (60 * 12));
	double y1 = a * sin(TAU * (60 * h + m) / (60 * 12));
	double x2 = b * cos(TAU * m / 60);
	double y2 = b * sin(TAU * m / 60);
	double ans = sqrt(sq(x1 - x2) + sq(y1 - y2));
	printf("%.12f\n", ans);
}


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

using namespace std;


#define PI 3.14159265
#define int long long


main(){

	string s; cin >> s;

	int n = s.size();

	int cnt = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == '1') cnt++;
	}



	cout << min(cnt, n - cnt) * 2 << endl;
	
	return 0;
}

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

int main() {
	int n;
	while (scanf("%d", &n), n) {
		deque<int>E[5];
		rep(i, n) {
			int d, p, q; scanf("%d%d%d", &d, &p, &q); q--;
			if (d == 1) {
				int Max = 0;
				rep(i, p)Max = max(Max, (int)E[q + i].size());
				rep(i, p) {
					int k = E[q + i].size();
					rep(j, Max - k)E[q + i].push_back(0);
					E[q + i].push_back(1);
				}
			}
			else {
				rep(i, p)E[q].push_back(1);
			}
			int Min = INT_MAX;
			rep(i, 5)Min = min(Min, (int)E[i].size());
			rep(i, Min) {
				bool ok = true;
				rep(j, 5)ok &= E[j][i];
				if (ok) {
					rep(j, 5)E[j][i] = -1;
				}
			}
			rep(i, 5)E[i].erase(remove(E[i].begin(), E[i].end(), -1), E[i].end());
			rep(i, 5) {
				while (!E[i].empty() && !E[i].back())E[i].pop_back();
			}
		}
		int sum = 0;
		rep(i, 5)rep(j, E[i].size()) {
			if (E[i][j])sum++;
		}
		printf("%d\n", sum);
	}
}

Measured memory_bytes: 3312
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
   ll n;
   cin>>n;
   pll p[n];
   ll i,j;
   for(i=0;i<n;i++)
   {
       cin>>p[i].first;
       p[i].second=i+1;
   }
   sort(p,p+n);
   for(i=0;i<n;i++)
   {
       cout<<p[i].second<<" ";
   }
   cout<<"\n";

}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

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

int main(){
  int r;
  cin >> r;
  if(r < 1200){
    cout << "ABC" << endl;
  }else if(r < 2800){
    cout << "ARC" << endl;
  }else{
    cout << "AGC" << endl;
  }
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    ll N, T; cin >> N >> T;
    vector<ll> t(N);
    for(int i = 0; i < N;i++) cin >> t[i];
    ll sum = 0, time = 0;
    for(int i = 1; i < N; i++) sum += min(T, t[i] - t[i - 1]);
    sum += T;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4788
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

// template from zscoder

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    int n,ans(0);
    cin >> n;
    vi a(2*n);
    for(int i = 0 ; i < (2*n); i++)
    {
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    for(int i = 0; i < (2*n); i+=2)
    {
        ans += min(a[i],a[i+1]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import bisect
import sys

def main():
  input = sys.stdin.readline
  n, d, a = map(int, input().split())
  fox = [None]*n
  for i in range(n):
    x, h = map(int, input().split())
    fox[i] = (x, h)

  fox.sort()
  x = [int(fox[i][0]) for i in range(n)]
  h = [int(fox[i][1]) for i in range(n)]

  ans = 0
  bit = [0]*n
  for i in range(n):
    if i != 0:
      bit[i] += bit[i-1]
    sub = max([(h[i]-bit[i]-1)//a+1, 0])
    ans += sub
    bit[i] += sub*a
    index = bisect.bisect_right(x, x[i]+2*d)
    if index != n:
      bit[index] -= sub*a
  print(ans)

if __name__ == "__main__":
  main()

Measured memory_bytes: 66856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;


//void warshall_floyd(int n){
//    for(int k=0;k<n;k++){
//        for(int i=0;i<n;i++){
//            for(int j=0;j<n;j++){
//                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
//            }
//        }
//    }
//}
//ll calc_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        ++res;
//        N /= 10;
//    }
//    return res;
//}
//ll sum_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        res += N % 10;
//        N /= 10;
//    }
//    return res;
//}


int main(){
    int n; cin >> n;
    vector<int> a,b,c;
    for(int i = 0;i < n;i++){
        int x; cin >> x;
        a.push_back(x);
    }
    for(int i = 0;i < n;i++){
        int x; cin >> x;
        b.push_back(x);
    }
    for(int i = 0;i < n;i++){
        int x; cin >> x;
        c.push_back(x);
    }
    sort(a.begin(),a.end());
    sort(c.begin(),c.end());
    ll ans = 0;
    for(int i = 0;i < n;i++){
        auto d = lower_bound(a.begin(),a.end(),b[i]);
        auto e = upper_bound(c.begin(),c.end(),b[i]);
        ans += (d-a.begin())*(n-(e-c.begin()));
    }
    cout << ans;
}



Measured memory_bytes: 4728
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if (A == C) {
		cout << 0 << endl;
	}
	else {
		cout << 1 << endl;
	}
}



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

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


ll n;
cin>>n;

string s;
cin>>s;


int a=0;

int b=n-1;
ll ans=0;
while(a<b){

    if(s[b]=='R'){

        while(s[a]!='W'&&a<b){
            a++;
        }
        if(a==b){
            break;
        }
        else{
            ans++;
            swap(s[a],s[b]);
            b--;
        }
    }
    else{
        b--;
    }

}
//cout<<s<<endl;
cout<<ans;

}










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

int main()
{
	int64_t x, k, d;
	cin >> x >> k >> d;

	{
		int64_t tmp = min(k, abs(x) / d);

		if (0 <= x)
		{
			x -= d * tmp;
		}
		else
		{
			x += d * tmp;
		}

		k -= tmp;
	}

	if (k % 2 == 1)
	{
		if (0 <= x)
		{
			x -= d;
		}
		else
		{
			x += d;
		}
	}

	cout << abs(x) << endl;

	return 0;
}

Measured memory_bytes: 3640
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
typedef long long ll;
const int mo = 1e9 + 7;
int f[1<<17], g[1<<17], p[50], n, x, y, z, m, ans;
inline void add(int &x, int y) {
	x += y; if (x >= mo) x -= mo;
}
int main() {
	scanf("%d%d%d%d", &n, &x, &y, &z); m = x + y + z;
	f[0] = p[0] = 1; for (int i = 1; i < 50; ++i) p[i] = p[i-1] * 10ll % mo;
	for (int i = 0; i < n; ++i, swap(f, g)) {
		memset(g, 0, sizeof(g));
		for (int s = 0; s < 1 << m; ++s) {
			if (f[s]) {
				for (int d = 1; d <= 10; ++d) {
					int ns = s >> d;
					if (d <= m) ns |= 1 << (m - d);
					if ((ns >> (x + y) & 1) && (ns >> x & 1) && (ns & 1))
						add(ans, 1ll * f[s] * p[n-1-i] % mo);
					else add(g[ns], f[s]);
				}
			}
		}
	} printf("%d\n", ans);
	return 0;
}

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

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

int main(){
  ll a, b;
  cin >> a >> b;
  ll c = gcd(a,b);
  ll x = c;
  ll ans = 1;
  for(ll i = 2; i*i <= c; i++){
    if(x % i == 0) ans++;
    while(x % i == 0) x /= i; 
  }
  if(x != 1) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

int a[10]={0,1,2,3,4,5,6,7,8,9};

int main(void){
    ll n;
    cin>>n;
    vector<ll>x(n),y(n);
    for(ll i=0;i<n;i++)cin>>x[i]>>y[i];
    for(ll i=0;i<n;i++)a[i]=i;
    double ans = 0.0;
    do
    {
        ll s=x[a[0]],t=y[a[0]];
        for(int i=1;i<n;i++){
            ll x1=x[a[i]]-s;
            ll y1=y[a[i]]-t;
            ll d=x1*x1+y1*y1;
            ans+=(double)sqrt(d);
            s=x[a[i]];
            t=y[a[i]];
        }
    } while (next_permutation(a,a+n));
    ll t=1;
    for(ll k=1;k<=n;k++)t*=k;
    printf("%.10lf",(double)ans/t);
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>

int main() {
	long long n, a, b;

	std::cin >> n >> a >> b;

	if ((a + b) % 2 == 0) {
		if (a < b) std::swap(a, b);
		std::cout << (a - b) / 2 << std::endl;
	}
	else {
		std::cout << std::min(a, n - b + 1) + std::abs(b - a) / 2 << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
s = ['.'*(w+2)]+['.'+input()+'.' for _ in range(h)]+['.'*(w+2)]
for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j]=='#':
            if s[i-1][j]=='#' or s[i+1][j]=='#' or s[i][j-1]=='#' or s[i][j+1]=='#':
                continue
            else:
                print('No')
                exit()
print('Yes')

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

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		String string;
		char ch[];
		
		int n, res;
		while(!(string = reader.readLine()).equals("0")){
			n = Integer.valueOf(string);
			
			int map[][] = new int[n][n];
			int sum[][] = new int[n + 1][n + 1];
			ch = reader.readLine().toCharArray();
			for(int i = 0; i < n; i++){
				map[0][i] = (ch[i] == '.' ? 1 : 0);
				
				if(i > 0){
					sum[1][i + 1] = sum[1][i] + map[0][i];
				}else{
					sum[1][i + 1] = map[0][i];
				}
			}
			for(int i = 1; i < n; i++){
				ch = reader.readLine().toCharArray();
				for(int j = 0; j < n; j++){
					map[i][j] = (ch[j] == '.' ? 1 : 0) + map[i - 1][j];
					
					if(j > 0){
						sum[i + 1][j + 1] = sum[i + 1][j] + map[i][j];
					}else{
						sum[i + 1][1] = map[i][0];
					}
				}
			}
			
			res = 0;
			x : for(int w = n + 1; w > 0; w--){
				for(int i = n; i > 0; i--){
					if(i - w < 0) break;
					for(int j = n; j > 0; j--){
						if(j - w < 0) break;
						
						if(sum[i][j] - sum[i - w][j] - sum[i][j - w] + sum[i - w][j - w] == w * w){
							res = w;
							break x;
						}
					}
				}
			}
			System.out.println(res);
		}
		reader.close();
	}
}

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

long long v[100000],w[100000],dp[100000];


main(){
	int k,m;
	cin>>k>>m;
	for(int i=1;i<=k;i++){
		cin>>w[i]>>v[i];
	}	
	dp[0];
	for(int i=1;i<=k;i++){
		for(int j=m;j>0;j--){
			if(j>=w[i])
				dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
		}
	}
	cout<<dp[m];
}

Measured memory_bytes: 4364
#include<bits/stdc++.h>
using namespace std;
const int N = 2200;
typedef long long  ll;
ll fuck_at[2200];
const ll inf=1LL<<60;
int u[N],v[N],w[N],n,m;
ll bell_man()
{
    for(int i=1; i<=n; i++)fuck_at[i]=-inf;
    fuck_at[1]=0;
    int f=0,i=1;
    for(int i=0; i<=n*(n-1)/2; i++)
    {
        for(int j=0; j<m; j++)
            if(fuck_at[v[j]]<fuck_at[u[j]]+w[j])
            {
                fuck_at[v[j]]=fuck_at[u[j]]+w[j];
                if(v[j]==n)
                {
                    f++;
                    if(f==n)
                        return inf;
                }
            }
    }
    return fuck_at[n];
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0; i<m; i++)
        scanf("%d%d%d",&u[i],&v[i],&w[i]);
    ll ans=bell_man();
    if(ans==inf)
        puts("inf");
    else
        printf("%lld\n",ans);
    return 0;

}


Measured memory_bytes: 384
N, K = list(map(int, input().split()))
chi = [0] * (N + 1)
A = []
for _ in range(K):
    d = int(input())
    a = list(map(int, input().split()))
    A.append(a)

for i in range(len(A)):
    for j in range(len(A[i])):
        chi[A[i][j]] = 1
print(chi.count(0)-1)


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

int main(){
    vector<string> vec;
    string ans = "";
    for(int i = 0; i < 3; i++){
        string s;
        cin >> s;
        ans += s[0];
    }
    cout << ans << endl;
    return 0;
}

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

int main(void) {
    string n;
    cin >> n;
    int num = 0;
    for (auto x : n) {
        num += x - '0';
    }
    cout << (num % 9 == 0 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3696
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#define mod 1000000007
#define ten5 100005
#define PI 3.1415926
using namespace std;



int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,range=0,fir=0,sec=0;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=0;
    //vector <int> v;
    //float f,g,h;
    char now,pre;
    //string a;
    cin>>m>>n;
    o=abs(m);k=abs(n);
    if(o==0||k==0)
    {
        if(m<n) cout<<abs(o-k);
        else if(m>n) cout<<abs(o-k)+1;
        return 0;
    }
    if(o==k)
    {
        if(m!=n) cout<<1;
        else cout<<0;
    }
    else if(o>k)
    {
        if(m<0&&n<0) cout<<o-k;
        else if(m>0&&n>0) cout<<o-k+2;
        else cout<<o-k+1;
    }
    else
    {
        if(m<0&&n<0) cout<<k-o+2;
        else if(m>0&&n>0) cout<<k-o;
        else cout<<k-o+1;
    }
    return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
using namespace std;

long int money = 100000;
int s = 100000;
int a[124],b[124];

int main(){
	int n;
	int tmp;
	cin>>n;
	//while(n!=0){
		money = 100000;
	for(int i=0;i<n;i++){
		money*=1.05;
		//if(i==n-1) cout << "\nbefore  \n" << money <<"\nafter"<<endl;
		
		money += money % 1000 != 0? 1000:0;
		money-=money%1000;
		b[i+1] = money;
		//if(i==n-1)	cout << money << endl;
	}
		cout<<b[n]<<endl;
		
		
 
    
    //scanf("%d",&n);
 
 
    for(int i=0;i<n;i++){
        if(int(s*1.05)%1000==0){
            s=int(s*1.05);
        }else{
            s= int(s*1.05) + (1000- int(s*1.05) % 1000);
        }
    	a[i+1] = s;
    }
    //printf("%d\n",s);
	
		for(int i=0;i<n;i++)
		if(a[i+1]!=b[i+1]){
		}
			//cout<<i+1<<" a = "<<a[i+1]<<" b = "<<b[i+1]<<endl;
	//cout << money << endl;
		//cin >> n;
	//}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <set>
#include <climits>

using namespace std;

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

char s[100005];
char t[100005];

int p[100005][26];

int main() {
    scanf("%s", s);
    scanf("%s", t);

    int sn = strlen(s);
    int a[26];
    memset(a, -1, sizeof(a));
    for (int i = sn - 1; i >= 0; --i) {
        for (int j = 0; j < 26; ++j) {
            p[i][j] = a[j];
        }

        a[s[i] - 'a'] = i;
    }

    for (int i = sn - 1; i >= 0; --i) {
        for (int j = 0; j < 26; ++j) {
            p[i][j] = a[j];
        }
        a[s[i] - 'a'] = i;
    }

    int tn = strlen(t);
    ll res = 0;
    int next = -1;
    for (int i = 0; i < tn; ++i) {
        int cur = next;
        if (i == 0) {
            next = a[t[i] - 'a'];
        } else {
            next = p[cur][t[i] - 'a'];
        }

        if (next == -1) {
            res = -1;
            break;
        } else {
            if (next <= cur) {
                res += sn - cur + next;
            } else {
                res += next - cur;
            }
            cur = next;
        }
    }
    printf("%lld\n", res);
    return 0;
}



Measured memory_bytes: 10624
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	s := getNextString(scanner)

	mp := MP{}
	ans := 0
	for i := 0; i < n; i++ {
		mp.init(s[i:n])
		for j := 1; j <= n-i; j++ {
			m := mp.table[j] % (j - mp.table[j])
			a := (j>>1-m)/(j-mp.table[j])*(j-mp.table[j]) + m
			if ans < a {
				ans = a
			}
		}
	}
	fmt.Println(ans)

	writer.Flush()
}

// MP ...
type MP struct {
	s     string
	table []int
}

func (mp *MP) init(s string) {
	mp.s = s
	n := len(s)
	table := make([]int, n+1)
	table[0] = -1
	j := -1
	for i := 0; i < n; i++ {
		for j >= 0 && s[i] != s[j] {
			j = table[j]
		}
		j++
		table[i+1] = j
	}
	mp.table = table
}


Measured memory_bytes: 9744
while True:
    n,x = map(int,input().split())
    if n==0 and x==0:
        break
    cnt = 0
    for i in range(1,n-1):
        for j in range(i+1,n+1):
            k = x-i-j
            if 1<=k<=n and k!=i and k>j:
                cnt += 1
    print(cnt)


Measured memory_bytes: 5596
import Data.Char

countAlphString :: String -> [String]
countAlphString str = [(c : " : ") ++ (show . length $ filter (==c) str) | c <- ['a' .. 'z']]

main :: IO ()
main = do
  x <- getContents
  mapM_ putStrLn $ countAlphString $ map toLower x

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

int main() {
    int n;
    cin >> n;
    vector<int> xx(n);
    for (int i = 0; i < n; i++) {
        cin >> xx.at(i);
    }
    vector<int> yy = xx;
    sort(yy.begin(), yy.end());
    int ys = yy.at(n / 2 - 1);
    int yb = yy.at(n / 2);
    for (int i = 0; i < n; i++) {
        if (xx.at(i) <= ys) {
            cout << yb << endl;
        } else {
            cout << ys << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3712
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const ll mod = 998244353;
long double PI = acosl(-1);
const ll infl = 1e18;
const int inf = 2e9;
const int nmax = 3e5+5;
const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;

vector<int>g[nmax];
int vis[nmax];

void dfs(int u, int p=0){
    vis[u] = true;
    for(int v : g[u]) if(!vis[v] and v!=p){
        dfs(v, u);
    }
}

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

    int n,m;
    cin>>n>>m;
    for(int i=0; i<m; i++){
        int u,v;
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int cmp = 0;
    for(int i=1; i<=n; i++){
        if(!vis[i]){
            dfs(i);
            cmp++;
        }
    }
    cout<<cmp-1<<endl;
}
/*
*/


Measured memory_bytes: 15108
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

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

  vector<int> v(n);
  for (auto &x : v) cin >> x;

  int ans = 0;
  int mx = 0;
  for (auto x : v) {
    ans += (mx <= x);
    mx = max(mx, x);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

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


    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    int total = 0;//求める総和

    for(int i = 1; i<=n; i++){
      int sum = findSumOfDigits(i); //n以下の整数の各位の和
      if(sum >= a && sum<=b){//n以下の整数の各位の和がa以上かつb以下か
        total +=i;
      }
    }
    System.out.println(total);
  }

    private static int findSumOfDigits(int n){//ある数の各位の和を求める
      int sum = 0;
      while(n>0){//0になるまで繰り返す
        sum += n%10;
        n /=10;
      }
      return sum;
    }




}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    IOS
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int l = max(a, c), r = min(b, d);
    cout << max(0, r - l) << endl;
}

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

int main(){

    int a, b;
    cin >> a >> b;
    if (a == 1){
        a += 13;
    }
    if (b == 1){
        b += 13;
    }
    if (a > b){
        cout << "Alice" << endl;
    }
    else if (a < b){
        cout << "Bob" << endl;
    }
    else if (a == b){
        cout << "Draw" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
 
int sosu1(int m){
  int i;
  for(i=2;i<=sqrt(m);i++){
    if(m%i==0){
      return 0;
    }
  }
  return 1;
}
 
int main(void){
  int n,count=0;
  int i,j;
 
  int sosu[50001];
  for(i=0;i<=50000;i++){
    sosu[i]=1;
  }
  for(i=2;i<=sqrt(50000);i++){
    if(sosu[i]==1){
      for(j=i*2;j<=50000;j+=i){
	sosu[j]=0;
      }
    }
  }
  while(1){
    scanf("%d",&n);
    if(n==0){
      break;
    }
    
    count=0;
    for(i=2;i<=n/2;i++){
      j=n-i;
      if(sosu[i]&&sosu[j]){
	//printf("%d+%d=%d\n",i,j,n);
	count++;
      }
    }
    printf("%d\n",count);
  }
return 0;
}

Measured memory_bytes: 1944
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////


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

    int N;

    cin >> N;

    vector<int> boss(N);
    for (int i = 2; i <= N; i++) {
        int val;
        cin >> val;
        val--;
        boss[val]++;
    }

    for (int i = 0; i < N; i++)
        cout << boss[i] << "\n";

    return 0;
}


Measured memory_bytes: 3968
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  string S; cin >> S;
  int Q; cin >> Q;
  deque<char> dq;
  rep(i,sz(S)){
    dq.push_back(S[i]);
  }
  int cnt = 0;
  rep(q,Q){
    int T; cin >> T;
    if(T==1){
      cnt++;
    }
    else if(T==2){
      int F; char C;
      cin >> F >> C;
      if((F+cnt)%2==1){
        dq.push_front(C);
      }
      else if((F+cnt)%2==0){
        dq.push_back(C);
      }
    }
  }
  string ans;
  while(!dq.empty()){
    ans += dq.front(); dq.pop_front();
  }
  if(cnt%2) reverse(all(ans));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1412
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout<<endl
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }

ll mod_pow(ll a, ll p)
{
	if (p == 0)return 1;
	else if (p == 1)return a;
	else if (p % 2 == 0)return (mod_pow(a, p / 2) * mod_pow(a, p / 2)) % mod;
	else return (mod_pow(a, p - 1) * a) % mod;
}

ll comb(ll n, ll m)
{
	if (n < m)return 0;
	if (n / 2 < m)return comb(n, n - m);
	ll resMul = 1;
	ll resDiv = 1;
	for (ll i = 1; i <= m; i++)
	{
		resMul *= (n - i + 1);
		resMul %= mod;
		resDiv *= i;
		resDiv %= mod;
	}
	ll res = (resMul * mod_pow(resDiv, mod - 2)) % mod;
	return res;
}

int main()
{
	ll n, k; cin >> n >> k;
	reps(i, k)
	{
		ll ans = (comb(k - 1, i - 1) * comb(n - k + 1, i)) % mod;
		co(ans);
	}
	return 0;
}

Measured memory_bytes: 256
while true do
    h,w = gets.split.map(&:to_i)
    break if h ==0 && w ==0
    h.times do |i|
        str = ''
        if i%2 == 0 then
            w.times do |j|
                if j%2 == 0 then
                    str+='#'
                else
                    str+='.'
                end
            end
        else
            w.times do |j|
                if j%2 == 0 then
                    str+='.'
                else
                    str+='#'
                end
            end
        end
        puts str
    end
    puts
end


Measured memory_bytes: 7260