akhauriyash/Code-Regression huggingface dataset:
#include <string.h>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
using namespace std;
int n;
bool maze[6010][6010];
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int w, h;
int compress(pair <int, int> *a, int p)
{
    vector <int> xs;
    for(int i = 0; i < n; i++)
        for(int j = -1; j <= 1; j++)
        {
            int t = a[i].first + j;
            if(t >= 0 && t <= p)
                xs.push_back(t);
            t = a[i].second + j;
            if(t >= 0 && t <= p)
                xs.push_back(t);
        }
    sort(xs.begin(), xs.end());
    xs.erase( unique(xs.begin(), xs.end()), xs.end() );
    for(int i = 0; i < n; i++)
    {
        a[i].first = find(xs.begin(), xs.end(), a[i].first) - xs.begin();
        a[i].second = find(xs.begin(), xs.end(), a[i].second) - xs.begin();
    }
    return xs.size();
}
void bfs(int i, int j)
{
    queue < pair <int, int> > que;
    que.push(make_pair(i, j));
    while(que.size())
    {
        pair <int, int> now = que.front();
        que.pop();
        for(int i = 0; i < 4; i++)
        {
            int nx = now.first + dx[i];
            int ny = now.second + dy[i];
            if(nx >= 0 && nx < w && ny >= 0 && ny < h && !maze[nx][ny])
            {
                maze[nx][ny] = true;
                que.push(make_pair(nx, ny));
            }
        }
    }
}
int main()
{
    pair <int, int> x[1010];
    pair <int, int> y[1010];
    while(scanf("%d%d", &w, &h), w || h)
    {
        memset(maze, false, sizeof(maze));
        scanf("%d", &n);
        for(int i = 0; i < n; i++)
            scanf("%d%d%d%d", &x[i].first, &y[i].first, &x[i].second, &y[i].second);
        w = compress(x, w) - 1;
        h = compress(y, h) - 1;
        for(int i = 0; i < n; i++)
            for(int j = x[i].first; j < x[i].second; j++)
                for(int k = y[i].first; k < y[i].second; k++)
                    maze[j][k] = true;
        int ans = 0;
        for(int i = 0; i < w; i++)
        {
            for(int j = 0; j < h; j++)
            {
                if(!maze[i][j])
                {
                    ans ++;
                    bfs(i, j);
                }
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 36516
#include <iostream>

using namespace std;

int comput(string a, int i, string b){
  int ans = 0;
  for(int j = 0;j < b.size();j++){
    if(a[i + j] != b[j]){
      ans++;
    }
  }
  return ans;
}

int main() {

  int n, ans = 1000;
  string s, t;
  cin >> s >> t;
  for(int i = 0;i < s.size() - t.size() + 1;i++){
    ans = min(ans, comput(s, i, t));
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3612
N, D = [int(c) for c in input().split()]
X = [[int(c) for c in input().split() ] for _ in range(N)]

n=0
for i in range(N):
    for j in range(i+1, N):
        d2 = 0
        for k in range(D):
            diff = X[i][k]-X[j][k]
            d2 += diff * diff
        if int(d2**0.5)	* int(d2**0.5) == d2:
            n+=1

print(n)

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

int main(){
  int a, b;
  cin>>a>>b;
  for(int i=0; i<=a; i++){
      if(i*2+(a-i)*4==b){
          cout<<"Yes\n";
          return 0;
      }
  }
  cout<<"No\n";
}

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

int main(){
	int A, B;
	cin >> A >> B;
	if(A <= 8 && B <= 8){
		cout << "Yay!";
	}else{
		cout << ":(";
	}
	return 0;
}

Measured memory_bytes: 256
import itertools
N=int(input())
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))
permutations=list(itertools.permutations(range(1,N+1)))
p=permutations.index(P)
q=permutations.index(Q)
ans=abs(p-q)
print(ans)

Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  int N; cin>>N;
  int a1[N]; CINA(a1,N);
  int a2[N]; CINA(a2,N);
  int c1[N];
  REP(i,N){
    if(i==0){c1[0]=a1[0]; continue;}
    c1[i] = c1[i-1]+a1[i];
  }
  int c2[N];
  REPR(i,N-1){
    if(i==N-1){c2[N-1]=a2[N-1]; continue;}
    c2[i] = c2[i+1] + a2[i];
  }
  int r = -1;
  REP(i,N){
    int s = c1[i] + c2[i];
    if(s>r){ r = s;}
  }
  cout << r;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;

  double sum = 0;
  for (int i = 0; i < N; i++) {
    double A;
    cin >> A;

    sum += 1.0 / A;
  }

  double answer = 1 / sum;

  cout << setprecision(10);
  cout << answer << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define M 65536
#define N 16
int a[N][N], v[N], n;
ll sum[M], f[M];
int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++) scanf("%d", &a[i][j]);
    for (int t = 0; t < (1 << n); t++) {
        int num = 0;
        for (int i = 0; i < n; i++)
            if (t >> i & 1ll) v[num++] = i;
        ll s = 0;
        for (int i = 0; i < num; i++)
            for (int j = i + 1; j < num; j++) s += a[v[i]][v[j]];
        f[t] = sum[t] = s;
    }
    for (int i = 0; i < (1 << n); i++)
        for (int j = i; j; j = (j - 1) & i) f[i] = max(f[i], f[i ^ j] + sum[j]);
    printf("%lld\n", f[(1 << n) - 1]);
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

vl f(ll d){
  vl cnt(10010,0);
  for(ll x = 1;(x*x)<d;x++){
    for(ll y=1;(y*y)<d;y++){
      for(ll z=1;(z*z)<d;z++){
        ll c = (x*x + y*y + z*z + x*y + y*z + z*x);
        if(c<=10000)cnt[c]++;
      }
    }
  }
  return cnt;
}

int main() {
  int n;
  cin >> n;
  vl ans = f(10000);
  for(int i = 1;i<=n;i++){
    printf("%Ld\n",ans[i]);
  }  
  return 0;
}

Measured memory_bytes: 3684
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define N 100005
#define rep(i,j,k) for (ll i=j;i<=k;++i)
#define per(i,j,k) for (ll i=j;i>=k;--i)
using namespace std;
inline ll read(){
	char ch=getchar(); ll x=0,f=1;
	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 n,m,sum,ans,a[N],b[N],c[N];
int main(){
	n=read(); m=read();
	rep(i,1,n) a[i]=read();
	rep(i,1,n-1){
		if (a[i+1]>a[i]){
			sum+=a[i+1]-a[i];
			b[a[i]+1]+=a[i]+1;
			b[a[i+1]+1]-=a[i]+1;
			++c[a[i]+1]; --c[a[i+1]+1];
		}else{
			sum+=m-a[i]+a[i+1];
			b[1]-=m-(a[i]+1); b[a[i+1]+1]+=m-(a[i]+1);
			b[a[i]+1]+=a[i]+1;
			++c[1]; --c[a[i+1]+1]; ++c[a[i]+1];
		}
	}
	rep(i,1,m) b[i]+=b[i-1],c[i]+=c[i-1];
	rep(i,1,m) ans=max(ans,i*c[i]-b[i]);
	printf("%lld",sum-ans);
}

Measured memory_bytes: 2560
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑

int a, b, sum, ave, mon;
int main() {
	char c;
	while (cin >> a >> c >> b) {
		sum += a * b;
		ave += b;
		++mon;
	}

	cout << sum << endl;

	if (fmod((double)ave / mon, 1) >= 0.5) { cout << ave / mon + 1 << endl; }
	else { cout << ave / mon << endl; }
}


Measured memory_bytes: 3100
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading;

class Program
{

    static void Main(string[] args)
    {
        long h = long.Parse(Console.ReadLine());
        long ans = 1;
        long sum = 1;
        while (h > 1)
        {
            h /= 2;
            ans *= 2;
            sum += ans;
        }
        Console.WriteLine(sum);
    }




}

Measured memory_bytes: 27504
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	long long K;
	cin >> K;

	string s;
	cin >> s;

	if (s.length() <= K)
	{
		cout << s << endl;
	}
	else
	{
		for (int i = 0; i < K; i++)
		{
			cout << s[i];
		}
		cout << "...";
	}

}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n;i++)
using namespace std;
int main(){
	long long x,a,b; cin>>x>>a>>b;
	if(b-a<=0)return puts("delicious")*0;
	else if(b-a<=x)return puts("safe")*0;
	else return puts("dangerous")*0;
}


Measured memory_bytes: 256
N,K = map(int, input().split())
P = list(map(int, input().split()))

S = [0]
before = 0
for i in range(N):
    S.append(P[i]+before)
    before += P[i]

max_num = 0
l = 0
m = 0
for i in range(N):
    if K+i > N:
        break
    tmp = S[K+i]-S[i]
    if tmp > max_num :
        l = K+i
        m = i
        max_num = tmp

S = P[m:l]
ans = 0
for i in range(len(S)):
    gausu = (S[i])*(S[i]+1)/2
    ans += (gausu/S[i])

print(ans)

Measured memory_bytes: 24804
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

signed main() {
    int x, y;
    cin >> x >> y;
    if(y%2) {
        cout << "No" << endl;
        return 0;
    } else {
        if(x*2 > y) {
            cout << "No" << endl;
            return 0;
        }
        x -= y/4;
        y -= 4*(y/4);
        if(x < 0) {
            cout << "No" << endl;
            return 0;
        } else {
            if(x*2 >= y) {
                cout << "Yes" << endl;
                return 0;
            } else {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

template<typename T> bool chmin(T& a, T b) {return a > b ? a = b, true : false;}

template<typename T> bool chmax(T& a, T b) {return a < b ? a = b, true : false;}

template<typename T> void sort(vector<T>& v) {sort(v.begin(), v.end());}

int main() {
  int64_t a, b, c;
  cin >> a >> b >> c;
  cout << b + min(a + b + 1, c) << endl;
}



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

int main() {
  int N, D;
  cin >> N >> D;
  int A[N][D];
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < D; j++) {
      cin >> A[i][j];
    }
  }
  int ans = 0;
  for(int i = 0; i < N - 1; i++) {
    for(int j = i + 1; j < N; j++) {
      int sum = 0;
      for(int k = 0; k < D; k++) {
        sum += (A[i][k] - A[j][k]) * (A[i][k] - A[j][k]);
      }
      for(int l = 0; l < 130; l++) {
        if(l * l == sum) ans++;
      }
    }
  }
  cout << ans << endl;
}
        

Measured memory_bytes: 256
#include <stdio.h>
int n, m, q, x, y, z, ans;
int a[50];
int b[50];
int c[50];
int d[50];
int e[10];
int main() {
	scanf("%d%d%d", &n, &m, &q);
	for (int i = 0; i < q; i++) {
		scanf("%d%d%d%d", a + i, b + i, c + i, d + i);
		a[i]--; b[i]--;
	}
	if (m == 1) {
		for (int i = 0; i < q; i++) {
			if (c[i] == 0)ans += d[i];
		}
		printf("%d\n", ans);
		return 0;
	}
	while (true) {
		x = -1;
		for (int i = 0; i < n; i++) {
			if (e[i] < m - 1)x = i;
		}
		if (x < 0)break;
		y = e[x] + 1;
		for (int i = x; i < n; i++) {
			e[i] = y;
		}
		z = 0;
		for (int i = 0; i < q; i++) {
			if (e[b[i]] - e[a[i]] == c[i]) {
				z += d[i];
			}
		}
		if (z > ans)ans = z;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 1724
from __future__ import division
import itertools

def exp(a,b,c,d):
    L=["((%d%c%d)%c(%d%c%d))","(%d%c(%d%c(%d%c%d)))","((%d%c(%d%c%d))%c%d)","(%d%c((%d%\
c%d)%c%d))","((%d%c(%d%c%d))%c%d)"]
    opr=["+","-","*"]
    for i,j,k,l in itertools.permutations([a,b,c,d]):
        for o1,o2,o3 in itertools.product(opr,repeat=3):
            for st in L:
                r=st%(i,o1,j,o2,k,o3,l)
                try:
                    t=eval(r)
                    if t==10:
                        return r
                except ZeroDivisionError:
                    pass
    return 0

while True:
    a,b,c,d=sorted(map(int,raw_input().split()),reverse=True)
    if a==b==c==d==0:break
    print exp(a,b,c,d)

Measured memory_bytes: 4424
MOD = 10 ** 9 + 7

N, K = map(int, input().split())

S = [0] * (N + 2)
for i in range(N + 1):
    S[i + 1] = S[i] + i

cnt = 0
for i in range(K, N + 2):
    a = S[i]
    b = S[N + 1] - S[N + 1 - i]
    cnt += b - a + 1
    cnt %= MOD

print(cnt)


Measured memory_bytes: 69368
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main(){
    ios;
    int x, a; cin >> x >> a;
    if(x < a)cout << 0;
    else cout << 10;
    
}



Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

  long long p = 1;
  for(int i = 1; i <= n; i++) {
    p *= (long long)i;
    if(p > 1000000000 + 7) {
      p %= 1000000000 + 7;
    }
  }

  cout << p << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    cout << (n % k != 0) << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
void call(int n) {
	int i = 1;
CHECK_NUM:
	int x = i;
	if (x % 3 == 0) {
		cout << " " << i;
		goto END_CHECK_NUM;
	}
INCLUDE3:
	if (x % 10 == 3) {
		cout << " " << i;
		goto END_CHECK_NUM;
	}
	x /= 10;
	if (x) goto INCLUDE3;
END_CHECK_NUM:
	if (++i <= n) goto CHECK_NUM;

	cout << endl;
}
void solv() {

	int n;
	cin >> n;
	int a[110];
	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (size_t i = 0; i < n; i++)
	{
		if (i > 0) cout << " ";
		cout << a[n - 1 - i];
	}
	cout << endl;
}

int main() {
	//	COMinit();
	solv();

	return 0;
}



Measured memory_bytes: 3104
#include <iostream>

class Dice
{
public:
    Dice(int s1, int s2, int s3, int s4, int s5, int s6);
    void rollE();
    void rollN();
    void rollS();
    void rollW();
    int getTop();
private:
    int ms1, ms2, ms3, ms4, ms5, ms6;
};

Dice::Dice(int s1, int s2, int s3, int s4, int s5, int s6)
: ms1(s1), ms2(s2), ms3(s3), ms4(s4), ms5(s5), ms6(s6)
{}

void Dice::rollE() {
    int tmp = ms1;
    ms1 = ms4;
    ms4 = ms6;
    ms6 = ms3;
    ms3 = tmp;
}

void Dice::rollN() {
    int tmp = ms1;
    ms1 = ms2;
    ms2 = ms6;
    ms6 = ms5;
    ms5 = tmp;
}

void Dice::rollS() {
    int tmp = ms1;
    ms1 = ms5;
    ms5 = ms6;
    ms6 = ms2;
    ms2 = tmp;
}

void Dice::rollW() {
    int tmp = ms1;
    ms1 = ms3;
    ms3 = ms6;
    ms6 = ms4;
    ms4 = tmp;
}

int Dice::getTop() {
    return ms1;
}

int main(int argc, const char *argv[]) {
    int s1, s2, s3, s4, s5, s6;
    std::cin >> s1 >> s2 >> s3 >> s4 >> s5 >> s6;
    Dice dice(s1, s2, s3, s4, s5, s6);
    std::string orders;
    std::cin >> orders;
    for (int i = 0; i < orders.size(); i++) {
        switch (orders[i])
        {
        case 'E' : dice.rollE(); break;
        case 'N' : dice.rollN(); break;
        case 'S' : dice.rollS(); break;
        case 'W' : dice.rollW(); break;
        }
    }
    std::cout << dice.getTop() << std::endl;
    return 0;
}

Measured memory_bytes: 3172
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<ll,ll> P;
//ll const INF=1001001001;
//ll const INF=1001001001001001001;
ll const MOD=1000000007;

ll n;
ll a[100000];

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

    ll maxi=0;
    rep(i,n) maxi=max(maxi,a[i]);

    ll r=0;
    rep(i,n){
        if(min(maxi-r,r)<min(maxi-a[i],a[i])) r=a[i];
    } 

    cout<<maxi<<' '<<r<<endl;
}

Measured memory_bytes: 4368
#include <iostream>
#include <cstdlib>

int main()
{
    std::string s;
    int n;
    std::cin>>n;
    std::cin>>s;
    
    for(auto&c:s){
        c = 'A'+(c-'A'+n)%26;
    }
    std::cout << s<< std::endl;
}


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

int main(){
    int N, K;
    cin >> N >> K;
    vector<vector<int>>  b(K, vector<int>(K)), w(K, vector<int>(K));
    for(int i = 0;i < N;i++){
        int xi, yi;
        char ci;
        cin >> xi >> yi >> ci;
        LL p = xi/K+yi/K;
        int rx = xi%K;
        int ry = yi%K;
        if(ci == 'B'){
            if(p&1) w[ry][rx]++;
            else    b[ry][rx]++;
        }else if(ci == 'W'){
            if(p&1) b[ry][rx]++;
            else    w[ry][rx]++;
        }
    }
    for(int i = 0;i < K;i++){
        for(int j = 1;j < K;j++){
            b[i][j] += b[i][j-1];
            w[i][j] += w[i][j-1];
        }
    }
    for(int i = 1;i < K;i++){
        for(int j = 0;j < K;j++){
            b[i][j] += b[i-1][j];
            w[i][j] += w[i-1][j];
        }
    }
    LL ans = 0;
    for(int i = 0;i < K;i++){
        for(int j = 0;j < K;j++){
            LL count = 0;
            count += b[i][j];
            count += w[K-1][j]-w[i][j];
            count += w[i][K-1]-w[i][j];
            if(i < K-1 && j < K-1)  count += b[K-1][K-1]-b[K-1][j]-b[i][K-1]+b[i][j];
            ans = max(ans, count);
        }
    }
    for(int i = 0;i < K;i++){
        for(int j = 0;j < K;j++){
            LL count = 0;
            count += w[i][j];
            count += b[K-1][j]-b[i][j];
            count += b[i][K-1]-b[i][j];
            if(i < K-1 && j < K-1)  count += w[K-1][K-1]-w[K-1][j]-w[i][K-1]+w[i][j];
            ans = max(ans, count);
        }
    }
    cout << ans << endl;
}

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

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

    int n;
    cin>>n;

    int a=n%1000;

    if(a==0){
        cout<<0<<"\n";
    }

    else{
        cout<<1000-a<<"\n";
    }
    
    return 0;
}



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

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

    int ans=0;
    for (int i = 1; i <= n; i++) {
        int tmp = i;
        int sum=0;
        while(tmp){
            sum += tmp%10;
            tmp /= 10;
        }

        if(a <= sum && sum <= b){
            ans += i;
        }

    }

    cout << ans << endl;
}

Measured memory_bytes: 256
# from operator import itemgetter
# import math
q, h, s, d = map(int, input().split())
n = int(input())

ans = 0

h = min(h, q*2)
s = min(s, h*2)
d = min(d, s*2)

if n == 1:
        # print("case1")
        ans = s
elif n%2 == 0:
        # print("case2")
        ans = n//2 * d
elif n%2 != 0:
        # print("case3")
        ans = (n-1)//2 * d + s
print(ans)


Measured memory_bytes: 38256
#include <stdio.h>

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

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> v(N);
    for (int i = 0; i < N; i++) {
        cin >> v[i];
    }
    ll ans = 0;
    for (int k = 0; k < min(K + 1, N + 1); k++) {
        for (int i = 0; i < k + 1; i++) {
            int left = i;
            int right = k - i;
            priority_queue<int, vector<int>, greater<int>> que;
            int cnt = K - k;
            for (int j = 0; j < left; j++) {
                que.push(v[j]);
            }
            for (int j = 0; j < right; j++) {
                que.push(v[(N - 1) - j]);
            }
            for (int j = 0; j < cnt; j++) {
                if (!que.empty() && que.top() < 0) {
                    que.pop();
                }
            }
            ll sum = 0;
            while (!que.empty()) {
                sum += que.top();
                que.pop();
            }
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;
}

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

int main()
{
	int  n,k;
	cin>>n>>k;
	
	vector<int> dist(n);
	for(int i=0;i<n;i++)
	   cin>>dist[i];
	vector<vector<int>> v(n);
	vector<bool> f(n,false);
	
	for(int i=0;i<k;i++)
	{
		int a,b;
		cin>>a>>b;
		v[a-1].push_back(b-1);
		v[b-1].push_back(a-1);
	}
	
	// for(auto x:v)
	// {
	// 	for(auto y:x)
	// 	  cout<<y<<" ";
	// 	  cout<<endl;
	// }
	// cout<<endl;
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		if(v[i].size()==0)
		 {
		 	cnt++;
		 	continue;
		 }
		 
		 bool f=false;
		 //cout<<dist[i]<<endl;
		for(int j=0;j<v[i].size();j++)
		{
		//	cout<<dist[v[i][j]]<<" ";
			if(dist[i]<=dist[v[i][j]])
			{
				f=true;
				break;
			}
		}
		//cout<<endl;
		if(!f)
		  cnt++;
	}
//	cout<<endl;
	cout<<cnt<<endl;
}

Measured memory_bytes: 8776
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
#define spln(i,n) (i==n?'\n':' ')
using namespace std;
int n,m,i,j,l,r,mid,ans;
string st,mem;
bool check(int x)
{
	st=mem+" ";
	int s=x*9,i,j;
	fz1(i,n){
//		cerr<<st<<endl; 
		if(s<st[i]-'0') return 0;
		while(s%10!=(st[i]-'0')) s--;
		int t=s;
		fz(j,i,n){
			st[j]-=t%10;
			if(st[j]<'0'){
				st[j+1]--;
				st[j]+=10;
			}
			t/=10;if(!t&&(j==n||st[j+1]>='0')) break;
		}
	}
	return 1;
}
int main()
{
	rdst(st,500005);n=st.length();reverse(st.begin(),st.end());st=" "+st;mem=st;
	l=0;r=n;
	while(l<r){
		mid=(l+r+1)/2;
		if(check(mid)){
			r=mid-1;
			ans=mid;
		}
		else l=mid;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2208
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string.h>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    int n;
    cin >> n;
    map<int, int> v[2];
    for(int i = 0; i < n; i++){
        int num;
        cin >> num;
        v[i % 2][num]++;
    }
    v[0][-1] = 0;
    v[1][-2] = 0;
    vector<pair<int, int>> v_sorted[2];
    for(auto i: v[0]){
        v_sorted[0].push_back({i.second, i.first});
    }
    for(auto i: v[1]){
        v_sorted[1].push_back({i.second, i.first});
    }
    sort(all(v_sorted[0]), greater<>());
    sort(all(v_sorted[1]), greater<>());
    if(v_sorted[0][0].second == v_sorted[1][0].second){
        cout << n - max(v_sorted[0][1].first + v_sorted[1][0].first, v_sorted[0][0].first + v_sorted[1][1].first) << endl;
    }else{
        cout << n - v_sorted[0][0].first - v_sorted[1][0].first << endl;
    }
}


Measured memory_bytes: 6136
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	#define PI 3.1415926535897932384626433832795
	#define rf freopen("inputf.in", "r", stdin)
	#define wf freopen("outputf.in", "w", stdout)

	using namespace std;
	int main(void)
	{//rf;wf;
		std::ios::sync_with_stdio(false);
		float b;
		cin>>b;
//		cout<<2*PI*b <<endl;
		cout << fixed << setprecision(20) << 2*PI*b <<endl;
	}

Measured memory_bytes: 3804
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 

int main() {
  int N,ans=0;
  cin >> N;
  if(N%10==0){
    cout << 10 << endl;
    return 0;
  }
    while(N!=0){
        ans+=N%10;
        N=N/10;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
    JAI JAGANNATH!
*/
//@Author : zanj0
#include <bits/stdc++.h>
#define fastio  ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int lli;
lli calcSetBits(lli x){
    if(x == 0)return 0;
    return calcSetBits(x >> 1) + (x & 1);
}
void printHonestStatus(vector < pair <int, int> > v){
    for(int i = 0; i < v.size(); i++)cout << v[i].first << " " << v[i].second << endl;
    cout << endl;
}
int main(){
    
    fastio
    lli n;
    cin >> n;
    vector < pair <int, int > > arr[n];
    for(lli i = 0; i < n; i++){
        lli x, y;
        lli a;
        cin >> a;
        while(a--){
            cin >> x >> y;
            arr[i].push_back({x, y});
        }
    }
    //for(lli i = 0; i < n; i++)printHonestStatus(arr[i]);
    lli ans = 0;
    lli bits = (1 << n) - 1;
    for(lli bit = 1; bit <= bits ;bit++){
            //cout << bit << endl;
            bool ok = true;
        for(lli j = 0; j < n; j++){
            if(!((bit >> j) & 1))continue;
            for(lli k = 0; k < arr[j].size(); k++){
                lli person = arr[j][k].first;
                lli honestStatus = arr[j][k].second;
                if(((bit >> (person - 1)) & 1) ^ honestStatus) {
                    //cout << "Problem! " << bit << " " << person - 1 << " " << honestStatus << endl;
                    ok = false;
                }
            }
        }
        if(ok) {
            lli setBits = calcSetBits(bit);
            ans = max(ans, setBits);
        }
    }
    cout << ans << endl;
    return 0;
}



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

int main(){
    int a,b;
    cin >> a >> b;
    
    if(a == 1) a += 13;
    if(b == 1) b += 13;

    if(a > b) cout << "Alice" << endl;
    else if(b > a) cout << "Bob" << endl;
    else cout << "Draw" << endl;
    
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
#define SHN 1e9
#define lSHN 1e18
using namespace std;
int n,m;
bool a[200010][2];
int main()
{
	cin >>n>>m;
	for (int i=0;i<m;i++)
	{
		int x,y;
		cin >>x>>y;
		x--,y--;
		if (!x) a[y][0]=1;
		if (y==n-1) a[x][1]=1;
	}
	for (int i=0;i<n;i++)
	{
		if (a[i][0] && a[i][1])
		{
			cout <<"POSSIBLE";
			return 0;
		}
	}
	cout <<"IMPOSSIBLE";
	return 0;
} 

Measured memory_bytes: 640
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    n = ni()
    s = ns()

    change = 0
    for i in range(1, n):
        if s[i] == 'E':
            change += 1

    ans = [change]
    for i in range(1, n):
        if s[i-1] == 'W':
            change += 1
        if s[i] == 'E':
            change -= 1
        ans.append(change)

    print(min(ans))

if __name__ == '__main__':
    main()

Measured memory_bytes: 16128
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, T;
    cin >> N >> T;
    int ans = INF;
    rep(i, N) {
        int c, t;
        cin >> c >> t;
        if (t <= T) {
            ans = min(ans, c);
        }
    }
    if (ans != INF) {
        cout << ans << endl;
    } else {
        cout << "TLE" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


ll get_digit_sum(ll num){

	ll ret = 0;

	while(true){
		ret += num%10;
		num /= 10;
		if(num == 0)break;
	}

	return ret;
}


int main(){

	ll add,n,LIMIT;

	scanf("%lld %lld %lld",&add,&n,&LIMIT);

	vector<ll> V;
	ll y = 1,tmp,mult;
	int ans = 0;

	while(true){

		tmp = y+add;
		mult = y+add;

		for(int i = 0; i < n-1; i++){
			tmp *= mult;
			if(tmp > LIMIT){
				break;
			}
		}

		if(tmp > LIMIT)break;

		if(get_digit_sum(tmp) == y){
			ans++;
		}

		y += 1;
	}

	printf("%d\n",ans);

	return 0;
}



Measured memory_bytes: 3220
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N + 1);
  for (ll i = 1; i <= N; ++i) {
    cin >> A[i];
  }

  if (K == 1) {
    cout << 0 << endl;
    return 0;
  }
  
  vector<ll> S(N + 1);
  S[0] = 0;
  for (ll i = 1; i <= N; ++i) {
    S[i] = S[i - 1] + A[i];
  }

  vector<ll> X(N + 1);
  for (ll i = 0; i <= N; ++i) {
    X[i] = (S[i] - i + K) % K;
  }

  ll ans = 0;
  map<ll, ll> counts;
  counts[0]++;
  for (ll j = 1; j <= N; ++j) {
    ans += counts[X[j]];
    counts[X[j]]++;
    if (j - K + 1 >= 0) counts[X[j - K + 1]]--;
  }

  cout << ans << endl;
  
  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
#define int long long
//for set
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   
// for multiset
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_multiset;


#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
int __unset(int b, int i) {return b&!(1<<i);}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mul(int a, int b) {return ((a%MOD)*(b%MOD))%MOD;}
int add(int a, int b) {return (a+b)%MOD;}
int sub(int a, int b) {return (((a-b)%MOD)+MOD)%MOD;}
int __div(int a, int b) {return mul(a, powmod(b, MOD-2, MOD));} //if MOD is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
vi order;
bool cmp(int a, int b) {
	return order[a] < order[b];
}
int dfs(int u, vi& trap, vi& a, vi& vis, int* cyc) {
	vis[u]=1;
	if(!vis[a[u]]) {
		dfs(a[u], trap, a, vis, cyc);
	} else if(vis[u]==1 && vis[a[u]]==1) {
		*cyc=u;
	}
	vis[u]=2;
}
int32_t main(void)
{
	IOS;
	// int a, b; cin>>a>>b;
	// int cnt=1;
	// int soc=a;
	// while(soc < b) {
	// 	cnt++;
	// 	soc = soc-1+a;
	// }
	// cout<<cnt<<endl;

	int n; cin>>n;
	vi a(n);
	for(int i = 0; i< n; i++)
	cin>>a[i];
	int dp[n];
	dp[0]=0;
	for(int i = 1; i<n; i++) {
		if(a[i] <= a[i-1]) {
			dp[i]=dp[i-1]+1;
		} else {
			dp[i]=0;
		}
	}
	cout<<*max_element(dp, dp+n)<<endl;
	// stack<int> s;
	// s.push(a[0]);
	// vi b(n,n);
	// for(int i = 1; i < n; i++) {
	// 	if(s.empty()) {
	// 		s.push(i);
	// 		continue;
	// 	}
	// 	while(!s.empty()) {
	// 		int ind=s.top();
	// 		if(a[ind] < a[i]) {
	// 			b[ind]=i;
	// 			s.pop();
	// 		} else break;
	// 	}
	// }
	// int mx=0;
	// for(int i = 0; i < n; i++) {
	// 	mx=max(mx, b[i]-i-1);
	// }
	// cout<<mx<<endl;
	time();
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 2e5; int n;
const lli mod = 1e9 + 7;
lli fat[maxN + 1], invFat[maxN + 1];

lli modPow(lli x, lli y)
{
  lli ans = 1;
  while (y)
  {
    if (y & 1LL) ans = ans * x % mod;
    x = x * x % mod, y >>= 1LL;
  }
  return ans;
}
lli invMod(lli x)
{
  return modPow(x, mod - 2);
}

vector<int> tree[maxN];
/*
  Do dfs to calculate all subtree's size (root at 0, later we will reroot)
  divisor = product (subtreeSize[u] for all u)

  ans = n!
  ans /= n
  ans /= belows subtreeSizes (will be at divisions[u])
    divisions[u] *= divisions[child(u)]
  ans /= aboves subtreeSizes
    passing down:
      divisions[u] / divisions[child(u)] / (n - subtreeSize[child(u)])

  reroot to u:
    when going down: pass the current divisions
*/

// calculates subtreeSize and divisions rooted at 0
lli divisions[maxN];
int subtreeSize[maxN];
void dfs1(int u = 0, int prv = -1)
{
  divisions[u] = 1, subtreeSize[u] = 1;
  for (int v: tree[u])
    if (v != prv)
    {
      dfs1(v, u);
      subtreeSize[u] += subtreeSize[v];
      divisions[u] = divisions[u] * divisions[v] % mod;
    }
  divisions[u] = divisions[u] * subtreeSize[u] % mod;
}

// find and for each u through rerooting
lli ans[maxN];
void dfs2(int u = 0, int prv = -1, lli aboveDivisions = 1)
{
  ans[u] = fat[n];
  if (prv != -1) ans[u] = ans[u] * invMod(aboveDivisions) % mod;
  ans[u] = ans[u] * invMod(divisions[u]) % mod // apply u's childs divisions
                  * subtreeSize[u] % mod // remove previous u's subtree size
                  * invMod(n) % mod; // add new u's subtree size

  for (int v: tree[u])
    if (v != prv)
    {
      lli newAboveDivisions =
        divisions[u] * aboveDivisions % mod // add above's divisions
                     * invMod(divisions[v]) % mod // remove this branch's divisions
                     * invMod(subtreeSize[u]) % mod // remove previous u's subtree size
                     * (n - subtreeSize[v]) % mod; // add new u's subtree size
      dfs2(v, u, newAboveDivisions);
    }
}

int main()
{
  fat[0] = 1, invFat[0] = invMod(1);
  for (lli i = 1; i <= maxN; i++)
  {
    fat[i] = i * fat[i - 1] % mod;
    invFat[i] = invMod(fat[i]);
  }

  int t = 0;
  while (scanf("%d", &n) != EOF)
  {
    if (t++) printf("-----------\n");
    for (int i = 0; i < n; i++) tree[i].clear();

    for (int i = 1; i < n; i++)
    {
      int u, v; scanf("%d %d", &u, &v); u--, v--;
      tree[u].push_back(v), tree[v].push_back(u);
    }

    dfs1();
    dfs2();

    for (int i = 0; i < n; i++)
      printf("%lld\n", ans[i]);
  }
  return 0;
}

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

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] first = br.readLine().split(" ", 2);
        int n = Integer.parseInt(first[0]);
        int t = Integer.parseInt(first[1]);
        String[] line = br.readLine().split(" ", n);
        int[] arr = new int[n];
        int max = 0;
        int[] maxes = new int[n];
        for (int i = n - 1; i >= 0; i--) {
            arr[i] = Integer.parseInt(line[i]);
            if (max < arr[i]) {
                max = arr[i];
            }
            maxes[i] = max;
        }
        max = 0;
        int count = 0;
        for (int i = 0; i < n; i++) {
            int value = maxes[i] - arr[i];
            if (max == value) {
                count++;
            } else if (max < value) {
                max = value;
                count = 1;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 47316
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+1;
pair<pair<int,int>,pair<int ,string> > city[maxn];
bool cmp1(pair<pair<int,int>,pair<int ,string> > a,pair<pair<int,int>,pair<int ,string> > b)
{
	if(a.first.first!=b.first.first)
		return a.first.first<b.first.first;
	return a.first.second<b.first.second;
}
bool cmp2(pair<pair<int,int>,pair<int ,string> > a,pair<pair<int,int>,pair<int ,string> > b)
{
	return a.second.first<b.second.first;
}
int main()
{
	int n,m;
	cin>>n>>m;
	
	for(int i=0;i<m;i++)
	{
		int p,y;
		cin>>p>>y;
		city[i]=make_pair(make_pair(p,y),make_pair(i+1,""));
	}
	sort(city,city+m,cmp1);
	int order=1;
	int pd=city[0].first.first;
	for(int i=0;i<m;i++)
	{
		char buf[15];
		if(city[i].first.first!=pd)
		{
			pd=city[i].first.first;
			order=1;
		}
		sprintf(buf,"%06d%06d",pd,order++); 
		city[i].second.second=buf;
	}
	sort(city,city+m,cmp2);
	for(int i=0;i<m;i++)
	{
		cout<<city[i].second.second<<endl;
	}
	return 0;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> d1(n), d2(n);
    for (int i = 0; i < n; ++i) {
        cin >> d1[i] >> d2[i];
        if (i >= 2) {
            if (d1[i - 2] == d2[i - 2] && d1[i - 1] == d2[i - 1] && d1[i] == d2[i]) {
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 3624
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

fn main() {
    input! {
        n: usize,
        a: [u64; n]
    }
    let mut res = 0;
    let mut sum = 0;
    let mut right = 0;
    for left in 0..n {
        while right < n && sum + a[right] == sum ^ a[right] {
            sum += a[right];
            right += 1;
        }
        
        res += right - left;
        
        if right == left {right+=1;}
        else {sum -= a[left];}
    }

    println!("{}", res);
}

Measured memory_bytes: 6396