akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,cnt=0,ans=0,buf=0;
  int a;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    if(buf==0){
      buf = a;
      cnt = 1;
    }
    else{
      if(buf!=a){
        if(cnt>1){
          ans += cnt/2;
        }
        cnt = 1;
        buf = a;
      }else if(buf==a){
        cnt++;
      }
    }
  }
  if(cnt>1){
    ans += cnt/2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
void main() {
	auto ip = readAs!(int[]), sx = ip[0], sy = ip[1], tx = ip[2], ty = ip[3];
	auto dx = tx-sx, dy = ty-sy;

	'U'.repeat(dy).write;
	'R'.repeat(dx).write;
	'D'.repeat(dy).write;
	'L'.repeat(dx+1).write;

	'U'.repeat(dy+1).write;
	'R'.repeat(dx+1).write;
	'D'.write;
	'R'.write;
	'D'.repeat(dy+1).write;
	'L'.repeat(dx+1).write;
	'U'.write;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(n):
    ans += a[i]
q = int(input())
p = []
for i in range(q):
    b,c = map(int,input().split())
    p.append([b,c])
from collections import defaultdict
d = defaultdict(int)
for i in range(n):
    d[a[i]] += 1
for i in range(q):
    ans = ans+(p[i][1]-p[i][0])*d[p[i][0]]
    print(ans)
    d[p[i][1]] += d[p[i][0]]
    d[p[i][0]] = 0

Measured memory_bytes: 36816
#include <iostream>

using namespace std ;

int main()
{
    int a , b , res ;
    while ( cin >> a >> b )
    {
        if ( a > b )
            res = 2 * a - 1 ;
        else if ( a == b )
            res = 2 * a ;
        else res = 2 * b - 1 ;
        cout << res << endl ;
    }
    return 0 ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    ll N,K;
    cin >> N >> K;
    if(K % 2 == 0) {
        ll cnt = max(0ll,(N + K / 2) / K);
        cout << (N / K) * (N / K) * (N / K) + cnt * cnt * cnt << endl;
    }
    else {
        cout << (N / K) * (N / K) * (N / K) << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using  namespace std;
#define rep(i,s,n) for(int i=s;i<n;i++)

vector<vector<int> > map(14,vector<int> (14,0));
	int dx[]={1,-1,0,0 };
	int dy[]={0,0,1,-1 };
void dfs(int x,int y){
	map[x][y] =0;
	for(int i=0;i<4;i++){
		int nx = x+dx[i],ny = y+dy[i];
		if(map[nx][ny]==1)dfs(nx,ny);
	}
	return;
}
int main(){
	char a;
	while(cin>>a){
		map[1][1] =a-'0';
		for(int i=2;i<13;i++)cin>>a,map[1][i]=a-'0';
		rep(i,2,13)rep(j,1,13)cin>>a,map[i][j]=a-'0';
		int ans = 0;
		rep(i,1,13)rep(j,1,13){
		if(map[i][j]){
		ans++;
		dfs(i,j);
		}

		}
		cout<<ans<<endl;
	}

	return 0;

}



Measured memory_bytes: 3040
#include<iostream>
using namespace std;
int a[(int)1e5+1],n,k;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;++i)cin>>a[i];
	int ans=(n-1+k-2)/(k-1);
	cout<<ans;
        return 0;
}


Measured memory_bytes: 640
n, x = map(int, input().split())
a = [0] + list(map(int, input().split()))

ans = 0
for i in range(n):
    if a[i] + a[i+1] > x:
        diff = (a[i] + a[i+1]) - x
        ans += diff
        a[i+1] -= diff
print(ans)


Measured memory_bytes: 14132
import math

(n, d) = list(map(int, input().split(' ')))
pairs = (list(map(int, input().split(' '))) for i in range(n))

count = 0

for pair in pairs:
    dist = math.sqrt(pair[0]**2 + pair[1]**2)
    if dist <= d:
        count += 1

print(count)

Measured memory_bytes: 9104
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
//const double EPS = 1e(-12);
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

int par[100010], rank_tree[100010];
void init()
{
    for (int i = 0; i < 100010; ++i)
    {
        par[i] = i;
        rank_tree[i] = 0;
    }
}
int root(int x)
{
    return par[x] == x ? x : par[x] = root(par[x]);
}

bool same(int x, int y)
{
    return root(x) == root(y);
}

void unite(int x, int y)
{
    x = root(x);
    y = root(y);
    if (x == y)
        return;

    if (rank_tree[x] < rank_tree[y])
    {
        par[x] = y;
    }
    else
    {
        par[y] = x;
        if (rank_tree[x] == rank_tree[y])
            rank_tree[x]++;
    }
}

int arr[100010];

int X[100010];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);
    init();
    int N, M;
    cin >> N >> M;

    for (int i = 0; i < N; ++i)
    {
        X[i] = 1;
    }
    arr[0] = 1;
    for (int i = 0; i < M; ++i)
    {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        if (arr[x] == 1 && X[x] == 1)
        {
            arr[x] = 0;
            X[x] = 0;
            arr[y] = 1;
            X[y]++;
                }
        else if (arr[x] == 1 && X[x] != 1)
        {
            arr[y] = 1;
            X[x]--;
            X[y]++;
        }
        else if (arr[x] != 1)
        {
            X[x]--;
            X[y]++;
        }
    }
    int ans = 0;
    for (int i = 0; i < N; ++i)
        if (arr[i] == 1)
            ans++;

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

Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    double x;
    cin >> x;
    double pi = acos(-1.0);
    printf("%.15f\n", 2 * x * pi);
    return 0;
}


Measured memory_bytes: 3776
import java.lang.Long.min
import java.lang.Math.abs


fun main (args:Array<String>) {
    var (N, K) = readLine()!!.split(" ").map(String::toLong)
    var minResult = N
    if (N > K) {
        N = N % K
        minResult = N
    }
    while (true) {
        N = abs(N - K)
        if (minResult == N) {
            break
        }
        minResult = min(N, minResult)
    }
    print(minResult)
}


Measured memory_bytes: 36468
s=input()
sf=int(s[:2])
sl=int(s[2:])
#print(int(sf)+int(sl))
if (1<= sf <=12 and 1<=sl <=12):
  print("AMBIGUOUS")
elif 1<= sf <=12:
  print("MMYY")
elif 1<= sl <=12:
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n, a[20], b[20], c[19];

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; a[i]--; }
	inc(i, n) { cin >> b[i]; }
	inc(i, n - 1) { cin >> c[i]; }
	
	int ans = 0;
	inc(i, n) { ans += b[a[i]]; }
	inc(i, n - 1) { if(a[i] + 1 == a[i + 1]) { ans += c[a[i]]; } }
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
def s(n):
    ret = 0
    while n > 0:
        ret += n % 10
        n //= 10
    return ret

numbers = [999999999999999999]
while numbers[-1] > 1:
    for d in range(0, 100):
        n = numbers[-1]
        m = n - 10 ** d
        if n * s(m) >= m * s(n):
            numbers.append(m)
            break
numbers = list(reversed(numbers))

n = int(input())
for i in range(n):
    print(numbers[i])


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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
#define test cout<<"test"<<endl;
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
const ll zero=0;
using P = pair<ll, ll>;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  bool judge = true;
  ll n,a,b;cin>>n>>a>>b;
  cout<<min(b,n*a)<<endl;

  return 0;
}

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

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

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int a,b;cin>>a>>b;
  int ans=0;
  if(a>b){
    ans+=a;
    a--;
  }else{
    ans+=b;
    b--;
  }
  if(a>b){
    ans+=a;
    a--;
  }else{
    ans+=b;
    b--;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long LL;
int main()
{
    LL N, M, K;
    cin >> N >> M >> K;
    bool found = false;
    for(LL A = 0; A <= M; A++)
        for(LL B = 0; B <= N; B++)
            if(A*N + B*M - 2*A*B == K)
            {
                found = true;
                break;
            }
            
    if(found)
        cout<<"Yes"<<endl;
    else    
        cout<<"No"<<endl;
    return 0;
}

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

typedef long long ll;
const ll xxx=2.25e8+10,mod=1e9+7;
ll s,res;
char digit[xxx];

inline ll qpow(ll a,ll n){
	ll res=1;
	for(;n;n>>=1,a=a*a%mod)
		if(n&1ll)
			res=res*a%mod;
	return res;
}

int main(){
	cin>>s;
	for(int i=1,j=1;i<xxx;i*=10,++j)
		digit[i]=j;
	for(int i=1;i<xxx;++i)
		if(!digit[i])
			digit[i]=digit[i-1];
	for(int l=1,r=1,now=1;l<10000000;now-=digit[l],++l){
		while(now+digit[r+1]<=s)
			++r,now+=digit[r];
		if(now==s)
			++res;
	}
	for(int i=2;i<=s;++i){
		int l=s/i,r=s%i;
		if(l>=8&&r)
			++res;
	}
	for(int i=8;i<=s>>1;++i)
		if(s/i*i==s)
			res=(res+9*qpow(10,i-1)-s/i+1)%mod;
	if(s>=8)
		res=(res+9*qpow(10,s-1))%mod;
	res%=mod;
	res=(res%mod+mod)%mod;
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 220032
n, k = map(int, input().split())
h = list(map(int, input().split()))

if k >= n:
    print(h[-1]-h[0])
    exit()
dp = [0] * n
dp[0] = 0
for i in range(1, k):
    dp[i] = abs(h[0]-h[i])

for i in range(k, len(dp)):
    dp[i] = min(abs(h[i]-h[i-j])+dp[i-j] for j in range(1, k+1))
print(dp[-1])



Measured memory_bytes: 53344
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int ac = 0, wa = 0, tle = 0, re = 0;
		int n = in.nextInt();
		for (int i = 0; i < n; i++) {
			String s = in.next();
			if (s.equals("AC"))
				ac++;
			else if (s.equals("WA"))
				wa++;
			else if (s.equals("TLE"))
				tle++;
			else if (s.equals("RE"))
				re++;
		}
		System.out.println("AC x " + ac);
		System.out.println("WA x " + wa);
		System.out.println("TLE x " + tle);
		System.out.println("RE x " + re);
	}

}


Measured memory_bytes: 58864
import sys
sys.setrecursionlimit(500*500)

N = int(input())
UVW = [list(map(int, input().split())) for _ in range(N-1)]

nbors = [[] for _ in range(N+1)]
for uvw in UVW:
    u,v,w = uvw[0], uvw[1], uvw[2]
    nbors[u].append((v, w))
    nbors[v].append((u, w))

dist = [-1] * (N+1)
dist[1] = 0
def dfs(now, nxt, w):
    if dist[nxt] >= 0:
        return
    dist[nxt] = dist[now] + w
    for nbor in nbors[nxt]:
        nxt2, w = nbor[0], nbor[1]
        dfs(nxt, nxt2, w)

for nbor in nbors[1]:
    nxt, w = nbor[0], nbor[1]
    dfs(1, nxt, w)

for i in range(1, N+1):
    if dist[i] % 2 == 0:
        print(0)
    else:
        print(1)


Measured memory_bytes: 153816
N = int(input())
U = [ input() for _ in range(N)]

M = int(input())
is_lock = True

for _ in range(M):
    T = input()
    if T not in U:
       print("Unknown %s" % T)
    elif is_lock:
       is_lock = False
       print("Opened by %s" % T)
    else:
       is_lock = True
       print("Closed by %s" % T)


Measured memory_bytes: 5608
def prime?(n)
  if 2 == n
    return true
  elsif n % 2 == 0
    return false
  else
    3.step(Math.sqrt(n).floor, 2) do |i|
      return false if n % i == 0
    end
    return true
  end
end

n = gets.to_i
cnt = 0
n.times do |i|
  cnt += 1 if prime?(gets.to_i)
end
puts cnt

Measured memory_bytes: 8784
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using vi = vector<int>;
using vl = vector<int64_t>;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

const int INF = 1e9;
vector<int> graph[303030];

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

  int n, m; cin >> n >> m;
  vector<int> u(m), v(m);
  rep(i, m) {
    cin >> u[i] >> v[i];
    --u[i]; --v[i];
    graph[u[i] * 3].push_back(v[i] * 3 + 1);
    graph[u[i] * 3 + 1].push_back(v[i] * 3 + 2);
    graph[u[i] * 3 + 2].push_back(v[i] * 3);
  }
  int s, t; cin >> s >> t; --s; --t;

  int dis[303030];
  fill(dis, dis + 303030, INF);

  dis[s * 3] = 0;

  queue<int> q;
  q.push(s * 3);

  while (!q.empty()) {
    int now = q.front(); q.pop();
    for (auto next : graph[now]) {
      if (dis[next] != INF) {
        continue;
      } else {
        dis[next] = dis[now] + 1;
        q.push(next);
      }
    }
  }

  if (dis[t * 3] == INF) {
    print(-1);
  } else {
    print(dis[t * 3] / 3);
  }

  return 0;
}

Measured memory_bytes: 18688
import math
def A():
    num = int(input())
    odd_nums = math.ceil(num/2.0)
    print(odd_nums/num)

def B():
    temp = [int(i) for i in input().split()]
    N = temp[0]
    K = temp[1]
    heights = [int(i) for i in input().split()]
    ans = 0
    for h in heights:
        ans += 1 if h >= K else 0
    print(ans)

def C():
    N = int(input())
    A = list(enumerate([int(i) for i in input().split()]))
    A.sort(key = lambda x: x[1])
    #print(A)
    print(' '.join([str(a+1) for a, i in A]))

C()


Measured memory_bytes: 24148
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int N = in.nextInt();
            long A[] = CPUtils.readLongArray(N, in);
            long answer = 1;
            for (long a : A)
            {
                if (a == 0)
                {
                    out.println(0);
                    return;
                }
            }
            BigDecimal bigDecimal = new BigDecimal("1");
            for (long a : A)
            {
                bigDecimal = bigDecimal.multiply(new BigDecimal("" + a));
                if (bigDecimal.compareTo(new BigDecimal("" + 1000000000000000000L)) > 0)
                {
                    out.println(-1);
                    return;
                }
            }
            out.println(bigDecimal.toString());
        }

    }

    static class CPUtils
    {
        public static long[] readLongArray(int size, Scanner in)
        {
            long[] array = new long[size];
            for (int i = 0; i < size; i++)
            {
                array[i] = in.nextLong();
            }
            return array;
        }

    }
}



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

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

#define loop(i, n) for(int i = 0;i < n;i++)
#define INF 1000000000

int n, m, x;

int ans = INF;


void dfs(int i, vector<int> c, vector<vector<int>> a, int total, vector<int> check){
    bool ok = true;
    loop(j, m){
        if(check[j] < x) ok = false;
    }
    if(ok) ans = min(ans, total);

    if(i == n) return;

    dfs(i+1, c, a, total, check);

    loop(j, m){
        check[j] += a[i][j];
    }
    total += c[i];
    dfs(i+1, c, a, total, check);

    
}

int main(void){

    cin >> n >> m >> x;

    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    vector<int> check(m);
    loop(i, n){
        cin >> c[i];
        loop(j, m){
            cin >> a[i][j];
        }
    }

    dfs(0, c, a, 0, check);

    if(ans == INF){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x, y;
    cin >> x >> y;
    int b = y - 2 * x;
    if (b < 0 || b % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }
    int a = x - b / 2;
    if (a >= 0) {
        cout << "Yes" << endl;

    }
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
map<int,int> m;
vector<int> v;
int main(){
    int n,ans;
    cin>>n;
    for(int i=1;i<=n;++i){
        int x;
        cin>>x;
        if(m[x]==0){
            v.push_back(x);
        }
        ++m[x];
    }
    for(register int i=0;i<v.size();i++){
        if(m[v[i]]>=v[i]){
            ans+=m[v[i]]-v[i]; 
        }
        else{
            ans+=m[v[i]];
        }
    } 
    cout<<ans;
    return 0;
}

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

char a[100][101], b[102][102];
int main(){
  int H,W;
  cin>>H>>W;
  
  for(int i=0;i<H;i++) cin>>a[i];
  
  for(int i=0;i<H+2;i++){
  	for(int j=0;j<W+2;j++){
   		b[i][j]='#';
    }
  }
  for(int i=0;i<H;i++){
  	for(int j=0;j<W;j++){
   		b[i+1][j+1]=a[i][j];
    }
  }
  for(int i=0;i<H+2;i++){
  	for(int j=0;j<W+2;j++){
      cout<<b[i][j];
    }
    cout<<endl;
  }
  
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  int l[n];
  rep(i,0,n) cin>>l[i];
  int ma=0;
  int sum=0;
  rep(i,0,n){
    ma=max(ma,l[i]);
    sum+=l[i];
  }
  if(sum-ma>ma) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
N = int(input()) + 1
nums_count = 0
for i in range(1, N):
    if i % 2 == 0:
        continue
    count = 1
    for j in range(1, int(i / 3) + 1):  # 8なら1,2,4,8で、1~4までやれば良い。最後に自分をたす あれ、もしかしてN/3?
        if i % j == 0:
            count += 1
    if count == 8:
        nums_count += 1

print(nums_count)


Measured memory_bytes: 38512
#!/usr/bin/env python3

N = int(input())

F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]

ans = float("inf") * -1

for i in range(1, 2 ** 10):
    idx = []
    times = []
    for j in range(10):
        if i >> j & 1 == 1:
            idx.append(j)
    for f in F:
        total = 0
        for i in idx:
            if f[i]:
                total += 1
        times.append(total)
    bft = 0
    for p, t in zip(P, times):
        bft += p[t]
    ans = max(bft, ans)

print(ans)

Measured memory_bytes: 43500
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = readLine >>= print . solve 

-- |
-- >>> solve [1,6]
-- 2
-- >>> solve [12345,678901]
-- 175897
solve :: [Int] -> Int 
solve [n, m] 
    | m < 2 * n = m `div` 2
    | otherwise = n + (m - 2 * n) `div` 4


readLine :: IO [Int]
readLine = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 380
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
int w, h;
const int mod = 100000;
int dp[101][101][2][2];

int main(int argc, char const* argv[])
{
  dp[0][0][0][0] = 1;
  dp[0][0][1][0] = 1;
  dp[0][0][0][1] = 0;
  dp[0][0][1][1] = 0;
  for(int i = 0; i < 101; i++){
    for(int j = 0; j < 101; j++){
      if(i == 0 && j == 0)continue;
      if(i > 0)dp[i][j][0][0] = (dp[i-1][j][0][0] + dp[i-1][j][0][1]) % mod;
      else dp[i][j][0][0] = 0;
      if(j > 0)dp[i][j][1][0] = (dp[i][j-1][1][0] + dp[i][j-1][1][1]) % mod;
      else dp[i][j][1][0] = 0;
      if(i > 0 && !(i == 1 && j == 0))dp[i][j][0][1] = dp[i-1][j][1][0];
      else dp[i][j][0][1] = 0;
      if(j > 0 && !(j == 1 && i == 0))dp[i][j][1][1] = dp[i][j-1][0][0];
      else dp[i][j][1][1] = 0;
    }
  }
  while(true){
    cin >> w >> h;
    if(w == 0)break;
    cout << (dp[w-1][h-1][0][0] + dp[w-1][h-1][1][0] + dp[w-1][h-1][0][1] + dp[w-1][h-1][1][1]) % mod << endl;
  }
	return 0;
}



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

typedef pair<int,int> P;

unsigned int dp[101][101];

int main(void){
  int n; cin>>n;
  vector<P> v(n);
  rep(i,n) cin>>v[i].first>>v[i].second;

  erep(i,n){
    erep(j,n) dp[i][j] = INT_MAX;
    dp[i][i] = 0;
  }

  REP(i,1,n){ //???????±????
    EREP(j,0,n-i){ //????§???????????±????
      REP(k,j,j+i){ //????????????????±????
        int cost = v[j].first * v[k].second * v[k+1].first * v[j+i].second;
        dp[j][j+i] = min(dp[j][j+i],cost+dp[j][k]+dp[k+1][j+i]);
      }
    }
  }

  cout<<dp[0][n-1]<<endl;

  return 0;
}

Measured memory_bytes: 3044
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int MAX=2e5+5;

int main(){
	int N;
	cin>>N;
	int k=-1;
	rep1(i,500){
		if((i*(i-1))/2==N)k=i;
	}
	if(k==-1)cout<<"No"<<endl;
	else{
      	cout<<"Yes"<<endl;
      	cout<<k<<endl;
		vi S[500];
		int ind=1;
		rep(i,k)rep(j,k)if(i<j){
			S[i].push_back(ind);
			S[j].push_back(ind);
			ind++;
		}
		rep(i,k){
			cout<<sz(S[i])<<" ";
			rep(j,sz(S[i]))cout<<S[i][j]<<" ";
			cout<<endl;
		}
	}
}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main() {
    int N;
    cin >> N;
    int h[N];
    rep(i,N) {
        int tmp;
        cin >> tmp;
        h[i] = tmp;
    }
    int ans = 0;
    while(1) {
        int cnt = 0;
        bool c = false;
        rep(i,N) {
            if(!c && h[i]>0) {
                cnt++;
                c=true;
            } 
            else if (c && h[i]==0) {
                c=false;
            }
            
            if (h[i]>0) h[i]--;
        }
        ans += cnt;
        if (cnt==0) {
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int N,x,y,cnt;
	scanf("%d",&N);
	x = N * 800;
	cnt = N / 15;
	y = cnt * 200;
	printf("%d\n",x - y);
	return 0;
}


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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

VI dp[100010];
//素数ならtrue
bool prime[100010];
VI p;
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

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

  if(k == 0) {
    cout << n*n << endl;
    return 0;
  }

  // int deb = 0;
  // FOR(i, 1, n+1) {
  //   FOR(j, 1, n+1) {
  //     cout << i%j << " ";
  //     if(i%j >= k) deb++;
  //   }
  //   cout << endl;
  // }
  // cout << deb << endl;

  int ans = 0;
  FOR(i, 1, n+1) {
    if(i-1 >= k) {
      ans += n/i*(i-k);
      ans += max(0LL, (n%i) - k + 1);
    }
  }
  cout << ans << endl;
  return 0;

  memset(prime, true, sizeof(prime));
  prime[0] = prime[1] = false;
  for (int i = 2; i * i <= 100010; i++) {
    if (prime[i]) {
      p.PB(i);
      for (int j = 2 * i; j <= 100010; j += i) {
        prime[j] = false;
      }
    }
  }

  // int ans = 0;
  FOR(i, 1, n+1) {
    REP(j, p.size()) {
      if(p[j] >= i) break;
      // iをp[j]で割る
      int tmp = i%p[j];
      cout << tmp << " ";
      if(tmp >= k) ans += i/p[j];
    }
    cout << endl;
    if(i >= k) ans += (n-i);
    cout << i << " " << ans << endl;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
int H, W;
vector<string> G;
vector<vector<int>> A;
deque<tuple<int,int,int>> Q;

tuple<int,int,int> bfs(int sx, int sy) {
    int dx[] = { 1, 0, -1, 0};
    int dy[] = { 0, 1,  0,-1};
    Q.push_front({sx,sy,0});
    int ma = 0; int px, py;
    while(!Q.empty()) {
        auto [x,y,cnt] = Q.front(); Q.pop_front();
        if (ma < cnt) ma = cnt, px = x, py = y;
        rep(i,4) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (nx < 0 || nx >= W) continue;
            if (ny < 0 || ny >= H) continue;
            if (G[ny][nx] == '#') continue;
            if (A[ny][nx] <= cnt + 1) continue;
            A[ny][nx] = cnt + 1;
            Q.push_back({nx, ny, cnt+1});
        }
    }
    /*
    printf("=====================================================\n");
    rep(i,H) {
        rep(j,W) if (A[i][j] == INT32_MAX) printf("## "); else printf("%2d ", A[i][j]);
        printf("\n");
    }
    */
    return make_tuple(px, py, ma);
}

int main() {
    cin >> H >> W;
    G.assign(H,"");
    rep(i,H) cin >> G.at(i);
    int ma = 0, mi = INT32_MAX;
    rep(sy,H) rep(sx,W) {
        if (G[sy][sx] == '#') continue;
        A.assign(H, vector<int>(W,INT32_MAX));
        A[sy][sx] = 0;
        Q.clear();
        auto [px, py, _] = bfs(sx, sy);
        A.assign(H, vector<int>(W,INT32_MAX));
        A[py][px] = 0;
        auto [_1, _2, cnt] = bfs(px, py);
        if (ma < cnt) ma = cnt;
        if (mi > cnt) mi = cnt;
    }
    cout << ma << endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define mod 1000000007
#define fr first
#define val second
#define N 100000000
#define fo(i,m,n) for(int i=m;i<n;i++)
#define M 7
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=long long;
using ul=unsigned long long;
using pii=pair<int,int>;
using vvi=vector<vector<int>>;
using vi=vector<int>;
using pll=pair<ll,ll>;
using vsi=vector<set<int>>;
using vll=vector<ll>;

ll power(ll a,ll n){
    ll j=0;
    ll x=1;
    while(1ll<<j<=n){
        if(1ll<<j&n)
            x=(x*a)%mod;

        a=a*a%mod;
        j++;
    }

    return x;
}

int gcd(int a,int b){
    if(b==0)
        return a;
    else
        return gcd(b,a%b);

}

int lb(vi &a,int x){
    int n=a.size();
    int l=0;
    int r=n-1;
    int ind=-1;
    while(l<=r){
        int mid=(l+r)/2;
        if(x>=a[mid]){
            l=mid+1;
            ind=mid;
        }
        else
            r=mid-1;

    }

    return ind+1;

}

int up(vll &a,ll x){
    int n=a.size();
    int l=0;
    int r=n-1;
    int ind=-1;

    while(l<=r){
        int mid=(l+r)/2;

        if(a[mid]>x){
            l=mid+1;
            ind=mid;
        }
        else
            r=mid-1;

    }

    return ind;
}

ll max(ll a,ll b){
    if(a>b)
        return a;
    else
        return b;

}

ll min(ll a, ll b){
    if(a>b)
        return b;
    else
        return a;

}
template<typename T>
void pra(T a[],int n){
    fo(i,0,n)
            cout<<a[i]<<' ';
    cout<<endl;

}

ifstream input;
ofstream output;
int t;
const ll inf=1e16;
int cs;
int tcs;
void build(vll &F,int ind,int tl,int tr,vll &st){

    if(tl==tr)
        st[ind]=F[tl];
    else{
        int mid=(tl+tr)/2;
        build(F,2*ind+1,tl,mid,st);
        build(F,2*ind+2,mid+1,tr,st);
        st[ind]=min(st[2*ind+1],st[2*ind+2]);
    }

}

void update(int j,ll nv,int ind,int tl,int tr,vll &st){

    if(j<tl||j>tr)
        return;
    else if(tl==tr)
        st[ind]=nv;
    else{
        int mid=(tl+tr)/2;
        update(j,nv,2*ind+1,tl,mid,st);
        update(j,nv,2*ind+2,mid+1,tr,st);
        st[ind]=min(st[2*ind+1],st[2*ind+2]);
    }

}


ll query(int ind,int tl,int tr,int l,int r,vll &st){
    int mid=(tl+tr)/2;
    if(r<tl||l>tr)
        return inf;
    else if(tl==l&&tr==r)
        return st[ind];
    else
        return min(query(2*ind+1,tl,mid,l,min(mid,r),st),query(2*ind+2,mid+1,tr,max(mid+1,l),r,st));

}

int main(){

    ll n,k;
    cin>>n>>k;

    int a[n];
    fo(i,0,n)
            cin>>a[i];

    sort(a,a+n);
    ll l=1;
    ll r=1e9;
    ll ans=a[n-1];

    while(l<=r){
        int mid=(l+r)/2;
        int k1=k;
        fo(i,0,n)
            k1-=a[i]/mid+(a[i]%mid?1:0)-1;
        //cout<<mid<<' '<<k1<<endl;
        if(k1<0)
            l=mid+1;
        else{
            ans=mid;
            r=mid-1;
        }
    }

    cout<<ans<<endl;

}


Measured memory_bytes: 4344
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long a[4],ans=-0x3f3f3f3f3f3f3f3f;
    cin>>a[0]>>a[1]>>a[2]>>a[3];
    for (int i=0; i<=1; i++) {
        for (int j=2; j<=3; j++) {
            ans=max(ans,a[i]*a[j]);
        }
    }
    cout<<ans<<'\n';
}

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

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

    int res = 0;
    for(int i = 1; i < n-1; i++){
        string t = s.substr(0,i);
        string u = s.substr(i);
        bool first[26] = {};
        bool second[26] = {};

        for(int j = 0; j < i; j++){
            first[t[j]-'a'] = true;
        }

        for(int j = 0; j < n-i; j++){
            second[u[j]-'a'] = true;
        }

        int ans = 0;
        for(int j = 0; j < 26; j++){
            if(first[j] && second[j]){
                ans++;
            }   
        } 

        res = max(res, ans);
    }

    cout << res << endl;
    return 0;
}

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

int main(){
    int k;
    cin >> k;
    int x = 7 % k;
    set<int> s;

    int i = 1;

    while(s.count(x) == 0){
        if(x == 0){
            cout << i << endl;
            return 0;
        }
        s.insert(x);
        x = (x * 10+ 7) % k;
        ++i;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 50448
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(N):
  n = a[i]
  ans.append(n-1)
  ans.append(n)
  ans.append(n+1)
  
c = Counter(ans)
m = c.most_common()
print(m[0][1])

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N;
    cin >> N;
    vector<LP> v(N);
    for(int i = 0; i < N; ++i) {
        cin >> v[i].F;
        v[i].S = -(i + 1);
    }
    sort(all(v), greater<P>());

    for(int i = 0; i < N; ++i) {
        v[i].S = -v[i].S;
    }

    LL cnt[SIZE] = {};
    LL mn_pos = v[0].S;
    LL mpos = 0;
    LL sum = 0;
    for(int i = 0; i < N; ++i) {
        if(v[mpos].S > v[i].S) {
            cnt[mn_pos] += sum - (v[i].F * i);
            sum = v[i].F * i;
            mn_pos = v[i].S;
            mpos = i;
        }
        sum += v[i].F;
    }
    cnt[mn_pos] += sum;

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


    return 0;
}



Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    int a,b,c,d; cin >> a >> b >> c >> d;
    if(a+b > c+d) cout << "Left" << endl;
    else if (a+b == c+d) cout << "Balanced" << endl;
    else cout << "Right" << endl; 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	vector<int> B;
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	B = A;
	sort(A.begin(), A.end());
	for (int i = 0; i < N; i++) {

		if (B[i] <= A[(N / 2) - 1]) {
			cout << A[(N / 2)] << endl;
		}
		else {
			cout << A[(N / 2) - 1] << endl;
		}
	}
	
}

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

const int MOD = 1e9+7;

string s;
int d;

int memo[10005][105][3];

int dp(int idx, int tot, int stat){
   if(idx>=s.size()){
      if(tot == 0) return 1;
      else return 0;
   }
   int &ret = memo[idx][tot][stat];
   if(ret!=-1) return ret;
   ret = 0;
   for(int i=0;i<10;i++){
      if(stat == 0 && i>s[idx]-'0') break;
      if(s[idx]-'0' == i && stat == 0) ret+= dp(idx+1,(tot+i)%d,0);
      else ret+= dp(idx+1,(tot+i)%d,1);
      ret%=MOD;
   }
   return ret;
}

int main(){
   memset(memo,-1,sizeof(memo));
   cin >> s;
   cin >> d;
   int ans = dp(0,0,0);
   printf("%d\n",(ans+MOD-1)%MOD);
	return 0;
}


Measured memory_bytes: 13312
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

str s;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>s;
    int ans = 700;
    for(int i=0;i<s.size();i++){
        if(s[i]=='o')ans+=100;
    }
    cout<<ans<<newl;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

ll gcdf(ll a, ll b)
{
    if(a < b) swap(a,b);
    while(a%b){
        ll tmp = a%b;
        a = b;
        b = tmp;
    }
    return b;
}

int main()
{
    ll i,j;
    ll n,k;
    cin >> n >> k;
    ll tmp;
    ll m = 0;
    cin >> tmp;
    m = max(m,tmp);
    for(i = 1;i < n;++i){
        ll a;
        cin >> a;
        m = max(m, a);
        tmp = gcdf(tmp, a);
    }
    if(k > m || k%tmp) cout << "IMPOSSIBLE" << endl;
    else cout << "POSSIBLE" << endl;

    return 0;
}

Measured memory_bytes: 256
let split str delim =
  let rec doit s acc =
    match
      try Some (String.index s delim)
      with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s2 (s1 :: acc)
  in
  List.rev (doit str [])

let () =
  let l = read_line () in
  match List.map int_of_string (split l ' ') with
  | [] | [_] | _::_::[] -> exit 1
  | a :: b :: c :: _ -> begin
      let n = ref 0 in
      for i = a to b do
        if c mod i = 0 then n := !n + 1
      done;
      Printf.printf "%d\n" !n
    end

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

int main() {
   string S;
   cin>>S;
   int N=S.size()-1;
   long long result=0;

   for(long long i=0;i<(1<<N);i++){
      vector<int> output;
      for(int j=0;j<N;j++){
         if((i>>j)&1)
            output.push_back(j);
      }
      output.push_back(S.size());

      int i_0=0;
      for(int x:output){
         int i_1=x+1-i_0;
         long long SS;
         istringstream(S.substr(i_0,i_1))>>SS;
         result+=SS;
         i_0=x+1;
      }
   }
   cout<<result<<endl;
}

Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig

def main():
    sys.setrecursionlimit(10 ** 7)
    inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; cnt = 0; ansli = []; tmpli = []; candili = []; stillset = set()
    eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
    dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
    """for dx, dy in dd:
            nx = j + dx; ny = i + dy
                if 0 <= nx < w and 0 <= ny < h:"""
    def wi(): return list(map(int, sys.stdin.readline().split()))
    def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
    def ws(): return sys.stdin.readline().split()
    def i(): return int(sys.stdin.readline())
    def s(): return input()
    def s_list(): return list(input())
    def hi(n): return [i() for _ in range(n)]
    def hs(n): return [s() for _ in range(n)]#HeightString
    def mi(n): return [wi() for _ in range(n)]#MatrixInt
    def num__grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]#NumberGrid
    def mip(n): return [wip() for _ in range(n)]
    def ms(n): return [ws() for _ in range(n)]
    def grid(n): return [s_list() for _ in range(n)]

    S = s()
    T = s()
    for i in range(3):
        if S[i] == T[i]:
            ans += 1
    print(ans)





if __name__ == '__main__':
    main()

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

int main(){
  double N,T,A;
  cin >> N >> T >> A;
  
  double min_dif = 1000;
  int ans;
  for ( int i = 0 ; i < N ; i++ ){
  	double h;
    cin >> h;
    double h_temp = T - h*0.006 ;
    
    min_dif = min( min_dif , abs(A-h_temp) );
    if ( min_dif ==  abs( A - h_temp))
      ans = i+1;
  }  
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import math
from pprint import pprint

A, B, N = map(int, sys.stdin.readline().strip().split())

def func(x):
    # return math.floor(A*x/B) - A*math.floor(x/B)
    return A*x//B - A*(x//B)

print(func(min(B-1, N)))

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

int calc(int x){
  int ret =0;
  while(x % 100 == 0){
    x/=100;
    ret++;
  }
  return ret;
}

int main(){
  int D,N;
  cin >> D >> N;
  int cnt = 0,val = 0;
  while(cnt< N){
    val++;
    if(calc(val)==D)cnt++;
  }
    cout <<  val << endl;
  }


Measured memory_bytes: 256