akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int solve()
{
    int M1, D1, M2, D2;

    std::cin >> M1 >> D1 >> M2 >> D2;

    if (M2 == M1)
        return 0;
    else
        return 1;
}

int main()
{
    std::cout << solve() << std::endl;

    return 0;
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans = 0, keeper;
    string subA, subB;
    vector<char> v;
    bool b;
    for(int i = 1; i < n; i++){
        subA = s.substr(0, i);
        subB = s.substr(i, n-i);
        v.clear();
        keeper = 0;
        for(int j = 0; j < subA.size(); j++){
            for(int k = 0; k < subB.size(); k++){
                if(subA[j] == subB[k]){
                    if(v.size() == 0){
                        v.push_back(subA[j]);
                    } else {
                        b = false;
                        for(int l = 0; l < v.size(); l++){
                            if(v[l] == subA[j]) b = true;
                        }
                        if(b == false) v.push_back(subA[j]);
                    }
                }
            }
        }
        keeper = v.size();
        ans = max(ans, keeper);
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
	int h;
	int a;
	int n;
	cin >> h;
	cin >> a;
	if (h >= a && (h % a) == 0) {
      	n = h / a;
		cout << n << endl;
	} else if (h >= a && (h % a) != 0) {
      	n = h / a;
      	cout << n + 1 << endl;
    } else {
      	cout << 1 << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int a,b[101],c,i,j,z,min,cnt=0;
	scanf("%d",&a);
	for(i=0;i<a;i++)
		scanf("%d",&b[i]);
	for(j=0;j<a-1;j++){
		min = b[j];
		z = j;	
		for(i=j+1;i<a;i++){	
			if(b[i] < min){
				min = b[i];
				z = i;
			}
		}
		if(b[j] != b[z]){
			cnt++;
			c = b[j];
			b[j] = b[z];
			b[z] = c;}
	}
	for(i=0;i<a;i++){
		printf("%d",b[i]);
		if(i!=a-1)
			printf(" ");
		else
			printf("\n");
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 604
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int count = 0;
    String s = "";
    for(int i=1;i<=n;i++){
      s = String.valueOf(i);
      if(s.length()%2 == 1){
        count++;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 28244
#include<bits/stdc++.h>
#include<map>
using namespace std;
typedef long long LL;
map<int,int> mp;
int a[100005]; int prime[100005]; bool vis[100005]; int cnt; int sz; int fac[1005][2];
void initial(const int n=1e5)
{
	cnt=0;
	for(int i=2;i<=n;i++)
	{
		if(vis[i]==false) prime[++cnt]=i;
		for(int j=1;j<=cnt&&i*prime[j]<=n;j++)
		{
			vis[i*prime[j]]=true;
			if(i%prime[j]==0) break;
		}
	}
}
void work(int x)
{
	sz=0;
	for(int i=1;i<=cnt&&1ll*prime[i]*prime[i]<=x;i++)
	{
		if(x%prime[i]) continue;
		int t=0;
		while(x%prime[i]==0) x/=prime[i],t++;
		fac[++sz][0]=prime[i]; fac[sz][1]=t;	
	}	
	if(x!=1) fac[++sz][0]=x,fac[sz][1]=1;
} 
void dfs(int pos,int num)
{
	if(pos==sz+1)
	{
		mp[num]++;
		return ;
	}
	int x=1;
	for(int i=0;i<=fac[pos][1];i++)
	{
		dfs(pos+1,num*x);
		x=x*fac[pos][0];
	}
}
int main(void)
{
	initial();
	int n; scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	{
		work(a[i]); dfs(1,1);
	}
	int res=0;
	for(auto P:mp)
	{
		if(P.second>=n-1) res=max(res,P.first);
	}
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 768
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 200000
using namespace std;
typedef long long LL;
struct node
{
	int tag,col;
}tree[MAXN*4];
int N;
LL K;
LL s[MAXN+5];
LL a[MAXN+5];
int b[MAXN+5];
LL l[MAXN+5],r[MAXN+5];
LL lsh[MAXN+5],lcnt;
LL f[MAXN+5];
void PushDown(int i)
{
	if(tree[i].tag==0)
		return;
	tree[i*2].tag=tree[i].tag;
	tree[i*2].col=tree[i].tag;
	tree[i*2+1].tag=tree[i].tag;
	tree[i*2+1].col=tree[i].tag;
	tree[i].tag=0;
}
int Query(int i,int l,int r,int k)
{
	if(l==r)
		return tree[i].col;
	int mid=(l+r)/2;
	PushDown(i);
	if(k<=mid)
		return Query(i*2,l,mid,k);
	else
		return Query(i*2+1,mid+1,r,k);
}
void Insert(int i,int l,int r,int ql,int qr,int val)
{
	if(qr<l||ql>r)
		return;
	PushDown(i);
	if(ql<=l&&r<=qr)
	{
		tree[i].tag=val;
		tree[i].col=val;
		return;
	}
	int mid=(l+r)/2;
	Insert(i*2,l,mid,ql,qr,val);
	Insert(i*2+1,mid+1,r,ql,qr,val);
}
LL Ask(int k)
{
	int pos=Query(1,1,lcnt,k);
	if(pos!=0)
		return f[pos]+(lsh[l[pos]]-lsh[k]+K)%K;
	return 0;
}
int main()
{
	scanf("%d %lld",&N,&K);
	for(int i=1;i<=N;i++)
	{
		scanf("%lld %d",&a[i],&b[i]);
		s[i]=s[i-1]+a[i];
		if(b[i]==2)
			l[i]=0,r[i]=K-1LL;
		else
			l[i]=(K-2LL*s[i-1]%K)%K,r[i]=(K-2LL*s[i]%K)%K;
		if(b[i]==1&&a[i]*2LL>K)
		{
			printf("-1\n");
			return 0;
		}
		lsh[++lcnt]=l[i],lsh[++lcnt]=r[i];
	}
	sort(lsh+1,lsh+1+lcnt);
	lcnt=unique(lsh+1,lsh+1+lcnt)-lsh-1;
	for(int i=1;i<=N;i++)
	{
		l[i]=lower_bound(lsh+1,lsh+1+lcnt,l[i])-lsh;
		r[i]=lower_bound(lsh+1,lsh+1+lcnt,r[i])-lsh;
	}
	for(int i=N;i>=1;i--)
	{
		f[i]=Ask(l[i]);
		if(l[i]>r[i])
			Insert(1,1,lcnt,r[i]+1,l[i]-1,i);
		else
			Insert(1,1,lcnt,1,l[i]-1,i),Insert(1,1,lcnt,r[i]+1,lcnt,i);
	}
	LL ans=f[1];
	for(int i=1;i<=lcnt;i++)
		ans=min(ans,Ask(i));
	printf("%lld\n",ans+2LL*s[N]);
	return 0;
}

Measured memory_bytes: 13824
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	string str;
	while(cin>>str){
		int i;
		bool x=false,y;
		for(i=0;i<=9;i++){
			int a=0,b=0,c=0;
			int j;
			y=true;
			for(j=0;str[j]!='+';j++){
				if(str[j]=='X'){
					a=a*10+i;
					if(i==0&&j==0&&str[j+1]!='+')y=false;
				}else{
					a=a*10+str[j]-'0';
				}
			}
			j++;
			for(;str[j]!='=';j++){
				if(str[j]=='X'){
					b=b*10+i;
					if(i==0&&str[j-1]=='+'&&str[j+1]!='=')y=false;
				}else{
					b=b*10+str[j]-'0';
				}
			}
			j++;
			for(;j<str.size();j++){
				if(str[j]=='X'){
					c=c*10+i;
					if(i==0&&str[j-1]=='='&&j!=str.size()-1)y=false;
				}else{
					c=c*10+str[j]-'0';
				}
			}
			if(y&&a+b==c){
				cout<<i<<endl;
				x=true;
			}
		}
		if(!x)cout<<"NA\n";
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  for(int p = 0; p < (b+1)*10; p++) {
  	if(floor(p * 0.08) == a && floor(p * 0.10) == b) {
     	cout << p << endl;
        return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

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

void call(int n){
  int i = 1;
 CHECK_NUM:
 //for(;i<=n;i++)
  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;
}

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


Measured memory_bytes: 3088
n,m = map(int,input().split())
py = [list(map(int,input().split())) + [_] for _ in range(m)]
py.sort()
result = ['' for _ in range(m)] #ここで先にリストを作るから後から飛び飛びのインデックス指定で値を埋めていける

a = 1 #県のインデックスを表す変数
b = 1 #市の県の中でのインデックスを表す変数
for i in range(m):
    if py[i][0] != a:
        b=1
        a = py[i][0] 
        result[py[i][2]] = str(a).zfill(6) + str(b).zfill(6)
        b+=1
    else:
        result[py[i][2]] = str(a).zfill(6) + str(b).zfill(6)
        b+=1

for i in range(m):
    print(result[i])



Measured memory_bytes: 32000
MOD = 10 ** 9 + 7
fac = [1] * (10 ** 5 * 3)


def nCr(n, r):
    return fac[n] * pow(fac[n - r], MOD - 2, MOD) * pow(fac[r], MOD - 2, MOD) % MOD


for i in range(len(fac) - 1):
    fac[i + 1] = fac[i] * (i + 1) % MOD
b, w = map(int, input().split())
n = b + w
p = [0] * n
q = [0] * n
for i in range(b, n):
    p[i] = (p[i - 1] + nCr(i - 1, b - 1) *
            pow(pow(2, i, MOD), MOD - 2, MOD)) % MOD
for i in range(w, n):
    q[i] = (q[i - 1] + nCr(i - 1, w - 1) *
            pow(pow(2, i, MOD), MOD - 2, MOD)) % MOD
t = pow(2, MOD - 2, MOD)
for i in range(n):
    print((q[i] + (1 - p[i] - q[i]) * t) % MOD)


Measured memory_bytes: 79896
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
T[] Reads(T)() { return readln.split.to!(T[]); }

void main() {
    int n, x; readf("%d %d\n", &n,&x);
    long[] l = Reads!(long);
    long d;
    int ans = d <= x;
    foreach (li ; l) {
        d = d + li;
        ans += d <= x;
    }
    writeln(ans);
}

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

using namespace std;

long long factorial(int n) {

	return (n > 0 ? n*factorial(n - 1) : 1);

}

int main() {
	int  n;
	scanf("%d", &n);
	
	printf("%lld\n", factorial(n));

	return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

char c[5] = {'M','A','R','C','H'};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  map<char,int32> mp;
  REP(i,n){
    string s;
    cin >> s;
    mp[s[0]]++;
  }
  //  S : subset of N & #S = k
  //      nCk
  int64 ans = 0;
  for(int s = (1 << 3) - 1; s < (1 << 5); ){
      // cout << bitset<10>(s) << endl;
      int64 cnt = 1;
      REP(i,5){
        if((s >> i) & 1)cnt *= mp[c[i]];
      }
      ans += cnt;
      int t = s | (s - 1);
      s = (t + 1) | (((~t & - ~t) - 1) >> (__builtin_ctz(s) + 1));
  }
  ANS(ans);
  return 0;
}

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

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

Measured memory_bytes: 128
N = int(input())
T = [int(input()) for i in range(N)]
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(a, b):
    return a * b // gcd (a, b)
res = [1]
for t in T:
    res.append(lcm(t, res[-1]))
print(res[-1])

Measured memory_bytes: 3064
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		char[] oct = {'0', '1', '2', '3', '5', '7', '8', '9'};
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int n = stdIn.nextInt();
			if(n == 0)
			{
				break;
			}
			List<Character> list = new ArrayList<Character>();
			while(n != 0)
			{
				list.add(oct[n % 8]);
				n /= 8;
			}
			for(int i = list.size() - 1; i >= 0; --i)
			{
				System.out.print(list.get(i));
			}
			System.out.println("");
		}
	}
}

Measured memory_bytes: 13000
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<cmath>
#include<stack>
#include<vector>
#include<cstdio>
#define MAXN 33000
#define INF 0x3f3f3f3f
#define lmid l,m,rt<<1
#define rmid m+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define Mod 1000000007
#define i64 __int64
#define LIMIT_ULL 100000000000000000
#define LL long long
using namespace std;
int main()
{
     int n;
     scanf("%d",&n);
     int a[5];
     int cnt=0;
     while(n)
     {
          a[cnt++]=n%10;
          n/=10;
     }
     if(a[0]==a[2])
     {
          cout<<"Yes"<<endl;
          return 0;
     }
     else
     {
          cout<<"No"<<endl;
          return 0;
     }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

Graph G;
int N, M;
bool dfs(int k = 0, int par = -1, int cnt = 0) {
	if (cnt == 2)return k == N - 1;
	bool is = false;
	for (auto p : G[k]) {
		if (p == par)continue;
		if (dfs(p, k, cnt + 1)) {
			is = true;
		}
	}
	return is;
}

int main() {
	init();

	cin >> N >> M;
	G.resize(N);
	rep(i, M) {
		int a, b; cin >> a >> b;
		--a; --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	if (dfs())puts("POSSIBLE");
	else puts("IMPOSSIBLE");


	return 0;
}

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

using lli = long long;
using pii = pair<int, int>;
using pll = pair<lli, lli>;
template <typename T>
using Vector = vector<vector<T>>;
template <typename T>
using Prior = priority_queue<T>;
template <typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;

#define IOS() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define X first
#define Y second
#define Push push_back
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()

const lli mod = 1E9 + 7;

void solve() {
	int n;
	string s;
	cin >> n >> s;

	if (n & 1) {
		cout << "No\n";
		return;
	}

	if (s.substr(0, n/2) == s.substr(n/2, n/2)) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}

int main() {
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    res = B[A[0] - 1]
    for i, a in enumerate(A[1:]):
        res += B[a - 1]
        if A[i] + 1 == a:
            res += C[A[i] - 1]
    # a = sum([B[i - 1] for i in A])
    # c = sum([C[i - 1] for i, j in zip(A[:-1], A[1:]) if i == j - 1])
    print(res)


if __name__ == "__main__":
    main()


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

int main(){
  int N;
  cin >> N;
  int h[N+1];
  for(int i=0; i<N; i++) cin >> h[i];
  h[N]=0;
  int ans=0;
  for(int i=0; i<N; i++){
    if(h[i]>h[i+1]){
      ans+= h[i]-h[i+1];
    }
    else ans=ans;
  }
  cout << ans << endl;
}

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

int main(){

  string alp = "abcdefghijklmnopqrstuvwxyz";

  char C = 'a';

  cin >> C;

  for (int i = 0; i < 26; i++) {
    if (alp[i] == C) {
      cout << alp[i + 1] << 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++)
int a[114514]; int n;
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	int ans = 0;
	rep(i, n) {
		if (a[i] % 2 == 1)ans++;
	}
	if (ans % 2 == 1)puts("NO");
	else puts("YES");
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;

typedef pair <int, int> pii;
const int N = 3e3 + 5;
const long long INF = 1e18;
const int mod = 998244353;//786433;//998244353;
const double Pi = acos(-1);

 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n, m;
queue <pair <int, int> > BFS;
int Dist[1005][1005];
char a[1005][1005];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int main()
{
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m; j++)
		{
			Dist[i][j] = 1000000;
			cin >> a[i][j];
			if(a[i][j] == '#')
			{
				Dist[i][j] = 0;
				BFS.push(mp(i, j));
			}
		}
	}
	while(BFS.empty() == false)
	{
		int x = BFS.front().fi, y = BFS.front().se;
		BFS.pop();
		for(int i = 0; i < 4; i++)
		{
			if(Dist[x + dx[i]][y + dy[i]] > Dist[x][y] + 1)
			{
				Dist[x + dx[i]][y + dy[i]] = Dist[x][y] + 1;
				BFS.push(mp(x + dx[i], y + dy[i]));
			}
		}
	}
	int t = 0;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m; j++)
		{
			t = max(t, Dist[i][j]);
		}
	}
	cout << t;
}

Measured memory_bytes: 13328
#include <bits/stdc++.h>
using namespace std;
#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
	#endif
}

int32_t main()
{
	fastIO
	inp_out();
	int n, k; 
	cin >> n >> k; 
	vi a(n); 
	for(int i = 0; i < n;  ++ i)
	cin >> a[i]; 
	sort(a.begin(), a.end());
	int ans = 0;  
	for(int i = 0; i < k;  ++ i)
		ans += a[i];
	cout << ans;   
	return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
int N,T,A,X;
int main()
{
  scanf("%d%d%d",&N,&T,&A);
  int res = 0;
  int cc=1000000;
  for(int i=1;i<=N;++i)
  {
    scanf("%d",&X);
    int d = (T*1000-X*6)-A*1000;
    if(d<0) d=-d;
    if(cc>d) cc=d,res=i;
  }
  printf("%d\n",res);
}

Measured memory_bytes: 128
#include <stdlib.h>
#include <stdio.h>




void mergeSort(int numbers[], int temp[], int array_size);
void m_sort(int numbers[], int temp[], int left, int right);
void merge(int numbers[], int temp[], int left, int mid, int right);

int numbers[500000];
int temp[500000];
int cnt=0;

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

	
	mergeSort(numbers, temp, n);

	for (i = 0; i < n; i++){
	if(i){
	printf(" ");
	}
	printf("%d", numbers[i]);
	}
	printf("\n%d\n", cnt);
	
	return 0;
}


void mergeSort(int numbers[], int temp[], int array_size)
{
  m_sort(numbers, temp, 0, array_size - 1);
}



void m_sort(int numbers[], int temp[], int left, int right)
{
  int mid;

  if (right > left)
  {
    mid = (right + left) / 2;
    m_sort(numbers, temp, left, mid);
    m_sort(numbers, temp, mid+1, right);

    merge(numbers, temp, left, mid+1, right);
  }
}


void merge(int numbers[], int temp[], int left, int mid, int right)
{
  int i, end_left, num_elements, tmp_pos;

  end_left = mid - 1;
  tmp_pos = left;
  num_elements = right - left + 1;

  while ((left <= end_left) && (mid <= right))
  {
    if (numbers[left] <= numbers[mid])
    {
      temp[tmp_pos] = numbers[left];
      tmp_pos = tmp_pos + 1;
      left = left +1;
    	cnt++;
    }
    else
    {
      temp[tmp_pos] = numbers[mid];
      tmp_pos = tmp_pos + 1;
      mid = mid + 1;
    	cnt++;
    }
  }

  while (left <= end_left)
  {
    temp[tmp_pos] = numbers[left];
    left = left + 1;
    tmp_pos = tmp_pos + 1;
  	cnt++;
  }
  while (mid <= right)
  {
    temp[tmp_pos] = numbers[mid];
    mid = mid + 1;
    tmp_pos = tmp_pos + 1;
  	cnt++;
  }

  for (i=0; i <= num_elements; i++)
  {
    numbers[right] = temp[right];
    right = right - 1;
  }
}


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

int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; i++) {
        cin >> H.at(i);
    }
    if (N < 2) {
        cout << "Yes" << endl;
        return 0;
    }
    for (int i = N-2; i >= 0; i--) {
        if (H.at(i) > H.at(i + 1)) {
            H.at(i) = H.at(i) - 1;
        }
    }
    int A = 0;
    for (int i = N-2; i >= 0; i--) {
        if (H.at(i) > H.at(i + 1)) {
            A++;
        }
    }
    if (A != 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

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

int main()
{
	int area[10] = {0};
	
	while (scanf("%d", area) != EOF){
		int i;
		int n;
		int v[2];
		int min = *area;
		int sum = *area;
		int current[2];
		int point;
		
		for (i = 1; i < 10; i++){
			scanf(",%d", area + i);
			sum += area[i];
			if (min > area[i]) min = area[i];
		}
		scanf(",%d,%d", v, v + 1);
		for (n = 1; sum * n % (v[0] + v[1]) != 0; n++);
		sum *= n;
		
		for (current[0] = 0, current[1] = sum; current[0] < current[1];){
			current[0] += v[0];
			current[1] -= v[1];
		}
		for (i = point = 0; point < current[0]; i++) point += area[i] * n;
		printf("%d\n", i);
	}
	
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, M, K;
    cin >> N >> M >> K;
    vector<ll> A(N);
    vector<vector<ll>> dp(K, vector<ll>(N, 0));
    rep(i, N) {
        cin >> A[i];
    }
    dp[0] = A;
    rep(i, 1, K) {
        deque<int> dq;
        rep(j, i) {
            while(!dq.empty() && dp[i - 1][dq.back()] < dp[i - 1][j]) {
                dq.pop_back();
            }
            dq.push_back(j);
        }
        rep(j, i, N) {
            dp[i][j] = dp[i - 1][dq.front()] + A[j] * (i + 1);
            while(!dq.empty() && dp[i - 1][dq.back()] < dp[i - 1][j]) {
                dq.pop_back();
            }
            dq.push_back(j);
            while(!dq.empty() && j - dq.front() >= M) dq.pop_front();
            
        }
    }
    
    ll ans = 0;
    rep(i, N) {
        ans = max(ans, dp[K - 1][i]);
    }
    output(ans);
    return 0;
}


Measured memory_bytes: 237056
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
typedef vector<ll> vl;
typedef vector<ull> vul;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<ll>> vvl;
typedef vector<vector<string>> vvs;
typedef vector<vector<ull>> vvul;
typedef vector<bool> vb;
const ll md = 1000000007;

ll add(ll a, ll b, ll mod = md) {
    return (a%mod + b%mod + mod)%mod;
}

ll mul(ll a, ll b, ll mod = md) {
    return (a%mod * b%mod)%mod;
}

ll fn(ll st, ll d, ll tm, ll mod = md) {
    ll res = 1, x = d%mod;
    ll ans = 0;
    while(tm) {
        if(tm&1) ans = (x*ans + res)%mod;
        res = ((res*x)%mod + res%mod)%mod;
        x = (x*x)%mod;
        tm = tm/2;
    }
    ans = (ans*st)%mod;
    return ans;
}

ll C(vl &fact, vl &invfact, ll n, ll r) {
    if(r == 0) return 1;
    ll num = fact[n];
    ll den = mul(invfact[r], invfact[n-r]);
    return mul(num, den);
}

ll mulm(ll a, ll b, ll mod = md) {
    ll r = 0;
    a %= mod;
    while (b) {
        if (b & 1) r = (r+a)%mod;
        a = (a+a)%mod;
        b = b/2;
    }
    r %= mod;
    return r;
}

ll power(ll x, ll n, ll mod = md) {
    ll res = 1;
    x %= mod;
    while (n) {
        if (n & 1)  res = (res*x)%mod;
        n = n/2;
        x = (x*x)%mod;
    }
    return res;
}

ll power2(ll x, ll n) {
    ll res = 1;
    while (n) {  
        if (n & 1) res = (res*x);
        n = n/2;
        x = (x*x);
    }  
    return res;
}

bool is_prime(ll x) {
    if(x == 1 || x == 0) return false;
    for(int i=2; i*i <= x; i++) {
        if(x%i == 0) return false;
    }
    return true;
}

ll compgcd(ll n, vector<ll> const &primes) { 
    ll res = n; 
    for (ll i=0; primes[i]*primes[i] <= n; i++) {
        if (n % primes[i]== 0) { 
            res -= (res / primes[i]); 
            while (n%primes[i]== 0) {
               n/=primes[i]; 
            }
        } 
    } 
    if (n > 1) {
       res -= (res / n); 
    }
    return res; 
}

void sieve(vector<bool> &prime, vector<ll> &primes, ll lim) {
    for(int i = 2; i*i <= lim; i++) {
        if(prime[i]) {
            for(int j = 2; j*i <= lim; j++) {
                prime[j*i] = false;
            }
        }
    }
    for(int i = 2; i <= lim; i++) {
        if(prime[i]) {
            primes.push_back(i);
        }
    }
}

void sieveGCD(ll lim, vector<ll> &tab, vector<ll> const &primes) {
    for(int  i = 1; i <= lim; i++) {
        tab[i] = i;
    }
    for(int i = 0; i<primes.size() && primes[i] <= lim; i++) {
        tab[primes[i]] = primes[i]-1;
        for(int j = 2; primes[i]*j <= lim; j++) {
            tab[primes[i]*j] = (tab[primes[i]*j]/primes[i])*(primes[i]-1);
        }
    }
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	vector<ll> a(n), b(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	if(n&1) {
		cout << (b[(n/2)] - a[(n/2)] + 1) << "\n";
	} else {
		cout << (b[(n/2)-1] + b[(n/2)]) - (a[(n/2)-1] + a[(n/2)]) + 1 << "\n";
	}
	return 0;
}

Measured memory_bytes: 6368
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
char in[210];

int main(){
	scanf("%s",in);
	int n=strlen(in);
	for(int i=0;i<n;i++)in[i+n]=in[i];
	int a;scanf("%d",&a);
	long long ret=0;
	bool chk=true;
	for(int i=1;i<n;i++){
		if(in[i]!=in[i-1])chk=false;
	}
	if(chk){
		printf("%lld\n",(long long)n*a/2);return 0;
	}
	if(in[0]==in[n-1]){
		int ren=0;
		for(int i=0;i<n;i++){
			if(in[i]==in[0])ren++;
			else break;
		}
		ret+=ren/2;
		int ren2=0;
		for(int i=n-1;i>=0;i--){
			if(in[i]==in[0])ren2++;
			else break;
		}
		ret+=ren2/2;
		int t=ren+ren2;
		ret+=(long long)(t/2)*(a-1);
	}
	int f=0;
	for(int i=0;i<n;i++){
		if(i==0||in[i]==in[i-1])f++;
		else{
			if(i!=f||in[0]!=in[n-1]){
				ret+=(long long)f/2*a;
			}
			f=1;
		}
	}
	if(in[0]!=in[n-1])ret+=(long long)f/2*a;
	printf("%lld\n",ret);
}

Measured memory_bytes: 128
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
using ll = long long;

using namespace std;
int main()
{/*三日目*/
//少数も使いたい割り算はしない方がいい(三日目）
// 数値の大きさ
	int n;cin >> n;
	bool ok=true;
	for(int i = 0; i < n;i++) {
		int a;cin >> a;
		if (a % 2 == 0) {
			if (a % 3 == 0 or a % 5 == 0)
				ok = true;
			else {
				ok = false;
				break;
			}
		}
	}if (ok)
		cout << "APPROVED";
	else
		cout << "DENIED";
	

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>

#define A_P(n,a,d) (n/2)*(2*a + (n-1)*d)
using namespace std;


int main(void){
    int N,T;
    cin >> N;
    map<int,int> prob;
    for(int i =0; i < N; i++){
        int tmp;
        cin >> tmp;
        prob[tmp]++;
    }

    cin >> T;
    for(int i = 0; i < T; i++){
        int tmp;
        cin >> tmp;
        if(prob[tmp] > 0){
            prob[tmp]--;
        }else{
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 12980
//#include"cpp_kyopro.h"
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main() {
	int a, b,c; cin >> a >> b;
	c = max(max(a + b, a - b), a * b);
	//c = max(a + b, a - b, a * b);

	cout << c << endl;


	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <climits>
#include <string>
#include <set>
#include <cmath>
#include <map>
#include <unordered_map>
#include <numeric>
#include <random>
#include <memory>
#include <chrono>
#include <functional>
#include <unordered_set>
#include <cstring>
#include <cassert>
#include <bitset>
#ifdef LOCAL
#include "debug.h"
#else
#define debug(x...)
#endif

//#define int ll
//#pragma GCC optimize("Ofast")

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define sz(x) int((x).size())

#ifdef ONLINE_JUDGE
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#else
mt19937 rng(228);
#endif

const int N = 2e6 + 7;
const int inf = INT_MAX / 2;
const ll INF = LLONG_MAX / 3;
//const int MOD = 998244353;
const int MOD = 1e9 + 7;
const ld eps = 1e-6;
const pii dir[] = { { 0, 1 }, { 0, -1 }, { 1, 0 }, { -1, 0 } };


signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cout << fixed << setprecision(9);
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    int n;
    cin >> n;

    cout << (1000 - n % 1000) % 1000;
    
    return 0;
}

Measured memory_bytes: 3668
X = list(map(int,input().split(' ')))
A = [X[1]+X[2]-X[3], -X[0]+X[2]+X[3], X[0]+X[1]-X[3], -X[0]+X[1]+X[2]]
print(str(X[1]+X[2]-X[3])+' '+str(-X[0]+X[2]+X[3])+' '+str(X[0]+X[1]-X[3])+' '+str(-X[0]+X[1]+X[2]))

Measured memory_bytes: 3064
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int K, T;
int a[100];

int main(int argc, char **argv) {
	cin >> K >> T;
	REP(i, T) cin >> a[i];
	sort(a, a + T);
	int m = (K + 1) / 2;
	if (a[T - 1] <= m) {
		cout << 0 << endl;
	}
	else {
		cout << ((a[T - 1] - m) * 2 - 1 - K % 2) << endl;
	}
	return 0;
}


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

const int mod = 1'000'000'007;


struct mint {
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}

  mint operator-() const { return mint(-x); }

  mint &operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }

  mint &operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }

  mint &operator*=(const mint a) {
    (x *= a.x) %= mod;
    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 pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }

  mint &operator/=(const mint a) { return *this *= a.inv(); }

  mint operator/(const mint a) const { return mint(*this) /= a; }
};

istream &operator>>(istream &is, mint &a) { return is >> a.x; }

ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a.at(i);
  mint aSum;
  rep(i, n) {
    aSum += a.at(i);
  }
  mint aSum2 = aSum * aSum;
  mint bSum;
  rep(i, n) {
    bSum += a.at(i) * a.at(i) % mod;
  }
  mint res = (aSum2 - bSum) / 2;
  cout << res.x << endl;
  return 0;
}


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

const int64_t MOD = 1e9+7;
void add_mod(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}

template<typename T>
struct BIT {
    int n;
    vector<T> dat;

    BIT(int n=0):n(n){
        initialize(n);
    }

    void initialize(int n){
        dat.resize(n);
        for(int i = 0; i<n; i++) dat[i] = 0;
    }

    T sum(int i){
        T s = 0;
        while(i >= 0){
            add_mod(s, dat[i]);
            i = (i & (i+1)) - 1;
        }
        return s;
    }

    void add(int i, T x){
        while(i < n){
            add_mod(dat[i], x);
            i |= i+1;
        }
    }
};

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> X(N), Y(M);
    for(int i=0; i<N; i++) cin >> X[i];
    for(int i=0; i<M; i++) cin >> Y[i];

    vector<pair<int, int>> pts;
    vector<int> ys = {0};
    for(int i=0, j=0; i<N; i++){
        if(X[i] < Y[0] || Y[M-1] < X[i]) continue;
        while(Y[j] < X[i]) j++;
        pts.push_back({X[i]-Y[j-1], -(Y[j]-X[i])});
        ys.push_back(Y[j]-X[i]);
    }
    if(pts.size() == 0){
        cout << 1 << endl;
        return 0;
    }

    sort(pts.begin(), pts.end());
    sort(ys.begin(), ys.end());
    pts.erase(unique(pts.begin(), pts.end()), pts.end());
    ys.erase(unique(ys.begin(), ys.end()), ys.end());

    BIT<int64_t> bit(ys.size());
    bit.add(0, 1);

    for(auto p : pts){
        int y = -p.second;
        int i = lower_bound(ys.begin(), ys.end(), y) - ys.begin();
        if(i > 0) bit.add(i, bit.sum(i-1));
    }
    cout << bit.sum(ys.size()-1) << endl;
    return 0;
}

Measured memory_bytes: 2800
#include <bits/stdc++.h>
using namespace std;
int minimumChar(string S1, string S2)
{
	int n = S1.size(), m = S2.size();
	int ans = INT_MAX;
	for (int i = 0; i < m - n + 1; i++) {
		int minRemovedChar = 0;
		for (int j = 0; j < n; j++) {
			if (S1[j] != S2[i + j]) {
				minRemovedChar++;
			}
		}
		ans = min(minRemovedChar, ans);
	}
	return ans;
}
int main()
{
	string s,ss;
	cin>>s>>ss;
	cout<<minimumChar(ss,s)<<endl;
	return 0;
}


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

int main(void) {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
while True:
    a, op, b = map(str, input().split())

    if op == '+':
        print(int(a) + int(b))
    elif op == '-':
        print(int(a) - int(b))
    elif op == '*':
        print(int(a) * int(b))
    elif op == '/':
        print(int(a) // int(b))
    else:
        break
    


Measured memory_bytes: 5596
S = input()
S1 = int(S[:2])
S2 = int(S[2:])
b1,b2 = False,False
if 1 <= S1 <= 12:
    b1 = True
if 1 <= S2 <= 12:
    b2 = True
print('AMBIGUOUS' if b1 and b2 else 'YYMM' if b2 else 'MMYY' if b1 else 'NA')

Measured memory_bytes: 3060
N, M = map(int, input().split())
A = [None] * M
K = [None] * M
INF = 10 ** 7
dp = [INF] * (2 ** N)
dp[0] = 0
for i in range(M):
    a, b = map(int, input().split())
    k = sum([2 ** (i - 1) for i in map(int, input().split())])
    for j in range(2 ** N):
        dp[j | k] = min(dp[j | k], dp[j] + a)

ans = dp[2 ** N - 1] if dp[2 ** N - 1] < INF else -1
print(ans)


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

using namespace std;
using namespace atcoder;

int main(){
  int N, M;
  cin >> N >> M;
  dsu D(N);
  for(int i=0; i<M; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    D.merge(a,b);
  }
  
  int cnt = 0;
  for(int i=0; i<N; i++){
    if(i == D.leader(i)){
      cnt++;
    }
  }
  
  cout << cnt - 1 << endl;
  
}
  

Measured memory_bytes: 3812
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
  
  

int main(){
    ll a,b,k;
    cin>>a>>b>>k;
        
    if(k >= a+b)cout<<0<<" "<<0<<endl;
    else if(a-k < 0)cout<<0<<" "<<b-(k-a)<<endl;
    else cout<<a-k<<" "<<b<<endl;
  
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;

static const int MAX = 200000;
static const int SENTINEL = 2000000000;
int n, *a, L[MAX/2 + 2], R[MAX/2 + 2];
long long ans;

void merge(int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    for(int i=0; i<n1; ++i) L[i] = a[left + i];
    for(int i=0; i<n2; ++i) R[i] = a[mid + i];
    L[n1] = SENTINEL; R[n2] = SENTINEL;

    int i=0, j=0, k=left;
    while(k < right){
        if(L[i] <= R[j]){
            a[k++] = L[i++];
        }
        else{
            a[k++] = R[j++];
            ans += n1 - i;
        }
    }
}

void mergeSort(int left, int right){
    if(left + 1 < right){
        int mid = (left + right)/2;
        mergeSort(left, mid);
        mergeSort(mid, right);
        merge(left, mid, right);
    }
}

int main(){
    scanf("%d", &n);
    a = new int[n];
    for(int i=0; i<n; ++i){ scanf("%d", &a[i]); }

    mergeSort(0, n);
    delete[] a;

    printf("%lld\n", ans);
}



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


int main(){

    int n;
    cin >> n;

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

    int res = 0;

    while(true){
        int start, end;
        for(start=0; start<n; start++){
            if(h[start] != 0){
                break;
            }
        }

        if(start == n){
            break;
        }

        for(end = start; end < n; end++){
            if(h[end] == 0){
                end--;
                break;
            }
        }

        for(int i=start; i<=end; i++){
            h[i]--;
        }

        res ++;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
n,m,x,*book=map(int,open(0).read().split())
ans=10**10

for i in range(2**n):
    j=i
    k=0
    cur=0
    curskill=[0]*m
    while j>0:
        if j&1:
            cur+=book[k*(m+1)]
            for l in range(1,m+1):
                curskill[l-1]+=book[k*(m+1)+l]
        j=j>>1
        k+=1
    
    for j in range(m):
        if curskill[j]<x:
            break
    else:
        ans=min(ans,cur)

if ans==10**10:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 74040
#include <bits/stdc++.h> // {{{
// clang-format off
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define pb emplace_back
#define em emplace
#define fi first
#define se second
#define USE1(...) template <typename __VA_ARGS__> inline
#define USE2(T, ...) USE1(T, typename __VA_ARGS__)
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
 
using ll = long long;
template<typename T> using vec = std::vector<T>;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE2(T=int,V=vec<T>)V reserved(int n){V v;v.reserve(n);return v;}
USE1(T=int)vec<T>in(int n){auto v=reserved<T>(n);rep(i,n)v.pb(in<T>());return v;}
USE2(T,U=std::pair<T,int>)vec<U>enume(const vec<T>&x,int s=0){int N=x.size();auto v=reserved<U>(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE2(T,U)void prif(bool b,T t,U f){if(b)pr(t);else pr(f);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(20);
    std::cout.setf(std::ios::fixed);
  }
} iosetup; //}}}
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

signed main() {
  int A = in(), B = in();
  pr((A + B) % 24);
  return 0;
}


Measured memory_bytes: 256