akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>
#include<unordered_set>
#include<unordered_map>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> ret;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i] ++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

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



// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll n, q;
	cin >> n >> q;

	vll ft(n, 0);
	auto add = [&](ll p, ll x) {
		for (ll k = p + 1; k <= n; k += k & -k) {
			ft[k - 1] += x;
		}
	};

	auto sum = [&](ll l, ll r) {
		ll ret = 0;
		for (ll k = r ; k > 0; k -= k & -k) {
			ret += ft[k-1];
		}
		for (ll k = l ; k > 0; k -= k & -k) {
			ret -= ft[k-1];
		}
		return ret;
	};


	rep(i,0, n) {
		ll a;
		cin >> a;
		add(i, a);
	}
	rep(i, 0, q) {

		ll t;
		cin >> t;
		if (t) {
			ll l, r;
			cin >> l >> r;
			cout << sum(l, r) << endl;
		}
		else {
			ll p, x;
			cin >> p >> x;
			add(p, x);
		}
	}

	return 0;
}


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


int main(){
    int N; cin >> N;
    vector<int> P(N);
    rep(i, N) cin >> P[i];

    int ans = 0;
    int minv = 300000;

    rep(i, N){
        if(minv >= P[i]){
            ans++;
            minv = P[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
# coding: utf-8
# Your code here!
import sys
N,M = map(int,input().split())
gates = []
for i in range(M):
    r = list(map(int, input().split()))
    gates.append(r)

left = gates[0][0]
right = gates[0][1]
#print(gates)
#print("left = " + str(left))
#print("right = " + str(right))
for i in range(1, M):
    if right >= gates[i][0]: #重なっていれば
        left = max([left, gates[i][0]])
        right = min([right, gates[i][1]])
        #print("left = " + str(left))
        #print("right = " + str(right))
    else:
        print(0)
        sys.exit()
print(right - left + 1)
    

Measured memory_bytes: 60888
// Problem : A - ∴ (Therefore)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
vector<string>vec_splitter(string s){s+=',';vector<string>res;while(!s.empty()){res.push_back(s.substr(0,s.find(',')));s=s.substr(s.find(',')+1);}
return res;}
void debug_out(vector<string>__attribute__((unused))args,__attribute__((unused))int idx,__attribute__((unused))int LINE_NUM){cerr<<endl;}
template<typename Head,typename...Tail>void debug_out(vector<string>args,int idx,int LINE_NUM,Head H,Tail...T){if(idx>0)cerr<<", ";else cerr<<"Line("<<LINE_NUM<<") ";stringstream ss;ss<<H;cerr<<args[idx]<<" = "<<ss.str();debug_out(args,idx+1,LINE_NUM,T...);}
#define XOX
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
#define ll          long long
#define ld          long double
#define ull         unsigned long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define Mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)      (a).rbegin(),(a).rend()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define mod        1000000007
//#define mod        998244353
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define INF         numeric_limits<ll>::max();
#define NINF        numeric_limits<ll>::min();
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))
#define vvd(a,b,name)    vector<vector<double>> name(a,vector<double>(b,-1))
//const ld pi=3.14159265359;
inline ll add(ll a,ll b,ll m){
    if((a+b)>=m)return (a+b)%m;
    return a+b;
}
inline ll mul(ll a,ll b,ll m){
    if((a*b)<m)return a*b;
    return (a*b)%m;
}
map<int,string> m;
void solve(){
	int n;cin>>n;
	m[3]="bon";
	m[0]=m[1]=m[6]=m[8]="pon";
	m[2]=m[4]=m[5]=m[7]=m[9]="hon";
	cout<<m[n%10]<<endl;
	
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3664
import java.util.*;

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

    int A = sc.nextInt();
    int B = sc.nextInt();

    if (A > 8 || B > 8) {
      System.out.println(":(");
    } else {
      System.out.println("Yay!");
    }
  }
}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string.h>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>

#define ll long long
#define INF 0x3f3f3f3f
#define clr(x) memset(x,0,sizeof(x))
#define clr2(x) memset(x,INF,sizeof(x))
#define clr3(x) memset(x,-INF,sizeof(x))
#define clr4(x) memset(x,-1,sizeof(x))
#define pb(x) push_back(x)
//#define debug

using namespace std;
const ll mod=1e9+7;

ll a[1234457],b[1234567],num[1234556];
void solve()
{
   int n,x;
   ll res=0;
   scanf("%d%d",&n,&x);

   for (int i=1;i<=n;i++)
    {
        scanf("%lld",&num[i]);
        a[i]=num[i];
        b[i]=num[i];
    }

   for (int i=2;i<=n;i++)
   {
       if (a[i]+a[i-1]>x)
       {
           res+=(a[i]+a[i-1]-x);
           a[i]-= (a[i]+a[i-1]-x);

       }
       if (a[i]<0) a[i]=0;
   }

   ll res2=0;

   for (int i=n-1;i>=1;i--)
   {
      if (b[i]+b[i+1]>x)
      {
          res2+= b[i] + b[i+1] - x;
          b[i]-=b[i] + b[i+1] - x;
      }
      if (b[i]<0) b[i]=0;
   }
   printf("%lld\n",min(res,res2));
}
int main()
{
    #ifdef debug
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif


        solve();


    return 0;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n; cin >> n;
    int ans = inf;
    for(int i = 1; i <= (n+1)/2; ++i) {
        int j = n-i;
        int p = 0;
        string s = to_string(i);
        for(auto ch : s) p += (ch-'0');
        s = to_string(j);
        for(auto ch : s) p += (ch-'0');

        chmin(ans, p);
    }

    cout << ans << '\n';
    // printf("ExcutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}

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

using namespace std;

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

int main() {
    int n;
    cin >> n;
    int debt = 100000;
    REP(i, n) {
        debt *= 1.05;
        if (debt % 1000 != 0) {
            debt -= debt % 1000;
            debt += 1000;
        }
    }
    cout << debt << endl;
    return 0;
}

Measured memory_bytes: 2992
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

vector<ll> dijkstra(ll s, vector<vpl> &G, ll n){
	vl d(n,linf);
	d[s] = 0;
	priority_queue<P,vector<P>,greater<P>> pq;
	pq.emplace(0,s);
	while(!pq.empty()){
		auto p = pq.top(); pq.pop();
		ll u = p.second;
		if(d[u] < p.first) continue;
		for(auto v : G[u]){
			if(d[v.first] > d[u] + v.second){
				d[v.first] = d[u] + v.second;
				pq.emplace(d[v.first], v.first);
			}
		}
	}
	return d;
}

int main(){
	ll n,m,s; cin >> n >> m >> s;
	vector<vpl> G(n);
	rep(i,m){
		ll u,v,d; cin >> u >> v >> d;
		G[u].emplace_back(v,d);
	}
	auto dist = dijkstra(s,G,n);
	for(auto v : dist){
		if(v != linf) cout << v << "\n";
		else cout << "INF" << "\n";
	}
}


Measured memory_bytes: 19384
#include<bits/stdc++.h>
using namespace std;
const int N=10;
int n,m,a[N],b[N];
bool judge(int x)
{
    int tot=0,s[N];
    while(x)
    {
        s[++tot]=x%10;x/=10;
    }
    if(tot==0) s[++tot]=0;
    if(tot!=n) return false;
    reverse(s+1,s+1+tot);
    for(int i=1;i<=m;i++)
        if(s[a[i]]!=b[i]) return false;
    return true;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++) scanf("%d%d",&a[i],&b[i]);
    for(int i=0;i<=999;i++)
        if(judge(i))
    {
        printf("%d\n",i);return 0;
    }
    printf("-1\n");
}


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

int n;
long long dp[55][3030];
long long ans;
int x[60];
int A;

int main()
{
	memset(dp,-1,sizeof dp);
	scanf("%d %d",&n,&A);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&x[i]);
 }
	for(int i=0;i<n;i++)
		for(int j=i+1;j>=0;--j)
			for(int t=0;t<2501;t++)
			{
				if(j==0)
				{
					if(dp[1][x[i]]==-1)	dp[1][x[i]]=1;
					else dp[1][x[i]]++;
					break;
				}
				else
				{
					if(dp[j][t]==-1)	continue;
					if(dp[j+1][t+x[i]]==-1)	dp[j+1][t+x[i]]=dp[j][t];
					else dp[j+1][t+x[i]]+=dp[j][t];
				}
			}
	unsigned	long long ans=0;
	for(int i=1;i<=n;i++)
		for(int j=0;j<2501;j++)
		{
			if(dp[i][j]==-1) continue;
			if(j%i==0&&j/i==A) ans+=dp[i][j];
		}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    map<int, int> m;
    for(int i=0; i<n; i++){
        int a;
        cin>>a;
        auto it=m.find(a);
        if(it==m.end()){
            m.insert(make_pair(a, 1));
        }
        else it->second++;
    }
    int ans=0;
    for(auto it=m.begin(); it!=m.end(); it++){
        if(it->first > it->second){
            ans+=it->second;
        }
        else if(it->first < it->second){
            ans+= it->second - it->first;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4736
#include<iostream>

int main(){
    int A, B, K;
    std::cin >> A >> B >> K;
    int i;
    for(i = A; i < A + K && i <= B; i++){
        std::cout << i << std::endl;
    }
    if(i > B - K + 1){
        for(int j = i; j <= B; j++){
            std::cout << j << std::endl;
        }
    }else{
        for(int j = B - K + 1; j <= B; j++){
            std::cout << j << std::endl;
        }
    }
    
    return 0;
}


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

#define INF LLONG_MAX/3
#define inf INT_MAX/3
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> P;
typedef long long ll;

int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int lcm(int a, int b) {
	return a / gcd(a, b)*b;
}
int modpow(int a, int b) {
	if (b == 0)return 1;
	if (b == 1)return a % MOD;
	if (b % 2)return modpow(a, b - 1)*a%MOD;
	else return modpow(a, b / 2)*modpow(a, b / 2) % MOD;
}
int comb(int a, int b) {
	if (b == 0 || a == b)return 1;
	if (b == 1)return a % MOD;
	return (comb(a - 1, b - 1) + comb(a - 1, b)) % MOD;
}

int n,x,a[110];
int ans=0;
int cnt=0;
int main() {
	cin>>n>>x;
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	rep(i,n){
		if(x-cnt>=a[i]){
			cnt+=a[i];
			ans++;
		}
		else{
			cout<<ans<<endl;
			return 0;
		}
	}
	if(cnt==x)cout<<n<<endl;
	else cout<<n-1<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class Pair
{
	public int Y { get; private set; }
	public int X { get; private set; }
	
	public Pair(int y, int x)
	{
		Y = y;
		X = x;
	}
}


public class A
{
	public static void Main()
	{
		string[] args = Console.ReadLine().Split(' ');
		int H = Int32.Parse(args[0]);
		int W = Int32.Parse(args[1]);

		char[,] A = new char[H,W];
		Queue<Pair> queue = new Queue<Pair>(H * W);
		int[,] cost = new int[H,W];
		for(int i = 0; i < H; i++)
		{
			string str = Console.ReadLine();
			for(int j = 0; j < W; j++)
			{
				A[i,j] = str[j];
				if(A[i,j] == '#')
				{	
					queue.Enqueue(new Pair(i,j));
				}
				else
				{
					cost[i,j] = Int32.MaxValue;
				}
			}
		}

		int[] dy = new int[4] {-1, 0, 1, 0};
		int[] dx = new int[4] {0, -1, 0, 1};
		while(queue.Count > 0)
		{
			Pair p = queue.Dequeue();
			for(int i = 0; i < 4; i++)
			{
				int ny = p.Y + dy[i];
				int nx = p.X + dx[i];
				if((ny < 0) || (ny >= H) || (nx < 0) || (nx >= W))
					continue;
				if(cost[ny,nx] < Int32.MaxValue)
					continue;
				cost[ny,nx] = cost[p.Y,p.X] + 1;
				queue.Enqueue(new Pair(ny,nx));
			}
		}

		int ans = 0;
		for(int i = 0; i < H; i++)
			for(int j = 0; j < W; j++)
				ans = Math.Max(ans, cost[i,j]);
		Console.WriteLine(ans);
	}
}





Measured memory_bytes: 48068
N = int(input())
A = list(map(int,input().split()))

from collections import Counter
C = Counter(A)
if len(C) > 3:
    print('No')
    exit()

if len(C) == 1:
    print('Yes' if A[0]==0 else 'No')
    exit()
if N%3:
    print('No')
    exit()

if len(C) == 2:
    if C[0] != N//3:
        print('No')
    else:
        print('Yes')
else:
    if any(v!=N//3 for v in C.values()):
        print('No')
    else:
        a,b,c = list(C)
        print('Yes' if a^b == c else 'No')

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

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

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001LL;
constexpr double EPS = 1e-10;
using number = long long;




int main() {
    int n;
    string s;
    map<pair<string,string>, ll> C;

    cin >> n >> s;
    reverse(s.begin() + n, s.end());
    rep(i, 1 << n) {
        string a, b;
        rep(j, n) {
            if (i >> j & 1)a += s[j];
            else b += s[j];
        }
        ++C[make_pair(a, b)];
    }
    ll ans = 0;
    rep(i, 1 << n) {
        string a, b;
        rep(j, n) {
            if (i >> j & 1)a += s[n + j];
            else b += s[n + j];
        }
        ans += C[make_pair(a, b)];
    }
    cout << ans << endl;
}

Measured memory_bytes: 91904
#include <iostream>
#include <set>
#include <string>

using namespace std;

string get_ans(string x, int K) {
    set<string> all_str;
    int curr_start = 0;
    while (curr_start < x.length()) {
        int curr_end = curr_start;
        //since each given length has at least 1 unique substr, max len = K. Thus we only check to K.
        while (curr_end < x.length() && curr_end < curr_start + K) {
            all_str.insert(x.substr(curr_start, curr_end - curr_start + 1));
            curr_end++;
        }
        curr_start++;
    }
    return *next(all_str.begin(), K - 1);
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    int K;
    cin >> K;
    cout << get_ans(s, K);
}

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

int64_t search(vector<int64_t> &pos, vector<int64_t> &negabs, int64_t K, int64_t N){
  int64_t Npos= pos.size();
  int64_t Nneg= negabs.size();
  int64_t Ppos= Npos*(Npos-1)/2 + Nneg*(Nneg-1)/2;
  int64_t Pneg= Npos* Nneg;
  sort(pos.begin(), pos.end());
  sort(negabs.begin(), negabs.end());

  int64_t ok,ng;
  if(Pneg >= K){
    ok= 1000000000000000000;
    ng= 0;
    while(ok-ng > 1){// 答えが負(K番目に小さい<=>絶対値がK番目に大きい)
      int64_t mid= (ng+ok)/2;
      int64_t cnt_g = 0;
      for(auto &p:pos){
        auto itr_g= upper_bound(negabs.begin(), negabs.end(), mid/p);
        cnt_g+= distance(itr_g, negabs.end());
      }

      if(cnt_g < K){
        ok= mid;
      }
      else{// cnt_g >= K
        ng= mid;
      }
    }

    ok= -ok;
  }
  else{// 答えが正
    int64_t M= N*(N-1)/2 -K +1;
    ok= 1000000000000000000;
    ng= 0;
    while(ok-ng > 1){
      int64_t mid= (ng+ok)/2;
      int64_t cnt_g = 0;
      for(int i=0; i<Npos-1; i++){
        auto itr_g= upper_bound(next(pos.begin(), i+1), pos.end(), mid/pos.at(i));
        cnt_g+= distance(itr_g, pos.end());
      }
      for(int i=0; i<Nneg-1; i++){
        auto itr_g= upper_bound(next(negabs.begin(), i+1), negabs.end(), mid/negabs.at(i));
        cnt_g+= distance(itr_g, negabs.end());
      }

      if(cnt_g < M){
        ok= mid;
      }
      else{// cnt_g >= M
        ng= mid;
      }
    }
  }

  return ok;
}

int main(){
  int64_t N,K,buf;
  cin >> N >> K;
  vector<int64_t> pos;
  vector<int64_t> negabs;
  int64_t Npos= 0;
  int64_t Nneg= 0;
  for(int i=0; i<N; i++){
    cin >> buf;
    if(buf > 0){
      pos.emplace_back(buf);
      Npos++;
    }
    else if(buf < 0){
      negabs.emplace_back(-buf);
      Nneg++;
    }
  }
  pos.resize(Npos); negabs.resize(Nneg);

  int64_t Ppos= Npos*(Npos-1)/2 + Nneg*(Nneg-1)/2;
  int64_t Pneg= Npos* Nneg;

  if(Pneg < K && Ppos < N*(N-1)/2 -K +1){
    cout << 0 << endl;
  } 
  else{
    cout << search(pos, negabs, K, N) << endl;
  }
}

Measured memory_bytes: 2420
#include <stdio.h>

int main(){
   long int h,w;scanf("%ld %ld",&h,&w);
   long ans;
   if(h == 1||w == 1){
      printf("1");
      return 0;
   }
   if(h % 2 == 0 && w % 2 == 0){
      ans = h*w/2;
   }else if(h % 2 == 0){
      ans = h/2*w;
   }else if(w % 2 == 0){
      ans = w/2*h;
   }else{
      ans = h*w/2+1;
   }
   printf("%ld\n",ans);
   return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		ArrayList<Long> a = new ArrayList<>();
		ArrayList<Long> b = new ArrayList<>();
		ArrayList<Long> c = new ArrayList<>();
		for(int i=0; i<n; i++) a.add(sc.nextLong());
		for(int i=0; i<n; i++) b.add(sc.nextLong());
		for(int i=0; i<n; i++) c.add(sc.nextLong());

		Collections.sort(a);
		Collections.sort(b);
		Collections.sort(c);

		//System.out.println(a);
		//System.out.println(b);
		//System.out.println(c);

		long sum = 0;
		for(int i=0; i<n; i++) {
			long bx = b.get(i);
			int ai = lowerbound(a, bx);
			int ci = upperbound(c, bx);
			long acnt = ai;
			long ccnt = c.size()-ci;
			sum += acnt*ccnt;
		}
		System.out.println(sum);
		sc.close();
	}

	private int upperbound(ArrayList<Long> list, long x) {
		int l=-1;
		int r=list.size();
		while(l+1<r) {
			int m=(l+r)/2;
			if(list.get(m) <= x) {
				l=m;
			}else {
				r=m;
			}
		}
		return l+1;
	}
	private int lowerbound(ArrayList<Long> list, long x) {
		int l=-1;
		int r=list.size();
		while(l+1<r) {
			int m=(l+r)/2;
			if(list.get(m) < x) {
				l=m;
			}else {
				r=m;
			}
		}
		return l+1;
	}
}


Measured memory_bytes: 69172
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf 1e18
#define g(x) cout<<x<<" "<<endl;
#define gg(x,y) cout<<x<<" & "<<y<<" "<<endl
#define jam(t) cout<<"Case #"<<t<<": "
#define ggg(x,y,z) cout<<x<<" & "<<y<<" & "<<z<<" "<<endl
#define all(x) x.begin(),x.end()
#define input_from_file  freopen("input.txt", "r", stdin);
#define mod 1000000007ll
#define sz 400005
#define bitcnt(x) __builtin_popcountll(x)
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}


ll a[sz];
void solve(){
    ll k,n;
    cin >> k >> n;
    for(ll i=1;i<=n;i++)
        cin >> a[i];
    ll an = inf;
    for(ll i=2;i<=n-1;i++){
        an = min(an,min(a[i-1] + k-a[i],a[i] + k-a[i+1]));
    }
    an = min(an,a[n]-a[1]);
    g(an);
}
int main()
{

    FASTIO
    cin.tie(NULL);
    fflush(stdout);
    ll t = 1;
 //   cin >> t;
    for(ll tcase = 1;tcase <= t;tcase++){
        solve();
        
    }
return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  int total = 0;
  rep(i, n) {
    cin >> x[i];
    total += x[i];
  }
  int ans1 = 0;
  int ans2 = 0;
  int ave = total / n;
  for (int i = 0; i < n; i++) {
    ans1 += pow(ave - x[i], 2);
  }
  for (int i = 0; i < n; i++) {
    ans2 += pow(ave + 1 - x[i], 2);
  }
  cout << min(ans1, ans2) << endl;
}


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

long long sum;

void DFS(long long a,long long nsum,long long nnum,int k){

  //int sum1,sum2;
  //cout << k << endl;
  if(k == 0){
    sum += nsum + nnum;
    //cout << nsum+nnum <<endl;
    return;
  }
  k--;
  long long t = 1;
  for(int i = 0;i < k;i++){
    t*= 10;
  }
  DFS(a%t,nsum,nnum*10+a/t,k);
  DFS(a%t,nsum+nnum,a/t,k);
  return ;

}
int main(){

  long long a;
  cin >> a;
  long long k = 0,atest = a;
  while(atest != 0){
    k++;
    atest /= 10;
  }
  sum = 0;
  long long t = 1;
  for(int i = 0;i < k-1;i++){
    t *= 10;
  }
  DFS(a%t,0,a/t,k-1);
  cout << sum << endl;

}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

// MergeSort O(nlogn)
public class Main {

    private static final int MAX = 500000;
    private static final int SENTINEL = 2000000000; // 番兵
    private static int[] L = new int[MAX/2+2];
    private static int[] R = new int[MAX/2+2];
    private static int cnt = 0;


    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int[] A = new int[MAX];
        StringBuilder builder = new StringBuilder();
        cnt = 0;
        int n = sc.nextInt();
        for(int i=0; i<n; i++) A[i] = sc.nextInt();
        mergeSort(A, n ,0, n);
        for(int i=0; i<n; i++){
            if(i == 0) builder.append(A[i]);
            else builder.append(" ").append(A[i]);
        }
        System.out.println(builder.toString());
        System.out.println(cnt);

    }
    static void merge(int A[],int n, int left, int mid, int right){
        int n1 = mid - left;
        int n2 = right - mid;
        for (int i=0; i<n1; i++) L[i] = A[left + i];
        for(int i=0; i<n2; i++) R[i] = A[mid + i];
        L[n1] = R[n2] = SENTINEL;
        int i = 0;
        int j = 0;
        for(int k=left; k<right; k++){
            // 比較回数を計算
            cnt++;
            // 小さい方を元の配列に格納する
            if(L[i] <= R[j]){
                A[k] = L[i++];
            }else{
                A[k] = R[j++];
            }
        }
    }
    static void mergeSort(int A[], int n, int left, int right){
        // left と right の　差が 1 より上だったら
        if(left+1 < right){
            int mid = (left + right)/2;
            mergeSort(A, n, left ,mid);
            mergeSort(A, n, mid, right);
            merge(A, n, left, mid, right);
        }
    }

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


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

struct dice{
	int top;
	int front;
	int left;
	int right;
	int back;
	int bottom;
};

void ClockwiseTop(dice *X){
	int c = X->front;
	X->front  = X->right;
	X->right  = X->back;
	X->back   = X->left;
	X->left   = c;
}

void ClockwiseFront(dice *X){
	int c = X->top;
	X->top    = X->left;
	X->left   = X->bottom;
	X->bottom = X->right;
	X->right  = c;
}

void ClockwiseRight(dice *X){
	int c = X->top;
	X->top    = X->front;
	X->front  = X->bottom;
	X->bottom = X->back;
	X->back   = c;
}

void ClockwiseBottom(dice *X){
	ClockwiseTop(X);
	ClockwiseTop(X);
	ClockwiseTop(X);
}

void ClockwiseBack(dice *X){
	ClockwiseFront(X);
	ClockwiseFront(X);
	ClockwiseFront(X);
}

void ClockwiseLeft(dice *X){
	ClockwiseRight(X);
	ClockwiseRight(X);
	ClockwiseRight(X);
}

void TwiceClockwiseTop(dice *X){
	ClockwiseTop(X);
	ClockwiseTop(X);
}

void TwiceClockwiseRight(dice *X){
	ClockwiseRight(X);
	ClockwiseRight(X);
}

dice ArrengeTop(int a, dice B){
	if(B.front  == a) ClockwiseRight(&B);
	if(B.right  == a) ClockwiseBack(&B);
	if(B.left   == a) ClockwiseFront(&B);
	if(B.back   == a) ClockwiseLeft(&B);
	if(B.bottom == a) TwiceClockwiseRight(&B);
	return B;
}

dice ArrengeFront(int a, dice B){
	if(B.right  == a) ClockwiseTop(&B);
	if(B.left   == a) ClockwiseBottom(&B);
	if(B.back   == a) TwiceClockwiseTop(&B);
	return B;
}

bool Flag(dice A, dice B){
	if(B.top    != A.top   ) return false;
	if(B.front  != A.front ) return false;
	if(B.right  != A.right ) return false;
	if(B.left   != A.left  ) return false;
	if(B.back   != A.back  ) return false;
	if(B.bottom != A.bottom) return false;
	return true;
}

bool Judge(dice A, dice B){
	B = ArrengeTop(A.top, B);
	B = ArrengeFront(A.front, B);	
	return Flag(A, B);
}

dice Enter(){
	dice X;
	cin >> X.top;
	cin >> X.front;
	cin >> X.right;
	cin >> X.left;
	cin >> X.back;
	cin >> X.bottom;
	return X;
}

int main(){
	//?????????????????????????????¢?????°????????\?????????
	dice A = Enter();
	dice B = Enter();
	//???????????????????????¨?????????
	if(Judge(A, B) == false) cout << "No"  << endl;
	if(Judge(A, B) == true ) cout << "Yes" << endl;
	return 0;
}

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

int main(){
    int X, Y, Z;
    cin >> X >> Y >> Z;
    int t;

    t = X;
    X = Y;
    Y = t;

    t = X;
    X = Z;
    Z = t;

    cout << X << " " << Y << " " << Z << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include <set>

#define DIV 1000000007
using namespace std;
using ll = long long;

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

    double total = 0;
    double cnt = 0;
    vector<double> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        total += a[i];
    }

    for (int i = 0; i < N; i++) {
        if (a[i] >= total / (4 * M)) {
            cnt++;
        }
    }

    if (cnt >= M)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define per(i, a, b) for(int i = (a); i >= (b); --i)
#define debug(x) cerr << #x << ' ' << x << endl;
using namespace std;

typedef long long ll;
const int mod = 1e9+7;
const int MAXN = 666 + 7;

double f[MAXN], dp[MAXN];
vector<int> G[MAXN];
int main(int argc, char const *argv[])
{
    int n, m;
    cin >> n >> m;
    int u, v;
    rep(i, 1, m) {
        cin >> u >> v;
        G[u].push_back(v);
    }
    f[n] = 0;
    per(i, n-1, 1) {
        double sum = 0;
        for(int p: G[i]) sum += f[p];
        f[i] = 1 + sum/G[i].size();
    }
    double ans = f[1];
    rep(i, 1, n-1) {
        if(G[i].size() == 1)    continue;
        rep(j, 1, n) dp[j] = f[j];
        double sum = 0, maxx = 0;
        for(int p: G[i]) {
            sum += f[p];
            maxx = max(maxx, f[p]);
        }
        sum -= maxx;
        dp[i] = 1 + sum/(G[i].size()-1);
        per(j, i-1, 1) {
            sum = 0;
            for(int p: G[j]) {
                sum += dp[p];
            }
            dp[j] = 1 + sum/G[j].size();
        }
        ans = min(ans, dp[1]);
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<string.h>
#include<algorithm>
using namespace std;

int main() {
	int A = 0;
	int B = 0;

	cin >> A >> B;

	if ((A+B)%3==0) {
		cout << "Possible"<< endl;
	}
	else if (A % 3 == 0) {
		cout << "Possible" << endl;
	}
	else if (B%3==0) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	public class Program
	{
		// ABC131-A
		static void Main(string[] args)
		{
			string str = Console.ReadLine();

			if (str[0] == str[1] || str[1] == str[2] || str[2] == str[3]) {
				Console.WriteLine("Bad");
			} else {
				Console.WriteLine("Good");
			}
		}
	}
}


Measured memory_bytes: 13140
N = gets.to_i
S = N.times.map{gets.chomp}.group_by{|n| n[0]}
ans = 0
a = ['M', 'A', 'R', 'C', 'H']
a.each{|c| S[c] = [] if !S[c]}
ans = 0
a.combination(3){|x, y, z| 
    ans += S[x].length * S[y].length * S[z].length
}
puts ans


Measured memory_bytes: 10784
#include<iostream>
#include<vector>
#include<map>

using namespace std;

int main()
{
    int N;
    cin >> N;
    map<int, int> V1;
    map<int, int> V2;
    int a;
    for(int i=0; i<N; i++){
        cin >> a;
        if(i%2==1){
            V1[a] += 1;
        }else{
            V2[a] += 1;
        }
    }
    int m = 0;
    int k = 0;
    for(pair<int, int> p: V1){
        if(p.second>m){
            m = p.second;
            k = p.first;
        }
    }
    int n = 0;
    for(pair<int, int> p: V2){
        if(p.second>n and p.first!=k){
            n = p.second;
        }
    }
    int ans1 = N-m-n;
    m = 0;
    k = 0;
    n = 0;
    for(pair<int, int> p: V2){
        if(p.second>m){
            m = p.second;
            k = p.first;
        }
    }
    for(pair<int, int> p: V1){
        if(p.second>n and p.first!=k){
            n = p.second;
        }
    }
    int ans2 = N-m-n;
    cout << min(ans1,ans2) << endl;
    return 0;
}


Measured memory_bytes: 4992
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;

int main(){
	int n ; 
	cin >> n ; 
	vector<pair<string,pair<int,int> > > v ; 
	for(int i=0;i<n;i++){
		string x; 
		cin >> x; 
		int s ; 
		cin >> s ;
		v.push_back({x,{-s,i+1}}) ; 
	}
	debug() << imie(v) ; 
	sort(v.begin(),v.end());
	debug() << imie(v) ; 
	for(int i=0;i<n;i++){
		cout << v[i].second.second << endl;
	}
    return 0 ;
}


Measured memory_bytes: 256
h,w,k = map(int,input().split())
choco = []
mcut = h+w
for i in range(h):
    choco.append(list(map(int,list(input()))))
for i in range(2**(h-1)):
    chocos = []
    cut = 0
    choco1 = choco[0][:]
    for j in range(h-1):
        if i >> j & 1:
            chocos.append(choco1)
            choco1 = choco[j+1][:]
            cut += 1
        else:
            for l in range(w):
                choco1[l] += choco[j+1][l]
    chocos.append(choco1)
    num = len(chocos)
    chocosum = [0 for _ in range(num)]
    flag = True
    for j in range(w):
        for l in range(num):
            if chocos[l][j] > k:
                flag = False
            chocosum[l] += chocos[l][j]
            if chocosum[l] > k:
                cut += 1
                chocosum = [chocos[_][j] for _ in range(num)]
                break
    if flag:
        mcut = min(cut,mcut)
print(mcut)

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

typedef long long ll;
ll MOD = 1000000007;

int main()
{
    int k, x;
    cin >> k >> x;

    for (int i = x-k+1; i <= k+x-1; i++) {
        cout << i << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate
n = int(input())
a = list(map(int, input().split()))

s = list(accumulate(a))
ans = float("inf")

j = 0
k = 2

for i in range(1, n-2):
    while abs(s[i]-2*s[j]) > abs(s[i]-2*s[j+1]):
        j += 1
    while abs(s[n-1] - 2*s[k] + s[i]) > abs(s[n-1] - 2*s[k+1] + s[i]):
        k += 1
    t = max(s[j], s[i]-s[j], s[k]-s[i], s[n-1]-s[k]) - min(s[j], s[i]-s[j], s[k]-s[i], s[n-1]-s[k])
    ans = min(ans, t)

print(ans)
 


Measured memory_bytes: 24172
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define P pair<ll,ll> 
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k,ans=0;cin>>n>>k;
  ll num=n/k;
  ans=num*num*num;
  if(k%2==0) {
    ll val=0;
    while(k*val+k/2<=n) val++;
    ans+=val*val*val;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    ll n, y;
    cin >> n >> y;
    for(ll i = 0; i<=n; i++){
        for(ll j=0; j<=n; j++){
            ll k = n - i - j;
            ll tmp = 10000*i + 5000*j + 1000*k;
            if(tmp == y && k>=0){
                cout << i << " " << j << " " << k << endl;
                exit(0);
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}

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

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;




void main() {
    string A, B;
    scan(A);
    scan(B);

    if (A == B) {
        writeln("EQUAL");
        return;
    }

    bool g;

    if (A.length > B.length) {
        g = true;
    }
    else if (A.length < B.length) {
        g = false;
    }
    else {
        g = A > B;
    }

    writeln(g ? "GREATER" : "LESS");
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int N;
    scanf("%d", &N);
    int i;
    for (i = 3; i <= N;i++){
        int x = i;
        if (x % 3 == 0)
        {
            printf(" %d", i);
        }
        else{
            while (x){
                if (x % 10 == 3){
                    printf(" %d", i);
                    break;
                }
                x = x / 10;
            }
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2060
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;
const int N = 1005;
int n, a[N][N], cnt[N], ans = 0, e = 0;
bool in[N];
vector<pair<int, int> > vec;
vector<int> tmp;
int main () {
	scanf("%d", &n), e = n * (n - 1) / 2;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j < n; j++) scanf("%d", &a[i][j]);
	}
	for (int i = 1; i <= n; i++) cnt[i] = 1;
	for (int i = 1; i <= n; i++) {
		int j = a[i][cnt[i]];
		if (a[j][cnt[j]] == i && j < i) vec.push_back(make_pair(i, j));
	}

	for (; e; ans++) {
		if (vec.empty()) {
			ans = -1;
			break;
		}
		tmp.clear();
		for (int i = 0; i < vec.size(); i++) {
			tmp.push_back(vec[i].first), tmp.push_back(vec[i].second);
			cnt[vec[i].first]++, cnt[vec[i].second]++, e--;
			in[vec[i].first] = in[vec[i].second] = true;
		}
		vec.clear();
		for (int i = 0; i < tmp.size(); i++) {
			int u = tmp[i];
			if (cnt[u] > n) continue;
			int v = a[u][cnt[u]];
			if (cnt[v] > n) continue;
			if (a[v][cnt[v]] == u) {
				if (!in[v]) vec.push_back(make_pair(u, v));
				else if (v < u) vec.push_back(make_pair(u, v));
			}
		}
		for (int i = 0; i < tmp.size(); i++) in[tmp[i]] = false;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 4224
#include <stdio.h>

int main(void)
{
	int n,i,c_max,c_min;
	long long int c_sum = 0;
	int c[10000];
	
	scanf("%d\n",&n);
	
	for(i=0;i<n;i++){
	scanf("%d",&c[i]);
	}
	c_max = c[0];
	c_min = c[0];
	for(i=1;i<n;i++){
		if(c_max < c[i]){
			c_max = c[i];
		}
		if(c_min > c[i]){
			c_min = c[i];
		}
	}
	for(i=0;i<n;i++){
		c_sum = c_sum + c[i];
	}	
		printf("%d %d %lld\n",c_min,c_max,c_sum);
	return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

void duplicate(vector <vector<int >>& nums, int i, int s, int w)
{
	if (nums[s][0] == 0) {
		duplicate(nums, s, s + 1, w);
	}
	FOR_LT(j, 0, w) {
		nums[i][j] = nums[s][j];
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int h, w, k; cin >> h >> w >> k;
	vector <vector<bool>> map(h, vector<bool>(w));
	vector <vector<int >> nums(h, vector<int>(w));
	FOR_LT(i, 0, h) {
		FOR_LT(j, 0, w) {
			char c; cin >> c;
			if (c == '#') map[i][j] = true;
		}
	}

	int n = 1;
	FOR_LT(i, 0, h) {
		bool has_s = false;
		FOR_LT(j, 0, w) {
			if (map[i][j]) {
				if (!has_s) {
					FOR_LT(l, 0, j) {
						nums[i][l] = n;
					}
				}
				nums[i][j] = n;
				has_s = true;
				n++;
			}
			else {
				if (has_s) {
					nums[i][j] = n - 1;
				}
			}
		}
	}

	{
		bool has_s = false;
		FOR_LT(i, 0, h) {
			if (nums[i][0] != 0) {
				has_s = true;
			}
			else {
				int source = has_s ? i - 1 : i + 1;
				duplicate(nums, i, source, w);
			}
		}
	}

	FOR_LT(i, 0, h) {
		FOR_LT(j, 0, w) {
			cout << nums[i][j] << " ";
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1152
s = input()
cnt = 0

if len(s)%2 == 1:
    print('No')
    exit()

for i in range(len(s)//2):
    if i == (len(s)/2):
        break
    if s[(i*2):(i+1)*2] != 'hi':
        cnt += 1

print('Yes' if cnt == 0 else 'No')

Measured memory_bytes: 38256
n = int(input())
s = input()
ans = s.count('R') * s.count('G') * s.count('B')
for i in range(n):
  for j in range(i, n-1):
    k = 2*j - i
    if k >= n:
      continue
    if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
      ans -= 1

print(ans)


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

int main() {
  string S;
  cin >> S;
  if(S.at(0) == S.at(1) && S.at(0) == S.at(2)) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
// #define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=((int)(n)-1);v>=0;v--)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define DUMP(x) cerr<<#x<<":="<<(x)<<endl
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1e9; const long long INFLL=1e18;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<" "<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":" ");return os;}
//------------------------------------------------------------------------------

char nextchar(char c) {
    if(c=='z') return 'a';
    return c+1;
}
signed main() {
    string s;
    cin>>s;
    ll K;
    cin>>K;
    int n=s.size();

    REP(i,n) {
        if(K==0) goto end;
        if(s[i]=='a') continue;
        int c=26-(s[i]-'a');
        if(c<=K) {
            s[i]='a';
            K-=c;
        }
    }

    K%=26;
    REP(i,K) s[n-1]=nextchar(s[n-1]);

end:
    cout<<s<<endl;
    return 0;
}


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

int main(){
	int H, W;
	scanf("%d%d", &H, &W);
	vector<string> S(H);
	for(int i = 0; i < H; i++)cin >> S[i];
	int X[4] = {1, 0, -1, 0};
	int Y[4] = {0, 1, 0, -1};
	bool JD = false;
	
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			if(S[i][j] == '.')continue;
			bool check = true;
			for(int k = 0; k < 4; k++){
				int x = j + X[k];
				int y = i + Y[k];
				if(x < 0 || x >= W || y < 0 || y >= H)continue;
				if(S[y][x] == '#'){
					check = false;
					break;
				}
			}
			if(check){
				JD = true;
				break;
			}
		}
		if(JD)break;
	}
	
	cout << ((JD) ? "No" : "Yes") << endl;
}

Measured memory_bytes: 256