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

int main() {
  int H,W;
  cin >> H >> W;
  vector<vector<char>> data(H,vector<char>(W));
  
  for(int i=0;i<H;i++){
    
    for(int j=0;j<W;j++){
      cin >> data.at(i).at(j);
      
    }
  }
  
  vector<int> ver(H,0);
  vector<int> sid(W,0);
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(data.at(i).at(j) == '#'){
        break;
      }
      if(j==W-1){
        ver.at(i) = 1;
      }
    }
  }
  
  for(int i=0;i<W;i++){
    for(int j=0;j<H;j++){
      if(data.at(j).at(i) == '#')
        break;
      if(j==H-1)
        sid.at(i) = 1;
    }
  }
  
  for(int i=0;i<H;i++){
    
    if(ver.at(i))
      continue;
    
    for(int j=0;j<W;j++){
      
      if(sid.at(j))
        continue;
      else
        cout << data.at(i).at(j);
      
    }
    cout << endl;
  }
  
}


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

int main(){
	int n, k, q;
	scanf("%d%d%d", &n, &k, &q);
	int ans[q];
	for(int i=0; i<q; i++){
		scanf("%d", &ans[i]);
	}
	int player[n+1];
	for(int i=0; i<=n; i++){
		player[i]=0;
	}
	
	for(int i=0; i<q; i++){
		player[ans[i]]++;
	}
	
	int qk=q-k;
	for(int i=1; i<=n; i++){
		if(qk>=player[i]) printf("No\n");
		else printf("Yes\n");
	}
	
	return 0;
}

Measured memory_bytes: 1280
#D
n = int(input())
a = list(map(int,input().split()))

x = [0] * n
a_o = [a[i] for i in range(len(a)) if i % 2 == 1]
x[0] = sum(a) - 2*sum(a_o)

for i in range(1,n):
    x[i] = 2 *a[i-1] - x[i-1]
    
print(*x)

Measured memory_bytes: 14108
#include<stdio.h>
#include<math.h>
using namespace std;

struct Point 
{
    double x, y;
};

void koch(int n, Point a, Point b)
{
    if ( n == 0 ) return;
    Point s, u, t;
    double th = M_PI * 60.0 / 180.0;
    s.x = (a.x * 2.0 + 1.0*b.x)/3.0;

    s.y = (2.0*a.y + 1.0*b.y)/3.0;

    t.x = (1.0*a.x + 2.0*b.x)/3.0;

    t.y = (1.0*a.y + 2.0*b.y)/3.0;

    u.x = (t.x - s.x)*cos(th) - (t.y - s.y)*sin(th) + s.x;

    u.y = (t.x - s.x)*sin(th) + (t.y - s.y)*cos(th) + s.y;

    koch(n-1,a,s);

    printf("%.8f %.8f\n", s.x,s.y);

    koch(n-1,s,u);

    printf("%.8f %.8f\n", u.x,u.y);

    koch(n-1,u,t);

    printf("%.8f %.8f\n", t.x,t.y);

    koch(n-1,t,b);

}

int main() 
{
    Point a, b;
    int n;
    scanf("%d", &n);
    
    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;
    printf("%.8f %.8f\n",a.x,a.y);

    koch(n,a,b);

    printf("%.8f %.8f\n",b.x,b.y);

    return 0;
    
}

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

using namespace std;

int main(void)
{
    int N, M;
    cin >> N >> M;

    priority_queue<int> q;

    for (int i = 0; i < N; i++)
    {
        int n;
        cin >> n;
        q.push(n);
    }

    for (int i = 0; i < M; i++)
    {
        int n = q.top();
        q.pop();
        q.push(n / 2);
    }

    long sum = 0;
    for (int i = 0; i < N; i++)
    {
        sum += q.top();
        q.pop();
    }

    cout << sum << endl;

    return 0;
}

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

using namespace std;

using ll = long long;

// http://drken1215.hatenablog.com/entry/2019/03/20/202800
const int MAX_ROW = 60; // to be set appropriately
const int MAX_COL = 100005; // to be set appropriately
struct BitMatrix {
    int H, W;
    bitset<MAX_COL> val[MAX_ROW];
    BitMatrix(int m = 1, int n = 1) : H(m), W(n) {}
    inline bitset<MAX_COL>& operator [] (int i) {return val[i];}
};

int GaussJordan(BitMatrix &A, bool is_extended = false) {
    int rank = 0;
    for (int col = 0; col < A.W; ++col) {
        if (is_extended && col == A.W - 1) break;
        int pivot = -1;
        for (int row = rank; row < A.H; ++row) {
            if (A[row][col]) {
                pivot = row;
                break;
            }
        }
        if (pivot == -1) continue;
        swap(A[pivot], A[rank]);
        for (int row = 0; row < A.H; ++row) {
            if (row != rank && A[row][col]) A[row] ^= A[rank];
        }
        ++rank;
    }
    return rank;
}

int linear_equation(BitMatrix A, vector<int> b, vector<int> &res) {
    int m = A.H, n = A.W;
    BitMatrix M(m, n + 1);
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) M[i][j] = A[i][j];
        M[i][n] = b[i];
    }
    int rank = GaussJordan(M, true);

    // check if it has no solution
    for (int row = rank; row < m; ++row) if (M[row][n]) return -1;

    // answer
    res.assign(n, 0);
    for (int i = 0; i < rank; ++i) res[i] = M[i][n];
    return rank;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    ll all_xor = 0;
    ll all_or = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        all_xor ^= a[i];
        all_or |= a[i];
    }

    ll red = 0;
    vector<int> b;
    BitMatrix A(0, n);
    for (int i = 59; i >= 0; i--) {
        if (all_xor & (1LL << i)) {
            continue;
        }

        if (!(all_or & (1LL << i))) {
            continue;
        }

        b.push_back(1);
        for (int j = 0; j < n; j++) {
            if (a[j] & (1LL << i)) {
                A[A.H].set(j);
            }
        }
        A.H++;

        vector<int> res;
        int rank = linear_equation(A, b, res);
        if (rank == -1) b.back() = 0;
        else {
            red ^= (1LL << i);
        }
    }
    cout << (red + (all_xor ^ red)) << "\n";
    return 0;
}

Measured memory_bytes: 3704
from math import sqrt

c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))

d = sqrt((c1[0]-c2[0])**2 + (c1[1]-c2[1])**2)
lsum = c1[2] + c2[2]
lsub = abs(c1[2] - c2[2])

if d>lsum: print('4')
if d == lsum: print('3')
if lsub<d<lsum: print('2')
if d == lsub: print('1')
if d<lsub: print('0')



Measured memory_bytes: 5664
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let s: Vec<char> = itr.next().unwrap().chars().collect();
    if s[0] == s[2] {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int main() {
    int N;
    cin >> N;
    vector<vector<int>> D(N, vector<int>(2));
    for (int i = 0; i < N; i++) {
        cin >> D[i][0] >> D[i][1];
    }
    string ans = "No";
    for (int i = 0; i < N-2; i++) {
        if (D[i][0]==D[i][1] && D[i+1][0]==D[i+1][1] && D[i+2][0]==D[i+2][1]) {
            ans = "Yes";
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int main(){
	int n,m;
	while(cin>>n>>m,n+m){
		vector<pair<int,pii> >in(m);
		rep(i,m){
			cin>>in[i].second.first>>in[i].second.second>>in[i].first;
		}
		sort(all(in));
		vvi dp(n+1,vi(101,inf));//sum kei=cost
		dp[0][0]=0;
		rep(i,n)rep(j,101)rep(k,m){
			if(j<in[k].first)continue;
			int a=min(n,i+in[k].second.first);
			int b=min(100,j+in[k].second.second);
			dp[a][b]=min(dp[a][b],dp[i][j]+1);
		}
		int mi=inf;
		rep(i,101)mi=min(dp[n][i],mi);
		if(mi!=inf)cout<<mi<<endl;
		else cout<<"NA"<<endl;
//		rep(i,n+1){rep(j,20)if(dp[i][j]!=inf)printf("%3d",dp[i][j]);
//		else cout<<" "<<-1;cout<<endl;}
	}
}

Measured memory_bytes: 1264
#include<bits/stdc++.h>
#define sit set<int>::iterator 
#define rep(x, L, R) for(int x = (L), _x = (R); x <= _x; x++)
#define per(x, R, L) for(int x = (R), _x = (L); x >= _x; x--)
#define mpr make_pair
#define x(v) (v).first
#define y(v) (v).second
#define siz(v) (int)(v).size()
using namespace std;

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

const int N = 2e5 + 10;
int n;
int fa[N], siz[N], x[N], y[N];
set<int> s;
int t[N];
int find(int x)
{
	if(fa[x] == x) return x;
	return fa[x] = find(fa[x]);
}
void merge(int x, int y)
{
	x = find(x), y = find(y);
	if(x == y) return;
	fa[x] = y;
	siz[y] += siz[x];
	return;
}
int main()
{
	scanf("%d", &n);
	rep(i, 1, n) siz[i] = 1, fa[i] = i;
	rep(i, 1, n) scanf("%d%d", &x[i], &y[i]), t[x[i]] = y[i];
	rep(i, 1, n)
	{
		if(s.empty()) 
		{
			s.insert(t[i]);
			continue;
		}
		sit it = s.lower_bound(t[i]);
		if(it == s.begin()) 
		{
			s.insert(t[i]);
			continue;
		}
		vector<int> p;
		for(sit ti = s.begin(); ti != it; ti++)
		{
			p.push_back(*ti);
		}
		rep(j, 0, siz(p) - 2) merge(p[j + 1], p[j]);
		rep(j, 0, siz(p) - 1) s.erase(p[j]);
		merge(t[i], p[0]);
		s.insert(p[0]);
	}
	rep(i, 1, n) printf("%d\n", siz[find(y[i])]);
	return 0;
}

Measured memory_bytes: 12340
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int n;
int ans = 114514;

int getSum(int x) {
    int cnt = 0;
    while (x != 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}

int main() {
    cin >> n;
    for (int i = 1; i < n; i++) {
        ans = min(ans, getSum(i) + getSum(n - i));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define MAX 131072
#define B 100
#define dpb push_back
#define fi first
#define se second
typedef pair<int, int> P;
typedef long long ll;
const int inf = 1e9;
const ll INF = 2147483647;
//__gcd(a,b), __builtin_popcount(a);

int n;
ll dat[MAX*2], add[MAX*2];
void init(int m){
	n = 1;
	while(n < m)n *= 2;
	for(int i = 0;i < 2*n;i++)dat[i] = INF;
	for(int i = 0;i < 2*n;i++)add[i] = -1;
}

void lazy_update(int k){
	if(add[k] == -1)return;
	if(k < n-1){
		add[k*2+1] = add[k];
		add[k*2+2] = add[k];
	}
	add[k] = -1;
}

void update(int a, int b, int x, int k, int l, int r){
	if(r <= a || b <= l)return;
	if(a <= l && r <= b){
		add[k] = dat[k] = x;
		lazy_update(k);
		return;
	}
	if(add[k] != -1)dat[k] = add[k];
	lazy_update(k);
	update(a, b, x, k*2+1, l, (l+r)/2);
	update(a, b, x, k*2+2, (l+r)/2, r);
	ll t1 = dat[k*2+1], t2 = dat[k*2+2];
	if(add[k*2+1] != -1)t1 = add[k*2+1];
	if(add[k*2+2] != -1)t2 = add[k*2+2];
	dat[k] = min(t1, t2);
	return;
}

ll find(int a, int b, int k, int l, int r){
	if(r <= a || b <= l)return INF;
	if(a <= l && r <= b){
		if(add[k] != -1){
			dat[k] = add[k];
		}
		lazy_update(k);
		return dat[k];
	}
	if(add[k] != -1)dat[k] = add[k];
	lazy_update(k);
	ll vl = find(a, b, k*2+1, l, (l+r)/2);
	ll vr = find(a, b, k*2+2, (l+r)/2, r);
	return min(vr, vl);
}

int main(){
	int m, q, c, s, t, x;
	scanf("%d%d", &m, &q);
	init(m);
	while(q--){
		scanf("%d", &c);
		if(c == 0){
			scanf("%d%d%d", &s, &t, &x);
			update(s, t+1, x, 0, 0, n);
		}else{
			scanf("%d%d", &s, &t);
			ll ans = find(s, t+1, 0, 0, n);
			printf("%lld\n", ans);
		}
	}
	return 0;
}



Measured memory_bytes: 7308
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
//#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1ll << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1ll << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return -1;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
template <typename T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b; // aをbで更新
        return true;
    }
    return false;
}
template <typename T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b; // aをbで更新
        return true;
    }
    return false;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));
int main()
{
    cout << fixed << setprecision(30);
    ll X, K, D;
    cin >> X >> K >> D;
    if (X != 0)
    {
        if (X < 0)
            X *= -1;
        ll a = X / D;
        if (a >= K)
        {
            putout(X - K * D);
            return 0;
        }
        ll nokori = (K - a);
        if (nokori % 2 == 0)
            putout(X - a * D);
        else
            putout(abs(X - (a + 1) * D));
    }
    if (X == 0)
    {
        if (K % 2 == 0)
            putout(0);
        else
            putout(D);
    }
    return 0;
}


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

using namespace std;
int main(int argc, const char * argv[]) {
    int N = 0;
    int K = 0;
    cin >> N >> K;
    vector<int> Vs(N, 0);
    for(int i = 0; i < N; i++) {
        cin >> Vs[i];
    }

    int value = 0;
    const int take_max = min(N, K);
    for(int i_left = 0; i_left <= take_max; i_left++) {// 左から i 個
        for(int j_right = 0; j_right <= take_max-i_left; j_right++) {// 右から j 個
            int d = K - i_left - j_right;
            //cout << "左から " << i_left << ", 右から　" << j_right << " とる。出すのは " << d << " 回以下" << endl;

            const int take_left_num = min(N, i_left);
            vector<int> taken_left(Vs.begin(), Vs.begin()+take_left_num);
            const int take_right_num = min(N, j_right);
            vector<int> taken_right(Vs.end()-take_right_num, Vs.end());

            const int take_num_tot = take_left_num + take_right_num;
            vector<int> taken;
            taken.insert(taken.end(), taken_left.begin(), taken_left.end());
            taken.insert(taken.end(), taken_right.begin(), taken_right.end());

            // sort ascending order
            sort(taken.begin(), taken.end());

            // remove d negatives
            int sum_start = 0;
            for(int d_k = 0; d_k < min(d, take_num_tot); d_k++) {
                if(0 < taken[d_k]) {
                    sum_start = d_k;
                    break;
                }
                sum_start++;
            }

            int sum = 0;
            for(int sum_k = sum_start; sum_k < take_num_tot; sum_k++) {
                sum += taken[sum_k];
            }
            value = max(value, sum);
        }
    }
    cout << value << endl;

    return 0;
}


Measured memory_bytes: 256
def calc(num, A, B) -> bool:
	ans = 0

	while True:
		if num // 10 == 0:
			ans += num
			break
		ans += num % 10
		num //= 10

	if A <= ans and ans <= B:
		return True
	else:
		return False



def main():
	N, A, B = map(int, input().split())
	ans = 0

	for num in range(1, N + 1):
		result = calc(num, A, B)
		if result:
			ans += num

	print(ans)

  
if __name__ == "__main__":
  	main()

Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k<=a)
	{
		cout<<k<<"\n";
		return 0;
	}
	if(k<=a+b)
	{
		cout<<a<<"\n";
		return 0;
	}
	int z=k-(a+b);
	cout<<a-z<<"\n";
	return 0;
}

Measured memory_bytes: 3652
Step = gets.chomp

# print Step

Step.each_char.with_index{
  |c,i|
  # print c,' '
  if (i+1) % 2 == 1 then
    if c == 'L' then
      print 'No'
      exit
    end
  elsif c == 'R' then
      print 'No'
      exit
  end
}
    
print 'Yes'

Measured memory_bytes: 14324
#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 n, k;
  cin >> n >> k;
  ll ans = 0;
  if (k == 0) {
    ans = (ll)n * n;
    cout << ans << endl;
    return 0;
  }
  for (int b = k+1; b <= n; ++b) {
    ans += max(n%b-k+1, 0) + (b-k) * (n/b);
    // printf("b = %d, ans = %lld\n", b, ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
import java.util.*;
public class Main {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int []hairetu=new int[3];
        hairetu[0] = sc.nextInt();
        hairetu[1] = sc.nextInt();
        hairetu[2] = sc.nextInt();
        int K = sc.nextInt(); 
        int max = hairetu[0];
        int a=0;
        for(int j=0;j<K;j++) {
        for(int i=0;i<3;i++){
        	if(max<hairetu[i]){
        		max=hairetu[i];
        		 a =i;
        	}
        }
        hairetu[a]=max*2;
        
        }
        int sum =0;
        for(int i=0;i<3;i++){
        	sum+=hairetu[i];
        }
        System.out.println(sum);
	}
}


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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define vint vector<int>
#define vvint vector<vector<int>>

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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}


int main(){
  int n; cin >> n;
  if(n-1){
    int a,b; cin >> a >> b;
    cout << a+b << endl;
  }
  else{
    cout << "Hello World" << endl;
  }

  return 0;
}


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


void solve(long long A, long long B, long long H, long long M){
    int mins = H * 60 + M;
    long double thetaA = mins / (12.0 * 60) * 360;
    long double thetaB = M / 60.0 * 360;

    long double theta = abs(thetaA - thetaB);

    long double C = A * A + B * B - 2 * A * B * cos(theta * (M_PI / 180));

    cout << fixed << setprecision(15) << sqrt(C) << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long H;
    scanf("%lld",&H);
    long long M;
    scanf("%lld",&M);
    solve(A, B, H, M);
    return 0;
}


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

int main() {
    int n;
    long long x, a[2000], b[2000], ans = 1e18;
    cin >> n >> x;
    for(int i=0;i<n;i++){
        cin >> a[i];
        b[i] = a[i];
    }
    for(int j=0;j<n;j++){
        long long s = x*j;
        for(int i=0;i<n;i++){
            b[i] = min(b[i], a[(i-j+n)%n]);
            s += b[i];
        }
        ans = min(ans, s);
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int N,K,num=1;
  	cin>>N>>K;
  	for(int i=0;i<N;i++){
    	if(num*2<num+K) num*=2;
    	else num+=K;
  	}
  	cout<<num<<endl;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main(void)
{
	int n;
	
	while (scanf("%d", &n), n != 0){
		int cnt = 0;
		int o = 1000 - n;
		
		while(o >= 500){
			cnt++;
			o -= 500;
		}
		while(o >= 100){
			cnt++;
			o -= 100;
		}
		while(o >= 50){
			cnt++;
			o -= 50;
		}
		while(o >= 10){
			cnt++;
			o -= 10;
		}
		while(o >= 5){
			cnt++;
			o -= 5;
		}
		while(o >= 1){
			cnt++;
			o -= 1;
		}
		printf("%d\n", cnt);
	}
	
	return (0);
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  int n, k;
  cin >> n >> k;
  vi a(n);
  rep(i,n) cin >> a[i];
  int ans = ceil(n-1, k-1);
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--) 
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();

int main(){
 int n; cin>>n;
  string res="";
 if(n<1000)
 res+="ABC";
 else res+="ABD";
 cout<<res<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;

signed main() {
  int n,m,p;cin>>n>>m>>p;
  pair<pair<int,int>,int> g[5100];int d[2600];
  rep(i,m){
    cin>>g[i].first.first>>g[i].first.second>>g[i].second;
    g[i].second -= p;g[i].second *= -1;
  }
  rep(i,2600)d[i] = INF;
  d[1] = 0;
  int dd;
  rep(i,2*n){
    bool updated = false;
    rep(j,m){
      pair<int,int> e = g[j].first;int cost = g[j].second;
      if(d[e.first] != INF && d[e.second] > d[e.first]+cost){
        if(i < n-1)d[e.second] = d[e.first]+cost;
        else d[e.second] = -922337203685;
        updated = true;
      }
    }
    if(i < n-1){
      dd = d[n];
    }
    if(!updated)break;
  }
  if(dd == d[n])cout << max((ll)0,d[n]*-1) << endl;
  else cout << -1 << endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

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

        int[] digits = sc.next().chars().map(ch -> ch - '0').toArray();

        System.out.println(solve(digits));

        sc.close();
    }

    static String solve(int[] digits) {
        for (int code = 0;; ++code) {
            StringBuilder result = new StringBuilder(String.valueOf(digits[0]));
            int n = digits[0];
            for (int i = 1; i < digits.length; ++i) {
                if ((code & (1 << (i - 1))) != 0) {
                    result.append("+");
                    n += digits[i];
                } else {
                    result.append("-");
                    n -= digits[i];
                }

                result.append(digits[i]);
            }

            if (n == 7) {
                result.append("=7");

                return result.toString();
            }
        }
    }
}

Measured memory_bytes: 27732
# -*- coding: utf-8 -*-

import numpy as np

h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            s[i][j] = 1
        else:
            s[i][j] = 0

no_flg = 0
s = np.array(s)
for i in range(h):
    for j in range(w):
        check = []
        if s[i, j] != 0:
            if i != 0:
                if s[i-1, j] == 1:
                    check.append(1)
            if j != 0:
                if s[i, j-1] == 1:
                    check.append(1)
            if i != h-1:
                if s[i+1, j] == 1:
                    check.append(1)
            if j != w-1:
                if s[i, j+1] == 1:
                    check.append(1)
            if sum(check) == 0:
                no_flg = 1
                break

if no_flg:
    print('No')
else:
    print('Yes')



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

using namespace std;
string grid[1001];
int mem[1001][1001][4];
int di[2] = {1, -1};

int n, m;

bool valid(int i, int j) {
    return i >= 0 && i < n && j >= 0 && j < m;
}

int solve(int i, int j, int d1, int d2) {
    if (!valid(i, j)) {
        return 1e9;
    }
    if (grid[i][j] == '#')
        return 0;
    int &ret = mem[i][j][d1*2+d2];
    if (~ret) return ret;
    ret = 1e9;
    ret = min(ret, solve(i + di[d1], j, d1, d2) + 1);
    ret = min(ret, solve(i, j + di[d2], d1, d2) + 1);
    return ret;
}

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.in", "r", stdin);
#endif

    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> grid[i];
    }
    memset(mem, -1, sizeof(mem));
    int res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            int mn = 1e9;
            for (int k = 0; k < 2; k++) {
                for (int l = 0; l < 2; l++) {
                    mn = min(mn, solve(i, j, k, l));
                }
            }
            res = max(res, mn);
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 17152
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	a *= b;
	c *= d;
	cout << max(a, c) << endl;
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define nl '\n'
#define f(i, n) for (int i = 0; i < n; ++i)

using namespace std;
void solve() {
    float d, t, s;
    cin >> d >> t >> s;
    cout << ((s >= d / t) ? "Yes" : "No") << nl;
}

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

Measured memory_bytes: 3676
# 写経
N, M = map(int, input().split())


sw = []
for i in range(M):
    k, *s = map(int, input().split())
    sw.append(s)


p = list(map(int, input().split()))


ans = 0
# N 個のスイッチの状態を N bit の二進数で表現する
for bit in range(2 ** N):
    flag = False
    # 電球につながってるスイッチを調べる
    for m in range(M):
        cnt = 0
        for s in sw[m]:
            # 割り当てたスイッチの番目に bit が立っているかどうか調べる
            if (1 << (s - 1)) & bit:
                cnt += 1
        if cnt % 2 == p[m]:
            continue
        else:
            flag = True
            break
    if not flag:
        ans += 1


print(ans)


Measured memory_bytes: 3064
#include <stdio.h>

int bubbleSort(int *a, int n);

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

	int i;
	int a[n], cnt = 0;
	for(i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	cnt = bubbleSort(a, n);
	for(i = 0; i < n - 1; i++){
		printf("%d ", a[i]);
	}
	printf("%d\n", a[n - 1]);
	printf("%d\n", cnt);
	return 0;
}

int bubbleSort(int *a, int n)
{
	int flg = 1;
	int cnt = 0;
	int j, buf;
	while(flg){
		flg = 0;
		for(j = n - 1; j > 0; j--){
			if(a[j] < a[j - 1]){
				buf = a[j];
				a[j] = a[j - 1];
				a[j - 1] = buf;
				flg = 1;
				cnt++;
			}
		}
	}
	return cnt;
}




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

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define all(x) x.begin(),x.end()
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
    int n;
    cin>>n;
    if(n<30)
        cout<<"No"<<nl;
    else cout<<"Yes"<<nl;
    return 0;
}



Measured memory_bytes: 3592
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int answer = 0;
        for (int i = 1; i <= n; i++) {
            int temp = input.nextInt();
            if (i % 2 != 0 && temp % 2 != 0)
                answer++;
        }
        System.out.println(answer);
    }
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  vector<long long> count(N);
  for (auto &a : A) {
    cin >> a;
    a--;
    count[a]++;
  }
  long long patterns = 0;
  for (auto c : count) {
    if (c > 1) {
      patterns += c * (c - 1) / 2;
    }
  }
  for (int i = 0; i < N; i++) {
    long long ans = patterns - count[A[i]] + 1;
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 5760
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
h, n = i2()
a = intl()
print("Yes" if h <= sum(a) else "No")

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

#define ll long long int

using namespace std;

int main() {
    ll l, r, d;
    cin >> l >> r >> d;
    ll res = 0;
    for (ll cur = 0; cur <= 100; cur += d) {
        if (cur >= l && cur <= r) ++res;
    }
    cout << res << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  string S;
  cin >> S;
  set<string> s;
  int n = S.length();
  if (n == 1) {
    cout << "1\n";
    return 0;
  }
  if (n == 2) {
    if (S[0] == S[1]) {
      cout << "1\n";
    } else {
      cout << "2\n";
    }
    return 0;
  }

  int dp[n + 1][2]{};
  dp[0][0] = 1;
  dp[0][1] = 0;
  if (S[0] == S[1]) {
    dp[1][0] = 0;
    dp[1][1] = 1;
  } else {
    dp[1][0] = 2;
    dp[1][1] = 1;
  }

  for (int i = 2; i < n; i++) {
    if(S[i] != S[i - 1]) {
      dp[i][0] = max(dp[i - 1][0] + 1, dp[i - 2][0] + 1); 
      dp[i][1] = dp[i - 2][0] + 1;
    } else {
      dp[i][0] = max(dp[i - 1][1] + 1, dp[i - 2][1] + 1);
      dp[i][1] = dp[i - 2][0] + 1;
    }
  }
  cout << max(dp[n -1][0], dp[n - 1][1]) << "\n";
  // for (int i = 0; i < n; i++) {
  //   cout << dp[i][0] << " " << dp[i][1] << "\n";
  // }
  return 0;
}

Measured memory_bytes: 2180
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

int main() {
	int N;
	while(cin >> N, N) {
		vvi info(N, vi(N, 0));
		int M, p;
		REP(i, N) {
			cin >> M;
			REP(j, M) {
				cin >> p;
				info[i][p-1] = 1;
			}
		}
		int K;
		cin >> K;
		vi l(K);
		REP(i, K) {
			cin >> l[i];
		}

		int ans = -1;
		REP(i, N) {
			bool ok = true;
			REP(j, K) {
				if(info[i][l[j]-1]) {
				
				} else {
					ok = false;
				}
			}
			if(ok) {
				if(ans == -1) {
					ans = i+1;
				} else {
					ans = -1;
					break;
				}
			}
		}

		cout << ans << endl;
	}

	return 0;
}

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

using namespace std;
#define ll long long

int main(){
    ll N,K;
    string S;
    cin >> N >> K >> S;
    for(int i=0; i<N; i++){
        if(i != K-1) cout << S[i];
        else cout << char(tolower(S[i]));
    }
    cout << endl;
}

Measured memory_bytes: 256
// 01/02/20 // 5:08 PM //

#include <bits/stdc++.h>

using namespace std;

#define int long long

const int MAXN = (int)1e2 + 10;
const int MAXK = (int)1e5 + 10;
const int MOD  = (int)1e9 + 7;

int n, k, a[MAXN];
int memo[2][MAXK], prefix[MAXK];

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

    cin >> n >> k;
    for(int i=1; i<=n; i++) cin >> a[i];

    memo[0][0] = memo[1][0] = 1;
    for(int j=0; j<=min(k,a[1]); j++)  memo[1][j] = 1;

    // i = 1
    prefix[0] = memo[1][0];
    for(int j=1; j<=k; j++) prefix[j] = memo[1][j] + prefix[j-1];

    for(int i=2; i<=n; i++){

        for(int j=0; j<=k; j++){

            if(j<=a[i])
                memo[i&1][j] = prefix[j];
            else
                memo[i&1][j] = (prefix[j] - prefix[j-a[i]-1] + MOD)%MOD;

        }

        prefix[0] = memo[i&1][0];
        for(int j=1; j<=k; j++)
            prefix[j] = (memo[i&1][j] + prefix[j-1])%MOD;
    }

    cout << memo[n&1][k] << endl;

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
#define decimalupto(no,y)  fixed<<setprecision(y)<<no
using namespace std;

const ll mx=1e18;
ll arr[100000];


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
     ll a;
     double b;
     cin>>a>>b;
     int B = round(b*100);
     ll ans = (ll)a*B/100;
     cout<<ans<<"\n";
     


}






Measured memory_bytes: 3720
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstring>
#include<cstdio>
using namespace std; 
void File(){ freopen("1559.in","r",stdin); freopen("1559.out","w",stdout); }
int a[110][110];
int main(void){
//	freopen("1559.out","w",stdout);
	int n,m;
	cin>>n>>m;
	for(int i=51;i<=100;++i)
		for(int j=1;j<=100;++j)
			a[i][j]=1;
	int ovo=0,qaq=0;
	for(int i=1;i<=50;i+=2){
		for(int j=1;j<=100;j+=2){
			if(ovo+1==n)
				break;
			a[i][j]=1;
			ovo++;
		}
		if(ovo+1==n)
			break;
	}
	for(int i=52;i<=100;i+=2){
		for(int j=1;j<=100;j+=2){
			if(qaq+1==m)
				break;
			a[i][j]=0;
			qaq++;
		}
		if(qaq+1==m)
			break;
	}
	printf("100 100\n");
	for(int i=1;i<=100;++i)
		for(int j=1;j<=100;++j){
			if(a[i][j]==1)
				printf(".");
			else
				printf("#");
			if(j==100)
				printf("\n");
		}

}


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

int N; long long A[200200], R[200200], K;

int main()
{
	cin >> N >> K; K *= 2;
	for (int i = 0; i < N; i++){
		cin >> A[i];
		R[i] = -A[i];
	}
	sort(A, A + N);
	sort(R, R + N);

	long long l = -1e18, r = 1e18;
	while (l + 1 < r){
		long long m = l + (r - l) / 2, c = 0;
		for (int i = 0; i < N; i++){
			if (A[i] == 0){
				if (m >= 0) c += N - 1;
			}
			else if (A[i] > 0){
				long long u = (m >= 0 ? m / A[i] : (m - A[i] + 1) / A[i]);
				c += upper_bound(A, A + N, u) - A;
				if (A[i] * A[i] <= m) c--;
			}
			else{
				long long u = (m >= 0 ? m / (-A[i]) : (m + A[i] + 1) / (-A[i]));
				c += upper_bound(R, R + N, u) - R;
				if (A[i] * A[i] <= m) c--;
			}
		}

		if (c < K) l = m;
		else r = m;
	}

	cout << r << endl;

	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    int n, x, t; cin >> n >> x >> t;
    cout << (n + x - 1) / x * t << endl;   
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = Console.ReadLine();
            int ret = 0;
            foreach (var c in r)
            {
                ret += int.Parse(c.ToString());
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 11092
#!/usr/bin/env python
# -*- coding: utf-8 -*-

M, D = map(int, input().split())

count=0
for i in range(4, M+1):
    for j in range(22, D+1):
        str_j = str(j)
        if int(str_j[1]) <= 1:
            continue
        if (int(str_j[0]) * int(str_j[1])) == i:
            count += 1
print(count)


Measured memory_bytes: 39536
/*
Cerberus97
Hanit Banga
*/

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

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 1e5 + 10;

int main() {
	int n, k;
	cin >> n >> k;
	ll ans = 0;
	for (int b = k + 1; b <= n; ++b) {
		ll cyc = (n + 1) / b;
		ll rem = n + 1 - b * cyc;
		ans += cyc * (b - k);
		ans += max(0ll, rem - k);
	}
	if (!k) {
		ans -= n;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    int n;
    std::cin >> n;
    std::vector<int> a(n),aa(n);
    rep(i,n){
        std::cin >> a[i];
        aa[i]=a[i];
    }
    
    sort(all(a));
    int c=a[n/2];
    rep(i,n){
        if(aa[i]>=c)std::cout << a[n/2-1] << std::endl;
        else std::cout << a[n/2] << std::endl;
    }
    
}




Measured memory_bytes: 3712
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#define INF 1<<28
#define F first
#define S second
using namespace std;
 

typedef pair < int, int > P;
vector < P > p[5];
int sx, sy, gx, gy;
int memo[5][5][1111];

int solve(int k, int t, int q){
  
  if(k == 4) return abs(p[t][q].F-gx) + abs(p[t][q].S-gy);
  if(~memo[k][t][q]) return memo[k][t][q];
  
  int ans = INF, d = (t+1)%5, c;
  for(int i=0;i<p[d].size();i++){
    c = k?abs(p[t][q].F-p[d][i].F) + abs(p[t][q].S-p[d][i].S):abs(sx-p[d][i].F) + abs(sy-p[d][i].S);
    ans = min(ans, solve(k+1, d, i) + c);
  }
 
  return memo[k][t][q] = ans;
}
 
int main(){
 
  int w, h;
  char c;
 
  while(cin >> w >> h, w){
 
    for(int i=0;i<5;i++) p[i].clear();
     
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> c;
	if(c == '.') continue;
	else if(c == 'S') sx = j, sy = i;
	else if(c == 'G') gx = j, gy = i;
	else  p[c-'1'].push_back( P(j,i) );
      }
    }
    
    memset(memo, -1, sizeof(memo));
    P q = P(0, INF);
    for(int i=0;i<5;i++){
      
      if(q.S > solve(0,i,0)) q.F = i+1, q.S = solve(0,i,0);
    }
    
    if(q.S == INF) cout << "NA\n";
    else cout << q.F << " " << q.S << endl;
    
  }
}

Measured memory_bytes: 1360
#Solve this by Rerooting
import sys
from itertools import accumulate
input = sys.stdin.buffer.readline

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


dfs_order = []
parent = [-1] * N
root = 0
stack = [root]
while stack:
    node = stack.pop()
    dfs_order.append(node)
    for next_node in adj[node]:
        if next_node != parent[node]:
            parent[next_node] = node
            stack.append(next_node)

dp1 = [1] * N
for node in reversed(dfs_order):
    for next_node in adj[node]:
        if next_node != parent[node]:
            dp1[node] = max(dp1[node], dp1[next_node] + 1)

dp2 = [1] * N
for node in dfs_order:
    around = [dp1[next_node]+1 if next_node != parent[node] else dp2[node] for next_node in adj[node]]
    from_left = [1] + list(accumulate(around, max))[:-1]
    from_right = list(accumulate(reversed(around), max))[-2::-1] + [1]
    without = [max(l, r) + 1 for l, r in zip(from_left, from_right)]
    for next_node, value in zip(adj[node], without):
        if next_node != parent[node]:
            dp2[next_node] = value

dp = [v1 + v2 - 1 for v1, v2 in zip(dp1, dp2)]

length = max(dp)

if length % 3 == 2:
    print("Second")
else:
    print("First")

Measured memory_bytes: 185008
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    cout << min(a, b) + min(c, d) << endl;
    
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
   long x; cin >> x;
   long y = x%100;
   long cnt = 0;
   for(int i=5;i>0;i--){
   cnt += y/i; y %= i;
   }
   if(cnt > x/100)cout << 0 << endl;
   else cout << 1 << endl;
}    

Measured memory_bytes: 3604
/*BINH :))*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long llu;
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define f  first
#define s  second
#define mp make_pair
#define pb push_back
#define ep emplace_back
#define sz(a) (int) a.size()
#define FOR(x,a,b) for (int x=a,u,v;x<=b;x++)
#define FOD(x,a,b) for (int x=a;x>=b;x--)
#define REP(x,a,b) for (int x=a;x<b;x++)
#define RED(x,a,b) for (int x=a;x>b;x--)
#define EL cout<<endl
#define maxn 1005
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#pragma GCC optimize("Ofast")
void init(){
}
int n,m,ans,dd[3000000],dp[3000000];
vi a[3000000];

void dfs(int u,int dem){
    dd[u]=1;
    ans = max(ans,dem);
    REP(i,0,sz(a[u])){
        int v = a[u][i];
        
        if(!dd[v])
            dfs(v,dem+1);
        dp[u] = max(dp[u] , dp[v] + 1);
    }
}

int main(){
    IO
    init();
    cin>>n>>m;
    FOR(i,1,m){
        cin>>u>>v;
        a[u].pb(v);
    }
    FOR(i,1,n){
        if(dd[i])continue;
        dfs(i,0);
    }
    FOR(i,1,n)ans = max(ans,dp[i]);
    cout<<ans;
}


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

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

  ll N; cin >> N;
  string S; cin >> S;
  vector<ll> R(N + 1, 0), G(N + 1, 0), B(N + 1, 0);
  for (ll i = 0; i < N; i++) {
    R[i + 1] = R[i];
    G[i + 1] = G[i];
    B[i + 1] = B[i];
    if (S[i] == 'R') R[i + 1]++;
    if (S[i] == 'G') G[i + 1]++;
    if (S[i] == 'B') B[i + 1]++;
  }
  // cout << R[0]; for (int i = 1; i < R.size(); i++) { cout << ' ' << R[i]; }
  // cout << '\n';
  // cout << G[0]; for (int i = 1; i < G.size(); i++) { cout << ' ' << G[i]; }
  // cout << '\n';
  // cout << B[0]; for (int i = 1; i < B.size(); i++) { cout << ' ' << B[i]; }
  // cout << '\n';

  ll ans = 0;
  for (ll i = 1; i < N - 1; i++) {
    for (ll j = 0; j < i; j++) {
      if (S[i] == S[j]) continue;
      ll k = i + (i - j);
      if ((S[i] == 'G' && S[j] == 'B') || (S[i] == 'B' && S[j] == 'G')) {
        ans += (R[N] - R[i + 1]);
        if (k < N && S[k] == 'R') ans--;

      } else if ((S[i] == 'B' && S[j] == 'R') || (S[i] == 'R' && S[j] == 'B')) {
        ans += (G[N] - G[i + 1]);
        if (k < N && S[k] == 'G') ans--;

      } else if ((S[i] == 'R' && S[j] == 'G') || (S[i] == 'G' && S[j] == 'R')) {
        ans += (B[N] - B[i + 1]);
        if (k < N && S[k] == 'B') ans--;

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

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

#include <boost/algorithm/string/classification.hpp>  // is_any_of
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/math/tools/minima.hpp>
#include <boost/multi_array.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>

const int MOD = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

namespace adaptor = boost::adaptors;
using namespace std;
using boost::irange;
using boost::algorithm::join;
using boost::algorithm::replace_all;
using boost::algorithm::split;
using boost::math::tools::brent_find_minima;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;

// TOP
void Main()
{
	string s;
	cin >> s;
	int n;
	n = s.size();
	string keyword = "keyence";
	if (s.substr(0, 7) == keyword || s.substr(n - 7, 7) == keyword)
	{
		cout << "YES" << endl;
		return;
	}
	int count;
	count = 0;
	while (s.at(count) == keyword.at(count))
		count++;
	n--;
	int i = 6;
	while (s.at(n) == keyword.at(i))
	{
		count++;
		n--;
		i--;
	}
	if (count >= 7)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
// END

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


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

int main() {
  int a,b,c,d;
  cin >>a>>b>>c>>d;
  for(;;){
    c-=b;
    if(c<=0){
      cout<<"Yes"<<endl;
      break;
    }
    a-=d;
    if(a<=0){
      cout<<"No"<<endl;
      break;
    }
  }
}

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

using namespace std;

int main(void){
    int N,K;
    cin>>N>>K;
    vector<long long> h(N);
    for(int i=0;i<N;i++){
        cin>>h[i];
    }
    sort(h.begin(),h.end());
    long long ans=1000000007;
    for(int i=0;i<=N-K;i++){
        ans=min(ans,h[i+K-1]-h[i]);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 1024
n,m=gets.split.map &:to_i
gakusei=(1..n).map{gets.split.map &:to_i}
checkpo=(1..m).map{gets.split.map &:to_i}
def manha(a,b)
    return (a[0]-b[0]).abs+(a[1]-b[1]).abs
end
gakusei.each{|posi|
    kyori=checkpo.map{|q|manha(posi,q)}
    p kyori.index(kyori.min)+1
}

Measured memory_bytes: 1788