akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<vector>
using namespace std;

int main(void) {
	int N;
	scanf("%d", &N);
	int buka[200010] = {0};
	for (int i = 0; i < N - 1; i++) {
		int A;
		scanf("%d", &A);
		buka[A - 1]++;
	}
	for (int i = 0; i < N; i++) {
		printf("%d\n", buka[i]);
	}
	return 0;
}


Measured memory_bytes: 4560
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  char c;
  cin>>c;
  cout<<char(c+1)<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){return (int)s.size();}
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int n,m; cin >> n >> m;
    int x = 1, y = n;
    rep(i,m){
        int z;
        if((y-x-1) % 2 == 0){
            int z = (y-x-1)/2;
            if(z <= i){
                i--;
                y--;
                continue;
            }
        }
        cout << x << " " << y << endl;
        x++; y--;
    }
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
 
#define mod 1000000007
#define inf 1000000000
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
 
int main(){
  ll n;
  cin >> n;
  
  ll ans = 0;
  for(ll i = 1; i <= n/2; i++){
    if(n - i != i) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int n,a,b,c,d; string s;
  cin>>n>>a>>b>>c>>d>>s;

  if(c<d){
    if(s.substr(a-1, d-a+1).find("##")==-1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }else{
    bool fl1=s.substr(b-2, d-b+3).find("...")!=-1;
    bool fl2=s.substr(a-1, c-a+1).find("##")==-1;
    if(fl1&&fl2)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}


Measured memory_bytes: 772
//#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define boost ios::sync_with_stdio(0); cin.tie(0)

#define fi first
#define se second

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

const int N = 1e6 + 5;

/***************************************************************************/

ll A[N];
ll f(ll b, int n) {
	ll ans = 0;
	for(int i=1; i<=n; i++) {
		ans += abs(A[i] - b - i);
	}
	return ans;
}

int main() {

	boost;
	int n; cin>>n;
	for(int i=1; i<=n; i++) {
		cin>>A[i];
	}

	ll la = -2e9, ra = 2e9;
	while(ra - la >= 3) {
		ll m1 = la + (ra-la) / 3;
		ll m2 = ra - (ra-la) / 3;
		if(f(m1, n) > f(m2, n)) la = m1;
		else ra = m2;
	}

	ll ans = f(la, n);
	while(++la <= ra) {
		ans = min(ans, f(la, n));
	}

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

Measured memory_bytes: 1792
#include <stdio.h>

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
int main() {
        int k,x;
        scanf("%d %d", &k, &x);

        int left = max(x - (k - 1), -1e6);
        int right = min(x + (k - 1), 1e6);

        for (int i = left ; i <= right ; i++) {
                printf("%d ", i);
        }
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
from sys import stdin
import math

n = int(stdin.readline().rstrip())
lx = list(map(int, stdin.readline().split()))
ly = list(map(int, stdin.readline().split()))

s1=s2=s3=max_x_y = 0
for i in range(n):
    x_y = abs(lx[i] - ly[i])
    #p=1
    s1+=x_y
    #p=2
    s2 += math.pow(x_y,2)
    #p=3
    s3 += math.pow(x_y, 3)
    #p=∞
    if max_x_y < x_y:
        max_x_y = x_y
else:
    #p=1
    print("{0:.8f}".format(s1))
    #p=2
    d2 = math.sqrt(s2)
    print("{0:.8f}".format(d2))
    #p=3
    d3 = math.pow(s3, 1.0 / 3.0)
    print("{0:.8f}".format(d3))
    #p=∞
    print(max_x_y)



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

int main(){
	int y[100], m[100], d[100];
	int n;
	int ans[100];

	for(int i=0; i <100; i++) ans[i] = 0;

	cin >> n;
	for(int i=0; i < n; i++) cin >> y[i] >> m[i] >> d[i];


	for(int i=0; i < n; i++){
		if(y[i] % 3 == 0 || m[i] % 2 == 1) ans[i] = 20 - d[i] + 1;
		else ans[i] = 19 - d[i] + 1;
		for(int j=y[i]; j < 1000; j++){
			for(int k = 1; k <= 10; k++){
				if(j == y[i] && k <= m[i]) continue;

				if(j % 3 == 0 || k % 2 == 1) ans[i] += 20;
				else ans[i] += 19;
			}
		}
	}

	for(int i=0; i < n; i++) cout << ans[i] << endl;
}

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

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int ans = min(B, D) - max(A, C);
    if( ans < 0 ) cout << 0 << endl;
    else cout << ans  << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using ll = long long int;

constexpr int MAX = 3010;
constexpr ll mod = 998244353;

ll dp[MAX][MAX];
int a[MAX];

int main()
{
    int n, s;
    std::cin >> n >> s;
    for (int i = 1; i <= n; ++i)
        std::cin >> a[i];

    ll ans = 0;

    for (int i = 1; i <= n; ++i)
    {
        dp[i][a[i]] = i;
        if (a[i] == s)
            ans = (ans + i * (n - i + 1)) % mod;
    }

    for (int i = 1; i <= n; ++i)
    {
        for (int sum = 1; sum < s; ++sum)
        {
            dp[i][sum] = (dp[i][sum] + dp[i - 1][sum]) % mod;
            if (sum > a[i])
                dp[i][sum] = (dp[i][sum] + dp[i - 1][sum - a[i]]) % mod;
        }
    }

    for (int i = 2; i <= n; ++i)
    {
        if (s > a[i])
            ans = (ans + dp[i - 1][s - a[i]] * (n - i + 1)) % mod;
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 70784
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  long long K, A[222222], d[222222], dp = -1;

  int N;

  std::cin >> K >> N;

  for (int i = 0; i < N; i ++)
    std::cin >> A[i];

  for (int i = 0; i < N - 1; i ++)
    dp = std::max(d[i] = A[i + 1] - A[i], dp);

  dp = std::max(d[N - 1] = A[0] + K - A[N - 1], dp);

  std::cout << K - dp << std::endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
int x,y;
cin>>x>>y;
if(x-2*y>=0)
{
    cout<<x-2*y;
}
if(x-2*y<0)
{
    cout<<0;
}
return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<iostream>

using namespace std;

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


Measured memory_bytes: 640
import math

def main():
    A, B, H, M = tuple(int(c) for c in input().split(' '))

    h = 2*math.pi / 12 * (H + M / 60)
    m = 2*math.pi / 60 * M

    xh = A * math.cos(h)
    yh = A * math.sin(h)
    xm = B * math.cos(m)
    ym = B * math.sin(m)

    distance = ((xh-xm)**2 + (yh-ym)**2)**0.5
    print(distance)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9580
#include<iostream>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<utility>
using namespace std;
int n;
double x[100],y[100];
main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>x[i]>>y[i];
	for(int i=0;i<n;i++)
	{
		double p[100];
		int f=0;
		for(int j=0;j<n;j++)
		{
			if(i==j)
			{
				f=1;
				continue;
			}
			p[j-f]=atan2(y[j]-y[i],x[j]-x[i]);
		}
		sort(p,p+n-1);
		p[n-1]=p[0]+2*M_PI;
		f=0;
		for(int i=0;i<n-1;i++)
		{
			if(p[i+1]-p[i]>M_PI)
			{
				cout<<fixed<<setprecision(9)<<(p[i+1]-p[i]-M_PI)/(2*M_PI)<<endl;
				f=1;
				break;
			}
		}
		if(!f)cout<<fixed<<setprecision(9)<<0.<<endl;
	}
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  map<char,ll> mp;
  for(int i = 0;i < n;i++){
    char in;
    cin >> in;
    mp[in]++;
  }
  if(mp.size() == 3)cout << "Three" << endl;
  else cout << "Four" << endl;
}

Measured memory_bytes: 3100
N = int(input())
b = list(map(int,input().split()))
a = [0]*N

aequalb = True
for i in reversed(range(1, N+1)):
    for j in reversed(range(1,i+1)):
        if b[j-1] == j:
            a[N-i] = b.pop(j-1)
            break
        elif j == 1:
            aequalb = False
    if aequalb == False:
        break

if aequalb:
    for i in range(N):
        print(a[N-1-i]) 
else:
    print(-1)

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

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		
		Console.WriteLine(p[0]*p[1]);
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

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

int main(){
  int a,b,c;cin>>a>>b>>c;
  REP(i,1000) if(!((i*a-c)%b)){
    cout<<"YES";
    return 0;
  }
  cout<<"NO";
}

Measured memory_bytes: 384
from collections import defaultdict

def submit():
    s = [int(c) for c in input()]
    modp = 2019

    curr = 0
    modp_count = defaultdict(int)
    modp_count[0] = 1
    ans = 0
    base = 1
    for c in reversed(s):
        curr += base * c
        curr_mod = curr % modp
        ans += modp_count[curr_mod]
        modp_count[curr_mod] += 1
        base *= 10
        base %= modp
    
    print(ans)
    

submit()
    

Measured memory_bytes: 11296
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
using namespace std;
typedef long long ll;
bool is_prime(long long _Num){
    if(_Num < 2)return false;
    if(_Num % 2 == 0){
        if(_Num == 2)return true;
        else return false;
    }
    bool prime = true;
    for(long long i = 3; i <= sqrt(_Num); i += 2){
        if(_Num % i == 0){
            prime = false;
            break;
        }
    }
    return prime;
}
set<ll> enum_div(ll n)//nの約数を列挙
{
	set<ll> ret;
	for(ll i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.insert(i);
			if(i!=1 && i*i!=n)
			{
				ret.insert(n/i);
			}
		}
	}
  ret.insert(n);
	return ret;
}

int main()
{
  ll a,b;cin>>a>>b;
	set<ll> r = enum_div(a);
  set<ll> tmp = enum_div(b);

  vector<ll> ko;
  for(auto it = tmp.begin();it!=tmp.end();it++){
    if(r.find(*it)!=r.end())ko.push_back(*it);
  }
  //rep(i,ko.size())cout<<ko[i]<<endl;
  set<ll>ans;
  ans.insert(1);
  if(min(a,b)!=1)ans.insert(ko[1]);
  for(auto it=ko.begin();it!=ko.end();it++){
    //bool ok=true;
    if(is_prime(*it))ans.insert(*it);
  }


  cout<<ans.size()<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=5005;
const int mod=1000000007;
int n,m,rev[maxn];
char s[maxn];
ll f[maxn][maxn],g[maxn];
inline void mul(ll *a,ll *b,ll *c)
{
	static ll ans[maxn];
	for(int i=0;i<=n;i++) ans[i]=0;
	for(int i=0;i<=n;i++)
		for(int j=0;j<=i;j++)
			(ans[i]+=a[j]*b[i-j])%=mod;
	for(int i=0;i<=n;i++) c[i]=ans[i];
}
inline void solve()
{
	static ll a[maxn],b[maxn];
	for(int i=0;i<n;i++) a[i+1]=f[i][0];
	b[0]=1;
	int t=m;
	for(;t;t>>=1,mul(a,a,a))
		if(t&1) mul(b,a,b);
	for(int i=0;i<=n;i++) g[i]=b[i];
}
int main()
{
	scanf("%d%s",&n,s+1); m=strlen(s+1);
	f[0][0]=1;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			if(f[i][j])
			{
				(f[i+1][j+1]+=2*f[i][j])%=mod;
				if(j>0) (f[i+1][j-1]+=f[i][j])%=mod;
			}
	/*
	g[0][0]=1;
	for(int i=0;i<m;i++)
		for(int j=0;j<n;j++)
			if(g[i][j])
				for(int k=0;j+k+1<=n;k+=2)
					(g[i+1][j+k+1]+=g[i][j]*f[k][0])%=mod;
	*/
	solve();
	for(int i=0;i<=n;i++)
		for(int j=0;j<=n+1;j++) f[i][j]=0;
	f[0][1]=1;
	for(int i=0;i<n;i++)
		for(int j=0;j<=n;j++)
			if(f[i][j])
			{
				(f[i+1][(j==0)?2:j+1]+=2*f[i][j])%=mod;
				(f[i+1][max(j-1,0)]+=f[i][j])%=mod;
			}
	ll ans=0;
	for(int i=0;i<=n-m;i++) (ans+=(f[i][0]+f[i][1])*g[n-i])%=mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 195968
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
n = int(input())
count = 0
for i in range(1, n+1, 2):
    if len(make_divisors(i)) == 8:
        count += 1
print(count)

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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;

const int mod = 1e9 + 7;


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

	int n;
	cin >> n;
	string s;
	cin >> s;

	int ans = 1;
	rep(i, n-1){
		if(s[i] != s[i+1]){
			ans++;
		}
	}

	cout << ans << endl;

    return 0;
}



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

int main() {
  int A,B,C,D,E,F; cin >> A >> B >> C >> D >> E >> F;
  double maxP = -1.0;
  int ans1,ans2;

  for ( int i = 0; 100*A*i <= F; i++ ) {
    for ( int j = 0; 100*A*i+100*B*j <= F; j++ ) {
      if ( i == 0 && j == 0 )continue;
      for ( int k = 0; 100*A*i+100*B*j+k*C <= F; k++ ) {
	for ( int l = 0; 100*A*i+100*B*j+k*C+l*D <= F; l++ ) {
	  //if (i == 0 && j == 0 && k == 0 && l == 0 ) continue;
	  int water = 100*A*i+100*B*j;
	  int sugar = k*C+l*D;
	  int sum = water+sugar;
	  double p = 100.0*sugar/sum;
	  if ( p <= 100.0*E/(100.0+E) && maxP < p ) {
	    maxP = p;
	    ans1 = sum;
	    ans2 = sugar;
	  }
	}
      }
    }
  }
  cout << ans1 << " " << ans2 << endl;
  return 0;
}


Measured memory_bytes: 256
import fractions

n=int(input())
li = list(map(int,input().split()))
an=10**9

for i in range(n-1):
    if fractions.gcd(li[i],li[i+1]) < an:
        an=fractions.gcd(li[i],li[i+1])
    if an==1:
        print(an)
        exit()

print(an)

Measured memory_bytes: 16280
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#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()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
#define pint pair<int,int>
#define vi(v) rep(i,v.size())cin >> v[i]
#define vc(v) rep(i,v.size())cout << v[i] << endl
#define ni(n) cin >> n
#define nc(n) cout << n << endl
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
vector<ll>ans;
ll cn = 0;
ll k = 0;
void bfs(ll n){
  queue<ll>q;
  REP(i,1,10){
    ans.push_back(i);
    q.push(i);
    cn++;
  }
  while(cn <= k){
    ll now = q.front();
    q.pop();
    string tmp = to_string(now);
    ll last = tmp[tmp.size() - 1] - '0';
    if(last == 0){
      q.push(now * 10 + 0);
      cn++;
      ans.push_back(now * 10 + 0);
      q.push(now * 10 + 1);
      cn++;
      ans.push_back(now * 10 + 1);
    }
    else if(last == 9){
      q.push(now * 10 + 8);
      cn++;
      ans.push_back(now * 10 + 8);
      q.push(now * 10 + 9);
      cn++;
      ans.push_back(now * 10 + 9);
    }
    else{
      q.push(now * 10 + (last - 1));
      cn++;
      ans.push_back(now * 10 + (last - 1));
      q.push(now * 10 + (last));
      cn++;
      ans.push_back(now * 10 + (last));
      q.push(now * 10 + (last + 1));
      cn++;
      ans.push_back(now * 10 + (last + 1));
    }
  }
}
int solve(){
  cin >> k;
  bfs(1);
  sort(all(ans));
  cout << ans[k - 1] << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}


Measured memory_bytes: 1620
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class Program{
  public static void Main(){

    int n = int.Parse(Console.ReadLine());
    var input = Console.ReadLine().Split();
    var b = new int[n];
    int k = 0;
    if(n % 2 == 1) k = 1;
    for(int i = 0; i < n; i++){
      if((i + k) % 2 == 0){
        b[(n + (i+1))/2] = int.Parse(input[i]);
      }
      else{
        b[(n -(i+1))/2] = int.Parse(input[i]);
      } 
    }
    for(int i = 0; i < n; i++){
      Console.Write(b[i]);
      if(i != n-1) Console.Write(" ");
    }
  }
}


Measured memory_bytes: 35512
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    string a,b; cin>>a>>b;
    sort(all(a));
    sort(all(b));
    reverse(all(b));
    cout<<(a<b?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i=0; i<n; i++)
#define loop(i, j, n) for(int i=j; i<n; i++)
using namespace std;
int main()
{
	string S;
	int n, cnt=0;

	cin >> S;
	n = S.size();

	if(S[0] != 'A'){
		puts("WA");
		return 0;
	}

	loop(i, 2, n-1){
		if(S[i] == 'C') cnt++;
	}

	if(cnt != 1){
		puts("WA");
		return 0;
	}
		
	loop(i, 1, n){
		if((S[i] >= 'a' && S[i] <= 'z') || S[i] == 'C'){
			;
		}else{
			puts("WA");
			return 0;
		}
	}

	puts("AC");
	return 0;
}

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

int main(){
    //input
    int K, S;
    cin >> K >> S;

    //calc
    int counta = 0;
    int X, Y;
    for(X=0; X<=K; X++){
        for(Y=0; Y<=K; Y++){
            if(0<=S-X-Y && S-X-Y<=K) counta++;
        }
    }

    //answer
    cout << counta << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 504
import java.util.*;
import static java.lang.Math.*;

public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int cnt_all = 0;
        for(int i=1; i<=n; i+=2){
            int cnt = 0;
            for(int j=1;j<=n;j++){
                if(i>=j && i%j==0){
                    cnt++;
                }
            }
            if(cnt == 8){
                cnt_all++;
            }
        }
        System.out.println(cnt_all);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main(){
    int n;
    cin >> n;
    if (n == 1000000000000000000)
    {
        cout << 124999999999999995 << endl;
        return 0;
    }
    if(n==0){
        cout << 0 << endl;
        return 0;
    }
    if(n%2==0){
        int x = 5;
        int ans = 0;
        x = 5;
        while (1)
        {
            if(x>n)
                break;
            ans+=(n/x)/2;
            x *= 5;
        }
        cout << ans << endl;
    }
    else{
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

template<typename T>
class rArray {
	int N;
	vector<int> pos, pre, data;
public:
	rArray(int N) : N(N), data(N) {}
	rArray(int N, T val) : N(N), data(N, val) {}
	rArray(const vector<T>& v) : N(v.size()), data(v) {}
	rArray(vector<T>&& v) : N(v.size()), data(move(v)) {}
	T change(int k, T val) {
		pos.push_back(k);
		pre.push_back(data[k]);
		return data[k] = val;
	}
	void undo() {
		data[pos.back()] = pre.back();
		pos.pop_back(), pre.pop_back();
	}
	T operator[](int k) const {
		return data[k];
	}
	int getversion() const {
		return pos.size();
	}
};

class rUnionFind {
	rArray<int> data;
	vector<int> pre;
	int find(int a) {
		return data[a] < 0 ? a : data.change(a, find(data[a]));
	}
public:
	rUnionFind(int n) : data(n, -1) {}
	bool same(int a, int b) {
		return find(a) == find(b);
	}
	void unite(int a, int b) {
		a = find(a);
		b = find(b);
		if (a == b) return;
		pre.push_back(data.getversion());
		if (data[a] < data[b]) swap(a, b);
		data.change(b, data[a] + data[b]);
		data.change(a, b);
	}
	void undo() {
		int cnt = data.getversion() - pre.back();
		while (cnt--) data.undo();
		pre.pop_back();
	}
	int size(int a) {
		return -data[find(a)];
	}
	int getversion() {
		return pre.size();
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	const int B = 200;
	int n, k;
	cin >> n >> k;
	vector<int> t(k), u(k), v(k);
	for (int i = 0; i < k; i++) {
		cin >> t[i] >> u[i] >> v[i];
	}
	set<P> es;
	rUnionFind uf(n);
	vector<bool> res;
	for (int i = 0; i < k; i += B) {
		vector<int> used(n);
		for (int j = i; j < min(i + B, k); j++) {
			used[u[j]] = used[v[j]] = 1;
		}
		set<P> unf;
		for (auto e : es) {
			if (used[e.first] && used[e.second]) {
				unf.insert(e);
			}
			else {
				uf.unite(e.first, e.second);
			}
		}
		for (int j = i; j < min(i + B, k); j++) {
			if (t[j] == 1) {
				unf.emplace(u[j], v[j]);
				es.emplace(u[j], v[j]);
			}
			else if (t[j] == 2) {
				unf.erase(P(u[j], v[j]));
				es.erase(P(u[j], v[j]));
			}
			else {
				int ver = uf.getversion();
				for (auto e : unf) {
					uf.unite(e.first, e.second);
				}
				res.push_back(uf.same(u[j], v[j]));
				while (uf.getversion() > ver) uf.undo();
			}
		}
		while (uf.getversion() > 0) uf.undo();
	}
	for (auto ans : res) {
		puts(ans ? "YES" : "NO");
	}
	return 0;
}

Measured memory_bytes: 6060
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=1000000007;
const ll INF=10100000101010101010101010;
int main(){
  ll n,k;cin >> n >> k;
  ll h[n];
  rep(i,n)cin>>h[i];
  sort(h,h+n,greater<int>());
  ll ans=INF;
  for(int i=0;i<n-k+1;i++){
  ans=min(ans,h[i]-h[i+k-1]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef pair<double,int>Q;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int xa,xb,xc,xd,xe,xf;
int ya,yb,yc,yd,ye,yf;
ll modpow(ll x,ll n)
{
	ll res=1;
	while(n>0)
	{
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
ll F[2000005],R[2000005];
void make(){
	F[0] = 1;
	for(int i=1;i<2000005;i++) F[i] = F[i-1]*i%mod;
	for(int i=0;i<2000005;i++) R[i] = modpow(F[i],mod-2);
}
ll C(int a,int b){
	return F[a]*R[b]%mod*R[a-b]%mod;
}
ll calc(int X1,int Y1,int X2,int Y2,int X3,int Y3,int X4,int Y4){
	ll cur = C(X3-X1+Y3-Y1,X3-X1) * C(X2-X3+Y2-Y3,X2-X3) % mod;
	ll ret = cur;
	for(int sum=X3+Y3+1;sum<=X4+Y4;sum++){
		int zan = sum-X3;
		if(zan<=Y4){
			cur += C(X3-X1-1+zan-Y1,zan-Y1)*C(X2-X3+Y2-zan,X2-X3)%mod;
			cur %= mod;
		}
		else{
			zan = sum-Y4;
			cur += mod - C(zan-X1-1+Y4-Y1,Y4-Y1)*C(X2-zan+1+Y2-Y4-1,X2-zan+1)%mod;
			cur %= mod;
		}
		
		zan = sum-Y3;
		if(zan<=X4){
			cur += C(zan-X1+Y3-Y1-1,zan-X1)*C(X2-zan+Y2-Y3,Y2-Y3)%mod;
			cur %= mod;
		}
		else{
			zan = sum-X4;
			cur += mod - C(zan-Y1-1+X4-X1,X4-X1)*C(Y2-zan+1+X2-X4-1,Y2-zan+1)%mod;
			cur %= mod;
		}
		ret = (ret+cur)%mod;
	}
	return ret;
}
int main(){
	cin>>xa>>xb>>xc>>xd>>xe>>xf;
	cin>>ya>>yb>>yc>>yd>>ye>>yf;
	int a[4][2]={{xa-1,ya-1},{xb,yb},{xa-1,yb},{xb,ya-1}};
	int b[4][2]={{xe,ye},{xf+1,yf+1},{xe,yf+1},{xf+1,ye}};
	ll ret = 0; make();
	rep(i,4){
		rep(j,4){
			int coef = 1;
			if(i>=2) coef *= -1;
			if(j>=2) coef *= -1;
			ret += 1LL*coef*calc(a[i][0],a[i][1],b[j][0],b[j][1],xc,yc,xd,yd)%mod;
			ret %= mod;
		}
	}
	cout<<(ret%mod+mod)%mod<<endl;
}

Measured memory_bytes: 31488
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
N,M = map(int,input().split())
fac = [1, 1]
inv = [0, 1]
finv = [1, 1]
MOD = 10**9+7
fac = [1, 1]
inv = [0, 1]
finv = [1, 1]
for i in range(2, M+1):
    fac.append(fac[-1] * i % MOD)
    inv.append(MOD - inv[MOD%i] * (MOD//i) % MOD)
    finv.append(finv[-1] * inv[-1] % MOD) 
def comb_mod(n, r, m):  #nCr mod m
    if (n<0 or r<0 or n<r): return 0
    r = min(r, n-r)
    return fac[n] * finv[n-r] * finv[r] % m

def chofuku(n,r): # nHr mod MOD の計算
    return comb_mod(n+r-1,r)
 
def nPr(n,r,m): #nPr mod m の計算
    return fac[n]*finv[n-r]%m
ans = 0
for i in range(1,N+1):
    if i % 2 == 1:
        flag = 1
    else:
        flag = -1
    s = flag*comb_mod(N,i,MOD)*nPr(M-i,N-i,MOD)
    ans += s
    if ans > MOD:
        ans %= MOD
ans1 = 1
for i in range(N):
    ans1 *= (M-i)
    ans1 %= MOD
ans2 = (ans1*ans1)%MOD
ans3 = (ans*nPr(M,N,MOD)) %MOD
print((ans2-ans3)%MOD)


Measured memory_bytes: 69756
#include <bits/stdc++.h>
#define ll  long long
#define ld  long double
#define endl "\n"
#define ull  unsigned long long
#define pb push_back
#define all(v) ((v).begin()),((v).end())
#define vi   vector<ll>
#define INF 1000000000
#define M ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int main()
{
	M
	ll n,dp[1000001]={};
	vi v;
	cin>>n;
	for(int i=0;i<n;i++){
		ll in; cin>>in; v.pb(in);
	}
	dp[0]=0;
	for(int i=1;i<=n;i++)
		dp[i]=INF;
	for(int i=0;i<n;i++){
		if(i+1<n) dp[i+1]=min(dp[i+1],dp[i]+abs(v[i]-v[i+1]));

		if(i+2<n) dp[i+2]=min(dp[i+2],dp[i]+abs(v[i]-v[i+2]));
	}
	cout<<dp[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 9208
n,m = map(int,input().split())
ab = []
for i in range(m):
    a,b = map(int,input().split())
    ab.append((a,b))
ab = sorted(ab,key=lambda x:x[1])
count = 0
while len(ab) != 0:
    x = ab.pop(0)
    cut = x[1]-1
    count += 1
    while len(ab) != 0:
        if ab[0][0] <= cut <= ab[0][1]:
            ab.pop(0)
        else:
            break
print(count)

Measured memory_bytes: 18980
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
//class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
        BufferedReader stdReader =
            new BufferedReader(new InputStreamReader(System.in));
        String[] nums = stdReader.readLine().split(" ");
         
        int[] a = new int[nums.length];
        
        for(int i = 0; i < nums.length; i++) {
        	a[i] = Integer.parseInt(nums[i]);
        }
        
        if( (a[2] - a[4]) < 0 		||
        	(a[3] - a[4]) < 0		||
        	(a[2] + a[4]) > a[0] 	||
        	(a[3] + a[4]) > a[1] 	){
        	System.out.println("No");
        } else {
        	System.out.println("Yes");
        }
        
	}
}

Measured memory_bytes: 17084
import java.util.*;
import java.text.*;
/*
Main class for AOJ where there is no input.
*/
public class Main{
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String[] arr = sc.nextLine().split(" ");
      int a = Integer.parseInt(arr[0]);
      int b = Integer.parseInt(arr[1]);
      
      int d = a / b;
      int r = a % b;
      double f = (double)a / (double)b;
      
      System.out.println(d + " " + r + " " + String.format("%.6f",f));
      
    
   }//main
}//class

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

int main(void)
{
    long long int x;
    cin >> x;

    long long int uu = 0;

    uu += x/500 * 1000;
    uu += (x%500)/5 * 5;

    cout << uu << endl;
    

    return 0;
}



Measured memory_bytes: 256
// Author       : Naresh Bharasagar
            // CF Handle    : Nareshhhh
            // Programme    : B.Tech Computer Science & Engineering
            // Organization : Indian Institute of Technology Guwahati

#include<bits/stdc++.h>
using namespace std;
typedef long long int loo;


#define loop(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define rep(r) for(auto i=1; i<=r; ++i)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define v(name,type,size) vector<type> name(size)
#define vloo vector<loo>
#define outa(a,n) loop(i,0,n) cout << a[i] << " ";
#define p0(a) cout << #a << endl
#define mod(a) a%1000000007
#define pb(l) push_back(l)
#define ppb pop_back()
#define ff first
#define ss second
#define input(a) for(auto &i: a) cin >> i;
#define prnt(v) for(auto it: v) cout << it << " ";
#define deb0(i) cout << "[i=" << i << "]" << endl;
#define mt make_tuple
#define mp make_pair
#define eb emplace_back
#define INF 1000000000
#define M 1000000007

loo power(loo x, loo y, loo p) { 
    loo res = 1;
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res*x) % p; 
        y = y>>1;
        x = (x*x) % p;   
    } 
    return res; 
}

bool sortbysec(const pair<loo,loo> &a, const pair<loo,loo> &b) { 
    return (a.second < b.second); 
}

string decToBin(loo n)
{
	string s = "0";
	if(n == 0) return s;
	s = "";
    while (n > 0)
    { 
        s += (n % 2) + '0';
        n = n / 2;
    }
    reverse(s.begin(), s.end());
    return s;
}
 
loo binToDec(string s)
{
    loo ans = 0;
    reverse(s.begin(), s.end());
    loop(i, 0, s.size())
    {
    	ans += pow(2, i)*(s[i] - '0');
    }
    return ans;
}

int main() {
	fast_io

    // freopen("filename.in","r",stdin);
    // freopen("filename.out","w",stdout);

    loo a,b,c;
    cin >> a >> b >> c;
    set<loo> res;
    res.insert(a);
    res.insert(b);
    res.insert(c);
    if(res.size()==2) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

public class Main{
	static void main() throws Exception{
		int[]in=sc.intArr(5);
		for(int i=0;i<5;i++) {
			if(in[i]==0) {
				pw.println(i+1);
				return;
			}
		}
	}
	public static void main(String[] args) throws Exception{
		pw=new PrintWriter(System.out);
		sc = new MScanner(System.in);
//		int tc=sc.nextInt();
//		while(tc-->0)
			main();
		pw.flush();
	}
	static PrintWriter pw;
	static MScanner  sc;
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}

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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	string s ;
	cin >> s ;
	//区画の数-1
	char c = s[0];
	int area = 1 ;
	rep(i,s.size()){
		if(c != s[i]){
			area ++;
			c = s[i];
		}
	}
	cout << area - 1 << endl;
}


Measured memory_bytes: 512
n,k = map(int,input().split())
now = list(map(int,input().split()))
#import heapq
for _ in range(k):
  last = now
  now = []
  imos = [0 for _ in range(n+1)]
  for i in range(n):
    l = max(0,i-last[i])
    r = min(n,i+last[i]+1)
    imos[l] += 1
    imos[r] -= 1
  now.append(imos[0])
  for i in range(1,n):
    now.append(now[-1]+imos[i])
  #print(now)
  if sum(now) == n**2:
    print(' '.join(map(str,now)))
    exit()
print(' '.join(map(str,now)))

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

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


template<typename T>
struct SegmentTree{
  using F = function<T(T, T)>;
  Int n;
  F f;
  T ti;
  vector<T> dat;
  SegmentTree(){}
  SegmentTree(F f, T ti):f(f), ti(ti){}

  void init(Int n_){
    n = 1;
    while(n < n_) n<<= 1;
    dat.assign(n<<1, ti);
  }

  void build(const vector<T> &v){
    Int n_ = v.size();
    init(n_);
    for(Int i=0;i<n_;i++) dat[n+i] = v[i];
    for(Int i=n-1;i;i--)
      dat[i] = f(dat[(i<<1)|0], dat[(i<<1)|1]);
  }

  void set_val(Int k, T x){
    dat[k+=n] = x;
    while(k>>=1)
      dat[k] = f(dat[(k<<1) | 0], dat[(k<<1) | 1]);
  }

  T query(Int a,Int b){
    T vl = ti, vr = ti;
    for(Int l=a + n, r = b + n; l<r ; l>>=1, r>>=1){
      if(l&1) vl = f(vl, dat[l++]);
      if(r&1) vr = f(dat[--r], vr);
    }
    return f(vl, vr);
  }
    

};
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);


  Int n,k;
  cin>>n>>k;
  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i],as[i]--;

  Int ans=1;
  for(Int i=0;i<n;i++){
    if(i>as[i]) continue;
    auto f=[](Int a,Int b){return max(a,b);};   
    SegmentTree<Int> seg(f,-n);
    seg.build(vector<Int>(n,-n));
    seg.set_val(as[i],1);
    for(Int j=i+1;j<as[i];j++){
      if(j>as[j]) continue;
      if(as[j]<as[i]) continue;      
      Int res=seg.query(0,as[j]);
      seg.set_val(as[j],res+1);
      //cout<<i<<" "<<j<<":"<<res+1<<endl;
      chmax(ans,res+1);
    }
  }
  
  ans+=k;
  chmin(ans,n/2);
  cout<<ans<<endl;
  return 0;
}




Measured memory_bytes: 3368
#include<bits/stdc++.h>
#define int long long
#define rep(i, l, r) for(register int i = l; i <= r; ++ i)
using namespace std;
const int N = 3000010;
inline int read()
{
	register char cc = getchar(); register int cn(0), flus(1);
	while(cc < '0' || cc > '9') {if(cc == '-') flus = - flus; cc = getchar();}
	while(cc >= '0' && cc <= '9') {cn = cn * 10 + cc - '0'; cc = getchar();}
	return cn * flus;
}
signed main()
{
	string s;
	cin>>s;
	rep(i, 1, s.size()) putchar('x');
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxN = 2e3 + 13, mod = 924844033;
int n, k, dp[maxN][maxN][2], ans, fac[maxN];
int32_t main () {
    cin >> n >> k;
    dp[0][0][0] = 1;
    int i = 0;
    for (int res = 0; res <  2 * k; res++)
	for (int pos = res + 1; pos <= n; pos += 2 * k) {
	    i++;
	    for (int j = 0; j <= i; j++) {
		if (pos - k <= 0 && pos + k > n) {
		    dp[i][j][0] = (dp[i - 1][j][0] + dp[i - 1][j][1]) % mod;
		    continue;
		}
		
		else if (pos - k <= 0) {
		    //qabli nadare
		    //bardashte nashe ya ba qablish bardashte she
		    dp[i][j][0] = (dp[i - 1][j][0] + dp[i - 1][j][1]) % mod;
		    //ba badish bardashte she
		    dp[i][j][1] = (dp[i - 1][j - 1][0] + dp[i - 1][j - 1][1]) % mod;
		}
		else if (pos + k > n) {
		    //badi nadare
		    dp[i][j][0] = (((dp[i - 1][j][0] + dp[i - 1][j][1]) % mod) + ((dp[i - 1][j - 1][0] + (pos == res + 1? dp[i - 1][j - 1][1] : 0)) % mod)) % mod;
		}
		else {
		    dp[i][j][0] = (((dp[i - 1][j][0] + dp[i - 1][j][1]) % mod) + ((dp[i - 1][j - 1][0] + (pos == res + 1? dp[i - 1][j - 1][1] : 0)) % mod)) % mod;
		    dp[i][j][1] = (dp[i - 1][j - 1][0] + dp[i - 1][j - 1][1]) % mod;
		}
		//cout << i << " " << j << " " << dp[i][j][0] << " " << dp[i][j][1] << endl;
	    }

	}
    fac[0] = 1;
    for (int i = 1; i <= n; i++) {
	fac[i] = fac[i - 1] * i % mod;
    }
    for (int i = 0; i <= n; i++) {
	ans = ((ans + ((i % 2 == 1? -1 : 1) * 1ll * ((dp[n][i][0] + dp[n][i][1]) % mod) * fac[n - i] % mod)) + mod) % mod;
    }
    cout << ans << endl;
}


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

int main(){
  int count = 0;
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  for (int m=0;m<=A;m++){
    int X2 = X -500*m;
    if(X2<0)continue;
    for(int n=0;n<=B;n++){
      int X3 = X2 -100*n;
      if(X3<0)break;
      int num = X3 / 50;
      if(num <= C){
        count++;
      }
    }
  }
cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,m;
    cin >> n >> m;
    pair<int, int> edge[m];
    rep(i,m)
    {
        int a,b;
        cin >> a >> b;
        --a;--b;
        pair<int, int> p=make_pair(a,b);
        edge[i] = p;
    }

    int ans=0;
    rep(i,m)
    {
        // i no hashi ga nakattara
        UnionFind uf(n);
        rep(j,m)
        {
            // tunaide, kyo ka handan
            if(i==j) continue;
            uf.merge(edge[j].first, edge[j].second);
        }
        if (uf.root(edge[i].first) != uf.root(edge[i].second) )
        {
            uf.merge(edge[i].first, edge[i].second);
            if (uf.root(edge[i].first) == uf.root(edge[i].second) ) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 892
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.Beginner068
{
    public class ABC089B
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] nums = Console.ReadLine().Split(' ').ToArray();

            foreach(string c in nums)
            {
                if(c.Equals("Y"))
                {
                    Console.WriteLine("Four");
                    return;
                }
            }
            Console.WriteLine("Three");
        }
    }
}

Measured memory_bytes: 13268
N, K = map(int, input().split())
h = list(map(int, input().split()))

if K >= N - 1:
    print(h[N - 1] - h[0])
else:
    dp = [10 ** 10 for i in range(N)]
    dp[0] = 0
    for i in range(1, N):
        for j in range(1, K + 1):
            if i >= j:
                dp[i] = min(dp[i - j] + abs(h[i] - h[i - j]), dp[i])
    print(dp[N - 1])


Measured memory_bytes: 56032
//Mohamed Galal
#define _CRT_SECURE_NO_WARNINGS
#include <cstring>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <string>
#include <cstdlib>
#include <functional>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <list>
#include <climits>
#include <cctype>
#include <bitset>
#define PI 3.14159265359
#define all(v)  ((v).begin()), ((v).end())
#define all(s)  ((s).begin()), ((s).end())
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
void file()
{
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
}
void Mohamed_Galal()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL), cout.tie(NULL);
}
int main()
{
	Mohamed_Galal();
	int count = 1, mx = 0;
	string s;
	cin >> s;
	/*for (size_t i = 0; i < s.size(); i++)
		s[i] -= '0';*/
	for (size_t i = 0; i < s.size(); i++)
	{
		if (s[i] == s[i + 1])
			count++;
		else
		{
			mx = max(count, mx);
			count = 1;
		}
	}
	if (mx >= 3 ? cout << "Yes" : cout << "No")
	//system("pause");
	return 0;
}

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

using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long

int main()
{
  IOS;
  int h, n;
  cin >> h >> n;
  int t=0;
  for (int i=0, x; i<n; i++)
    {
      cin >> x;
      t+=x;
    }
  if (t>=h)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3660