akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 100010
#define ll long long
using namespace std;

struct aa{int x, y, id;}a[N], a1[N], a2[N];
struct data{int l, r;}b[N][4];
int n, X, Y, x, y, D, f1[N], f2[N], flag[N], op, cl, d[N], p, L, R, pos1[N], pos2[N];
ll ans;

inline int abs(int x){return max(x, -x);}

inline bool cmp1(aa a, aa b){
	if(a.x!=b.x)return a.x<b.x;
	return a.y<b.y;
}
inline bool cmp2(aa a, aa b){
	if(a.y!=b.y)return a.y<b.y;
	return a.x<b.x;
}

inline int gether1(int x){return f1[x]?f1[x]=gether1(f1[x]):x;}
inline int gether2(int x){return f2[x]?f2[x]=gether2(f2[x]):x;}
inline void ins(int i){flag[i]=1; f1[pos1[i]]=pos1[i]+1; f2[pos2[i]]=pos2[i]+1; d[++cl]=i;}

int main(){
	scanf("%d%d%d", &n, &X, &Y);
	for(int i=1; i<=n; i++){scanf("%d%d", &x, &y); a[i].x=x+y; a[i].y=x-y; a[i].id=i;}
	D=max(abs(a[X].x-a[Y].x), abs(a[X].y-a[Y].y));
	memcpy(a1, a, sizeof(a1)); memcpy(a2, a, sizeof(a2));
	sort(a1+1, a1+1+n, cmp1); sort(a2+1, a2+1+n, cmp2);
	for(int i=1; i<=n; i++)pos1[a1[i].id]=i;
	for(int i=1; i<=n; i++)pos2[a2[i].id]=i;
	op=1; cl=0;
	for(int i=1; i<=n; i++){
		x=a1[i].id; p=a[x].x-D; L=a[x].y-D; R=a[x].y+D;
		while(op<=n&&(a1[op].x<p||(a1[op].x==p&&a1[op].y<L)))op++;
		while(cl<n&&(a1[cl+1].x<p||(a1[cl+1].x==p&&a1[cl+1].y<=R)))cl++;
		b[x][0].l=op; b[x][0].r=cl;
	}
	op=n; cl=n+1;
	for(int i=n; i; i--){
		x=a1[i].id; p=a[x].x+D; L=a[x].y-D; R=a[x].y+D;
		while(op&&(a1[op].x>p||(a1[op].x==p&&a1[op].y>R)))op--;
		while(cl>1&&(a1[cl-1].x>p||(a1[cl-1].x==p&&a1[cl-1].y>=L)))cl--;
		b[x][1].l=cl; b[x][1].r=op;
	}
	op=1; cl=0;
	for(int i=1; i<=n; i++){
		x=a2[i].id; p=a[x].y-D; L=a[x].x-D+1; R=a[x].x+D-1;
		while(op<=n&&(a2[op].y<p||(a2[op].y==p&&a2[op].x<L)))op++;
		while(cl<n&&(a2[cl+1].y<p||(a2[cl+1].y==p&&a2[cl+1].x<=R)))cl++;
		b[x][2].l=op; b[x][2].r=cl;
	}
	op=n; cl=n+1;
	for(int i=n; i; i--){
		x=a2[i].id; p=a[x].y+D; L=a[x].x-D+1; R=a[x].x+D-1;
		while(op&&(a2[op].y>p||(a2[op].y==p&&a2[op].x>R)))op--;
		while(cl>1&&(a2[cl-1].y>p||(a2[cl-1].y==p&&a2[cl-1].x>=L)))cl--;
		b[x][3].l=cl; b[x][3].r=op;
	}
	memset(f1, 0, sizeof(f1)); memset(f2, 0, sizeof(f2)); memset(flag, 0, sizeof(flag));
	ins(X); ins(Y);
	op=0; cl=2; d[1]=X; d[2]=Y;
	while(op<cl){
		op++; x=d[op];
		for(int i=gether1(b[x][0].l); i<=b[x][0].r; i=gether1(i+1))ins(a1[i].id);
		for(int i=gether1(b[x][1].l); i<=b[x][1].r; i=gether1(i+1))ins(a1[i].id);
		for(int i=gether2(b[x][2].l); i<=b[x][2].r; i=gether2(i+1))ins(a2[i].id);
		for(int i=gether2(b[x][3].l); i<=b[x][3].r; i=gether2(i+1))ins(a2[i].id);
	}
	ans=0;
	for(int i=1; i<=n; i++)if(flag[i])
		for(int j=0; j<=3; j++)ans+=b[i][j].r-b[i][j].l+1;
	ans>>=1; printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    cin >> n;
    ll ans = inf;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) chmin(ans, i + n / i - 2);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

int main(){
int a,b,c,d;cin>>a>>b>>c>>d;
int x=c-a,y=d-b;
for(int i=0;i<y;i++)cout<<"U";
for(int i=0;i<x;i++)cout<<"R";
for(int i=0;i<y;i++)cout<<"D";
for(int i=0;i<x;i++)cout<<"L";
cout<<"L";
for(int i=0;i<=y;i++)cout<<"U";
for(int i=0;i<=x;i++)cout<<"R";
cout<<"D"<<"R";
for(int i=0;i<=y;i++)cout<<"D";
for(int i=0;i<=x;i++)cout<<"L";
cout<<"U";


}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,S;
    cin >>a>>b>>c>>d;
    S=a+b+c+d;
    int e,f,g,h,T;
    cin >>e>>f>>g>>h;
    T=e+f+g+h;
    if(S>=T){
        cout <<S;
    }
    else{
        cout <<T;
    }
    cout <<endl;
}


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

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

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

    int k, n;
    cin >> k >> n;

    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<int> d(n, 0);
    d[0] = k - a[n - 1] + a[0];

    for (int i = 1; i < n; i++){
        d[i] = a[i] - a[i - 1];
    }

    int dm = 0;
    int idx = 0;
    rep(i, n) {
        if(dm<d[i]){
            dm = d[i];
            idx = i;
        }
    }

    long long ans = 0;
    for (int i = 0; i < n; i++) {
        if(i!=idx){
            ans += d[i];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
package main

import (
	"fmt"
)

func main() {
	var N int
	var S1, S2 string
	fmt.Scan(&N, &S1, &S2)

	var i, ans int
	if S1[0] == S2[0] {
		i = 1
		ans = 3
	} else {
		i = 2
		ans = 6
	}
	for ; i < N; i++ {
		if S1[i] == S2[i] {
			if S1[i-1] == S2[i-1] {
				ans = ModMul(ans, 2)
			}
			continue
		}

		if S1[i-1] == S2[i-1] {
			ans = ModMul(ans, 2)
			continue
		}
		if S1[i-1] == S1[i] {
			continue
		}
		ans = ModMul(ans, 3)
	}
	fmt.Println(ans)
}

const Mod = 1000000007

func ModMul(a, b int) int { return (Mod + a%Mod) * (Mod + b%Mod) % Mod }


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

int main() {
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  a[n-1] /=2;
  int ans=0;
  for(int i=0;i<n;i++) ans+=a[i];
  cout<<ans<<endl;
  }


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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define umax(m, x) (m = max(m, x));
#define umin(m, x) (m = min(m, x));

#define rng(v) v.begin(), v.end()
#define rrng(v) v.rbegin(), v.rend()

#define debug(x) cerr << #x << " = " << x << endl

using namespace std;

using ll = long long int;

using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;

using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;

inline void yn(bool f) { cout << (f ? "Yes" : "No") << endl; }

int main() {
    int n, m;
    cin >> n >> m;

    vi k(m);
    vvi s(m);
    vi p(m);

    rep(i, m) {
        cin >> k[i];

        rep(j, k[i]) {
            int t;
            cin >> t;
            s[i].push_back(t);
        }
    }

    rep(i, m)
        cin >> p[i];

    int cnt = 0;

    rep(sw, pow(2, n)) {
        bool f = true;

        rep(i, m) {
            int sum = 0;
            rep(j, k[i])
                sum += (sw >> (s[i][j] - 1)) & 1;

            if (sum % 2 != p[i]) {
                f = false;
                break;
            }
        }

        if (f) cnt++;
    }

    cout << cnt << endl;

    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int pre = -999;
    rep(i, n)
    {
        if (pre <= a[i] - 1)
        {
            pre = a[i] - 1;
        }
        else if (pre <= a[i])
        {
            pre = a[i];
        }
        else
        {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl

#define INF 1000000001
#define MOD 1000000007
#define INF64 1000000000000000001

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000
long long L,R;
long long bufl,bufr;
long long ans,newans;
int bans;

long long solve(void) {
  ans = 2019;
  if (R-L >= 2019) {
    return 0;
  }
  L %= 2019;
  R %= 2019;

  if ( L >= R ) {
    return 0;
  }

  for(bufl = L;bufl<=R-1;bufl++) {
    for(bufr = bufl+1;bufr<=R;bufr++) {
      newans = bufl * bufr;
      newans %= 2019;
      if(ans > newans) ans = newans;

      // ans = min(ans,newans);
    }
  }



  return ans;
}

int main (void)
{
  cin >> L >> R;
  bans = solve();
  put(bans);

  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
s = a[0]
for i in range(1,n):
    s = s^a[i]
#print(s)
for i in range(n):
    if i != n-1:
        print(s^a[i],end = " ")
    else:
        print(s^a[i])


Measured memory_bytes: 94444
#include<stdio.h>
int main(){
	char s[10];
  	int i,n=0,x=0;
	scanf("%s",s);
  	for(i=0;i<10;i++){
    	if(s[i]=='\0') break;
      	else{
        	if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
            	n++;
            	if(n>x) x=n;
            }
        	else n=0;
        }
    }
  	printf("%d",x);
	return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=(n)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define maxs(a,b) a=max(a,b);
#define mins(a,b) a=min(a,b);
#define max3(a,b,c) max(a,max(b,c)) 
#define mix3(a,b,c) mix(a,mix(b,c))

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){
   
    int n;cin>>n;
    vi l(n);rep(i,n)cin>>l[i];

    sort(all(l));

    int ans=0;

    for(auto i=l.begin();i!=l.end();i++){
        for(auto j=i+1;j!=l.end();j++){
            auto it1 = upper_bound(j+1,l.end(),*j-*i);
            auto it2 = lower_bound(j+1,l.end(),*j+*i);
            ans+=it2-it1;
        }
    }

    cout<<ans<<endl;

    return 0;
}

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

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;

#define pb push_back

const int MOD = 1e9 + 7;
const int L = 700;
const int S = 3000;

int dp[L][S];	

void add(int& x, int y) {
	x += y;
	if (x > MOD) x -= MOD;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
   int s;
   cin >> s;
   for (int i = 3; i <= s; i++)
   	dp[1][i] = 1;
  	int k = s / 3;
   for (int i = 2; i <= k; i++)
   	for (int j = 3 * i; j <= s; j++)
   		for (int d = 3; d <= j; d++)
   			add(dp[i][j], dp[i - 1][j - d]);
   int ans = 0;
 	for (int i = 1; i <= k; i++) 
 		add(ans, dp[i][s]);
 	cout << ans;
   return 0;
}

Measured memory_bytes: 8804
#include<iostream>
#include<fstream>
#include<string>
#include<algorithm>
using namespace std;
long long x,a,b,s,c;
int main()
{
    
    cin>>x>>a>>b;
    s=x-a,c=s/b;
    if(s%b==0)
    cout<<"0"<<endl;
    else cout<<x-a-b*c<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 2e18;
signed main(){
  ll n,k;
  cin>>n>>k;
  ll A[n];
  for(ll i=0;i<n;i++)cin>>A[i];
  vector<ll>dp(n,inf);
  dp[0] = 0;
  for(ll i=0;i<n;i++){
     for(ll j=i+1;j<=i+k;j++){
        dp[j] = min(dp[j],dp[i]+abs(A[i]-A[j]));
     }
  }
  cout << dp[n-1] << '\n';
return 0;
}


Measured memory_bytes: 1792
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
struct ConvexHullTrick {
    vector<lpair> deq;
    ll s,t;
    ConvexHullTrick(ll n){
        deq.resize(n);
        s = 0, t = 0;
    }
    void add(ll a, ll b) {
        const lpair p(a,b);
        while(s+1 < t && check(deq[t-2],deq[t-1],p)) t--;
        deq[t++] = p;
    }
    ll incl_query(ll x) {
        while(s+1 < t && f(deq[s], x) >= f(deq[s+1], x)) s++;
        return f(deq[s], x);
    }
    ll query(ll x) {
        ll low = s-1, high = t-1;
        while(high - low > 1) {
            ll mid = (low+high) / 2;
            if (isright(deq[mid], deq[mid+1], x)) low = mid;
            else high = mid;
        }
        return f(deq[high], x);
    }
private:
    bool isright(const lpair &p1, const lpair &p2, ll x) {
        return (p1.second - p2.second) >= x * (p2.first - p1.first);
    }
    bool check(const lpair &p1, const lpair &p2, const lpair &p3) {
        return (p2.first - p1.first) * (p3.second - p2.second) >=
            (p2.second - p1.second) * (p3.first - p2.first);
        }
    ll f(const lpair &p, ll x) {
        return p.first * x + p.second;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,C;
    cin >> N >> C;
    ll h[200010];
    rep(i,0,N) cin >> h[i];
    ll dp[200010] = {};
    dp[0] = 0;
    ConvexHullTrick cht(200010);
    cht.add(-2 * h[0], dp[0] + h[0] * h[0]);
    rep(i,1,N){
        dp[i] = cht.query(h[i]) + h[i] * h[i] + C;
        cht.add(-2 * h[i], dp[i] + h[i] * h[i]);
    }
    print(dp[N-1]);
    


    

}

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

//Function Macros:
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main()
{
    int N;
    cin >> N;
    cout << N * N * N << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

void solve(){
  string s;
  cin >> s;
  cout << s.substr(0,3) + "8" + s.substr(4) << endl;
}

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

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((int)(x).size())
#define MSG(a) cout << #a << " " << a << endl;

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n + 1);
    vector<ll> b(n);
    ll ans = 0;
    for (int i = 0; i < n + 1; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }

    for (int i = 0; i < n; i++) {
        // まず自分の担当の街を助ける
        ll dmg = min(a[i], b[i]);
        ans += dmg;
        a[i] -= dmg;
        b[i] -= dmg;

        // 次の街を助けに行く
        dmg = min(a[i + 1], b[i]);
        ans += dmg;
        a[i + 1] -= dmg;
        b[i] -= dmg;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int H, W, K; cin >> H >> W >> K;
    vector<vector<int>> S(H, vector<int>(W));
    rep(i, H) {
        rep(j, W) {
            char tmp; cin >> tmp;
            S[i][j] = tmp - '0';
        }
    }
    vector<vector<int>> sumS(H+1, vector<int>(W));
    rep(i, H) {
        rep(j, W) {
            sumS[i+1][j] = sumS[i][j] + S[i][j];
        }
    }
    int ans = 100000;
    int cnt;
    rep(i, 1<<H) {
        vector<vector<int>> cut = {{0}};
        rep2(j, 1, H) {
            if ((i&(1<<j)) && (i&(1<<(j-1)))) cut[cut.size()-1].push_back(j);
            else if (!(i&(1<<j)) && !(i&(1<<(j-1)))) cut[cut.size()-1].push_back(j);
            else {
                vector<int> tmp = {j};
                cut.push_back(tmp);
            }
        }
        cnt = cut.size()-1;
        vector<int> tmpSize(cut.size());
        bool flag = false;
        rep(j, W) {
            rep(k, cut.size()) {
                int d = cut[k][0], u = cut[k][cut[k].size()-1]+1;
                int tmp = sumS[u][j] - sumS[d][j];
                if (tmp > K) {
                    flag = true;
                    break;
                }
                tmpSize[k] += tmp;
            }
            if (flag) break;
            if (vmax(tmpSize) <= K) continue;
            rep(k, cut.size()) {
                int d = cut[k][0], u = cut[k][cut[k].size()-1]+1;
                int tmp = sumS[u][j] - sumS[d][j];
                tmpSize[k] = tmp;
            }
            cnt++;
        }
        if (flag) continue;
        chmin(ans, cnt);
    }
    cout << ans << endl;
}


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

int main()
{
  int N;
  cin >> N;
  vector<int> B(N), res(0);
  for (int i = 0; i < N; i++)
  {
    cin >> B.at(i);
  }
  for (int i = 0; i < N; i++)
  {
    for (int j = B.size() - 1; j >= 0; j--)
    {
      if (j == 0 && B.at(0) != 1)
      {
        cout << -1 << endl;
        return 0;
      }
      if (B.at(j) == j + 1)
      {
        res.push_back(B.at(j));
        B.erase(B.begin() + j);
        break;
      }
    }
  }
  reverse(res.begin(), res.end());
  for (int b : res)
  {
    cout << b << endl;
  }
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	a, b, _ := scanInt(), scanInt(), scanInt()
	fmt.Fprintln(wr, a*b/2)
}


Measured memory_bytes: 1780
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
 
 
 
 
 
 
 







int dp[2005][2005];
int f[2005];
int main()
{
    for(int i=0;i<=2000;i++)dp[0][i]=0;
    for(int i=0;i<=2000;i++)dp[i][0]=1;
    for(int i=1;i<=2000;i++){
         for(int j=1;j<=i;j++){
              dp[i][j]=(1LL*dp[i-1][j]+dp[i-1][j-1])%mod;
         }
    }
    f[0]=1,f[1]=1;
    for(int i=2;i<=2000;i++){
         f[i]=(1LL*f[i-1]*i)%mod;
    }
    
    int n,k;
    cin>>n>>k;
    int r=n-k+1;
    for(int i=1;i<=r&&i<=k;i++){
        ll res=(1LL*dp[r][i]*dp[k-1][i-1])%mod;
         cout<<res<<"\n";
    }
    if(r<k){
         while(r!=k){cout<<0<<"\n";r++;}
    }
}


























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

int main()
{
    int n;
    int ans = 0;
    std::cin >> n;
    std::unique_ptr<int[]> a{new int[n]};
    for (int i = 0; i < n; ++i) {
        std::cin >> a[i];
    }
    std::unique_ptr<int[]> b{new int[n]};
    for (int i = 0; i < n; ++i) {
        std::cin >> b[i];
    }
    for (int i = 0; i < n; ++i) {
        int temp = 0;
        for (int j = 0; j <= i; ++j) {
            temp += a[j];
        }
        for (int k = i; k < n; ++k) {
            temp += b[k];
        }
        ans = std::max(temp, ans);
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 3608
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut ss = vec![];
    for i in 0..n {
        let s = read::<String>();
        ss.push(s);
    }

    let mut pt_indexes = vec![];
    let mut nt_indexes = vec![];
    for (i, ref s) in ss.iter().enumerate() {
        let mut cur = 0i64;
        for ch in s.chars() {
            if ch == '(' {
                cur += 1;
            } else {
                cur -= 1;
            }
        }
        if cur >= 0 {
            pt_indexes.push(i)
        } else {
            nt_indexes.push(i);
        }
    }

    let mut pairs = vec![];
    for i in pt_indexes {
        let s = &ss[i];
        let mut cur = 0i64;
        let mut worst = 0i64;
        for ch in s.chars() {
            if ch == '(' {
                cur += 1;
            } else {
                cur -= 1;
            }
            worst = min(worst, cur);
        }
        pairs.push((worst, cur));
    }
    pairs.sort_by_key(|x| -x.0);

    let mut cur_level1 = 0;
    for (worst, total) in pairs {
        if cur_level1 < -worst {
            println!("No");
            return;
        }
        cur_level1 += total;
    }

    let mut pairs = vec![];
    for i in nt_indexes {
        let s = &ss[i];
        let mut cur = 0i64;
        let mut worst = 0i64;
        for ch in s.chars().rev() {
            if ch == ')' {
                cur += 1;
            } else {
                cur -= 1;
            }
            worst = min(worst, cur);
        }
        pairs.push((worst, cur));
    }
    pairs.sort_by_key(|x| -x.0);

    let mut cur_level2 = 0;
    for (worst, total) in pairs {
        if cur_level2 < -worst {
            println!("No");
            return;
        }
        cur_level2 += total;
    }

    if cur_level1 == cur_level2 {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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


int main()
{
    int a,b,c;cin>>a>>b>>c;
    bool can = false;
    for(int i = 1; i <= b; i++){
        if(a*i%b == c) {
            can = true;
            break;
        }
    }
    cout << (can?"YES":"NO") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#else
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
 public:
  int h[333];
  i64 dp[333][333];
  void chmin(i64 &a, i64 b) {
    if (a == -1)
      a = b;
    else
      a = min(a, b);
  }
  void solve() {
    int n, m;
    cin >> n >> m;
    m = n - m;
    for (int i = 1; i <= n; ++i) cin >> h[i];
    i64 ans = -1;
    for (int i = 1; i <= n; ++i) {
      dp[i][1] = h[i];
      for (int j = 2; j <= i; ++j) {
        dp[i][j] = -1;
        for (int k = j - 1; k < i; ++k) {
          chmin(dp[i][j], dp[k][j - 1] + max(h[i] - h[k], 0));
        }
      }
      if (i >= m)
        chmin(ans, dp[i][m]);
    }

    cout << ans << '\n';
  }
} NSPACE;
int main() {
  FPEN;
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  NSPACE.solve();
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;


public class Main{
	static int n;
	static int [][] f;
	static int [][] p;
	static int []a;
	static int ans;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		f = new int[n][10];
		for(int i = 0;i < n;i++){
			for(int j = 0;j < 10;j++){
				f[i][j] = sc.nextInt();			//店の状態
			}
		}
		p = new int[n][11];
		for(int i = 0;i < n; i++){
			for(int j = 0; j< 11; j++){
				p[i][j] = sc.nextInt();			//利益の入力
			}
		}
		sc.close();
		a = new int [10];			//姉さんの店の状態を入れる配列
		ans = Integer.MIN_VALUE;		//intの最小値
		dfs(0);
		System.out.println(ans);
	}
	static void dfs(int index){
		if(index == 10){
			if(Arrays.toString(a).equals("[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]"))return;
			memo();
			return;

		}else{
			a[index] = 0;
			dfs(index + 1);
			a[index] = 1;
			dfs(index + 1);

		}
	}

	static void memo(){
		int partAns = 0;
		for(int i = 0;i < n;i++){
			int count = 0;
			for(int j = 0; j < 10;j++){
				if(a[j] == 1 && f[i][j] == 1){			//姉さんの店と店iが空いてたらカウントプラス１
					count++;
				}
			}
			partAns += p[i][count];
		}
		ans = Math.max(partAns, ans);
	}
}


Measured memory_bytes: 25820
from collections import deque
from itertools import product
import numpy as np

H, W = map(int, input().split())
S = np.zeros((H, W), dtype='U1')
for hi in range(H):
    raw = input()
    S[hi, :] = list(raw)

maxmove = np.zeros_like(S, dtype='int')

for hi, wi in product(range(H), range(W)):
    # hi, wiをスタート位置とする場合
    if S[hi, wi] == '#': continue

    # 必要な諸々を定義
    VisitOrScheduled = np.zeros_like(S, dtype='bool')
    VisitOrScheduled[hi, wi] = True
    nummove = np.zeros_like(S, dtype='int')
    deq = deque()

    deq.append((hi, wi))
    while True:
        try:
            hj, wj = deq.popleft()
        except IndexError:
            break
        VisitOrScheduled[hj, wj] = True
        for neighbour in [(hj, wj-1), (hj, wj+1), (hj+1, wj), (hj-1, wj)]:
            if not (0 <= neighbour[0] < H and 0 <= neighbour[1] < W): continue
            if S[neighbour] == '#':
                continue
            if not VisitOrScheduled[neighbour]:
                nummove[neighbour] = nummove[hj, wj] + 1
                deq.append(neighbour)
                VisitOrScheduled[neighbour] = True
    
    maxmove[hi, wi] = np.max(nummove)

print(np.max(maxmove))


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string w; cin>>w;
	map<char,int> ct;
	for (auto ch : w)
		ct[ch]++;
	for (auto it : ct)
		if(it.second%2) {
			cout << "No" << endl;
			return 0;
		}
	cout << "Yes" << endl;
	return 0;
}


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

using namespace std;
const int INF = 1000 * 1000 * 1000;
int main()
{

int h,n;
cin >> h >> n;
vector <pair<int,int>> ax(n);
for (int i=0; i<n; i++) cin >> ax[i].first >> ax[i].second;  // hp + price

vector <int> dp(h+1);
for (int i=1; i<=h; i++)
    {
        int minV = INF;
        for (int j=0; j<n; j++)
            {
                if (i>=ax[j].first) minV = min(minV, dp[i-ax[j].first] + ax[j].second);
            }
        dp[i] = minV;

    }

int min_res = INF;
for (int i=0; i<n; i++)
    {
        for(int j=h; j>=max(0,h-ax[i].first); j--)
            min_res = min(min_res, dp[j] + ax[i].second);
    }
cout << min_res;

}


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


int main() {
  long long a,b,n;
  cin >> n >> a >> b;

  long long t = n/(a+b),nn=n%(a+b);
  long long sum = a*t;

  if(nn >=a) sum +=a;
  else sum += nn;

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
/*---------------------------------

 @Author:   Dicer
 @DateTime: 2019-05-28 19:08:14

---------------------------------*/

#include <iostream>
#include <cstdio>
#include <cmath>
#include <string.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
inline ll qpow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res = (res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int MAXN = 2e5 + 7;

int main(int argc, char const *argv[])
{
	int a, b;
	cin >> a >> b;
	cout << (a*3 + b)/2 << endl;	
	return 0;
}

Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())
ans = ""

diff_x = abs(tx-sx)
diff_y = abs(ty-sy)

# 最短距離で行って戻る
ans += "U" * diff_y + "R" * diff_x
ans += "D" * diff_y + "L" * diff_x

# 一歩左に進んでから、ty+1の位置まで上に進む。
ans += "L" * 1 + "U" * (diff_y+1)
# txの位置まで右に進んでから、一歩下に進む。
ans += "R" * (diff_x+1) + "D" * 1

# 一歩右に進んでから、sy-1の位置まで下に進む。
ans += "R" * 1 + "D" * (diff_y+1)
# sxの位置まで左に進んでから、一歩上に進む。
ans += "L" * (diff_x+1) + "U" * 1

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int D;
  cin >> D;
  if (D == 25)
    cout << "Christmas";
  else if (D == 24)
    cout << "Christmas Eve";
  else if (D == 23)
    cout << "Christmas Eve Eve";
  else if (D == 22)
    cout << "Christmas Eve Eve Eve";
  
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    
    int A[N];
    int ans = 0;
    for(int i = 0;i < N;i++){
        cin >> A[i];
            while(A[i]%2 == 0){
                ans++;
                A[i] /= 2;
            }
        }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<long long>;
using pll = pair<long long, long long>;
template<class T> using pr = pair<T, T>;
template<class T> using vec = vector<T>;

#define debug(x) (std::cerr << (x) << "\n")
#define debug_tab(n, x) (std::cerr << strMulti("\t",n) << (x) << "\n")
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define str(n)	(n.toString())

#define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(ll i=(n)-1; i >= 0; --i)
#define rrep1(i, n) for(ll i=(n); i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b)
constexpr int INF = 2000000100;
constexpr ll MOD = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = math_P(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T mod_pow(T x, T n, const T& p) { T ret = 1; while (n > 0) { if (n & 1) { (ret *= x) %= p; } (x *= x) %= p; n >>= 1; } return ret; }

/*****/

void Main()
{
	string S;
	cin >> S;
	sort(all(S));
	if (S[0] != S[1] || S[1] != S[2])
		cout << "Yes";
	else
		cout << "No";
}

/*****/

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

	//std::cout << std::fixed << std::setprecision(10);

	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/

	Main();
	cout << endl;

	return 0;
}


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

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n,k;cin>>n>>k;
  int ans = 0;
  rep(i,n){
    int h;cin>>h;
    if (h>=k) ans++;
  }
  cout << ans << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
const int max_n = 100;
const int max_w = 10000;
 
int n, W;
int w[max_n + 1], v[max_n + 1];
int dp[max_n + 1][max_w + 1];

int main(void){
    cin >> n >> W;
    for(int i=0;i<n;i++){
        cin >> v[i] >> w[i];
    }
    for(int i=n-1;i>=0;i--){
    	for(int j=0; j<=W;j++){
    		if(j < w[i]){
    			dp[i][j] = dp[i+1][j];
    		}else{
    			dp[i][j] = max(dp[i+1][j], dp[i+1][j-w[i]]+v[i]);
    		}
    	}
    }
    cout << dp[0][W] << endl;
    return 0;
}

Measured memory_bytes: 7008
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n;
  cin >> n;
  int add_pow, num;
  add_pow = 1;
  if(n < 10){
    num = n;
  }else if(n < 100){
    num = 9;
  }else if(n < 1000){
    num = 9 + n - 99;
  }else if(n < 10000){
    num = 9 + 900;
  }else if(n < 100000){
    num = 9 + 900 + n - 9999;
  }else if(n == 100000){
    num = 9 + 900 + 90000;
  }
  printf("%d", num);
  
  return 0;
}


Measured memory_bytes: 256
li = []
l = []
for i in range(5):
    a = int(input())
    li.append(a)
    if a % 10 != 0:
        l.append(a%10)
    else:
        l.append(10)
ind = l.index(min(l))
ans = 0
for i in range(5):
    if i != ind and i != 10:
        ans += (li[i] + 10 - l[i])
    elif i != ind and i == 10:
        ans += (li[i] - l[i])
print(ans+li[ind])    

Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)

	ans := ""
	for i := 0; i < len(S); i++ {
		for j := i; j < len(S); j++ {
			s := S[i : j+1]
			t := S[j]
			if !(t == 'A' || t == 'C' || t == 'G' || t == 'T') {
				break
			}
			if len(ans) < len(s) {
				ans = s
			}
		}
	}
	fmt.Println(len(ans))
}


Measured memory_bytes: 512
N, X, Y = map(int, input().split())
X, Y = X-1, Y-1
cs = [0]*(N-1)
for i in range(N):
  for j in range(i+1, N):
    d = min(j-i, abs(X-i)+1+abs(j-Y))
    #print(i, j, d)
    cs[d-1] += 1
for d in range(N-1):
  c = cs[d]
  print(c)


Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int crs(int x1, int y1, int x2, int y2) {
    return (0 < x1 * y2 - y1 * x2 ? 1 : -1);
}

int main() {
    int n,xp1,yp1,xp2,yp2,xp3,yp3,xk,yk,xs,ys;
    cin >> n;
    for (int i=0; i<n; ++i) {
        cin>>xp1>>yp1>>xp2>>yp2>>xp3>>yp3>>xk>>yk>>xs>>ys;
        int t1 = 0;
        t1 += crs(xp2 - xp1, yp2 - yp1, xk - xp1, yk - yp1);
        t1 += crs(xp3 - xp2, yp3 - yp2, xk - xp2, yk - yp2);
        t1 += crs(xp1 - xp3, yp1 - yp3, xk - xp3, yk - yp3);
        int t2 = 0;
        t2 += crs(xp2 - xp1, yp2 - yp1, xs - xp1, ys - yp1);
        t2 += crs(xp3 - xp2, yp3 - yp2, xs - xp2, ys - yp2);
        t2 += crs(xp1 - xp3, yp1 - yp3, xs - xp3, ys - yp3);
        if ((abs(t1) == 3 && abs(t2) != 3) ||
            (abs(t1) != 3 && abs(t2) == 3)) {
            cout << "OK" << endl;
        } else {
            cout << "NG" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;


int main()
{
   FAST/**/
   char c;cin>>c;
   cout<<++c;
   
   return 0;        
}  
   

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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#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 ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

string minstr(string a, string b) {
    if (a.length() == 0) return b;
    if (b.length() == 0) return a;
    if (a.length() != b.length()) {
        return a.length() < b.length() ? a : b;
    }
    return min(a, b);
}

int main() {
    int N;
    while (cin >> N, N) {
        vs S;
        vs in(N);
        REP(i, N) cin >> in[i];
        SORT(in);
        in.erase(unique(ALL(in)), in.end());
        N = SZ(in);
        REP(i, N) {
            bool ok = true;
            REP(j, N) {
                if (i == j) continue;
                if (in[j].find(in[i]) != string::npos) {
                    ok = false;
                    break;
                }
            }
            if (ok) S.push_back(in[i]);
        }

        N = SZ(S);
        vector<vs> tail(N, vs(N));
        REP(i, N) REP(j, N) {
            if (i == j) continue;
            RREP(k, S[i].length()) {
                if (k < (int)S[j].length()) {
                    bool ok = true;
                    REP(l, k) {
                        if (S[i][S[i].length()-k+l] != S[j][l]) {
                            ok = false;
                            break;
                        }
                    }
                    if (ok) {
                        tail[i][j] = S[j].substr(k);
                        break;
                    }
                }
            }
        }

        vector<vs> dp(N, vs(1<<N));
        REP(i, N) {
            dp[i][1<<i] = S[i];
        }

        REP(X, 1<<N) {
            REP(i, N) if (BIT(X, i)) {
                REP(j, N) if (!BIT(X, j)) {
                    dp[j][X|(1<<j)] = minstr(dp[j][X|(1<<j)], dp[i][X] + tail[i][j]);
                }
            }
        }
        string mi;
        REP(i, N) {
            mi = minstr(mi, dp[i][(1<<N)-1]);
        }
        cout << mi << endl;
    }
}

Measured memory_bytes: 3472
A,B = input().split()
A = int(A)
B = int(B)

x_mina = (A/0.08)
x_maxa = (A+1)/0.08

if x_mina > (int)(x_mina):
  x_mina = (int)(x_mina)+1
else:
   x_mina = (int)(x_mina)
    
if x_maxa > (int)(x_maxa):
  x_maxa = (int)(x_maxa)
else:
  x_maxa = (int)(x_maxa-1)

x_minb = B/0.1
x_maxb = (B+1)/0.1

ans = -1

for i in range(x_mina,x_maxa+1):
  if i >= x_minb and i<x_maxb:
    ans = i
    break

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
    int i[3000];
    int k[3000];
    int fin;
    for(int c=0;c<=3000;c++){
        scanf("%d %d",&i[c],&k[c]);
        fin=c;
        if(i[c]==0&&k[c]==0){
            break;
        }
    }
    for(int c=0;c<=fin-1;c++){
        if(i[c]<=k[c]){
            printf("%d %d\n",i[c],k[c]);
        }
        else if(i[c]>k[c]){
            printf("%d %d\n",k[c],i[c]);
        }
    }
    return 0;
}



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

using namespace std;
#define ll long long int

int main()
{
   ll t;
   t = 1;	
  // cin >> t;
   while(t--){
      ll n;
      cin >> n;
      ll sum = 0;
      for(int i = 1; i <= n ; i++)
      {
          sum += i * (n - i + 1);
      }
      for(int i = 0; i < n -1 ; i ++)
      {
          int x , y;
          cin >> x >> y;

          sum -= (min(x , y)) * (n - max(y,x) + 1);
      }
      cout << sum << endl;
   }
}


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

using namespace std;

int main(){

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

  for(int j=0; j<m; j++){
    int ans=sum;
    int p, x;
    cin>>p>>x;
    ans=sum-a[p-1]+x;
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 3596
#include <stdio.h>

int main(void)

{

	int W, H, x, y, r;

	scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
	if(0<=(x-r) && 0<=(y-r) && W>=(x+r) && H>=(y+r)){
	
	printf("Yes\n");

	}else{

		printf("No\n");
	}

	return 0;

}

Measured memory_bytes: 584
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  long long int arr[n], max = 1e18, prod = 1, flag = 0, zero = 0;
  
  for (int i = 0; i < n; i++) {
    scanf("%lld", &arr[i]);
    flag = (arr[i] > max) ? 1 : flag;
    prod *= arr[i];
    (arr[i]) ? max /= arr[i] : zero = 1;
  }

  (zero) ? puts("0") : ((flag) ? puts("-1") : printf("%lld\n", prod));
  return 0;
}

Measured memory_bytes: 2460
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
  
  int a, b, c, k;
  
  scanf("%d %d %d %d", &a, &b, &c, &k);
  
  if (k <= a) printf("%d\n", k);
  else if (a < k && k <= a+b) printf("%d\n", a);
  else if (a+b < k) printf("%d\n", 2*a+b-k);
  
  return 0;
}

Measured memory_bytes: 1736
import java.io.*;

class Main {
  public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();
    while(true){
      String data[] = br.readLine().split(" ");
      int a = Integer.parseInt(data[0]);
      int b = Integer.parseInt(data[1]);
      if(a == 0 && b == 0)
    	  break;

      for(int i = 0; i < a; i++){
          for(int j = 0; j < b; j++){
              if(i == 0 || i == a-1 || j == 0 || j == b-1)
                  sb.append("#");
              else
                  sb.append(".");
          }
          sb.append("\n");
      }
      sb.append("\n");
    }
    System.out.print(sb);
  }
}

Measured memory_bytes: 25544
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = 0
    i = 0
    while i < N:
        pos1, pos2 = i, i
        while pos1+1 < N and A[pos1] <= A[pos1+1]:
            pos1 += 1
        while pos2+1 < N and A[pos2] >= A[pos2+1]:
            pos2 += 1
        ans += 1
        i = max(pos1, pos2) + 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62704
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 


int main(){
  int N;
  cin >> N;
  
  vector<int> a(N);
  vector<int> b(N); //並び替え
  
  rep(i, N){
    cin >> a.at(i);
    b.at(i) = a.at(i);
  }
  
  sort(b.begin(), b.end());
  int point_Alice = 0;
  int point_Bob = 0;
  
  rep(i, N){
    if(i%2 == 0){
      point_Alice += b.at(N-1-i);
    }else{
      point_Bob += b.at(N-1-i);
    }
  }
  
  cout << point_Alice - point_Bob;
}

Measured memory_bytes: 256