akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>




using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const int INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;



void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> pr(n + 1, 0);
    for (int i = 0; i < n; ++i) {
        pr[i + 1] = pr[i];
        if (s[i] == '#')
            ++pr[i + 1];
    }
    int res = pr[n];
    int x = 0;
    for (int i = n - 1; i >= 0; --i) {
        if (s[i] == '.') 
            ++x;
        res = min(res, x + pr[i]);
    }
    cout << res << endl;


}

//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();


#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

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

const int N = 200200;
const int mod = 1e9 + 7;
const ll INF = 1e18;
int n,cnt;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
		cin>>n;
		fo(i,n)
		{
			int x;
			cin>>x;
			if(x%2==1)
				++cnt;
		}
		if(cnt&1)
		cout<<"NO";
		else cout<<"YES";
	return 0;	
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_solve
{
    class Program
    {
        static void Main(string[] args)
        {
            var data = Console.ReadLine().Split();
            var n = int.Parse(data[0]);
            var r = int.Parse(data[1]);
            var ans = 0;

            if (n >= 10)
            {
                ans = r;
            }
            else
            {
                ans =r+ (100 * (10 - n));
            }

            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <map>
#include <vector>

using namespace std;

const int MOD = 1000000007;

int main() {
    char s[100010];
    scanf("%s", s);

    int length = strlen(s);

    vector< vector<int> > dp;

    dp.resize(length);

    for (int i = 0; i < length; ++i) {
        dp[i].assign(13, 0);
    }

    for (int i = 0; i < length; ++i) {
        for (int j = 0; j < 13; ++j) {
            int r;

            if (i == 0) {
                r = (j == 0) ? 1 : 0;
            } else {
                r = dp[i-1][j];
            }

            if (s[i] == '?') {
                for (int k = 0; k < 10; ++k) {
                    int r2 = (j * 10 + k) % 13;
                    dp[i][r2] += r;
                    dp[i][r2] %= MOD;
                }
            } else {
                int r2 = (j * 10 + (int)s[i] - 48) % 13;
                dp[i][r2] += r;
                dp[i][r2] %= MOD;
            }
        }
    }

    printf("%d\n", dp[length - 1][5]);

    return 0;
}

Measured memory_bytes: 8960
#include <iostream>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using pii = pair<int, int>;
using pll = pair<LL, LL>;


int main()
{
    cin.sync_with_stdio(0);

    int x, y;
    cin >> x >> y;

    if (y % 2 == 0 && 2 * x <= y && y <= 4 * x)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

Measured memory_bytes: 3620
/*** keep hungry and calm CoolGuang!***/
#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define debug(x) cout<<#x<<":"<<x<<endl;
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("avx2")
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pp;
const ll INF=1e17;
const int Maxn=2e7+10;
const int maxn =3e5+10;
const int mod=1e9+9;
const int Mod = 1e9+7;
///const double eps=1e-10;
inline bool read(ll &num)
{char in;bool IsN=false;
    in=getchar();if(in==EOF) return false;while(in!='-'&&(in<'0'||in>'9')) in=getchar();if(in=='-'){ IsN=true;num=0;}else num=in-'0';while(in=getchar(),in>='0'&&in<='9'){num*=10,num+=in-'0';}if(IsN) num=-num;return true;}
ll n,m,p;
ll dp[maxn];
ll a[maxn];
int main()
{
    read(n);
    if(n>=1800&&n<=1999) printf("1\n");
    else if(n>=1600) printf("2\n");
    else if(n>=1400) printf("3\n");
    else if(n>=1200) printf("4\n");
    else if(n>=1000) printf("5\n");
    else if(n>=800) printf("6\n");
    else if(n>=600) printf("7\n");
    else printf("8\n");
    return 0;
}
/**
3 3 2
 0

**/


Measured memory_bytes: 3596
//
#include <vector>
#include <set>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
#define BIGP   1000000007
#define INF_I  std::numeric_limits<ll>::max()
#define INF_F  std::numeric_limits<float>::infinity()
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll K;
    cin >> K;
    ll c = 7 % K;
    ll r = 1;
    rep(i,K)
    {
        if (c == 0)
        {
            cout << r;
            return 0;
        }
        c = (c * 10 + 7) % K;
        ++r;
        
    }
    cout << -1;
    return 0;
}

Measured memory_bytes: 3184
=begin
        0
    3   1   2   4
        5
=end

a = gets.split(" ").map(&:to_i)
b = gets.split(" ").map(&:to_i)

"EEEESEEEESEEEESEEEESREEERREEE".each_char do |i|
    if i.eql?("N") then
        a[0], a[1], a[5], a[4] = a[1], a[5], a[4], a[0]
    elsif i.eql?("S") then
        a[0], a[1], a[5], a[4] = a[4], a[0], a[1], a[5]
    elsif i.eql?("E") then
        a[0], a[2], a[5], a[3] = a[3], a[0], a[2], a[5]
    elsif i.eql?("W") then
        a[0], a[2], a[5], a[3] = a[2], a[5], a[3], a[0]
    elsif i.eql?("R") then
        a[3], a[1], a[2], a[4] = a[4], a[3], a[1], a[2]
    elsif i.eql?("L") then
        a[3], a[1], a[2], a[4] = a[1], a[2], a[4], a[3]
    end

    if a == b then
        print "Yes\n"
        exit
    end
end

print "No\n"




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

using namespace std;

int main() {
    int n;
    cin >> n;
    while (n > 0) {
        if (n % 10 == 7) {
            cout << "Yes";
            return 0;
        }
        n /= 10;
    }
    cout << "No";
}


Measured memory_bytes: 3552
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    int k;
    cin >> k;
    int odd = 0, even = 0;
    FOR(i,1,k+1){
        if(i%2==0)even++;
        else odd++;
    }
    cout << even*odd << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N, M; std::cin >> N >> M;
  struct Edge {
    int from;
    int to;
    ll cost;
  };
  std::vector<Edge> G;
  std::vector<ll> d(N, -1e15); d[0] = 0;
  rep(i,M) {
    int a, b;
    ll c; std::cin >> a >> b >> c;
    a--, b--;
    G.push_back( { a, b, c } );
  }

  rep(i,N) rep(j,sz(G)) {
    auto&& e = G[j];
    if ( d[e.from] == -1e15 ) continue;
    if ( d[e.to] < d[e.from] + e.cost ) {
      d[e.to] = d[e.from] + e.cost;
    }
  }


  ll ans = d[N-1];
  std::vector<bool> negative(N);
  rep(i,N) rep(j,sz(G)) {
    auto&& e = G[j];
    if ( d[e.from] == -1e15 ) continue;
    if ( d[e.to] < d[e.from] + e.cost ) {
      d[e.to] = d[e.from] + e.cost;
      negative[e.to] = true;
    }
    if ( negative[e.from] ) negative[e.to] = true;
  }



  if ( negative[N-1] ) std::cout << "inf" << std::endl;
  else std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 384
// cycle detection in a directed graph
#include <iostream>
#include <stack>
#include <list>
#include <cstdlib> // rand(), abs()
#include <fstream> // file


using namespace std;

const int numVertex_max = 100;
const int numEdge_max = 1000;

class Graph{
public:
    Graph(int v); //construction function
    void addEdge(int u, int v);
    void printGraph();
    bool isCyclic();
protected:
private:
    int V; //number of vertexes
    // int E; //number of edges
    list<int>* adj; //pointer to save adjacent vertexes of each vertex
};


int main()
{
//    // import data from a txt file
//    int numVertex = 5;
//    // int numEdge = 3;
//    Graph myGraph(numVertex);
//    ifstream infile("input.txt");
//    int a, b;
//    while (infile >> a >> b){
//        myGraph.addEdge(a, b);
//    }
//    infile.close();

    //import data from command line
    int numVertex = 0;
    int numEdge = 0;
    cin >> numVertex >> numEdge;
    Graph myGraph(numVertex);
    int a, b;
    for (int i = 0; i < numEdge; i++) {
        cin >> a >> b;
        myGraph.addEdge(a, b);
    }

    // test : print out the graph
    //myGraph.printGraph();

    // test for cycle detection function
    if (myGraph.isCyclic()) {cout << "1\n";} else {cout << "0\n";}

    return 0;
}


Graph::Graph(int v) {
    V = v;
    adj = new list<int>[v];
}

void Graph::addEdge(int u, int v) {
    adj[u].push_back(v);
}

void Graph::printGraph() {
    for (int i = 0; i < V; i++) {
        cout <<  "adj[" << i << "]: ";
        list<int>::iterator it;
        for(it = adj[i].begin(); it != adj[i].end(); ++it) {
            cout << *it << " ";
        }
        cout << "\n";
    }
}

bool Graph::isCyclic() {
    bool isCycleDetected = false;
    //DFS: repeat until a cycle is detected
    stack<int> myStack;
    bool isDiscovered[V];
    for (int i = 0; i < V; i++){isDiscovered[i] = false;}
    for (int iVertex = 0; iVertex < V; iVertex++) {
		myStack.push(iVertex);
		// reset all elements to zero
		for (int i = 0; i < V; i++){isDiscovered[i] = false;}
		int v; //a temporary vertex
		while (!myStack.empty() && !isCycleDetected) {
			v = myStack.top();
			myStack.pop();
			if (!isDiscovered[v]) {
				isDiscovered[v] = true;
				list<int>::iterator it;
				for (it = adj[v].begin(); it != adj[v].end(); ++it) {
					if (*it == iVertex) {
						isCycleDetected = true;
						break;
					} else {
						myStack.push(*it);
					}
				}
			}
		}
		if (isCycleDetected) {break;}
    }

    if (isCycleDetected) {return true;} else {return false;}
}



Measured memory_bytes: 3124
#include<stdio.h>
#define compile 0
double func_cal_x(double a, double b, double c, double d, double e, double f);
double func_cal_y(double a, double b, double c, double d, double e, double f);
void func_output(double x, double y);
main()
{
	double a = 0, b = 0, c = 0, d = 0, e = 0, f = 0;
	
	while(scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF)
	{
		double x = 0.0, y = 0.0;
		x = func_cal_x(a, b, c, d, e, f);
		y = func_cal_y(a, b, c, d, e, f);
		func_output(x, y);
	}
	return 0;
}
double func_cal_x(double a, double b, double c, double d, double e, double f)
{
	double result = 0.0;
	result = (((b * f) - (c * e)) / ((b * d) - (a * e)));
	if(result == 0)
	{
		result = 0.0;
	}
#if compile == 1
	printf("x result = %lf\n", result);
#endif
	return result;
}
double func_cal_y(double a, double b, double c, double d, double e, double f)
{
	double result = 0.0;
	result = (((c * d) - (a * f)) / ((b * d) - (a * e)));
	if(result == 0)
	{
		result = 0.0;
	}
#if compile == 1
	printf("x result = %lf\n", result);
#endif
	return result;
}
void func_output(double x, double y)
{
	printf("%.3lf %.3lf\n", x, y);
}

Measured memory_bytes: 652
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(100000)


def read_values():
    return map(int, input().split())


def read_index():
    return map(lambda x: x - 1, map(int, input().split()))


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def functional(N, mod):
    F = [1] * (N + 1)
    for i in range(N):
        F[i + 1] = (i + 1) * F[i] % mod
    return F


def inv(a, mod):
    return pow(a, mod - 2, mod)


def C(F, a, b, mod):
    return F[a] * inv(F[a - b], mod) * inv(F[b], mod) % mod 


def main():
    N, K = read_values()
    mod = 10 ** 9 + 7
    F = functional(5 * 10 ** 5, mod)
    res = 0
    if N <= K:
        res = C(F, 2 * N - 1, N - 1, mod)
    else:
        c = C(F, N - 1, 0, mod)
        for k in range(K + 1):
            res += pow(c, 2, mod) * N * inv(N - k, mod) % mod
            c *= ((N - k - 1) * inv(k + 1, mod)) % mod
            c %= mod
    
    print(res % mod)

if __name__ == "__main__":
    main()

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

//////////

int main() {
    int a, b;
    cin >> a >> b;
    if ((a*b)%2 == 0) {
        cout << "Even" << endl;
    } else {
        cout << "Odd" << endl;
    }
}


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

int main(){

  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int dir[2];
  dir[0] = x2-x1;
  dir[1] = y2-y1;
  int x3, y3, x4, y4;
  x3 = x2 - dir[1];
  y3 = y2 + dir[0];
  x4 = x3 - dir[0];
  y4 = y3 - dir[1];
  cout << x3 << " " << y3 << " " <<x4 << " " << y4 << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define pd(a,n) for(int i=0;i<n;i++)cout<<a[i]<<((i==n-1)?"\n":" ");cout<<endl;
#define pdd(a,n,m)for(int i=0;i<n;i++){for(int j=0;j<m;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define mp make_pair
#define pb push_back
#define ll long long
//#define __int64 lng long
#define P pair<int,int>
#define PP pair<P,int>

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

  return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

int main(){
    string s;
    cin >> s;
    bool ans = false;
    for (char i : s) {
        if (i == '7') ans = true;
    }
    cout << (ans?YES:NO) << endl;
    return 0;
}


Measured memory_bytes: 3632
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class DSumOfDivisors {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<ll> vec(n+1);
      for(int i=1; i<=n; i++) {
        for(int j=i; j<=n; j+=i) {
          vec[j]++;
        }
      }
      ll ans = 0;
      for(int i=1; i<=n; i++) {
        ans += vec[i]*i;
      }
      cout << ans << endl;


    }
};

signed main() {
  DSumOfDivisors solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 81376
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int N, M;
    cin >> N >> M;
    auto G = make_vec<int>(N, N);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a][b] = 1;
        G[b][a] = 1;
    }

    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        A[i] = i;
    }

    long long ans = 0;
    do {
        if (A[0] != 0) break;
        bool flag = true;
        for (int i = 0; i < N - 1; i++) {
            if (G[A[i]][A[i + 1]] == 0) {
                flag = false;
                break;
            }
        }
        if (flag) ans++;
    } while (next_permutation(A.begin(), A.end()));
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ss second
#define ff first
#define pb push_back
#define all(v) v.begin(),v.end()
#define unik(v)  v.erase(unique(v.begin(),v.end()),v.end())
using namespace std;
typedef pair<int, int> pii;
const ll mod = 998244353;
const int sz = 1000 + 3, inf = 1e9 + 10;
int a[sz];
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int n, m;
	cin >> n >> m;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}

	int avg = (sum / (4 * m));
	if ((sum % (4 * m)) >= 1)avg++;
	//cout<<avg<<'\n';
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] >= avg)cnt++;
	}

	if (cnt >= m)cout << "Yes\n";
	else cout << "No\n";




	return 0;
}

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

using namespace std;

int maxtime(int x) {
    return (x + 9) / 10 * 10;
}

int remtime(int x) {
    return maxtime(x) - x;
}

int main() {
    
    int A, B, C, D, E;
    int sum = 0;

    cin >> A >> B >> C >> D >> E;

    sum = maxtime(A) + maxtime(B) + maxtime(C) + maxtime(D) + maxtime(E);

    sum -= max({ remtime(A), remtime(B), remtime(C), remtime(D), remtime(E) });
   
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
SA = list(input())
SB = list(input())
SC = list(input())

a = -1
b = -1
c = -1

nA = len(SA)
nB = len(SB)
nC = len(SC)

m = 'a'
while True:
    if m == 'a':
        a += 1
        if a == nA:
            print("A")
            exit()
        m = SA[a]
    elif m == 'b':
        b += 1
        if b == nB:
            print("B")
            exit()
        m = SB[b]
    else:
        c += 1
        if c == nC:
            print("C")
            exit()
        m = SC[c]


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

int main(void){
  int n;
  int in[100];

  cin >> n;

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

  for(int i = 0; i < n; i++){
    cout << in[n - i - 1];

    if(i != n - 1)
      cout << " ";
  }

  cout << endl;

  return 0;
}

Measured memory_bytes: 1160
#define _USE_MATH_DEFINES

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

using namespace std;

//typedef pair<long long int, long long int> P;
long long int INF = 1e18;

int K, R, L;
double P, E, T;

double func(int depth, double l, double r, double dist, double p){
	//cout << l << " " << r << " " << p << endl;
	if(depth == K){
		if((l + r) / 2 <= dist){
			return p;
		}
		return 0;
	}
	double mid = (l + r) / 2;
	double ret = 0;
	if(mid < dist){
		if(mid < T){
			ret += p * P;
			ret += func(depth + 1, mid, r, dist, p - p * P);
		}else{
			ret += p * (1 - P);
			ret += func(depth + 1, mid, r, dist, p * P);
		}
	}else{
		if(mid < T){
			ret += func(depth + 1, l, mid, dist, p * P);
		}else{
			ret += func(depth + 1, l, mid, dist, p - p * P);
		}
	}
	//cout << l << " " << r << " " << ret << endl;
	return ret;
}

int main(){
	
	cin >> K >> R >> L;
	cin >> P >> E >> T;
	
	double ans = 0;
	ans += func(0, R, L, T + E, 1);
	ans -= func(0, R, L, T - E, 1);
	printf("%.10f\n", ans);
	
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)
bool cmp(string &a,string &b) {
	return a+b<b+a;
}
void solve(int test_case) {
	int n;
	cin>>n;
	int arr[26];
	fill(arr,arr+26,-1);
	while(n--){
		string s;
		cin>>s;
		unordered_map<char,int> m;
		for(char c:s)m[c]++;
		for(char c='a';c<='z';c++) {
			if(arr[(int)(c-'a')]==-1)arr[(int)(c-'a')]=m[c];
			arr[(int)(c-'a')]=min(arr[(int)(c-'a')],m[c]);
		}
	}
	vector<string> v;
	for(int i=0;i<26;i++) {
		if(arr[i]<=0)continue;
		while(arr[i]--)v.PUB(string(1,(char)(i+'a')));
	}
	sort(v.begin(),v.end(),cmp);
	string sol="";
	for(string s:v)sol+=s;
	cout<<sol;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
}	


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
Aをいれかえて全合格。そのとき、動いたものの最小数
sortすれば-1判定はできる
sortして、左から右へは交換可能か。
同じ数字OKがきつい
まずBでsortしてナンバリングするか？
Bが同じ数字だったときのナンバリングのずれか

A235
B341

 012numb
A523
B134sort

 120
A235sort
B134

A233
B221

 012numb
 332
B122sort

 201
A233sort
B122

6
1 2 3 5 6 4
2 2 2 1 5 5
3ってでるはずなのに4だな

A123564
B222155

A512364
B122255

 012345が正しい
 123504
A123456
B122255

 012345が正しい
 132504
A132456
B122255

 012345が正しい
 152304
A142356
B122255

 012345が正しい
 152340←これがかえられるのか
A142365
B122255

63189252 64991604   11 0
74164189 195848680  8  1
78303147 740174259  2  2
98239366 372327760  3  3
110823640 440075441 9  4
118867039 458054863 5  5
122948912 529866931 6  6
147060907 354974235 7  7
362739947 463477172 0  8
465611891 632963102 4  9
501410831 615762794 10 10
572905212 757232153 1  11

63189252  64991604  11 0確定
74164189  757232153 1  1
78303147  740174259 2  2
98239366  372327760 3  3
110823640 440075441 9  4
118867039 458054863 5  5
122948912 195848680 8  6
147060907 354974235 7  7
362739947 463477172 0  8
465611891 529866931 6  9
501410831 615762794 10 10
572905212 632963102 4  11　1,2,4

sortしたあと、なるべく小さいのが末尾にくるようにしてみる？
該当するものが無い場合、一番低い数をいれる？
その低い数が適当だったらOUT
もともとみたしているものが候補。
みたしてないのとみたしてるのソート。

問題勘違いしてた。総和が等しい、か。
数字は自由に選べて、そのうえでいくつかえらえれるか、か。
AとBの差をだす。
A-B>=0なら変更しなくてもすむ可能性ある。
A-B<0なら、だめ
総和を出して、A-Bが割り振りできるポイント。
差が小さいものから採択していけばいいか。
*/
int main(){
  ll N,ans=0; cin>>N;
  vector<ll> A(N,0),B(N,0),D(N,0);
  for(ll i=0; i<N; i++) cin>>A[i];
  for(ll i=0; i<N; i++) cin>>B[i];
  ll asum=0,bsum=0;
  for(ll i=0; i<N; i++) asum+=A[i];
  for(ll i=0; i<N; i++) bsum+=B[i];
  ll p=asum-bsum;//自由に割り振れるポイント。
  if(p<0){
    cout<<-1<<endl;
    return 0;
  }
  for(ll i=0; i<N; i++) D[i]=A[i]-B[i];
  sort(D.begin(), D.end());
  for(ll i=0; i<N; i++){
    if(p-D[i]<0) break;
    if(D[i]>=0){
      p-=D[i];
      ans++;
    }
  }
  cout<<N-ans<<endl;
}

Measured memory_bytes: 2688
#include <iostream>
#include <map>

using namespace std;
#define in(v) v; cin >> v;
#define rep(i,n) for(int i=0;i<(n);++i)

template<int MOD> struct MInt {
  long long val;
  MInt(long long val = 0) : val(val % MOD) { if (val < 0) val += MOD; }
  MInt operator+(const MInt& n) const { return MInt(val) += n; }
  MInt operator*(const MInt& n) const { return MInt(val) *= n; }
  MInt operator/(const MInt& n) const { return MInt(val) /= n; }
  MInt& operator+=(const MInt& n) { val = (val + n.val) % MOD; return *this; }
  MInt& operator*=(const MInt& n) { val = (val * n.val) % MOD; return *this; }
  MInt& operator/=(const MInt& n) { val = (*this * n.inv()).val; return *this; }
  MInt pow(long long n) const {
    MInt pow = val, ans = 1;
    for (long long p = n; p > 0; p >>= 1) {
      if (p & 1) ans *= pow;
      pow *= pow;
    }
    return ans;
  }
  MInt inv() const { return pow(MOD-2); }
  friend ostream& operator<<(ostream& os, const MInt& n) { os<<n.val; return os; }
};
using mint = MInt<1000000007>;

const int MAX_N = 100100;
mint fac[MAX_N], inv[MAX_N];
int main() {
  int in(N); int in(M);

  fac[0] = inv[0] = 1;
  rep(i, MAX_N-1) {
    fac[i+1] = fac[i] * (i+1);
    inv[i+1] = inv[i] / (i+1);
  }

  map<int, int> m;
  for (int i = 2; i * i <= M; ++i) {
    while (M % i == 0) {
      M /= i;
      ++m[i];
    }
  }
  if (M > 1)
    ++m[M];

  mint ans = 1;
  for (const auto& e : m)
    ans *= fac[e.second + (N-1)] * inv[e.second] * inv[N-1];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    REP(i, a + 1)REP(j, b + 1)REP(k, c + 1) {
        if(i * 500 + j * 100 + k * 50 == x) ans++;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 892
a=int(input())
b=int(input())
c=int(input())
X=int(input())
count=0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      A=500*i+100*j+50*k
      if A==X:
        count+=1
print(count)


Measured memory_bytes: 9096
#include <bits/stdc++.h>
#define foi(i,k,n) for(int i = (int)k; i < (int)n; ++i)

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

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  int x,y; cin >> x >> y;
  for (int a = 0; a <= 100; a++) {
    for (int b = 0; b <= 100; ++b) {
      if (2*a+4*b == y && a+b == x) {
        cout << "Yes" << '\n';
        return 0;
      }
    }
  }
  cout << "No" << '\n';
  return 0;
}


Measured memory_bytes: 3648
#pragma GCC optimize(2)
#include<bits/stdc++.h>
typedef long long ll;
const int maxn=1e7+5+5e6;
using namespace std;
const ll INF=1e15+7;
const ll mod=1e9+7;
ll n,m,p;
ll zero[1000];
ll one[1000];
ll qpow(ll a,ll b)
{
    ll ans=1;
    while(b)
    {
        if(b%2) ans=(ans*a)%mod;
        b/=2;a=(a*a)%mod;
    }
    return ans;
}
int main()
{
    scanf("%lld",&n);
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        ll x;
        scanf("%lld",&x);
        for(int k=64;k>=1;k--)
        {
            if(x&(1ll<<(k-1)))
            {
                sum+=zero[k]*qpow(2,k-1);
                one[k]++;
                sum%=mod;
            }
            else
            {
                sum+=one[k]*qpow(2,k-1);
                zero[k]++;
                sum%=mod;
            }
        }
    }
    printf("%lld\n",sum);
    return 0;
}


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

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

Measured memory_bytes: 3648
fun main(args: Array<String>) {
    agc010a()
}

fun agc010a() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map { it.toLong() }

    val answer = if (aList.count { it % 2 != 0L } % 2 == 0) "YES" else "NO"

    println(answer)
}


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

int main(){
  int n;
  cin >> n;
  int h,j,i;
  h = n/100;
  j = (n-h*100)/10;
  i = (n-h*100-j*10);

  cout << (10-i)+(10-j)*10+(10-h)*100 <<endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())

count = 0
N_copy = N
while N_copy != 0:
    N_copy //= 26
    count += 1

ans = ""
alpha = "abcdefghijklmnopqrstuvwxyz"
for i in range(count):
    #print(N, ans)
    ans = alpha[N%26-1] + ans
    if N%26 == 0:
        N //= 26
        N -= 1
    else:
        N //= 26

if ans[0] == "z":
    print(ans[1:len(ans)])
else:
    print(ans)

Measured memory_bytes: 9188
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;
int main(){
  ll h,sum=0,n;
  cin >> h >> n;
  rep(i,n){
    int a; cin >> a;
    sum += a;
  }

  if(sum>=h) puts("Yes");
  else puts("No");
}


Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i += 2) {
		int cnt = 0;
		for (int j = 1; j <= i; j++) {
			if (i%j == 0) cnt++;
		}
		if (cnt == 8) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n, k; cin >> n >> k;
    vector<int> a(n), sum(n + 1, 0), psum(n + 1, 0);
    rep(i, n) {
        cin >> a[i];
        sum[i + 1] = sum[i] + a[i];
        psum[i + 1] = psum[i] + (a[i] > 0 ? a[i] : 0);
    }
    int ans = 0;
    for(int r = k; r <= n; ++ r) {
        int l = r - k;
        int res = max(0LL, sum[r] - sum[l]);
        res += psum[n] - (psum[r] - psum[l]);
        chmax(ans, res);
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

using namespace std;
typedef long long ll;
const int MAXN = 1000100;

int N;
int arr[MAXN];

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> N;
    for (int i = 0; i < N; i++)
        cin >> arr[i];

    vector <int> v;
    for (int i = N - 1; i >= 0; i -= 2)
        v.push_back(arr[i]);
    for (int i = N % 2; i < N; i += 2)
        v.push_back(arr[i]);

    for (int x : v)
        cout << x << " ";
    cout << "\n";
}

Measured memory_bytes: 4084
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#define ll long long int
#define MOD 1000000007LL
using namespace std;
bool G[10][10];
const int NMAX=8;
int dfs(int s,int n,bool v[NMAX]){
    bool av=true;
    for(int i=0;i<n;i++){
        if(v[i]==false){
            av=false;
        }
    }
    if(av){
        return 1;
    }
    int r=0;
    for(int i=0;i<n;i++){
        if(G[s][i]){
            if(!v[i]){
                v[i]=true;
                r+=dfs(i,n,v);
                v[i]=false;
            }
        }
    }
    return r;
}
int main() {
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            G[i][j]=false;
        }
    }

    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a][b]=true;
        G[b][a]=true;
    }
    bool visited[NMAX];
    for(int i=0;i<NMAX;i++){
        visited[i]=false;
    }
    visited[0]=true;
    cout<<dfs(0,n,visited)<<endl;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn readu() -> usize {
    read::<usize>()
}

#[allow(dead_code)]
fn readi() -> i32 {
    read::<i32>()
}

pub fn gcd(a: usize, b: usize) -> usize {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut g = gcd(a[0], a[1]);
    for ai in &a {
        g = gcd(g, *ai);
    }
    println!("{}", g);
}

Measured memory_bytes: 4352
def prepare(n, MOD):
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
    return factorials, invs


b, w = map(int, input().split())
MOD = 10 ** 9 + 7
I2 = 500000004  # 2^(-1) mod MOD
factorials, inverses = prepare(b + w, MOD)
buf = []
denom = I2
pi, qi = 0, 0
for i in range(b + w):
    if i >= b:
        pi *= 2
        pi += factorials[i - 1] * inverses[i - b] * inverses[b - 1]
        pi %= MOD
    if i >= w:
        qi *= 2
        qi += factorials[i - 1] * inverses[i - w] * inverses[w - 1]
        qi %= MOD
    buf.append((I2 - (pi - qi) * denom) % MOD)
    denom = denom * I2 % MOD
print('\n'.join(map(str, buf)))


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

int main() {
    long long n, k;
    cin >> n >> k;
    vector<int> a(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    // --
    int seg = 0;
    int loop = 0;
    vector<int> AtStep (2*n, 1);
    vector<int> Reach (n, -1);
    //
    Reach[0] = 0;
    AtStep[0] = 0;
    for (int city = 0, step = 1; step <= 2*n; step++) {
        if (Reach[a[city]] != -1) {
            loop = step - Reach[a[city]];
            seg = Reach[a[city]];
            break;
        }
        //
        city = a[city];
        Reach[city] = step;
        AtStep[step] = city;
    }
    //
    //cout << seg << " " << loop << endl;
    //
    if (k < seg) {
        cout << AtStep[k]+1 << endl;
    } else {
        k = k - seg;
        k %= loop;
        int city = AtStep[seg];
        //cout << "At Start of Loop" << AtStep[seg] << endl;
        while (k > 0) {
            k--;
            city = a[city];
        }
        cout << city+1 << endl;
    }
}

Measured memory_bytes: 6360
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll n;
    cin >> n;
    set<ll> a;
    for(int i = 0; i < n; i++)
    {
        ll tmp;
        cin >> tmp;
        a.insert(tmp);
    }
    set<ll>::iterator itr = a.end();
    ll x = *--itr;
    ll y = 0;
    ll border = x/2;
    if(x % 2 == 1) border++;
    ll cand1 = *lower_bound(a.begin(), a.end(), border);
    ll cand2 = *--lower_bound(a.begin(), a.end(), border);
    ll c1 = abs(cand1 - border);
    ll c2 = abs(cand2 - border);
    if(c1 < c2)
    {
        y = cand1;
    }
    else
    {
        y = cand2;
    }
    cout << x << " " << y << endl;
}



Measured memory_bytes: 4992
from heapq import heappop, heappush, heapify
n,m = map(int, input().split())
a = list(map(int, input().split()))
b = [-i for i in a]
b.sort()

heapify(b)
for i in range(m):
    q = heappop(b)
    q /= 2
    heappush(b, q)

ans = sum(int(-i) for i in b)
print(ans)

Measured memory_bytes: 81176
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

int main() {
	string A, B, C;
	cin >> A >> B >> C;
	cout << 'A' << B[0] << 'C' << enld;
}

Measured memory_bytes: 256
n,c=map(int, input().split())
a = [[0,0]]+[list(map(int, input().split())) for i in range(n)]
l=[[0,0] for i in range(n+1)]
r=[[0,0] for i in range(n+1)]
b = 0
b1 = 0
# 最大値を格納
x=[0]*(n+1)
y=[0]*(n+1)
ans=0
ansl=0
ansr=0

#  時計周りで累積和を取る。折り返しがない時の最大値を探す。
ans1=-10**20
ans2=-10**20
for i in range(n+1):
    b+=a[i][1]
    l[i][0]=a[i][0]
    l[i][1]=b
    if b-l[i][0]>ans1:
        ans1=b-a[i][0]
        x[i]=ans1
    else:
        x[i]=x[i-1]

for i in range(n+1):
    b1+=a[-i][1]
    r[i][0]=c-a[-i][0]
    r[i][1]=b1
    if b1-r[i][0]>ans2:
        ans2=b1-r[i][0]
        y[i]=ans2
    else:
        y[i]=y[i-1]
r[0][0]=0
y[0]=0


# 反時計周りで折り返して時計周りへ進む
for i in range(n):
    cnt=x[n-i]+r[i][1]-2*r[i][0]
    ansr=max(cnt,ansr)

# 時計周りで折り返して反時計周りへ進む
for i in range(n):
    cnt=y[n-i]+l[i][1]-2*l[i][0]
    ansl=max(cnt,ansl)
print(max(ansr,ansl))

Measured memory_bytes: 87480
#include <algorithm>
#include <cstdio>
using namespace std;
const int N = 100010;
int n, x, y, len;
long long ans;
int a[N][2];
int idx[N], idy[N];
bool fx[N * 4], fy[N * 4];
int d[N];
bool bz[N];
int dis(int x, int y, int xx, int yy) {
    return max(abs(xx - x) , abs(yy - y));
}
void build(int l, int r, int s) {
    fx[s] = fy[s] = 1;
    if (l == r) return;
    build(l, (l + r)/ 2, s + s);
    build((l + r) / 2 + 1, r, s + s + 1);
}
void work1(int l, int r, int s) {
    if (!fy[s]) return;
    fy[s] = 0;
    if (l == r) {
        if (!bz[idy[l]])
            bz[d[++d[0]] = idy[l]] = 1;
        return;
    }
    work1(l, (l + r) / 2, s + s);
    work1((l + r) / 2 + 1, r, s + s + 1);
}

void work2(int l, int r, int s) {
    if (!fx[s]) return;
    fx[s] = 0;
    if (l == r) {
        if (!bz[idx[l]])
            bz[d[++d[0]] = idx[l]] = 1;
        return;
    }
    work2(l, (l + r) / 2, s + s);
    work2((l + r) / 2 + 1, r, s + s + 1);
}
void search1(int l, int r, int s, int ll, int rr, int lll) {
    if (a[idy[r]][1] < lll || a[idy[l]][1] > lll) return;
    if (a[idy[l]][1] == a[idy[r]][1] && (a[idy[l]][0] > rr ||a[idy[r]][0] < ll)) return;
    if (a[idy[l]][1] == a[idy[r]][1] && (a[idy[l]][0] >= ll &&a[idy[r]][0] <= rr)) {
        ans += r-l  +1;
        work1(l, r, s);
        return;
    }
    search1(l, (l + r ) / 2, s + s, ll, rr, lll);
    search1((l + r ) / 2 + 1, r, s + s + 1, ll, rr, lll);
    fy[s] = fy[s + s] | fy[s+s+1];
}

void search2(int l, int r, int s, int ll, int rr, int lll) {
    if (a[idx[r]][0] < lll || a[idx[l]][0] > lll) return;
    if (a[idx[l]][0] == a[idx[r]][0] && (a[idx[l]][1] > rr ||a[idx[r]][1] < ll)) return;
    if (a[idx[l]][0] == a[idx[r]][0] && (a[idx[l]][1] >= ll &&a[idx[r]][1] <= rr)) {
        ans += r-l  +1;
        work2(l, r, s);
        return;
    }
    search2(l, (l + r ) / 2, s + s, ll, rr, lll);
    search2((l + r ) / 2 + 1, r, s + s + 1, ll, rr, lll);
    fx[s] = fx[s + s] | fx[s+s+1];
}
int main() {
    scanf("%d %d %d", &n, &x, &y);
    for (int i =1; i <= n ; i ++) {
        int x ,y;
        scanf("%d %d", &x, &y);
        a[i][0] = x - y;
        a[i][1] = x + y;
        idx[i] = idy[i] = i;
    }
    len = dis(a[x][0], a[x][1], a[y][0], a[y][1]);
    sort(idx + 1, idx + n + 1, [](const int & x, const int & y) {
        return a[x][0] < a[y][0] || (a[x][0] == a[y][0] && a[x][1] < a[y][1]);
    });
    sort(idy + 1, idy + n + 1, [](const int & x, const int & y) {
        return a[x][1] < a[y][1] || (a[x][1] == a[y][1] && a[x][0] < a[y][0]);
    });
    build(1, n, 1);
    d[0] = 2;
    d[1] = x;
    d[2] = y;
    bz[x] = bz[y] = 1;
    for (int i = 1; i <= d[0]; i ++)
    {
        int x  = d[i];
        search1(1, n, 1, a[x][0] - len, a[x][0] + len, a[x][1] - len);
        search1(1, n, 1, a[x][0] - len, a[x][0] + len, a[x][1] + len);
        search2(1, n, 1, a[x][1] - len + 1, a[x][1] + len - 1, a[x][0] - len);
        search2(1, n, 1, a[x][1] - len + 1, a[x][1] + len - 1, a[x][0] + len);
    }
    printf("%lld\n", ans / 2);
    return 0;
}

Measured memory_bytes: 2816