akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;

namespace ALDS1_14_D
{
	class SuffixArray
	{
		internal int[] sa, rank, tmp;
		internal string S;
		internal int n, k;
		
		public SuffixArray(string SS)
		{
			S = SS;
			n = S.Length;
			sa = new int[n + 1];
			rank = new int[n + 1];
			tmp = new int[n + 1];
			Construct_SA();
		}
		
		public int Compare_SA(int i, int j)
		{
			if(rank[i] != rank[j]) return rank[i] - rank[j];
			
			int ri = i + k  <= n ? rank[i + k] : -1;
			int rj = j + k <= n ? rank[j + k] : -1;

			return  ri - rj; 
		}
		
		public void Construct_SA()
		{
			for(int i = 0; i < n; i++)
			{
				sa[i] = i;
				rank[i] = S[i];
			}
			sa[n] = n; rank[n] = -1;
			
			for(k = 1; k <= n; k*= 2)
			{
				Array.Sort(sa, Compare_SA);
                
                int d;
                d = tmp[sa[0]] = 0;
                for (int i = 1; i <= n; i++)
                {
                    d = tmp[sa[i]] = d + ((Compare_SA(sa[i - 1], sa[i]) < 0) ? 1 : 0);
                }
                for (int i = 0; i <= n; i++)
                {
                    rank[i] = tmp[i];
                }
 
			}
		}
		
		public string Contains(string pattern)
		{
			int l = 1, r = n + 1;
			int pl = pattern.Length;
			
			while(l < r)
			{
				int m = (l + r) / 2;
				
				string subStr = (sa[m] + pl > n) ? S.Substring(sa[m]) : S.Substring(sa[m], pl);
                    
                int comp = subStr.CompareTo(pattern);
                if (comp == 0) return "1";
                
                if (comp < 0) l = m + 1;
                else r = m;
			}
			return "0";
		}
	}
	
	
    class Program
    {
    	
        static void Main(string[] args)
        {
        	var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    	 	Console.SetOut(sw);
    	 
        	var T = Console.ReadLine();
        	
            var SA = new SuffixArray(T);

 
            var Q = int.Parse(Console.ReadLine());
 
            for (int i = 0; i < Q; i++)
            {
                var P = Console.ReadLine();
 
                Console.WriteLine(SA.Contains(P));
            }
            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 33472
import sys  
import numpy as np

input = sys.stdin.readline
N, M= map(int, input().split())
AB = []
for i in range(N):
    a, b = list(map(int, input().split()))
    AB.append([a, b])

CD = []
for i in range(M):
    c, d = list(map(int, input().split()))
    CD.append([c, d])


for i in range(N):
    leng = []
    for j in range(M):
        temp = abs(AB[i][0]-CD[j][0]) + abs(AB[i][1]-CD[j][1])
        leng.append(temp)
    for k in range(len(leng)):
        if leng[k] == min(leng):
            print(k+1)
            break

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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int A[2200];
pint Ai[2200];
int dp[2200][2200];
int dfs(int l, int r) {
    int k = N - 1 - (r - l);
    if (k == N) { return 0; }
    if (dp[l][r] > 0) { return dp[l][r]; }
    return dp[l][r] = max(dfs(l + 1, r) + Ai[k].first * abs(Ai[k].second - l),
                          dfs(l, r - 1) + Ai[k].first * abs(Ai[k].second - r));
}
signed main() {
    cin >> N;
    rep(i, N) {
        cin >> A[i];
        Ai[i] = {A[i], i};
    }
    sort(Ai, Ai + N), reverse(Ai, Ai + N);
    cout << dfs(0, N - 1) << endl;
}


Measured memory_bytes: 26964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main()
{
    int h, w;
    cin >> h >> w;
    char s[h + 2][w + 2];
    rep(i, 0, h + 2) {
        rep(j, 0, w + 2) {
            s[i][j] = '.';
        }
    }
    rep(i, 1, h + 1) {
        rep(j, 1, w + 1) {
            cin >> s[i][j];
        }
    }

    rep(i, 1, h + 1) {
        rep(j, 1, w + 1) {
            if (s[i][j] == '#') {
                bool flag = false;
                for (int k = -1; k <= 1; k++) {
                    for (int l = -1; l <= 1; l++) {
                        if (abs(k) == abs(l)) continue;
                        if (s[i + k][j + l] == '#') flag = true;
                    }
                }
                if (!flag) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "Yes" << endl;
    return 0;

}


Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>

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

using namespace std;

struct menu{
	char name[21];
	int lim,t;
};

int n;
menu M[20];

bool cmp(int a,int b){
	return M[a].t>M[b].t || M[a].t==M[b].t && a<b;
}

int main(){
	for(int test=0,m;scanf("%d%d",&n,&m),n;test++){
		if(test>0) puts("");

		rep(i,n) scanf("%s%d%d",&M[i].name,&M[i].lim,&M[i].t);

		pair< int,vector<int> > order[100]; // <到着時刻,注文内容>
		rep(i,m){
			int k; scanf("%d%d",&order[i].first,&k);
			order[i].second.resize(k);
			rep(j,k){
				char name[21]; scanf("%s",name);
				rep(l,n) if(strcmp(name,M[l].name)==0) { order[i].second[j]=l; break; }
			}
			sort(order[i].second.begin(),order[i].second.end(),cmp);
		}

		int fin[100]={},ans[100];

		deque< pair<int,int> > wait; // <注文した人,調理待ちの料理>
		int cooking=0; // 今調理中かどうか
		priority_queue< pair<int,int> > Q; // <-time,event_type>
		rep(i,m) Q.push(make_pair(-order[i].first,i+1));
		while(!Q.empty()){
			int t=-Q.top().first,type=Q.top().second; Q.pop();

			// 来客
			if(type>0){
				type--;

				const vector<int> &O=order[type].second;
				rep(i,O.size()) wait.push_back(make_pair(type,O[i]));
			}
			// 料理ができた
			else{
				type*=-1;
				type--;

				fin[type]++;
				if(fin[type]==order[type].second.size()) ans[type]=t;
				cooking--;
			}

			if(cooking==0 && !wait.empty()){
				int a=wait.front().first,menuid=wait.front().second; wait.pop_front();
				Q.push(make_pair(-(t+M[menuid].t),-(a+1)));
				cooking++;

				int cnt=1;
				rep(i,wait.size()) if(wait[i].second==menuid && cnt<M[menuid].lim) {
					Q.push(make_pair(-(t+M[menuid].t),-(wait[i].first+1)));
					wait.erase(wait.begin()+i);
					i--;
					cnt++;
					cooking++;
				}
			}
		}

		rep(i,m) printf("%d\n",ans[i]);
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
ll a[10005];

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n;cin>>n;
  REP(i,n)cin>>a[i];
  ll cnt=0;
  REP(i,n){
    while(a[i]%2==0){
      a[i]/=2;
      cnt++;
    }
  }
  P(cnt);
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()




int main() {
    string s, t;
    cin >> s >> t;
    if (s.size() == t.size() - 1 && s == t.substr(0, t.size() - 1)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define inf 1e16
#define M 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define mx 1000010

int main(){
	IOS;
	ll n;cin>>n;ll a[n];
	ll pos=0,neg=0,zer=0,mn=M,sum=0;
	rep(i,0,n){
		cin>>a[i];
		if(a[i]>0)pos++;if(a[i]==0)zer++;if(a[i]<0)neg++;mn=min(mn,abs(a[i]));sum+=abs(a[i]);
	}
	if(neg&1)sum-=2*mn;
	cout<<sum;
	return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>

int main()
	{
	int N,L[100],t=0,max=0,i=0;
     
	scanf("%d",&N);

	for(i=0;i<N;i++)
		{
		scanf("%d",&L[i]);

		t=t+L[i];

		if(max<L[i])	max=L[i];
		}
	
		t=t-max;

		if(max<t)
			printf("Yes");
		else
			printf("No");

		return 0;
	}


Measured memory_bytes: 128
N=map(int, list(raw_input()))

len_N=len(N)
sum_result=0

not_list_nine=[i for i in N if i != 9]
num_nine=len_N - len(not_list_nine)

N_first=N[0]

if N_first==9:
  if num_nine==len_N: sum_result=sum(N)
  else: sum_result=(len_N-1)*9+8
else:
  if num_nine==len_N-1: sum_result=sum(N)
  else: sum_result=(N_first-1)+(len_N-1)*9

print sum_result


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

int main() {
    int x,y,z;
    cin>>x>>y>>z;

    int i=1;
    while(1){
        if((i*y+(i+1)*z)>x){
            cout<<i-1<<endl;
            return 0;
        }
        i++;
    }

}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int a,b,c,x;
    int count=0;
    int sum;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> x;
    for (int i=0;i<=a;i++){
        for (int j=0;j<=b;j++){
            for (int k=0;k<=c;k++){
                sum = 500*i + 100*j + 50*k;
                if (x==sum){
                    count++;
                }
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
a = list( map(int, input().split()))

me = sum(a)/n

for i in range(n):
    a[i]= abs(a[i]-me)

mia = min(a)
ans = a.index(mia)

print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
char m[11][10001];
char t[11][10001];
int R,C;
int count()
{
  int i,j,c,t=0;
  for(i=0;i<C;i++){
    c = 0;
    for(j=0;j<R;j++){
      if(m[j][i] == 0) c++;
    }
    if(R/2 >= c) t += R-c;
    else t += c;
  }
  return t;
}
int search(int n)
{
  int i,j;
  if(n==R) return count();
  i = search(n+1);
  memcpy(t[n],m[n],C);
  for(j=0;j<C;j++){
    m[n][j] = (m[n][j] == 1) ? 0 : 1;
  }
  j = search(n+1);
  memcpy(m[n],t[n],C);
  return i > j ? i : j;
}
int main()
{
  int i,j,k;
  for(;;){
    scanf("%d%d",&R,&C);
    if(R==0 && C==0) break;
    for(i=0;i<R;i++){
      for(j=0;j<C;j++){
	scanf("%d",&m[i][j]);
      }
      scanf("\n");
    }
    k = search(0);
    printf("%d\n",k);
  }
  return 0;
}

Measured memory_bytes: 620
#include<bits/stdc++.h>
#define mo 1000000007
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
long long n,i,j,x[200005],y[200005],max1,min1,sum,book[200005],flag,ans,min2,max2,top;
struct nyh{
	long long x,id;
}o[400005];
bool cmp(nyh u,nyh v){
	return u.x<v.x;
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	n=read();
	for(i=1;i<=n;i++){
		x[i]=read();
		y[i]=read();
	}
	for(i=1;i<=n;i++)
		if(x[i]>y[i])
			swap(x[i],y[i]);
	for(i=1;i<=n;i++)
		if(x[min1]>x[i]||min1==0)
			min1=i;
	for(i=1;i<=n;i++)
		if(y[max1]<y[i]||max1==0)
			max1=i;
	ans=1000000000000000000LL;
	if(max1!=min1){
		for(i=1;i<=n;i++){
			if(min1!=i){
				top++;
				o[top].x=x[i];
				o[top].id=i;
			}
			if(max1!=i){
				top++;
				o[top].x=y[i];
				o[top].id=i;
			}
		}
		sort(o+1,o+top+1,cmp);
		j=1;
		for(i=1;i<=top;i++){
			book[o[i].id]++;
			if(book[o[i].id]==1)
				sum++;
			while(sum==n){
				book[o[j].id]--;
				if(book[o[j].id]==0)
					sum--;
				flag=1;
				j++;
			}
			if(flag==1)
				ans=min(ans,(o[i].x-o[j-1].x)*(y[max1]-x[min1]));
		}
	}
			
	top=0;
	for(i=1;i<=n;i++)
		if(x[max2]<x[i]||max2==0)
			max2=i;
	for(i=1;i<=n;i++)
		if(y[min2]>y[i]||min2==0)
			min2=i;
	ans=min(ans,(x[max2]-x[min1])*(y[max1]-y[min2]));
	pus(ans,2);
	return 0;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

using Weight = int;
using Flow = int;
struct Edge {
    int s, d; Weight w; Flow c;
    Edge() {};
    Edge(int s, int d, Weight w = 1) : s(s), d(d), w(w), c(w) {};
};
bool operator<(const Edge &e1, const Edge &e2) { return e1.w < e2.w; }
bool operator>(const Edge &e1, const Edge &e2) { return e2 < e1; }
inline ostream &operator<<(ostream &os, const Edge &e) { return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')'); }

using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

void addArc(Graph &g, int s, int d, Weight w = 1) {
    g[s].emplace_back(s, d, w);
}
void addEdge(Graph &g, int a, int b, Weight w = 1) {
    addArc(g, a, b, w);
    addArc(g, b, a, w);
}

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

    int2(n, m);

    Graph g(n);

    vi mmn(n);

    rep(i, m) {
        int3(s, t, d);
        s--; t--;
        addArc(g, s, t, d);
        mmn[t]++;
    }

    vi topo;
    stack<int> funami;
    rep(i, n) if (!mmn[i]) funami.push(i);

    while (funami.size()) {
        int p = funami.top(); funami.pop();
        topo.pb(p);
        for (auto i : g[p]) {
            mmn[i.d]--;
            if (!mmn[i.d]) {
                funami.push(i.d);
            }
        }
    }

    if (topo.size() != n) {
        std::cout << "No" << std::endl;
        return 0;
    } else {
        map<int, int> mm;
        for (auto i : topo) {
            if (mm.find(i) == mm.end()) {
                mm[i] = 0;
            }
            for (auto j : g[i]) {
                if (mm.find(j.d) == mm.end()) {
                    mm[j.d] = mm[i] + j.w;
                } else if (mm[i] + j.w != mm[j.d]) {
                    std::cout << "No" << std::endl;
                    return 0;
                }
            }
        }
        for (auto i : mm) {
            //cout << i.sec << " ";
            if (i.sec > 1000000000) {
                std::cout << "No" << std::endl;
                return 0;
            }
        }
        std::cout << "Yes" << std::endl;
    }


    return 0;
}


Measured memory_bytes: 19316
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n = 0; lli x = 0ll, y = 0ll;
	cin >> n;
	lli a = -(lli)1e18, b = (lli)1e18;
	lli c = a, d = b;
	for (int i = 0; i < n; ++i)
	{
		cin >> x >> y;
		a = max(a, x + y); b = min(b, x + y);
		c = max(c, x - y); d = min(d, x - y);
	}
	cout << max(a - b, c - d) << endl;
}

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

int main() {
    // Input
    int n, k, sum = 0;
    cin >> n >> k;
    int p[n];
    for(int i = 0; i < n; i++) {
        cin >> p[i];
    }

    // Bubble sort
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n-1; j++) {
            if (p[j] > p[j+1]) {
                swap(p[j], p[j+1]);
            }
        }
    }

    // Output
    for(int i = 0; i < k; i++) {
        sum += p[i];
    }

    cout << sum << endl;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
#define INF 100000000
#define IINF 9999999999999;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

// 1

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

    int X;
    cin >> X;
    int a = X % 7;
    switch(a) {
        case 0: cout << "thu" << endl; break;
        case 1: cout << "fri" << endl; break;
        case 2: cout << "sat" << endl; break;
        case 3: cout << "sun" << endl; break;
        case 4: cout << "mon" << endl; break;
        case 5: cout << "tue" << endl; break;
        case 6: cout << "wed" << endl; break;
    }
}


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

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

int n;
int len, la[10010], to[10010];
string s;

int calc(int l, int r)
{
    ++l;
    if (s[l] >= '0' && s[l] <= '9') {
	int x = 0;
	for (int i = l; i < r; ++i) {
	    x = x * 10 + s[i] - '0';
	}
	return x / 2 + 1;   
    }

    vector<int> res;
    for (int i = l; i < r; ++i) {
	int nr = to[i];
	res.push_back(calc(i, nr));
	i = to[i];
    }

    sort(res.begin(), res.end());
    int sz = res.size() / 2 + 1;

    int t = 0;
    rep(i, sz) t += res[i];
    return t; 
}

int main() {
    cin >> n;
    rep(i, n) {
	cin >> s;
	len = s.size();
	
	int dep = 0;
	rep(j, len) {
	    if (s[j] == '[') la[dep++] = j;
	    else if (s[j] == ']') to[la[--dep]] = j;
	}
	cout << calc(0, len-1) << endl;
    }
    return 0;
}

Measured memory_bytes: 1324
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
const ll inf = 1LL<<60;

int main()
{
  int n; cin >> n;
  vector<int> p(n+1, 0);
  rep(i, n) cin >> p[i] >> p[i+1];
  vector<vector<ll>> dp(n+1, vector<ll>(n+1, inf));
  rep(i, n+1) dp[i][i] = 0;
  rep(i, n) dp[i][i+1] = 0;
  for (int len=2; len<=n; len++) {
    for (int left=0; left+len<=n; left++) {
      int right = left+len;
      dp[left][right] = inf;
      for (int i=left+1; i<right; i++) {
        dp[left][right] = min(dp[left][right], dp[left][i] + dp[i][right] + p[left]*p[i]*p[right]);
      }
    }
  }
  cout << dp[0][n] << endl;

  return 0;
}



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

typedef long long ll;
typedef pair<ll, ll> P;

int N, A, B;

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

    int ans = 0;
    for(int i=1;i<=N;i++){
        int res = 0, num = i;
        for(int j=0;j<5;j++){
            res += num % 10;
            num /= 10;
        }
        if(A <= res && res <= B)    ans += i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
// 明らかに最大のやつに引っ張られる
// それ以外のやつは最大のやつの合間にはさめばいいので、max(A)-1<=max(A)以外の合計、ならばいける
// いけない場合はmax(A)-1-max(A)以外の合計かな
package main

import "fmt"

var k, t int

func main() {
	fmt.Scan(&k, &t)
	max_a := -1
	for i := 0; i < t; i++ {
		var j int
		fmt.Scan(&j)
		if j > max_a {
			max_a = j
		}
	}
	sum := k - max_a
	if max_a-1 <= sum {
		fmt.Println(0)
	} else {
		fmt.Println(max_a - 1 - sum)
	}
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>

using namespace std;

const int inf = 10000000;

int main() {
  for (;;) {
    int n, m;
    cin >> n >> m;
    if (!n || !m) return 0;
    int d[100][100];
    bool t[100][100];
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        d[i][j] = (i == j ? 0 : inf);
    for (int i = 0; i < m; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      a--; b--;
      d[a][b] = d[b][a] = c;
    }
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        t[i][j] = false;
    for (int k = 0; k < n; k++)
      for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
          if (i != k && k != j && d[i][k] + d[k][j] < inf)
            t[i][j] = true;
    for (int k = 0; k < n; k++)
      for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    int result = d[0][n-1];
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        if (t[i][j])
          result = min(result, d[0][i] + d[j][n-1]);
    cout << result << endl;
  }
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
#define cs const
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define ll long long
#define bg begin
namespace IO{
	
cs int RLEN=1<<20|1;
char ibuf[RLEN],*ib,*ob;
inline char gc(){
	(ib==ob)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob)?EOF:*ib++;
}
inline int read(){
	char ch=gc();
	int res=0;bool f=1;
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
	return f?res:-res;
}
inline int readstring(char *s){
	int top=0;char ch=gc();
	while(isspace(ch))ch=gc();
	while(!isspace(ch)&&ch!=EOF)s[++top]=ch,ch=gc();
	return top;
}

}
using IO::read;
using IO::readstring;
template<typename tp>inline void chemx(tp &a,tp b){a=max(a,b);}
template<typename tp>inline void chemn(tp &a,tp b){a=min(a,b);}
cs int N=1000005,M=16;
int pw[M];
char str[N];
int n,m,tot,id[N],ans[N],lc[N],rc[N],pc[N],rev[N];
void build(int &u,int dep,int ps){
	u=++tot;
	if(dep==n){
		id[u]=ps;
		return;
	}
	build(lc[u],dep+1,ps);
	build(rc[u],dep+1,ps+pw[dep]);
	build(pc[u],dep+1,ps+2*pw[dep]);
}
void pushnow(int u){
	rev[u]^=1,swap(rc[u],pc[u]);
}
void pushdown(int u){
	if(!rev[u])return;
	if(lc[u])pushnow(lc[u]);
	if(rc[u])pushnow(rc[u]);
	if(pc[u])pushnow(pc[u]);
	rev[u]=0;
}
void move(int u,int dep){
	pushdown(u);
	if(dep==n)return;
	swap(rc[u],pc[u]),swap(rc[u],lc[u]);
	move(lc[u],dep+1);
}
void dfs(int u,int dep,int ps){
	pushdown(u);
	if(dep==n){ans[id[u]]=ps;return;}
	dfs(lc[u],dep+1,ps);
	dfs(rc[u],dep+1,ps+pw[dep]);
	dfs(pc[u],dep+1,ps+2*pw[dep]);
}
int main(){
	#ifdef Stargazer
	freopen("lx.in","r",stdin);
	#endif
	n=read();pw[0]=1;int rt=0;
	m=readstring(str);
	for(int i=1;i<M;i++)pw[i]=pw[i-1]*3;
	build(rt,0,0);
	for(int i=1;i<=m;i++)
	if(str[i]=='S')pushnow(rt);
	else move(rt,0);
	dfs(rt,0,0);
	for(int i=0;i<pw[n];i++)cout<<ans[i]<<" ";puts("");
	return 0;
}

Measured memory_bytes: 22156
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    int n = s.length();
    int n2 = t.length();
    if((n2-n) == 1){
        for (size_t i = 0; i < n; i++) {
            if(s[i] != t[i]){
                cout<<"No\n";\
                return 0;
            }
        }
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int M1 = scanner.nextInt();
        int D1 = scanner.nextInt();
        int M2 = scanner.nextInt();
        int D2 = scanner.nextInt();

        int ans = 0;
        if(M1 != M2) ans = 1;
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  char key = S[0];
  int count = 0;
  rep(i, S.size()) {
    if(i == 0) continue;
    if(key == S[i]) {
      continue;
    } else {
      if(key == 'L') key = 'R';
      else key = 'L';
      count++;
    }
  }
  count++;

  int m = count - 2 * K;
  if(m <= 0) m = 1;
  int ans = N - m;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <stdio.h>
#include <set>
#include <vector>
using namespace std;

int main(){
    string a, b, c;
    cin>>a>>b>>c;
    int am = 0;
    int bm = 0;
    int cm = 0;
    char genzai = 'a';
    char shori;
    while(1){
        if(am==a.size()+1){
            cout<<'A'<<endl;
            break;
        }
        else if(bm == b.size()+1){
            cout<<'B'<<endl;
            break;
        }
        else if(cm == c.size()+1){
            cout<<'C'<<endl;
            break;
        }
        if(genzai=='a'){
            genzai = a[am];
            am++;
            //cout<<"am"<<am<<endl;
        }
        else if(genzai == 'b'){
            genzai = b[bm];
            bm++;
            //cout<<"bm"<<bm<<endl;
        }
        else if(genzai =='c'){
            genzai = c[cm];
            cm++;
            //cout<<"cm"<<cm<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

using namespace std;

int main() {
    int A, B, C; cin >> A >> B >> C;
    long long mx = max(max(A, B), C);
    long long ret = A + B + C + mx * 10 - mx;
    cout << ret << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
inline int read()
{
	int t=1,sum=0;char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') t=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
		sum=sum*10+ch-'0',ch=getchar();
	return t*sum;
}
const int _N=2e3+10,_M=4e6+10,mod=1e9+7;
int fac[_M],inv[_M],f[_N][_N],n,m;
void up(int &x,int y)
{
	x+=y;
	if(x>=mod) x-=mod;
}
int C(int x,int y)
{
	if(x<y) return 0;
	return 1LL*fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int main()
{
	int i,j;
	n=read(); m=read();
	if(m==1) return puts("1"),0;
	fac[0]=inv[0]=inv[1]=1;
	for(i=2;i<=n*m;i++)
		inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod;
	for(i=1;i<=n*m;i++)
		fac[i]=1LL*fac[i-1]*i%mod,
		inv[i]=1LL*inv[i-1]*inv[i]%mod;
	f[0][0]=1;
	for(i=0;i<=n;i++)
		for(j=0;j<=n;j++)
			if(f[i][j])
			{
				if(j!=n)
					up(f[i][j+1],1LL*f[i][j]*C(i-1+(m-1)*(j+1),m-2)%mod);
				if(i<j)
					up(f[i+1][j],f[i][j]);
			}
	printf("%d\n",1LL*fac[n]*f[n][n]%mod);
	return 0;
}

Measured memory_bytes: 47232
#include<stdio.h>
#define Number 100

int main()
{

	int a;
	float sum;
	int count2[Number];
	int count=0;
	int i,j,z;

while(1)
{
	scanf("%d",&a);
	scanf("%f",&sum);
	//printf("a:%d sum:%f\n",a,sum);

	if(a==0 && sum==0)
	break;
	count2[count]=0;
		for (i=1;i<sum/3;i++)
		{
			for (j=i+1;j<(sum-i)/2;j++)
			{
				//printf("i:%d j:%d\n",i,j);
				if(sum-i-j<=a)
					count2[count]++;
		    }
		}
		count++;

}

for(z=0;z<count;z++)
printf("%d\n",count2[z]);

}



Measured memory_bytes: 2064
#include <bits/stdc++.h>
using namespace std;
const int N = 100005, MOD = 1E9 + 7;
vector<int> adj[N];
int n;
int ans[N][2];
void dfs(int u, int p)
{
	for (int v: adj[u])
	{
		if (v == p)
			continue;
		dfs(v, u);
	}
	int tot = 1, tw = 1;
	for (int v: adj[u])
	{
		if (v == p)
			continue;
		tw = (1LL * tw * ans[v][0]) % MOD;
		tot = (1LL * tot * (ans[v][0] + ans[v][1])) % MOD;
	}
	ans[u][0] = tot;
	ans[u][1] = tw;
}
int main(int argc, char const *argv[])
{
	memset(ans, -1, sizeof(ans));
	scanf("%d", &n);
	for (int i = 0; i < n - 1; ++i)
	{
		int u, v;
		scanf("%d", &u);
		scanf("%d", &v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	dfs(1, -1);
	int ANS = (1LL * ans[1][0] + ans[1][1]) % MOD;
	printf("%d", ANS);
	return 0;
}

Measured memory_bytes: 13440
import numpy as np

A_init = 500
B_init = 100
C_init = 50

A_n = int(input())
B_n = int(input())
C_n = int(input())

X = int(input())

cnt = 0
for a in range(A_n+1):
    for b in range(B_n+1):
        for c in range(C_n+1):
            if (A_init * a + B_init * b + C_init * c) == X: cnt += 1
# print(np.count_nonzero([k+[i for i in All_list] == X for k in All_list]))
print(cnt)

Measured memory_bytes: 27100
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 998244353;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	long inf = LMAX / 2 - MAX;

	void doIt() {
		int N = sc.nextInt();
		int a[] = new int[N];
		int sum = 0;
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			sum ^= a[i];
		}
		for(int i = 0; i < N; i++) {
			System.out.print((sum ^ a[i]) + " ");
		}
		System.out.println();
	}

	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 61764
n=int(input())

for i in range(n):
  if (i+1)%3==0:
    print(" {}".format(i+1), end="")
  else:
    j = i+1
    while j > 0:
      if j%10 == 3:
        print(" {}".format(i+1), end="")
        break
      else:
        j = j//10

print("")


Measured memory_bytes: 5868
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

//AtCoderC++.cpp

using namespace std;

void Show(vector<vector<int>> Ns) {
	for (int i = 0; i < Ns.size(); i++) {
		for (int j = 0; j < Ns[i].size(); j++) {
			if (j == Ns[i].size() - 1) {
				cout << Ns[i][j] << endl;
			} else {
				cout << Ns[i][j] << ",";
			}			
		}
	}
}

void Show(vector<int> N) {
	for (int i = 0; i < N.size(); i++) {
		cout << N[i];
		if (i != N.size() - 1) {
			cout << " ";
		} else {
			cout << endl;
		}
	}
}


int main() {
	string S;
	cin >> S;
	if (S.length() == 2) {
		cout << S << endl;
	} else {
		for (int i = 0; i < 3; i++) {
			cout << S[2 - i];
		}
		cout << endl;
	}
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n, m;
bool isa[200200];

set<li> edge[200200][2];

inline bool ok(li x) {
    return (!edge[x][0].empty() && !edge[x][1].empty());
}

inline void prune(li x) {
    vector<li> remove_list;
    rep(i, 2) {
        foreach (it, edge[x][i]) {
            li next = *it;
            if (next == x)continue;
            edge[next][!isa[x]].erase(x);
            remove_list.pb(next);
        }
        edge[x][i].clear();
    }
    rep(i, sz(remove_list)) {
        if (!ok(remove_list[i])) {
            prune(remove_list[i]);
        }
    }
}

int main() {
    cin >> n >> m;
    string s;
    cin >> s;
    rep(i, sz(s)) {
        isa[i] = (s[i] == 'A');
    }
    rep(i, m) {
        li x, y;
        cin >> x >> y;
        x--;
        y--;
        edge[x][!isa[y]].insert(y);
        edge[y][!isa[x]].insert(x);
    }

    rin{
        if (!ok(i)) {
            prune(i);
        }
    }
    bool res = false;
    rin{
        if (ok(i)) {
            res = true;
            break;
        }
    }
    cout << (res ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 41476
using System;

class Program
{
    public static void Main(string[] args)
    {
        var input = Console.ReadLine();
        var values = input.Split(' ');
        int[] numbers = new int[values.Length];

        int n = 0;
        foreach (var value in values)
        {
            numbers[n] = int.Parse(value);
            n++;
        }
        Array.Sort(numbers);

        Console.WriteLine(string.Format("{0} {1} {2}", numbers[0], numbers[1], numbers[2]));
    }
}

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

int main() {
    int n, x;
    int c = 0;
    while(true){
        cin >> n >> x;
        if(n==0){
            break;
        }
        for (int i = 1; i <= n-2 ; i++) {
            for (int j = i+1; j <= n-1; j++) {
                for (int k = j+1; k <= n; k++) {
                    if(i+j+k == x){
                        c++;
                    }
                }
            }
        }
        cout << c << endl;
        c = 0;
    }
    return 0;
}



Measured memory_bytes: 3092
N,K = map(int,input().split())
S = list(input())
tmp = []
tmp.append(S[0])
for i in  range(1,N):
    if(S[i] != S[i-1]):
        tmp.append(S[i])
G = len(tmp)
G -= 2*K
G = max(G-1,0)

print(N-G-1)

Measured memory_bytes: 10476
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin>>n;
    ll input,temp,gcd;
    cin>>gcd;
    for(int i=0;i<n-1;i++){
        cin>>input;
        gcd=__gcd(gcd,input);
    }
    cout<<gcd<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unordered_map>
#include <vector>

int main(){
  int N, M;
  scanf("%d", &N);
  scanf("%d", &M);
  std::vector<int > H(N);
  for (int i=0; i<N; i++){
    scanf("%d", &H[i]);
  }
  std::vector<int > A(M), B(M);
  std::vector<int > edge[N+4];
  for (int i=0; i<M; i++){
    scanf("%d", &A[i]);
    scanf("%d", &B[i]);
    A[i]--;
    B[i]--;
    edge[A[i]].push_back(B[i]);
    edge[B[i]].push_back(A[i]);
  }
  int ans = 0;
  for (int i=0; i<N; i++){
    bool highest = true;
    for (int j=0; j<edge[i].size(); j++){
      if (H[edge[i][j]]>=H[i]){
        highest=false;
        break;
      }
    }
    if (highest) ans++;
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 9196
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;

int m,a,b;

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


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

int a[1005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, k, tot = 0;
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a,a+n);
    for (int i = 0; i < k; i++) tot += a[i];
    cout << tot;
}

Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<string>
int i;
int ioi=0,joi=0;
std::string s;
#define I if(s[i]=='I')
#define J if(s[i]=='J')
int main(){
	while(std::cin>>s){
	    for(i=0;i<s.size();i++){
		    I{
			    if(s[i+1]=='O'){
				    if(s[i+2]=='I'){
					    ioi++;
				    }
			    }
		    }
		    J{
			    if(s[i+1]=='O'){
				    if(s[i+2]=='I'){
					    joi++;
				    }
			    }
		    }
	    }
	    std::cout<<joi<<std::endl;
	    std::cout<<ioi<<std::endl;
		ioi=0,joi=0;
    }
}

Measured memory_bytes: 1196
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>	// upper_bound(A, A+N, num):>, lower_bound(A, A+N, num):>=
#include <functional>
#include <string>
#include <sstream>
#include <complex>
#include <vector>	// V[i],  push_back(x), pop_back(), insert(index, x), erase(index), sort(v.begin(), v.end(), greater<int>())
#include <list>		// push_front(x), push_back(x), pop_front(), pop_back(), insert(index, x)
#include <queue>	// push(x), front(), pop()
#include <deque>
#include <stack>	// push(x), top(), pop()
#include <map>		// M[key],  insert(key, val), erase(key), find(key), 
#include <set>		// insert(key), erase(key), find(key)

using namespace std;
typedef long long ll;
// typedef pair<int, int> P;

#define pi 3.141592653589793)
#define mod 1000000007

int N, X;
int m[1001];

void solve() {
	cin >> N >> X;
	int cnt = N;
	for (int i = 0; i < N; i++) {
		cin >> m[i];
		X -= m[i];
	}
	sort(m, m + N);
	while (X-m[0] >= 0) {
		X -= m[0];
		cnt++;
	}
	cout << cnt << endl;
}

int main() {
	solve();
	return 0;
}

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

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

  vector<int> vec(N);
  vec.push_back(K);
  vec.push_back(0);
  for (int i = 0; i < N; i++)
  {
    cin >> vec.at(i);
  }
  vector<int> dif(0);
  for (int i = 0; i < N; i++)
  {
    int d = vec.at(i + 1) - vec.at(i);
    dif.push_back(d);
  }
  int e = vec.at(0) - 0;
  int f = dif.at(N - 1);
  int end = e + f;
  int g = *max_element(dif.begin(), dif.end());

  // cout << "end: " << end << endl;
  // cout << "g: " << g << endl;

  int ans;
  for (int i = 0; i < N; i++)
  {
    ans += dif.at(i);
  }
  ans -= dif.at(N - 1);
  // cout << "ans: " << ans << endl;

  if (g <= end)
  {
    cout << ans << endl;
  }
  else
  {
    cout << end + ans - g << endl;
  }
}

Measured memory_bytes: 2828
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
typedef long double ld;
typedef unsigned long long ull;
#define X first
#define Y second
#define mp make_pair
template<class T> using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T, class X> using indexed_map = tree<T, X, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const long long M = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

long long modpow(long long n, long long k, long long MOD);

/**************** code starts here ****************/

void poppingfever() {
	int n, k; cin >> n >> k;
	string s; cin >> s;
	k--;

	s[k] -= 'A';
	s[k] += 'a';
	cout << s;
}

/**************************************************/

signed main() {
	#ifdef fastfurioustransform
	freopen("inp.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif

	ios::sync_with_stdio(0); cin.tie(0);
	//cout << fixed << setprecision(12);

	poppingfever();

	return 0;
}

long long modpow(long long n, long long k, long long MOD) {
	long long ans = 1; n %= MOD;
	while (k > 0) {
		if (k & 1) ans = (ans*n) % MOD;
		k >>= 1; n = (n*n) % MOD;
	}
	return ans; 
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <bits/stdc++.h>

using namespace std;

class dwacon5_c {
public:
    void solve(istream& in, ostream& out) {
        int N, Q;
        string S;
        in >> N >> S >> Q;
        for (int i = 0; i < Q; ++i) {
            int k;
            in >> k;
            long long res = 0;
            long long d = 0, m = 0, dm = 0;
            for (int i = 0; i < N; ++i) {
                if (i >= k) {
                    int j = i - k;
                    /*if (S[j] == 'D') {
                        dm -= m;
                        d -= 1;
                    } else if (S[j] == 'M') {
                        m -= 1;
                    }*/
                    dm -= m * (S[j] == 'D');
                    d -= 1 * (S[j] == 'D');
                    m -= 1 * (S[j] == 'M');
                }
                /*if (S[i] == 'D') {
                    d += 1;
                } else if (S[i] == 'M') {
                    m += 1;
                    dm += d;
                } else if (S[i] == 'C') {
                    res += dm;
                }*/
                d += 1 * (S[i] == 'D');
                m += 1 * (S[i] == 'M');
                dm += d * (S[i] == 'M');
                res += dm * (S[i] == 'C');
            }
            out << res << "\n";
        }
    }
};

int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	dwacon5_c solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, M, X;
int C[22];
int A[22][22];
signed main() {
    cin >> N >> M >> X;
    rep(i, N) {
        cin >> C[i];
        rep(j, M) { cin >> A[i][j]; }
    }
    int ans = LLONG_MAX;
    rep(i, bit(N)) {
        int cur = 0;
        vint g(M);
        rep(j, N) {
            if (~i & bit(j)) { continue; }
            cur += C[j];
            rep(k, M) { g[k] += A[j][k]; }
        }
        bool flag = true;
        rep(j, M) { flag &= (g[j] >= X); }
        if (!flag) { continue; }
        chmin(ans, cur);
    }
    if (ans == LLONG_MAX) { cout << -1 << endl; }
    else { cout << ans << endl; }

}


Measured memory_bytes: 3640