akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>

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

using namespace std;
using ll = long long;
using P = pair<int, int>;
using TP = tuple<ll, ll, ll>;
ll MOD = 1e9+7;
ll INF = 1LL<<58;

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

    cin >> N;
    vector<ll> b(N+1,0), w(N+1,0);
    char s;
    REP(i,N){
        cin >> s;
        if(s == '#'){
            b[i+1]++;
        }else{
            w[i]++;
        }
    }

    for(ll i = 0; i < N-1; i++){
        b[i+1] += b[i];
    }
    for(ll i = N; i > 0; i--){
        w[i-1] += w[i];
    }
    ll m = 1e9;
    for(int i = 0; i <=N; i++){
        //cout << b[i] << "," << w[i] << endl;
        m = min(m,b[i-1]+w[i]);
    }
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <queue>
#include <map>
#include <tuple>
using namespace std;

int N, L[11];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) cin >> L[i];
	sort(L, L + N);

	int s0 = L[N - 1], s1 = 0;
	for (int i = 0; i < N - 1; i++) s1 += L[i];

	if (s0 < s1) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		if (n <= 599) {
			System.out.println("8");
		} else if (n <= 799) {
			System.out.println("7");
		} else if (n <= 999) {
			System.out.println("6");
		} else if (n <= 1199) {
			System.out.println("5");
		} else if (n <= 1399) {
			System.out.println("4");
		} else if (n <= 1599) {
			System.out.println("3");
		} else if (n <= 1799) {
			System.out.println("2");
		} else if (n <= 1999) {
			System.out.println("1");
		}
	}
}

Measured memory_bytes: 32692
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)

int main() {
	int n,m,a,b,ans,c;
	fscanf(stdin, "%d%d", &n, &m);
	ans = c = m;
	while (n--) {
		fscanf(stdin, "%d%d", &a, &b);
		if (c < 0) continue;
		c += a - b;
		if (c < 0) ans = 0;
		if (ans < c) ans = c;
	}
	P(d, ans);
	return 0;
}

Measured memory_bytes: 600
from fractions import gcd
a,b,c,d = map(int, input().split())

nums = b-a+1
t1 = b//c - (a-1)//c
t2 = b//d - (a-1)//d

lcm = (c*d)//gcd(c,d)
t3 = b//lcm - (a-1)//lcm
print(nums-t1-t2+t3)

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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

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

void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }
void yesOrNo(bool flg) {
  if (flg)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

void solve(ll N) {
  if (ll(sqrt(1 + 8 * N)) * ll(sqrt(1 + 8 * N)) != 1 + 8 * N) {
    no();
    return;
  }
  ll k = (1 + sqrt(1 + 8 * N)) / 2;

  vector<vector<int>> S(k);

  S.at(0).push_back(1);
  ll v = 2;
  for (int i = 1; i < k - 1; i++) {
    for (int j = v; j < v + i + 1; j++) {
      S.at(i).push_back(j);
    }
    v += i + 1;
  }

  for (int i = 0; i < k - 1; i++) {
    ll d = 0;  //幅
    ll b = S.at(i).back();
    for (int j = i + 1; j < k - 1; j++) {
      d += j;
      S.at(i).push_back(b + d);
    }
  }

  v = 0;
  for (int j = 1; j < k; j++) {
    v += j;
    S.at(k - 1).push_back(v);
  }

  yes();
  cout << k << endl;
  rep(i, k) {
    ll z = sz(S.at(i));
    cout << z;
    rep(j, z) { cout << " " << S.at(i).at(j); }
    cout << endl;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(Args&&... args) { print(std::forward<Args>(args)...); }

    private:
        const char *sep, *term;
        void print() { std::cout << term; }
        void print_rest() { std::cout << term; }
        template <class T, class... Tail>
        void print(T&& head, Tail&&... tail) { std::cout << head, print_rest(std::forward<Tail>(tail)...); }
        template <class T, class... Tail>
        void print_rest(T&& head, Tail&&... tail) { std::cout << sep << head, print_rest(std::forward<Tail>(tail)...); }
    };

public:
    Prints(void) {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") { return __Prints(sep, term); }
    template <class T>
    void print_vec(const std::vector<T>& vec, const std::string& sep = " ", const std::string& term = "\n") {
        const size_t sz = vec.size();
        for (size_t i = 0; i < sz; i++) std::cout << vec[i] << (i == sz - 1 ? term : sep);
    }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    Vl A(N);
    ll s = 0;
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
        s ^= A[i];
    };
    for (ll i = 0; i < N; i++) {
        ll ans = s ^ A[i];
        prints()(ans);
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

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

int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  int ans = 0;
  rep(i, s.size()) {
    if (i == 0 && s[i] == 'L') continue;
    if (i == s.size()-1 && s[i] == 'R') continue;
    if (s[i] == 'L' && s[i-1] == 'L') ++ans;
    if (s[i] == 'R' && s[i+1] == 'R') ++ans;
  }
  int seq = 1;
  rep(i, s.size()-1) {
    if (s[i+1] != s[i]) ++seq;
  }
  if (k < seq / 2) ans += 2 * k;
  else ans = n-1;
  cout << ans << endl; 
  return 0;
}

Measured memory_bytes: 3696
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> p;
  tools::read(p, N);
  std::transform(p.begin(), p.end(), p.begin(), [](const i64& p_i) { return p_i - 1; });

  std::vector<i64> a(N), b(N);
  for (i64 i = 0; i < N; ++i) {
    a[i] = i * N + 1;
    b[N - i - 1] = i * N + 1;
  }
  for (i64 i = 0; i < N; ++i) {
    a[p[i]] += i;
  }

  std::string delimiter = "";
  for (const i64& a_i : a) {
    std::cout << delimiter << a_i;
    delimiter = " ";
  }
  std::cout << std::endl;
  delimiter = "";
  for (const i64& b_i : b) {
    std::cout << delimiter << b_i;
    delimiter = " ";
  }
  std::cout << std::endl;
  return 0;
}

Measured memory_bytes: 1152
/*************************************************\
           In the name of almighty ALLAH
                 MD.Faysal Hasan
                Comilla Univesity
\*************************************************/

#include<bits/stdc++.h>
using namespace std;

#define     ikarus_101  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef     long long             ll;
typedef     long double           ld;
typedef     unsigned long long    ull;
typedef     vector<ll>            vll;
typedef     pair<ll,ll>           pll;
typedef     vector<pll>           vpl;
typedef     map<ll,ll>            mll;
typedef     multiset<ll>          msl;
typedef     multimap<ll,ll>       Mll;
using pqboro=priority_queue<ll,vll,less<ll>>;
using pqchoto=priority_queue<ll,vll,greater<ll>>;

#define    all(str)       str.begin(),str.end()
#define    sajo(str)      sort(str.begin(),str.end())
#define    rev(str)       reverse(str.begin(),str.end())
#define    usajo(str)     sort(str.rbegin(),str.rend())
#define    vin(a)         for(auto &it : a) cin>>it
#define    vout(a)        for(auto it:a) cout<<it<<' ';cout<<nn
#define    pb             push_back
#define    eb             emplace_back
#define    mkp(x,y)       make_pair(x,y)
#define    F              first
#define    S              second
#define    yes            cout<<"YES"<<nn
#define    no             cout<<"NO"<<nn
#define    nn             "\n" ///endl
#define    rep(i,n)       for (i=0;i<n;++i )
#define    rep1(i,n)      for (i=1;i<=n;++i )

#define    min3(a,b,c)    min(a,min(b,c))
#define    max3(a,b,c)    max(a,max(b,c))
#define    sqr(x)         ((x)*(x))
#define    pi             2*acos(0.0)
#define    gcd(a,b)       __gcd(a,b)
#define    lcm(a,b)       (a/gcd(a,b))*b
#define    mem(a,b)       memset(a,b,sizeof (a))
#define    dec(x)         cout<<fixed<<setprecision(x)
#define    none(n)         __builtin_popcountll(n)

template < typename T > string toString ( T Number ) { stringstream ss ; ss << Number ; return ss.str() ; }
template < typename T > ll toll ( T str ) { stringstream ss ; ss << str ; ll num ; ss >> num ; return num ; }
ll power(ll n , ll k) { if(k == 0) return 1 ; if(k&1) return n*sqr(power(n,k/2)) ; else return sqr(power(n,k/2)); }

const   int  N   =   2e5+7;
const   int  M   =   1e9+7;
const   ll  inf  =   0x7f7f7f7f7f7f7f7f;

int main() {ikarus_101

    ll n,m,i,j,k,x;

    string a,b,c;
    cin>>a>>b>>c;
    if(a.back() == b.front() and b.back() == c.front()) yes;
    else no;













    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B;
  cin >> A >> B;
  if (A > 12 )cout << B <<endl;
  else if (6 <= A && A <=12)cout << B/2<< endl;
  else cout << 0 << endl;
  return 0;
}

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

#define repo(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;

ll choose2(ll n){
    return n*(n-1)/2;
}


int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    ll m = 0;
    repo(i,N) cin >> A[i];
    repo(i,N)  A[i]--;
//     array<ll,1000006> hako;
//     map<int,int> h;
    vector<int> H(N);

    repo(i,N){
        H[A[i]]++;
    }
    ll total =0;
    repo(i,N){
        total += choose2(H[i]);
    }
    repo(i,N){
        ll ans = total;
        ans -=H[A[i]]*(H[A[i]]-1)/2;  
        ans +=(H[A[i]]-1)*(H[A[i]]-2)/2;
        cout << ans << endl;
    }
//     h[1];
//     cout << h[1] << endl;

//     for(ll i = 0; i < N; i++){
//         cin >> A[i];
//         hako[A[i]]++;
// //         h[A[i]]++;    
//         m = max(m,A[i]);
//     }
//     repo(i,N){
//
//     }
//     for(ll i = 0; i < N; i++){
//             int ans = 0;
// //         h[A[i]]--;
//         hako[A[i]]--;
//         for(ll j = 0; j <= m; j++){
//             ans += hako[j]*(hako[j]-1)/2;
// //             ans+= h[j]*(h[j])
//         }
//
//         cout << ans << endl;
//
//         hako[A[i]]++;
//     } 
//     cout << ans << endl;

    return 0;
}



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

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		int a = 0, b = 0;
		int num[10];
		for(int j = 0; j < 10; j++){
			cin >> num[j];
		}
		for(int j = 0; j < 10; j++){
			if(a < b){
				swap(a,b);
			}
			if(num[j] > a){
				a = num[j];
			}
			else if(num[j] > b){
				b = num[j];
			}
			else{
				cout << "NO" << endl;
				break;
			}
			if(j == 9){
				cout << "YES" << endl;
			}
		}
	}
}

Measured memory_bytes: 1148
import java.util.Scanner;

class Main{


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力


		int n = sc.nextInt();
		int k = sc.nextInt()-1;
		int[] a = new int[n+1];
		for(int i = 1;i <= n;i++){
			a[i] = sc.nextInt();
		}
		int one = 0;

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

		int left = one - 1;
		int right = n - one;
		int ans = 0;

		int l = 0;
		int r = 0;

		if(left < right){
			if(left == 0){

			}else if(left < k){
				ans++;
				right -= k - left;
				left = 0;
			}else{
				if(left % k == 0) {
					l = left/k;
				}else{
					ans++;
					int lamari = l % k;
					right -=k - lamari;
					l = left/k;
				}
			}

			if(right <= 0){

			}else{
				if(right % k == 0) {
					r = right/k;
				}else{
					r = right/k + 1;
				}
			}

		}else{
			if(right == 0){

			}else if(right < k){
				ans++;
				left -= k - right;
				right = 0;
			}else{
				if(right % k == 0) {
					r = right/k;
				}else{
					int ramari = right % k;
					l -= k - ramari;
					r = right/k;
				}				
			}
			
			if(left <= 0){
				
			}else{
				if(left % k == 0) {
					l = left/k;
				}else{
					l = left/k + 1;
				}
			}

		}

		ans += l + r;
		System.out.println(ans);


	}

}

class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}



Measured memory_bytes: 49672
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,X,Y,Z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
long long sum = 0;

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

int main() {
    string s;
    cin >> N;
    cin >> s;
    if(N%2 == 1) cout << "No";
    else{
        rep(i, s.size()/2){
            if(s[i] != s[i+N/2]) {
                cout << "No";
                return 0;
            }
        }
        cout << "Yes";
    }
}


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

int main()
{
    string s;
    string t;
    cin >> s;
    cin >> t;

    vector<string> v;
    for(int i = 0; i < s.size(); i++)
    {
        for(int j = 0; j < t.size(); j++)
        {
            if(s[i] == t[j] and i-j >= 0 and i+(t.size()-j)-1 < s.size())
            {
                bool flag = true;
                string sub = s;
                for(int k = i-j, n = 0; k < i+(t.size()-j) and n < t.size(); k++, n++)
                {
                    if(s[k] != t[n] and s[k] != '?')
                    {
                        flag = false;
                    }
                    else
                    {
                        sub[k] = t[n];
                    }
                }
                if(flag == true)
                {
                    for(int k = 0; k < sub.size(); k++)
                    {
                        if(sub[k] == '?')
                        {
                            sub[k] = 'a';
                        }
                    }
                    v.push_back(sub);
                }
            }
        }
    }

    int tlen = t.size();
    for(int i = 0; i < s.size(); i++)
    {
        string sub = s;
        bool flag = true;
        for(int j = i; j < i+tlen; j++)
        {
            if(sub[j] != '?') flag = false;
        }
        if(flag == true)
        {
            for(int j = i, n = 0; j < i+tlen; j++, n++)
            {
                sub[j] = t[n];
            }
            for(int j = 0; j < sub.size(); j++)
            {
                if(sub[j] == '?') sub[j] = 'a';
            }
            v.push_back(sub);
        }
    }

    if(v.size() > 0)
    {
        sort(v.begin(), v.end());
        cout << v[0] << endl;
    }
    else
    {
        cout << "UNRESTORABLE" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define quickIO()	{cin.tie(0);	cout.sync_with_stdio(false);}
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<(int)n;i++)
#define REP(i,n)	for(int i=0;i<=(int)n;i++)
#define srep(i,a,n)	for(int i=a;i<(int)n;i++)
#define SREP(i,a,n)	for(int i=a;i<=(int)n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
#define fst	first
#define scn second
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll gcd(ll a, ll b) {
	return a%b == 0 ? b : gcd(b, a%b);
}
#define debug(x)	cout<<"case #" << x << ": " << endl
#define DEBUG 0
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ld eps = 1e-15;
const int dx[] = { 1,0,-1,0,0 };
const int dy[] = { 0,1,0,-1,0 };

int main() {
	int n, k;	cin >> n >> k;
	ll ret = 0;
	SREP(b, k + 1, n) {
		int loop = n / b;
		ret += loop*max(b - k, 0);
		ret += max(0, (n%b) - max(k, 1) + 1);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
const int M = 1000000007;

int n, m, l;
vector<long long> k, imos;
long long cost(int i, int j) {
    return (imos[k[min(j, n)]] - imos[k[max(i, 1)] - 1]) / l;
}

int main() {
    cin >> n >> m >> l;
    k.resize(n + 1);
    k[0] = 0;
    for (int i = 0; i < n; ++i) {
        cin >> k[i + 1];
    }
    vector<int> s(m);
    imos.resize(m + 1, 0);
    for (int i = 0; i < m; ++i) {
        cin >> s[i];
        imos[i + 1] = imos[i] + s[i];
    }
    sort(k.begin(), k.end());
    vector<vector<long long>> dp(n + 1, vector<long long>(n + 1, (long long)1e16));
    vector<long long> mi(n + 1, (long long)1e16);
    dp[0][0] = cost(1, n);
    for (int i = 1; i < n; ++i) {
        dp[0][0] += cost(i, i + 1);
    }
    mi[0] = dp[0][0];
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < i - 1; ++j) {
            dp[i][1] = min(dp[i][1], mi[j] - cost(i - 1, i) - cost(i, i + 1) + cost(i - 1, i + 1) - cost(j, n) + cost(j, i) + cost(i, n));
            mi[i] = min(mi[i], dp[i][1]);
        }
        for (int j = 2; j <= i; ++j) {
            dp[i][j] = dp[i - 1][j - 1] - cost(i - j, i) - cost(i, i + 1) + cost(i - j, i + 1) - cost(i - 1, n) + cost(i - 1, i) + cost(i, n);
            mi[i] = min(mi[i], dp[i][j]);
        }
    }
    long long ans = mi[0];
    for (long long i : mi) {
        ans = min(ans, i);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 35332
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int ans = 0;
    int a = 0;
    int b = 0;
    int d = 0;
    vector<string> S(n);
    for(int i = 0;i < n;i++){
        cin >> S[i];
        if(S[i].size() > 1 && S[i][0] == 'B' && S[i][S[i].size()-1] == 'A')d++;
        else if(S[i][0] == 'B')b++;
        else if(S[i][S[i].size()-1] == 'A')a++;
        for(int j = 1;j < S[i].size();j++){
            if(S[i][j] == 'B' && S[i][j-1] == 'A')ans++;
        }
      
    }
    ans += max(0,d-1);
    if(a > 0 && d > 0){
      ans++;
      --a;
    }
    if(b > 0 && d > 0){
      ans++;
      --b;
    }
    ans += min(a,b);
    cout << ans << endl;    
}

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

struct node{
  int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur = nil->next;
  while( cur != nil && cur->key != key ){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void delete(int key){
  NodePointer t = listSearch(key);
  if ( t == nil ) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if(!( 0 <= key && key <= 2000000000)){printf("error") ;}
    if ( com[0] == 'i' ) {insert(key); np++; }
    else if ( com[0] == 'd' ) {delete(key); nd++; }
  }

  if(!( np+nd <= 1000000)){printf("error") ;}
  if(!( nd <= 1000000)){printf("error") ;}
  printList();

  return 0;
}

Measured memory_bytes: 15000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n,x; cin>>n;
	ll tot_a=0, tot_b=0;
	vector<int>a(n),b(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		cin>>b[i];
		if(a[i]<b[i]){
			int diff=b[i]-a[i];
			if(diff%2){
				tot_a+=(diff+1)/2;
				tot_b++;
			}
			else tot_a+=(diff/2);
		}
		else 
			tot_b+= (a[i]-b[i]);
	}
	if(tot_a>=tot_b) 
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}

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

long long dp[110][100010],v[110],w[110];
int main()
{
    long long n , W;
    cin >> n >> W;
    for(int i = 0 ; i < n ; i++)    cin >> w[i] >> v[i];

    for(int i = n-1 ; i >= 0 ; i--)
        for(int curw = 0 ; curw <= W ; curw++)
            dp[i][curw] = max(dp[i+1][curw],(curw + w[i] <= W ? dp[i+1][curw + w[i]] + v[i] : -1));

    cout << dp[0][0] << endl;
    return 0;
}


Measured memory_bytes: 80128
#include <iostream>
#include <map>
#include <vector>
using namespace std;
map<int, int> counts;
vector<int> l;
int n;

bool is_triangle(int i, int j, int k) {
  if (i + j > k && j + k > i && k + i > j) {
    return true;
  } else {
    return false;
  }
}

void solve() {
  int ans = 0;
  for (int i = 0; i < l.size(); i++) {
    for (int j = i + 1; j < l.size(); j++) {
   	  for (int k = j + 1; k < l.size(); k++) {
        if(is_triangle(l[i], l[j], l[k])) {
          int d = 1;
          d *= counts[l[i]];
          d *= counts[l[j]];
          d *= counts[l[k]];
          ans += d;
        }
      }
    }
  }
  cout << ans;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (counts[a] == 0) l.push_back(a);
    counts[a] += 1;
  }
  
  solve();
}

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

int main(){
    int a , b ;
    cin >> a >> b ;
    string s ;
    cin >> s ;
    if ( s[a] == '-' ){
        for(int i=0;i<s.size();i++){
            if ( i == a ) continue ;
            if ( s[i] >= '0' && s[i] <= '9' ){

            }
            else {
                cout << "No" << endl;
                return 0 ;
            }
        }
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const ll mod = 1e9+7;

//-------------------------<MATH>-------------------------------------------------------//
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2;}return ans;}
ll inv(ll x){return expo(x,mod-2);}
ll mult_mod(ll a , ll b){a = a%mod; b = b%mod;
ll c = (a * b)%mod;
//cout << a << " " << b << endl;
return c;}
ll add_mod(ll a , ll b){a = (a + mod)%mod;b = (b + mod)%mod;ll c = (a + b)%mod;return c;}
ll fac[(int)(5e5 + 5)] , inv_fac[(int)(5e5 + 5)];
void precomp_factorial(int M){fac[0] = 1;for(int i = 1 ; i <= M ; i++) fac[i] = mult_mod(i , fac[i - 1]);
    inv_fac[M] = inv(fac[M]);for(int i = M - 1 ; i >= 0 ; i--) inv_fac[i] = mult_mod(i + 1 , inv_fac[i + 1]);}
ll nCk(ll n , ll k){ll ans = fac[n];ans = mult_mod(ans , inv_fac[n - k]);ans = mult_mod(ans , inv_fac[k]);return ans;}
int lo[(int)(1e3 + 6)];
void sieve(int M){for(int i = 2 ; i < M ; i++){ if(lo[i]) continue; for(int j = i ; j < M ; j += i)lo[j] = i;}}
int max_expo_prime_n_fac(ll N , int prime){int ress = 0;while(N){ress += (N/prime);N /= prime;}return ress;}
//-------------------------</MATH>-------------------------------------------------------//

//-------------------------<STRING>-------------------------------------------------------//
string get_prefix(string x , int MAX){return x.substr(0 , min((int)x.size() , MAX));}
string get_suffix(string x,int MAX){int dn=1;for(int i=x.size()-1;i>=0;i--){if(dn==MAX)return x.substr(i);dn++;}return x;}
string convert_to_binary(int x,int len) {string ans=""; while(x){if(x&1){ans='1'+ans;}
    else{ans ='0'+ans;}x/=2;}int k = ans.size();while(k < len){ans = '0' + ans;k++;}return ans;}
//-------------------------</STRING>-------------------------------------------------------//

ull llrand() {ull r = 0;for(int i = 0; i < 5; ++i){r = (r << 15)|(rand() & 0x7FFF);}return r & 0xFFFFFFFFFFFFFFFFULL;}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};






int main(){

    char c;
    cin >> c;

    if('a' <= c && c <= 'z'){
        cout << 'a';
    } else cout << "A";

}


Measured memory_bytes: 3628
open Printf
open Scanf

let solve n s =
  let rec loop i c =
    if i > n - 3 then c
    else if String.sub s i 3 = "ABC" then loop (i + 1) (c + 1)
    else loop (i + 1) c
  in loop 0 0
       
let () =
  scanf "%d %s " solve |> printf "%d\n"


Measured memory_bytes: 2432
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int w, h, q;
int row[51000];
int colum[51000];
vector<int> seq[51000];

int main() {
  while (scanf("%d %d %d", &h, &w, &q), w|h|q) {
    REP(i, q) { seq[i].clear(); }
    MEMSET(row, 0);
    MEMSET(colum, 0);
    REP(i, q) {
      int a, b, o;
      scanf("%d %d %d", &a, &b, &o);
      seq[i].push_back(a);
      seq[i].push_back(b);
      seq[i].push_back(o);
    }
    reverse(seq, seq + q);
    ll ans = 0;
    int useW = 0;
    int useH = 0;
    REP(i, q) {
      int a = seq[i][0];
      int b = seq[i][1];
      int o = seq[i][2];
      if (a == 0) {
        if (row[b] == 1) { continue; }
        row[b] = 1;
        useH++;
        if (o == 0) { continue; }
        ans += w - useW;
      } else {
        if (colum[b] == 1) { continue; }
        colum[b] = 1;
        useW++;
        if (o == 0) { continue; }
        ans += h - useH;
      }
    }
    printf("%lld\n", ans);
  }
}

Measured memory_bytes: 3092
#include<iostream>
using namespace std;
int main()
{

  int n,m;
  cin>>n>>m;
  if(n<=m)
  {
	for(int i=0;i<m;i++)
    {
		cout<<n;
    }
  }
  else {
  for(int i=0;i<n;i++)
    {
		cout<<m;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
struct{char s;int n;}C[40],T[40],P;
int N,i,j;

void B()
{
	int i,j;
	for(i=0;i<N;i++)
		for(j=N-1;j>=0;j--)
		{
			if(C[j].n<C[j-1].n)
			{
				P=C[j];
				C[j]=C[j-1];
				C[j-1]=P;
			}
		}
}

void S()
{
	int i,j,p;
	for(i=0;i<N;i++)
	{
		p=i;
		for(j=i;j<N;j++)
			if(T[j].n<T[p].n)
				p=j;
		P=T[p];
		T[p]=T[i];
		T[i]=P;
	}
}

int main()
{
	scanf("%d\n",&N);
	for(i=0;i<N;i++)
		scanf("%c%1d%*c",&C[i].s,&C[i].n);
	memcpy(T,C,sizeof(C));
	B();S();
	for(i=0;i<N;i++)
		printf("%c%d%s",C[i].s,C[i].n,i==N-1?"\n":" ");
	puts("Stable");
	for(i=0;i<N;i++)
		printf("%c%d%s",T[i].s,T[i].n,i==N-1?"\n":" ");
	puts(memcmp(C,T,sizeof(C))==0?"Stable":"Not stable");
	return 0;
}



Measured memory_bytes: 2048
H, W, N = map(int, input().split())
ab = []
for i in range(N):
    a, b = map(int, input().split())
    ab.append((a - 1, b - 1))

comb_map = {}


for a, b in ab:
    for k in range(3):
        for m in range(3):
            if 0 <= a - k < H - 2 and 0 <= b - m < W - 2:
                if (a-k, b-m) in comb_map.keys():
                    comb_map[(a - k, b - m)] += 1
                else:
                    comb_map[(a - k, b - m)] = 1

count = [0 for _ in range(10)]

for v in comb_map.values():
    count[v] += 1

count[0] = (H - 2) * (W - 2) - sum(count[1:])

for c in count:
    print(c)


Measured memory_bytes: 180012
n = gets.to_i
f = n.times.map{gets.chomp.split(" ").map(&:to_i)}
p = n.times.map{gets.chomp.split(" ").map(&:to_i)}
ans = -(10**9)
for i in 1..1023
  combi = []
  10.times do |j|
    combi[j] = i%2
    i /= 2
  end
  temp = 0
  for j in 0..n-1
    same = 0
    10.times do |k|
      if combi[k] == 1 && f[j][k] == 1
        same += 1
      end
    end
    temp += p[j][same]
  end
  ans = [ans,temp].max
end
puts ans

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

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main() {
	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
	// #endif
	off;
	LL n;
	cin>>n;
	vector<LL> corr(n);
	vector<LL> arr(n);
	rep(i,1,n+1)
	{
		corr[i-1]=i;
	}
	LL mis = 0;
	vector<LL> m(n);
	LL in = 0;
	rep(i,0,n)
	{
		cin>>arr[i];
		if(arr[i]!=corr[i])
		{
			mis++;
			m[in]=i;
			in++;
		}
	}
	if(mis > 2)
	{
		cout<<"NO";
	}
	else if(mis == 2)
	{
		cout<<"YES";
	}
	else
	{
		cout<<"YES";
	}
  	return 0;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "3 2", "1 2", "2 3" ].parse.expand.solve == "POSSIBLE" );
	assert( [ "4 3", "1 2", "2 3", "3 4" ].parse.expand.solve == "IMPOSSIBLE" );
	assert( [ "100000 1", "1 99999" ].parse.expand.solve == "IMPOSSIBLE" );
	assert( [ "5 5", "1 3", "4 5", "2 3", "2 4", "1 4" ].parse.expand.solve == "POSSIBLE" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	auto abs = new long[ 2 ][ nm[ 1 ] ];
	foreach( ref ab; abs )
	{
		input.popFront;
		ab = input.front.split.to!( long[] );
	}
	return tuple( nm[ 0 ], abs );
}

auto solve( long n, long[ 2 ][] abs )
{
	// 島1から他の島へ行く定期船を調べる
	auto s1 = abs.filter!( ( ab ) => ab[ 0 ] == 1 ).map!( ( ab ) => ab[ 1 ] ).array;
	s1.sort();
	
	// 他の島から島Nへ行く定期船を調べる
	auto s2 = abs.filter!( ( ab ) => ab[ 1 ] == n ).map!( ( ab ) => ab[ 0 ] ).array;
	s2.sort();
	
	// 島1と島Nの両方から行ける島を調べる
	while( !s1.empty && !s2.empty )
	{
		if( s1.front == s2.front ) return "POSSIBLE";
		
		if( s1.front < s2.front ) s1.popFront;
		else                      s2.popFront;
	}
	
	return "IMPOSSIBLE";
}


Measured memory_bytes: 6780
# -*- coding: utf-8 -*-

s = input()

cur = 0
max = 0

for index,item in enumerate(s):
    if item == "A" or item == "T" or item == "G" or item == "C":
        cur += 1
        if cur >= max:
            max = cur
    else:
        cur = 0

print(max)

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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  
  sort(v.begin(), v.end());
  
  int count = 0;
  for (int i = 0; i < (n - 2); i++) {
    for (int j = i + 1; j < (n - 1); j++) {
      for (int k = j + 1; k < n; k++) {
        if (v.at(i) + v.at(j) > v.at(k)) {
          count++;
        } else {
          break;
        }
      }
    }
  }
  
  cout << count << endl;
}

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

int main() {
  int n, num;
  cin >> n;
  int condition = 1;
  int count = 0;
  rep(i, n){
    cin >> num;
    if(num == condition) condition++;
    else count++;
  }
  cout << (condition != 1? count:-1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int n, k;

	cin >> n >> k;

	int ar[n];

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

	int b=n-1;
	int c=k-1;

	cout << (b+c-1)/c << endl;
}


Measured memory_bytes: 640
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let s: String = read();

    println!("{}", if "2019/04/30" >= &s { "Heisei" } else { "TBD" });
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
#define maxn 100001
char s[maxn];
int main(void)
{
	scanf("%s",s);
	int num0=0,num1=0;
	for(int i=0;i<strlen(s);i++){
		if(s[i]=='1') num1++;
		if(s[i]=='0') num0++;
	}
	if(num1>num0) printf("%d\n",num0*2);
	else printf("%d\n",num1*2);
 	return 0;
 }


Measured memory_bytes: 384
pr = Array.new(10**6,1)
(2..1000).each{|i|
	next if pr[i] == 0
	j = i * i
	while j < 10**6
		pr[j] = 0
		j += i
	end
}
pr[0] = pr[1] = 0
(2..10**6).each{|i|
	pr[i] = pr[i] == 1 ? pr[i-1]+1 : pr[i-1]
}
while gets
	p pr[$_.to_i]
end

Measured memory_bytes: 13908
#coding=utf-8

def check_circle(s):
    x = str(s)
    flag = True
    for i in range(int(len(x) / 2)):
         if x[i] != x[-1 * (i + 1)]:
              flag = False
    return flag

def solve(A, B):
    count = 0
    for y in range(A, B + 1):
        if check_circle(y):
            count += 1

    return count

def main():
    A, B = input().split(' ')
    print(solve(int(A), int(B)))


if __name__ == '__main__':
    main()



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

int main(){
	string S, T;
	cin>>S;
	cin>>T;
	cout<< (S==T.substr(0,S.size())? "Yes":"No") <<endl;
	// printf("%f\n",ans);
	// cout<<cout<<setprecision(10)<<ans<<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,sum=0;
    cin >> n;
    rep(i,n) sum+=i;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    int n, i, a, w, r, t;
    a = w = r = t = 0;

    cin >> n;
    for(i = 0; i < n; i++){
        cin >> s;
        if(s == "AC")
            a++;
        else if(s == "WA")
            w++;
        else if(s == "RE")
            r++;
        else if(s == "TLE")
            t++;
    }

    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", a, w, t, r);

    return 0;
}


Measured memory_bytes: 3724
import sys

MOD = 10**9 + 7

N = int(input())
As = [int(sys.stdin.readline()) for _ in range(N)] + [10**9 + 1]
Bs = [int(sys.stdin.readline()) for _ in range(N)] + [10**9 + 1]

As.sort()
Bs.sort()

ans = 1
iA = iB = 0
for _ in range(2*N):
    if iA > iB and As[iA] > Bs[iB]:
        ans *= iA - iB
        ans %= MOD
    elif iA < iB and As[iA] < Bs[iB]:
        ans *= iB - iA
        ans %= MOD

    if As[iA] < Bs[iB]:
        iA += 1
    else:
        iB += 1

print(ans)


Measured memory_bytes: 11792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define INF INT_MAX
ll n,m;
ll a,b,c,d;
string s[1001];
ll dist[1001][1001];
ll ar[1001][1001];
map<pair<ll,ll>,ll> mp;
bool check(ll x,ll y)
{
	if(x<0 or y<0 or x>=n or y>=m or s[x][y]=='#') return false;
	return true;
}
void dfs(ll x,ll y,ll v)
{
	if(x<0 or y<0 or x>=n or y>=m or s[x][y]=='#') return;
	if(mp[{x,y}]) return;
	mp[{x,y}]=1;
	ar[x][y]=v;
	dfs(x+1,y,v);
	dfs(x,y+1,v);
	dfs(x-1,y,v);
	dfs(x,y-1,v);
}
/*ll func(ll x,ll y)
{
	if(x<0 or y<0 or x>=n or y>=m or s[x][y]=='#') return INF;
	if(mp[{x,y}]) return dp[x][y];
	mp[{x,y}]=1;
	if(x==c and y==d) return dp[c][d]=0;
	ll ret=INT_MAX;
	ret=min(ret,func(x-1,y));
	ret=min(ret,func(x,y-1));
	ret=min(ret,func(x+1,y));
	ret=min(ret,func(x,y+1));
	for(ll i=-2;i<=2;i++)
	{
		for(ll j=-2;j<=2;j++)
		{
			if(i==-1 and j==0) continue;
			if(i==0 and j==-1) continue;
			if(i==1 and j==0) continue;
			if(i==0 and j==1) continue;
			if(check(x+i,y+j))
			{
				if(ar[x+i][y+j]!=ar[x][y])
				ret=min(ret,1+func(x+i,y+j));
			}
		}
	}
	return dp[x][y]=ret;
}*/
int main()
{
	ll i,j,k,t;
	cin>>n>>m;
	cin>>a>>b>>c>>d;
	a--,b--,c--,d--;
	for(i=0;i<n;i++)
	{
		cin>>s[i];
	}
	for(i=0;i<=1000;i++)
	{
		for(j=0;j<=1000;j++)
		dist[i][j]=INF;
	}
	set<pair<ll,pair<ll,ll>>> st;
	st.insert(make_pair(0ll,make_pair(a,b)));
	dist[a][b]=0;
	while(!st.empty())
	{
		pair<ll,pair<ll,ll>> p=*(st.begin());
		st.erase(st.begin());
		pair<ll,ll> u=p.second;
		for(i=-2;i<=2;i++)
		{
			for(j=-2;j<=2;j++)
			{
				if(check(u.first+i,u.second+j)==false) continue;
				if((i==0 and j==1) or (i==1 and j==0) or (i==-1 and j==0) or (i==0 and j==-1))
				{
					ll wt=0;
					if(dist[u.first+i][u.second+j]>dist[u.first][u.second]+wt)
					{
				//		if(u.first+i==1 and u.second+j==4) cout<<u.first<<'d'<<u.second<<endl;//
						if(dist[u.first+i][u.second+j]!=INF)
						st.erase(st.find(make_pair(dist[u.first+i][u.second+j],make_pair(u.first+i,u.second+j))));
						dist[u.first+i][u.second+j]=dist[u.first][u.second]+wt;
						st.insert(make_pair(dist[u.first+i][u.second+j],make_pair(u.first+i,u.second+j)));
					}
				}
				else
				{
					ll wt=1;
					if(dist[u.first+i][u.second+j]>dist[u.first][u.second]+wt)
					{
				//		if(u.first+i==1 and u.second+j==4) cout<<u.first<<' '<<u.second<<endl;//
						if(dist[u.first+i][u.second+j]!=INF)
						st.erase(st.find(make_pair(dist[u.first+i][u.second+j],make_pair(u.first+i,u.second+j))));
						dist[u.first+i][u.second+j]=dist[u.first][u.second]+wt;
						st.insert(make_pair(dist[u.first+i][u.second+j],make_pair(u.first+i,u.second+j)));
					}
				}
			}
		}
	}
	/*for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		if(dist[i][j]==INF) cout<<-1<<' ';
		else
		cout<<dist[i][j]<<' ';
		cout<<endl;
	}*/
	if(dist[c][d]==INF) cout<<-1;
	else cout<<dist[c][d];
}

Measured memory_bytes: 13580
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,x,y,z;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	if(a<0){
		a=a*-1;	
		x=a*c+d+b*e;
	}
	else {
		x=(b-a)*e;
	}
	printf("%d\n",x);
	return 0;
}


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

#define int long long
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define str string
#define vint vector<int>
#define vvint vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vool vector<bool>
#define vtr vector<str>
#define vvtr vector<vector<str>>
#define pb() pushback
#define elif else if
#define all(x) x.begin(),x.end()

main(){
    int N,X,b,H=0,W=0,count=0,count2=0;
    double d;
    int C='A'-'a';
    char op;
    str S,T;
    cin>>N;
    vint t(N);
    rep(0,N){
      cin>>t[i];
      count+=t[i];
    }
    count2=count;
    cin>>X;
    vint p(X);
    vint x(X);
    rep(0,X){
    cin>>p[i]>>x[i];
    if(t[p[i]-1]>=x[i])count-=t[p[i]-1]-x[i];
    elif(t[p[i]-1]<x[i])count+=x[i]-t[p[i]-1];
    cout<<count<<endl;
    count=count2;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
long long power(long long m, long long n) {
    if(n == 1)
    return m;
    else if(n%2 == 0)
    return power(m*m%1000000007, n/2);
    else
    return power(m*m%1000000007, n/2)*m%1000000007;
}
 
int main(void){
    long long m, n; 
    scanf("%lld %lld\n", &m, &n);
    printf("%lld\n", power(m,n));
    return 0;
}


Measured memory_bytes: 2144
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << (((c + b - 1) / b <= (a + d - 1) / d) ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t i64;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())

int main() {
  i64 N;
  cin >> N;
  i64 S = 0;

  for (i64 i = 1; i <= N; i++) {
    if (i % 5 == 0 && i % 3 == 0) {
      continue;
    }
    if (i % 5 == 0) continue;
    if (i % 3 == 0) continue;
    S += i;
  }
  cout << S << endl;
}


Measured memory_bytes: 3596