akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new ABC120().SolveB(new ConsoleInput(Console.In, ' '));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
  class ABC120
    {
        public void SolveB(ConsoleInput cin)
        {
            var a = cin.ReadInt;
            var b = cin.ReadInt;
            var k = cin.ReadInt;
            var divList = new List<int>();
            for (int i = 1; i <= 100; i++)
            {
                if (a % i == 0 && b % i == 0) { divList.Add(i); }
            }
            WriteLine(divList.OrderByDescending(x => x).ToArray()[k-1]);
            ReadLine();
        }
    }
}

Measured memory_bytes: 13524
#include<iostream>
#include<vector>
#include<map>
#include<stack>
#define FOR(i,a,b) for(int i=(a); i<int(b); ++i)
#define RFOR(i,a,b) for(int i=(b)-1; i>=int(a); --i)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,int(n)+1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
#define al(d) d.begin(),d.end()
using namespace std;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(int n){
	vector<T> vec;
	rep(i,n){
		T input;
		cin >> input;
		vec.emplace_back(input);
	}
	return vec;
}
using AdjList = vector<vector<int>>;
using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

// Recieve edge(=(int,int)) as an adj list.
vector<vector<int>> getadj(int N, int M){
	// Initialize all lists of the graph as a empty vector.
	vector<int> init;
	vector<vector<int>> graph(N,init);

	rep(i,M){
		int a, b;
		cin >> a >> b;
		graph[a-1].emplace_back(b-1);
		graph[b-1].emplace_back(a-1);
	}
// rep(i,N)
// 	putv(graph[i]);
	return graph;
}

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
	int n = 3;
	vector<string> vec;
	rep(i,n){
		string str;
		cin >> str;
		vec.emplace_back(str);
	}
	rep(i,n)
		cout << vec[i][0];
	cout << endl;
}

Measured memory_bytes: 256
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
typedef long long ll;
const int Imx=2147483647;
const int mod=1000000007;
const ll Lbig=2e18;
//My own input/output stream
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putsp()
#define putii(x,y) puti(x),putnum(y),putsp()
#define putiii(x,y,z) putii(x,y),putnum(z),putsp()
#define putsi(x) putnum(x),putendl()
#define putsii(x,y) puti(x),putnum(y),putendl()
#define putsiii(x,y,z) putii(x,y),putnum(z),putendl()
inline ll getnum()
{
	register ll r=0;register bool ng=0;register char c;c=getchar();
	while(c!='-'&&(c<'0'||c>'9'))c=getchar();
	if(c=='-')ng=1,c=getchar();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=getchar();
	if(ng)r=-r;return r;
}
template <class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline void putsp(){putchar(' ');}
inline void putendl(){putchar('\n');}
inline char mygetchar(){register char c=getchar();while(c==' '||c=='\n')c=getchar();return c;}
int n,m,a[100111];
ll cnt[100111],cnt0[100111],ans;
void add(int l,int r,int beg)
{
	cnt[l]++;cnt[r+1]--;
	cnt0[l]+=beg-1;
	cnt0[r+1]-=beg-1;
	cnt0[r+1]-=r-l+1;
}
int main()
{
	getii(n,m);
	for(int i=1;i<=n;i++)geti(a[i]);
	for(int i=1;i<n;i++)
	{
		ans+=(a[i+1]-a[i]+m)%m;
		if(a[i]==a[i+1]||(a[i]+1)%m==a[i+1]%m)continue;
		int l=a[i],r=a[i+1];
		if(l<r)
		{
			add(l+1,r,0);
		}
		else
		{
			if(l<m)add(l+1,m,0);
			add(1,r,m-l);
		}
	}
	for(int i=1;i<=m;i++)cnt[i]+=cnt[i-1];
	for(int i=1;i<=m;i++)cnt[i]+=cnt0[i];
	for(int i=1;i<=m;i++)cnt[i]+=cnt[i-1];
	ll mx=0;
	for(int i=1;i<=m;i++)mx=max(mx,cnt[i]);
	cout<<ans-mx<<endl;
	return 0;
}

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

struct Edge {
  int to, w;
  Edge(int t, int w) :to(t), w(w) {}
};

struct Tree {
  int N;
  vector<vector<Edge>> edges;
  vector<int> size;

  Tree() : Tree(0) {};
  Tree(int N) : N(N), edges(N), size(N) {}

  void addDEdge(int a, int b) { addDEdge(a, b, 1); }
  void addDEdge(int a, int b, int w) { edges[a].emplace_back(b, w); }
  void addEdge(int a, int b) { addEdge(a, b, 1); }
  void addEdge(int a, int b, int w) { 
    edges[a].emplace_back(b, w);
    edges[b].emplace_back(a, w);
  }

  int setsize(int p, int now){
    int s = 1;
    for(Edge e : edges[now]) {
      if (e.to == p) continue;
      s += setsize(now, e.to);
    }
    size[now] = s;
    return s;
  }
};

vector<int> nowp, c;
Tree G;
vector<map<int, int>> mps;
void dfs(int p, int now, int fc) {
  int tmp;
  if (fc != -1) {
    tmp = nowp[fc];
    nowp[fc] = now;
    mps[fc][now] = G.size[now];
  }
  int color = c[now];
  mps[color][nowp[color]] -= G.size[now];

  for (Edge e : G.edges[now]) {
    if (e.to == p) continue;
    dfs(now, e.to, color);
  }
  if (fc != -1) nowp[fc] = tmp;
  }

int main(){
  int N; cin >> N;
  c = vector<int>(N);
  rep(i, N) {
    cin >> c[i];
    c[i]--;
  }

  G = Tree(N);
  rep(i, N - 1) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    G.addEdge(x, y);
  }
  G.setsize(-1, 0);

  nowp = vector<int>(N, 0);
  mps = vector<map<int, int>>(N);
  rep(i, N) mps[i][0] = N;

  dfs(-1, 0, -1);

 
  rep(i, N) {
    long long ans = 0;
    for (auto x : mps[i]) {
      long long num = x.second;
      ans += num * (num - 1) / 2 + num;
    }
    cout << (long long)N * (N - 1) / 2 + N - ans << endl;
  }
}


Measured memory_bytes: 66624
def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)

N = int(input())
if digitSum(N)%9==0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 11052
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var B = int.Parse(ReadLine());

        var ans = B < 1200 ? "ABC" : B < 2800 ? "ARC" : "AGC";

        WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 27504
[N,A,B]=[int(x) for x in raw_input().split()]
L=raw_input()
Kok=0
Out=0
for c in L:
    if c=='a':
        if Kok+Out<A+B:
            print 'Yes'
            Kok+=1
        else:
            print 'No'
    elif c=='b':
        if Kok+Out<A+B and Out<B:
            print 'Yes'
            Out+=1
        else:
            print 'No'
    else:
        print 'No'

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

int main(){
	string s;
	cin>>s;
	int tam=s.size();
	int r=0;
	
	for(int i=0;i<tam/2;i++){
		if(s[i]!=s[tam-i-1]){
			r++;
		
		}
		//cout<<s[i]<<" "<<s[tam-i-1]<<endl;
	}	
	cout<<r;
	return 0;
}


Measured memory_bytes: 3612
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#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;
 
/*
template <typename T>  using ordered_set =
    tree<T, null_type, less<T>,   /// greater<T> for sorting decreasingly
    rb_tree_tag, tree_order_statistics_node_update>;
*/

#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         mod                         1000000007
#define         INF                         2e18
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;


int main(){
    ll n,x,s=0;
    sfl(n);
    for(ll i=1;i<=n;i++){
        sfl(x);
        s += x-1;
    }
    pfl(s);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define lli long long int
using namespace std;
#define S second
#define F first
#define pb push_back 
#define M1 1000000007
#define M2 998244353
#define plli pair<lli,lli>
#define setit set<lli>::iterator seti
#define mapit map<lli,lli> ::iterator mapi
#define MP make_pair
#define MT make_tuple
// map      iterator->first 
// map      mp[key]=value
// set      *s.begin()
// vector   v[j]=value
// pair     p.first p.second
// vector of pairs v[j].first v[j].second
// tuple    get<index>(tuple_name)
// vector of tuples get<index>(v[j])  sort(v.begin(),v.end())
//priority queue .top() .pop() .push()
// __gcd(x,y)
#define fr(j,a,b) for(j=a;j<b;j++)

int power(int x, unsigned int y, int p)  
{    int res = 1;    
     x = x % p;
     if (x == 0) return 0;
     while (y > 0)  
     {  if (y & 1)  
        res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
     }  
    return res;  
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	lli t,i,j,n,x;
	cin>>t>>n;
if(n>=t){
    cout<<"unsafe";
}
else{
    cout<<"safe";
}
	
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    double A, B;
    cin >> A >> B;
    for (double i = 1; i <= 10000; i++) {
        int eight = floor(i * 0.08);
        int ten = floor(i * 0.1);
        if ((eight == A) && (ten == B)) {
            cout << i << '\n';
            return 0;
        }
    }
    cout << -1 << '\n';
}


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

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

    vector<long long> memo;
    for (int i=0; i<N; i++) {
        long long h;
        cin >> h;
        memo.push_back(h);
    }
    sort(memo.begin(), memo.end());

    long long d = min(N, K);
    long long sum = 0;
    for (auto m=memo.begin(); m != (memo.end() - d); m++) {
        sum += *m;
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
using lint = long long;

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

  lint a;
  cin >> a;

  vector<lint> cnt;
  for (lint i = 2; i * i <= a; i++) {
    if (a % i == 0) {
      cnt.emplace_back(0);
      while (a % i == 0) {
        a /= i;
        cnt.back()++;
      }
    }
  }
  if (a > 1) {
    cnt.emplace_back(1);
  }

  lint ans = 0;
  for (auto i : cnt) {
    lint cur = 1;
    while (cur <= i) {
      i -= cur;
      cur++;
      ans++;
    }
  }

  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3652
/*================================================================
*   Copyright (C) 2019 Sangfor Ltd. All rights reserved.
*
*   创 建 者： badcw
*   创建日期： 2019/12/22
*
================================================================*/
#include <bits/stdc++.h>

#define ll long long
using namespace std;

const int maxn = 100;
const int mod = 1e9+7;
ll qp(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

template <class T>
inline bool scan(T& ret) {
    char c;
    int sgn;
    if (c = getchar(), c == EOF) return 0; // EOF
    while (c != '-' && (c < '0' || c > '9')) c = getchar();
    sgn = (c == '-') ? -1 : 1;
    ret = (c == '-') ? 0 : (c - '0');
    while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
    ret *= sgn;
    return 1;
}

//template <class T>
//inline void out(T x) {
//    if (x > 9) out(x / 10);
//    putchar(x % 10 + '0');
//}

int a[3];
int main(int argc, char* argv[]) {
    int res = 0;
    for (int i = 0; i < 3; ++i) {
        int x;
        scanf("%d", &x);
        res += x;
    }
    puts(res >= 22 ? "bust" : "win");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	ios::sync_with_stdio(false);
	int a,b,c;
	cin>>a>>b>>c;
	int len=a-2*c+c;
	int ans=len/(b+c);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
// Author :
// Date :
// Problem:
// Solution:
// Comment:

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstring>

#define pp push
#define pb push_back
#define mp make_pair
#define xx first
#define yy second

using namespace std;

void play(int n , int l){
    int pos[105][2]={0};
    int time=0;
    int left = n;
    string dir;
    int loc;
    int ans;
    
    for(int i = 1 ; i <= n ; i++){
        cin >> dir >> loc;
        if(dir == "R") pos[loc][0] = i;
        else pos[loc][1] = i;
    }
    
    //cout << left << endl << endl;;
    string str;
    while(left > 0){
        int moved[100] = {0};
        for(int i = 1 ; i<=l ; i++){
            if(pos[i][1] != 0 && moved[pos[i][1]] == 0){ // Left
                //cout << "L " << pos[i][1]<< endl;
                
                moved[pos[i][1]] = 1;
                pos[i-1][1] = pos[i][1];
                pos[i][1] = 0;
            }
            /*
            if(pos[i][0] != 0 && pos[i+2][1] != 0 && moved[pos[i][0]] == 0 && moved[pos[i+2][1]] == 0){ // Collide
                cout << "Col " << pos[i][0] << " " << pos[i+2][1] << endl;
                moved[pos[i][0]] = 1;
                moved[pos[i+2][1]] = 1;
                pos[i+1][1] = pos[i][0];
                pos[i][0] = 0;
                pos[i+1][0] = pos[i+2][1];
                pos[i+2][1] = 0;
            }
            /*
            if(pos[i][0] != 0 && pos[i+1][1] != 0 && moved[pos[i][0]] == 0 && moved[pos[i+1][1]] == 0){ // Pass
                cout << "Pass " << pos[i][0] << " " << pos[i+1][1] << endl;
                moved[pos[i][0]] = 1;
                moved[pos[i+1][1]] = 1;
                pos[i+1][0] = pos[i][0];
                pos[i][1] = pos[i+1][1];
                
                pos[i+1][1] = 0;
                pos[i][0] = 0;
            }
            */
            
        }
        for(int i = l; i >= 1 ; i--){
            if(pos[i][0] != 0 && moved[pos[i][0]] == 0){ // Right
                //cout << "R " << pos[i][0] << endl;
                moved[pos[i][0]] = 1;
                pos[i+1][0] = pos[i][0];
                pos[i][0] = 0;
            }
        }
        
        for(int i = 1 ; i<=l ; i++){
            if(pos[i][0] && pos[i][1]){
                swap(pos[i][0],pos[i][1]);
            }
        }
        if(pos[l][0]){
                if(left == 1) ans = pos[l][0];
                //cout << "LeaveR " << pos[l][0] << endl;
                pos[l][0] = 0;
                left--;
        }
        if(pos[0][1]){
                if(left == 1) ans = pos[0][1];
                //cout << "LeaveL " << pos[0][1] << endl; 
                pos[0][1] = 0;
                left--;
        }
        time++;
        //cout << endl << endl;
        //cout << left << endl;
        //cin >> str;
    }
    
    cout << time << " " << ans << endl;
}
main(){
    int n,l;
    
    while(true){
        cin >> n >> l;
        if( n == 0) break;
        
        play(n,l);
    }
    
    #ifdef GEREL
        for(;;);
    #endif

    return 0;
}

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

int main(){
    int N;  cin >> N;
    int k = -1;
    for(int i=1; i<=1e4; i++){
        if(i*(i-1) == 2*N){
            k = i;
            break;
        }
    }
    if(k==-1){
        cout << "No" << endl;
        return 0;
    }

    vector<vector<int>> S(k);
    int cnt = 1;
    for(int i=0; i<k; i++) for(int j=i+1; j<k; j++){
        S[i].push_back(cnt);
        S[j].push_back(cnt);
        cnt++;
    }

    cout << "Yes" << endl;
    cout << k << endl;
    for(vector<int> s : S){
        cout << k-1 << " ";
        for(int v : s){
            cout << v << " ";
        }cout << endl;
    }
}

Measured memory_bytes: 2304
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
int A[100000],n;

int main(){
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>A[i];
    int q,k,sum=0;                                         
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>k;
        if(*lower_bound(A,A+n,k)==k)sum++;
    }   
    cout<<sum<<"\n";
    return 0;
}



Measured memory_bytes: 3364
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    int a,b;cin>>a>>b;
    if (a<=0 && b>=0)cout<<"Zero"<<endl;
    else if(a>0)cout<<"Positive"<<endl;
    else if((b-a+1)%2==0)cout<<"Positive"<<endl;
    else cout<<"Negative"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,i,x,num=0;
    cin>>n;
    for(i=sqrt(n);i>=1;i--){
    	if(n%i==0){
    		x=n/i;
    		break;	
		}
	}
	while(x){
		num++;
		x=x/10;
	}
	cout<<num;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
)

const Inf = 1 << 60

func main() {
	H, W := ReadInt(), ReadInt()
	Ch, Cw := ReadInt()-1, ReadInt()-1
	Dh, Dw := ReadInt()-1, ReadInt()-1

	grid := make([]string, H)
	for y := 0; y < H; y++ {
		grid[y] = ReadString()
	}

	c := make([][]int, H)
	for y := 0; y < H; y++ {
		c[y] = make([]int, W)
		for x := 0; x < W; x++ {
			c[y][x] = Inf
		}
	}

	h := Heap{}
	h.push(State{X: Cw, Y: Ch, Cost: 0})

	for len(h) > 0 {
		now := h.pop()
		if grid[now.Y][now.X] == '#' {
			continue
		}
		if c[now.Y][now.X] <= now.Cost {
			continue
		}
		c[now.Y][now.X] = now.Cost
		for dx := -2; dx <= 2; dx++ {
			for dy := -2; dy <= 2; dy++ {
				if dx == 0 && dy == 0 {
					continue
				}
				nx := now.X + dx
				ny := now.Y + dy

				if 0 <= nx && nx < W && 0 <= ny && ny < H {
					if grid[ny][nx] == '#' {
						continue
					}
					nc := now.Cost + 1
					if dx*dy == 0 && Abs(dx+dy) == 1 {
						nc = now.Cost
					}
					if c[ny][nx] <= nc {
						continue
					}
					h.push(State{
						X:    nx,
						Y:    ny,
						Cost: nc,
					})
				}
			}
		}
	}

	ans := c[Dh][Dw]
	if ans == Inf {
		fmt.Println(-1)
	} else {
		fmt.Println(ans)
	}
}

func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

// h := Heap{}
// h.push(State{Cost: 0, X: 0, Y: 0})
// state := h.pop()

type State struct {
	X, Y, Cost int
}

type HeapElement = State
type Heap []HeapElement

func (h Heap) Less(i, j int) bool    { return h[i].Cost < h[j].Cost }
func (h Heap) Len() int              { return len(h) }
func (h Heap) Swap(i, j int)         { h[i], h[j] = h[j], h[i] }
func (h *Heap) Push(x interface{})   { *h = append(*h, x.(HeapElement)) }
func (h *Heap) Pop() (x interface{}) { *h, x = (*h)[:len(*h)-1], (*h)[len(*h)-1]; return }
func (h *Heap) push(v HeapElement)   { heap.Push(h, v) }
func (h *Heap) pop() HeapElement     { return heap.Pop(h).(HeapElement) }

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

#define w(t) int t; cin>>t; while(t--)
#define ll long long int
#define rep(n) for (long long int i=0; i<n; i++)

int main ()
{
    int n,x,t,cnt;
    cin >> n >>x >>t;
    (n%x==0 ? cnt=n/x : cnt=(n/x)+1);
    cout << cnt*t << "\n"; 
    return 0;
}


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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

ll A[200000];
ll S[200000];

int main()
{
	int N;
	ll ans = 0;
	map<ll, ll> mp;

	cin >> N;
	rep(i, N) cin >> A[i];

	rep(i, N) {
		if (i == 0) S[i] = A[i];
		else S[i] = S[i - 1] + A[i];
	}

	rep(i, N) {
		if (S[i] == 0) ans++;
		if (mp.count(S[i]) > 0) ans += mp[S[i]];
		if (mp.count(S[i]) > 0) mp[S[i]]++;
		else mp[S[i]] = 1;
	}

	cout << ans << endl;

	return 0;
}


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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
  ll A, B, C;
  cin >> A >> B >> C;
  cout << C << " " << A << " " << B;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
namespace QiFeng233{
	double r,pi;
	void solve(){
		pi=acos(-1);
		scanf("%lf",&r);
		printf("%.20lf",2.0*r*pi);
	}
}
signed main(){
	QiFeng233::solve();
	return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
    
int main(){
  int n;
  cin>>n;
  queue<int> q;
  for(int i=0; i<n ;i++){
    int tmp;
    cin>>tmp;
    q.push(tmp);
  }
  int count=0;
  int i=1;//最終的にi番目になる
  while(!q.empty()){
    if(q.front()==i){
      i++;
    }
    else{
      count++;
    }
    q.pop();
  }
  if(count==n) count=-1;
  cout<<count<<endl;
    
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> A(N), B(N), C(N - 1);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		A[i]--;
	}
	for (int i = 0; i < N; i++) {
		cin >> B[i];
	}
	for (int i = 0; i < N - 1; i++) {
		cin >> C[i];
	}
	int total = 0;
	for (int i = 0; i < N; i++) {
		total += B[A[i]];
	}
	for (int i = 0; i < N - 1; i++) {
		if (A[i + 1] == A[i] + 1) total += C[A[i]];
	}
	cout << total << endl;
	return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
int main()
{
    int a,b,c,i,divisor=0;
    scanf("%d %d %d",&a,&b,&c);
    for(i=a;i<=b;i++)
    {
        if(c%i==0)
        {
            divisor++;
        }
    }
    printf("%d\n",divisor);
    return 0;
}



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

#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)


using namespace std;
using ll = long long;

void solve() {
    int n;
    cin >> n;
    vector<ll> h(n);
    for (auto &a:h) {
        cin >> a;
    }

    vector<ll> dp(n, 0);
    dp[1] = abs(h[1] - h[0]);
    for (int i = 1; i < n - 1; ++i) {
        dp[i] = min(dp[i], abs(h[i] - h[i - 1]) + dp[i - 1]);
        dp[i + 1] = abs(h[i + 1] - h[i - 1]) + dp[i - 1];
    }
    dp[n - 1] = min(dp[n - 1], abs(h[n - 1] - h[n - 2]) + dp[n - 2]);
    cout << dp[n - 1] << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);

    solve();
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
int main()
{
	#define int long long
	int n;
	cin >> n;
	double a[n];
	double ans = 0;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		ans += (1/a[i]);
	}
	ans = 1/ans;
	cout << ans << "\n";
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
using namespace std;


int main() {
	int N;
	char S[51];

	cin >> N;
	cin >> S;

	int ans = 0;

	for (int i = 0; i < N - 2; i++) {
		if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
			ans += 1;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
int cur = 0;
struct node{
  node *l,*r;
  node(node *l = nullptr,node *r = nullptr):l(l),r(r){};
};
node* parse(string &f){
  assert(f[cur] == '(');
  cur++;
  node *current = new node();
  if(f[cur] == '('){
	node *left = parse(f);
	current->l = left;
  }
  assert(f[cur] == ',');
  cur++;
  if(f[cur] == '('){
	node *right = parse(f);
	current->r = right;
  }
  assert(f[cur] == ')');
  cur++;
  return current;
}
string dfs_i(node *f,node *s){
  if(f == nullptr || s == nullptr)return "";
  return "(" + dfs_i(f->l,s->l) + "," + dfs_i(f->r,s->r) + ")";
  
}
string dfs_u(node *f,node *s){
  if(f == nullptr && s == nullptr)return "";
  if(f == nullptr) return "(" + dfs_u(nullptr,s->l) + "," + dfs_u(nullptr,s->r) + ")";
  if(s == nullptr) return "(" + dfs_u(f->l,nullptr) + "," + dfs_u(f->r,nullptr) + ")";
  return "(" + dfs_u(f->l,s->l) + "," + dfs_u(f->r,s->r) + ")";
  
}
int main(){
  string f,s;
  char c;
  while(cin >> c >> f >> s){
	node *f_t,*s_t;
	cur = 0;
	f_t = parse(f);
	cur = 0;
	s_t = parse(s);
	
	if(c == 'i')cout << dfs_i(f_t,s_t) << endl;
	if(c == 'u')cout << dfs_u(f_t,s_t) << endl;
	
	
  }

  return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;
ll gcd(ll a, ll b){if(b==0) return a; return gcd(b, a%b);}
int main(){
    fast_io

    int x, y, z;
    cin>>x>>y>>z;
    cout<<x*y/2<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int N,S,T;
	scanf("%d",&N);
	S=N/10;
	T=N%10;
	if(S==9||T==9){
		printf("Yes\n");
	}
	else{
		printf("No\n");
		}
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/python3
# import bisect
from collections import Counter, deque, OrderedDict,defaultdict
# from copy import copy, deepcopy
# from functools import reduce
# from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import unittest
from io import StringIO
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    N = int(input())
    A = list(map(int, input().split()))
    d=defaultdict(int)
    cnt=0
    for k,v in enumerate(A):
        d[k+v]+=1
        cnt+=d[k-v]

    print(cnt)


resolve()

Measured memory_bytes: 146212
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = ns()
n = len(s)
ans = n

for i in range(n-1):
    if s[i] != s[i+1]:
        k = max(n-i-1,i+1)
        ans = min(ans,k)

print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header
int main() {
	string s;
	cin >> s;
	int f1, f2;
	rep(i,s.length()){
		if(s[i]=='A'){
			f1=i;
			break;
		}
	}
	rep(i,s.length()){
		if(s[i]=='Z') f2=i;
	}
	cout << f2-f1+1 << endl;
	return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}


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

  lol n, h;
  cin >> n >> h;
  lol a, b;
  bool thr[n + 5] = {false};
  priority_queue<pair<lol, int> > na;
  reps(i, n){
    cin >> a >> b;
    na.push(mp(a, 2));
    na.push(mp(b, 1));
  }
  lol ans = 0;
  while(h > 0){
    tie(a, b) = na.top();
    //cout << a << " " << b << '\n';
    na.pop();
    if(b == 1){
      ans ++;
      h -= a;
    } else {
      ans += UPDigit(h, a);
      h = 0;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 6256
#include <iostream>
#include <vector>
#include <string>
#include <map>

using namespace std;
typedef pair<string, int> P;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		map<string, int> Map;
		for(int i = 0; i < n; ++i)
		{
			string s;
			int t;
			cin >> s >> t;
			Map[s] = t;
		}
		int m;
		cin >> m;
		vector<string> item(m);
		vector<int> Vec(m);
		vector< vector<string> > str(m);
		for(int i = 0; i < m; ++i)
		{
			cin >> item[i] >> Vec[i];
			for(int j = 0; j < Vec[i]; ++j)
			{
				string s;
				cin >> s;
				str[i].push_back(s);
			}
		}
		while(true)
		{
			bool update = false;
			for(int i = 0; i < m; ++i)
			{
				int sum = 0;
				for(int j = 0; j < Vec[i]; ++j)
				{
					sum += Map[str[i][j]];
				}
				if(Map[item[i]] > sum)
				{
					Map[item[i]] = sum;
					update = true;
				}
			}
			if(update == false)
			{
				break;
			}
		}
		string Target;
		cin >> Target;
		cout << Map[Target] << endl;
	}
}

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

Measured memory_bytes: 0
N,K = gets.split.map(&:to_i)
S = gets.chomp

cur = S[0]

count = 1

run = []

if cur == "0"
  run.push(0)
end


for i in 1..N-1 do
  if S[i] == cur
    count += 1
  else
    run.push(count)
    count = 1
    cur = S[i]
  end

  if i == N-1
    run.push(count)
  end
end

if S[N-1] == "0"
  run.push(0)
end

R = run.length

if R/2 <= K
  puts N
  exit
end

max = 0
for i in 0..((R-1)/2-K) do
  if i == 0
    tmp = 0

    for j in 0..(2*K) do
      tmp += run[j]
    end
  end

  if max < tmp
    max = tmp
  end

  if i != (R-1)/2-K
    tmp = tmp - run[2*i] - run[2*i+1] + run[2*(i+K+1)-1] + run[2*(i+K+1)]
  end
end

puts max


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int n[3];
    REP(i, 3)
    {
        cin >> n[i];
    }
    sort(n, n + 3);
    string ans = "No";
    if (n[0] + n[1] == n[2])
        ans = "Yes";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
struct stick{
	int h;
	int l;
};

int main() {
	while (1) {
		int N, M, H, K; cin >> N >> M >> H >> K;
		if (!N)break;
		vector<int>scores(N);
		for (int i = 0; i < N; ++i) {
			cin >> scores[i];
		}
		vector<pair<int, int>>ss;
		for (int i = 0; i < M; ++i) {
			int a, b; cin >> a >> b;
			a--;
			ss.push_back(make_pair(b, a));
		}
		sort(ss.begin(), ss.end(),greater<pair<int,int>>());
		vector<int>nums(N);
		iota(nums.begin(), nums.end(), 0);
		vector<pair<int, int>>ps;
		for (auto s : ss) {
			ps.emplace_back(nums[s.second], nums[s.second + 1]);
			swap(nums[s.second], nums[s.second + 1]);
		}
		int ans = 2e9;
		{
			int nans = 0;
			for (int k = 0; k < K; ++k) {

				nans += scores[nums[k]];
			}
			ans = min(ans, nans);
		}
		for (int i = 0; i < M; ++i) {
			swap(scores[ps[i].first], scores[ps[i].second]);
			int nans = 0;
			for (int k = 0; k < K; ++k) {

				nans += scores[nums[k]];
			}
			ans = min(ans, nans);		
			swap(scores[ps[i].first], scores[ps[i].second]);


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

Measured memory_bytes: 5084
N=int(input())
V=list(map(int,input().split()))
C=list(map(int,input().split()))
real=[]
for i in range(0,N):
  tmp=V[i]-C[i]
  real.append(tmp)
#print(real)
sum=0
for i in range(0,N):
  if real[i]>0:
    sum+=real[i]
print(sum)

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

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

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

inline void read() {}

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

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

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

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

string N;
int dp[30][2][300];

int rec(int k, bool tight, int sum) {
    if (k >= N.size()) {
        return sum;
    }
    auto &res = dp[k][tight][sum];
    if (~res) return res;

    int x = N[k] - '0';
    int r = (tight ? x : 9);

    res = 0;

    for (int i = 0; i <= r; ++i) {
        chmax(res, rec(k + 1, tight & (i == r), sum + i));
    }

    return res;
}

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

    read(N);
    memset(dp, -1, sizeof(dp));
    print(rec(0, true, 0));

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
#define F first
#define S second
const int N = 2e5 + 87;
pii a[N];
int b[N];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i].F;
        a[i].S = i;
    }
    sort(a,a+n);
    for (int i = 0; i < n/2; ++i)
        b[a[i].S] = a[n/2].F;
    for (int i = n/2; i < n; ++i)
        b[a[i].S] = a[n/2-1].F;
    for (int i = 0; i < n; ++i)
        cout << b[i] << '\n';
}

Measured memory_bytes: 4608
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;


class Program {

	const long mod = 1000000007;
	//public static int[] max;

	static void Main(string[] args) {

		char[] cs = new char[] { ' ', ',' };
		//int val = int.Parse(Console.ReadLine());
		int[] vals = parseAry(Console.ReadLine().Split(cs));
		//int val = int.Parse(Console.ReadLine());
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//int n = vals[0];
		//string res="";

		//int y = vals[0];
		//int x = vals[1];

		string re = "NO";
		if (vals[1]-vals[0]==(vals[2]-vals[1])) {
			re = "YES";
		}



		Console.WriteLine(re);


		return;
	}



	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryl(string[] str) {
		long[] nums = new long[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}



	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for (int i = 0; i < str.Length; i++) { re[i] = str[i].ToString(); }
		return re;
	}

}

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

#define INC(i) (i)+1

using namespace std;

int main(){
  string s;
  int count = 0;
  cin >> s;
  for(int i = 0;i < 6;i++){
    // TODO: ここで1を数える
    count += (int)s[i]-(int)'0';
  }
  cout << count << "\n";
  cout << flush;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 105;
string s;
int k;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> s >> k;
    set<string> pq;
    int i = 0, j = 0;
    int n = s.length();
    for(i = 0; i < n; i++){
        string st = "";
        for(j = i; j < min(n, i + 6); j++) {
            st += s[j];
            pq.insert(st);
        }
    }
    string ans = "";
    while(k--) {
        ans = *pq.begin();
        pq.erase(ans);
        //cout << ans << "\n";
    }
    cout << ans;
    return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var counter = new List<int>();
            var cur = S[0];
            var count = 1;

            for (var i = 1; i < S.Length; i++)
            {
                if (cur == S[i])
                    count++;
                else
                {
                    counter.Add(count);
                    count = 1;
                    cur = S[i];
                }
            }

            counter.Add(count);

            if (counter.Count == 1)
            {
                Console.WriteLine(SumVal(counter[0]));
                return;
            }

            if (counter.Count == 2 && S[0] == '>' && S[S.Length-1] == '<')
            {
                Console.WriteLine(SumVal(counter[0]) + SumVal(counter[1]));
                return;
            }

            var start = S[0] == '<' ? 1 : 2;
            decimal ans = 0;
            if (counter.Count % 2 == 1)
                ans = S[0] == '<' ? SumVal(counter[counter.Count - 1]) : SumVal(counter[0]);
            if (counter.Count % 2 == 0 && S[0] == '>' && S[S.Length - 1] == '<')
                ans = SumVal(counter[0]) + SumVal(counter[counter.Count - 1]);

            for (var i = start; i < counter.Count; i+=2)
            {
                if (counter[i] >= counter[i - 1])
                    counter[i - 1]--;
                else
                    counter[i]--;

                ans += SumVal(counter[i]);
                ans += SumVal(counter[i - 1]);
            }

            Console.WriteLine(ans);
        }

        static decimal SumVal(int a)
        {
            return (decimal)(a * 0.5 * (a + 1));
        }
    }
}


Measured memory_bytes: 14944
/*
貪欲
後ろから見る
DP
順位表をチェック
二分探索
不変なもの・偶奇に注目

*/
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<tuple>
#include<set>
using namespace std;
#define INF 1LL<<60
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
//typedef pair< pair<int,int>,pair<int,int> > p;
//#define int ll int main->signed main
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());

int main(){
    int N;
    string S;
    cin>>N>>S;
    int ans=0;
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            for(int k=0;k<10;k++){
                int count=0;
                for(int l=0;l<N;l++){
                    bool flag=false;
                    if(count==0 && (int)(S[l]-'0')==i) flag=true;
                    if(count==1 && (int)(S[l]-'0')==j) flag=true;
                    if(count==2 && (int)(S[l]-'0')==k) flag=true;
                    if(flag) count++;                   
                }
                if(count==3){
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, k;
    cin >> n >> k;
    vector<P> a(n);
    rep(i, n)cin >> a[i].second >> a[i].first;
    sort(a.begin(), a.end(), greater<P>());
    ll sum = 0;
    set<int> t;
    stack<int> stock;
    rep(i, k){
        sum += a[i].first;
        if(t.find(a[i].second) == t.end()){
            t.insert(a[i].second);
        }else{
            stock.push(a[i].first);
        }
    }
    ll s = t.size();
    ll ans = sum + s * s;
    for(int i = k; i < n; i++){
        if(t.find(a[i].second) == t.end()){
            if(!stock.empty()){
                sum -= stock.top();
                sum += a[i].first;
                stock.pop();
                t.insert(a[i].second);
                s++;
                ans = max(ans, sum + s * s);
            }
        }
    }
    cout << ans << endl;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ll N; cin >> N;
  vector<string> S(N); REP(i, N) cin >> S[i];

  map<string, int> m;
  REP(i, N) {
    m[S[i]]++;
  }

  ll tmp = 0;
  for(auto x : m) {
    if(x.second > tmp) tmp = x.second;
  }

  for(auto x : m) {
    if(tmp == x.second) cout << x.first << endl;
  }
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> vec(n);
    for(int i=0; i<n; i++) {
        cin >> vec.at(i);
    }
    cout << 1+(n-2)/(k-1) << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define RFOR(i,s,e) for(int (i) = (s);(i) >= (e);(i)--)
#define rep(i,n) FOR(i,0,n-1)

signed main() {
    int n;cin>>n;
    while(n)
    {
        if(n/100 ==n/10%10 && n/100 == n%10)
        {
            cout << n<< endl;
            return 0;
        }
        n++;
    }
}


Measured memory_bytes: 256