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

#define all(x) x.begin(),x.end()
#define pb(x) emplace_back(x)
#define forn(i,N) for(int i=0;i<N;i++)

using namespace std;
using ll=long long int;
using ld=long double;
using vi=vector<int>;

int main() {
//freopen("input.txt","rt",stdin);
ios::sync_with_stdio(false);
cin.tie(nullptr);

int N;
cin>>N;
vector<int> v(N);
int sum=0;
for(auto& x: v) {
  cin>>x;
  sum+=x;
}
sum/=N;
int a[3]={0};
for(auto& x: v) {
  for(auto& y: {-1,0,1}) {
    a[y+1]+=((x-(sum+y))*(x-(sum+y)));
  }
}
cout<<*min_element(a,a+3)<<endl;
return 0;
}


Measured memory_bytes: 3664
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int N;
	cin >> N;
	int A[1000000];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int z = 0; z < N; z++) {
		if (A[z] % 2 == 1) {
		}
		else
		{


			if (A[z] % 3 != 0 && A[z] % 5 != 0) {
				cout << "DENIED";
				return 0;
			}
			else
			{
			}
		}
	}
		cout << "APPROVED";
		return 0;
	}

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

#define MAXN 200005
#define INF 0x3f3f3f3f

typedef long long lint;

using namespace std;

const int mod = 1e9 + 7;
int n, x, y;
int c[MAXN], w[MAXN], mini[MAXN];
int sum[MAXN], amount;
int first, second, firstc;
lint fac[MAXN], inf[MAXN];

int read() {
    char c = getchar();
    int x = 0;
    while (!isdigit(c))
        c = getchar();
    while (isdigit(c)) {
        x = (x << 3) + (x << 1) + c - '0';
        c = getchar();
    }
    return x;
}

lint power(lint a, int b) {
    lint res = 1;
    while (b) {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

void init() {
    fac[0] = inf[0] = 1;
    for (int i = 1; i <= n; ++i)
        fac[i] = fac[i - 1] * i % mod;
    inf[n] = power(fac[n], mod - 2);
    for (int i = n - 1; i >= 1; --i)
        inf[i] = inf[i + 1] * (i + 1) % mod;
}

int main() {
//    freopen("15.txt", "r",stdin);
    n = read();
    x = read();
    y = read();
    init();
    memset(mini, 0x3f, sizeof(mini));
    for (int i = 1; i <= n; ++i) {
        c[i] = read();
        w[i] = read();
        mini[c[i]] = min(mini[c[i]], w[i]);
    }
    for (int i = 1; i <= n; ++i)
        if (mini[c[i]] + w[i] <= x)
            w[i] = mini[c[i]];
    first = second = INF;
    for (int i = 1; i <= n; ++i)
        if (mini[i] < first) {
            second = first;
            first = mini[i];
            firstc = i;
        }
        else if (mini[i] < second)
            second = mini[i];
//    printf("%d %d\n", first, second);
    if (first + second <= y)
        for (int i = 1; i <= n; ++i)
            if (c[i] == firstc && w[i] != first && w[i] + second <= y)
                w[i] = first;
    for (int i = 1; i <= n; ++i)
        if (c[i] == firstc && w[i] == first) {
//            cout << "first: " << i << endl;
            ++sum[c[i]];
            ++amount;
        }
        else if (c[i] != firstc && w[i] + first <= y) {
//            cout << "second: " << i << endl;
            ++sum[c[i]];
            ++amount;
        }
    lint res = fac[amount];
    for (int i = 1; i <= n; ++i)
        res = res * inf[sum[i]] % mod;
    printf("%lld\n", res);
}


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

int main() {
    int a, b;
    char op;
    while (true) {
        scanf("%d %c %d", &a, &op, &b);
        if (op == '+') {
            cout << a + b << endl;
        } else if (op == '-') {
            cout << a - b << endl;
        } else if (op == '*') {
            cout << a * b << endl;
        } else if (op == '/') {
            cout << a / b << endl;
        } else {
            break;
        }
    }
}

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

double p[3010];
double dp[3010][3010];

int main(void) {
  	int N;
  	cin >> N;
	dp[0][0] = 1;
	for(int i=1; i<=N; i++) {
		cin>>p[i];
		dp[i][0] = 0;
		for(int j=1; j<=i; j++) {
			dp[i][j-1] = dp[i][j-1]+(1-p[i])*dp[i-1][j-1];
			dp[i][j] = p[i]*dp[i-1][j-1];
		}
	}
	long double ans=0;
	for(int i=N/2+1; i<=N; i++)
		ans += dp[N][i];
	cout << fixed << setprecision(9) << ans << endl;
	return 0;
}


Measured memory_bytes: 69120
x=int(input())
m=2*(10**5)
lis=[True for i in range(m)]
i=2
while i*i<=m:
    if lis[i]:
        for j in range(2*i,m,i): lis[j]=False
    i+=1
while True:
    if lis[x]:
        print(x)
        break
    x+=1

Measured memory_bytes: 10624
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;

long long R, C, K;
map<pair<long long, long long>, long long> item;

//x 行 y 列
long long dp[3005][3005][5];

int main(){
	cin >> R >> C >> K;

	rep(i, K) {
		long long x, y, v;
		cin >> x >> y >> v;
		x--;y--;
		item[make_pair(x, y)] = v;
	}

	long long ans = 0;
	rep(x, R) {
		rep(y, C) {
			if(item.count(make_pair(x, y)) != 0) {
				long long v = item[make_pair(x, y)];
				//拾って右, 3個拾った状態からは拾えない
				//行移動
				rep(i, 3) {
					dp[x+1][y][0] = max(dp[x+1][y][0], dp[x][y][i] + v);
					ans = max(ans, dp[x+1][y][0]);
				}

				//拾って下
				rep(i, 3) {
					dp[x][y+1][i+1] = max(dp[x][y+1][i+1], dp[x][y][i] + v);
					ans = max(ans, dp[x][y+1][i+1]);
				}
			}

			//拾わないで右
			rep(i, 4) {
				dp[x+1][y][0] = max(dp[x+1][y][0], dp[x][y][i]);
			}

			//拾わないでした
			rep(i, 4) {
				dp[x][y+1][i] = max(dp[x][y+1][i], dp[x][y][i]);
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 368400
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x,y;cin>>x>>y;
  ll res=(4-min(4LL,x)+4-min(4LL,y))*100000;
  if(x==1&&y==1)res+=400000;
  cout<<res<<endl;
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    ll n;
    in(n);
    vector<ll> a(n),b(n),plus;
    in(a);
    in(b);
    ll x,minus=0,plussum=0,minusn=0;
    rep(i,n){
        x=a[i]-b[i];
        if(x>0){
            plus.push_back(x);
        }
        if(x<0){
            minus+=x;
            minusn++;
        }
    }
    sort(rall(plus));
    rep(i,plus.size()){
        plussum+=plus[i];
        plus[i]=plussum;
    }
    if(plussum<-minus){
        out(-1);
        return 0;
    }
    minus=-minus;
    ll ans=(ll)(lower_bound(all(plus),minus)-plus.begin())+minusn+1;
    if(minus==0)ans=0;
    if(*(lower_bound(all(plus),minus))==minus)ans--;
    out(ans);
}

Measured memory_bytes: 5496
#include <iostream>
#include <iomanip>
#include <cmath>
#include <map>
#include <queue>
#include <string>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int n,k; cin >> n >> k;
    --k;
    long double exp[n];
    for(int i = 0; i<n; ++i){
        long  tmp; cin >> tmp;
        exp[i] = (1.0+tmp)/2.0;
    }
    //ok
    long double sum_exp[n]; sum_exp[0] = exp[0];
    for(int i = 1; i<n; ++i){
        sum_exp[i] = sum_exp[i-1] + exp[i];
    }
    //ok
    long double ans = sum_exp[k];
    for(int i = 1; i+k<n; ++i){
        long double tmp_exp = sum_exp[i+k] - sum_exp[i-1];
        if(ans < tmp_exp) ans = tmp_exp;
    }
    cout << setprecision(10) << ans << endl; return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  long long a, b, x;
  cin >> a >> b >> x;
  long long ans = (b / x) - (a / x);
  if(a % x == 0)
    ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	string s;
	cin >> s;
	for (int i = 0; i < s.size() - 1; i++) {
		if (s[i] == 'A'&&s[i + 1] == 'C') {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>
#include <map>
#include <random>
/* All our base are belong to AC */
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<int,int>;
const ll M = 1e9+7;
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; template<typename T, typename U> void chmax(T& x, U y) {if (x<y) x=y;}; template<typename T, typename U> void chmin(T& x, U y) {if (x>y) x=y;};
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}

namespace r {
    random_device rd;
    mt19937 mt(rd());
    //mt19937 mt(time(NULL));
    int nd(int max) {return mt() % max + 1;}
    int nd2(int min, int max) {return mt() % (max - min + 1) + min;}
}

int main() {
  for(int i=0;i<365;i++) {
    cout<<r::nd(26)<<endl;
  }
}

Measured memory_bytes: 3628
from fractions import gcd


x,y = map(int, input().split())


def gcd(x, y):
  b = max(x, y)
  s = min(x, y)
  r = b % s
  while r != 0:
    b = s
    s = r
    r = b % s
  return s
 
def lcm(x, y):
  return (x * y) // gcd(x,y)


ans = lcm(x,y)

print(ans)

Measured memory_bytes: 10416
S = list(input())
L = len(S)
count = 0
count_minus = [0] * L
for i in range(L):
    if S[i] == ">":
        count = 0
    else:
        count += 1
    count_minus[i] = count

count = 0
count_plus = [0] * L
for i in reversed(range(L)):
    if S[i] == "<":
        count = 0
    else:
        count += 1
    count_plus[i] = count

result_list = [0] * (L-1)
for i in range(len(result_list)):
    result_list[i] = max(count_minus[i], count_plus[i+1])

result = sum(result_list) + count_minus[L-1] + count_plus[0] 
print(result)

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

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

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

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

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

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

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

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

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

    int n;
    cin >> n;
    vi v(n);
    rep(i, n) { cin >> v[i]; }

    sort(all(v));

    double ans = v[0];
    for (int i = 1; i < n; i++) {
        ans = (ans + v[i]) / 2;
    }

    cout << ans << endl;

    return 0;
}


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


 
int main(){
  int n, i, j, k;
  vector<vector<int>> data(3, vector<int>(3));
  for(i=0; i<3; i++){
    for(j=0; j<3; j++){
      cin >> data.at(i).at(j);
    }
  }
  
  
  cin >> n;
  
  vector<int> B(n);
  int ch = 2;
  int th = 2;
  for (i = 0; i < n; i++) {
    cin >> B[i];
  }
  
  for(i=0; i<3; i++){
    for(j=0; j<3; j++){
      for(k=0; k<n; k++){
        if(B[k] == data.at(i).at(j)) data.at(i).at(j) = 128; 
      }
    }
  }
  
  for(i=0; i<3; i++){
    if(data.at(i).at(0) == 128 && data.at(i).at(1) == 128 && data.at(i).at(2) == 128){
     ch = -1;
     break; 
    }
    if(data.at(0).at(i) == 128 && data.at(1).at(i) == 128 && data.at(2).at(i) == 128){
     ch = -1;
     break; 
    }
    if(data.at(i).at(i) == 128){
     ch--;
    }
    if(data.at(i).at(2-i) == 128){
     th--;
    }
  }
  

  
  
  if(ch == -1 || th == -1) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define ar array
#define db double
#define filename "SUBKGCD"
#define pow pw
const db pi = 3.14159265358979323846;
int pw(int a,int b){
	int ans=1;
	while(b){
	if (b%2) ans*=a;
	a*=a;
	b/=2;
	}
	return(ans);
}
const int mxn=5e5+3;
int n,q;
int ft[2*mxn];
void upd(int i,int v)
{
    while(i<=n)
    {
        ft[i]+=v;
        i+=i&-i;
    }
}
int que(int i)
{
    int res=0;
    while(i>=1)
    {
        res+=ft[i];
        i-=i&-i;
    }
    return(res);
}
signed main()
{
    //freopen(filename".inp","r",stdin);
    //freopen(filename".out","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    cin>>n>>q;
    for (int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        upd(i,x);
    }
    while(q--)
    {
        int qu,a,b;
        cin>>qu>>a>>b;
        if (qu==0)
        {
            upd(a+1,b);
        }
        else cout<<que(b)-que(a)<<"\n";
    }
	return 0;
}


Measured memory_bytes: 8256
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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

int main() {
	int N;
	cin >> N;
	vector<ll> A(N);
	rep(i,N) cin >> A[i];
	vector<ll> B(N), C(N);
	map<ll, ll> mp, mp2;
	ll ans = 0;
	rep(i,N) {
		C[i] = i - A[i];
		ans += mp[C[i]];
		B[i] = i + A[i];
		mp[B[i]]++;
	}
	cout << ans << endl;


  return 0;
}


Measured memory_bytes: 30672
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int readin()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
ll qmod(ll a,ll b,ll mod)
{
	ll r=1;
	while(b)
	{
		if(b&1)
		r=r*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return r;
}
ll exgcd(ll a,ll b,ll &x,ll &y)
{
	if(a==0&&b==0)
	return -1;
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll d=exgcd(b,a%b,y,x);
	y-=a/b*x;
	return d;
}
ll niyuan(ll a,ll n)
{
	ll x,y;
	ll d=exgcd(a,n,x,y);
	if(d==1)
	return (x%n+n)%n;
	return -1;
}
int main()
{
    int i,j;
    string s;
    cin>>s;
    int flg=0;
    int len=s.length();
    for(i=0;i<=len-2;i++)
    {
        if(s[i]=='h' && s[i+1]=='i')
        {
            flg++;
        }
    }
    if(len%2==0 && flg==len/2)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		int[] a=new int[3];
		for(int i=0;i<3;++i)a[i]=sc.nextInt();
		Arrays.sort(a);
		System.out.println(a[0]==5&&a[1]==5&&a[2]==7?"YES":"NO");
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
	
}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
 
int main()
{
 vector<int> v(10);
 int n,i,m;
 while(cin>>n,n){
  fill(v.begin(),v.end(),0);
  for(i=0;i<n;i++){
   cin>>m;
   v[m]++;
  }
  for(i=0;i<10;i++){
   if(!v[i])cout<<"-";
   else for(n=0;n<v[i];n++)cout<<"*";
   cout<<endl;
  }
 }
 return 0;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;
long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
     cin>>n;
     if(n<=999)Cout("ABC");
     else Cout("ABD");
    
       
return 0;
}


Measured memory_bytes: 256
x, y = map(int, input().split())
has_edge = [[2000000010 for _ in range(4)] for _ in range(4)]
has_edge[0][1] = has_edge[1][0] = 1
has_edge[2][3] = has_edge[3][2] = 1
has_edge[0][3] = has_edge[2][1] = abs(x) + abs(y)
if abs(y) >= abs(x):
    has_edge[1][3] = has_edge[2][0] = abs(y) - abs(x)
if abs(y) <= abs(x):
    has_edge[3][1] = has_edge[0][2] = abs(x) - abs(y)
has_edge[0][0] = has_edge[1][1] = has_edge[2][2] = has_edge[3][3] = 0
for k in range(4):
    for i in range(4):
        for j in range(4):
            has_edge[i][j] = min(has_edge[i][j], has_edge[i][k] + has_edge[k][j])
xx = 1 if x >= 0 else 0
yy = 3 if y >= 0 else 2
print(has_edge[xx][yy])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll MOD = 1e9+7;

int main(){
  ll n,q;
  string s;
  cin>>n>>s>>q;
  for(int i=0;i<=n;i++)s+='.';
  for(int cn=0;cn<q;cn++){
	ll k,ans=0;
	cin>>k;
	ll cntc=0,sumn=0,cntm=0;
	for(int i=0;i<k;i++){
	  if(s[i]=='M')cntm++;
	  if(s[i]=='C'){
		sumn+=cntm;
		cntc++;
	  }
	}
	for(int i=0;s[i]!='.';i++){
	  if(s[i]=='D')ans+=sumn;
	  if(s[i]=='M'){
		cntm--;
		sumn-=cntc;
	  }
	  if(s[i]=='C'){
		cntc--;
	  }
	  if(s[i+k]=='M')cntm++;
	  if(s[i+k]=='C'){
		cntc++;
		sumn+=cntm;
	  }
	}
	cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 2436
#include <iostream>
#include <vector>
using namespace std;
using ull = unsigned long long;
int main(void) {
  ull N, K;
  cin >> N >> K;
  vector<ull> A(N);
  for (auto &a : A) {
    cin >> a;
    a--;
  }

  vector<ull> vis(N, 0);
  ull cnt = 1;
  ull i = 0;
  do {
    vis[i] = cnt;
    cnt++;
    i = A[i];
  } while (vis[i] == 0);

  ull line = vis[i];
  ull loop = cnt - vis[i];

  ull m = (K > line) ? line + (K - line) % loop : K;
  ull x = 0;
  for (ull i = 0; i < m; i++) {
    x = A[x];
  }
  cout << x + 1 << endl;
  return 0;
}

Measured memory_bytes: 6388
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
typedef long long ll;
const int N = 25;
const int INF = 1e9;
const int MOD = 1e9+7;

int n;
int a[N];
int b[N];
int c[N-1];
int main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n;
	for(int i=1; i<=n; i++) cin >> a[i];
	for(int i=1; i<=n; i++) cin >> b[i];
	for(int i=1; i<n; i++) cin >> c[i];
	int ans = 0;
	for(int i=1; i<=n; i++){
		ans += b[a[i]];
		if (a[i] - a[i-1] == 1) {
			ans += c[a[i-1]];
		}
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 384
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647 -> 10桁
// MAX ll 9,223,372,036,854,775,807 -> 19桁
// MAX O(n) 10^18

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A.at(i);

    ll ans = 1;
    rep(i, N) {
        if ((A.at(i) != 0 && ans > (ll)pow(10, 18)) || A.at(i) != 0 && ans * A.at(i) != (ll)pow(10, 18) && to_string(ans).size() + to_string(A.at(i)).size() >= 20) {
            ans = (ll)pow(10, 18) + 1;
        } else {
            ans *= A.at(i);
        }
    }

    if(ans > (ll)pow(10, 18)) {
        ans = -1;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3992
import scala.io.StdIn._
object Main extends App {
  val Array(l, r) = readLine.split(" ").map(_.toLong)
  val is = l to Math.min(r - 1, l + 2019)
  println(is.foldLeft(Long.MaxValue){(min, i) =>
    val js = i + 1 to Math.min(r, i + 2020)
    js.foldLeft(min){(minmin, j) =>
      Math.min(minmin, i * j % 2019)
    }
  })
}

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

int64_t count(int64_t x) {
    if (x <= 0) {
        return 0;
    } else if (x < 7) {
        return 1;
    } else  if (x < 12) {
        return 2;
    }
    int64_t temp = x/11;
    return 2*temp+count(x-temp*11);
}

int main() {
    int64_t x;
    cin >> x;
    cout << count(x) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
	int a,sum=0,i=0;
	scanf("%d",&a);
	while(a>=sum)
	{
		i+=1;
		sum=i*i;
	}
	printf("%d\n",(i-1)*(i-1));
    	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#pragma comment(linker,"/STACK:1024000000,1024000000")
//251103FD
//4008802802
using namespace std;
#define PB pop_back
#define PF pop_front
#define np next_permutation
#define eb emplace_back
#define pb push_back
#define bf push_front
#define mp make_pair
#define s second
#define f first
#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)
#define Foreach(it, a) for(__typeof((a).rbegin()) it=(a).rbegin(); it!=(a).rend(); it++)
#define forn(i, a) for(register int i=0; i<a; i++)
#define Forn(i, a) for(register int i=1; i<=a; i++)
#define memINF 127
#define all(x) x.begin(), x.end()
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<pi,int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef unsigned int uint;
typedef vector<vector<ll> > matrix;

inline int in() 
{
    int x=0, c;
    while((uint)((c=getchar())-48)>=10) 
		if(c=='-') 
			return -in();
    do 
	{ x=(x<<3)+(x<<1)+(c^48); }
	while((uint)((c=getchar())^48)<10);
    return x;
}
inline int lcm(int a, int b){return a*b/__gcd(a, b);}

const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,-1,1};
const char d[4]={'R','L','D','U'};
const int MAX=1005;

vi v;
int N, x[MAX], y[MAX], s0, s1;

int main()
{
	N=in();
	Forn(i, N)
    {
        x[i]=in(), y[i]=in();
		if((x[i]+y[i])&1) 
            s1++;
        else 
            s0++;
	}
	if(s0&&s1) 
    {
        puts("-1");
        return 0;
    }
	if(s0) 
        puts("32");
    else 
        puts("31");
    
    for(register int i=30; i>-1; --i)
        v.eb(1<<i), printf("%d ", 1<<i);
	if(s0) 
        v.eb(1),printf("1");
	puts("");
	Forn(i, N)
	{
		ll nx=0, ny=0;
		foreach(it, v)
		{ 
		   ll Min=1e18, pos;
		   forn(j, 4)
		   {
		   	  ll tx=nx+(*it)*dx[j], ty=ny+(*it)*dy[j];
		   	  if((ll)abs(x[i]-tx)+abs(y[i]-ty)<Min)
		   	  {
		   	  	  Min=(ll)abs(x[i]-tx)+abs(y[i]-ty);
		   	  	  pos=j;
			  }
		   }
		   putchar(d[pos]);
		   nx+=(*it)*dx[pos];
           ny+=(*it)*dy[pos];
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 256
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;
use std::collections::HashSet;

fn main() {
    let n: usize;
    input!(n);
    let a = input_vector::<usize>();
    let a = a.iter().collect::<HashSet<_>>();
    if a.len() == n {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 11440
#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<assert.h>
#include<set>
#include<cmath>
#include<queue>
#include<cstdlib>
#include<iostream>
#include<bitset>
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define rep(i,j,k) for(int i=(int)(j);i<=(int)(k);i++)
#define per(i,j,k) for(int i=(int)(j);i>=(int)(k);i--)
using namespace std;
typedef long long LL;
//template
typedef double db;
const db eps=1e-10;
const db pi=acosl(-1.0);
int sign(db x){if(x<-eps)return -1;if(x>eps)return 1;return 0;}
int cmp(db x,db y){return sign(x-y);}
struct po{
	db x,y;
	po(db _x=0,db _y=0):x(_x),y(_y){}
};
po operator +(const po &a,const po &b){return po(a.x+b.x,a.y+b.y);}
po operator -(const po &a,const po &b){return po(a.x-b.x,a.y-b.y);}
po operator *(const po &a,const db &b){return po(a.x*b,a.y*b);}
po operator /(const po &a,const db &b){return po(a.x/b,a.y/b);}
db operator *(const po &a,const po &b){return a.x*b.x+a.y*b.y;}
db operator ^(const po &a,const po &b){return a.x*b.y-a.y*b.x;}
db mo2(po a){return a*a;}
db mo(po a){return sqrt(a*a);}
po proj(po x,po y){//proj x to y
	return y*((x*y)/mo2(y));
}
po refl(po x,po y){//refl x from y
	return proj(x,y)*2-x;
}
//template
int main(){
	po p1,p2;
	scanf("%lf%lf%lf%lf",&p1.x,&p1.y,&p2.x,&p2.y);
	int t;scanf("%d",&t);
	p2=p2-p1;
	while(t--){
		po x;scanf("%lf%lf",&x.x,&x.y);
		x=x-p1;
		db w=(x^p2);
		if(sign(w)==1){
			puts("CLOCKWISE");
			continue;
		}
		if(sign(w)==-1){
			puts("COUNTER_CLOCKWISE");
			continue;
		}
		if(sign(x*p2)==-1){
			puts("ONLINE_BACK");
			continue;
		}
		if(cmp(mo2(x),mo2(p2))<=0){
			puts("ON_SEGMENT");
			continue;
		}
		puts("ONLINE_FRONT");
		continue;
	}
	return 0;
}






Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define sqr(x) (x)*(x)
#define mod 1000000007

ll n,m,tim,dp[52][1048580];
vector<pll> edge,rest;
vector<ll> adj[52],effect[52];
bool vis[52];

void dfs(ll u, ll p){
	vis[u]=1;
	for(auto v:adj[u]){
		if(v!=p) dfs(v,u);
	}
}

ll call(ll pos, ll mask){
	if((pos+1)==n) return mask==((1ll<<m)-1);
	ll &ret=dp[pos][mask];
	if(ret!=-1) return ret;
	ret=0;
	ret+=call(pos+1,mask);
	ll nmask=mask;
	for(int i=0;i<(int)effect[pos].size();i++){
		ll idx=effect[pos][i];
		nmask|=(1ll<<idx);
	}
	ret+=call(pos+1,nmask);
	return ret;
}

int main()
{
    scanf("%lld",&n);
    for(int i=0;i<n-1;i++){
		ll u,v;
		scanf("%lld %lld",&u,&v);
		adj[u].pb(v);
		adj[v].pb(u);
		edge.pb({u,v});
	}
	scanf("%lld",&m);
	for(int i=0;i<m;i++){
		ll u,v;
		scanf("%lld %lld",&u,&v);
		rest.pb({u,v});
	}
	for(int i=0;i<n-1;i++){
		memset(vis,0,sizeof vis);
		dfs(edge[i].ff,edge[i].ss);
		for(int j=0;j<m;j++){
			if(vis[rest[j].ff]!=vis[rest[j].ss]) effect[i].pb(j);
		}
	}
	memset(dp,-1,sizeof dp);
	ll ans=call(0,0);
	printf("%lld\n",ans);
	return 0;
}



Measured memory_bytes: 426240
N = int(input())
a = [int(input()) for x in range(N)]

count = 1
flag = False
place = 1
for i in range(N):
    place = a[place-1]
    if place == 2:
        flag = True
        print(count)
        break
    else:
        count +=1
if flag == False:
    print(-1)

Measured memory_bytes: 7084
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define EPS 0.0000000001
#define INF 1000000000
#define MOD 1000000007
typedef long long ll;

int main()
{
    string s;
    cin>>s;
    int n=s.size();
    int count=n;
    int cnt=0;
    for(int i=0;i<n;i++){
        if(s[i]=='S'){
            cnt++;
        }
        else if(s[i]=='T'){
            if(cnt>0){
                cnt--;
                count-=2;
            }


        }

    }
    cout<<count<<endl;
}


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

class Program {
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        var RestaurantList = new List<Restaurant>();

        for (int i = 0; i < n; i++) {
            string[] input = Console.ReadLine().Split(' ');
            RestaurantList.Add(new Restaurant() { name = input[0], score = int.Parse(input[1]), index = i +1 });
        }

        var resultList = RestaurantList.OrderByDescending(u => u.score)
            .OrderBy(u => u.name).ToList();

        foreach (var result in resultList) {
            Console.WriteLine(result.index);
        }
    }
}

class Restaurant {
    public string name;
    public int score;
    public int index;
}


Measured memory_bytes: 13660
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String line;

        while(!((line = sc.nextLine()).equals("-"))) {
          char[] c = line.toCharArray();

          line = sc.nextLine();
          int m = Integer.parseInt(line);

          for(int ii = 0; ii < m; ii++) {
              line = sc.nextLine();

              int h = Integer.parseInt(line);
              char z = 0;

              for(int I = 0; I < h; I++) {
                z = c[0];
                for(int i = 0; i < c.length - 1; i++) {
                  c[i] = c[i + 1];
                }
                c[c.length - 1] = z;
              }

          }

          System.out.println(String.valueOf(c));

        }
    }
}

Measured memory_bytes: 26452
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int n;
	static int[] point;
	public static void main(String[] args) {
		while(read()){
			solve();
		}
	}
	
	static boolean read(){
		n = sc.nextInt();
		if(n == 0)return false;
		point = new int[n];
		for(int i = 0; i < point.length; i++){
			point[i] = sc.nextInt();
		}
		return true;
	}
	
	static void solve(){
		Arrays.sort(point);
		int score = 0;
		for(int i = 1; i < point.length - 1; i++){
			score += point[i];
		}
		System.out.println(score/(n-2));
	}

}

Measured memory_bytes: 0
n, x, y = list(map(int, input().split(' ')))
k = n - 1
result = [0] * k

for i in range(n):
    for j in range(i + 1, n):
        if j <= x - 1or x >= y - 1:
            result[j - i - 1] += 1
        else:
            r1 = j - i
            r2 = abs(i - (x - 1)) + 1 + abs((y - 1) - j)

            v = min([r1, r2])
            result[v - 1] += 1
        
for i in result:
    print(i)



Measured memory_bytes: 46428
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int memo[100001];

int loopDP(int _num) {
	if (_num == 0) return 0;
	if (memo[_num] != -1) return memo[_num];

	int res = _num;

	// 全ての手法の中から最もいいやつを選んでくる
	for (int i = 1; i <= _num; i *= 6) {
		res = min(loopDP(_num - i) + 1, res);
	}
	for (int i = 1; i <= _num; i *= 9) {
		res = min(loopDP(_num - i) + 1, res);
	}
	return memo[_num] = res;
}

int main() {
	int N;
	cin >> N;
	REP(i, 100001) {
		memo[i] = -1;
	}
	cout << loopDP(N);
	system("pause");
}

Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
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;}
using Int = long long;
const char newl = '\n';

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

  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int ans=0;
  ans+=min(a,k);k-=min(a,k);
  k-=min(b,k);
  ans-=k;
  cout<<ans<<newl;
  return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define Rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef int64_t intl;


int main(){
 int N;
  cin  >> N;
  vector <string> S(N);
  Rep(i,N){
    cin >> S.at(i);
  }
  sort ( S.begin() , S. end() );
  int get =1;
  if (N == 1) {cout << get; return 0;}
  Rep(i,N-1){
    if ( S.at(i) != S.at(i+1) ) {
      get ++;
    }
  }
  cout << get;
}


Measured memory_bytes: 9600
def examA():
    N = I()
    A = LI()
    ans = "YES"
    cur = 0
    for a in A:
        if a%2==1:
            cur +=1
    if cur%2==1:
        ans = "NO"
    print(ans)
    return

def examB():
    N = I()
    A = LI()
    ans = "YES"
    sumA = sum(A)
    oneA = (1+N)*N//2
    if sumA%oneA!=0:
        ans = "NO"
    ope = sumA//oneA
    #各Aについて何回始点としたか二分探索
    cur = 0
    for i in range(N):
        now = ope - (A[i]-A[i-1])
        if now%N!=0 or now<0:
#            print(now,i)
            ans = "NO"
            break
        cur += now//N
    if cur!=ope:
        ans = "NO"
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = 10**18

if __name__ == '__main__':
    examB()


Measured memory_bytes: 15524
#include <bits/stdc++.h>
using namespace std;
#define int long long
 
int X, Y, Z, K, A[1005], B[1005], C[1005];
priority_queue<pair<int, int> > pq;
 
main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> X >> Y >> Z >> K;
	for (int i = 1; i <= X; i++) cin >> A[i];
	for (int i = 1; i <= Y; i++) cin >> B[i];
	for (int i = 1; i <= Z; i++) cin >> C[i];
	sort(C + 1, C + 1 + Z);
	for (int i = 1; i <= X; i++)
		for (int j = 1; j <= Y; j++)
			pq.emplace(A[i] + B[j] + C[Z], Z);
	while (K--) {
		auto ii = pq.top();
		pq.pop();
		cout << ii.first << '\n';
		if (ii.second > 1) pq.emplace(ii.first - C[ii.second] + C[ii.second - 1], ii.second - 1);
	}
}


Measured memory_bytes: 18792
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

using namespace std;

int main(int argc, char* argv[]) {

	int H, W, cnt, cnt2, flg, i, j, k;
	string a[100];
	string b[100];
	string c[100];

	cin >> H >> W;

	for (i = 0; i < H; i++) {
		cin >> a[i];
	}

	cnt = 0;
	for (i = 0; i < H; i++) {
		flg = 0;
		for (j = 0; j < W; j++) {
			if (a[i][j] == '#') {
				flg = 1;
				break;
			}
		}
		if (flg) {
			b[cnt] = a[i];
			cnt++;
		}
	}

	cnt2 = 0;
	for (j = 0; j < W; j++) {
		flg = 0;
		for (i = 0; i < cnt; i++) {
			if (b[i][j] == '#') {
				flg = 1;
				break;
			}
		}
		if (flg) {
			for (i = 0; i < cnt; i++) {
				c[i].insert(cnt2,b[i].substr(j,1));
			}
			cnt2++;
		}
		else {

		}
	}

	for (i = 0; i < cnt; i++) {
		cout << c[i] << endl;
	}

	return 0;

}

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

int64_t MOD = 1000000007;
double PI = 3.141592653589793;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> list(N);
    for (int i = 0; i < N; i++)
        cin >> list[i];
    for (int i = K; i < N; i++)
    {
        if (list[i] > list[i - K])
            cout << "Yes";
        else
            cout << "No";
        cout << endl;
    }
}

Measured memory_bytes: 3996
H, W = map(int, input().split())
#左右に'.'を余分に付けて標準入力からリストを作成
grid = [list('.'+input()+'.') for i in range(H)]
#上下にも付けてやる
grid.insert(0, list('.' * (W + 2)))
grid.append(list('.' * (W + 2)))
#答えを入れるリスト
ans = []

for i in range(1, H + 1):
  for j in range(1, W + 1):
    if grid[i][j] == '#':
      ans.append('#')
    else:
      #8方向にある'#'の数をカウント
      #付け足したのは'.'なので条件分岐は不要
      #str型で出力しなければjoinできない
      ans.append(str((grid[i-1][j-1:j+2]+grid[i][j-1:j+2]+grid[i+1][j-1:j+2]).count('#')))
  #一行終わったので改行を入れる
  ans.append('\n')
print(''.join(ans))
      

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

int main(){
    int n,ma=0,mi=10000000001; cin>>n;
    vector<int>d(n);
    for(int i=0;i<n;i++){
        cin>>d.at(i);
        ma=max(d.at(i),ma);
        mi=min(d.at(i),mi);
        }
    sort(d.begin(),d.end());
    cout<<ma-mi<<endl;
    }


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    v = [[] for i in range(n)]
    for i in range(n-1):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v[b].append(a)
    q = deque([0])
    d = [0]*n
    d[0] = 1
    pre = [None]*n
    while q:
        x = q.popleft()
        nd = d[x]+1
        for y in v[x]:
            if not d[y]:
                d[y] = nd
                pre[y] = x
                q.append(y)
    V = list(range(1,n))
    V.sort(key = lambda x:-d[x])
    size = [1]*n
    for i in V:
        size[pre[i]] += size[i]
    inv = pow(2,mod-2,mod)
    ans = (1-pow(inv,n,mod)-n*inv)%mod
    p = [pow(inv,i,mod) for i in range(n)]
    for i in range(1,n):
        a = size[i]
        b = n-a
        ans += (p[a]-1)*(p[b]-1)%mod
        ans %= mod
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(2e5) + 17;

int n;
int p[MAXN], ans[MAXN];

bool read() {
    if (!(cin >> n))
        return false;

    forn (i, n)
        cin >> p[i + 1];

    return true;
}

void solve() {
    forn (i, n)
        forn (j, n)
            if (i != j && p[i + 1] == p[j + 1]) {
                cout << "No\n";
                return ;
            }

    vector< pair<int, int> > vec;

    forn (i, n)
        vec.pb(mp(p[i + 1], i + 1));

    sort(vec.begin(), vec.end());
    set<int> f, vac;

    forn (i, n * n)
        f.insert(i + 1);

    for (auto x : vec) {
        f.erase(x.f);
        ans[x.f] = x.s;
    }

    for (auto x : vec) {
        int cnt = x.s - 1;

        for (; cnt > 0 && !f.empty() && *f.begin() < x.f; --cnt, f.erase(f.begin()))
            ans[*f.begin()] = x.s;

        for (; cnt > 0 && !vac.empty() && *vac.begin() < x.f; --cnt) {
            ans[*f.begin()] = ans[*vac.begin()];
            ans[*vac.begin()] = x.s;
            vac.erase(vac.begin());
            vac.insert(*f.begin());
            f.erase(f.begin());
        }

        if (cnt > 0) {
            cout << "No\n";
            return ;
        }

        cnt = n - x.s;

        for (; cnt > 0 && f.upper_bound(x.f) != f.end(); --cnt) {
            auto it = f.upper_bound(x.f);
            vac.insert(*it);
            ans[*it] = x.s;
            f.erase(it);
        }

        if (cnt > 0) {
            cout << "No\n";
            return ;
        }
    }

    cout << "Yes\n";

    forn (i, n * n)
        cout << ans[i + 1] << ' ';

    cout << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
#endif
    
    while (read())
        solve();
    
    return 0;
}



Measured memory_bytes: 13952
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define For(i,a,b) for(int i=a;i<b;i++)
#define rFor(i,a,b) for(int i=a;i>b;i--)
#define sort(a,b) sort(a.begin(),b.end())
#define reverse(a,b) reverse(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//vector<vector<int>> data(a,vector<b>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j)  a×b行列の入力
//floor(log10(a)+1) aの10進法での桁数
//ceil(log10(a)) aの10進法での桁数

int main() {
  ll a,b;
  ci(a>>b);
  string c;
  ci(c);
  string an="Yes";
  For(i,0,a)
    if(c[i]=='-')
      an="No";
  For(i,a+1,a+b+1)
    if(c[i]=='-')
      an="No";
  if(c[a]!='-')
    an="No";
  co(an);
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int w[10],k[10];
	int ws,ks;
	int i,j,temp;
	ws=0;
	ks=0;
	
	for(i=0;i<10;i++){
		scanf("%d",&w[i]);
	}
	for(i=0;i<9;i++){
		for(j=i+1;j<10;j++){
			if(w[i]<w[j]){
				temp=w[i];
				w[i]=w[j];
				w[j]=temp;
			}
		}
	}
	ws=w[0]+w[1]+w[2];
	
	for(i=0;i<10;i++){
		scanf("%d",&k[i]);
	}
	for(i=0;i<9;i++){
		for(j=i+1;j<10;j++){
			if(k[i]<k[j]){
				temp=k[i];
				k[i]=k[j];
				k[j]=temp;
			}
		}
	}
	ks=k[0]+k[1]+k[2];
	
	printf("%d %d\n",ws,ks);
	return 0;
}

Measured memory_bytes: 1024
"use strict";
    
const main = arg => {
    arg     = arg.split("\n")[0].split(" ").map(n=>parseInt(n));
    const A = arg[0];
    const B = arg[1];
    const K = arg[2];
    
    let N = [];
    
    for(let i=0; i<K; i++) {
        if((A+i) > B) break;
        N.push(A+i);
    }
    
    for(let i=0; i<K; i++) {
        if((B-i) < A) break;
        N.push(B-i);
    }
    
    let set = new Set(N);
    
    console.log([...set].sort((a,b)=>a-b).join("\n"));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
#include <stdio.h>

int main(){
    
    int a,b;
    scanf("%d %d", &a, &b);
    if(a < b){
        printf("a < b\n");
    }else if(a > b){
        printf("a > b\n");
    }else if(a == b){
        printf("a == b\n");
    }
    
    
    return 0;
}


Measured memory_bytes: 2704