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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

// クエリあたりO(lonN)で処理できる
// 1-indexedなので注意
// 区間加算にも対応した BIT
template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

signed main()
{   
    gearup;
    ll n,k; cin >> n >> k;
    vl a(n);
    rep(i,n)cin>>a[i];

    rep(j,min(1LL*100,k)){
        BIT<int> bit(n+1);
        rep(i,n){
            ll left = max(i-a[i],0LL);
            ll right = min(n,i+a[i]+1);
            bit.add(left+1,right+1,1);
        }
        rep(i,n){
            a[i] = bit.sum(i+1,i+2);
        }
    }
    rep(i,n){
        if(i) cout << " ";
        cout << a[i];
    }
    cout << endl;
}


Measured memory_bytes: 6268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
#define N 100010
int main(){
    ll h,w;cin>>h>>w;
    if(h==1||w==1){co(1);return 0;}
    co(((h%2==1)&&(w%2==1))?(h*w/2+1):(h*w/2));
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int sum[1001];

int main() {
  for (int i = 1; i < 1001; i++) sum[i] = sum[i-1] + i;
  int n;
  while(cin >> n, n) {
    int ans = 0;
      for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= i - 2; j++) {
          if (sum[i] - sum[j] == n) ans++;
        }
      }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const int MOD = 1000000007;

struct mint
{
  ll x;
  mint(ll x = 0) : x((x % MOD + MOD) % MOD)
  {
  }
  mint operator-() const
  {
    return mint(-x);
  }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += MOD - a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint &operator^=(const mint a)
  {
    (x ^= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const
  {
    return mint(*this) += a;
  }
  mint operator-(const mint a) const
  {
    return mint(*this) -= a;
  }
  mint operator*(const mint a) const
  {
    return mint(*this) *= a;
  }
  mint operator^(const mint a) const
  {
    return mint(*this) ^= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const
  {
    return pow(MOD - 2);
  }
  mint &operator/=(const mint a)
  {
    return *this *= a.inv();
  }
  mint operator/(const mint a) const
  {
    return mint(*this) /= a;
  }
};
istream &operator>>(istream &is, const mint &a)
{
  return is >> a.x;
}
ostream &operator<<(ostream &os, const mint &a)
{
  return os << a.x;
}

struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < MOD);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
      fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
      ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
      return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main()
{
  long long S;
  scanf("%lld", &S);
  combination comb(2000);

  mint sum = 0;

  for (ll i = 0; i < S / 3; ++i)
  {
    ll t = S - 3 * (i + 1);
    sum += comb.fact[t + i] * comb.ifact[t] * comb.ifact[i];
  }
  cout << sum << endl;

  return 0;
}


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

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

	int ans = 0;
	for (int i = a; i <= b; i++) {
		string a_tmp, b_tmp;
		string ch = to_string(i);
		for (int j = 0; j < ch.size(); j++) {
			a_tmp.push_back(char(ch[j]));
			b_tmp.push_back(char(ch[ch.size() - j-1]));
		}
		if (a_tmp == b_tmp)ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3644
import math
a, b = map(int, input().split())
ta = a / 0.08
tb = b / 0.10
if (math.floor(ta * 0.1) == b):
  print(math.ceil(ta))
elif (math.floor(tb * 0.08) == a):
  print(math.ceil(tb))
else:
  print(-1)


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(){
    int x,y;
    cin>>x>>y;
    int b,s,z;
    if(x>=y){
        b=x;
        s=y;
    }
    else if(x<y){
        b=y;
        s=x;
    }
    while(1){
        z=b%s;
        if(z==0){
            break;
        }
        else{
            b=s;
            s=z;
        }
    }
    cout<<s<<endl;
}


Measured memory_bytes: 3096
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let n = input::<i64>();
    let t = input::<i64>();
    let ct = (0..n)
        .map(|_| {
            let c = input();
            let t = input();
            (c, t)
        })
        .collect::<Vec<(i64, i64)>>();

    let ans = ct
        .iter()
        .filter_map(|&(ci, ti)| if ti <= t { Some(ci) } else { None })
        .min();
    match ans {
        Some(c) => println!("{}", c),
        _ => println!("TLE"),
    }
}


Measured memory_bytes: 4352
<?php

ini_set('error_reporting', E_ALL & ~E_NOTICE);

// define('DEBUG', true);
define('DEBUG', false);

define('MOD', pow(10, 9) + 7);

fscanf(STDIN, "%d %d", $N, $M);
if ($N == $M) {
    $ans = 1;
    for ($i = 0; $i < $N; $i++) {
        $ans *= $N - $i;
        $ans %= MOD;
    }
    for ($i = 0; $i < $N; $i++) {
        $ans *= $N - $i;
        $ans %= MOD;
    }
    $ans *= 2;
    $ans %= MOD;
} elseif ($N - 1 == $M || $N + 1 == $M) {
    $ans = 1;
    $mmax = max($N, $M);
    $mmin = min($N, $M);
    for ($i = 0; $i < $mmax; $i++) {
        $ans *= $mmax - $i;
        $ans %= MOD;
    }
    for ($i = 0; $i < $mmin; $i++) {
        $ans *= $mmin - $i;
        $ans %= MOD;
    }
} else {
    echo "0\n";
    exit;
}

echo $ans . PHP_EOL;



Measured memory_bytes: 5240
#https://atcoder.jp/contests/abc065/tasks/arc076_b

from heapq import heappush, heappop

def prim_heap(edges, n):
    visited = [False] * n
    heap = []
    start = 0
    for e in edges[start]:
        heappush(heap, e)
    visited[start] = True

    res = 0
    while heap:
        cost, v = heappop(heap)
        if visited[v]:
            continue
        visited[v] = True
        res += cost
        for c,u in edges[v]:
            if visited[u]:
                continue
            heappush(heap, (c,u))
    return res

n = int(input())
edges = []

for i in range(n):
    x,y = map(int,input().split())
    edges.append((x,y))

x = sorted(range(n), key=lambda i:edges[i][0])
y = sorted(range(n), key=lambda i:edges[i][1])
edge_list = [[] for _ in range(n)]
manhattan = lambda a,b: min(abs(a[0] - b[0]), abs(a[1] - b[1]))
for i in range(n):
    if i + 1 < n:
        edge_list[x[i]].append((manhattan(edges[x[i]], edges[x[i+1]]), x[i+1]))
        edge_list[x[i+1]].append((manhattan(edges[x[i]], edges[x[i+1]]), x[i]))
        edge_list[y[i]].append((manhattan(edges[y[i]], edges[y[i+1]]), y[i+1]))
        edge_list[y[i+1]].append((manhattan(edges[y[i]], edges[y[i+1]]), y[i]))

print(prim_heap(edge_list, n))
# print(edge_list)


Measured memory_bytes: 82836
#include "bits/stdc++.h"
#define lpa(i,a,b) for(int i=a; i<b; ++i)
#define lp(i,n) lpa(i,0,n)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define print_v(v,n) lp(i,n) cout<<v[i]<<' '; cout<<'\n';
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
bool dist(std::vector<int> &p, std::vector<int> &q){
	double dits = 0;
	lp(i, p.size()) dits += (q[i] - p[i]) * (q[i] - p[i]);
	dits = sqrt(dits);
	return dits == floor(dits); 
}
int main(int argc, char const *argv[])
{
	int n,d;
	cin>>n>>d;
	vector<vector<int>> point(n, vector<int>(d));
	lp(i, n)
		lp(j, d) cin>>point[i][j];
	int np = 0;
	lp(i, n){
		lpa(j, i+1, n){
			if(dist(point[i], point[j])) ++np;
		}
	}
	cout<<np;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A;
  string AA;
  cin >> A >> AA;
  int count=0;
  for(int i=0;i<=A-3;i++){
  	if(AA[i]=='A'&&AA[i+1]=='B'&&AA[i+2]=='C')count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    int a, b;
    cin >> a >> b;
    FOR(i, 1, 10000) {
        if(floor(i/12.5) == a && floor(i/10.0) == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <cmath>
#include <map>

using ll = long long;

int main()
{
    std::string S;
    std::cin >> S;

    int red = 0, blue = 0;
    for (int i = 0; i < (int)S.length(); i++)
    {
        if (S[i] == '0')red++;
        else blue++;
    }
    int min = std::min(red, blue);
    std::cout << min * 2 << std::endl;

    return 0;
}

Measured memory_bytes: 512
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>

#define LL long long int
#define pb push_back
#define mp make_pair
#define MAX 100005
#define MOD 1000000007

using namespace std;

int main() {
	int n, m, x, sum = 0;
	cin>>n>>m;
	
	for(int i=0;i<m;i++) {
		cin>>x;
		sum += x;
	}
	
	n = n - sum;
	if(n<0) n = -1;
	cout<<n<<endl;
    return 0;
}



Measured memory_bytes: 3632
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) - 1 for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n, m = map(int, input().split())

d = getSomeInputListInt(m)

path = []
for p in itertools.permutations(range(1, n), n-1):
    tmp = (0,) + p
    path.append(tmp)


def pathsearch(a, b):
    flga = False
    for tmp_d in d:
        if a in tmp_d and b in tmp_d:
            flga = True
            break

    return flga


ans = 0
for p in path:
    flg = True
    for i in range(1, n, 1):
        tmp = pathsearch(p[i - 1], p[i])
        if not tmp:
            flg = False
            break

    if flg:
        ans += 1

print(ans)


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

#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 pb push_back
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 = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222



ll d[33][33];



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


  
  cin >> n >> m;
  rep(i, n) rep(j, m) cin >> d[i][j];
  rep(i, n) {
    FOR(j, i + 1, n) {
      ll sum = 0;
      rep(k, m) sum += (d[i][k] - d[j][k])*(d[i][k] - d[j][k]);
      double d = sqrt(sum);
      if ((ll)d == d) ans++;
    }
  }
  cout << ans << endl;





  return 0;
}

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

int main()
{
	int sum = 0, max = 0;
	bool check = false;
	string s;
	cin >> s;
	for(int i = 0; i < s.size()-1; i++)
	{
		if( s[i] == 'R')
			check = true;
		if( s[i] == s[i+1]  and s[i] == 'R' )
		{
			sum++;
			if( sum > max )
				max = sum;
		}
		else
			sum = 0;
	}
 	if( s[s.size()-1] == 'R' )
	 	check = true;
	if( max == 0 and check == false )
		cout << 0;
	else
		cout << max+1;	
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;

////////////// Prewritten code follows. Look down for solution. ////////////////
#define x first
#define y second
#define len(x) ((int)(x).size())
using pii = pair<int, int>;
using ll = long long;
using llu = long long unsigned;
using ld = long double;

const ld EPS = 1e-9;
inline int cmp(ld x, ld y = 0, ld tol = EPS) {
	return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

const int MOD = 1e9+7;
inline int mod (ll x, int m = MOD) {
	return (int)(((x%m) + m)%m);
}

////////////////////////// Solution starts below. //////////////////////////////

const int N = 110, K = 1e5+10;

int n, k;
int a[N];
int pd[N][K];

int main () {
	scanf ("%d %d", &n, &k);
	for (int i = 1; i <= n; i++)
		scanf ("%d", &a[i]);
	
	for (int j = 0; j <= a[1]; j++)
		pd[1][j] = 1;
	for (int i = 2; i <= n; i++) {
		int acu = 0;
		for (int j = 0; j <= k; j++) {
			acu = mod (acu + pd[i-1][j]);
			if ((j-a[i]-1) >= 0) acu = mod (acu - pd[i-1][j-a[i]-1]);
			pd[i][j] = acu;
		}
	}
// 	for (int i = 1; i <= n; i++) {
// 		for (int j = 0; j <= k; j++)
// 			printf ("%d ", pd[i][j]);
// 		putchar ('\n');
// 	}
	
	printf ("%d\n", pd[n][k]);

	return 0;
}


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

int main(){
	while(1){
		int n , k[10010];
		scanf("%d",&n); if(n == 0)break;
		for(int i = 0 ; i < n ; i ++){
			scanf("%d",&k[i]);
		}
		int cnt = 0;
		bool t = false;
		for(int i = 0 ; i < n ; i ++){
			if(k[i] > 0)cnt ++;
			if(k[i] >= 2)t = true;
		}
		if(t)printf("%d\n",cnt+1);
		else puts("NA");
	}
}

Measured memory_bytes: 1236
#include <iostream>
#include <vector>
#include <functional>

using namespace std;

vector<vector<int>> color(int N, int D)
{
    vector<int> Dx, Dy;
    for (int y=0; y<2*N; y++)
    for (int x=0; x<2*N; x++)
    if (x*x+y*y==D)
    {
        Dx.push_back(x);
        Dy.push_back(y);
        if (y>0)
        {
            Dx.push_back(x);
            Dy.push_back(-y);
        }
        if (x>0)
        {
            Dx.push_back(-x);
            Dy.push_back(y);
        }
        if (x>0 && y>0)
        {
            Dx.push_back(-x);
            Dy.push_back(-y);
        }
    }

    vector<vector<int>> C(2*N, vector<int>(2*N, -1));

    function<void (int, int, int)> BT = [&](int x, int y, int c)
    {
        C[y][x] = c;
        for (int d=0; d<(int)Dx.size(); d++)
        {
            int dx = x + Dx[d];
            int dy = y + Dy[d];
            if (0<=dx && dx<2*N && 0<=dy && dy<2*N &&
                C[dy][dx] == -1)
                BT(dx, dy, 1-c);
        }
    };

    for (int y=0; y<2*N; y++)
    for (int x=0; x<2*N; x++)
    if (C[y][x]==-1)
        BT(x, y, 0);

    return C;
}

int main()
{
    int N, D1, D2;
    cin>>N>>D1>>D2;

    vector<vector<int>> C1 = color(N, D1);
    vector<vector<int>> C2 = color(N, D2);

    vector<int> X[4], Y[4];
    for (int y=0; y<2*N; y++)
    for (int x=0; x<2*N; x++)
    {
        int c = C1[y][x] + 2*C2[y][x];
        X[c].push_back(x);
        Y[c].push_back(y);
    }

    for (int i=0; i<4; i++)
    if ((int)X[i].size() >= N*N)
    {
        for (int j=0; j<N*N; j++)
            cout<<X[i][j]<<" "<<Y[i][j]<<endl;
        break;
    }
}


Measured memory_bytes: 29304
#include<bits/stdc++.h>
using namespace std;
const int N = 300000 + 10;
int arr[N];
const double eps = 1e-10;
char s[N], x[N], ans[N];
int cnt1[30], cnt2[30];
int cmp(char a, char b)
{
    return a>b;

}
int main()
{
    int a, b, c;
    cin>>a>>b>>c;
    if(c>=a && c<=b)
        puts("Yes");
    else puts("No");
}


Measured memory_bytes: 256
#lang racket

(define (sum items comb)
  (let iter ([queries items])
    (if (null? queries)
        0
        (let* ([query (car queries)]
               [a (vector-ref query 0)]
               [b (vector-ref query 1)]
               [c (vector-ref query 2)]
               [d (vector-ref query 3)])
          (+ (if (= (- (vector-ref comb b) (vector-ref comb a)) c)
                 d
                 0)
             (iter (cdr queries)))))))

           
          
(define (solve N M queries ans)
  (define (dfs now i comb)
    (if (= i N)
        (void)
        (let iter ([j M])
          (if (< j now)
              (void)
              (begin
                (vector-set! comb i j)
                (set! ans (max ans (sum queries comb)))
                (dfs j (+ i 1) comb)
                (iter (- j 1)))))))
  (begin
    (dfs 1 0 (make-vector N M))
    ans))
          
          
(define (readlines q)
  (let iter ([i q])
    (if (zero? i)
        null
        (let ([a (- (read) 1)]
              [b (- (read) 1)]
              [c (read)]
              [d (read)])
          (cons (vector a b c d) (iter (- i 1)))))))

(let* ([N (read)]
       [M (read)]
       [Q (read)])
       (display (solve N M (readlines Q) 0)))

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

string S;

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

	vector<int> v;
	char c = '1';
	int cnt = 0;
	for( int i = 0; i < S.size(); i++ ) {
		if( S[i] == c ) {
			cnt++;
		}
		else {
			v.push_back( cnt );
			cnt = 1;
			c = S[i];
		}
	}
	v.push_back( cnt );
	vector<int> sum( v.size() + 1 );
	for( int i = 0; i < v.size(); i++ ) {
		sum[i + 1] = sum[i] + v[i];
	}
	int ans = 0;
	for( int i = 0; i < v.size(); i += 2 ) {
		int l = i;
		int r = min( i + 2 * K + 1, (int)v.size() );
		int cnt = sum[r] - sum[l];
		ans = max( ans, cnt );
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  string M;
  bool a=false,b=false,c=false;
  cin>>N>>M;
  for(int i=0;i<N;i++)
  {
    a|=M.at(i)=='2';
    b^=M.at(i)=='2'&&((N-1)&i)==i;
    c^=M.at(i)=='3'&&((N-1)&i)==i;
  }
  if(b)
    return cout<<1<<endl,0;
  if(a)
    return cout<<0<<endl,0;
  if(c)
    return cout<<2<<endl,0;
  else
    return cout<<0<<endl,0;
}

Measured memory_bytes: 1412
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const ll inf=1ll<<60;

int main(){
  int a,b,q;
  cin >> a >> b >> q;
  vector<ll> s(a+4); s[0]=-inf-1; s[1]=-inf; s[a+2]=inf; s[a+3]=inf+1;
  vector<ll> t(b+4); t[0]=-inf-1; t[1]=-inf; t[b+2]=inf; t[b+3]=inf+1;
  for(int i=2;i<=a+1;i++) cin >> s[i];
  for(int i=2;i<=b+1;i++) cin >> t[i];
  vector<ll> x(q);
  rep(i,q) cin >> x[i];
  rep(i,q){
    ll a1=*lower_bound(all(s),x[i]);
    ll b1=*prev(lower_bound(all(s),x[i]),1);
    ll c1=*lower_bound(all(t),a1);
    ll d1=*prev(lower_bound(all(t),a1),1);
    ll e1=*lower_bound(all(t),b1);
    ll f1=*prev(lower_bound(all(t),b1),1);
    ll dist1=inf;
    chmin(dist1,abs(x[i]-a1)+abs(a1-c1));
    chmin(dist1,abs(x[i]-a1)+abs(a1-d1));
    chmin(dist1,abs(x[i]-b1)+abs(b1-e1));
    chmin(dist1,abs(x[i]-b1)+abs(b1-f1));
    ll a2=*lower_bound(all(t),x[i]);
    ll b2=*prev(lower_bound(all(t),x[i]),1);
    ll c2=*lower_bound(all(s),a2);
    ll d2=*prev(lower_bound(all(s),a2),1);
    ll e2=*lower_bound(all(s),b2);
    ll f2=*prev(lower_bound(all(s),b2),1);
    ll dist2=inf;
    chmin(dist2,abs(x[i]-a2)+abs(a2-c2));
    chmin(dist2,abs(x[i]-a2)+abs(a2-d2));
    chmin(dist2,abs(x[i]-b2)+abs(b2-e2));
    chmin(dist2,abs(x[i]-b2)+abs(b2-f2));
    ll ans=min(dist1,dist2);
    cout << ans << endl;
  }
}

Measured memory_bytes: 3712
/* ex2_3
   YSK722 */

#include <stdio.h>

int main(void){
    int n, a;
    scanf("%d", &n);
    scanf("%d", &a);
    if(n < 1 || 100 < n){
        return 1;
    }
    if(a < 0 || n * n < a){
        return 1;
    }
    printf("%d\n", n * n - a);
    return 0;
}

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

typedef long long ll;

int main(){

    ll N,K;
    cin >> N >> K;

    ll ans = 1;
    for(ll i = 0; i < N ; i++){
      if (i==0) {
          ans *= K;
      }
      else {
          ans *= K-1;
      }
    }
    cout << ans << endl;

    return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << (var) << endl;
#else
#define debug(var)
#endif

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

void solve() {
	string s; cin >> s;
	int n = s.size();
	for (int i = 0; i < n;) {
		if (s.substr(i, 7) == "dreamer" && (i+7 >= n || s[i+7] == 'd' || s[i+7] == 'e')) {
			i+=7;
		} else if (s.substr(i, 5) == "dream" && (i+5 >= n || s[i+5] == 'd' || s[i+5] == 'e')) {
			i+=5;
		} else if (s.substr(i, 6) == "eraser" && (i+6 >= n || s[i+6] == 'd' || s[i+6] == 'e')) {
			i+=6;
		} else if (s.substr(i, 5) == "erase" && (i+5 >= n || s[i+5] == 'd' || s[i+5] == 'e')) {
			i+=5;
		} else {
			puts("NO");
			return;
		}
	}
	puts("YES");
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


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

int main() {
  int A1,A2,A3;
  cin >> A1 >> A2 >> A3;
  
  string ans = "bust";
  if (A1+A2+A3 >= 22) ans = "bust";
  else ans = "win";
  
  cout << ans << endl;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))

a.sort()

s=[]
ai=a[0]
acnt=-1
for i in range(n):
    if a[i]>ai:
        s.append([acnt+1,ai])
        acnt=0
        ai=a[i]
    else:
        acnt=acnt+1
s.append([acnt+1,ai])
        

if len(s)<=k:
    print(0)
else:
    s.sort()
#    print(s)
    ssum=0
    for i in range(len(s)-k):
        ssum=ssum+s[i][0]
    print(ssum)    
    

Measured memory_bytes: 31396
def main():
    N, x = map(int, input().split())
    a = list(map(int, input().split()))
    a = sorted(a)
    c = 0
    for i in range(N):
        if x >= a[i]:
            x -= a[i]
            c += 1
        else:
            print(c)
            return
    if x > 0:
        print(N-1)
    else:
        print(N)
        
main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
using namespace std;
 
long long dataset[300005]={0};
 
int main()
{
    int number;
    cin>>number;
 
    for(int i=0;i<number;i++)
        cin>>dataset[i];
 
    ll result=0;
    for(ll i=0;i<62;i++)
    {
        long long zeros=0,ones=0;
 
        for(ll j=0;j<number;j++)
        {
            if(dataset[j]%2ll==1)
                ones++;
            else
                zeros++;
            dataset[j]/=2ll;
        }
        result+=((ones*zeros)%MOD*((1ll<<i)%MOD))%MOD;
      result%=MOD;
 
    }
    cout<<result<<endl;
}


Measured memory_bytes: 5840
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr double EPS = 1e-9;


int main() {
    
    // ld a,b,c,d;
    // cin>>a>>b>>c>>d;
    // ld tyo = d/60*360;
    // ld tan = (c/12 + 1.0/12*d/60)*360;
    // ld doo=abs(tan-tyo);
    // // fin(doo);
    // ld co = cos(doo/180*MATHPI);
    // // fin(co);
    // ld ans=a*a+b*b-2*a*b*co;
    // printf("%.9Lf\n",sqrt(ans));
    int k;
    string s;
    cin>>k>>s;
    if(s.size()<=k)fin(s);
    else {
        fin(s.substr(0,k)+"...");
    }
}



Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

const int maxn = int(2e3)+5;

pair<int, int> edge[maxn];
vector<int> graph[maxn];


int dfs(int node, int par, int d)
{
	int res = 1;
	if(!d) return res;
	for(auto it: graph[node])
	{
		if(it != par) res += dfs(it, node, d-1);
	}
	return res;
}

int main(void)
{
	int n, k, u, v;
	scanf("%d%d", &n, &k);
	for(int i = 1;i < n;i++)
	{
		scanf("%d%d", &u, &v);
		u--, v--;
		graph[u].push_back(v);
		graph[v].push_back(u);
		edge[i] = {u, v};
	}

	int res = 0;
	if(k%2)
	{
		for(int i = 1;i < n;i++)
		{
			res = max(res, dfs(edge[i].first, edge[i].second, k/2)+dfs(edge[i].second, edge[i].first, k/2));
		}
	}
	else
	{
		for(int i = 0;i < n;i++)
		{
			res = max(res, dfs(i, -1, k/2));
		}
	}
	printf("%d\n", n-res);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (size_t i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (size_t k = 1; k < v.size(); k++)
	{
		for (size_t j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

class UnionFind
{
public:
	vector<int> par;
	vector<int> rank;
	UnionFind(int N) : par(N)
	{
		par.resize(N);
		par.shrink_to_fit();
		rank.resize(N);
		rank.shrink_to_fit();
		for (int i = 0; i < N; i++)
			par[i] = i, rank[i] = 0;
	}
	int root(int x)
	{
		if (par[x] == x)
			return x;
		return par[x] = root(par[x]);
	}
	void merge(int x, int y)
	{
		x = root(x);
		y = root(y);
		if (x == y)
			return;
		if (rank[x] < rank[y])
			swap(x, y);
		if (rank[x] == rank[y])
			++rank[x];
		par[y] = x;
		return;
	}
	bool is_same(int x, int y)
	{
		return root(x) == root(y);
	}
	size_t size()
	{
		set<int> s;
		for (size_t i = 0; i < par.size(); i++)
		{
			s.insert(root(i));
		}
		return s.size();
	}
};

int main()
{
	int n, m;
	cin >> n >> m;
	UnionFind uf(n);
	rep(i, m)
	{
		int x, y, z;
		cin >> x >> y >> z;
		--x;
		--y;
		uf.merge(x, y);
	}
	cout << uf.size() << endl;
	return 0;
}

Measured memory_bytes: 5760
#include <iostream>

int main()
{
    int n(0);
    std::cin >> n;
    
    int tmp(0), count(0);
    for(int i=0; i < n; ++i){
        std::cin >> tmp;
        if(tmp != i+1){
            ++count;
        }
    }
    
    if(count < 3){
        std::cout << "YES" << std::endl;
    }else{
        std::cout << "NO" << std::endl;
    }
    
    return 0;
}

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

#define     bip(a)         __builtin_popcount(a)
#define     ull            unsigned long long
#define     ll             long long
#define     u              unsigned
#define     pb             push_back
#define     pf             push_front ///for list
#define     mpr            make_pair
#define     is             insert
#define     ff             first
#define     ss             second
#define     vi             vector<int>
#define     vl             vector<ll>
#define     si             set<int>
#define     sl             set<ll>
#define     li             list<int>
#define     pii            pair<int,int>
#define     pll            pair<ll,ll>
#define     mii            map<int,int>
#define     mll            map<ll,ll>
#define     ma             INT_MAX
#define     mi             INT_MIN
#define     mod            1000000007
#define     pi             3.14159265359
#define     e              2.71828182846
#define     inf            1000000000000000LL
#define     all(x)         x.begin(), x.end()
#define     lb(a,b,c)      lower_bound(a,a+b,c)-a
#define     ub(a,b,c)      upper_bound(a,a+b,c)-a
#define     lbv(a,c)       lower_bound(all(a),c)-a.begin()
#define     ubv(a,c)       upper_bound(all(a),c)-a.begin()
#define     srt1(a,b)      sort(a,a+b)
#define     srt2(a,b)      sort(a,a+b,greater<int>())
#define     gcd(a,b)       __gcd(a,b)
#define     lcm(a,b)       (a*(b/gcd(a,b)))
#define     harmonic(n)    0.57721566490153286l+log(n)
#define     mem(a, b)      memset(a, b, sizeof(a))

///s.lower_bound(a),s.upper_bound(a), for set
///nCr(x, y) = nCr(x-1, y-1) + nCr(x-1, y)
///factorial digit   ((n * log10(n / e) +log10(2 * pi * n) /2.0));


int main()
{
    /*char ch;
    cin>>ch;
    if(ch>='a' && ch<='z')cout<<"a\n";
    if(ch>='A' && ch<='Z')cout<<"A\n";*/
    /*int n,k;
    cin>>n>>k;
    int p[n+5];
    for(int i=0;i<n;i++)cin>>p[i];
    srt1(p,n);
    ll sum=0;
    for(int i=0;i<k;i++)sum+=p[i];
    cout<<sum<<endl;*/
    ll n;
    cin>>n;
    vi v;
    while(n!=0){
        n--;
        v.pb(n%26);
        n/=26;
    }
    for(int i=v.size()-1;i>=0;i--)
        cout<<(char)(97+v[i]);
    cout<<endl;
}



Measured memory_bytes: 3628
#include <cstdio>

int main(void){
		int n, x;
		scanf("%d %d", &n, &x);
		int min = 1001;
		for(int i = 0; i < n; i++){
				int m;
				scanf("%d", &m);
				if(min > m)min = m;
				x -= m;
		}
		printf("%d\n", n + x / min);
		return 0;
}



Measured memory_bytes: 128
#include<iostream>
#include<string>

using namespace std;

int main() {
	string S;	cin >> S;
	int answer = 0;

	for (int i = 0; i < 3; ++i) {
		if (S[i] == '1') {
			++answer;
		}
	}

	cout << answer << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 5;
vector<int> g[MAXN];
int s[MAXN];
int vis[MAXN];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n,m;
  cin >> n >> m;
  for(int i = 0 ; i < m ; i++)
   {
       int u,v;
       cin >> u >> v;
       g[u].push_back(v);
       g[v].push_back(u);
   }
   queue<int> q;
  q.push(1);
  vis[1] = 1;
  while(!q.empty())
  {
      int u = q.front();
      q.pop();
      for(auto &k : g[u])
           {
               if(!vis[k])
               {
                   s[k] = u;
                   vis[k] = 1;
                   q.push(k);
               }
           }
  }
  
  for(int i = 2 ; i <= n ; i++)
         if(vis[i] == 0)
          {
              cout << "No";
              return 0;
          }
          
    cout << "Yes\n";
    for(int i = 2 ; i <= n ; i++)
         cout << s[i] << '\n';
  
  
}

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


int main()
{
	int a = {};
	int b = {};
	int c = {};
	cin >> a>>b>> c;
	if (a + b >= c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,b,a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
#define pb push_back
#define pf push_front
#define rem 1000000007
#define cont continue
#define PI 3.141592653589793238462643383279502
#define debug(n1) cout<<"debug... "<<n1<<"\n"
const ll INF=(1ll<<60)-1;//ll ans = 3e18 + 5;
////////////////////////////////////////////////////////
class abc
{
    public:
    ll x;
    ll y;
};
bool fun1( abc &a , abc &b )
{
    return (a.x-b.x) - (a.y-b.y) < ( b.x - a.x) -( b.y - a.y) ;
}
// bool fun2( abc &a , abc &b )
// {
//     return a.x-a.y < b.x-b.y ;
// }
// bool fun3( abc &a , abc &b )
// {
//     return -a.x-a.y < -b.x-b.y ;
// }
// bool fun4( abc &a , abc &b )
// {
//     return -a.x-+a.y < -b.x+b.y ;
// }
////////////////////////////////////////////////////////
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll tc=1;
    //cin>>tc;
    while(tc--)
    {
        ll n;
        cin>>n;
        abc a[n];
        ll ans=-1e12;
        ll mx1=-1e12;
        ll mn1=1e12;
        ll mx2=-1e12;
        ll mn2=1e12;
        ll mx3=-1e12;
        ll mn3=1e12;
        ll mx4=-1e12;
        ll mn4=1e12;
        rep(i,0,n)
        {
            cin>>a[i].x>>a[i].y;

            mx1=max(mx1,a[i].x+a[i].y);
            mn1=min(mn1 , a[i].x+a[i].y);

            mx2=max(mx2,a[i].x-a[i].y);
            mn2=min(mn2,a[i].x-a[i].y);
            //ans=max({mx1-mx2,abs(mx2+mx3),abs(mn2+mn3)});
            ans = max( { ans , mx1-mn1 , mx2-mn2 , mn2-mx2 , mn1-mx1 });
        }
        
        cout<<ans;
    }
}

Measured memory_bytes: 6764
S = list(input())
while True:
  if len(S) >= 8:
    if S[:8] == ["d", "r", "e", "a", "m", "e", "r", "a"]:
      del S[:5]
    elif S[:7] == ["d", "r", "e", "a", "m", "e", "r"]:
      del S[:7]
    elif S[:6] == ["e", "r", "a", "s", "e", "r"]:
      del S[:6]
    elif S[:5] == ["d", "r", "e", "a", "m"]:
      del S[:5]
    elif S[:5] == ["e", "r", "a", "s", "e"]:
      del S[:5]
    else:
      print("NO")
      break
  elif len(S) == 7:
    if S[:7] == ["d", "r", "e", "a", "m", "e", "r"]:
      del S[:7]
  elif len(S) == 6:
    if S[:6] == ["e", "r", "a", "s", "e", "r"]:
      del S[:6]
  elif len(S) == 5:
    if S[:5] == ["d", "r", "e", "a", "m"]:
      del S[:5]
    elif S[:5] == ["e", "r", "a", "s", "e"]:
      del S[:5]
  elif len(S) == 0:
    print("YES")
    break
  else:
    print("NO")
    break


Measured memory_bytes: 9984
N = int(input())

max_cnt = 1
max_index = 1
for i in range(1,N+1):
    cnt = 0
    index = i
    while True:
        if i % 2 == 0:
            i //= 2
            cnt += 1
        else:
            break
    if max_cnt <= cnt:
        max_cnt = cnt
        max_index = index
print(max_index)

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

//int _; 


int main()
{
	//for(scanf("%d",&_);_;_--)
	int n,m;
	cin >> n >> m;
	for(int i=0;i<m;i++)
	{
		int a;
		cin >> a;
		n -= a;
	}
	if(n<0)
	{
		puts("-1");
	}
	else
		cout << n << endl;
	return 0;
}


Measured memory_bytes: 3628
//#pragma GCC optimize(2)
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cassert>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<bitset>
#define heap priority_queue<int,vector<int>,greater<int> >
#define _heap priority_queue<int,vector<int>,less<int> >
#define _for(a,b,c) for((a)=(b);(a)<=(c);++(a))
#define __for(a,b,c) for((a)=b;(a)>=(c);--(a))
#define _init(a,b) memset((a),(b),sizeof (a))
#define LL long long
#define mod 1e9+7
#define INF 0x3f3f3f3f
using namespace std;

namespace FastIO {
	template<typename tp> inline void read(tp &x) {
		x=0; register char c=getchar(); register bool f=0;
		for(;c<'0'||c>'9';f|=(c=='-'),c = getchar());
		for(;c>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0',c = getchar());
		if(f) x=-x;
	}
	template<typename tp> inline void write(tp x) {
		if (x==0) return (void) (putchar('0'));
		if (x<0) putchar('-'),x=-x;
		int pr[20]; register int cnt=0;
		for (;x;x/=10) pr[++cnt]=x%10;
		while (cnt) putchar(pr[cnt--]+'0');
	}
	template<typename tp> inline void writeln(tp x) {
		write(x);
		putchar('\n');
	}
}
using namespace FastIO;

//------------Coding Area------------

int main(){
	int a,b,c;
	read(a),read(b),read(c);
	if(c>=a&&c<=a+b) puts("YES"); else puts("NO");
}

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;
using ld = long double;
long double const pi = std::acos(-1.0L);
typedef pair<int,int> P;
const int INF = 1001001001;


int main() {
  int a, b;
  cin >> a >> b;
  cout << a*b << endl;
  return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string s2 = System.Console.ReadLine().Trim();

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "Yes";
            if (s2 == "AAA" || s2 == "BBB") { sOut = "No"; }

            // 出力
            System.Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
function main (s) {
	var c=s.split("\n");
	for(var i=0;i<c.length;i++)c[i]=c[i].split("");
	console.log(c[0][0]+c[1][1]+c[2][2]);
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <stdio.h>

int main(int argc, const char * argv[]) {
    long long int a[101][101]={},b[101][101]={},c[101][101]={};
    long long int n,m,l,i,j,k = 0;
    scanf("%lld %lld %lld",&n,&m,&l);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%lld",&a[i][j]);
        }
    }
    for(i=0;i<m;i++){
        for(j=0;j<l;j++){
            scanf("%lld",&b[i][j]);
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            for(k=0;k<m;k++){
                c[i][j] += a[i][k]*b[k][j];
            }
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            printf("%lld",c[i][j]);
            if(j!=l-1){
                printf(" ");
            }
        }
        
        if(i!=n-1 && j!=l-1){
            printf("\n");
        }
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 852
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define                          ll                          long long int
ll gcd(int a,int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}

#define                          in(x)                       scanf("%lld",&x)
#define                          in2(x,y)                    scanf("%lld %lld",&x,&y)
#define                          in3(x,y,z)                  scanf("%lld %lld %lld",&x,&y,&z)
#define                          out(x)                      printf("%lld\n",x)
#define                          cy                          printf("YES\n")
#define                          cn                          printf("NO\n")
#define                          inf                         1e18
#define                          neg                         -1e18
#define                          mx                          2111111
#define                          fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define                          fi                          first
#define                          si                          second
#define                          ce                          cout<<endl
#define                          pb                          push_back
#define                          vc(x)                       x.begin(),x.end()
#define                          pb                          push_back
#define                          pi                          pair<ll,ll>
#define                          debug                       printf("ok\n");
#define                          pg                          pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> >
#define                          mod                         1000000007
vector<ll>g[mx];
bool vis[mx];
void dfs(ll n){
    vis[n]=1;
    for( auto x:g[n]){
        if(!vis[x]){
            vis[x]=1;
            dfs(x);
        }
    }

}

int main(){

     ll i,n,j,ans=0,m,s=0,sum=0,x=0;
    ll u,v;

   in2(n,m);
   for(i=0;i<m;i++){
        in2(u,v);
     g[u].pb(v);
     g[v].pb(u);

   }
   for(i=1;i<=n;i++){
     if(vis[i]==0){
        ans++;
        dfs(i);
     }
   }
 cout<<ans-1<<endl;


}




Measured memory_bytes: 57668
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main() {
    int N, K;
    cin >> N >> K;
    if(N % K == 0) cout << 0 << endl;
    else cout << 1 << endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define MOD int(1e9 +7)
#define MAXN 100005
#define ll long long
inline ll mult(ll a, ll b, ll p = MOD) {return (ll) a * b % p;}
inline ll addmod(ll a, ll val, ll p = MOD) {{if ((a = (a + val)) >= p) a -= p;} return a;}

vector < int > adj[MAXN];
bool visited[MAXN];
ll wp[MAXN],bp[MAXN];
void __DFS(int v){
    visited[v] = true;
    ll wres=1,bres=1;        
    for(int u: adj[v])
        {
            if(visited[u] && adj[v].size()==1)
            {
                wp[v]=bp[v]=1;
                continue;
            }
           
           if(!visited[u])
            {
               __DFS(u);
               wres=mult(wres,addmod(wp[u],bp[u]));
               bres=mult(bres,wp[u]);
            }
        }
        wp[v]=wres;bp[v]=bres;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin>>n;
    if(n==1){cout<<2<<endl;
        return 0;
    }
    int m=n-1;
    while(m--)
    {
        int i, j;
        cin >> i >> j;
        adj[i].push_back(j);
        adj[j].push_back(i);
    }
    __DFS(1);
    cout<<addmod(wp[1],bp[1])<<endl;
    return 0;        
}

Measured memory_bytes: 14336