akhauriyash/Code-Regression huggingface dataset:
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//ここまで標準include

using namespace std;
long long gcd(long a, long b) {
	long long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		a = b;
		b = r;
	}
}

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

int main() {
	long long a, b;
	cin >> a >> b;
	cout << lcm(a, b) << endl;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll P,A[3333];
ll inv[3333];
ll poly[3333];
ll C[3333][3333];
ll i, j, k, ans;


ll moddiv(ll a,ll b){
    a %= P;
    b %= P;
    for(ll m=P-2;m>0;m/=2){
        if(m&1){
            a=a*b%P;
        }
        b=b*b%P;
    }
    return a;
}
int main(){
    scanf("%lld", &P);
    fornum(i,0,P){
        scanf("%lld", &A[i]);
    }
    C[0][0] = 1;
    fornum(i,0,P){
        C[i+1][0] = 1;
        fornum(j,0,P){
            C[i + 1][j + 1] = (C[i][j] + C[i][j + 1]) % P;
        }
    }

    fornum(i,0,P){
        ll a = 1;
        fornum(j,0,P){
            if(j%2)
                poly[P - 1 - j] = (poly[P - 1 - j] + C[P - 1][j] * a * A[i]) % P;
            else
                poly[P - 1 - j] = (poly[P - 1 - j] + (P - C[P - 1][j]) * a * A[i]) % P;
            a = (a * i) % P;
        }
        poly[0] = (poly[0] + A[i]) % P;
    }
    fornum(i,0,P){
            printf("%lld ", poly[i]);
        }
}

Measured memory_bytes: 80128
using System;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			int S = Int32.Parse(Console.ReadLine());
			int a = S % 3600;
			int s = a % 60;
			int m = ((S % 3600) - s) / 60;
			int h = (S - a) / 3600;

			Console.WriteLine(h + ":" + m + ":" + s);
		}
	}
}

Measured memory_bytes: 5612
a, b, c, d = map(int, input().split())
if 0 <= a-c <= d or 0 <= c-a <= d or ((0 <= b-a <= d or 0 <= a-b <= d) and (0 <= c-b <= d or 0 <= b-c <= d)):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, st, n) for (int i = (st); i < (n); ++i)
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
 
template <typename T1, typename T2> bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; }
template <typename T1, typename T2> bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; }

const int MOD = 1e9 + 7;
int add(int x, int y)
{
    x += y;
    if (x >= MOD) x -= MOD;
    return x;
}
void vadd(int &x, int y)
{
    x += y;
    if (x >= MOD) x -= MOD;
}
int sub(int x, int y)
{
    x -= y;
    if (x < 0) x += MOD;
    return x;
}
int mult(int x, int y)
{
    return x * (ll)y % MOD;
}
int bpow(int x, ll y)
{
    int res = 1;
    for (; y; y >>= 1)
    {
        if (y & 1)
        {
            res = mult(res, x);
        }
        x = mult(x, x);
    }
    return res;
}

int dp[45][1 << 17];
bool good[1 << 17];

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
    freopen("in", "r", stdin);
#endif
    
    int n, x, y, z;
    cin >> n >> x >> y >> z;
    int S = x + y + z;
    memset(dp, 0, sizeof(dp));
    for (int mask = 0; mask < (1 << S); ++mask)
    {
        good[mask] = !((mask & 1) and ((mask >> x) & 1) and ((mask >> (x + y)) & 1));
    }
    dp[0][0] = 1;
    for (int i = 0; i < n; ++i)
    {
        for (int mask = 0; mask < (1 << S); ++mask) if (good[mask])
        {
            int mask1 = mask;
            mask1 |= (1 << S);
            for (int d = 1; d <= 10; ++d)
            {
                mask1 >>= 1;
                if (good[mask1])
                {
                    vadd(dp[i + 1][mask1], dp[i][mask]);
                }
            }
        }
    }
    int sum = 0;
    for (int mask = 0; mask < (1 << S); ++mask) if (good[mask])
    {
        vadd(sum, dp[n][mask]);
    }
    cout << sub(bpow(10, n), sum);
    return 0;
}

Measured memory_bytes: 23424
def gcd(a, b):
    while b != 0:
        r = a % b
        a = b
        b = r
    return a

N = int(input())
A = list(map(int, input().split()))
d = gcd(A[0], A[1])
for i in range(2, N):
    d = gcd(d, A[i])
print(d)

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

int main() 
{
   char c;
   cin >> c;
   
   if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
      cout << "vowel" << endl;
   }
   else {
     cout << "consonant" << endl;
   }

}

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

int main()
{
    char s[100], p[100], tmp;
    int i, j, slen, plen;

    scanf("%s", s);
    scanf("%s", p);

    slen = strlen(s);
    plen = strlen(p);
    
    int flag = 0;
    for(i = 0; i < plen; i++) {
        if(strstr(s, p) != NULL) {
            flag = 1;
            break;
        }

        tmp = s[0];
        for(j = 1; j < slen; j++) {
            s[j - 1] = s[j];
        }
        s[slen - 1] = tmp;
    }

    if(flag) printf("Yes\n");
    else printf("No\n");
}



Measured memory_bytes: 2104
#pragma GCC optimize("O3")
    #pragma comment(linker, "/stack:200000000")
    #pragma GCC optimize("unroll-loops")
     
    #include <algorithm>
    #include <bitset>
    #include <cassert>
    #include <chrono>
    #include <cmath>
    #include <complex>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <ctime>
    #include <deque>
    #include <functional>
    #include <iomanip>
    #include <iostream>
    #include <iterator>
    #include <limits>
    #include <climits>
    #include <list>
    #include <map>
    #include <numeric>
    #include <queue>
    #include <random>
    #include <ratio>
    #include <set>
    #include <sstream>
    #include <stack>
    #include <string>
    #include <unordered_map>
    #include <unordered_set>
    #include <utility>
    #include <vector>
    using namespace std;
     
    typedef long long ll;
    typedef long double LD;
    #define int ll
    #define double LD
    #define pb push_back
    #define mp make_pair
    #define REP(i,n) for (int i = 0; i < n; i++)
    #define loop(i,n) for (int i = 0; i < n; i++)
    #define FOR(i,a,b) for (int i = a; i < b; i++)
    #define REPD(i,n) for (int i = n-1; i >= 0; i--)
    #define FORD(i,a,b) for (int i = a; i >= b; i--)
    #define remax(a,b) a = max(a,b)
    #define remin(a,b) a = min(a,b)
    #define mem(a, b) memset(a, b, sizeof a)
    #define append push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define print(x) cout << (x) << endl
    #define PRECISION(x) cout << fixed << setprecision(x)
    #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
     
    const double PI=acos(-1);
    const int MOD = 1000000007;
    const int FMOD = 998244353;
    const double eps = 1e-9;
     
    mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
 	
 	
    signed main()
    {
    	int n,k;
		cin>>n>>k;
		if(n>=10)
		{
			cout<<k<<endl;
		}
		else
		{
			cout<<k+100*(10-n)<<endl;
		}
	}

Measured memory_bytes: 256
N = int(input())
eni_B = 0
end_A = 0
both = 0
count = 0

for i in range(N):
    s = list(input())
    if s[0] == 'B':
        eni_B += 1
    if s[-1] == 'A':
        end_A += 1
    if s[0] == 'B' and s[-1] == 'A':
        eni_B -= 1
        end_A -= 1
        both += 1
    for j in range(len(s)-1):
        if s[j] == 'A':
            if s[j+1] == 'B':
                count += 1

m = min(end_A,eni_B)
M = max(end_A,eni_B)

if both == 0 :
    count = count + m
else:
    if m == 0 and M == 0 :
        count = count + both - 1
    else:
        count = count + both + m 

print(count)


Measured memory_bytes: 3188
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

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

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

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

    double ma = 0;
    P ans = P(100*a, 0);
    for(int i=0; i<=f; i+=100*a){
        for(int j=0; i+j<=f; j+=100*b){
            for(int k=0; i+j+k<=f; k+=c){
                for(int l=0; i+j+k+l<=f; l+=d){
                    if((i + j) / 100 * e < k + l) continue;

                    if(ma < 1. * (k + l) * 100 / (i + j + k + l)){
                        ma = 1. * (k + l) * 100 / (i + j + k + l);
                        ans = P(i + j + k + l, k + l);
                    }
                }
            }
        }
    }

    cout << ans.first << " " << ans.second << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 500000
#define INF 1000000000

void merge(int, int, int);
void mergeSort(int, int);

int S[N], count=0;

int main()
{
  int i, n;

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

  mergeSort(0, n);

  for(i = 0 ; i < n-1 ; i++){
    printf("%d ", S[i]);
  }
  printf("%d\n", S[i]);
  printf("%d\n", count);

  return 0;
}
  
void merge(int left, int mid, int right)
{
  int i, j, n1, n2, k, L[N/2 +1], R[N/2 +1];
  n1 = mid - left;
  n2 = right - mid;
  
  for(i = 0 ; i < n1 ; i++){
    L[i] = S[left + i];
  }
  for(i = 0 ; i < n2 ; i++){
    R[i] = S[mid + i];
  }
  L[n1] = INF+50;
  R[n2] = INF+50;
  i = 0;
  j = 0;
  for(k = left ; k < right ; k++){
    count++;
    if (L[i] <= R[j]){
      S[k] = L[i];
      i = i + 1;
    }
    else{ 
      S[k] = R[j];
      j = j + 1;
    }
  }
}
 
void mergeSort(int left, int right)
{
  int mid;
  
  if (left+1 < right){
    mid = (left + right)/2;
    mergeSort(left, mid);
    mergeSort(mid, right);
    merge(left, mid, right);
  }
}

Measured memory_bytes: 4504
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

using Data = int;
const int len = 1 << 18;

struct BIT {
  vector<Data> data;
  BIT() : data(len, 0) {}
  void update(int i, Data value) {
    for (; i < len; i |= i+1) data[i] += value;
  }
  Data query(int i) {
    Data s = 0;
    for (; i >= 0; i = (i&i+1)-1) s += data[i];
    return s;
  }
};

bool ok(const vecint& a, const int th) {
  ll n = a.size();
  BIT bit;
  int offset = n;
  ll cnt = 0;
  REP(i,n) {
    bit.update(offset, 1);
    if (a[i] >= th) {
      offset -= 1;
    } else {
      offset += 1;
    }
    cnt += bit.query(offset-1);
  }
  ll m = n * (n+1) / 2;
  ll mid = m/2 + 1;
  return cnt >= mid;
}

int main()
{
  int n;
  cin>>n;
  vecint a(n);
  REP(i,n) cin>>a[i];
  vecint b = a;
  b.push_back(0);
  b.push_back(1000000007);
  sort(ALL(b));
  b.erase(unique(ALL(b)), end(b));
  int hi = b.size()-1;
  int lo = 0;
  while ((hi - lo) > 1) {
    int mid = (hi + lo) / 2;
    if (ok(a, b[mid])) {
      hi = mid;
    } else {
      lo = mid;
    }
  }
  cout << b[lo] << endl;
  return 0;
}


Measured memory_bytes: 2052
/***************************************************************************/
/*                         YOU HAVE IT IN YOU.                            */
/*************************************************************************/

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

const ll MOD = 1e9 + 7;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define vpii vector<pair<int, int>>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define umpll unordered_map<ll, ll>
#define umpii unordered_map<int, int>
#define umpli unordered_map<ll, int>
#define usi unordered_set<int>
#define usll unordered_set<ll>
#define si set<int>
#define sll set<ll>
#define spii set<pair<int, int>>
#define spll set<pair<ll, ll>>

//////////////////////////////////////////////////////////////////////////

void solve(){

}

/////////////////////////////////////////////////////////////////////////

int main()
{
    #ifndef ONLINE_JUDGE
      string inputFile, testOutputFile, outputFile;
      inputFile = "input.txt";
      testOutputFile  = "output.txt";
      freopen(inputFile.c_str(), "r", stdin);
      freopen(testOutputFile.c_str(), "w", stdout);
    #endif

    int t;
    ll n, m, x, k;
    cin>>t;
    switch(t % 10){
      case 2:
      case 5:
      case 7:
      case 4:
      case 9: cout << "hon\n";
               break;
      case 0:
      case 1:
      case 6:
      case 8: cout << "pon\n";
               break;
      default: cout << "bon\n";
   }
    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdtr1c++.h>
#include<list>
#include<algorithm>
using namespace std;

int main(){
    int A,B;
    string c;
    cin >> A >> c >> B;
    if (c == "+"){
        cout << A+B << endl;
    }
    else{
        cout << A-B << endl;
    }
    return 0;
    }

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<unordered_map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define pb push_back
#define endl '\n'
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok = true, flag = false;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 222222


struct BinaryIndexed {
	ll num;
	vll bit;

	BinaryIndexed(ll x = MAX) {
		num = x;
		bit.resize(x + 1, 0);
	}

	ll sum(ll i) {
		ll ret = 0;
		while (i > 0) {
			ret += bit[i];
			i -= i & -i;
		}
		return ret;
	}

	void add(ll i, ll x) {
		if (i == 0) cout << "access 0 index" << endl;
		while (i <= num) {
			bit[i] += x;
			i += i & -i;
		}
	}
};

ll a[MAX], b[MAX];

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


	cin >> n >> m;
	FOR(i, 1, n + 1) {
		cin >> a[i];
	}
	FOR(i, 1, n + 1) b[i] = b[i - 1] + a[i];
	FOR(i, 1, n + 1) b[i] = i * m - b[i];
	vll v;
	FOR(i, 1, n + 1) v.pb(b[i]);
	sort(all(v));
	MAP comp;
	rep(i, n) comp[v[i]] = i + 1;
	BinaryIndexed bit;
	FOR(i, 1, n + 1) {
		if (comp[b[i]] > 1) ans += (i - 1) - bit.sum(comp[b[i]] - 1);
		else ans += i - 1;
		if (b[i] <= 0) ans++;
		bit.add(comp[b[i]], 1);
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 19184
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <deque>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#define ll              long long
#define PII             pair<int, int>
#define rep(i,a,b)      for(int  i=a;i<=b;i++)
#define dec(i,a,b)      for(int  i=a;i>=b;i--)
using namespace std;
int dir[4][2] = { { 0,1 } ,{ 0,-1 },{ 1,0 },{ -1,0 } };
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf = 0x3f3f3f3f;
const double pi = 3.14159265358979323846;
const double eps = 1e-6;
const int mod =1e9+7;
const int N = 1e5+5;
//if(x<0 || x>=r || y<0 || y>=c)

inline ll read()
{
	ll x = 0; bool f = true; char c = getchar();
	while (c < '0' || c > '9') { if (c == '-') f = false; c = getchar(); }
	while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
	return f ? x : -x;
}
ll gcd(ll m, ll n)
{
	return n == 0 ? m : gcd(n, m % n);
}
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}
bool prime(int x) {
    if (x < 2) return false;
    for (int i = 2; i * i <= x; ++i) {
        if (x % i == 0) return false;
    }
    return true;
}
ll qpow(ll m, ll k, ll mod)
{
    ll res = 1, t = m;
    while (k)
    {
        if (k & 1)
            res = res * t % mod;
        t = t * t % mod;
        k >>= 1;
    }
    return res;
}      

int main()
{
    int n;
    cin >> n;
    vector<int> a(n + 1);
    rep(i, 1, n)
        cin >> a[i];
    vector<int> dp(n + 1,0);
    a[0] = a[1];
    rep(i, 2, n)
    {
        dp[i] = min(dp[i-1]+abs(a[i] - a[i - 1]),dp[i-2] + abs(a[i] - a[i - 2]));
    }
    cout << dp[n] << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

bool comp (const vector<ll> &a, const vector<ll> &b){
  return a[1] > b[1];
}
    

int main(){
  int N, M;
  cin >> N >> M;
  ll tmp, b, c, p;
  vector<ll> A;
  vector<vector<ll>> move;
  for (int i=0; i<N; i++){
    cin >> tmp;
    A.push_back(tmp);
  }
  sort(A.begin(), A.end());
  ll Bmax = -1, Cmax = -1;
  for (int i=0; i<M; i++){
    cin >> b >> c;
    move.emplace_back(vector<ll>({b, c}));
  }
  sort(move.begin(), move.end(), comp);
  ll replaced = 0, pl, pr;
  vector<vector<ll>> pickup;
  for (auto e : move){
    if (A.empty()) break;
    pl = (long long)(lower_bound(A.begin(), A.end(), e[1]) - A.begin());
    p = min(pl, e[0]);
    if (p >= 0){
      replaced += p;
      pickup.emplace_back(vector<ll>({p, e[1]}));
      A.erase(A.begin(), A.begin() + p);
    }
    else break;
  }
  ll ans = 0;
  for (auto e : pickup){
    ans += e[0]*e[1];
  }
  for (ll i=0; i<A.size(); i++){
    ans += A[i];
  }
  cout << ans << endl;
                          
  return 0;
}

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

using namespace std;

#define ll long long
#define pii pair<int,int>
#define mod 1000000007
int main()
{
    int n;
    cin>>n;
    vector<ll> a(n),b(n);
    ll x,y;
    for(int i=0;i<n;i++)
    {
        cin>>x>>y;
        a[i] = x+y;
        b[i] = x-y;
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    ll nax = max(a[n-1] -a[0],b[n-1]-b[0]);
    cout<<nax<<endl;
}

Measured memory_bytes: 6352
#!/usr/bin/env python3
import sys


def solve(N: int, a: "List[int]"):
    abs_min = 0
    abs_min_index = 0
    for i in range(N):
        if abs(a[i])>abs_min:
            abs_min = abs(a[i])
            abs_min_index = i
    
    print(2*N-1)
    for j in range(1,N+1):
        print(abs_min_index+1,j)

    if a[abs_min_index] >= 0:
        for j in range(1,N):
            print(j,j+1)
    else:
        for j in range(N,1,-1):
            print(j,j-1)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


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

#define rep(i, o) for (ll i = 0; i < (o);i++)
#define rep_s(i, o) for (int i = 1; i <= (o);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

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


template<class T>
bool chmax(T &a, const T &b) { if (a < b) { return b; } return a; }

template<class T>
bool chmin(T &a, const T &b) { if (a > b) { a = b; return a; } return a; }

int main() {
    ll k, a, b; 
    cin >> k >> a >> b;

    ll ans = 0;
    // cout << b*(k/(a+1))+(k%(a+1)) << endl;
    // ll biscuit = 1; ll yen = 0;
    // rep(i, k) {
    //     if (yen == 1) { ans += b*yen; yen = 0; continue; }
    //     if (biscuit == a) { yen = 1; biscuit = 0; continue; }
    //     biscuit++; 
    //     // if (a+1 <= k) ans = max(k+1, b*(k/(a+1))+(k%(a+1)));
    //     // else ans = k+1;
    //     // cout << ans << endl;
    // }
    // cout << ((ans+biscuit > k+1) ? ans+biscuit : k+1) << endl;
    if (b-a <= 2) ans = k+1;
    else 
    { 
        ans += a;
        ans += (b-a) * ((k-a+1)/2);
        ans += (k-a+1)%2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
A=int( input() )
B=int( input() )
C=int( input() )
target=int( input() )
num=0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if a*500+b*100+c*50 == target:
                num+=1
print(num)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#define ll long long
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;

int main(){
    int n,ans;
    int *a;
    ll sum=0;
    cin >> n;
    a = new int[n-1];
    vector<vector<ll>> dp(n,vector<ll>(21,0));
    rep(i,n-1){
        cin >> a[i];
    }
    cin >> ans;
    
    dp[1][a[0]]=1;

    for(int i=1;i<n-1;i++){
        rep(k,21){
            if (k+a[i] <= 20) {
                dp[i+1][k+a[i]] += dp[i][k]; 
            }
            if (k-a[i] >= 0) {
                dp[i+1][k-a[i]] += dp[i][k];
            }
        }
    }

    cout << dp[n-1][ans] << endl;
    return 0;
}

Measured memory_bytes: 3176
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100


struct Edge{
	Edge(int arg_to,int arg_capacity,int arg_rev_index){
		to = arg_to;
		capacity = arg_capacity;
		rev_index = arg_rev_index;
	}
	int to,capacity,rev_index;
};

int V,E;

vector<Edge> G[NUM];
bool used[NUM];

void add_edge(int from,int to,int capacity){
	G[from].push_back(Edge(to,capacity,G[to].size()));
	G[to].push_back(Edge(from,0,G[from].size()-1));
}

int dfs(int node_id,int sink,int flow){
	if(node_id == sink)return flow;
	used[node_id] = true;

	for(int i = 0; i < G[node_id].size(); i++){
		Edge &e = G[node_id][i];
		if(used[e.to] == false && e.capacity > 0){
			int tmp_flow = dfs(e.to,sink,min(flow,e.capacity));
			if(tmp_flow > 0){
				e.capacity -= tmp_flow;
				G[e.to][e.rev_index].capacity += tmp_flow;
				return tmp_flow;
			}
		}
	}
	return 0;
}


int max_flow(int source,int sink){
	int flow = 0,add;
	while(true){
		for(int i = 0; i < V; i++)used[i] = false;
		add = dfs(source,sink,BIG_NUM);
		if(add == 0)break;
		flow += add;
	}
	return flow;
}


int main(){

	scanf("%d %d",&V,&E);

	int from,to,cost;

	for(int loop = 0; loop < E; loop++){
		scanf("%d %d %d",&from,&to,&cost);
		add_edge(from,to,cost);
	}

	printf("%d\n",max_flow(0,V-1));

	return 0;
}



Measured memory_bytes: 3232
#include <stdio.h>

int main(void)
{
	int i, fi, fi2;
	char c;
	
	scanf("%d", &fi);
	while (1){
		
		scanf(" %c", &c);
		
		if (c == '='){
			break;
		}
		
		scanf("%d", &fi2);
		
		if (c == '+'){
			fi += fi2;
		}
		else if (c == '-'){
			fi -= fi2;
		}
		else if (c == '*'){
			fi *= fi2;
		}
		else{
			fi /= fi2;
		}
	}
	
	printf("%d\n", fi);
	return (0);
}
			

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

int main() {
    int n, m, x, y, minY, maxX;

    cin >> n >> m >> x >> y;

    minY = y;
    maxX = x;

    for (int i = 0, c; i < n; i++) {
        cin >> c;
        maxX = max(maxX, c);
    }

    for (int i = 0, c; i < m; i++) {
        cin >> c;
        minY = min(minY, c);
    }

    if (maxX < minY)
        cout << "No War" << endl;
    else
        cout << "War" << endl;
    return 0;
}


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

using namespace std;

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

  int n;
  cin>> n;
  int come[120000]={0};
  come[0]++;
  for(int i=0;i<n;i++){
    int a,b;
    cin >> a>>b;
    come[a]++;
    come[b+1]--;
  }
  for(int i=1;i<120000;i++) come[i]+=come[i-1];
  int res=1;
  for(int i=2;i<120000;i++){
    if(i<=come[i]) res=i;
  }
  cout << res-1 << endl;
}

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

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

// 最大公約数（a > b）
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}

int main() {
  int N;
  cin >> N;
  ll a[N];
  for (int i = 0; i < N; i++) cin >> a[i];

  int lgcd[N];
  lgcd[0] = a[0];
  for (int i = 1; i < N; i++) lgcd[i] = gcd(lgcd[i-1], a[i]);
  int rgcd[N];
  rgcd[N-1] = a[N-1];
  for (int i = N - 2; i >= 0; i--) rgcd[i] = gcd(rgcd[i+1], a[i]);

  int ans = max(rgcd[1], lgcd[N-2]);
  for (int i = 1; i < N - 1; i++) {
    ans = max(ans, gcd(lgcd[i-1], rgcd[i+1]));
  }

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


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W == 0) break;
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    if((i%2+j)%2==0) System.out.printf("#");
                    else System.out.printf(".");
                }
                System.out.println();
            }
            System.out.println();
        }
        sc.close();
    }
}


Measured memory_bytes: 61108
// 自分の手番で必勝となる場合を考える
// - 残りの木にあるりんごがぜんぶ1
// - 残りの木が1でりんごが奇数
// サンプル1 -> 残りの木が偶数で総数が奇数？
//					-> 相手に「残りの木が奇数で総数が偶数」を押し付けると勝てる？
// ここまでで雑に「総数が奇数orNならこっちの勝ち」として2WAあるらしい
// 所与の総数が奇数でも負ける場合がある or 所与の総数が偶数でも勝てる場合がある のどっちかだと思われ
// 後者
// ex)[1, 3]
// 自 [0 2]
// 相 [0 1] 偶数を押し付けられなくなったので相手の負け
// 本数が偶数かつ総数が偶数なら勝てるのでは？
// -> WAが増えました 死
// （なんでだろうね）
// -> 反例 [2 2 1 3]だと
// 自[1 1 0 2] 相手必敗
// じゃひとつでもAに奇数があったら勝てるのでは?

package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	sum := 0
	odd := false
	for i := 0; i < N; i++ {
		var V int
		fmt.Scan(&V)
		sum += V
		if V%2 == 1 {
			odd = true
		}
	}
	if sum == N || sum%2 == 1 || (sum%2 == 0 && odd) {
		fmt.Println("first")
	} else {
		fmt.Println("second")
	}
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define F first
#define S second

int a[100009][20];
int b[100009];
int n,L,test;

signed main(){
	cin>>n;
	r(i,n) cin>>b[i];
	cin>>L;
	r(j,20){
		if(j==0){
			int id=0,sum=0;
			r(i,n){
				while(id<n-1 && sum+(b[id+1]-b[id])<=L) sum += b[id+1]-b[id],id++;
				a[i][j] = id;
				//cout<<id<<endl;
				if(i!=n-1 && sum)sum -=b[i+1]-b[i];
			}
		}
		else{
			r(i,n){
				a[i][j] = a[a[i][j-1]][j-1];
			}
		}
	}



	cin>>test;
	while(test--){
		int l,r;
		cin>>l>>r; l--; r--;
		if(r<l)swap(l,r);
		int sum=0;
		while(l<r){
			//cout<<l<<endl;
			for(int i=19;i>=0;i--){
				if(i&&( a[l][i]>=r ))continue;
				//cout<<l<<' '<<i<<' '<<a[l][i]<<' '<<i<<endl;
				l=a[l][i];
				sum+=pow(2,i);
				break;
			}
			//cout<<l<<endl;
		}
		cout<<sum<<endl;
	}
}


Measured memory_bytes: 17280
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back

using namespace std;

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

const int MAXN = 2e5 + 10;
const ll mod = 1e9+7;

ll n, m, k;
ll p, q;

ll mypow(ll x, ll p){
	ll ret = 1;
	while(p){
		if(p&1){
			ret *= x;
			ret %= mod;
		}
		x *= x;
		x %= mod;
		p >>= 1;
	}

	return ret;
}

int main(){
	ios_base::sync_with_stdio(false), cin.tie(0);
	cin >> n >> m >> k;
	p = q = 1;

	ll ck = k - 2;
	ll cn = n*m - 2;
	for(ll i=1; i<=cn; i++){
		p *= i;
		p %= mod;
	}

	for(ll i=1; i<=cn-ck; i++){
		q *= i;
		q %= mod;
	}
	for(ll i=1; i<=ck; i++){
		q *= i;
		q %= mod;
	}
	
	ll ans = 0;
	ll ot = 0;
	for(ll i=1; i<=n; i++){
		ans += ot * m;	
		ans %= mod;
		
		ot += i * m;
		ot %= mod;
	}

	ot = 0;
	for(ll i=1; i<=m; i++){
		ans += ot * n;
		ans %= mod;

		ot += i * n;
		ot %= mod;
	}

	ans *= p;
	ans %= mod;
	ans *= mypow(q, mod-2);
	ans %= mod;
	
	cout << ans << endl;
}


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

#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)

using ll = long long;
#define INF 1e9

int N, M;
vector<int> A;
ll ans = 0;

int main(){
  cin >> N >> M;
  A.resize(N);
  priority_queue<int> que;
  REP(i, N){
    cin >> A[i];
    que.push(A[i]);
  }
  REP(i, M){
    int top = que.top()/2;
    que.pop();
    que.push(top);
  }
  REP(i, N){
    ans += que.top();
    que.pop();
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1276
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
typedef long long ll;
using namespace std;

#define PI 3.14159265358979323846264338327950L

int res = 0;

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

    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++)
    {
        int you = A[A[i] - 1];
        if (i + 1 == you)
        {
            res++;
        }
    }
    cout << res/2 << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	int data[50];
	for(int i=0;i<n;i++){
		cin>>data[i];
	}
	sort(data,data+n);
	int ans=0;
	for(int i=1;i<=k;i++){
		ans+=data[n-i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    String s;
    private void solve() {
        s = next();
        int N = s.length();

        int a = 0;
        for(int i = 0;i < N;i++) {
            if (s.charAt(i) == '0' + (i % 2)) {
                a++;
            }
        }

        int b = 0;
        for(int i = 0;i < N;i++) {
            if (s.charAt(i) == '0' + ((i+1) % 2)) {
                b++;
            }
        }

        out.println(Math.min(a, b));
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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

int main(){
  while(1){
    int h, w, n;
    int i, j;
    int field[1001][1001], dp[1001][1001];
    memset(field, -1, sizeof(field));
    memset(dp, 0, sizeof(dp));
    scanf("%d%d%d", &h, &w, &n);
    if(h == 0 && w == 0 && n == 0)return 0;
    for(i = 0;i < h;i++){
      for(j = 0;j < w;j++){
	scanf("%d", &field[i][j]);
      }
    }
    dp[0][0] = n;
    for(i = 0;i < h;i++){
      for(j = 0;j < w;j++){
	if(field[i][j] == 0){
	  dp[i][j + 1] += dp[i][j] / 2;
	  dp[i + 1][j] += dp[i][j] - dp[i][j] / 2;
	}
	else{
	  dp[i + 1][j] += dp[i][j] / 2;
	  dp[i][j + 1] += dp[i][j] - dp[i][j] / 2;
	}
	field[i][j] += dp[i][j];
	field[i][j] %= 2;
      }
    }
    int pi = 0, pj = 0;
    while(field[pi][pj] != -1){
      if(field[pi][pj] == 1){
	pi++;
      }
      else pj++;
    }
    printf("%d %d\n", pi + 1, pj + 1);
  }
}

Measured memory_bytes: 8436
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##_len=(int)(n);i<i##_len;++i)
#define REP(i,n) REPF(i,0,n)
#define RREP(i,n) for(int i=(int)(n);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int a,b;
    cin>>a>>b;
    cout<<(a+b)%24<<endl;
    return 0;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input!{
        n: usize,
        m: usize,
        h: [usize; n],
    }

    let mut edge = vec![Vec::<usize>::new(); n];

    for _ in 0..m {
        input!{
            a: usize,
            b: usize,
        }

        let a = a-1;
        let b = b-1;
        edge[a].push(b);
        edge[b].push(a);
    }

    let mut top = vec![true; n];

    for i in 0..n {
        for j in edge[i].iter() {
            if h[i] <= h[*j] {
                top[i] = false;
            }
        }
    }

    let mut ans = 0;

    for i in top {
        if i {
            ans += 1;
        }
    }

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


Measured memory_bytes: 10996
#include <iostream>
#include <cstdio>
#include <string>
#include <bits/stdc++.h>
#include <set>
#include <list> //list<???> a; a.push_back ,insert(追加したい要素),a.sort(),参照できない
#include <vector> //vector<???> a; a.push_back,sort(a.begin(),a.end());a[i]
//配列 int a[N];a[i]=追加したい要素;sort(a,a+N);a[i]
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)


//using namespace std;
//


int main(){
  string A,S,C;cin>>A>>S>>C;


  cout<<"A"<<S[0]<<"C"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define iFOR(i, a, b) for(int i=(a); i>=(b); --i)
#define make_unique(a) sort(all((a))), (a).resize(unique(all((a)))-(a).begin())

using namespace std;

typedef pair<int,int> PII;
typedef long long LL;
typedef double DD;
typedef long double LD;
typedef pair<LL,LL> PLL;
typedef pair<DD,DD> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;
char str[200005];
int dp[2055];
int main(){
	int i,j,k,l,a,b,c,d;
    scanf("%s",str+1);
    a = strlen(str+1);
    FOR(i, 1, 2018){
        if((i*10)%2019 == 1){
            b = i; break;
        }
    }
    dp[0] = 1; c = 1;
    int x = 0; 
    LL ans = 0;
    FOR(i, 1, a){
        d = (c*(str[i]-'0'))%2019;
        x = (x+d)%2019;
        ans += dp[x];
        dp[x]++;
        c = (c*b)%2019;
    }
    printf("%lld",ans);
	return 0;
}
/*
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */


Measured memory_bytes: 4024
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int> V(N);
    rep(i,0,N)cin >> V[i];
    sort(V.begin(), V.end());
    cout << V.back() - V.front() << endl;
}

Measured memory_bytes: 256
s = input()

if len(s) == 2 and s[0] == s[1]:
  print("1 2")
  import sys
  sys.exit()

for i in range(len(s)-2):
  if s[i] == s[i+1] or s[i] == s[i+2] or s[i+1] == s[i+2]:
    print("{} {}".format(i+1, i+3))
    import sys
    sys.exit()

print("-1 -1")

Measured memory_bytes: 3188
S=input()

l=len(S)

while True:
    if S[-7:]=="dreamer":
        S=S[:-7] 
    elif S[-6:]=="eraser":
        S=S[:-6]
    elif S[-5:]=="dream":
        S=S[:-5]
    elif S[-5:]=="erase":
        S=S[:-5]

    if l==len(S):
        break
    else:
        l=len(S)


if l==0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3188
#include<stdio.h>

int main(void)
{
	int a,b,c,x,y,z;
	
	scanf("%d %d %d",&a,&b,&c);

	if(a > b){
		x = a;
		a = b;
		b = x;
		}

	if(b > c){
		y = b;
		b = c;
		c = y;
		}

	if(a > b){
		z = a;
		a = b;
		b = z;
		}

	printf("%d %d %d\n",a,b,c);

	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans1 = min(a, b);
  ll ans2 = max((ll)0, a + b - n);
  cout << ans1 << " " << ans2 << endl;
}

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

int main(){
  int n;
  cin>>n;
  vector<int> p(n);
  for(int i=0;i<n;++i){
    cin>>p.at(i);
  }

  int count=0;
  for(int i=1;i<n-1;++i){
    if(p.at(i)>min(p.at(i-1),p.at(i+1)) && p.at(i)<max(p.at(i-1),p.at(i+1))){
      ++count;
    }
  }

  cout<<count<<endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

long int M = 1e+9+7;
int inf = 1e+9;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int n,k;
    cin >> n >> k;
    vi h(n);
    rep(i,n){
        cin >> h[i];
    }
    sort(rng(h));
    int ans=inf;
    rep(i,n-k+1){
        int mx=h[i+k-1];
        int mn=h[i];
        chmin(ans,mx-mn);
        //cout << mx-mn << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);

  if((a==b&&a!=c)||(b==c && a!=b)||(a==c && a!=b))
    printf("Yes");
  else
    printf("No");

  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int min(int a, int b);

int main(void)
{
	int p[3];
	int j[2];
	int i;
	int p_min;
	int j_min;
	int ans;
	
	for (i = 0; i < 3; i++){
		scanf("%d\n", &p[i]);
	}
	for (i = 0; i < 2; i++){
		scanf("%d\n", &j[i]);
	}
	
	p_min = min(p[0], min(p[1], p[2]));
	j_min = min(j[0], j[1]);
	
	ans = (p_min + j_min) - 50;
	
	printf("%d\n", ans);
	
	return (0);
}

int min(int a, int b)
{
	if (a > b){
		return (b);
	}
	else {
		return (a);
	}
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a >= b && a >= c) cout << b + c << endl;
    else if(b >= c && b >= a) cout << c + a << endl;
    else if(c >= a && c >= b) cout << a + b << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a, b, c, d , e ,f ;
	float x, y;
	while(scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f)!=-1){
		x = (float)(c * e - b * f) / (a * e - b * d);
		y = (float)(-d * c + a * f) / (a * e - b * d);
		//x += 0.0005;
		//y += 0.0005;
		if (x <= 0 && x > -0.0005) x = 0;
		if (y <= 0 && y > -0.0005) y = 0;
		printf("%.3f %.3f\n", x, y);
	}
	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
typedef long long ll;
#define vstroku() to_string()
#define vchislo() to_ulong()
#define gcd(x,y) __builtin_gcd(x,y)
#define numberof1(x) __builtin_popcount(x)
#define povsemelementam(i,mnozh) for(auto i: mnozh)
#define podotrezok(i,j) substr(i-1,j) // like prefix sum, (i,j)=s[j]-s[i-1]
#define pb push_back
#define pf push_front
#define popf pop_front
#define popb pop_back 
#define pii pair <int, int>
#define F first
#define S second
#define mipletsplay ios_base::sync_with_stdio(0); cin.tie(0); 


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 3e5;
const ll INF = 1e9;
const ll kek=998244353;

int main() {
mipletsplay;

ll l,r;
cin>>l>>r;
int q=l%2019;
int f=r%2019;
if (l>=r||r-l>=2019)
cout<<0;
else
{
int minix=INF;
for (int i=q;i<=f;i++)
{
for (int j=i+1;j<=f;j++)
minix=min(minix,(i*j)%2019);
}
cout<<minix; 
}
}

Measured memory_bytes: 256
N,K=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*N
dp[0]=0
dp[1]=abs(h[0]-h[1])
for i in range(2,N):
  dp[i] = min( dp[j] + abs(h[i]-h[j]) for j in range(max(0,i-K),i) )
print(dp[-1])

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

int main() {
  int N;
  cin >> N;
  int sum1 = 0;//前半
  int sum2;//後半
  
  vector<int> W(N);
  rep(i, N) {
    cin >> W[i];
    sum2 += W[i];
  }
  
  rep(i, N) {
    sum1 += W[i];
    sum2 -= W[i];
    if (sum1 >= sum2) {
      int x = abs(sum2 - sum1);
      int y = abs(sum2 - sum1 +2*W[i]);
      if (x >= y) cout << y << endl;
      else cout << x << endl;
      return 0;
    }
  }
}


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

int n, r = 0, b = 0;
string s, ans;

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

    for (int i = 0; i < n; ++i)
    {
        if (s.at(i) == 'R')
        {
            r++;
        }

        if (s.at(i) == 'B')
        {
            b++;
        }     
    }

    if (r > b)
    {
        ans = "Yes";
    } else {
        ans = "No";
    }

    cout << ans << endl;
}

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

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

using namespace std;

using int64 = int64_t;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> cnt(10, vector<int>(10));
  for (int i = 1; i <= n; i++) {
    string s = to_string(i);
    int firs = s[0] - '0', last = s.back() - '0';
    ++cnt[firs][last];
  }
  int ans = 0;
  rep(i, 10) {
    rep(j, 10) {
      ans += cnt[i][j] * cnt[j][i];
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3652
#　N M の形で受け取る
N,M = map(int, input().split())

#　複数の要素をまとめて受け取る
A = list(map(int, input().split()))

#　リストAの総和を取る
S = sum(A)

#入力チェック

if N - S >= 0:
    print(N-S)
else:
    print(-1)

Measured memory_bytes: 9884