akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

class SEGTREE {
    unsigned int n;
    ll dflt;
    vector<ll> dat;

    static ll op(const ll a, const ll b) {
        return max(a, b);
    }

    bool f(const unsigned int id, const ll a){
        return dat[id] >= a;
    }

public:
    SEGTREE(unsigned long _n, ll _a) : n(1), dflt(_a) {
        while (n < _n) {n *= 2;}
        dat.resize(n * 2, dflt);
    }

    void update(unsigned int k, ll a) {
        k += n;
        dat[k] = a;
        while (k > 0) {
            k >>= 1;
            dat[k] = op(dat[k<<1], dat[(k<<1)|1]);
        }
    }

    void init(vector<ll> &v) {
        for (int i = 0; i < (int)v.size(); ++i) dat[i + n] = v[i];
        for (int i = n - 1; i >= 1; --i) {
            dat[i] = op(dat[i * 2], dat[i * 2 + 1]);
        }
    }

    ll query(unsigned int l, unsigned int r) {
        ll res_left = dflt, res_right = dflt;
        l += n; r += n;
        for ( ; l < r; l >>= 1, r >>= 1){
            if(l&1){
                res_left = op(res_left, dat[l]);
                if((++l) == r) break;
            }
            if(r&1){
                res_right = op(dat[r ^ 1], res_right);
            }
        }
        return op(res_left, res_right);
    }

    unsigned int max_right_search(unsigned int id, ll a){
        while(id < n) id = (id<<1) | !f(id<<1, a);
        return id - n;
    }

    unsigned int max_right(unsigned int l, unsigned int r, ll a){
        //[l, r)内のindexであるjであって、query(l, j) < a <= query(l, j + 1)なるものを求める
        //つまり、j >= l かつ dat[j] >= a である最小の数jを求める(func = maxの場合)
        unsigned int see_after = r + n;
        l += n;
        for (unsigned int tr = r + n ; l < tr; l >>= 1, tr >>= 1){
            if(l&1){
                if(f(l, a)) return max_right_search(l, a);
                if((++l) == tr) break;
            }
            if((tr&1) && f(tr ^ 1, a)) see_after = tr ^ 1;
        }
        return see_after == r + n ? r : max_right_search(see_after, a);
    }

    //単項にアクセスする[]だが、書き換え厳禁
    //一応後でinitすれば書き換えてもよさそうだが…
    ll &operator[](int k) { return dat[k + n]; }
};
int main() {
    cin>>N>>Q;
    vec a(N);
    rep(i, N) scanf("%lld", &a[i]);
    SEGTREE seg(N, -1);
    seg.init(a);
    rep(_, Q){
        int t, x, v, l, r;
        scanf("%d", &t);
        if(t == 1){
            scanf("%d%d", &x, &v); --x;
            seg.update(x, v);
        }else if(t == 2){
            scanf("%d%d", &l, &r);
            printf("%lld\n", seg.query(l - 1, r));
        }else{
            scanf("%d%d", &x, &v); --x;
            printf("%u\n", seg.max_right(x, (unsigned int) N, v) + 1);
        }
    }
}



Measured memory_bytes: 9120
a, b, k = map(int, input().split())
if (b - a + 1) <= 2 * k:
  for i in range(a, b + 1):
    print(i)
else:
  for i in range(a, a + k):
    print(i)
  for i in range(b - k + 1, b + 1):
    print(i)


Measured memory_bytes: 9112
import queue
import sys
imput = sys.stdin.readline

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

conne = [[] for _ in range(n)]
dist = [99999]*(n)
par = [0] * (n)

for i in range(m):
    a,b = map(int,input().split()) 
    conne[a-1].append(b-1)
    conne[b-1].append(a-1)
    
q=queue.Queue()
dist[0] = 0
q.put((0,0))

while not q.empty():
    
    x,d = q.get()
    
    for i in conne[x]:
        if dist[i]==99999:
            q.put((i,d+1))
            par[i] = x
            dist[i] = d+1

print("Yes")    

for i in par[1:]:
    print(i+1)



Measured memory_bytes: 104784
// https://atcoder.jp/contests/abc124/tasks/abc124_b

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 20;
const int H_I_MAX = 100;

int N;
int H[N_MAX];

void solve() {
  int hx = 0;
  int ans = 0;
  REP(i, N) {
    if (H[i] >= hx) {
      ans++;
      hx = H[i];
    }
  }
  printf("%d\n", ans);
}

void input() {
  scanf("%d", &N);
  REP(i, N) scanf("%d", H + i);
}

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();

		if (a == b + c) {
			System.out.println("Yes");
		} else if (b == a + c) {
			System.out.println("Yes");
		} else if (c == a + b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23252
#!/usr/bin/env python3
#ABC53 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

n = int(input())
a = list(map(int,input().split()))
a = len(list(Counter(a)))
if a % 2:
    print(a)
else:
    print(a-1)


Measured memory_bytes: 62124
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define endl "\n"
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

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

  int A, B, C, X;
  cin >> A >> B >> C >> X;

  int res = 0;
  rep(i, A+1) {
    rep(j, B+1) {
      rep(k, C+1) if(500*i+100*j+50*k == X) res++;
    }
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> v(N); rep(i, 0, N) { cin >> v[i]; }
	vector<int>lis(N, INF);
	lis[0] = v[0];
	int x(0);
	rep(i, 1, N) {
		if (lis[x] < v[i])lis[++x] = v[i];
		else *lower_bound(lis.begin(), lis.begin() + x + 1, v[i]) = v[i];
	}
	cout << x + 1 << endl;
	return 0;
}

Measured memory_bytes: 3616
N = int(input())
cnt = [0] * (N + 1)

for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            check = x*x + y*y + z*z + x*y + y*z + z*x
            if check <= N:
                cnt[check] += 1
            else:
                break

for i in range(1,N+1):
    print(cnt[i])

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007


int main()
{
    string s[3];
    cin >> s[0] >> s[1] >> s[2];

    lli now = 0;
    while(1){
        if(s[now].size()==0){
            if(now == 0) cout << "A\n";
            else if(now == 1) cout << "B\n";
            else if(now == 2) cout << "C\n";
            return 0;
        }
        lli tmp = now;
        if(s[now][0]=='a')
            now = 0;
        else if(s[now][0]=='b')
            now = 1;
        else if(s[now][0]=='c')
            now = 2;
        s[tmp].erase(s[tmp].begin());
    }
    return 0;
}

Measured memory_bytes: 256
/**
 *   author: sahushivam
 *   created: 16 February 2020 (Sunday)  17:28:20
**/
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1e18
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define int long long

void solve(){
    vector<int> a(10,0);
    int a1,b,c;
    cin>>a1>>b>>c;
    a[a1]++;
    a[b]++;
    a[c]++;
    for(int i=0;i<10;i++)
    {
        if(a[i]==2)
        {
            cout<<"Yes\n";
            return;
        }
    }
    cout<<"No\n";
}

signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int t=1; while(t--) solve();
    return 0;
}   

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
//const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
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< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  string S;
  cin >> S;
  if(S[2] == S[3] && S[4] == S[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
def gcd_and_lcm(nums)
  a = nums.max
  b = nums.min
  until b == 0
    tmp = b
    b = a % b
    a = tmp
  end
  gcd = tmp
  lcm = nums.max * nums.min / gcd
  return [gcd, lcm]
end

while line = gets
  data = line.chomp.split(" ").map(&:to_i)
  puts gcd_and_lcm(data).join(" ")
end

Measured memory_bytes: 8684
def Euclidean(a, b):
    if a<b:
        a, b = b, a
    while True:
        m = a%b
        if m==0 or b==1:
            return b
        a = b
        b = m

N, M = list(map(int, input().split()))
S = input().rstrip()
T = input().rstrip()

if S[0]!=T[0]:
    print(-1)
    exit()

gcm = Euclidean(N, M)
gcd = int(N*M/gcm)
#print(gcm, gcd)

if N<M:
    N, M = M, N
    S, T = T, S
#print(N, M)
#print(S, T)

a = int(gcd/M)
b = int(gcd/N)
ab = a*b
for i in range(int(gcd/ab)):
    #print(i*a, i*b)
    if S[i*a]!=T[i*b]:
        print(-1)
        exit()
print(gcd)

Measured memory_bytes: 3444
# AGC008A - Simple Calculator
def main():
    x, y = tuple(map(int, input().rstrip().split()))
    xs, ys = x >= 0, y >= 0
    dif = abs(abs(x) - abs(y))
    if x == 1000000000 and y == 1:
        print(1000000001)
        return

    if abs(x) == abs(y):  # <-> x == y <-> y - x = 0
        if x == y:
            ans = 0
        else:
            ans = 1
    elif 0 <= x < y:
        ans = y - x
    elif 0 <= y < x:
        ans = 1 + dif
    elif x < y < 0:
        ans = y - x
    elif y < x < 0:
        ans = 1 + dif + 1  # -a -> a -> b -> -b
    elif x < 0 <= y:
        ans = dif + 1
        ans -= 1 if y == 0 else 0
    else:  # y < 0 <= x
        ans = dif + 1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
import itertools

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

s = [list(map(int,input().split())) for _ in range(m)]
p = list(map(int,input().split()))

li = [0,1]
ans = 0
for elm in itertools.product(li,repeat=n):
    for i in range(m):
        mm = 0
        for j in range(1,s[i][0]+1):
            if elm[s[i][j]-1]==1:
                mm += 1
        if mm%2!=p[i]:
            break
    else:
        ans += 1
        #print(elm)
print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#define ll long long
ll solve(ll n,ll x)
{
	if (n%x==0) return 2*n-x;
	return solve(x,n%x)+n/x*x*2;
}
int main()
{
	ll n,x;
	scanf("%lld%lld",&n,&x);
	printf("%lld",solve(n-x,x)+n);
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
	int M, N, i, cnt=0, arr[1000];
	double sum=0, num;
	scanf("%d %d", &N, &M);
	for(i=0; i<N; i++){
		scanf("%d", &arr[i]);
		sum+=arr[i];
	}
	num=sum/(4*M);
	for(i=0; i<N; i++){	
		if(arr[i]>=num)
			cnt++;
	}
	if(cnt>=M)
		printf("Yes");
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
	int p[131072] = {0},n,i,j,k;
	p[0] = 1;
	p[1] = 1;
	for(i = 4;i <= 131072;i+=2){
		p[i] = 1;
	}
	for(i = 3;i <= 399;i+=2){
		if(p[i]){continue;}
		else{
			for(j = i * 3;j <= 131072;j+=(i * 2)){
				p[j] = 1;
			}
		}
	}
	while(scanf("%d",&n) , n != 0){
		k = 0;
		for(i = 2;i <= n/2;i++){
			if(p[i] == 0 && p[n - i] == 0){k++;}
		}
		printf("%d\n",k);
	}
	return 0;
}

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

string str;
bitset<10> oki;

int main( void ) {
    
    int n, k;
    cin >> n >> k;
    
    str = to_string( n );
    for( int i = 1; i <= k; i ++ ) {
        int x;
        cin >> x;
        
        oki[x] = true;
    }
    
    int ans1 = 0;
    for( int i = 1; i <= 9; i ++ ) {
        if( oki[i] == false ) {
            ans1 = i;
            break;
        }
    }
    
    for( int i = 0; i <= 9; i ++ ) {
        if( oki[i] == false ) {
            for( int j = 1; j <= str.length(); j ++ )
                ans1 = ans1 * 10 + i;
            break;
        }
    }
    
    bool aux = true;
    for( char ch : str )
        aux = min( aux, !oki[ch - '0'] );
    
    int ans2 = INT_MAX;
    if( aux == true )
        ans2 = n;
    
    for( int i = 0; i < str.length(); i ++ ) {
        bool ok = true;
        
        for( int j = 0; j < i; j ++ )
            ok = min( ok, !oki[str[j] - '0'] );
        
        if( ok == true ) {
            for( int j = str[i] -  '0' + 1; j <= 9; j ++ ) {
                if( oki[j] == false ) {
                    int nr = 0;
                    
                    for( int k = 0; k <= i - 1; k ++ )
                        nr = nr * 10 + ( str[k] - '0' );
                    nr = nr * 10 + j;
                
                    for( int k = 0; k <= 9; k ++ ) {
                        if( oki[k] == false ) {
                            for( int p = i + 1; p < str.length(); p ++ )
                                nr = nr * 10 + k;
                            break;
                        }
                    }
                    
                    ans2 = min( ans2, nr );
                }
            }
        }
    }
    
    cout << min( ans1, ans2 ) << endl;
    return 0;
}

Measured memory_bytes: 256
// AOJ 2917: Pray
// 2019.2.17 bal4u

#include <stdio.h>
#include <stdlib.h>

int main()
{
	int N, a, ans;

	ans = 0;
	scanf("%d", &N);
	while (N--) {
		scanf("%d", &a);
		if ((a & 1) == 0) ans++;
	}
	printf("%d\n", ans);
	return 0;
}



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

signed main(){
  int N;
  cin>>N;
  vector<int> A(N);
  rep(i,N)cin>>A[i];
  sort(begin(A),end(A));
  if(A[0]==0){
    cout<<0<<endl;
    return 0;
  }
  int ans=1;
  rep(i,N){
    if(A[i]<=1000000000000000000/ans){
      ans*=A[i];
    }else{
      ans=-1;
      break;
    }
  }
  cout<<ans<<endl;
}

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

int main() {
   int a,b,c;
  string s;
  cin>>a>>s;
  bool ai=1;
  if(a%2==1)
  ai=0;
  else{
    for(int i=0;i<a/2;i++){
    	if(s.at(i) != s.at(i+a/2))
          ai =0;
    }
  }
  
  if(ai)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}
  

Measured memory_bytes: 256
#include <iostream>

using namespace std;

u_int lcm(const u_int* a, u_int n)
{
	u_int max = a[0];
	for (u_int i = 1; i < n; i++)
		if (a[i] > max)
			max = a[i];

	u_int res = max;
	while (1) {
		u_int i = 0;
		for (; i < n; i++)
			if (res % a[i])
				break;

		if (i == n)
			return res;
		else
			res += max;
	}
}

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

	u_int a[n];
	for (u_int i = 0; i < n; i++)
		cin >> a[i];

	cout << lcm(a, n) << endl;
	
    return 0;
}

Measured memory_bytes: 1156
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.D_Challenge
{
    class ABC_093
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int q = ReadInt();
            long[] ans = new long[q];
            for(int i = 0; i < q; i++)
            {
                long[] ab = ReadLongs();
                long min = Math.Min(ab[0], ab[1]);
                long max = Math.Max(ab[0], ab[1]);
                long multi = min * max;

                if (min == max || min + 1 == max)
                {
                    ans[i] = min * 2 - 2;
                    continue;
                }
                else
                {
                    long sqrt = (long)Math.Sqrt(multi);
                    if (sqrt*sqrt==multi) sqrt--;
                    if (sqrt * (sqrt + 1) >= multi)
                    {
                        ans[i] = 2 * sqrt - 2;
                    }
                    else
                    {
                        ans[i] = 2 * sqrt - 1;
                    }
                }

            }
            for(int i = 0; i < q; i++)
            {
                Console.WriteLine(ans[i]);
            }
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

using vi=vector<int>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m,q;
    cin>>n>>m>>q;
    vvi s(n,vi(m));
    for(int i=0;i<n;i++){
        string buf; cin>>buf;
        for(int j=0;j<m;j++){
            s[i][j]=buf[j]-'0';
        }
    }

    vvi eh(n,vi(m-1));
    vvi ev(n-1,vi(m));
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(!s[i][j]) continue;
            if(i+1!=n){
                if(s[i+1][j]) ev[i][j]=true;
            }
            if(j+1!=m){
                if(s[i][j+1]) eh[i][j]=true;
            }
        }
    }
    auto d2sum=[&](const vvi& t1,vvi& t2){
        for(int i=1;i<=t1.size();i++){
            for(int j=1;j<=t1[i-1].size();j++){
                t2[i][j]=t2[i-1][j]+t2[i][j-1]-t2[i-1][j-1]+t1[i-1][j-1];
            }
        }
    };
    vvi ehsum(n+1,vi(m));
    d2sum(eh,ehsum);
    vvi evsum(n,vi(m+1));
    d2sum(ev,evsum);
    vvi ssum(n+1,vi(m+1));
    d2sum(s,ssum);
    auto rect=[&](int x1,int y1,int x2,int y2,const vvi& table){
        return table[x2][y2]-table[x1][y2]-table[x2][y1]+table[x1][y1];
    };
    
    while(q--){
        int x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        x1--,y1--;
        int sv=rect(x1,y1,x2,y2,ssum);
        int ehv=rect(x1,y1,x2,y2-1,ehsum);
        int evv=rect(x1,y1,x2-1,y2,evsum);
        cout<<sv-ehv-evv<<"\n";
    }
    return 0;
}

Measured memory_bytes: 96000
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
int main() {
    i64 A, B, C;
    cin >> A >> B >> C;
    i64 M = max({A, B, C});
    A = M - A, B = M - B, C = M - C;
    cout << A / 2 + B / 2 + C / 2 + (3 - A % 2 - B % 2 - C % 2) % 3 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=0x61=97
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef string str;
typedef pair<int,int> pairii;
typedef vector<int> veci;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int main() {
  ll a;
 ld b;
  cin>>a>>b;
  cout<< fixed << setprecision(0)<<floor(a*b)<<endl;cerr<< fixed << setprecision(10)<<a*b;
}

Measured memory_bytes: 3792
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

use input::*;

fn main() {
    let (a, b, c): (usize, usize, usize);
    input!(a, b, c);
    if a == b && b == c {
        p("Yes");
    } else {
        p("No");
    }
}



Measured memory_bytes: 4352
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n'
#define pe(x) cout<<x<<" "
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
#define double long double

template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
int MOD = 1e9+7;

const int MAX = 200060;
const double pi = acos(-1);
const double EPS = 1e-12;


void solve(){
	int A, B; cin >> A >> B;
	if (A <= 9 && B <= 9) {
		print(A*B);
	}
	else {
		print(-1);
	}
}


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


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

bool f = false;

void dfs(int a, int b, int c, int k){
    if(a > b && b > c){
        f = true;
        return;
    }
    if(k == 0)  return;
    dfs(2*a, b, c, k-1);
    dfs(a, 2*b, c, k-1);
    dfs(a, b, 2*c, k-1);
}

int main(){
    int a[3];
    cin >> a[2] >> a[1] >> a[0];
    int k;
    cin >> k;
    dfs(a[0], a[1], a[2], k);
    cout << (f ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The Value Of " << #val << " is : " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 0;
int n;
string s;
unordered_map<char, ll>cnt;

int main(){
	IOS
	cin >> n >> s;
	for(int i=0;i<n;i++){
		cnt[s[i]]++;
	}
	ll maks=cnt['R'] * cnt['G'] * cnt['B'];
	ll minus=0;
	for(int l=2;l<=n;l++){
		for(int i=0;i+l+l-2<n;i++){
			unordered_map<char, ll>tmp;
			int j=i+l-1;
			int k=j+l-1;
			tmp[s[i]]++, tmp[s[j]]++, tmp[s[k]]++;
			if(tmp['R']==1 && tmp['G']==1 && tmp['B']==1){
				minus++;
			}
		}
	}
	cout << maks - minus << '\n';
}


Measured memory_bytes: 3632
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int A, B, C, K;

  scanf("%d%d%d%d", &A, &B, &C, &K);

  int ans = min(A, K);
  K -= min(A, K);
  K -= min(B, K);
  ans -= min(C, K);

  printf("%d\n", ans);

  return 0;
}

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

int main(){
  int x,y;
  cin>>x>>y;
  if((y-2*x)%2==0&&(4*x-y)%2==0&&y-2*x>=0&&4*x-y>=0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int N;
bool leaf[100005];
vector<int> v[100005];

void dfs(int x, int p) {
    int cnt = 0;
    for(int it : v[x]) {
        if(it == p) continue;
        dfs(it, x);
        if(leaf[it]) cnt++;
    }
    if(cnt > 1) { puts("First"); exit(0); }
    leaf[x] = !cnt;
}

int main() {
    scanf("%d", &N);
    if(N & 1) return puts("First"),0;
    for(int i=1, x, y; i<N; i++) {
        scanf("%d %d", &x, &y);
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs(1, 0);
    puts("Second");
}


Measured memory_bytes: 5888
#include <stdio.h>
#include <math.h>

int main(int argc,char* argv[]){
  double x1,y1,x2,y2,x3,y3,xp,yp;
  double x,y,r;
  double r12,r23,r31,rp1,rp2,rp3,angle1,angle2,angle3;
  int num,count;
  
  while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp) != EOF){
    
    rp1 = sqrt((x1 -xp)*(x1 -xp) + (y1 -yp)*(y1 -yp));
    rp2 = sqrt((x2 -xp)*(x2 -xp) + (y2 -yp)*(y2 -yp));
    rp3 = sqrt((x3 -xp)*(x3 -xp) + (y3 -yp)*(y3 -yp));
    r12 = sqrt((x1 -x2)*(x1 -x2) + (y1 -y2)*(y1 -y2));
    r23 = sqrt((x2 -x3)*(x2 -x3) + (y2 -y3)*(y2 -y3));
    r31 = sqrt((x3 -x1)*(x3 -x1) + (y3 -y1)*(y3 -y1));
    
    angle3 = acos( (rp2*rp2+rp1*rp1-r12*r12) / (2.0*rp2*rp1) );
    angle1 = acos( (rp3*rp3+rp2*rp2-r23*r23) / (2.0*rp3*rp2) );
    angle2 = acos( (rp1*rp1+rp3*rp3-r31*r31) / (2.0*rp1*rp3) );
    
    if((angle1 + angle2 + angle3 < M_PI*2 + 0.001) && (angle1 + angle2 + angle3 > M_PI*2 - 0.001)){
      printf("YES\n");
    }else{
      printf("NO\n");
    }
    
  }  
  
  return 0;
  
}

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

#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;

Node treeMinimum(Node);
Node treeSearch(Node, int);
Node treeSuccessor(Node);
void treeDelete(Node);
void insert(int);
void inorder(Node);
void preorder(Node);

int main(){
  int n, i, x;
  char com[20];
  scanf("%d",&n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if(com[0] == 'i'){
      scanf("%d",&x);
      insert(x);
    }
    else{
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key)return u;

  if(k < u->key)return treeSearch(u->left, k);
  else return treeSearch(u->right, k);
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL){
    return treeMinimum(x->right);
  }
  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL)y = z;
  else y = treeSuccessor(z);

  if(y->left != NIL)x = y->left;
  else x = y->right;

  if(x != NIL)x->parent = y->parent;

  if(y->parent == NIL)root = x;
  else if(y == y->parent->left)y->parent->left = x;
  else y->parent->right = x;

  if(y != z){
    z->key =y->key;

  }
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key)x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL)root = z;
  else if(z->key < y->key)y->left = z;
  else y->right = z;
}

void inorder(Node u){
  if(u == NIL)return ;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
  
}
void preorder(Node u){
  if(u == NIL)return ;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
  
}

Measured memory_bytes: 24040
# -*- coding: utf-8 -*-
import numpy as np
from decimal import Decimal

N = int(input())
A = [int(10**9*Decimal(input())) for _ in range(N)]

Z = np.zeros((20,20), dtype=int)

def count2(a):
  n = a
  count = 0
  while n%2 == 0:
    n //= 2
    count += 1
  return count

def count5(a):
  n = a
  count = 0
  while n%5 == 0:
    n //= 5
    count += 1
  return count

answer = 0
for a in A:
  c2 = count2(a)
  c5 = count5(a)
  t2 = max(18-c2,0)
  t5 = max(18-c5,0)
  #answer += np.sum(Z[t2:,t5:])
  #Z[min(19,c2),min(19,c5)] += 1
  answer += Z[t2,t5]
  Z[:min(19,c2)+1,:min(19,c5)+1] += 1

print(answer)

Measured memory_bytes: 35072
using System;
using System.Collections.Generic;
using System.Linq;
    class Program
    {
        static void Main(string[] args)
        {
            var ABC = Console.ReadLine().Split().Select(s=>int.Parse(s)).ToArray();
            var A = ABC[0];
            var B = ABC[1];
            var C = ABC[2];
            var result = new List<int>();
            var sum = A;
            while(true)
            {
                var m = sum % B;
                if(m==C)
                {
                    Console.WriteLine("YES");
                    return;
                }
                if (result.Contains(m)) break;
                result.Add(m);
                sum += A;
            }
            Console.WriteLine("NO");
        }
    }

Measured memory_bytes: 13280
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cstdio>
#include <set>
#include <cmath>
#include <unordered_map>
#include <algorithm>
#include <stack>
#include <unordered_set>
using namespace std;

int main () {
	vector<long long int> v;
	long long int n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;
	v.push_back(0);
	v.push_back(n);
	v.push_back(0);
	v.push_back(0);
	v.push_back(0);
	v.push_back(0);
	v.push_back(0);
	long long int res = 0;
	while (v[6] != n) {
		v[6] += min(v[5], e);
		v[5] -= min(v[5], e);

		v[5] += min(v[4], d);
		v[4] -= min(v[4], d);

		v[4] += min(v[3], c);
		v[3] -= min(v[3], c);

		v[3] += min(v[2], b);
		v[2] -= min(v[2], b);

		v[2] += min(v[1], a);
		v[1] -= min(v[1], a);

		res++;
		if (min(v[5], e) > 0) {
			res += (n - v[6]) / min(v[5], e);
			if ((n - v[6]) % min(v[5], e) > 0)
				res++;
				break;
		}
	}
	cout << res;
}

Measured memory_bytes: 256
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    l = 0
    r = n
    print(0)
    la = input()
    if la == "Vacant":
        exit()
    ra = la
    while True:
        mid = l+(r-l)//2
        print(mid)
        ma = input()
        if ma == "Vacant":
            exit()
        elif (ma == la and (mid-l)%2 == 0) or ((not ma == la) and (mid-l)%2 == 1):
            l = mid
            la = ma
        else:
            r = mid
            ra = ma

    return

if __name__ == '__main__':
    main()


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

int main() {
    int n,k;
    cin>>n>>k;
    int arr[n];
    rep(i,0,n){
        cin>>arr[i];
    }
    rep(i,k,n){
        if(arr[i]>arr[i-k]){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
}



Measured memory_bytes: 4412
#include <bits/stdc++.h>
#define MAXN 5005
using namespace std;

const int mod = 1000000007;

int n, calc[MAXN], sz[MAXN];
vector<int> G[MAXN];
vector<int> dp[MAXN][2];

void precalc() {
    calc[2] = 1;

    for (int i = 4; i <= n; i += 2)
        calc[i] = 1LL * (i - 1) * calc[i - 2] % mod;
}

void DFS(int u, int p) {
    vector<int> sons;

    sz[u] = 1;

    for (auto x: G[u]) {
        if (x == p) continue;
        DFS(x, u);
        sons.push_back(x);
        sz[u] += sz[x];
    }

    if (sons.empty()) {
        dp[u][0].resize(2);
        dp[u][1].resize(2);
        dp[u][1][1] = 1;
        return;
    }

    vector<int> crtDp[2][2];
    int act = 0, nxt = 1;
    int son0 = sons[0];

    int maxSz = sz[son0] + 2;
    for (int b = 0; b < 2; ++b) {
        crtDp[act][b].resize(maxSz);

        for (int sz = 2; sz < maxSz; ++sz)
            crtDp[act][b][sz] = dp[son0][b][sz - 1];
        
        for (int sz = 1; sz < maxSz - 1; ++sz)
            crtDp[act][b][1] = (crtDp[act][b][1] + 1LL * dp[son0][b ^ 1][sz] * calc[sz]) % mod;
    }

    for (int i = 1; i < (int) sons.size(); ++i) {
        int son = sons[i];
        maxSz += sz[son];

        for (int b = 0; b < 2; ++b) {
            crtDp[nxt][b].clear();
            crtDp[nxt][b].resize(maxSz);
        }

        for (int b0 = 0; b0 < 2; ++b0) {
            for (int b1 = 0; b1 < 2; ++b1) {
                for (int sz0 = 1; sz0 < crtDp[act][b0].size(); ++sz0) {
                    for (int sz1 = 1; sz1 < dp[son][b1].size(); ++sz1) {
                        crtDp[nxt][b0 ^ b1 ^ 1][sz0 + sz1] = (crtDp[nxt][b0 ^ b1 ^ 1][sz0 + sz1] + 1LL * crtDp[act][b0][sz0] * dp[son][b1][sz1]) % mod;
                        crtDp[nxt][b0 ^ b1][sz0] = (crtDp[nxt][b0 ^ b1][sz0] + 1LL * crtDp[act][b0][sz0] * dp[son][b1][sz1] % mod * calc[sz1]) % mod;
                    }
                }
            }
        }

        swap(act, nxt);
    }

    dp[u][0] = crtDp[act][0];
    dp[u][1] = crtDp[act][1];
}

int fmod(long long x) {
    x %= mod;
    return (x < 0) ? (x + mod) : x;
}

int main() {
    ios::sync_with_stdio(0);

    cin >> n;
    precalc();

    for (int i = 1; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    DFS(1, 0);

    int sol = 0;
    for (int sz = 2; sz < dp[1][0].size(); sz += 2)
        sol = fmod(sol - 1LL * dp[1][0][sz] * calc[sz]);
    for (int sz = 2; sz < dp[1][1].size(); sz += 2)
        sol = (sol + 1LL * dp[1][1][sz] * calc[sz]) % mod;

    cout << sol << "\n";

    return 0;
}

Measured memory_bytes: 75264
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException{
		// TODO Auto-generated method stub
		InputStreamReader ir=new InputStreamReader(System.in);
		BufferedReader br=new BufferedReader(ir);
		String [] num=br.readLine().split(" ");
		int A=Integer.parseInt(num[0]);
		int B=Integer.parseInt(num[1]);
		int sum=A+B;
		if(A == B)
		{
			System.out.println(0);
		}
		else if(sum % 2 !=0)
		{
			System.out.println("IMPOSSIBLE");
		}
		else
		{
			int k=sum/2;
			System.out.println(k);
		}
		
	}

}


Measured memory_bytes: 23124
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 100000 + 1000;
const int ZERO = 250;

int n, h;
int fa[MAXN], deg[MAXN], vis[MAXN], ok[MAXN];

int find(int x)
{
	return x == fa[x] ? x : fa[x] = find(fa[x]);
}

void unite(int x, int y)
{
	fa[find(x)] = find(y);
}

void no()
{
	cout << "NO" << endl;
	exit(0);
}

void yes()
{
	cout << "YES" << endl;
	exit(0);
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> n >> h;
	for(int i = -h + ZERO; i <= h + ZERO; i++)
		fa[i] = i;
	for(int i = 1; i <= n; i++)
	{
		int a, b, c, d, l, r;
		cin >> a >> b >> c >> d;
		l = (c == 0 ? a : -c);
		r = (d == 0 ? -b : d);
		deg[l + ZERO]++, vis[l + ZERO]++;
		deg[r + ZERO]--, vis[r + ZERO]++;
		unite(l + ZERO, r + ZERO);
		// cerr << l << ' ' << r << endl;
	}
	for(int i = -h + ZERO; i <= -1 + ZERO; i++)
		if(deg[i] > 0)
			no();
	for(int i = 1 + ZERO; i <= h + ZERO; i++)
		if(deg[i] < 0)
			no();
	for(int i = -h + ZERO; i <= h + ZERO; i++)
		if(deg[i] != 0)
			ok[find(i)] = true;
	for(int i = -h + ZERO; i <= h + ZERO; i++)
		if(find(i) == i && vis[i] && !ok[i])
			no();
	yes();

	return 0;
}


Measured memory_bytes: 256
# Candies
n = int(input())
a = [tuple(map(int, input().split()))]
a.append(tuple(map(int, input().split())))
ans = 0
for i in range(n+1):
    s = sum(a[0][:i+1:]) + sum(a[1][i::])
    if s >= ans:
        ans = s
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define endl '\n'
#define int long long


signed main() { //[J][O][L][S][K][E][Y]
        ios_base::sync_with_stdio(false);
//        freopen("input.txt", "r", stdin);
        int a; cin >> a;
        double odds = 0;
        for (int i = 1; i <= a; i++)
                if (i & 1) odds++;

        cout <<odds/a;
        return 0;
}
/*

*/

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

//template
#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 ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
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 end

struct BIT{
    int n; vector<ll> bit;
    void init(int m){n=m; bit.resize(n+10,0);}
    void add(int i,int x){
        i++;
        while(i<=n){
            bit[i]+=x; i+=(i&-i);
        }
    }
    ll sum(int i){
        i++; ll res=0;
        while(i){
            res+=bit[i]; i-=(i&-i);
        } return res;
    }
};

int t[200010],a[200010],b[200010];

int main(){
    int q; scanf("%d",&q);
    vector<int> val;
    rep(i,0,q){
        scanf("%d",&t[i]);
        if(t[i]==1){
            scanf("%d%d",&a[i],&b[i]);
            val.push_back(a[i]);
        }
    }
    sort(ALL(val)); val.erase(unique(ALL(val)),val.end()); int n=val.size();
    map<int,int> rev; rep(i,0,n)rev[val[i]]=i;
    BIT cnt,sum; cnt.init(n); sum.init(n);
    int m=0; ll add=0;
    rep(i,0,q){
        if(t[i]==1){
            int idx=rev[a[i]];
            cnt.add(idx,1); sum.add(idx,a[i]);
            add+=b[i]; m++;
        }
        else{
            ll ans=add;
            int flag=(m+1)/2;
            int lb=-1,rb=n-1;
            while(rb-lb>1){
                int mid=(lb+rb)/2;
                if(cnt.sum(mid)>=flag)rb=mid; else lb=mid;
            }
            int idx=rb; int x=val[idx];
            ans+=(cnt.sum(idx)*x)-sum.sum(idx);
            ans+=(sum.sum(n-1)-sum.sum(idx))-(cnt.sum(n-1)-cnt.sum(idx))*x;
            printf("%d %lld\n",x,ans);
        }
    }
    return 0;
}


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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<#x<<" = "<<x<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

void solve()
{
    li x,y;

    cin>>x>>y;

    if(y%2==0 && y>=2*x && y<=4*x)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

int main()
{    
    

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li t=1;

    // cin>>t;

    while(t--)
    {
        solve();
    }

    return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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; }

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    map<int, int> mp;

    int N;
    cin >> N;

    int tmp;
    for(int i = 0; i < N; i++){
        cin >> tmp;
        mp[tmp]++;
    }

    int ans = 0;

    for(auto itr = mp.begin(); itr != mp.end(); itr++){

        if(itr->first <= itr->second){
            ans += itr->second - itr->first;
        }else{
            ans += itr->second;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=600001,INF=1<<30;

const ll B1=1000000007,B2=1000000009;
ll mo1,mo2;
vector<int> ok;

void contain(string a,string b){
    int al=a.length(),bl=b.length();
    if(al>bl) return;
    
    ll t1=1,t2=1;
    for(int i=0;i<al;i++){
        t1*=B1;
        t1%=mo1;
        t2*=B2;
        t2%=mo2;
    }
    
    ll ah1=0,ah2=0,bh1=0,bh2=0;
    for(int i=0;i<al;i++){
        ah1=(ah1*B1+(a[i]-'a'))%mo1;
        ah2=(ah2*B2+(a[i]-'a'))%mo2;
        bh1=(bh1*B1+(b[i]-'a'))%mo1;
        bh2=(bh2*B2+(b[i]-'a'))%mo2;
    }
    
    for(int i=0;i+al<=bl;i++){
        if(ah1==bh1&&ah2==bh2) ok.push_back(i);
        if(i+al<bl){
            bh1=(bh1*B1+(b[i+al]-'a')-((b[i]-'a')*t1)%mo1+mo1)%mo1;
            bh2=(bh2*B2+(b[i+al]-'a')-((b[i]-'a')*t2)%mo2+mo2)%mo2;
        }
    }
    
    return;
    
}

int par[MAX],size[MAX];

void init(int n){
    for(int i=0;i<n;i++){
        par[i]=i;
        size[i]=1;
    }
}

int root(int a){
    if(par[a]==a) return a;
    else return par[a]=root(par[a]);
}

void unite(int a,int b){
    if(root(a)!=root(b)){
        size[root(a)]+=size[root(b)];
        par[root(b)]=root(a);
    }
}

bool check(int a,int b){
    return root(a)==root(b);
}

int main(){
    
    srand((unsigned int)time(NULL));
    
    mo1=rand();
    mo2=rand();
    
    string preS,T,S;cin>>preS>>T;
    int L=T.size();
    
    while(int(S.size())<2*int(T.size())+int(preS.size())) S+=preS;
    
    contain(T,S);
    
    init(int(preS.size()));
    
    for(int i:ok){
        if(i>=preS.size()) break;
        int j=(i+L)%int(preS.size());
        if(check(i,j)){
            cout<<-1<<endl;
            return 0;
        }
        unite(i,j);
        //cout<<i<<endl;
    }
    
    int ans=-1;
    
    for(int i=0;i<preS.size();i++){
        ans=max(ans,size[root(i)]-1);
    }
    
    cout<<ans<<endl;
    
    
}


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

int n;
int x[200010];
int y[200010];
int l, r;

int main(){
	scanf("%d", &n);
	for(int i=0; i<n; ++i){
		scanf("%d", &x[i]);
		y[i] = x[i];
	}
	sort(y, y+n);
	l = y[n/2-1];
	r = y[n/2];
//	printf("%d %d\n", l, r);
	for(int i=0; i<n; ++i)
		if(x[i] <= l) printf("%d\n", r);
		else printf("%d\n", l);
}

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


using namespace std;
const long long INF = 1LL <<60;

int main(void){
  long long tmp=0;
  long long i,j,k;
  string S;
  cin>>S;
  
  if(S=="RSS" || S=="RSR" || S=="SRS" ||S=="SSR"){
    cout<<1<<endl;
  }
  else if(S=="RRS" || S=="SRR"){
    cout<<2<<endl;
  }
  else if(S=="RRR"){
    cout<<3<<endl;
  }
  else{
    cout<<0<<endl;
  }

  return 0;
  
}    

Measured memory_bytes: 3624