akhauriyash/Code-Regression huggingface dataset:
line = input().split(" ")
w = int(line[0])
h = int(line[1])
x = int(line[2])
y = int(line[3])
r = int(line[4])
if x - r < 0:
    print("No")
elif w < x + r:
    print("No")
elif y - r < 0:
    print("No")
elif h < y + r:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 7672
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll gcd(ll a, ll b);
ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

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

  vector<int> dp(n + 1, 1000000);
  dp[0] = 0;
  for (int i = 0; i < n; i++){
    dp[i + 1] = min(dp[i + 1], dp[i] + 1);
    int j = 1;
    while (i + power(6, j) <= n){
      dp[i + power(6, j)] = min(dp[i + power(6, j)], dp[i] + 1);
      j++;
    }
    j = 1;
    while (i + power(9, j) <= n){
      dp[i + power(9, j)] = min(dp[i + power(9, j)], dp[i] + 1);
      j++;
    }
  }

  cout << dp[n] << endl;

  return 0;
}

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

ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>

#define AS(a) (sizeof(a)/sizeof(a[0]))
using namespace std;
long long int MOD = 1000000007;

int main() {
  long long int N,M;
  cin >> N >> M;
  long long int ans = 0;
  if(N * 2 >= M) {
    ans = M / 2;
  } else {
    ans = N;
    M -= N * 2;
    N = 0;

    ans += M / 4;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
while True:
    n,x =map(int,input().split())
    if n==x==0:
        break
    l = list(range(1,n+1))
    c = 0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            if i != j:
                for k in range(j +1,n+1):
                    if k==x-i-j:
                        c+=1
                        
    print(c)


Measured memory_bytes: 5596
public class Main {
	public static void main(String[] ags) {
		for (int leftIdx = 1; leftIdx <= 9; leftIdx++) {
			for (int rightIdx = 1; rightIdx <= 9; rightIdx++) {
				System.out.println(leftIdx + "x" + rightIdx + "=" + (leftIdx * rightIdx));
			}
		}
	}
}

Measured memory_bytes: 24040
module ABC133

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public  :: task_B
  private :: calc_distance2
  private :: is_GoodDistance

  ! variables for this <module>
  integer(INT32) :: num_point_all
  integer(INT32) :: num_point_GD
  integer(INT32) :: val_dimension

  ! arrays for this <module>
  integer(INT32), dimension(:,:), allocatable :: coordinate

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_B

    ! support variables for this <subroutine>
    integer(INT32) :: itr
    integer(INT32) :: itr_orign, itr_target

    ! STEP.01
    ! read out the given data (1/2)
    read(unit=INPUT_UNIT, fmt=*) num_point_all, val_dimension

    ! STEP.02
    ! allocate the array to store the data of the points
    allocate( coordinate(1:val_dimension, 1:num_point_all) )

    ! STEP.03
    ! read out the given data (1/2)
    do itr = 1, num_point_all, 1
      read(unit=INPUT_UNIT, fmt=*) coordinate(:, itr)
    end do

    ! STEP.04
    ! calculate the answer of this task
    num_point_GD = 0_INT32

    do itr_orign  = 1,             num_point_all, 1
    do itr_target = itr_orign + 1, num_point_all, 1

      if ( is_GoodDistance( calc_distance2( coordinate(:, itr_orign), coordinate(:, itr_target) ) ) ) then
        num_point_GD = num_point_GD + 1_INT32
      else
        continue
      end if

    end do
    end do

    ! STEP.05
    ! output the answer of this task
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') num_point_GD

    ! STEP.06
    ! deallocate the array to store the data of the points
    deallocate( coordinate )

    ! STEP.END
    return

  end subroutine task_B

  pure function calc_distance2 (coordinate_orign, coordinate_target) result(distance)

    ! arguments for this <function>
    integer(INT32), dimension(1:val_dimension), intent(in) :: coordinate_orign
    integer(INT32), dimension(1:val_dimension), intent(in) :: coordinate_target

    ! return value of this <function>
    integer(INT32) :: distance

    ! support variables for this <function>
    integer(INT32) :: difference
    integer(INT32) :: itr

    distance = 0_INT32

    do itr = 1, val_dimension, 1
      difference = coordinate_target(itr) - coordinate_orign(itr)
      distance   = distance + difference * difference
    end do

    return

  end function calc_distance2

  pure function is_GoodDistance (val_distance) result(stat)

    ! arguments for this <function>
    integer(INT32), intent(in) :: val_distance

    ! return value of this <function>
    logical :: stat

    ! support variables for this <subroutine>
    integer(INT32) :: itr, itr2

    stat = .false.

    do itr = 0_INT32, val_distance, 1_INT32
      itr2 = itr * itr
      if (itr2 .eq. val_distance) stat = .true.
    end do

    return

  end function is_GoodDistance

end module ABC133

program main

  ! <module>s to import
  use, non_intrinsic :: ABC133

  ! require all variables to be explicitly declared
  implicit none

  call task_B

end program main

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll A, B;
	cin >> A>>B;

	cout << (A<=8&&B<=8 ? "Yay!" : ":(") << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	s := getNextString(scanner)

	ans := 0
	for i := 0; i < 10; i++ {
		for j := 0; j < 10; j++ {
			for k := 0; k < 10; k++ {
				ic := 0
				jc := 0
				for ii := 0; ii < n; ii++ {
					num := int(s[ii] - '0')
					if ic == 0 && num == i {
						ic++
						continue
					}
					if ic > 0 && jc == 0 && num == j {
						jc++
						continue
					}
					if ic > 0 && jc > 0 && num == k {
						ans++
						break
					}
				}
			}
		}
	}
	fmt.Fprintln(writer, ans)
	writer.Flush()
}


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

using namespace std;


int main()
{
    int n, a[25], c = 0;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    for(int i = 1; i < n - 1; i++){
        if(a[i] > a[i - 1] && a[i] < a[i + 1])
            c++;
        if(a[i] < a[i - 1] && a[i] > a[i + 1])
            c++;
    }
    cout << c;
    return 0;
}



Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var N int
	fmt.Scan(&N)
	minVal := N - 1
	if N == 2 || N == 3 {
		fmt.Println(minVal)
		return
	}
	for i := 2; i <= int(math.Sqrt(float64(N))); i++ {
		q, r := N/i, N%i
		if r == 0 {
			val := (i - 1) + (q - 1)
			if val < minVal {
				minVal = val
			}
		}
	}
	fmt.Println(minVal)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N,M;
string s;
int A[200001];
bool used[200001];
vector<int> G[200001];

int a[200001];
int b[200001];

int main(){
	cin>>N>>M;
	cin>>s;
	REP(i,N){
		used[i]=true;
		a[i]=0;
		b[i]=0;
	}
	REP(i,N){
		if(s[i]=='A'){
			A[i]=0;
		}else{
			A[i]=1;
		}
	}
	REP(i,M){
		int aa,bb;
		cin>>aa>>bb;
		aa--;bb--;
		G[aa].push_back(bb);
		G[bb].push_back(aa);
		if(A[aa]==0){
			a[bb]++;
		}else{
			b[bb]++;
		}
		if(A[bb]==0){
			a[aa]++;
		}else{
			b[aa]++;
		}
	}
	vector<int>v;
	REP(i,N){
		if(a[i]==0||b[i]==0){
			v.push_back(i);
			used[i]=false;
		}
	}
	REP(i,v.size()){
		int x=v[i];
		REP(j,G[x].size()){
			int y=G[x][j];
			if(used[y]==true){
				if(A[x]==0){
					a[y]--;
				}else{
					b[y]--;
				}
				if(a[y]==0||b[y]==0){
					v.push_back(y);
					used[y]=false;
				}
			}
		}
	}
	bool check=false;
	REP(i,N){
		if(used[i]==true)check=true;
	}
	if(check){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}



Measured memory_bytes: 13952
def iter_bit(k, LIMIT):
    v = (1 << k) - 1

    while v < LIMIT:
        yield v
        x = v & -v
        y = v + x
        v = (v & ~y) // x >> 1 | y


def solve(n, cards):
    dp = [{} for _ in range(1 << n)]
    dp[-1][0] = 0
    LIMIT = 1 << n

    for d in range(n):
        for state in iter_bit(n - d, LIMIT):
            scores = dp[state]
            k = state
            curr = 0
            while k:
                b = k & -k
                i = b.bit_length() - 1
                num = cards[i][(d - i) % 2]
                next_dp = dp[state ^ b]
                for left_num, score in scores.items():
                    if left_num > num:
                        continue
                    ns = score + curr
                    if num not in next_dp or next_dp[num] > ns:
                        next_dp[num] = ns
                k ^= b
                curr += 1

    if len(dp[0]) > 0:
        return min(dp[0].values())
    else:
        return -1


n = int(input())
aaa = list(map(int, input().split()))
bbb = list(map(int, input().split()))
cards = list(zip(aaa, bbb))
print(solve(n, cards))


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

ll StoLL(string s){
  stringstream ss(s);
  ll res;
  ss >> res;
  return res;
}

string s;
ll parse(int l, int r){
  if(s[l]!='['){
    return StoLL(s.substr(l,r-l))/2 + 1;
  }

  vector<ll> ans;
  int k = 0, prv = l;
  for(int i=l;i<r;i++){
    if(s[i] == '[')k++;
    if(s[i] == ']')k--;
    if(k==0){
      ans.push_back(parse(prv+1,i));
      prv = i+1;
    }
  }

  sort(ans.begin(),ans.end());
  ll res = 0;
  for(int i=0;i<=(int)ans.size()/2;i++)res += ans[i];
  return res;
}
      
int main(){
  int n;
  cin >> n;
  while(n--){
    cin >> s;
    cout << parse(1,s.size()-1) << endl;
  }
}
	 

Measured memory_bytes: 1328
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define fo(i,n) for(i=0;i<n;i++)
#define fok(i,k,n) for(i=k;i<n;i++)
#define ci(x) cin>>x;
#define ci2(x,y) cin>>x>>y;
#define co(x) cout<<x<<"\n";
#define co2(x,y) cout<<x<<" "<<y<<"\n";
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;


int main(){
	ll n;
	ci(n);
	ll ans=(n/500)*1000;
	ans+=((n%500)/5)*5;
	co(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void dfs (
	int crr
, int& cnt
, bool& is_binary
, vector<int>& col
, vector<vector<int>>& grh
) {
	cnt++;
	for (int nxt : grh[crr]) {
		if (col[nxt] ==  -1) {
			col[nxt] = col[crr] ^ 1;
			dfs(nxt, cnt, is_binary, col, grh);
		} else if (col[nxt] == col[crr]) {
			is_binary = false;
		}
	}
}
int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> grh(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		grh[--a].push_back(--b);
		grh[b].push_back(a);
	}
	vector<int> cmp;
	int cnt = 0;
	bool is_binary;
	vector<int> col(n, -1);
	long long a(0), b(0), c(0);
	for (int i = 0; i < n; i++) {
		if (col[i] == -1) {
			col[i] = 1;
			dfs(i, cnt = 0, is_binary = true, col, grh);
			if (cnt > 1 && is_binary) a++;
			else if (cnt > 1 && not is_binary) b++;
			else c++;
		}
	}
	long long ret =
			2 * a * a
		+ 2 * a * b
		+ b * b
		+ 2 * n * c
		- c * c;
	cout << ret << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;

const int N=1e5+10;

int n,pa[N];
int f[N];
int q[N];
vector <int> v[N];

bool comp(int x,int y){
    return f[x]<f[y];
}
void BFS(){
    int top=1,bot=1;
    q[1]=1;
    while (top<=bot){
        int x=q[top++];
        for(auto y:v[x]) q[++bot]=y;
    }
}
int main(){
    scanf("%d",&n);
    for(int i=2;i<=n;i++) {
        scanf("%d",pa+i);
        v[pa[i]].push_back(i);
    }
    BFS();
    for(int j=n;j>=1;j--){
        int x=q[j];
        sort(v[x].begin(),v[x].end(),comp);
        int n1=v[x].size();
        for(int i=0;i<n1;i++) f[x]=max(f[x]+1,f[v[x][i]]+1);
    }
    cout<<f[1]<<'\n';
}


Measured memory_bytes: 7040
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll

const int md = 1000000007;
const int INF = 1<<30;



int main(){
    int n; cin >> n;
    //vector<string> a(n);
    map<string,ll> m;

    rep(i,n){
        string s; cin >> s;
        Sort(s);
        m[s]++;
    }

    ll ans = 0;
    for(auto x: m){
        ll tmp = x.second;
        ans += (tmp)*(tmp-1) / 2;
    }

    cout << ans << endl;
}


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

int main(void)
{
	char s[200] = {};
	int i = 0, len = 0, half = 0, j, count = 0;

	scanf("%s", s);
	len = strlen(s);

	for (i = len - 2; i >= 2;i -= 2){
		count = 0;
		half = i / 2;
		for (j = 0;j < half;j++) {
			if (s[j] == s[half + j]) {
				count++;
			}
		}
		if (count == half) {
			break;
		}
	}

	printf("%d\n", count * 2);

	return 0;
}

Measured memory_bytes: 128
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef pair<ll,ll> p;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll n,k;
cin>>n>>k;
vector<ll>v;
for(ll i=0;i<n;i++)
{
    ll a;
    cin>>a;
    v.pb(a);
}
sort(all(v));
ll ans=0;
for(ll i=0;i<k;i++)
{
    ans+=v[i];
}
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 3664
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}
ll n,m;
bool ok(ll a,ll b){
    return a>=0&&b>=0&&a<n&&b<m;
}
ll dx[8]={1,0,-1,0,1,-1,1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};

int main(){
    IOS;
    make(ll,n);
    vector <ll> t(n+1);
    vector <array <ll,2> >vec(n+1);
    fr(i,n) cin>>t[i+1]>>vec[i+1][0]>>vec[i+1][1];
    bool flag=1;
    for(ll i=1;i<n+1;i++){
        ll x=abs(vec[i][0]-vec[i-1][0])+abs(vec[i][1]-vec[i-1][1]);
        if(t[i]-t[i-1]<x || (t[i]-t[i-1]-x)%2==1) flag=0;
    }
    if(flag) cout<<"Yes \n";
    else cout<<"No \n";

    return 0;
}


Measured memory_bytes: 5528
j = input()
lis = sorted(list("qwertyuiopasdfghjklzxcvbnm"))
abs = ""
for h in j:
    lis.remove(h)
if not lis:
    ans = "-1"
else:
    ans = "{}{}".format(j, lis[0])
tmp = "zz"
for i in range(len(j)):
    try:
        if tmp > j[:i] + sorted(filter(lambda x: x > j[i], j[i+1:]))[0]:
            tmp = j[:i] + sorted(filter(lambda x: x > j[i], j[i+1:]))[0]
    except:
        pass
if tmp == "zz" and ans == "-1":
    print("-1")
elif tmp == "zz":
    print(ans)
elif ans == "-1":
    print(tmp)
else:
    print(min(ans, tmp))

Measured memory_bytes: 3064
N = int(input())
A = [int(x) for x in input().split()]
A.sort()

tmp = A[0]
ans = 1
for i in range(1,N) :
    if A[i] <= tmp*2 :
        ans += 1
    else :
        ans = 1
    tmp += A[i]

print(ans)


Measured memory_bytes: 14304
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector <int> a(n);
    cin >> a;
    int sum = 0;
    forn (i, 0, n)
        sum += a[i];
    int cnt = 0;
    forn (i, 0, n)
        if (!(a[i] * 4 * m < sum))
            ++cnt;
    if (cnt >= m)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define FAST ios_base::sync_with_stdio(false);cin.tie(0);
    const double EPS = 1e-9;
    const double PI = acos(-1);
    const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
    //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
    //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
    const int dx[] = {0 , 1 , 0 , -1};
    const int dy[] = {1 , 0 , -1 , 0};
    //#define MOD         1000000007LL
    #define MAX         1000005
    const ll MOD = 1000000000 + 7;
    
    int main()
    {
        FAST
        int t;
        t = 1;

        while(t--)
        {
           ll n , d;
           cin >> n >> d;
           
           int ans = 0;
           
           for(int i = 0 ; i < n ; i++)
           {
               ll a , b;
               cin >> a >> b;
               //cout << (d * d) << " " << ((a * a) + (b * b)) << endl;
               if((d * d) >= ((a * a) + (b * b)))ans++;
           }
           
           cout << ans << endl;
        }
    }



Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    sort(ALL(a));
    auto isOK = [&](ll x){
        ll cnt = 0;
        if(x >= 0){
            rep(i,n){
                if(a[i] == 0){
                    cnt += n - 1;
                }else if(a[i] > 0){
                    cnt += n - (a.end() - upper_bound(ALL(a), x / a[i])) - (a[i] <= x / a[i] ? 1 : 0);
                }else{
                    cnt += a.end() - lower_bound(ALL(a), x / a[i]) - (a[i] >= x / a[i] ? 1 : 0);
                }
            }
            cnt /= 2;
        }else{
            rep(i,n){
                if(!(a[i] < 0)) break;
                cnt += a.end() - lower_bound(ALL(a), (abs(x) + abs(a[i]) - 1) / abs(a[i]));
            }
        }
        return k <= cnt;
    };
    ll ng = -LINF - 1, ok = LINF + 1;
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if(isOK(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    cout << ok << endl;
    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

// Problem Specific Parameter:
string s;
int limit;
int dp[310][310][310];

int main(void) {
	cin >> s >> limit;
	const int n = s.size();

	rep(i, n + 1)rep(j, n + 1)rep(k, limit + 1) {
		const int sidx = i;
		const int ridx = n - 1 - j;

		if (sidx < n and 0 <= ridx and s[sidx] == s[ridx]) {
			chmax(dp[i + 1][j + 1][k], dp[i][j][k] + 1);
		}

		if (sidx < n) {
			chmax(dp[i + 1][j][k], dp[i][j][k]);
		}

		if (0 <= ridx) {
			chmax(dp[i][j + 1][k], dp[i][j][k]);
		}

		if (k + 1 <= limit and sidx < n and 0 <= ridx) {
			chmax(dp[i + 1][j + 1][k + 1], dp[i][j][k] + 1);
		}
	}

	int ans = 0;
	rep(i, n + 1) {
		const int j = n - i;
		rep(k, limit + 1) chmax(ans, 2 * dp[i][j][k]);
	}

	rep(i, 1, n + 1) {
		const int j = n + 1 - i;
		rep(k, limit + 1) chmax(ans, 2 * dp[i][j][k] - 1);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 114560
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        while (true) {
                                long L = sc.nextLong();
                                if (L == 0) {
                                        break;
                                }
                                long i, j=-1;
                                for (i = 0; i < 12; i++) {
                                        L -= sc.nextLong();
                                        L += sc.nextLong();
                                        if (L <= 0 && j == -1) {
                                                j=i;
                                        }
                                }
                                if (j == -1) {
                                        System.out.println("NA");
                                } else {
                                        System.out.println(j + 1);
                                }
                        }
                }
        }
}

Measured memory_bytes: 43516
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
template<class V> struct BIT { BIT() {}  // [L, R)
    int NV;vector<V> bit;BIT(int n){init(n);}void init(int n){NV=1;while(NV<n)NV*=2;bit.resize(NV);}
    V operator[](int e) { V s = 0; e++; while (e) s += bit[e - 1], e -= e&-e; return s; }
    void add(int e, V v) { e++; while (e <= NV) bit[e - 1] += v, e += e&-e; }
    int lower_bound(V val) { V tv = 0; int i, ent = 0; for (i = NV - 1; i >= 0; i--)
        if(tv+bit[ent+(1<<i)-1]<=val)tv+=bit[ent+(1<<i)-1],ent += (1 << i);return ent;}
    V get(int L, int R) {assert(0 <= L); assert(R <= NV); assert(L <= R);
        V res = 0; if(R) res += operator[](R - 1); if (L) res -= operator[](L - 1);return res;}
    void clear() { bit.clear(); }};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






string S; int K;
queue<int> idx[26];
BIT<int> bit;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> S >> K;
    int N = S.length();
    bit.init(N);
    rep(i, 0, N) idx[S[i] - 'a'].push(i);
    rep(i, 0, N) bit.add(i, 1);

    string ans = "";
    rep(i, 0, N) rep(c, 0, 26) if (0 < idx[c].size()) {
        int top = idx[c].front();
        int req = bit.get(0, top);
        if (req <= K) {
            ans += char('a' + c);
            idx[c].pop();
            K -= req;
            bit.add(top, -1);
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 5484
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>


using namespace std;



int main() {

	int N, * A, first = 0, second = 0, key =0;

	cin >> N;

	A = new int[N];

	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (A[i] > first) {
			first = A[i];
			key = i;
		}
		else if (A[i] <= first && second <= A[i]) {
			second = A[i];
		}
	}

	for (int i = 0; i < N; i++) {
		if (i != key) {
			cout << first << "\n";
		}
		else {
			cout << second << "\n";
		}
	}

	return 0;

}

Measured memory_bytes: 2432
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
		
const double eps = 1e-9;																							   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////


///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   
	int a, b;
	cin >> a >> b;
	if(a == b){
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	
	
    
 
 
 
	
	
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main () {
    int a,b,c;
    cin >> a >> b >> c;
    if (a > b && a > c) cout << (b * c) / 2 << endl;
    else if (b > a && b > c) cout << (a * c) / 2 << endl;
    else cout << (a * b) / 2 << endl;
    return 0;
}


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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const long long int MOD = 1000000007;
const int INF = 1000000007;

ll modx(ll a)
{
    return (a%MOD+MOD)%MOD;
}

ll times(ll a, ll b)
{
    return modx(modx(a)*modx(b));
}

ll add(ll a, ll b)
{
    return modx(modx(a)+modx(b));
}

ll sub(ll a, ll b)
{
    return modx(MOD+modx(a)-modx(b));
}

ll fastExp(ll base, ll exp)
{
    if(exp == 0LL)
    {
        return 1LL;
    }

    if(exp%2==0)
    {
        return fastExp(times(base, base), exp/2);
    }
    else
    {
        return times(base, fastExp(times(base, base), exp/2));
    }
}


const int MAXN = (int)1e5+1;
int N;

ll choose(ll a, ll b)
{
    ll res = 1LL;
    for(ll i = a; i>=a-b+1; i--)
    {
        res = times(res, i);
    }

    for(ll i = 1; i<= b; i++)
    {
        res = times(res, fastExp(i, MOD-2));
    }
    return res;
}

int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll X, Y;
    cin >> X >> Y;
    if(2*X < Y || 2*Y < X || (X+Y)%3!=0)
    {
        cout << 0;
        return 0;
    }

    ll a = (X+Y)/3;
    ll b = abs(X-a);
    cout << choose(a, b);

    return 0;
}


Measured memory_bytes: 256
A, B, K = list(map(int, input().split()))

result = []
for i in range(A, min(A + K, B)):
    result.append(i)

for i in range(max(B - K + 1, A), B + 1):
    result.append(i)

result = list(set(result))
result.sort()
for r in result:
    print(r)


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n-1) cin >> a[i];

    ll sum = 0;
    FOR(i, 2, n-1) sum += a[i];

    deque<ll> dp(sum+1);
    REP(i, sum+1) dp[i] = i;
    FOR(i, 2, n-1) {
        // dp[1]~dp[a[i]] を逆順にしてpush
        vector<ll> v;
        REP(j, a[i]) v.push_back(dp[j+1]);
        REP(j, a[i]) dp.push_front(v[j]);
    }

    ll q;
    cin >> q;
    while(q--) {
        ll x;
        cin >> x;
        if(sum <= x) {
            cout << x-sum+a[0]-a[1] << endl;
        } else {
            cout << dp[x]+a[0]-a[1] << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 25964
import itertools

while True:
    n, x = map(int, input().split())

    if n == 0 and x == 0:
        break

    combination_list = itertools.combinations(range(1, n + 1), 3)
    combination_sum_list = [sum(list(x)) for x in combination_list]
    count = combination_sum_list.count(x)

    print(count)



Measured memory_bytes: 8368
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        int one = input.nextInt();
        int two = input.nextInt();
        int divide = one / two;
        int mod = one % two;
        double divideD = (double) one/ (two * 1.0);
        System.out.printf("%d %d %.5f",divide, mod, divideD);
    }
}


Measured memory_bytes: 26444
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int main() {
    int n;
    cin >> n;
    if (n / 100 == n % 10) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
 
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
#define in2(N,s,t) rep(i,N){in(s[i] , t[i]);}
#define in3(N,s,t,u) rep(i,N){in(s[i] , t[i] , u[i]);}
using vd = V<double>; using vs = V<string>; using vvl = V< V<> >;
template<typename T>using heap = priority_queue< T , V<T> , greater<T> >;
 
//using P = pair<ll,char>; using vp = V<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
//////////////////

void solve(){
  ins(S);
  ini(K);
  rep(i , sz(S)){
    if(K == 0) break;
    if(S[i] == 'a') continue;
    int num = ('a' + 26 - S[i]) % 26;
    if(num <= K){
      S[i] = 'a';
      K -= num;
    }
    else continue;
  }
  if(K != 0){
    ll nya = S.back() - 'a';
    nya += K;
    nya %= 26;
    S.back() = 'a' + nya;
  }
  out(S);

}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

int main() {
  int h, w, n;
  cin >> h >> w >> n;
  int hoge;
  deque<int> d;
  for (int i = 1; i <= n; i++) {
    cin >> hoge;
    for (int j = 0; j < hoge; j++)
      d.push_back(i);
  }

  int M[h][w] = {};
  for (int i = 0; i < h; i++) {
    if (i % 2 == 0) {
      for (int j = 0; j < w; j++) {
        M[i][j] = d.front();
        d.pop_front();
      }
    } else {
      for (int j = w - 1; 0 <= j; j--) {
        M[i][j] = d.front();
        d.pop_front();
      }
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w - 1; j++) {
      cout << M[i][j] << " ";
    }
    cout << M[i][w - 1] << endl;
  }
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<sstream>
#include<iomanip>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int a,b,c;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>a>>b>>c;
	if(b*c>=a)cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 10005
using namespace std;
struct edge{
	int k,next;
}e[1000005];
struct P{
	int x,y;
}a[N];
int n,m,w[N<<1],id[N<<3],cc,home[N*100],cnt=-1,H[N*100];
pair<int,int> b[N<<1];
void add(int x,int y){
	cnt++;
	e[cnt].k=y;
	e[cnt].next=home[x];
	home[x]=cnt;
}
void build(int k,int l,int r){
	id[k]=++cc;
	if(l==r) return;
	int mid=l+r>>1;
	build(k<<1,l,mid);
	build(k<<1|1,mid+1,r);
	add(id[k],id[k<<1]);
	add(id[k],id[k<<1|1]);
}
void insert(int k,int l,int r,int x,int v){
	if(l==r){
		add(id[k],v);
		return;
	}
	int mid=l+r>>1;
	if(x<=mid) insert(k<<1,l,mid,x,v);
	else insert(k<<1|1,mid+1,r,x,v);
}
void query(int k,int l,int r,int L,int R,int x){
	if(L<=l&&R>=r){
		add(x,id[k]);
		return;
	}
	int mid=l+r>>1;
	if(L<=mid) query(k<<1,l,mid,L,R,x);
	if(R>mid) query(k<<1|1,mid+1,r,L,R,x);
}
int s[N*100],T,top,dfn[N*100],mn[N*100],tot,fr[N*100];
bool ins[N*100];
void tarjan(int k){
	dfn[k]=mn[k]=++T;
	s[++top]=k;
	ins[k]=1;
	for(int i=home[k];~i;i=e[i].next){
		if(!dfn[e[i].k]){
			tarjan(e[i].k);
			mn[k]=min(mn[k],mn[e[i].k]);
		}else if(ins[e[i].k]) mn[k]=min(mn[k],dfn[e[i].k]);
	}
	if(mn[k]==dfn[k]){
		ins[k]=0;
		fr[k]=++tot;
		while(s[top]!=k){
			ins[s[top]]=0;
			fr[s[top]]=tot;
			top--;
		}
		top--;
	}
}
bool solve(int d){
	for(int i=1,pos=1;i<=n+n;i++){
		while(pos<i&&b[pos].first<=b[i].first-d) pos++;
		if(pos!=i) query(1,1,m,pos,i-1,b[i].second);
	}
	for(int i=n+n,pos=n+n;i;i--){
		while(pos>i&&b[pos].first>=b[i].first+d) pos--;
		if(pos!=i) query(1,1,m,i+1,pos,b[i].second);
	}
	memset(dfn,0,sizeof(dfn));
	tot=0;
	for(int i=1;i<=cc;i++) if(!dfn[i]) T=0,tarjan(i);
	for(int i=1;i<=n;i++) if(fr[i]==fr[i+n]) return 0;
	return 1;
}
int main(){
	memset(home,-1,sizeof(home));
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d%d",&a[i].x,&a[i].y);
	for(int i=1;i<=n;i++) b[i]=make_pair(a[i].x,i),b[i+n]=make_pair(a[i].y,n+i);
	sort(b+1,b+n+n+1);
	cc=m=n+n;
	build(1,1,m);
	for(int i=1;i<=n+n;i++){
		int x=b[i].second<=n?b[i].second+n:b[i].second-n;
		insert(1,1,m,i,x);
	}
	int l=0,r=1e9,mid,CNT=cnt,ans;
	for(int i=1;i<=cc;i++) H[i]=home[i];
	while(l<=r){
		mid=l+r>>1;
		for(int i=1;i<=cc;i++) home[i]=H[i];
		cnt=CNT;
		if(solve(mid)) ans=mid,l=mid+1;
		else r=mid-1;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 24448
#include <iostream>
#include <string.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
#define ii pair < int, int >
#define iii pair < int, ii >
#define INF 987654321
#define LINF 987654321987654321

/*
node num = edge num + cc
cc = node num - edge num
*/

int main()
{
	cio;
	ll n;
	cin >> n;

	ll tot = 0;

	for (int i = 1; i <= n; i++)
		tot += i * (n - i + 1);

	for (int i = 1; i < n; i++)
	{
		ll u, v;
		cin >> u >> v;

		if (u > v) swap(u, v);

		tot -= u * (n - v + 1);
	}

	cout << tot;
}

Measured memory_bytes: 3152