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

#define w cout
#define e '\n'
#define int long long
#define sz(x) (int)x.size()
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

int mod = 998244353;

void solve() {
	int n ; cin >> n;
	int v[n + 1] = {};
	for(int i = 1 ; i <= n ;i ++) cin >> v[i];
	int dd[n + 1][30];
	
	memset(dd , 0, sizeof dd);
	
	int l , q; cin >> l >> q;
	
	for(int i = 1; i <= n ;i ++){
		int can = v[i] - l;
		dd[i][0] = max(1ll , (int)(lower_bound(v + 1 , v + n + 1 , can) - v));
	}
	for(int j = 1; j < 18 ;j ++) {
		for(int i = 1; i <= n ;i ++) {
			dd[i][j] = dd[dd[i][j-1]][j-1];
		}
	}
	
	while(q--) {
		int a ,b ; cin >> a >> b;
		if(a > b) swap(a , b);
		int ans = 0;
		
		for(int j = 17 ; j >= 0; j --) {
			if(dd[b][j] > a) {
				ans += pow(2 , j);
				b = dd[b][j];
			}
		}
		w << ans + 1 << e;
	}
}

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


Measured memory_bytes: 25088
#include <iostream>
#include <cmath>
using namespace std;
const int D = pow(10, 9) + 7;
int main (void) {
    int N;

    cin >> N;

    long long ans = 1;
    for (int i = 1; i <= N; i++) ans = ans * i % D;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(a) for(int k=head[a];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef double db;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=1e6+5,M=5e3+5,INF=1e9,mod=998244353;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
int fa[N],n,h,ind[N],outd[N],ext[N],sta[N];;
int getf(int x){return fa[x]==x?x:fa[x]=getf(fa[x]);}
void die(){puts("NO");exit(0);}
int main(){
	read(n,h);rep(i,1,h+h)fa[i]=i;
	rep(i,1,n){int A,B,C,D;
		read(A,B);read(C,D);
		if(C)A=C+h;if(D)B=D;else B+=h;
		ind[B]++;outd[A]++;fa[getf(A)]=getf(B);ext[getf(A)]=1;
	}
	rep(i,1,h)if(outd[i]<ind[i])die();
	rep(i,1,h)if(outd[i+h]>ind[i+h])die();
	rep(i,1,h)if(outd[i]>ind[i])sta[getf(i)]=1;
	rep(i,1,h+h)if(getf(i)==i&&!sta[i]&&ext[i])die();
	puts("YES");
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


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

  int a,b,c,d;
  cin>>a>>b>>c>>d;

  int s1=abs(a-c);
  int s2=abs(b-d);

  cout<<s1+s2-__gcd(s1,s2)<<endl;


}

Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int dp[100001];

int main(){
  int X;
  cin >> X;
  dp[0] = 1;
  rep(n, 100, 106){
    rep(i, 100001){
      if(dp[i] && i + n <= X) dp[i + n] = 1;
    }
  }

  int ans = dp[X];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
const int INF=1e9;

int digit(int n){
  int res=0;
  while(n>0){
    res+=(n%10);
    n/=10;
  }
  return res;
}

int main(){
  int n;cin>>n;
  int ans=INF;
  for(int a=1;a<n;a++){
    int b=n-a;
    ans=min(ans,digit(a)+digit(b));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if((abs(a-b) <= d && abs(c-b) <= d) || (abs(a-c) <= d)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define m_k make_pair
#define int long long
using namespace std;
int n,a,b;
signed main()
{
	scanf("%lld%lld%lld",&n,&a,&b);
	if (a>b)
	{
		printf("0\n");
		return 0;
	}
	if (a==b)
	{
		printf("1\n");
		return 0;
	}
	if (n==1)
	{
		printf("0\n");
		return 0;
	}
	printf("%lld\n",(b-a)*(n-2)+1);
}

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

namespace ConsoleApplication
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var input = Utilities.ReadInts().ToArray();
            var n = input[0];
            var k = input[1];
            var result = k * Math.Pow(k - 1, n - 1);
            
            System.Console.WriteLine(result);
        }
    }

    public static class Utilities
    {
        #region Extensions for IO
        public static int ReadInt()
            => ReadInts().First();
        public static IEnumerable<int> ReadInts()
            => ReadStrings().Select(int.Parse);

        public static string ReadString()
            => ReadStrings().First();
        public static IEnumerable<String> ReadStrings()
            => Console.ReadLine().Split(' ');
        #endregion

        #region Extensions of int
        public static bool IsOdd(this int n)
            => !n.IsEven();

        public static bool IsEven(this int n)
            => n % 2 == 0;
        
        public static bool CanDivideWith(this int n, int divisor)
            => n % divisor == 0;
        #endregion

        public static int ToInt(this string str)
            => int.Parse(str);
    }
}


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

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	int dp[n];
	vector<int> cost(n);

	for (int i=0; i<n; i++) 
		scanf("%d", &dp[i]);

	int minc;

	for (int i=1; i<n; i++) {
		minc = INT_MAX;
		for (int j=1; j<=k && i-j>=0; j++) {
			minc = min(minc, cost[i-j]+abs(dp[i]-dp[i-j]));
		}
		cost[i] = minc;
	}
	
	cout << cost[n-1] << endl;

	return 0;
}

Measured memory_bytes: 1024
import java.util.*;	
import java.math.BigInteger;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		BigInteger a = sc.nextBigInteger();
		BigInteger b = sc.nextBigInteger();
		if(a.compareTo(b) == 1)System.out.println("GREATER");
		else if(a.compareTo(b) == -1)System.out.println("LESS");
		else System.out.println("EQUAL");
	}

}

Measured memory_bytes: 23892
S = input()
n = len(S)
i = n-1
B = ["0","1"]
n0,n1,b = 0,0,0
while i>=0:
  if S[i]==B[b] : n0+=1
  else : n1+=1
  b = 1-b
  i -= 1
if n0>n1 : print(n1)
else : print(n0)


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

using namespace std;

const int N = 100 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n, m;
int l[N], r[N];

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

    for (int i = 0; i < m; ++i)
        cin >> l[i] >> r[i];

    return true;
}

void solve() {
    cout << max(0, 1 + *min_element(r, r + m) - *max_element(l, l + m)) << endl;
}

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

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 1024
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

constexpr int MOD = 1e9+7;
struct mint
{
	int v;
	mint():v(0){}
	mint(int v):v((v+MOD)%MOD){}
	mint operator-()const{ return mint(0) - *this; }
	mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this; }
	mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this; }
	mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this; }
	mint& operator/=(const mint& a){ (*this) *= a.inv(); return *this; }
	mint operator+(const mint& a)const{ return mint(*this) += a; }
	mint operator-(const mint& a)const{ return mint(*this) -= a; }
	mint operator*(const mint& a)const{ return mint(*this) *= a; }
	mint operator/(const mint& a)const{ return mint(*this) /= a; }
	bool operator<(const mint& a)const{ return v < a.v; }
	bool operator==(const mint& a)const{ return v == a.v; }
	mint pow(int k)const{ mint r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }
	mint inv()const{ return pow(MOD-2); }
	static mint comb(int n, int k) {
		if(n-k<k) k=n-k;
		mint num(1), dom(1);
		for(int i=0;i<k;i++) { num*=n-i; dom*=i+1; }
		return num/dom;
	}
};
std::istream& operator>>(std::istream&i,mint&a){ int t; i>>t; a=mint(t); return i; }
std::ostream& operator<<(std::ostream&o,const mint&a){ o<<a.v; return o; }


signed main() {
	int n,m,k;
	std::cin >> n >> m >> k;

	mint comb = mint::comb(n*m-2,k-2);

	mint sum = 0;
	for(int d=1;d<n;d++) sum+=mint(d)*mint(n-d)*mint(m*m)*comb;
	for(int d=1;d<m;d++) sum+=mint(d)*mint(m-d)*mint(n*n)*comb;

	print(sum);
	return 0;
}


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

int main(){
	int h,w;
	cin>>h>>w;
	vector<string> s(h);
	for (int i = 0; i < h; i++) {
		cin>>s[i];
	}
	vector<vector<int>> u(h,vector<int>(w,0));
	vector<vector<int>> d(h,vector<int>(w,0));
	vector<vector<int>> l(h,vector<int>(w,0));
	vector<vector<int>> r(h,vector<int>(w,0));
	//left
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (j==0) {
				l[i][j]=0;
			}else if (s[i][j-1]=='#'||s[i][j]=='#') {
				l[i][j]=0;
			}
			else {
				l[i][j]=l[i][j-1]+1;
			}
		}
	}
	//right
	for (int i = 0; i < h; i++) {
		for (int j = w-1; j >= 0; j--) {
			if (j==w-1) {
				r[i][j]=0;
			}else if (s[i][j+1]=='#'||s[i][j]=='#') {
				r[i][j]=0;
			}else {
				r[i][j]=r[i][j+1]+1;
			}
		}
	}
	//up
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (i==0) {
				u[i][j]=0;
			}else if (s[i-1][j]=='#'||s[i][j]=='#') {
				u[i][j]=0;
			}else {
				u[i][j]=u[i-1][j]+1;
			}
		}
	}
	//down
	for (int i = h-1; i >= 0; i--) {
		for (int j = 0; j < w; j++) {
			if (i==h-1) {
				d[i][j]=0;
			}else if (s[i+1][j]=='#'||s[i][j]=='#') {
				d[i][j]=0;
			}else {
				d[i][j]=d[i+1][j]+1;
			}
		}
	}
	int ans=0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			ans=max(ans,l[i][j]+r[i][j]+u[i][j]+d[i][j]+1);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 67200
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  char s[11], t[11], flag = 1;
  scanf("%s%s", s, t);
  for (int i = 0; i < strlen(s); i++)
  {
    if (s[i] != t[i])
      flag = 0;
  }
  puts(flag ? "Yes" : "No");
}


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

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main(){

    int n, m, a;
    cin >> n >> m;
    vector<ll> cnt(n+6);
    vector<bool> broken(n+1, false);
    for(int i = 0; i < m; i++){
        cin >> a;
        broken[a] = true;
    }

    cnt[1] = cnt[2] = 1;
    if( !broken[1] )
        cnt[2]++;
    for(int i = 3; i <= n; i++){
        if( !broken[i-2] )
            cnt[i] = (cnt[i] + cnt[i-2])%MOD;
        if( !broken[i-1] )
            cnt[i] = (cnt[i] + cnt[i-1])%MOD;
    }

    cout << cnt[n]%MOD << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; int i; bool used; };
 
int MOD = 1000000007;

struct xyz {
	int x, y, z; bool f;
	xyz(int _x, int _y, int _z)
		: x(_x), y(_y), z(_z), f(true) {}
};

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

int main() {
	int n, x0, y0, t;
	cin >> n >> x0 >> y0 >> t;
	x0++; y0++;
	x0 *= 2; y0 *= 2;
	vector< vector<bool> > a(200, vector<bool>(200));
	while (n--) {
		int xs, ys, xe, ye;
		cin >> xs >> ys >> xe >> ye;
		xs++; ys++; xe++; ye++;
		xs *= 2; ys *= 2; xe *= 2; ye *= 2;
		if (xs == xe) {
			if (ys > ye) swap(ys, ye);
			for (int y = ys; y <= ye; y++)
				a[xs][y] = true;
		}
		else {
			if (xs > xe) swap(xs, xe);
			for (int x = xs; x <= xe; x++)
				a[x][ys] = true;
		}
	}
	queue<xyz> q;
	for (int z = 0; z < 4; z++)
		if (a[x0 + dx[z]][y0 + dy[z]])
			q.push(xyz(x0, y0, z));
	/*for (int i = 0; i < 53; i++) {
		for (int j = 0; j < 53; j++)
			cout << (a[i][j] ? ' ' : '#');
		cout << endl;
	}*/
	set<i_i> s;
	while (t--) {
		int d; cin >> d;
		d *= 2;
		while (d--) {
			vector< vector< vector<bool> > > b(200, vector< vector<bool> >(200, vector<bool>(4)));
			queue<xyz> _q;
			while (!q.empty()) {
				xyz e = q.front(); q.pop();
				for (int z = 0; z < 4; z++) {
					if (abs(z - e.z) != 2 && a[e.x + dx[z]][e.y + dy[z]]) {
						if (!e.f && abs(z - e.z) % 2) continue;
						if (!b[e.x + dx[z]][e.y + dy[z]][z]) {
							_q.push(xyz(e.x + dx[z], e.y + dy[z], z));
							b[e.x + dx[z]][e.y + dy[z]][z] = true;
						}
					}
				}
			}
			q = _q;
		}
		string c; cin >> c;
		int z;
		if (c == "W") z = 0;
		if (c == "S") z = 1;
		if (c == "E") z = 2;
		if (c == "N") z = 3;
		queue<xyz> _q;
		s.clear();
		while (!q.empty()) {
			xyz e = q.front(); q.pop();
			if ((e.z + 1) % 4 == z && a[e.x + dx[z]][e.y + dy[z]]) {
				e.f = false;
				e.z = z;
				_q.push(e);
				s.insert(i_i(e.x, e.y));
			}
			else if ((e.z + 3) % 4 == z && a[e.x + dx[z]][e.y + dy[z]]) {
				e.f = false;
				e.z = z;
				_q.push(e);
				s.insert(i_i(e.x, e.y));
			}
			else if (e.z == z) {
				_q.push(e);
				s.insert(i_i(e.x, e.y));
			}
		}
		q = _q;
		/*for (set<i_i>::iterator it = s.begin(); it != s.end(); it++)
			cout << it->first / 2 - 1 << ' ' << it->second / 2 - 1 << endl;
		cout << endl;*/
	}
	for (set<i_i>::iterator it = s.begin(); it != s.end(); it++)
		cout << it->first / 2 - 1 << ' ' << it->second / 2 - 1 << endl;
} 

Measured memory_bytes: 4152
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <set>
#include <cmath>
#include <vector>
#include <ctime>
#include <queue>
#include <sstream>
#include <utility>
#include <bitset>

using namespace std;

#define MP make_pair 
#define PB push_back 
#define INF (1000000007) 
#define eps 1e-8
#define MOD (1000000007)

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

ll k;
ll n=50;

int main()
{
	
	cin>>k;
	cout<<n<<endl;
	ll l=k/n;
	ll t=k%n;
	if(k<50) 
	{
		cout<<49+50*k+l<<" ";
		for(int i=2;i<=n;i++) cout<<l<<" ";
	}
	else
	{
		ll tmp=49+l-t;
		ll m=t/3;
		for(int i=1;i<=47;i++) cout<<tmp<<" ";
		tmp=49+l-m;
		if(t%3==0)
		{
			for(int i=1;i<=3;i++) cout<<tmp+m*n-2*m<<" ";
		}
		else if(t%3==1)
		{
			cout<<tmp+m*n-2*m-1<<" "<<tmp+m*n-2*m-1<<" "<<tmp+m*n-2*m+n;
		}
		else 
		{
			cout<<tmp+m*n-2*m-2<<" "<<tmp+m*n-2*m-1+n<<" "<<tmp+m*n-2*m-1+n;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll n; cin >> n;
  
  ll ans= 0;
  
  for(ll i=1; i <= n-1; i++){
    ans += (n-1)/i;
  }
  
  cout << ans << endl;
  
  
}

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

int main() {

	int a;
	int ans = 0;

	cin >> a;
	
	if (a % 10 == 9 || a + 10 >= 100) { ans = 1; }


	if (ans == 1) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  cin>>s;
  if(s[1]=='B') cout<<"ARC";
  else cout<<"ABC";
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
  // cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 3572
import sys
input = sys.stdin.readline
read = sys.stdin.read
import heapq

n, q = map(int, input().split())
STX = [list(map(int, input().split())) for _ in range(n)]
D = list(map(int, read().split()))
E = []
for s, t, x in STX:
  E.append((s-x, x, 1))
  E.append((t-x, x, 0))
E.sort(reverse=True)
que = []
stop = set()
que.append(10**10)
stop.add(10**10)
for d in D:
  while E and E[-1][0] <= d:
    temp, x, f = E.pop()
    if f:
      heapq.heappush(que, x)
      stop.add(x)
    else:
      stop.remove(x)
  while que[0] not in stop:
    heapq.heappop(que)
  if que[0] == 10**10:
    print(-1)
  else:
    print(que[0])

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

int main() {

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

}

Measured memory_bytes: 1536
#include <stdio.h>
#include <string.h>


void Str0(char s[])
{
	int len;
	int i;
	char *p;
	
	s[9999] = '\0';
	len = strlen(s);
	p = s;
	for (p += 9999; p >= s; p--){
		if (len >= 0){
			*p = s[len];
			len--;
		}
		else {
			*p = '0';
		}
	}
}

void Kuriagari(int j, char a[], char b[], char sum[])
{
	char *p;
	
	p = sum + j - 1;/*1をたす桁を指定*/
	
	*(p) += 1;
	if (*(p) == ':'){
		*(p) = '0';
		Kuriagari(j - 1, a, b, sum);
	}
}

int main(void)
{
	char a[10000], b[10000], sum[10000];
	int len;
	int n;
	int i, j;
	char *p;
	int flag;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		flag = 0;
		
		/*0詰めで文字列を入力*/
		scanf("%s", a);
		if (strlen(a) > 80){
			flag = 1;
		}
		Str0(a);
		
		scanf("%s", b);
		if (strlen(b) > 80){
			flag = 1;
		}
		Str0(b);
		
		
		if (flag == 1){
			printf("overflow\n");
		}
		else {
			/*繰り上がり処理*/
			for (j = 0; j < 9999; j++){
				sum[j] = ((a[j] - '0') + (b[j] - '0')) % 10;/*筆算する*/
				if (((a[j] - '0') + (b[j] - '0')) / 10 >= 1){/*もし繰り上がりが発生したら*/
					/*printf("test:%c\n", sum[j - 1]);*/
					Kuriagari(j, a, b, sum);/*繰り上がり処理*/
					/*printf("test:%c\n", sum[j - 1]);*/
				}
				sum[j] += '0';
			}
			sum[9999] = '\0';
			
			
			p = sum;
			while (*p == '0'){
				p++;
			}
			/*printf("%d\n", *p);*/
			if (strlen(p) == 0){
				printf("0\n");
			}
			else if (strlen(p) <= 80){
				printf("%s\n", p);
			}
			else {
				printf("overflow\n");
			}
		}
	}
	
	return (0);
}

Measured memory_bytes: 616
using System;
using System.Collections.Generic;
using System.Linq;
 
class Hello
{
    
    static void Main()
    {
        string [] str=Console.ReadLine().Split(' ');
        int n=int.Parse(str[0]);
        int m=int.Parse(str[1]);
        int [,] array=new int [n,m];
        
        
        for(int i=0;i<n;i++)
        {
            str=Console.ReadLine().Split(' ');
            for(int w=0;w<m;w++)
            {
                array[i,w]=int.Parse(str[w]);
            }
        }
        
        int [] b=new int [m];
        for(int i=0;i<m;i++)
        {
            b[i]=int.Parse(Console.ReadLine());
        }
        
        int sum=0;
        for(int i=0;i<n;i++){
            for(int w=0;w<m;w++){
                sum+=array[i,w]*b[w];
            }
            Console.WriteLine(sum);
            sum=0;
        }
    }
}


Measured memory_bytes: 20056
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define tc int t; cin>>t; while(t--)
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mod 1000000007
#define pb push_back
#define vi vector<int>
#define vc vector<char>
#define eb emplace_back
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define fo(i,x,n) for(int i=x;i<n;i++)
#define csb(x) __builtin_popcount(x)
#define tz(x) __builtin_ctz(x)
#define lsbp(x) __builtin_ffs(x)
#define msbp(x) __lg(x)
#define btoi(str,i) stoi(str,0,i)
#define ff first
#define ss second
const int inf=0x3f3f3f3f3f3f3f3f;
const int mx=2e5+1;



int32_t main(){
  
int cnt=0;
string s;cin>>s;
deque<char>dq;
int n=s.size();
for(int i=0;i<n;i++){
    dq.pb(s[i]);
}
tc{
    int x;cin>>x;
    if(x==1){
        cnt+=1;
    }
    else{
        int a;char c;
        cin>>a>>c;
        if(a==1){
            if(cnt&1)dq.pb(c);
            else dq.push_front(c);
        }
        else{
            if(cnt&1)dq.push_front(c);
            else dq.pb(c);
        }
    }
}
if(cnt&1){
    while(!dq.empty()){
        cout<<dq.back();dq.pop_back();
    }
}
else{
    while(!dq.empty()){
        cout<<dq.front();dq.pop_front();
    }
}


}

Measured memory_bytes: 896
import sys
def main():
    input=sys.stdin.readline
    X,Y,Z,K=map(int,input().split())
    A=list(map(int,input().split()))
    B=list(map(int,input().split()))
    C=list(map(int,input().split()))
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)

    AB=[]
    append=AB.append
    for i in range(min(K,X)):
        for j in range(min(K,Y)):
            append(A[i]+B[j])
    AB.sort(reverse=True)

    ABC=[]
    appendd=ABC.append
    for k in range(min(K,len(AB))):
        for l in range(min(K,Z)):
            appendd(AB[k]+C[l])
    ABC.sort(reverse=True)

    for m in range(K):
        print(ABC[m])

if __name__=="__main__":
    main()

Measured memory_bytes: 205400
n = int(input())
xy = []
for i in range(n):
    tmp = list(map(int,input().split()))
    tmp.append(i)
    xy.append(tmp)
link = []

xy.sort(key=lambda x:x[0])
for i in range(n-1):
    x1,_,node1 = xy[i]
    x2,_,node2 = xy[i+1]
    cost = abs(x1-x2)
    link.append([node1,node2,cost])

xy.sort(key=lambda x:x[1])
for i in range(n-1):
    _,y1,node1 = xy[i]
    _,y2,node2 = xy[i+1]
    cost = abs(y1-y2)
    link.append([node1,node2,cost])
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):
        return len(self.roots())

def krs(g,num_v):
    g.sort(key=lambda x:x[2])

    uf = UnionFind(num_v)
    mst = []
    for edge in g:
        if not uf.same(edge[0], edge[1]):
            uf.union(edge[0], edge[1])
            mst.append(edge)
    return mst


ret = krs(link,n)
ans=0
for i in range(len(ret)):
    ans+=ret[i][2]
print(ans)


Measured memory_bytes: 129964
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

int main(){
    int n, m;
    cin >> n >> m;
    vi a(n);
    ll sum = 0;
    rep(i, n){
        cin >> a.at(i);
        sum += a.at(i);
    }
    Sort(a);
    string ans = "Yes";
    if(a.at(n-m)*4*m<sum){
        ans = "No";
    }
    cout << ans << endl;
    return 0;
}

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

int main(int argc, char const *argv[])
{
    int s;
    cin >> s;
    int l = s / 100;
    int r = s % 100;
    if(1 <= l && l <= 12) {
        if(1 <= r && r <= 12) {
            cout << "AMBIGUOUS" << endl;
        } else {
            cout << "MMYY" << endl;
        }
    } else {
        if(1 <= r && r <= 12) {
            cout << "YYMM" << endl;
        } else {
            cout << "NA" << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 256
N,Ma,Mb = map(int,input().split())
abc = [list(map(int,input().split())) for _ in range(N)]
inf = 10**9
dp = [[inf for i in range(N*10+1)] for i in range(N*10+1)]
dp[0][0] = 0
max_a = 0
max_b = 0
for i in range(N):
    max_a += abc[i][0]
    max_b += abc[i][1]
    for ai in range(abc[i][0],max_a+1)[::-1]:
        for bi in range(abc[i][1],max_b+1)[::-1]:
            dp[ai][bi] = min(dp[ai][bi],dp[ai-abc[i][0]][bi-abc[i][1]]+abc[i][2])
ans = inf
for i in range(1,min(max_a//Ma,max_b//Mb)):
    ans = min(ans,dp[i*Ma][i*Mb])
if ans == inf:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 40944
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int x,n;
    cin >> x >> n;
    vi p(n);
    cin >> p;
    int now = inf;
    rep(i,102) {
        bool ok = true;
        rep(j,n) if(p[j] == i) ok = false;
        if(!ok) continue;
        if(abs(x-i) < abs(x-now)) {
            now = i;
        }
    }
    cout << now << endl;
}


Measured memory_bytes: 3676
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = []
d = 0
dc = 0
for I in range(n):
 x = a[I] - b[I]
 if x >= 0:
  c.append(x)
 else:
  d -= x
  dc += 1  
c.sort(reverse = True)
m = len(c)
k = 0
while d >0 and k < m :
 d -= c[k]
 k += 1
if d >0:
 print(-1)
else:
 print(dc + k)



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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int[] num = new int[N];
            for (int i = 0; i < N - 1; i++)
            {
                num[A[i] - 1]++;
            }
            for (int i = 0; i < N; i++)
            {
                Console.WriteLine(num[i].ToString());
            }
        }
    }
}

//24579 =  hon
//0168 = pon
//3 = bon
//long n = long.Parse(Console.ReadLine());
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

//Console.WriteLine(cnt);
//Console.ReadKey();


Measured memory_bytes: 43568
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define N 666666
int arr[N];
int n,m;
vector<int> v[N];
signed main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>arr[i];
	for(int i=1;i<=m;i++){
		int a,b;
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		int f=1;
		for(int j=0;j<v[i].size();j++){
			if(arr[i]<=arr[v[i][j]]){
				f=0;
				break;
			} 
		}
		if(f) ans++;
	} 
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 23492
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
#include <utility>
#include <queue>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;
const dd PI = 3.1415926435;

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

ll fact(ll n)
{
    if (n == 0)
    {
        return 1;
    }
    if (n == 1)
    {
        return 1;
    }
    return n * fact(n - 1) % MOD;
}

ll pow_fast(ll n, ll k)
{
    if (k == 0)
    {
        return 1;
    }
    if (k == 1)
    {
        return n;
    }

    if (k % 2 == 0)
    {
        ll tmp = pow_fast(n, k / 2LL);
        return tmp * tmp % MOD;
    }
    else
    {
        ll tmp = pow_fast(n, k / 2LL);
        tmp *= tmp;
        tmp %= MOD;
        return tmp * n % MOD;
    }
}

map<ll, ll> sosuu(ll n)
{
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            res[i] += 1;
            n /= i;
        }
    }
    if (n != 1)
    {
        res[n] += 1;
    }
    return res;
}

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

    char cur = 'a';
    char ans;
    while (true)
    {
        if (cur == 'a') {
            if (a.size() == 0) {
                ans = 'A';
                break;
            }
            cur = a[0];
            a.erase(0, 1);
        } else if (cur == 'b') {
            if (b.size() == 0) {
                ans = 'B';
                break;
            }
            cur = b[0];
            b.erase(0, 1);
        } else if (cur == 'c') {
            if (c.size() == 0) {
                ans = 'C';
                break;
            }
            cur = c[0];
            c.erase(0, 1);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int a, b, c, x, y;

int main() {
  scanf("%d%d%d%d%d", &a, &b, &c, &x, &y);
  ll ret = 1e9;
  for(ll i = 0; i <= 1000000; i+=2) {
    ll curr = i * c;
    curr += max(0LL, x-i/2) * a;
    curr += max(0LL, y-i/2) * b;
    ret = min(ret, curr);
  }
  printf("%lld\n", ret);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll N; cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    sort(A.begin(), A.end());
    ll ans = A[N - 1];
    ll ptr = N - 2;
    N -= 2;
    while (N > 1) {
        N-= 2;
        ans += A[ptr] * 2;
        ptr--;
    }
    if (N == 1) ans += A[ptr];
    cout << ans << endl;
}

Measured memory_bytes: 4784
#include<iostream>
#include<cmath>

int main(){

    int num;
    std::cin >> num;

    int h = num / 3600;
    num %= 3600;
    int m = num / 60;
    int s = num % 60;

    printf("%d:%d:%d\n", h, m, s);

    return 0;
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
  char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
  vector<char*> v({token});
  while(token = strtok(NULL,", ")) v.push_back(token);
  return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
  debug() << " [" << args.back() << ": " << H << "] ";
  args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=998244353;
const int MX=0x3f3f3f3f;

int main() {
    IOS;
    int n,q,x,t;
    cin>>n>>q;
    ll ans=1ll*(n-2)*(n-2);
    set<int> r,c;
    vi rp(n+1,MX),cp(n+1,MX);
    rp[n]=n;
    cp[n]=n;
    r.insert(n);
    c.insert(n); 
    while(q--){	
    	cin>>t>>x;
    	// dbg(t,x);
    	if(t==1){
    		auto it=r.lower_bound(x);
    		ans-=rp[*it]-2;
    		// dbg(*it,rp[*it],ans);
    		c.insert(rp[*it]);
    		cp[rp[*it]]=min(x,cp[rp[*it]]);
    	}else{
    		auto it=c.lower_bound(x);
    		ans-=cp[*it]-2;
    		// dbg(*it,cp[*it],ans);
    		r.insert(cp[*it]);
    		rp[cp[*it]]=min(x,rp[cp[*it]]);
    	}
    }
    cout<<ans;
    return 0;   
} 

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

long long v[300000];
 
int main()
{
  
  int n;
  cin >> n;
  long long res = 1;
  for( int i = 0; i < n; i++ ){
    cin >> v[i];
  }
  for( int i = 0; i < n; i++ ){
    if(res == -1){
    	if( v[i] == 0 ){
          res = 0;
          break;
        }
      	else 
          continue;
    }
    if( res  > 1000000000000000000LL / v[i] ){
    	res = -1;
    }
    else
      	res *= v[i];
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 4376
#include<bits/stdc++.h>
using namespace std;
const int N=105;

int n;
char s[N],t[N];

int main(){
    scanf("%d",&n);
    scanf("%s%s",s,t);
    for(int i=0;i<n;++i){
        printf("%c%c",s[i],t[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
typedef long long ll;
using namespace std;
int main(){
	int N;
	cin >> N;
	vector<int>X(N);
	for (int i = 0;i < N;++i) {
		ll a;
		cin >> X[i];
	}
	vector<int>vec = X;
	sort(X.begin(),X.end());
	int mid = N/ 2;
	ll mid_r = X[mid], mid_l = X[mid - 1];
	for (int i = 0;i < N;++i) {
		if (vec[i] >= mid_r) {
			cout << mid_l << endl;
		}
		else {
			cout << mid_r << endl;
		}
		
	}

	return 0;
}

Measured memory_bytes: 3712
N=int(input())
Amax=0
secoundmax=0
L=[]
for i in range(N):
    A=int(input())
    if Amax>A:
        if A>secoundmax:secoundmax=A
    elif A>Amax:
        secoundmax=Amax
        Amax=A
        L=[i]
    else:
        L.append(i)
if len(L)>=2:
    for _ in range(N):print(Amax)
else:
    for j in range(N):
        if j in L:print(secoundmax)
        else:print(Amax)

Measured memory_bytes: 12500
using System;
class Program
{
    static void Main(string[] args)
    {
        string input = Console.ReadLine();
        int ans = 0;

        switch (input)
        {
            case "SUN":
                ans = 7;
                break ;
            case "MON":
                ans = 6;
                break;
            case "TUE":
                ans = 5;
                break;
            case "WED":
                ans = 4;
                break;
            case "THU":
                ans = 3;
                break;
            case "FRI":
                ans = 2;
                break;
            case "SAT":
                ans = 1;
                break;
        }
        Console.Write(ans);
    }
}

Measured memory_bytes: 13152
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)*}
    };
}

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

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        k: usize
    }
    if n < 2 * k - 1 {
        println!("-1");
        return;
    }
    for i in 0..(n + 1) / 2 {
        println!("{} {} {}", k + 2 * i, k + 2 * n - 1 - i, k + 2 * n + n / 2 + i);
    }
    for i in 0..n / 2 {
        println!("{} {} {}", k + 1 + 2 * i, k + n + n / 2 - 1 - i, k + 2 * n + i);
    }
}


Measured memory_bytes: 6268
#include <iostream>

using namespace std;

int main()	{
  int n;
  cin >> n;
  int freq[4] = {0};
  for (int i = 0; i < 4; i++)	{
    int tmp = n % 10;
    freq[4 - i - 1] = tmp;
    n /= 10;
  }
  if (freq[0] == freq[1] && freq[1] == freq[2])	{
    cout << "Yes" << endl;
  }
  else if (freq[1] == freq[2] && freq[2] == freq[3])	{
    cout << "Yes" << endl;
  }
  else	{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define ll long long int

int main(){
    string s,t;
    cin>>s>>t;
    int n=s.length();
    int m=t.length();
    int ans=1e5+10;
    for(int i=0;i<n-m+1;i++){
        int change=0;
        for(int j=0;j<m;j++){
            if(s[i+j]==t[j])continue;
            else change++;
        }
        ans=min(ans,change);
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#include <bitset>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;
const int MAX = 510000;
signed main(){
    int a,b;
    cin>>a>>b;
    cout<<max((ll)0,a-2*b)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int k,n; cin >> k >> n;
    vector<int> a(n+1);
    rep(i,n) cin >> a[i];
    a[n] = a[0] + k;
    int tmp = -1;
    rep(i,n+1) chmax(tmp, a[i+1] - a[i]);
    cout << k - tmp << endl;
}


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

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

int main() {
	int x, y;
	cin >> x >> y;
	if (abs(x) < abs(y)) {
		if (y > 0) cout << min(y - x, 1 + y + x) << endl;
		else cout << 1 + min(-y - x, 1 - y + x) << endl;
	} else {
		if (x > 0) cout << 1 + min(y + x, 1 - y + x) << endl;
		else cout << min(y - x, 1 -y - x) << endl;
	}
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL d, n, m, p[112345], k[112345];
std::vector<LL>pv;
LL ans;

int main()
{
	while (true)
	{
		d = n = m = ans = 0;
		memset(p, 0, sizeof(p));
		memset(k, 0, sizeof(k));
		pv.clear();

		in >> d;
		if (d == 0) { break; }
		in >> n >> m;
		rep(i, n - 1) { in >> p[i]; }
		rep(i, m) { in >> k[i]; }

		pv.push_back(0); pv.push_back(d);
		rep(i, n - 1) { pv.push_back(p[i]); }
		std::sort(pv.begin(), pv.end());
		std::sort(k, k + m);
		rep(i, m)
		{
			auto prev = std::lower_bound(pv.begin(), pv.end(), k[i]);
			auto next = std::upper_bound(pv.begin(), pv.end(), k[i]);
			if (*prev != k[i]) { --prev; }
			ans += std::min(*next - k[i], k[i] - *prev);
		}

		out << ans << std::endl;
	}
	return 0;
}

Measured memory_bytes: 5608