akhauriyash/Code-Regression huggingface dataset:
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/04/30 10:25:51 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

#define MOD 1000000007;
#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++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

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

// TOP
void	Main()
{
	int	n;
	cin >> n;

	vector<vector<int>>	V(3, vector<int>(n));
	vector<vector<int>>	dp(3, vector<int>(n));
	rep(i, n)
	{
		rep(j, 3)
			cin >> V.at(j).at(i);
	}
	rep(i, 3)
		dp.at(i).at(0) = V.at(i).at(0);
	rep2(j, 1, n)
	{
		rep(i, 3)
		{
			rep(k, 3)
			{
				if (k == i)
					continue;
				dp.at(i).at(j) = max(dp.at(i).at(j), dp.at(k).at(j - 1) + V.at(i).at(j));
			}
		}
	}
	int	maxv;
	maxv = 0;
	rep(i, 3)
		maxv = max(maxv, dp.at(i).back());
	cout << maxv << endl;
}
// END

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


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  // 0点はなし
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  bool bl = true;
  for (int i = K; i < N; i++) {
    bl = A[i] > A[i-K];
    puts(bl ? "Yes" : "No");
  }
  return 0;
}

Measured memory_bytes: 4040
#include <bits/stdc++.h>
using namespace std;
 
int num[1000001];
 
void prime_num() {
  num[0] = 1;
  num[1] = 1;
  for ( int i = 2; i * i  < 1000001; i++ ) {
    if ( num[i] == 0 ) {
      for ( int j = i * 2; j < 1000001; j += i ) {
    num[j] = 1;
      }
    }
  }
}
 
int main() {
  int n;
  prime_num();
  while ( cin >> n ) {
    int cnt = 0;
    for ( int i = 2; i  <= n; i++ ) {
      if ( num[i] == 0 ) cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 5064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int mod2 = 998244353;

int main() {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
    if (s[0] == s[1] && s[2] == s[3] && s[1] !=s[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    double T, X;
    cin >> T >> X;

    cout << T / X << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	int a,b,k;
	scanf("%d%d%d",&k,&a,&b);
	for(int i=a;i<=b;i++){
		if(i%k==0){
			printf("OK\n");
			return 0;
		}
	}
	printf("NG\n");
	return 0;
}


Measured memory_bytes: 3800
#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <string>
#include <string.h>
#include <map>
#include <math.h>
#include <vector>
#include <set>
#include <map>
#include <deque>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+7;
int gcd(int a,int b)
{
    return b?gcd(b,a%b):a;
}
int get_bit(int x,int i){return (x>>i)&1;}
int a[1000],b[1000];
int main()
{
    int n;
    cin>>n;
    int sum=0;
    for(int i=1;i<=n;i++)cin>>a[i],sum+=a[i];
   int ans=0x3f3f3f3f;
   for(int i=1;i<n;i++)
   {
      int k=0;
       for(int j=1;j<=i;j++)
         k+=a[j];
       ans=min(ans,abs(sum-k-k));
   }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
mt19937 rng(std::chrono::duration_cast<std::chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=200005;
#define M 1000000007
#define double long double
#define BINF 10000000000000
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 15000001
#define deb(x) cout << #x << " " << x << "\n";
const int LG = 22;

int power(int x,int y,int m){
    if (y == 0)
        return 1;
    int p = power(x, y/2, m) % m;
    p = (p * p) % m;
 
    return (y%2 == 0)? p : (x * p) % m;
}

int fact[N], ifact[N];

void proecss(){
    fact[0] = 1;
    for(int i = 1; i < N; i++)
        fact[i] = (fact[i - 1] * i) % M;
    for(int i = 0; i < N; i++)
        ifact[i] = power(fact[i], M - 2, M);
}

int nCr(int n, int r){
    if(r > n) return 0;
    if(r == n) return 1;
    int ans = (ifact[n - r] * ifact[r]) % M;
    ans = (ans * fact[n]) % M;
    return ans;
}


#undef int 
int main() {
#define int long long int
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0);

    proecss();

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

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

    int ans = 0;
    for(int i = 0; i < n; i++){
        
        int p = nCr(i, k - 1) - nCr(n - i - 1, k - 1);
        p = (p + M) % M;
        a[i] = (a[i] + M) % M;
        ans = (ans + (a[i] * p) % M) % M;
    }

    cout << ans << endl;

    
return 0;
}




Measured memory_bytes: 4224
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){

 string S;
 ll int counter = 0;
 ll int N ;
 cin >> S;

 N = S.size();
 if(N == 1){
	 cout << "0";
	 return 0;
 }

else if ( N%2==0){
	 for(int i=0;i<N/2;i++){
		 if(S[i]==S[N-1-i]){
		 }
		 else{
			 counter +=1;
		 }
	 }
 }
 else{
	 for(int i=0;i<(N-1)/2;i++){
		 if(S[i]==S[N-1-i]){
		 }
		 else{
			 counter +=1;
		 }
		 
	 }
 }
 cout << counter;











	return 0;

}



Measured memory_bytes: 256
// Problem : 
// 			C - Walking Takahashi
// 			
// 		
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*
	“Whether you think you can, or you think you can’t – you’re right” - Henry Ford 
*/

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define pb push_back
#define pl pair<ll, ll>
#define vl vector<ll>
#define vi vector<int>
#define endl '\n'

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

template <typename T, typename TT>
ostream &operator<<(ostream &os, const pair<T, TT> &t) {
    return os << t.first << " " << t.second;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &t) {
    for (auto &i : t) os << i << " ";
    return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &t : v) is >> t;
    return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, vector<pair<T1, T2>> &v) {
    for (pair<T1, T2> &t : v) is >> t.first >> t.second;
    return is;
}

const ll mod = 1e9 + 7;

void solve() {
	ll x, k, d;
	cin >> x >> k >> d;
	ll req = abs(x)/d;
	if(req >= k) {
		ll ans1 = x - k*d, ans2 =x + k*d;
		if(abs(ans1) > abs(ans2)) cout << abs(ans2) << endl;
		else cout <<abs(ans1) << endl;
		return;
	}
	ll cur = (abs(x - req*d) > abs(x + req*d) ? x + req*d : x  - req*d);
	k -= req;
	if(abs(cur + d) < abs(cur)) cur += d, k--;
	else if(abs(cur - d) < abs(cur)) cur -= d, k--;
	if(k & 1) cur = (abs(cur + d) < abs(cur - d) ? cur + d : cur - d);
	cout << abs(cur) << endl;
}

int main()
{
	fast;
   ll t = 1;
   // cin >> t;
   while(t--) {
   	solve();
   }
	return 0;
}


Measured memory_bytes: 3692
using System;
using System.Text;

namespace ALDS1_6_A {
    class Program {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');

            int[] A = new int[n + 1];
            int[] B = new int[n + 1];
            int[] C = new int[10001];

            for (int i = 1; i <= n; i++) {
                int temp = int.Parse(input[i - 1]);
                A[i] = temp;
                C[temp]++;
            }

            for (int i = 1; i < 10001; i++) {
                C[i] += C[i - 1];
            }

            for (int i = n; i > 0; i--) {
                B[C[A[i]]] = A[i];
                C[A[i]]--;
            }

            StringBuilder sb = new StringBuilder();
            sb.Append(B[1]);
            for (int i = 2; i <= n; i++)
                sb.Append(" " + B[i]);
            Console.WriteLine(sb.ToString());
        }
    }
}

Measured memory_bytes: 257824
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(c>=a && c<=b)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
n =int(input())
L = sorted(list(map(int,input().split())))

L = [-10**10] +L +[10**10]
li = []
from bisect import bisect,bisect_right,bisect_left
for i in range(n+2):
    #a = (bisect_left(L,L[i]-1),bisect_right(L,L[i]+1),L[i])
    li.append((bisect_left(L,L[i]-1),bisect_right(L,L[i]+1)))

max1 = 0
for i in range(1,len(li)-1):
    max1 = max(max1,li[i][1]-li[i][0])
print(max1)

Measured memory_bytes: 21700
//#pragma GCC optimize("O3")

#include <bits/stdc++.h>

using namespace std;
const int N = 1e5 + 5;

int arr[N];

int main() {
   // freopen("in.txt", "rt", stdin);
    int n, k;
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; ++i) {
        scanf("%d", arr + i);
    }
    int ans = 1e9;
    for (int i = k - 1; i < n; ++i) {
        int a = arr[i - k + 1], b = arr[i];
        int v = 0;
        if (a >= 0 && b >= 0) {
            v = b;
        }
        if (a <= 0 && b <= 0) {
            v = -a;
        }
        if (a <= 0 && b >= 0) {
            v = b - a;
            v += min(b, -a);
        }
        ans = min(ans, v);
    }
    printf("%d", ans);
}

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

#ifdef LOCAL 
string to_string(char a) { return string(1,a); }
string to_string(bool a) { return a ? "1" : "0"; }
string to_string(const char* a) { return (string)a; }
string to_string(string a) { return a; }
string to_string(vector<bool> v) {
	string s = "["; for(unsigned i=0;i<v.size();i++){ s += ((i>0)?" ":"");
    s += char('0'+v[i]); } 	s += "]"; return s; }
template<class A, class B> string to_string(pair<A,B> p);
template<class T> string to_string(T v) {
	bool b = 1; string s = "["; for (const auto& x: v) {
		if (!b) {s += ", ";} b = 0; s += to_string(x); } s += "]"; return s; }
template<class A, class B> string to_string(pair<A,B> p) {
	return "("+to_string(p.first)+", "+to_string(p.second)+")"; }
void dbgf() { cerr << endl; }
template<class H, class... T> void dbgf(H h, T... t) {
	cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
	dbgf(t...); }
#define dbg(...) cerr << #__VA_ARGS__ << " = ", dbgf(__VA_ARGS__)
#else
#define dbg(...) 0
#endif
#define boolout(x) cout<<(x?"YES":"NO")<<endl;
typedef long long ll;

const int MOD = 1000000007;

void solve()
{
    int n;
    cin >> n;

    vector<double> p(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }

    vector<vector<double>> dp(n, vector<double>(n+1, 0));
    dp[0][0]= 1-p[0];
    dp[0][1]= p[0];
    for (int i = 1; i < n; ++i) {
        for (int j = 0; j < i+2; ++j) {
            dp[i][j] = (j==0?0.0:dp[i-1][j-1]) * p[i] + dp[i-1][j] * (1-p[i]);
        }
    }

    double res = 0;
    for (int i = n/2+1; i < n+1; ++i) {
       res += dp[n-1][i]; 
    }

    //dbg(dp);
    cout << setprecision(15) << res << endl;

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t; // read t. cin knows that t is an int, so it reads it as such.
    for (int i = 1; i <= t; ++i) {
        solve();
    }
    return 0;
}



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

using namespace std;

int main(int argc, char const *argv[])
{
    string S;
    cin >> S;
    int p = 0;
    long long ans = 0;
    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] == 'W')
        {
            ans += (i - p);
            p++;
        }

    }

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

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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    String[] a_str = in.readLine().split(" ");
    double[] a = new double[n];
    double sum = 0;
    
    for(int i = 0; i < n; i++){
      a[i] = (double)1/Integer.parseInt(a_str[i]);
      sum += a[i];
    }
    System.out.println((double)1/sum);
  }
}

Measured memory_bytes: 21204
var stdin = require('fs').readFileSync('/dev/stdin', 'utf8');
  var input  = stdin.toString().trim().split('\n');
var cols = input[0].split(' ');
var a = parseInt(cols[0], 10);
var b = parseInt(cols[1], 10);
var area = a * b;
var around = (a + b) * 2;

  console.log(area, around);

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

using namespace std;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    long long int arr[n];
    for(int i=0;i<n;i++)
    {
         cin>>arr[i];
    }
    long long int ans=0;
    vector<long long int>v;
    for(int i=0;i<n-2;i++)
    {
         for(int j=i+1;j<n-1;j++)
         {
              for(int k=j+1;k<n;k++)
              {
                     v.push_back(arr[i]);
                     v.push_back(arr[j]);
                     v.push_back(arr[k]);
                     
                     sort(v.begin(),v.end());
                     
                     if(v[0]+v[1]>v[2])
                     {
                        
                        if(v[0]!=v[1]&&v[1]!=v[2]&&v[2]!=v[0])
                        {
                         ans++;
                         }
                     }
                     v.clear();
              }
         }
    }
    cout<<ans<<endl;
    
	return 0;
}

Measured memory_bytes: 3660
#include <vector>
#include <iostream>
#include <limits>
#include <queue>
#include <numeric>

using namespace std;

struct edge {
    int v;
    int weight;

    edge(int v, int w) : v(v), weight(w) {}
};

bool operator < (const edge &a, const edge &b) {
  return a.weight > b.weight;
}

int main() {
    auto const INF = numeric_limits<int>::max();

    int V, E;
    cin >> V >> E;

    vector<vector<edge>> G(V);
    for (int i = 0; i < E; ++i) {
        int s, t, w;
        cin >> s >> t >> w;
        G[s].emplace_back(t, w);
        G[t].emplace_back(s, w);
    }

    // Prim's algorithm
    vector<int> mincost(V, INF);
    vector<bool> visited(V, false);
    priority_queue<edge> Q;

    Q.emplace(0, 0);
    mincost[0] = 0;
    while (!Q.empty()) {
        auto e = Q.top(); Q.pop();
        if (visited[e.v])
            continue;
        visited[e.v] = true;

        for (auto& u : G[e.v]) {
            if (!visited[u.v] && u.weight < mincost[u.v]) {
                mincost[u.v] = u.weight;  // mincost
                Q.emplace(u.v, u.weight);
            }
        }
    }

    auto total = accumulate(mincost.begin(), mincost.end(), 0);
    cout << total << endl;

    return 0;
}

Measured memory_bytes: 6136
#include <stdio.h>
typedef long long ll;
#define abs(x) ((x) > 0 ? (x) : -(x))

int
main(int argc, char *argv[])
{
  int n;
  ll a[100000], sum = 0, min = 1000000000; int minus = 0;
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%lld", &a[i]);
    sum += abs(a[i]);
    if(a[i] < 0) minus++;
    min = (min > abs(a[i]) ? abs(a[i]) : min);
  }

  printf("%lld\n", sum - (minus % 2) * 2 * min);

  return 0;
}
  
      


Measured memory_bytes: 896
fun main(args: Array<String>) {
    val k = readLine()!!.toInt()
    val (a, b) = readLine()!!.split(' ').map { it.toInt() }

    var ans = false
    for (i in a .. b) {
        if (i%k == 0) ans = true
    }

    if (ans) println("OK")
    else println("NG")
}


Measured memory_bytes: 36372
loop do
  m, f, r = gets.split.map(&:to_i)
  break if m == -1 && f == -1 && r == -1

  if m == -1 || f == -1
    puts 'F'
    next
  end

  sum = m + f

  case sum
  when 80..100
    puts 'A'
  when 65...80
    puts 'B'
  when 50...65
    puts 'C'
  when 30...50
    if r >= 50
      puts 'C'
    else
      puts 'D'
    end
  else
    puts 'F'
  end
end

Measured memory_bytes: 8672
def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]
 
N = read()
A = reads()
B = reads()
 
D = 28
xor = 0
for d in range(D + 1):
  mask = (1 << (d + 1)) - 1 # [1] * (d+1)
  AA = sorted(x & mask for x in A)
  BB = sorted(x & mask for x in B)
  count = 0
  itr = [N] * 4
  for a in AA:
    vs = [
      (1 << d) - a,
      (1 << (d + 1)) - a,
      (1 << d) + (1 << (d + 1)) - a,
      (1 << (d + 2)) - a
    ]
    for i in range(4):
      while 0 < itr[i] and vs[i] <= BB[itr[i]-1]:
        itr[i] -= 1
    count += (itr[1] - itr[0]) + (itr[3] - itr[2])
  if count & 1:
    xor |= 1 << d
 
print(xor)

Measured memory_bytes: 139908
#include <bits/stdc++.h>
using namespace std;
 
#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	long long N,mid = 0;
  int sw = 0;
  cin >> N;
   vector<long long> a(N);
  vector<long long> b(N);
    froop1(0,N){
      cin >> a.at(i);
      b.at(i) = a.at(i);
    }
  sort(b.begin(),b.end());
  mid = b.at(b.size() / 2) - 1;
  int n = b.size() / 2 - 1;
  froop1(0,N){
   if(a.at(i) <= mid){
     cout << b.at(n + 1);
   }else{
     cout << b.at(n);
   }
    cout << endl;
  }
      
  return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

struct UnionFind
{
private:
  vi data;
  int cnt;

public:
  UnionFind(const int size) : data(size, -1), cnt(size) {}
  bool unite(int x, int y){
    x = root(x);
    y = root(y);
    if(x != y){
      data[x] += data[y];
      data[y] = x;
      cnt -= 1;
    }
    return x != y;
  }
  bool same(int x, int y){ return root(x) == root(y); }
  int root(int x){ return data[x] < 0 ? x : data[x] = root(data[x]); }
  int size(int x){ return -data[root(x)]; }
  int group(){ return cnt; }
};

const int MAX_Q = 111111;
const int MAX_N = 111111;
int N, Q;
int q[MAX_Q];
int p[MAX_N];
pair<char, int> query[MAX_N];
bool flag[MAX_N];

int main()
{
  while(cin >> N >> Q, Q){
    rep(i, N) flag[i] = false;

    UnionFind uf(N);
    p[0] = 0;
    rep(i, N - 1) cin >> p[i + 1],  p[i + 1] -= 1;
    rep(i, Q) cin >> query[i].first >> query[i].second, query[i].second -= 1;

    rep(i, Q) if(query[i].first == 'M') if(flag[query[i].second]) query[i].first = 'a'; else flag[query[i].second] = true;
    rep(i, N) if(!flag[i]) uf.unite(p[i], i);
    ll res = 0LL;
    rev(i, Q){
      if(query[i].first == 'M') uf.unite(p[query[i].second], query[i].second);
      if(query[i].first == 'Q') res += (ll)uf.root(query[i].second) + 1LL;
    }
    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 2944
# https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/all/DSL_2_B
import sys
input = sys.stdin.readline

n, q = map(int, input().split())

class RMQ:
    def __init__(self, n, e):
        # 単位元
        self.e = e
        # num_min:n以上の最小の2のべき乗
        self.num_min =2**(n-1).bit_length()
        self.seg=[self.e]*2*self.num_min

    def initialize(self, init):
        #初期値が指定されている場合
        #set_val
        for i in range(n):
            self.seg[i+self.num_min-1]=init[i]
        #built
        for i in range(self.num_min-2,-1,-1) :
            self.seg[i]=min(self.seg[2*i+1],self.seg[2*i+2])

    def update(self, k, x):
        k += self.num_min-1
        self.seg[k] += x
        while k:
            k = (k-1)//2
            self.seg[k] = self.seg[k*2+1] + self.seg[k*2+2]

    def query(self, p, q):
        q += 1
        if q<=p:
            return self.e
        p += self.num_min-1
        q += self.num_min-2
        res=self.e
        while q-p>1:
            if p&1 == 0:
                res += self.seg[p]
            if q&1 == 1:
                res += self.seg[q]
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res += self.seg[p]
        else:
            res += self.seg[p] + self.seg[q]
        return res

e = 0
rmq = RMQ(n, e)

for i in range(q):
    com, x, y = map(int, input().split())
    x -= 1
    if com == 0:
        rmq.update(x, y)
    else:
        y -= 1
        ans = rmq.query(x, y)
        print(ans)



Measured memory_bytes: 10968
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define MAX 200005
#define MOD 1000000007
#define endl "\n"
lli a[MAX];
lli b[MAX];
map <lli,lli> mp;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli N;
    cin>>N;
    lli ans = 0;
    for(lli i = 1; i<=N; i++){
        cin>>a[i];
        b[i] =  i - a[i];
        ans += mp[b[i]];
        mp[i+a[i]]++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 29316
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from collections import Counter
from random import randrange
def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    if Counter(A + B).most_common()[0][1] > n:
        print("No")
        return

    B.reverse()
    for i in range(n):
        if A[i] != B[i]:
            continue
        while 1:
            j = randrange(n)
            if A[i] != B[j] and A[j] != B[i]:
                B[i], B[j] = B[j], B[i]
                break
    print("Yes")
    print(*B)
resolve()

Measured memory_bytes: 154616
#include<bits/stdc++.h>
using namespace std;
string s;
int l, i, j, k, now, past;
long long ans, p = 1000000007, dp[100005][13];
int main(){
	cin>>s;
	l = s.size();
	for(i = l; i > 0; i--) s[i] = s[i-1];
	dp[0][0] = 1;
	for(i = 1; i <= l; i++){
		if(s[i] != '?'){
			now = s[i] - '0';
			for(j = 0; j < 13; j++)
				for(k = 0; k < 13; k++)
			    	if((10*k)%13 == (j-now+13)%13) dp[i][j] = (dp[i][j] + dp[i-1][k]) %p;
		}
		else{
			for(j = 0; j < 13; j++)
			    for(now = 0; now <= 9; now++)
			    	for(k = 0; k < 13; k++)
			    	    if((10*k)%13 == (j-now+13)%13) dp[i][j] = (dp[i][j] + dp[i-1][k]) %p;
		}
	}
	cout<<dp[l][5]<<endl;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素


int main(){
    string t,ans;
    cin>>t;
    int n=t.size();
    rep(i,n){
        if(t[i]=='?') ans+='D';
        else ans+=t[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3920
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll					long long
#define MOD					1000000007
#define MAX					1e9
#define MIN                 -1e9
#define PI					acos(-1.0)
#define vi					vector<int>
#define vii					vector<vi>
#define vll					vector<ll>
#define mid(s,e)			(s+(e-s)/2)

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
template<typename T>
void printVec(const T &v, char sep=' ') {for (auto &i: v) cout << i << sep;}
template<typename T>
void printVecPair(const T &v, char sep=' ') {for (auto &i: v) cout << i.first <<" " << i.second<< sep;}


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
	ll h; cin>>h;
	ll ans = 1LL << (64 - __builtin_clzll(h));
	cout<<ans-1;

	return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string src;
	cin>>src;
	string dest;
	cin>>dest;
	int ch=0;
	  for(int i=0;i<src.length();i++)
	  {
		  if(src[i]!=dest[i])
			ch++;
		 
	  }
	  cout<<ch<<endl;
	  
}

Measured memory_bytes: 3920
#include<iostream>
#include<cstdio>
using namespace std;
#define loop(i,a,b) for(int i = a ; i < b ; i++)
#define rep(i,a) for(int i = 0 ; i < a ; i++) 

int maze[10][10];
int smallx[5] = { 1,-1, 0, 0, 0};
int smally[5] = { 0, 0, 0, 1,-1};
int midx[4] = { 1, 1,-1,-1};
int midy[4] = { 1,-1, 1,-1};
int largex[4] = { 2,-2, 0, 0};
int largey[4] = { 0, 0, 2,-2};

bool inmaze(int x,int y){
  return (0<=x && x<10) && (0<=y && y<10);
	     
}
void Fsmall(int x,int y){
  rep(i,5)
    if(inmaze(x+smallx[i],y+smally[i]))
       maze[x+smallx[i]][y+smally[i]]++;
       
}
void Fmid(int x,int y){
  rep(i,4)
    if(inmaze(x+midx[i],y+midy[i]))
       maze[x+midx[i]][y+midy[i]]++;
}
void Flarge(int x,int y){
  rep(i,4)
    if(inmaze(x+largex[i],y+largey[i]))
    maze[x+largex[i]][y+largey[i]]++;
}
int main(void){
  int x,y,size;
  rep(i,10)rep(j,10)maze[i][j] = 0;
  while(scanf("%d,%d,%d",&x,&y,&size)!=EOF)
    switch(size){
    case 3:
      Flarge(x,y);
    case 2:
      Fmid(x,y);
    case 1:
      Fsmall(x,y);
    }
    
  int no = 0,ma = -1;
  rep(i,10)rep(j,10){
    if(maze[i][j] == 0)no ++;
    ma = max(ma,maze[i][j]);
  }
  cout<<no<<endl<<ma<<endl;
  
}

Measured memory_bytes: 1208
t = input()
t += "O"

str = []
i=0
while i < len(t):
  if t[i] != "?":
    str.append(t[i])
    i += 1
    continue
  elif t[i-1] == "P" and t[i] == "?":
    str.append("D")
    i+=1
  elif t[i] == "?" and t[i+1] == "D":
    str.append("P")
    i+=1
  elif t[i] == "?" and t[i+1] == "?":
    str.append("P")
    str.append("D")
    i += 2
  else:
    str.append("D")
    i+=1

StrA = "".join(str)
print(StrA[:-1])




Measured memory_bytes: 11092
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;

  unordered_map<string, int> ms;
  F0R(i, N) {
    string s;
    cin >> s;
    sort(rng(s));
    ms[s]++;
  }
  i64 result = 0;
  for (auto p : ms) {
    result += (i64)p.second * (p.second - 1) / 2;
  }
  cout << result;
}
#endif


Measured memory_bytes: 10356
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

const ll inf = 1LL<<60;

int N;
vector<vector<ll>> a(334, vector<ll>(334, 0));
vector<vector<ll>> dist(334, vector<ll>(334, inf));

void floyd(){
    rep(k, N){
        rep(i, N){
            if(dist[i][k] == inf) continue;
            rep(j, N){
                if(dist[k][j] == inf) continue;
                chmin(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
}

void input(){
    cin >> N;
    rep(i, N) rep(j, N) { cin >> a[i][j]; dist[i][j] = a[i][j]; }
}

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

    
    input();
    floyd();

    // ng check 
    rep(i, N) repr(j, i+1, N) if(dist[i][j] < a[i][j]) { cout << -1 << endl; return 0; }
    ll ans = 0;
    rep(i, N) repr(j, i+1, N) ans += dist[i][j];

    rep(i, N) repr(j, i+1, N){
        bool discard = false;
        rep(k, N) if(k != i && k != j){
            if(dist[i][k]+dist[k][j] == dist[i][j]) discard = true;
        }
        if(discard) ans -= dist[i][j];
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;


signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    int n;cin >> n;
    unordered_map<int, int> cnt;
    int in;
    FOR(i, n){
        cin >> in;
        cnt[in]++;
    }
    vi temp;
    for(pii tem:cnt)temp.pb(tem.second);
    sort(temp.begin(), temp.end(), greater<int>());
    vector<int> pre(n+1);
    FORD0(i, temp.size() -1){
       pre[i] = pre[i+1] + temp[i];
      // cout <<i << " " << pre[i] <<endl;
    }
    int tot = n;
    int loc = 0;
    int ans = n;
    FOR1(i, n){
        while(ans != (loc * ans + pre[loc])/i){
            ans = (loc*ans + pre[loc])/i;
        }
        if(i > temp.size()){
            cout << 0 <<endl;
            continue;
        }
        while(loc < temp.size() && ans < temp[loc]){
            loc++; 
            while(ans != (loc* ans + pre[loc])/i){
                ans = (loc*ans + pre[loc])/i;
            }
        }
        //        debug(loc);
        cout << ans <<endl;
    }

}




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

using namespace std;

using ll = long long;
using ld = long double;
using D = double;
using uint = unsigned int;
template<typename T>
using pair2 = pair<T, T>;

#ifdef WIN32
    #define LLD "%I64d"
#else
    #define LLD "%lld"
#endif

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

const int kk = 38;
const int maxn = 2005;

int a[maxn][maxn];

int main()
{
    int k = kk;
    int offset = 0;
//     while (k > 0)
//     {
        for (int i = 0; i < k; i++)
        {
            a[offset + i][offset] = 1;
            a[offset][offset + i] = 1;
            if (i == 0) continue;
            for (int j = 0; j < k - 1; j++)
            {
                a[offset + i][offset + k + (i - 1) * (k - 1) + j] = 1;
                a[offset + k + (i - 1) * (k - 1) + j][offset + i] = 1;
            }
        }
        for (int i = 0; i < k - 1; i++)
        {
            int st = 0;
            int addst = i;
            for (int j = 0; j < k - 1; j++)
            {
                for (int t = 0; t < k - 1; t++)
                {
                    a[offset + k + i * (k - 1) + (t + st) % (k - 1)][offset + k + j * (k - 1) + t] = 1;
                }
                st = (st + addst) % (k - 1);
            }
        }
//         offset += k;
//         k--;
//     }
    k = kk;
    int n = k * (k - 1) + 1;
    printf("%d %d\n", n, k);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++) if (a[i][j]) printf("%d ", j + 1);
        printf("\n");
    }
//     for (int i = 0; i < n; i++)
//     {
//         for (int j = 0; j < n; j++) cout << a[i][j];
//         cout << endl;
//     }
    fflush(stdout);
    for (int i = 0; i < n; i++)
    {
        assert(accumulate(a[i], a[i] + n, 0) == k);
        for (int j = i + 1; j < n; j++)
        {
            int sum = 0;
            for (int k = 0; k < n; k++) sum += a[i][k] * a[j][k];
            assert(sum == 1);
        }
    }
    for (int i = 0; i < n; i++)
    {
        int sum = 0;
        for (int k = 0; k < n; k++) sum += a[k][i];
        assert(sum == k);
    }
    return 0;
}

Measured memory_bytes: 12672
#include <iostream>

int main()
{
    int countFor5 = 0;
    int countFor7 = 0;
    int array[3];
    std::cin >> array[0] >> array[1] >> array[2];
    for(int i=0; i<3; i++)
    {
        if(array[i] == 5){
            countFor5++;
        }
        if(array[i] == 7){
            countFor7++;
        }
    }
    if(countFor5==2 && countFor7==1){
        std::cout << "YES" << std::endl;
        return 0;
    }

    std::cout << "NO" << std::endl;
    return 0;
}

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

int main() {
	
	int N,D;
	cin >>N >>D;
	
	vector<vector<int>> Cor(N, vector<int>(D));
	
	for(int i=0; i<N; i++){
		
		for(int j=0; j<D; j++){
			
			cin >>Cor.at(i).at(j);
			
		}
		
	}
	
	int ans =0;
	for(int i=0; i<N; i++){
		
	
		for(int j=i+1; j<N; j++){
			
			int total=0;
			
			for(int k=0; k<D; k++){
				
				int diff = abs(Cor.at(i).at(k)-Cor.at(j).at(k));
				total+=diff*diff;
				
			}
			
			bool flag =false;
			for(int k=0; k<=total; ++k){
				
				if(k*k==total){
					
					flag=true;
					
				}
				
			}
			
			if(flag) ans++;
		}
		
	}
	
	
	cout <<ans <<endl;
}

Measured memory_bytes: 256
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val s = readLine()!!.reversed()
    if (s != s.reversed()) {
        println("No")
        return
    }

    val pre = s.substring(0, (s.length - 1) / 2)
    if (pre != pre.reversed()) {
        println("No")
        return
    }

    val suf = s.substring((s.length + 3) / 2 - 1)
    if (suf != suf.reversed()) {
        println("No")
        return
    }
    println("Yes")
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 33776
#include <iostream>

using namespace std;

int main(){
  int n,m,x,y,toado;
  bool KT = false;
  int maxa=-10000,minb=10000;
  cin >> n>>m>>x>>y;
  for (int i =1;i<=n;i++){
    cin >>toado;
    if ( toado > maxa) maxa = toado;
  }
  for (int i =1;i<=m;i++){
    cin >>toado;
    if ( toado < minb) minb = toado;
  }
  for (int i = x+1 ;i<=y;i++)
    if ((i>maxa) && (i <= minb)) {
        KT = true;
        break;
    }
    if ( KT == true) cout << "No War"; else cout <<"War";
  return 0;
}

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

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

const int N = 2e5+10 , mod = 1e9+7;

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int l , r , d;
   cin >> l >> r >> d;
   cout << r / d - (l - 1) / d;
   return 0;
}


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

int absf (int n) {
    if (n < 0) return -n;
    else return n;
}

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

Measured memory_bytes: 1024
#include<stdio.h>

int main(){
  double r,ans1,ans2,pai;
  pai = 3.14159265359;
  scanf("%lf",&r);

  ans1 = r * r * pai;
  ans2 = r * 2 * pai;

  printf("%f %f\n",ans1,ans2);

  return 0;

}

Measured memory_bytes: 648
#include "bits/stdc++.h"

#define rep(i,n) for(int i = 0;i<n;i++)
#define vv(Type,Name, n,m,d)vector<vector<Type>> vv(n, vector<Type>(m, d));

using namespace std;
using ll = long long;


bool is_prime(int a) {
	if (a == 1) return false;

	for (int i = 2; i * i <= a; i++) {
		if (a % i == 0) return false;
	}
	return true;
}


int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);

	
	int n; cin >> n;
	
	while (true) {
		if (is_prime(n)) {
			cout << n << endl;
			return 0;
		}
		n++;
	}


	return 0;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	ll n; cin>>n;
  if(n%2!=0 || n<2){
    cout<<0<<endl;
    return 0;
  }
  ll c=0;
  ll x=n/2;
  while(x){
    x/=5;
    c+=x;
  }
  ll d=n/2;
  x=n/2;
  while(x){
    x/=2;
    d+=x;
  }
  cout<<min(c, d)<<endl;
	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

using namespace std;

int main() {
    int N;
    cin >> N;
    int current=0,prev=0;
    bool canNotDown = true;
    rep(i,N) {
        if(i==1) cin >> prev;
        else {
            cin >> current;
            if(prev>current){
                if(prev==current+1){
                    current++;
                }else{
                    canNotDown = false;
                    break;
                }
            }
            prev = current;
        }
    }

    cout << (canNotDown ? "Yes":"No") << endl;

}


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

int main() {
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	vector<int> vecX(N);
	vector<int> vecY(M);
	int count = 0;

	if (X >= Y)
		cout << "War" << endl;

	else {
		for (int i = 0; i < N; i++) {
			cin >> vecX.at(i);
			if (vecX.at(i) >= Y) {
				cout << "War" << endl;
				break;
			}
			count++;
		}
		
		if (count == N) {
			count = 0;
			sort(vecX.begin(), vecX.end());

			for (int i = 0; i < M; i++) {
				cin >> vecY.at(i);
				if (vecY.at(i) <= X || vecX.at(N - 1) >= vecY.at(i)) {
					cout << "War" << endl;
					break;
				}
				count++;
			}
			if(count==M)
				cout << "No War" << endl;
		}
	}
}

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

int main() {
    int s; cin >> s;
    set<int> st;
    int x = s;
    while (st.count(x) == 0) {
        st.insert(x);
        if (x % 2 == 0) x = x / 2;
        else x = x * 3 + 1;
    }

    cout << st.size() + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> ss(h); cin >> ss;
    int cnt = 1, rcnt = 1;
    vector<vector<int>> ans(h, vector<int>(w));
    for(int i = 0; i < h; i++){
        int cake = 0;
        for(int j = 0; j < w; j++){
            if(ss[i][j] == '#'){
                if(cake){
                    cnt++;
                }else{
                    cake = 1;
                }
            }
            for(int ii = i - rcnt + 1; ii < h; ii++){
                ans[ii][j] = cnt;
            }
        }
        if(cnt == k){
            break;
        }
        if(!cake){
            rcnt++;
        }else{
            rcnt = 1;
            cnt++;
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cout << ans[i][j] << ' ';
        }
        cout << '\n';
    }
}


Measured memory_bytes: 1280