akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ClassLibrary1
{
    public class ListNode
    {
        public int val;
        public ListNode next;
        public ListNode(int x) { val = x; }
    }


    public class Class1
    {
        static Dictionary<Tuple<long, long>, long> dic = new Dictionary<Tuple<long, long>, long>();


        static void Main(string[] args)
        {
            var n = ReadLong();
            var s = ReadString().ToCharArray();
            char[] c = new char[s.Length];
            for(int i=0; i<s.Length; i++)
            {
                c[i] = convert(s[i], n);
            }
            Console.WriteLine(new string(c));
        }

        private static char convert(char c, long n)
        {
            string s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            var ind = (s.IndexOf(c) + n)%26 ;
            return s.ToCharArray()[ind];
        }


        public static long nCm(long n, long m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            var a = n * nCm(n - 1, m - 1) / m;
            return a % 1000000007;
        }

        private static string ReadString()
        {
            return Console.ReadLine();
        }
        private static string[] ReadStringArr()
        {
            return Console.ReadLine().Split(' ');
        }
        private static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadLongArr()
        {
            string[] s = ReadStringArr();
            long[] l = new long[s.Length];
            for(int i=0; i<l.Length; i++)
            {
                l[i] = long.Parse(s[i]);
            }

            return l;
        }
    }

}


Measured memory_bytes: 11140
import java.math.*

fun main(args: Array<String>) {
    val N = readInputLine().toLong()
    
    var ans = 0L
    
    for (i in LongRange(1L, N)) {
        if (i * i >= N) {
            break
        }
        
        if (N % i == 0L && i < N / i - 1L) {
            ans += N / i - 1L
        }
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


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

int main() {
  string N;
  cin >> N;
  int ans = 0;
  if (N[0] == '2') ans++;
  if (N[1] == '2') ans++;
  if (N[2] == '2') ans++;
  if (N[3] == '2') ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

#define swap(type,x,y) do{type t=x;x=y;y=t;}while(0)

void quick(int a[], int b[],  int left, int right) {
	int pl = left;
	int pr = right;
	int x = a[(pl + pr) / 2];

	do {
		while (a[pl] < x)pl++;
		while (a[pr] > x)pr--;
		if (pl <= pr) {
			swap(int, a[pl], a[pr]);
			swap(int, b[pl], b[pr]);
			pl++;
			pr--;
		}
	} while (pl <= pr);
	if (left < pr) quick(a, b, left, pr);
	if (pl < right) quick(a, b, pl, right);
}

int main() {
	int n, i, j, x;
	int max_y = 0, idx, count = 0;
	bool flag;

	cin >> n;

	int a[n], b[n], c[n], d[n];

	for (i = 0; i < n; i++) {
		cin >> x;
		a[i] = x;
		cin >> x;
		b[i] = x;
	}
	for (i = 0; i < n; i++) {
		cin >> x;
		c[i] = x;
		cin >> x;
		d[i] = x;
	}

	quick(a, b, 0, n - 1);
	quick(c, d, 0, n - 1);

	for (i = 0; i < n; i++) {
		max_y = -1;
		idx = -1;
		for (j = 0; j < n; j++) {
			if (a[j] == -1)
				continue;
			if (a[j] < c[i] && b[j] < d[i]) {
				if (max_y < b[j] || max_y == -1) {
					max_y = b[j];
					idx = j;
				}
			}
		}
		if (idx != -1) {
			count++;
			a[idx] = -1;
			b[idx] = -1;
		}
	}

	cout << count;

	return 0;
}

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

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

int main(void){
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	string a;
	cin >> a;
	bool flag = 0;
	for(int i = 0;i < a.size();i++)
		if(a[i] == '9')
			flag = 1;
	if(flag)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int A = scn.nextInt();
		int B = scn.nextInt();
		int C = scn.nextInt();
		System.out.println(A+B>=C?"Yes":"No");
	}

}


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

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    ll ans = 0;
    ll price = 1;
    for (int i = 0; i < N; i++) {
        if (A[i] < price) continue;
        if (A[i] == price) {
            price++;
            continue;
        }
        ans += (A[i]-1)/price;
        if (price==1) price++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#define N 100001 
long p[N],r[N],n,m,i,b[N],a[N][2],c,d;int f(int x){if(p[x]==x)return x;return p[x]=f(p[x]);}int u(int x,int y){x=f(x);y=f(y);p[x]=y;r[y]+=r[x];r[x]=r[y];}int main(){scanf("%ld%ld",&n,&m);for(i=0;i<m;i++)scanf("%d%d",a[i],&a[i][1]);b[m]=n*(n-1)/2;for(i=0;i<N;i++){p[i]=i;r[i]=1;};for(i=m-1;i>0;i--){c=a[i][0],d=a[i][1];b[i]=b[i+1];if(f(c)!=f(d)){b[i]-=r[f(c)]*r[f(d)];u(c,d);}}for(i=1;i<=m;i++)printf("%ld\n",b[i]);}

Measured memory_bytes: 5120
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<ll> pow2;
  ll p = 1;
  while (p < (1LL<<62)/2) {
    p *= 2;
    pow2.push_back(p);
  }
  int n;
  cin >> n;
  multiset<int> st;
  rep(i, n) {
    int tmp;
    cin >> tmp;
    st.insert(tmp);
  }
  int ans = 0;
  while (st.size() >= 2) {
    auto tmp = st.end();
    tmp--;
    int mx = *tmp;
    st.erase(tmp);
    rep(i, pow2.size()) {
      int f = pow2[i]-mx;
      auto it = st.lower_bound(f);
      if (it != st.end() && *it == f) {
        st.erase(it);
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    if (n >= MAX) {
        long long ans = 1;
        long long nn = n;
        for (int i = 0; i < k; i++) {
            ans = ans * nn % MOD;
            --nn;
        }
        long long kk = k;
        for (int i = 0; i < k; i++) {
            ans = ans * modinv(kk, MOD) % MOD;
            --kk;
        }
        return ans;
    }
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(void) {
    int n, a, b;
    cin >> n >> a >> b;
    COMinit();
    int t = modpow(2, n, MOD);
    t -= COM(n, a);
    if (t < 0) {
        t += MOD;
    }
    t -= COM(n, b);
    if (t < 0) {
        t += MOD;
    }
    t -= 1;
    if (t < 0) {
        t += MOD;
    }
    printf("%d\n", t);
    return 0;
}


Measured memory_bytes: 12160
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  string s;
  cin >> s;
  if(s.back()=='s'){
    s += "es";
  }else{
    s += "s";
  }
  cout << s << endl;
}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

// #define amari(x) ((x) % 1000000007)
#define amari(x) ((x) % 998244353)

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<int>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(long i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

struct Pony
{
    long v, n;

    Pony(long v_, long n_)
    {
        v = v_;
        n = n_;
    }

    bool operator<(const Pony &another) const
    {
        return v < another.v;
    };

    bool operator>(const Pony &another) const
    {
        return v > another.v;
    };
};

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

  long n, m;

  cin >> n >> m;

  vector<long> a(n);

  fillLong(a, n);

  sort(a.begin(), a.end(), std::greater<long>());

  vector<Pony> p;

  rep(i, m) {
    long b, c;
    cin >> b >> c;
    p.push_back(Pony(c, b));
  }

  sort(p.begin(), p.end(), std::greater<Pony>());

  long i = 0;

  long cnt = 0;
  long sm = 0;
  
  long j = 0;
  long plen = p.size();
  while(cnt < n) {
    while(i < n && cnt < n && p[j].v < a[i]) {
      sm += a[i];
      i++;
      cnt++;
    }
    if(j < plen && cnt < n) {
      long c = min(p[j].n, n-cnt);
      sm += p[j].v * c;
      j++;
      cnt += c;
    }
  }
  cout << sm << endl;
}


Measured memory_bytes: 3188
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1000000000;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, k;
    cin >> h >> w >> k;
    int sy, sx;
    vector<vector<char>> grid(h, vector<char>(w));
    rep(i,h)rep(j,w){
        cin >> grid[i][j];
        if(grid[i][j] == 'S'){
            sy = i;
            sx = j;
        }
    }
    vector<vector<int>> dist(h, vector<int>(w, INF));
    dist[sy][sx] = 0;
    int ans = INF;
    queue<P> que;
    que.push(P(sy, sx));
    while(!que.empty()){
        P p = que.front();
        que.pop();
        int cmp = INF;
        chmin(cmp, 1 + (p.first + k - 1) / k);
        chmin(cmp, 1 + (h - 1 - p.first + k - 1) / k);
        chmin(cmp, 1 + (p.second + k - 1) / k);
        chmin(cmp, 1 + (w - 1 - p.second + k - 1) / k);
        chmin(ans, cmp);
        rep(i,4){
            int ny = p.first + dy[i];
            int nx = p.second + dx[i];
            if(ny < 0 || h <= ny) continue;
            if(nx < 0 || w <= nx) continue;
            if(dist[ny][nx] != INF) continue;
            if(grid[ny][nx] == '#') continue;
            if(dist[p.first][p.second]+1 > k) continue;
            dist[ny][nx] = dist[p.first][p.second] + 1;
            que.push(P(ny, nx));
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint a, b;
    cin >> a >> b;
    if (a * b <= 0) {
        cout << "Zero"
             << "\n";
        return 0;
    }
    if (1 <= a) {
        cout << "Positive"
             << "\n";
        return 0;
    }
    lint nneg = b - a + 1;
    if (nneg % 2 == 0) {
        cout << "Positive"
             << "\n";
    } else {
        cout << "Negative"
             << "\n";
    }
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int n, m;
int g[51][51];
bool visited[51];
bool dfs(int s){
  for(int i = 0; i < n; i++){
    if(s != i && (g[s][i] || g[i][s]) && !visited[i]){
        g[s][i] = 0;
        g[i][s] = 0;
        visited[i] = true;
        dfs(i);
        g[s][i] = 1;
        g[i][s] = 1;
    }
  }
  for(int i = 0; i < n; i++){
    if(!visited[i]) return false;
  }
  return true;
}
int main(void){
  int a[50], b[50];
  int ans = 0;
  cin >> n >> m;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      g[i][j] = 0;
    }
  }
  for(int i = 0; i < m; i++){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    g[a[i]][b[i]] = 1;
    g[b[i]][a[i]] = 1;
  }
  for(int i = 0; i < m; i++){
    g[a[i]][b[i]] = 0;
    g[b[i]][a[i]] = 0;
    for(int j = 0; j < n; j++) visited[j] = false;
    visited[0] = true;
    if(!dfs(0)) ans++;
    g[a[i]][b[i]] = 1;
    g[b[i]][a[i]] = 1;
  }
  cout << ans << endl;
  return 0;
}

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

const long long INF = 1e6+7;
const long long MOD = 1e9+7;
const double PI=acos(-1);

using namespace std;

int main(){
	int x,n;
	cin >> x >> n;
	vector<int> a(n);
	vector<int> check(150,0);
	for(int i=0;i<n;i++){
		cin >> a[i];
		check[a[i]]++;
	}
	int up=0;
	for(int i=x;i<150;i++){
		if(check[i]==0){
			up=i;
			break;
		}
	}
	int dw=0;
	for(int i=x;i>=0;i--){
		if(check[i]==0){
			dw=i;
			break;
		}
	}
	int ans;
	if(abs(up-x)<abs(dw-x)){
		ans=up;
	}else if(abs(up-x)>=abs(dw-x)){
		ans=dw;
	}
	cout << ans << endl;		
	return 0;
}


Measured memory_bytes: 3636
#include <cstdint>
#include <cstdio>
#include <unordered_set>

int main () {

	int n;

	scanf("%d", &n);

	int * a = new int[n];
	int p1 = 1; //, p2 = 1;
	uint64_t count = 0;
	
	std::unordered_set<int> visited;
	visited.insert(1);
	
	bool hasCycle = false;

	for (int i = 0; i < n; ++i) scanf("%d", &a[i]);

	do {
		p1 = a[p1 - 1];
		auto contains = visited.find(p1);
		if (contains == visited.end()) {
			visited.insert(p1);
			++count;
		} else {
			break;
		}
		// p2 = a[p2 - 1];
		// p2 = a[p2 - 1];
	} while (p1 != 2 /* && p1 != p2 */);

	if (p1 == 2) {
		printf("%llu\n", count);
	} else {
		printf("%d\n", -1);
	}

	delete[] a;

	return 0;

}


Measured memory_bytes: 4772
from sys import stdin
input = stdin.readline

N = int(input())
A = map(int, input().split())
res = int(1)
Lim = int(1000000000000000000)
#print(Lim)
for X in A:
    #print(X)
    if X == 0:
        res *= X
        continue
    if res > Lim:
        continue
    res *= X
if res > Lim:
    print(-1)
else:
    print(res)


Measured memory_bytes: 19488
module A
  sub Main(byval args() as string)
    dim s as string = console.readline()
    if s.substring(2,1) = s.substring(3,1) andalso s.substring(4,1) = s.substring(5,1) then
      console.writeline("Yes")
    else
      console.writeline("No")
    end if
  end sub
end module

Measured memory_bytes: 20432
#pragma region Macros

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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>
ostream &operator<<(ostream &out, vector<T> const &v) {
    for (auto &&a : v) out << a << " ";
    out << endl;
    return out;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int N;
    cin >> N;
    vi a(N);
    REP(i, N) {
        cin >> a[i];
    }
    int b = 0;
    int count = 1;
    REP(i, N - 1) {
        if (a[i + 1] > a[i]) {
            if (b == -1) {
                count++;
                b = 0;
            } else {
                b = 1;
            }
        }
        if (a[i + 1] < a[i]) {
            if (b == 1) {
                count++;
                b = 0;
            } else {
                b = -1;
            }
        }
    }

    cout << count;
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


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

int main(int argc, char **argv)
{
	ll n, m;
	cin >> n >> m;
	vector<pair<ll, ll>> a_b(n);
	for (int i = 0; i < n; ++i)
	{
		ll a, b; cin >> a >> b;
		a_b[i] = pair<ll, ll>(a, b);
	}

	sort(a_b.begin(), a_b.end(), [](const auto &a, const auto &b)
								 {
									 return a.first < b.first; 
								 });

	ll c{0};
	ll c_money{0};
	ll i = 0;
	for (; i < n; ++i)
	{
		if (c + a_b[i].second >= m) break;
		c += a_b[i].second;
		c_money += a_b[i].first * a_b[i].second;
	}

	ll &&remain = m - c;
	c_money += remain * a_b[i].first;
	std::cout << c_money << std::endl;
}

Measured memory_bytes: 1792
use proconio::{input, fastout};
use std::time::{Duration, Instant};
use rand::prelude::*;

const TYPE_COUNT: usize = 26;

#[fastout]
fn main() {
    input! {
        d: usize,
        cc: [usize; TYPE_COUNT],
        ss: [[usize; TYPE_COUNT]; d],
    }
    let start = Instant::now();

    let mut last = vec![0; TYPE_COUNT];

    let mut ans = vec![];

    for s in ss.iter() {
        let mut max = 0;
        let mut index = 0;
        for (i, &x) in s.iter().enumerate() {
            let x = x + cc[i] * last[i] * 5;
            if max < x {
                max = x;
                index = i;
            }
        }
        for l in last.iter_mut() {
            *l += 1;
        }
        last[index] = 0;
        ans.push(index);
    }

    let mut score = calc_score(&cc, &ss, &ans);
    let mut rng = thread_rng();

    while Instant::now().duration_since(start) < Duration::from_millis(1950) {

        let day = rng.gen_range(0, d);
        let ty = rng.gen_range(0, 26);

        let old = ans[day];
        ans[day] = ty;

        let new_score = calc_score(&cc, &ss, &ans);
        if new_score < score {
            ans[day] = old;
        } else {
            score = new_score;
        }
    }

    for x in ans {
        println!("{}", x+1);
    }
    
}

fn calc_score(cc: &Vec<usize>, ss: &Vec<Vec<usize>>, tt: &Vec<usize>) -> isize {
    let mut last = vec![0; TYPE_COUNT];

    let mut v = 0;
    for (s, &t) in ss.iter().zip(tt.iter()) {
        v += s[t] as isize;
        for l in last.iter_mut() {
            *l += 1;
        }
        last[t] = 0;
        v -= last.iter().zip(cc.iter()).map(|(&l, &c)| (l * c) as isize).sum::<isize>();
    }
    v
}

Measured memory_bytes: 2720
#include<bits/stdc++.h>
#define ll long long int 
#define pb push_back
#define mp make_pair
#define ff first
#define se second
#define MAX 1000001
#define MAXN 100005
#define mod 1000000007 
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,k,i;
    cin>>a>>b>>k;
    vector<ll> vi1;
    for(i=1;i<=a && i<=b;i++){
        if(a%i==0 && b%i==0){
            vi1.pb(i);
           // cout<<i<<" ";
        }
    }
    cout<<vi1[vi1.size()-k];
}

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

int h[110];

int main()
{
  int T;
  scanf("%d", &T);
  while (T--) {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
      scanf("%d", h+i);
    }
    int m1 = 0, m2 = 0;
    for (int i = 0; i < n-1; ++i) {
      int diff = h[i] - h[i+1];
      if (diff < 0)
        m1 = max(m1, -diff);
      else
        m2 = max(m2, diff);
    }
    printf("%d %d\n", m1, m2);
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

int main(){
  int n,f,m,t;
  vector<int> a1;
  vector<int> a2;
  cin >> n;
  REP(i,n){
    cin >> f;
    a1.push_back(f);
  }
  REP(i,n){
    cin >> f;
    a2.push_back(f);
  }
  m = 0;
  REP(i,n){
    t = 0;
    FOR(j,0,i+1){
      t += a1[j];
    }
    FOR(j,i,n){
      t += a2[j];
    }
    if(t>m)m=t;
  }
  cout << m;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){ 
    int n; cin >> n;
    vector<vector<int>> D(n, vector<int>(2));
    rep(i, n){
        rep(j, 2){
            cin >> D[i][j];
        }
    }
    bool fg = false;
    rep(i, n-2){
        if(D[i][0]==D[i][1] && D[i+1][0]==D[i+1][1] && D[i+2][0]==D[i+2][1])fg = true;
    }
    if(fg)cout << "Yes" << ln;
    else cout << "No" << ln;
}



Measured memory_bytes: 3640
#define Bobyama
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100;
int N;
string S[MAX_N];
int P[MAX_N];

struct Res {
  string S;
  int P;
  int i;
};

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

  cin >> N;
  rep(i, N) cin >> S[i] >> P[i];

  vector<Res> v;
  rep(i, N) {
    Res res;
    res.S = S[i];
    res.P = P[i];
    res.i = i+1;
    v.push_back(res);
  }

  sort(all(v), [](const Res& r1, const Res& r2){
      if (r1.S != r2.S) {
        return r1.S > r2.S;
      } else {
        return r1.P < r2.P;
      }});

  for (int i = len(v) - 1; i >= 0; --i) {
    cout << v[i].i <<  endl;
  }
 
  return 0;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int x,y,z;
    cin >> x;
    cin >> y;
    cin >> z;
    if(x>y){
        int temp = x;
        x = y;
        y = temp;
    }
    if(y>z){
        int temp = y;
        y = z;
        z = temp;
    }
    if(x>y){
        int temp = x;
        x = y;
        y = temp; 
    }
    cout << x << " " << y << " " << z << endl;

}


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

int main(){
    int k,s;
    cin >> k >> s;
    int cnt=0;
    for(int i=0;i<=k;i++)
    {
        for(int j=0;j<=k;j++)
           {
            if(s-i-j>=0&&s-i-j<=k){
                int len = s-i-j;
                   if(i+j+len == s) cnt++;
                }
            }
    }

    cout << cnt << endl;
    return 0;
}



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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
#define pqasc priority_queue<long long, vector<long long>, greater<long long>>

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ul = unsigned long;

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

class UnionFind{
private:
  vector<int> Parent; 
 public:
  UnionFind(int N){
    Parent = vector<int>(N, -1);
  }
  
  int root(int A){
    if(Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  
  int size(int A){
    return -Parent[root(A)]; 
  }
  
  bool connect(int A, int B){
    A = root(A);
    B = root(B);
    if(A == B){
      return false;
    }
    if(size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
  
  bool isSame(int A, int B){
    return root(A) == root(B);
  }
};

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s,t; cin>>s>>t;
  bool ok=false;
  int n=s.size();
  rep(i,n){
    s=s[n-1]+s.substr(0,n-1);
    if(s==t) ok=true;
  }
  if(ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
a = [input() for _ in range(H)]

h = []
w = []
for i in range(H):
    cnt = 0
    for j in range(W):
        if a[i][j] == '.':
            cnt += 1
    if cnt == W:
        h.append(i)

for j in range(W):
    cnt = 0
    for i in range(H):
        if a[i][j] == '.':
            cnt += 1
    if cnt == H:
        w.append(j)

for i in range(H):
    if i in h:
        continue
    for j in range(W):
        if j in w:
            continue
        print(a[i][j],end='')
    print()

Measured memory_bytes: 4468
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
 
#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
 
int main(void){
    int n; cin >> n;

    while(n --){
        vi res(81);

        rep(i, 2){
            string in; cin >> in;
            if(in.size() > 80){ res[80] = 1; continue; }
            rep(j, in.size() + 1){
                if(j != in.size()) res[j] += in.at(in.size() - j - 1) - '0';
                for(int l = 0; res[j + l] > 9; l ++) res[j + l + 1] ++, res[j + l] %= 10;
            }
        }

        if(res[80]){ cout << "overflow" << endl; continue; }

        bool ok = false;
        for(int i = 79; i >= 0; i --){
            if(!ok) if(res[i] || !i) ok = true;
            if(ok) cout << res[i];
        }
        cout << endl;
    }
 
    return 0;
}

Measured memory_bytes: 1212
#include <stdio.h>

int ReadValue() {
    int value; scanf("%d",&value);
    return value;
}
void ReadArray(int *Array,int index) {
    int i;
    for (i=0; i<index; i++) {
        scanf("%d",&Array[i]);
    }
}
void swap(int *a,int *b) {
    int temp; temp=*a; *a=*b; *b=temp;
}
int selectionSort(int *Array, int index) {
    int swapcount=0;
    int i,j,flag=1;
    for (i=0; i<index; i++) {
        int minj=i;
        for (j=i; j<index; j++) {
            if (Array[j]<Array[minj]) {
                minj=j;
            }
        }
        swap(&Array[i],&Array[minj]);
        if (minj!=i) {
            swapcount++;
        }
    }
    return swapcount;
}
void Display(int *Array,int index) {
    int ans=selectionSort(Array,index);
    int i;
    for (i=0; i<index; i++) {
        if (i>0) {
            printf(" ");
        }
        printf("%d",Array[i]);
    }
    printf("\n");
    printf("%d\n",ans);
}
int main() {
    int N=ReadValue();
    int A[N]; ReadArray(A,N);
    Display(A,N);
    return 0;
}


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

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  int count = 0;
  for(int i = 0; i < n; i++) {
    if(count > x) {
      cout << i - 1 << endl;
      return 0;
    } else if(count == x) {
      cout << i << endl;
      return 0;
    } else {
      count += a.at(i);
    }
  }
  if(count == x) {
    cout << n << endl;
  } else {
	cout << n - 1 << endl;
  }
}


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

int A, B;
int add, sub, mul;
int maxval;

int main() {
  scanf("%d%d", &A, &B);
  add = A + B;
  sub = A - B;
  mul = A * B;

  maxval = add > sub ? add : sub;
  maxval = mul > maxval ? mul : maxval;
  printf("%d\n", maxval);

  return 0;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }

  vector<int> b(n,0);
  for(int i=0;i<n;i++) ++b.at(a.at(i)-1);

  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());

  int ans=0;
  for(int i=0;i<n;i++) ans += b.at(i);
  for(int i=0;i<k;i++) ans -= b.at(i);

  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    int n;cin >> n;
    vector<LL> a(n),b(n);
    vector<LL> g(n);
    LL o = 86400; 
    LL cnt = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        cnt += a[i];
        g[i] = cnt % o;
        cnt += b[i];
    }
    sort(ALL(g));
    for (int i = 0; i < n; i++) {
        g.pb(g[i] + o);
    }
    int r = 0;
    int ans = 0;
    for (int i = 0; i < 2*n; i++) {
        while(r < 2 * n && g[r] - g[i] <= 10800){
            r++;
        }
        ans = max(ans, r - i);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3440
from collections import deque

INF = 10**18

H, W, K = map(int, input().split())
x1, y1, x2, y2 = map(lambda x: int(x) - 1, input().split())
C = [input() for _ in range(H)]

queue = deque()
queue.append((x1, y1))

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

dist = [[INF for j in range(W)] for i in range(H)]
dist[x1][y1] = 0

while queue:
    x, y = queue.popleft()
    for i in range(4):
        for k in range(K):
            nx = x + (k + 1) * dx[i]
            ny = y + (k + 1) * dy[i]
            if not (0 <= nx < H and 0 <= ny < W):
                break
            if C[nx][ny] == '@':
                break
            if dist[nx][ny] <= dist[x][y]:
                break
            if dist[nx][ny] != INF:
                continue
            dist[nx][ny] = dist[x][y] + 1
            queue.append((nx, ny))

print(dist[x2][y2] if dist[x2][y2] != INF else -1)

Measured memory_bytes: 150656
from itertools import product
s = input()
for p in product(range(2),repeat=3):
    tmp = ''
    for i in range(len(s)-1):
        if p[i] == 0:
            tmp += s[i]+'+'
        else:
            tmp += s[i]+'-'
    if eval(tmp+s[-1]) == 7:
        print(tmp+s[-1]+'=7')
        exit()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N;
int main(){
	cin >> N;
	vector<int> L(2*N);
	for(int i=0;i<2*N;i++)cin >> L[i];
	sort(all(L));
	int ans = 0;
	for(int i=0;i<N;i++)ans+=L[i*2];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, l, r;
  cin >> N;
  int total = 0;
  
  for (int i = 0; i < N; i++){
    cin >> l >> r;
    total += r - l + 1;
  }
  
  cout << total << endl;
}

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

using namespace std;

vector<vector<int> > dp;
string s;

bool dfs(int l,int r) {
  if(dp[l][r]!=-1) return dp[l][r];
  if(l==r) return dp[l][r]=true;
  if(s[l]!='m'||s[r-1]!='w') return dp[l][r]=false;
  for(int i=l+1;i<r-1;++i)
    if(s[i]=='e')
      if(dfs(l+1,i)&&dfs(i+1,r-1)) return dp[l][r]=true;
  return dp[l][r]=false;
}

int main(){
  cin >> s;
  dp.assign(s.size(),vector<int>(s.size()+1,-1));
  if(dfs(0,s.size())) cout << "Cat" << endl;
  else cout << "Rabbit" << endl;
  
  return 0;
}


Measured memory_bytes: 3988
a,b=input().split()
c=int(a[:3]+a[1]+a[0])
if int(a)>c:
  x=c//100+1
else:
  x=c//100
d=int(b[:3]+b[1]+b[0])
if int(b)<d:
  y=d//100-1
else:
  y=d//100
print(y-x+1)

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

int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
char board[401][401];
int h,w;
int visited[401][401];
long long int arr[160005][2];

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

	cin >> h >> w;

	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			cin >> board[i][j];
		}
	}

	memset(visited,-1,sizeof(visited));

	int cnt = 0;

	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(visited[i][j]==-1 && board[i][j]=='#')
			{
				queue <pair<int,int>> que;
				que.push(make_pair(i,j));
				visited[i][j] = cnt;
				while(!que.empty())
				{
					int y = que.front().first;
					int x = que.front().second;
					que.pop();

					for(int k=0;k<4;k++)
					{
						int ny = y + dy[k];
						int nx = x + dx[k];
						if(ny < 0 || ny >= h || nx < 0 || nx >= w)
						{
							continue;
						}
						if(visited[ny][nx]==-1 && board[ny][nx]!=board[y][x])
						{
							visited[ny][nx] = cnt;
							que.push(make_pair(ny,nx));
						}
					}
				}
				cnt++;
			}
		}
	}

	long long int res = 0;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(visited[i][j]==-1)
			{
				continue;
			}
			if(board[i][j]=='#')
			{
				arr[visited[i][j]][0]++;
			}
			else
			{
				arr[visited[i][j]][1]++;
			}
		}
	}

	for(int i=0;i<cnt;i++)
	{
		res += (arr[i][0]*arr[i][1]);
	}

	cout << res << '\n';

    return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
typedef unsigned long long ull;
#define rep(i,a) for(int i=0;i<a;i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
using namespace std;
const double eps = 1e-10;
const double pi = acos(-1);
const double inf = (int)1e8;

void solved(){
  int c[] = {1,5,10,50,100,500};
  int sum = 0 ;
  rep(i,6){
    int n;
    cin>>n;
    sum += n * c[i];
  }
  cout<<(sum/1000?1:0)<<endl;
}
int main(void){
  solved();
  return 0;
}

Measured memory_bytes: 1164
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){
    
    vector<ll>v(3);
    cin >> v[0] >> v[1] >> v[2];
    sort(v.begin(), v.end());
    cout << v[2] - v[0] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<string, int> PSI;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define REP(i,n)  for(int i=0; i<(n); i++)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
/*int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}*/
/*bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second > secondElof.second;
}*/


/*long nCr(int n, int r)
{
       if(n==r) return dp[n][r] = 1;
       if(r==0) return dp[n][r] = 1;
       if(r==1) return dp[n][r] = n;
       if(dp[n][r]) return dp[n][r];
       return dp[n][r] = nCr(n-1,r) + nCr(n-1,r-1);
}*/

int main(){
    int n;
    cin >> n;
    VI a(n),b(n);
    REP(i,n){
        cin >> a[i];
        b[i]=a[i];
    }
    int tmp,cnt;
    SORT(b);
    REP(i,n){
        if(a[i]<=b[n/2-1]){
            cout << b[n/2] << endl;
        }else cout << b[n/2-1]<< endl;
    }
}


Measured memory_bytes: 3712
N = int(input())
h = list(map(int, input().split()))

INF = 10 ** 5
dp = [INF] * N

dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, N):
    dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]))

print(dp[N - 1])


Measured memory_bytes: 13976
n,q = map(int, input().split())
s = list(input())
lis = [list(map(int, input().split())) for i in range(q)]
l1 = [0]*n
for i in range(n-1):
    if s[i] == 'A' and s[i+1] == 'C':
        l1[i+1] = 1
l2 = [l1[0]] + [0] * (n-1)
for i in range(1,n):
    l2[i] = l2[i-1] + l1[i]
for i in range(q):
    l,r = lis[i][0]-1, lis[i][1]-1
    print(l2[r] - l2[l])

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

int main()
{
  int X;
  cin >> X;
  
  for(int i = 1; i < 9; i++)
  {
    if(X >= 2000 - 200 * i)
    {
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 3632
#include <stdlib.h>
#include <stdio.h>

int main(){
  
  int a[4];
  int b[4];
  for(int i=0;i<5;i++){
    scanf("%d", &a[i]);
  }
  
  for(int k=0;k<5;k++){
    if(a[k]!=k+1){
      printf("%d", k+1);
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 1712
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
	int N;
	scanf("%d",&N);

	char S[N][5];
	int i;
	for(i=0;i<N;i++){
	scanf("%s",S[i]);
	}

	int cAC=0,cWA=0,cTLE=0,cRE=0;
	int j;
	for(j=0;j<N;j++){
		if(strcmp(S[j],"AC")==0){
			cAC++;
		}else if(strcmp(S[j],"WA")==0){
			cWA++;
		}else if(strcmp(S[j],"TLE")==0){
			cTLE++;
		}else if(strcmp(S[j],"RE")==0){
			cRE++;
		}
	}

	printf("AC x %d\n",cAC);
	printf("WA x %d\n",cWA);
	printf("TLE x %d\n",cTLE);
	printf("RE x %d\n",cRE);
	return 0;
}


Measured memory_bytes: 2200
#!/usr/bin/env python3
import sys

def count(s, t):
    ret = 0
    for i in range(len(s)):
        if s[i] != t[i]:
            ret += 1
    return ret


def solve(S: int):
    t1 = []
    t2 = []
    for i in range(len(S)):
        t1.append(str(i % 2))
        t2.append(str((i + 1) % 2))
    t1 = ''.join(t1)
    t2 = ''.join(t2)
    ret = min(count(S, t1), count(S, t2))
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = str(next(tokens))
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 16004
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N >> M;

  vector<int> count(N*2);

  for(int i=0;i<M*2;i++){
    int x;
    cin >> x;
    for (int j=0;j<N;j++){
      if(x==j+1){
        count.at(j)++;
      }
    }
  }
  
  for(int i=0;i<N;i++){
    cout << count.at(i)<<endl;
  }

}

Measured memory_bytes: 256
n=int(input())
a=list(map(int, input().split())) 
 
box=[]
for i in range(n):
    if a[i]%2 == 0:
        if a[i]%3 == 0 or a[i]%5 == 0:
            box.append(1)
        else:
            box.append(0)
if all(box):
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3060
n = int(input())
d = [int(i) for i in input().split()]
m = max(d)
cnt = [0]*(m+1)
ans = 1
flag = True
mod = 998244353

if d[0] == 0:
    cnt[0] += 1
else:
    flag = False

for i in range(1,n):
    if d[i] == 0:
        flag == False
        break
    else:
        cnt[d[i]] += 1

for i in range(1,m+1):
    ans *= cnt[i-1]**cnt[i]
    ans %= mod

if flag == False:
    ans = 0

print(ans)

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

int main(){
	int n,a,b;
	cin>>n>>a>>b;
	int s=0;
	for(int i=1; i<=n; i++){
		int t=i,s1=0;
		while(t!=0){
			s1+=t%10;
			t=t/10;
		}
		if(s1>=a && s1<=b){
			s+=i;
		}
	}
	cout<<s<<endl;
	
	return 0;
}

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

using namespace std;


int mod(int a, int b){
    int c;
    while (a%b != 0) {
        c = a%b;
        a = b;
        b = c;
    }
    return b;
}


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



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;

int main() {
    long long N,V=0,a;
	cin >> N;
    vector<long long> T(N),U(N+1);
	for (size_t i = 0; i < N; i++)
	{
		cin >> T.at(i);
		U.at(T.at(i))++;
	}
	for (size_t i = 0; i < N+1; i++)
	{
		if(U.at(i)>=2)V += U.at(i) * (U.at(i) - 1) / 2;
	}
	for (size_t i = 0; i < N; i++)
	{
		if (U.at(T.at(i)) == 1)cout << V<<endl;
		else if (U.at(T.at(i)) == 2)cout << V - 1<<endl;
		else cout << V - U.at(T.at(i))+1<<endl;
	}
}

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

int main(){
  int a,b ;
  cin >> a >> b ;  
  if((a+b)%2==0){
    cout << (a+b)/2 << endl;
  }
  
  else{
    cout << (a+b+1)/2 << endl;
  }
}
  


Measured memory_bytes: 3636