akhauriyash/Code-Regression huggingface dataset:
S = input()
ans = []
for i in range(len(S)-2):
    chk = int(S[i]+S[i+1]+S[i+2])
    if chk == 753:
        print(0)
        exit()
    else:
        ans.append(abs(753-chk))
ans = sorted(ans)
print(ans[0])
pass


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

int main(){
  int h,w;
  cin >> h >> w;
  bool flag = false;
  vector<vector<int>> a(h,vector<int>(w));
  queue<vector<int>> ans;
  for (int i = 0; i<h; i++){
    for  (int j = 0; j<w; j++){
      cin >> a[i][j];
    }
  }
  vector<int> stc(4);
  for (int i = 0; i<h; i++){
    for (int j = (i%2)*(w-1); 0<=j && j<w; j+= -(i%2)*2 + 1){
      if (flag){
        a[i][j] += 1;
        stc[2]= i+1;
        stc[3] = j+1;
        ans.push(stc);
        flag = false;
      }
      if (a[i][j]%2 == 1){
        stc[0] = i+1;
        stc[1] = j+1;
        flag = true;
      }
    }
  }
  cout << ans.size() << endl;
  int k = ans.size();
  for (int i = 0; i<k; i++){
    stc = ans.front(); ans.pop();
    for (int j = 0; j<3; j++){
      cout << stc[j] << " ";
    }
    cout << stc[3] << endl;
  }
}

Measured memory_bytes: 10112
import bisect
from math import ceil


def can_exterminate(attack_count):
    sum_b = b * attack_count
    i = bisect.bisect(enemies, sum_b)

    for enemy in enemies[i:]:
        attack_count -= ceil((enemy - sum_b) / d)
        if attack_count < 0:
            return False
    return True


def binary_search(max_attack_count):
    l, r, m = 1, max_attack_count + 1, 0
    while l < r:
        m = (l + r) // 2
        if can_exterminate(m):
            r = m
        else:
            l = m + 1
    return l


n, a, b = map(int, input().split())
d = a - b
enemies = sorted(int(input()) for _ in range(n))
boss = max(enemies)
print(binary_search(ceil(boss / b)))


Measured memory_bytes: 8076
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
  int n = 0;
  cin >> n;
  vector<int> num(n);
  for(int i = 0;i <= n - 1;i++)cin >> num[i];
  sort(num.begin(),num.end());
  int res = 0;
  res = num[n / 2] - num[n / 2 - 1];
  if(res < 0)res = 0;
  cout << res << endl;
  return 0;
}

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

using namespace std;
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/__gcd(a,b)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef long int li;

int main()
{
    IOS;
    string s;
    cin>>s;
    ll n=s.size();
    int sum=0;
    for(int i=0;i<n;i++){
       sum+=s[i]-'0'; 
    }
    if(sum%9==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
int c[26];
int main(){
    string s;
    cin >> s;
    for(int i=0;i<s.length();i++)c[(s[i]-'a')]++;
    for(int i=0;i<26;i++){
        if(c[i]==0){
            cout << (char)('a'+i);
            return 0;
        }
    }
    cout << "None";
}

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

int main()
{
    string s;
    cin >> s; 
    int a = 0;

    for(int i = 0; i < 4; i++){
        if(s[i] == '+'){
            a++;
        }else{
            a--;
        }
    }
    cout << a << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0159

"""
import sys
from sys import stdin
input = stdin.readline
from collections import namedtuple
bmi = namedtuple('bmi', ['d', 'p'])

def calc_BMI(h, w):
    return w / ((h / 100)**2)


def main(args):
    while True:
        n = int(input())
        if n == 0:
            break

        scores = []
        for _ in range(n):
            p, h, w = map(int, input().split())
            scores.append(bmi(abs(calc_BMI(h, w) - 22), p))

        scores.sort()
        print(scores[0].p)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 8124
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;
struct data
{
    int a,b;
};

bool cmp(data x,data y)
{
    return x.a < y.a;
}

data d[200005];
int g[200005];
int main()
{
    int n,k;
    scanf("%d",&n);
    k=n/2;
    for (int i=1;i<=n;i++) { scanf("%d",&d[i].a); d[i].b=i; }
    sort(d+1,d+n+1,cmp);
    for (int i=1;i<=n;i++)
    {
        if (i<=k) g[d[i].b]=d[k+1].a;
        else g[d[i].b]=d[k].a;
    }
    for (int i=1;i<=n;i++) printf("%d\n",g[i]);
    return 0;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

ll par[100000]; // par[i]... iの親
ll mem[100000]; // iの(自分も含めた) 子の構成島数

ll root(ll x) {
    // 自身が親と同一の時まで再帰的にrootをたどる
    if(par[x]==x) return x;
    else { // xの親を直接根にする(経路圧縮)
      return par[x] = root(par[x]);
    }
}

void unite(ll x, ll y) {
  ll rx = root(x);
  ll ry = root(y);
  if(rx==ry) return;
  else {
    // if(rx<ry) {
    //   ll tmp = rx;
    //   rx = ry;
    //   ry = tmp;
    // }
    mem[ry] += mem[rx];
    par[rx] = ry;
    return;
  }
}

int main() {
  ull N, M;
  cin >> N >> M;
  ull A[M], B[M];
  rep(i, M) {
    ull a, b;
    cin >> a >> b;
    A[i] = a-1;
    B[i] = b-1;
  }

  /* Uion-find というデータ構造を使えば処理時間を短縮できるらしい */
  // cf. https://qiita.com/ofutonfuton/items/c17dfd33fc542c222396
  // cf. https://atc001.contest.atcoder.jp/tasks/unionfind_a

  rep(i, N) par[i] = i; // 最初は全て自分が親
  rep(i, N) mem[i] = 1;

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

  ull ans[M]; // ans
  ans[M-1] = N*(N-1)/2; // 全ての橋が崩壊した時の不便さ
  for(ll i=M-1; i>0; i--) {
    ll ra = root(A[i]);
    ll rb = root(B[i]);
    if(ra==rb) ans[i-1] = ans[i];
    else {
      ans[i-1] = ans[i] - mem[ra]*mem[rb];
      // cout << "log:" << ans[i-1] << endl;
      // cout << "A, B " << A[i] << ' ' << B[i] << endl;
      // cout << "rA, rB " << root(A[i]) << ' ' << root(B[i]) << endl;
      // cout << "mrA, mrB " << mem[root(A[i])] << ' ' << mem[root(B[i])] << endl;
      unite(rb, ra);
    }
  }

  rep(i, M) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 5248
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here! 
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        
        int min = 1001001009;
        for (int i = -100; i <= 100; i++) {
            int tmp = 0;
            for (int j = 0; j < n; j++) {
                tmp += (array[j] - i) * (array[j] - i);
            }
            
            min = Math.min(min, tmp);
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 22996
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;

struct UnionFind {
    vector<int> par; // 親を指すvector,-par[親]は木のサイズ
    UnionFind(int n):par(n, -1) {} // uniteで親を埋め込んでいく必要あり
    int root(int x) { // 親をたどる&データの整理
        if(par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    bool unite(int x, int y) { // データの結合
        x = root(x);
        y = root(y);
        if(x == y) return false;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    bool same(int x, int y) {return root(x) == root(y);} // 所属判定
    int size(int x) {return -par[root(x)];} // 木のサイズ
}uft(200000);

struct vnionFind {
    vector<map<int, int> > cou;
    vector<int> par; // 親を指すvector,-par[親]は木のサイズ
    vnionFind(int n):par(n, -1), cou(n) {
        rep(i, n) {
            cou[i][uft.root(i)]++;
        }
    } // uniteで親を埋め込んでいく必要あり
    int root(int x) { // 親をたどる&データの整理
        if(par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    bool unite(int x, int y) { // データの結合
        x = root(x);
        y = root(y);
        if(x == y) return false;
        if(par[x] > par[y]) swap(x, y);
        for(auto lll:cou[y]) {
            cou[x][lll.first] += lll.second;
        }
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    bool same(int x, int y) {return root(x) == root(y);} // 所属判定
    int size(int x) {return -par[root(x)];} // 木のサイズ
};

int main() {
    int n, k, l;
    cin >> n >> k >> l;
    rep(i, k) {
        int p, q;
        cin >> p >> q;
        --p;
        --q;
        uft.unite(p, q);
    }
    vnionFind vft(200000);
    rep(i, l) {
        int r, s;
        cin >> r >> s;
        --r;
        --s;
        vft.unite(r, s);
    }

    rep(i, n-1) {
        cout << vft.cou[vft.root(i)][uft.root(i)] << ' ';
    }
    cout << vft.cou[vft.root(n-1)][uft.root(n-1)] << endl;
}

Measured memory_bytes: 24064
def divisors(n):
    i = 1
    table = set()
    while i * i <= n:
        if not n % i:
            table.add(i)
            table.add(n//i)
        i += 1
    return table

def max2(x,y):
    return x if x > y else y

def rec(start_set, t):
    global res
    res = max2(res, t)
    next_set = []
    i = start_set[0]
    for j in start_set[1:]:
        if gcd(data[i], data[j]) == 1:
            next_set.append(j)
    if next_set:
        rec(next_set, t+1)
    return res

from math import gcd

A, B = map(int, input().split())
data = divisors(A) & divisors(B)
data = list(data)
data.sort()
L = len(data)
res = 0
print(rec(list(range(L)),1))





Measured memory_bytes: 69668
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
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; }
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1LL << 60;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())
#define rSORT(v) std::sort(v.begin(), v.end(),std::greater<int>())

int L[100010] = { 0 };
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<pair<string,pair<int,int>>> s(n);
    
    for (int i = 0; i < n; ++i) {
        cin >> s[i].first >> s[i].second.first;
        s[i].second.second = i;
    }
    SORT(s);
    stack<int> st;
    st.push(s[0].second.second + 1);
    for (int i = 1; i < n; ++i) {
        if(s[i].first==s[i-1].first)st.push(s[i].second.second + 1);
        else {
            while (!st.empty()) {
                cout << st.top() << endl;
                st.pop();
            }
            st.push(s[i].second.second + 1);
        }
    }
    while (!st.empty()) {
        cout << st.top() << endl;
        st.pop();
    }
    return 0;
}


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


signed main() {
    int N, M;
    cin >> N >> M;

    vector<ll> H(N+1);
    rep (i, N) cin >> H[i+1];

    vector<vector<ll>> A(2, vector<ll>(M));
    rep (i, M) cin >> A.at(0).at(i) >> A.at(1).at(i);

//    cout << "aaa" << endl;
    vector<ll> R(N+1);
    rep (i, M) {
        int f = A.at(0).at(i);
        int s = A.at(1).at(i);
 //       cout << H[f] << "vs" << H[s] << endl;
        if (H[f] > H[s]) {
            R[s] = -1;
        } else if (H[f] < H[s]) {
            R[f] = -1;
        } else { 
            R[f] = -1;
            R[s] = -1;
        }
    }

//    cout << "bbb" << endl;

    int ans = 0;
    rep (i, N) {
//        cout << "R[" << i+1 << "]=" << R[i+1] << endl;
        if (R[i+1] != -1) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 6492
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return a % 1000000007;
}

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


int main(){
  ll a,b,c; cin >> a >> b >> c; 
  if(max(max(a,b),c) == b&&min(min(a,b),c) == a) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(){
	for (int i = 1; i <= 9; i++){
		for (int j = 1; j <= 9; j++){
			cout << i << "x" << j << "=" << i * j << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 2924
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import bisect

n = int(readline())
x = list(map(int,readline().split()))
l = int(readline())
q = int(readline())
ab = list(map(int,read().split()))

dbl = [[] for _ in range(n)]
j = 0
for i in range(n):
    while(j < n-1):
        if(abs(x[j+1] - x[i]) > l):
            break
        j += 1
    dbl[i].append(j)

for i in range(30):
    if(dbl[0][-1] == n-1):
        break
    for j in range(n):
        dbl[j].append(dbl[ dbl[j][i] ][i])

def calc(a,b):
    if(dbl[a][0] >= b):
        return 1
    ind = bisect.bisect_left(dbl[a],b) - 1
    return 2**ind + calc(dbl[a][ind],b)

ans = []
it = iter(ab)
for a,b in zip(it,it):
    a -= 1
    b -= 1
    a,b = min(a,b),max(a,b)
    ans.append(calc(a,b))

print('\n'.join(map(str,ans)))

Measured memory_bytes: 159884
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    int n; ll k; cin >> n >> k;
    vector<int> bit(60,0);
    ll ans = 0;
    
    rep(i,n){
        ll a; cin >> a;
        rep(j,60) if ((a>>j) & 1ll) bit[j]++;
        ans += a ^ k;
    }

    vector<bool> kk(60,false);
    rep(i,60) if ((k>>i) & 1ll) kk[i] = true;

    for (int i = 59; i >= 0; i--) {
        if (!kk[i]) continue;
        ll ch = 0;
        rep(j,60) {
            if(j > i) {
                if (kk[j]) ch += ((ll)(n-bit[j])<<j);
                else ch += ((ll)bit[j]<<j);
            }
            else if(j == i) ch += ((ll)bit[j]<<j);
            else ch += ((ll)max(n-bit[j],bit[j])<<j);
        }
        chmax(ans, ch);
    }

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

Measured memory_bytes: 3612
#include <stdio.h>

int main(){
	
	int N, X, T;
	
	scanf("%d %d %d", &N, &X, &T);	
	N % X == 0 ? printf("%d", T * (N / X)) : printf("%d",   (T * (N / X)) + T);
	
	return 0;
}


Measured memory_bytes: 1708
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

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

int N, L;

int main() {

	scanf("%d%d", &N,&L);
	if (L <= 0 && L + N - 1 >= 0) printf("%d\n", (L + L + N - 1) * N / 2);
	else if (L > 0)  printf("%d\n", (L + L + N - 1) * N / 2 - L);
	else printf("%d\n", (L + L + N - 1) * N / 2 - (L + N - 1));

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int64_t sum =0;
  for ( int i = 0 ; i < n ; i++ ) {
    if ( (i+1)%3==0 || (i+1)%5==0 ) {
      continue;
    }
    else {
      sum += i+1;
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 3624
int main(void)
{
	int a, b, box;
	while(scanf("%d %d", &a, &b))
	{
		if(a > b)
		{
			box = b;
			b = a;
			a = box;
		}
		else if(a == 0 && b == 0)
		{
			break;
		}
		printf("%d %d\n", a, b);
	}
	return 0;
}


Measured memory_bytes: 2028
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define st(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())
int inf = 1000000007;
i64 giant = 4000000000000000000;

using namespace std;

int main() {
	int n;
	cin >> n;
	int ms = 0;
	ff(i, 1, n + 1) {
		int a;
		cin >> a;
		if (a != i)ms++;
	}
	if (ms == 0 || ms == 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  vector<LL> xs(7);
  REP(i,7) cin >> xs[i];

  LL res = xs[1];
  if(xs[0] > 2){
	if(xs[0]%2 == 1){
	  res += xs[0]/2*2;
	  xs[0] = 1;
	}
	else{
	  res += xs[0]/2*2-2;
	  xs[0] = 2;
	}
  }
  if(xs[3] > 2){
	if(xs[3]%2 == 1){
	  res += xs[3]/2*2;
	  xs[3] = 1;
	}
	else{
	  res += xs[3]/2*2-2;
	  xs[3] = 2;
	}
  }
  if(xs[4] > 2){
	if(xs[4]%2 == 1){
	  res += xs[4]/2*2;
	  xs[4] = 1;
	}
	else{
	  res += xs[4]/2*2-2;
	  xs[4] = 2;
	}
  }

  int c = 0;
  c += xs[0] > 1;
  c += xs[3] > 1;
  c += xs[4] > 1;
  if(c == 3)
	res += 6;
  else if(c == 2)
	res += 4;
  else{
	if(xs[0] > 0 && xs[3] > 0 && xs[4] > 0)
	  res += 3;
	else
	  res += c*2;
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 384
X=input()
k=0 # これまでに現れたSの数-Tの数 ただし0が下限
cnt=0 # k=0のときに現れたTの数
for c in X:
    if c=='S':
        k+=1
    else:
        if k==0:
            cnt+=1
        else:
            k-=1
print(cnt*2)

Measured memory_bytes: 41564
# coding: utf-8
# Here your code !
q = int(raw_input())
for i in range(q):
    l = map(float,raw_input().split())
    if l[2] - l[0] == 0:
        if l[6] - l[4] == 0:
            print 2
        elif l[7]-l[5] == 0:
            print 1
        else:
            print 0
    elif l[6] - l[4] == 0:
        if l[2] - l[0] == 0:
            print 2
        elif l[3] - l[1] == 0:
            print 1
        else:
            print 0
    else:
        s1 = (l[3] - l[1], l[2] - l[0])
        s2 = (l[7] - l[5], l[6] - l[4])
        if s1[0]/s1[1] == s2[0]/s2[1]:
            print 2
        elif s1[0]*s2[0] + s1[1]*s2[1] == 0:
            print 1
        else:
            print 0

Measured memory_bytes: 4284
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    System.out.println(Math.max(a*b, c*d));
  }
}


Measured memory_bytes: 21844
n = int(input())
a = [0] + list(map(int, input().split()))
b = [0]*(n+1)
for i in range(1, n+1)[::-1]:
    if a[i] == 1:
        if sum(b[i::i]) % 2 == 0:
            b[i] = 1
        else:
            b[i] = 0
    else:
        if sum(b[i::i]) % 2 == 0:
            b[i] = 0
        else:
            b[i] = 1
print(b.count(1))
for i in range(n+1):
    if b[i] == 1:
        print(i)

Measured memory_bytes: 70748
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 998244353;

vector<int> divi[210000];
long long int memo[210000];

int main(){
	int N;
	cin >> N;
	string X;
	cin >> X;
	for(int i = 1; i < 210000; i++){
		for(int j = i * 2; j < 210000; j += i){
			divi[j].push_back(i);
		}
	}
	long long int cur = 0;
	for(int i = 1; i <= N; i++){
		cur *= 2;
		if(X[i - 1] == '1'){
			cur += 1;
		}
		cur %= MOD;
		if(N % i == 0 && N / i % 2 == 1){
			//cout << i << endl;
			bool flag = true;
			int span = i;
			for(int j = span; j < N; j++){
				if(j / span % 2 == 1){
					if(X[j % span] == '0' && X[j] == '0'){
						flag = false;
						break;
					}
					if(X[j % span] == '1' && X[j] == '1'){
						break;
					}
				}else{
					if(X[j % span] == '0' && X[j] == '1'){
						break;
					}
					if(X[j % span] == '1' && X[j] == '0'){
						flag = false;
						break;
					}
				}
			}
			memo[i] = cur;
			if(flag){
				memo[i] += 1;
				memo[i] %= MOD;
			}
			for(int num : divi[i]){
				memo[i] += MOD - memo[num];
				memo[i] %= MOD;
			}
			//cout << memo[i] << endl;
		}
	}
	long long int ans = 0;
	for(int i = 1; i <= N; i++){
		ans += memo[i] * i * 2 % MOD;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 23044
/*
 
@author
_      _          _                 _      _
\\    // /\    | | \  |     |    /\ \\    //     
 \\  // /__\   | |_/  |_____|   /__\ \\  //
  \\// /    \  | | \  |     |  /    \ \\//
   \/ /      \ | |_/  |     | /      \ \/
@ Indian Institute of Technology Bhilai

With practice comes perfection,
with knowledge comes wisdom.
Incorporate wisdom in you, practice will harvest better results.
Always learn from others, your method is good but someone's even better.
Results take time, run for wisdom, for innovation, for getting better.
Points are mere objects, either you solve first or you solve better.
Seek for betterment, for quality, pace is important but cannot outstand
the quality you persist.
Times are bad just as now but it'll improve, this is my passion and I promise 
I won't let it go. I'll build myself again like a fighter gets back up after 
being thrown to the ground.
I'll learn. I bet that. I promise that.
*/
 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
#define fr(i,start,end, inc) for(ll i=(start); i<(end); i+=inc)
#define rf(i,end,start, inc) for(ll i=(start-1); i>=(end); i-=inc)
#define rep(i,n) for(ll i=0; i<n; i++)
#define rep1(i,n) for(ll i=1; i<=n; i++)
#define pb push_back
#define pl pair<ll, ll>
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define alla(arr,n) arr, arr+n
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
#define fsync ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll maxx =  1e9+7;

bool compare(vector<ll> &a, const vector<ll> &b){
    return a.size()>b.size();
}

ll inline power(ll a, ll b, ll p){
    a %= p;
    ll ans = 1;
    while(b>0){
        if(b & 1)
            ans = (ans*a)%p;
        a = (a*a)%p;
        b >>= 1;
    }
    return ans;
}

bool inline isPrime(ll n) { 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
    return true; 
}

template<class T>
void printv(T &v, ll n){
    if(n==-1)
        n = v.size();
    rep(i,n)
        cout << v[i] << " ";
    cout << "\n";
}


void solve(){
    ll n,k;
    cin>>n>>k;
    n -= (n/k)*k;
    cout << min(k-n,n)<<"\n";
}
int main(){
    fsync
    ll test=1;
    // cin >> test;
    while(test--){
        solve();
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }
    if (n <= 0) {
      System.out.println(0 + " " + 0 + " " + 0);
    } else {
      System.out.println(min(a) + " " + max(a) + " " + sum(a));
    }
  }
  static int min(int[] a) {
    int min = a[0];
    for (int i = 1; i < a.length; i++) {
      if (min > a[i]) {
        min = a[i];
      }
    }
    return min;
  }
  static int max(int[] a) {
    int max = a[0];
    for (int i = 1; i < a.length; i++) {
      if (max < a[i]) {
        max = a[i];
      }
    }
    return max;
  }
  static long sum(int[] a) {
    long sum = a[0];
    for (int i = 1; i < a.length; i++) {
      sum += a[i];
    }
    return sum;
  }
}


Measured memory_bytes: 41072
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char ch[3];
    int count = 0;
    cin>>ch;
    for(int i = 0;i<3;i++)
    {
      if(ch[i]=='7')
      count++;
     
    }
    if(count==0)
    cout<<"No"<<endl;
    else
    cout<<"Yes"<<endl;
}

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

public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] s= br.readLine().split(" ");
		int a = Integer.parseInt(s[0]);
		int b = Integer.parseInt(s[1]);
		if(a==b){
			System.out.println("a == b");
		}else if(a > b){
			System.out.println("a > b");
		}else{
			System.out.println("a < b");
		}
	}

}

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

using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;
    int s[55][55]={};
    char x;
    for(int i=1; i<=h; i++)
    {
        for(int j=1; j<=w; j++)
        {
            cin >> x;
            if(x=='#') s[i][j]=1;
        }
    }
    for(int i=1; i<=h; i++)
    {
        for(int j=1; j<=w; j++)
        {
            if(s[i][j]==1) cout << '#';
            else
            {
                cout << s[i-1][j-1]+s[i-1][j]+s[i-1][j+1]+s[i][j-1]+s[i][j+1]+s[i+1][j-1]+s[i+1][j]+s[i+1][j+1];
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define discount(n) ((n) * 8 / 10)

int main(void)
{
	int n;
	
	scanf("%d", &n);
	while (n-- > 0){
		int x, y, b, p;
		int sum_price = 0;
		
		scanf("%d %d %d %d", &x, &y, &b, &p);
		sum_price = x * b + y * p;
		if (b >= 5 && p >= 2){
			sum_price = discount(sum_price);
		}
		else {
			if (b < 5){
				b = 5;
			}
			if (p < 2){
				p = 2;
			}
			if (sum_price > discount(x * b + y * p)){
				sum_price = discount(x * b + y * p);
			}
		}
		printf("%d\n", sum_price);
	}
	
	return 0;
}

Measured memory_bytes: 600
n=int(input())
nums=list(map(int,input().split()))
count=0

def inversions(nums,left,mid,right):
    global count
    inf=10**9
    L=nums[left:mid]+[inf]
    R=nums[mid:right]+[inf]
    i=0
    j=0
    l=len(L)-1
    for k in range(left,right):
        if L[i]<=R[j]:
            nums[k]=L[i]
            i+=1
            l-=1

        else:
            nums[k]=R[j]
            j+=1
            count+=l


def inversions_sort(nums,left,right):
    if left+1<right:
        mid=(left+right)//2
        inversions_sort(nums,left,mid)
        inversions_sort(nums,mid,right)
        inversions(nums,left,mid,right)



inversions_sort(nums,0,n)
print(count)


Measured memory_bytes: 27476
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

template<class Monoid>
class SegmentTree{
private:
  using T = typename Monoid::T;
  const size_t n;
  vector<T> d;

  void build(){
    for(size_t b = n - 1; b > 0; b--) d[b] = Monoid::op(d[b << 1], d[b << 1 | 1]);
  }

public:
  SegmentTree(size_t n)
    : n(n), d(2 * n, Monoid::identify()) {}

  template<typename InputItr>
  SegmentTree(InputItr first, InputItr last)
    : n(distance(first, last)), d(2 * n, Monoid::identify()){
    copy(first, last, next(d.begin(), n));
    build();
  }

  /* set one value */
  void modify(size_t k, T v){
    for(d[k += n] = v; k > 1; k >>= 1) d[k >> 1] = Monoid::op(d[k], d[k ^ 1]);
  }

  /* return [l, r) value */
  T query(size_t l, size_t r){
    T res {Monoid::identify()};
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l&1) res = Monoid::op(res, d[l++]);
      if (r&1) res = Monoid::op(res, d[--r]);
    }
    return res;
  }
  
  void dump(){
    FOR(i, n, 2 * n) cout << i - n << ": " << d[i] << endl;
  }
};

template<typename U = ll>
struct RMQ{
  using T = U;
  static T op(const T& a, const T& b){ return max<T>(a, b); };
  static constexpr T identify(){ return numeric_limits<T>::min(); };
};

int main() {
    int n; cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    SegmentTree<RMQ<>> tree(a.begin(), a.end());

    REP(i, n) {
        cout << max(tree.query(0, i), tree.query(i+1, n)) << endl;
    }

    return 0;
}


Measured memory_bytes: 5504
#define KAKUSUKO
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 200000;
int N;
ll K;
ll A[MAX_N], F[MAX_N];


int main() {
    cin >> N >> K;
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> F[i];
    sort(F, F+N);
    reverse(F, F+N);
    sort(A, A+N);

    ll sum = 0;
    rep(i, N) sum += A[i];

    if (sum <= K) {
        cout << 0 << endl;
        return 0;
    }

    ll rest = sum - K;
    ll lb = -1, ub = INFLL, mid;
    while ((ub-lb) > 1) {
        mid = (ub+lb)/2;
        ll tmp = 0;
        for (int i = 0; i < N; ++i) {
            tmp += min(mid / F[i], A[i]);
        }
        if (tmp >= rest) {
            ub = mid;
        } else {
            lb = mid;
        }
    }

    cout << ub << endl;

    return 0;
}


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

using namespace std;

int main()
{
    int A[3];
    int i;
    for(i=0; i<3; i++){
        cin>>A[i];
    }
    sort(A,A+3);
    if(A[0]==5 && A[1]==5 && A[2]==7){
        cout<<"YES";
    }else{
    cout<<"NO";
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n)-1; i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const int MOD = 1000000007;

int main(){
  int r;  cin >> r;
  cout << 3*r*r << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  int n;
  cin >> n;
  vector<ll>a(n);
  ll sum=0;
  for(int i=0;i<n;++i) cin >> a[i];
  for(int i=0;i<n-1;++i) {
    if(a[i]>a[i+1]){
      sum+=a[i]-a[i+1];
      a[i+1]=a[i];
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 4840
function Main(input) {
  input = input.split("\n");
  const n = input[0];
  var tempBArray = input[1].split(" ");
  var BArray = [];
  var sum = 0;
  
  tempBArray.forEach(function(value) {
     BArray.push(Number(value));
  });

  for (var i = 0; i < n; i ++) {
    if (i === 0) {
      sum = sum + BArray[0];
    } else if (i === n-1) {
      sum = sum + BArray[n-2];
    } else {
      if (BArray[i - 1] < BArray[i]) {
        sum = sum + BArray[i - 1];
      } else {
        sum = sum + BArray[i];
      }
    }
  }

  console.log(sum);
  
  }
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 11468
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <list>
#include <map>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define fi first
#define se second
#define pb push_back
//#define mp make_pair
#define rep(i,n) for(register int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
const int INF=0x3f3f3f3f;
const int dx[]={0,1,-1,0},dy[]={1,0,0,-1};
//const int MOD=998244353;
//const int N=2e5+10;

inline int read(){
	int ww=1,xx=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-') ww=-ww;ch=getchar();}
	while(isdigit(ch)){xx=(xx<<1)+(xx<<3)+(ch^48);ch=getchar();}
	return ww*xx;
}

int a,b;
int cnt;
int tmp;

signed main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>a>>b;
	if(b==1) puts("0");
	else
	for(int i=1;;i++) if(i*(a-1)+1>=b) {printf("%d\n",i);break;}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int t;
  cin >> t;
  while(t--) {
    int n,k;
    cin >> n >> k;
    int x[n];
    long long  res = 0;
    REP(i,n) {
      cin >> x[i];
    }
    vector<int> v(n-1);
    REP(i,n-1) {
      v[i] = x[i+1]-x[i];
      res += v[i];
    }
    sort(ALL(v),greater<int>());
    REP(i,min(k-1,n-1)){
      res -= v[i];
    }
    cout << res << endl;
  }
}

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

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}

struct Edge {
    LL dst, a, b;
};
typedef vector<Edge> Node;
typedef vector<Node> Graph;

const LL INF = 1e18;

vector<LL> dijkstra1(const Graph& G, int s){
    typedef pair<LL, int> P;
    priority_queue<P, vector<P>, greater<P>> que;
    vector<LL> dist(G.size(), INF);
    que.push(P(0, s));
    dist[s] = 0;
    while(!que.empty()){
        P p = que.top(); que.pop();
        LL v = p.second, c = p.first;
        if(c > dist[v]) continue;
        for(auto& e : G[v]){
            if(dist[e.dst] > dist[v] + e.a){
                dist[e.dst] = dist[v] + e.a;
                que.push(P(dist[e.dst], e.dst));
            }
        }
    }
    return dist;
}
vector<LL> dijkstra2(const Graph& G, int s){
    typedef pair<LL, int> P;
    priority_queue<P, vector<P>, greater<P>> que;
    vector<LL> dist(G.size(), INF);
    que.push(P(0, s));
    dist[s] = 0;
    while(!que.empty()){
        P p = que.top(); que.pop();
        LL v = p.second, c = p.first;
        if(c > dist[v]) continue;
        for(auto& e : G[v]){
            if(dist[e.dst] > dist[v] + e.b){
                dist[e.dst] = dist[v] + e.b;
                que.push(P(dist[e.dst], e.dst));
            }
        }
    }
    return dist;
}


int main(){
    iostream_init();
    int N, M, S, T;
    cin >> N >> M >> S >> T;
    S--; T--;
    Graph G(N);
    REP(_, M) {
        LL u, v, a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        G[u].push_back({ v, a, b });
        G[v].push_back({ u, a, b });
    }

    vector<LL> d1 = dijkstra1(G, S);
    vector<LL> d2 = dijkstra2(G, T);
    vector<LL> d;

    for(int i = 0; i < N; i++) {
        d.push_back(d1[i] + d2[i]);
    }

    deque<pair<LL, int>> que;
    for(int i = 0; i < N; i++) {
        auto x = d[i];
        while(que.size() > 0) {
            auto p = que.front();
            if (p.first >= x) {
                que.pop_front();
            } else {
                break;
            }
        }
        que.push_front(make_pair(x, i));
    }

    LL base = 1e15;
    for(int i = 0; i < N; i++) {
        while (que.back().second < i) {
            que.pop_back();
        }
        cout << base - que.back().first << endl;
    }

    return 0;
}


Measured memory_bytes: 14456
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int MOD = 1e9 + 7 ;



int32_t main()
{
   IOS
   int n,m;cin>>n>>m;
   vector<vector<char>>g(n+2,vector<char>(m+2));
   vector<vector<int>>dp(n+2,vector<int>(m+2));
   for(int i=1;i<=n;i++)
   for(int j=1;j<=m;j++)
   cin>>g[i][j];
   for(int i=1;i<=n;i++)
   for(int j=1;j<=m;j++)
   {
	   if(g[i][j]=='#')continue;
	   if(i==1 && j==1)dp[i][j]=1;
	   else
	   {
		   dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
	   }
   }
   cout << dp[n][m] << endl;
	  
}


Measured memory_bytes: 9216
#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()
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

map<int, int> mp;
int n;
int ask(int i) {
    i %= n;
    if (mp.count(i)) return mp[i];
    cout << i << endl;
    string s;
    cin >> s;
    if (s[0] == 'V') exit(0);
    return mp[i] = (s[0]  == 'M');
}

int g(int i, int j) { return (j-i+n)%n;}

int main() {
	cin >> n;
    int l = 0, r = n/2;
    int a = ask(l);
    int b = ask(r);
    if ((a^b) == g(l,r)%2) {
        swap(l,r); r += n;
    }
    while (1) {
        int c = (l+r)>>1;
        if ((ask(l)^ask(c)) == g(l,c)%2)   l = c;
        else                               r = c;
    }
	return 0;
}


Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
typedef long long int lli;
#define tc int t;cin>>t;while(t--)
#define f first
#define s second
#define pb push_back
#define vi vector<int>
#define vll vector<lli>


int main() {
   fastio;
   string s;
   cin>>s;
   if(s[2]==s[3] and s[4]==s[5])
    cout<<"Yes\n";
   else
    cout<<"No\n";
   return 0;
}


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

int main()
{
    int n, m, i, j;
    scanf("%d %d", &n, &m);
    int a[n][m], b[m], ans[n] ={};
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
            scanf("%d", &a[i][j]);
    }
    for (i = 0; i < m; i++)
        scanf("%d", &b[i]);

    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
            ans[i] += a[i][j] * b[j];
        printf("%d\n", ans[i]);
    }
}


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

/*vector<int> p(n);
cin >> p[i]*/

int main(){

    int n;
    cin >> n;

    if(n%2 == 0) cout << n/2 << endl;
    else cout << n/2+1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 405

enum Type{
	R,
	G,
	Y,
};

int N;
Type colors[3] = {R,G,Y};
int dp[NUM][NUM][NUM][3];
int LOC[NUM][3],num[3],left_num[NUM][3];
char buf[NUM];

int move_cost(int base_loc,int left_R,int left_G,int left_Y){

	return max(0,left_num[base_loc][R]-left_R)+max(0,left_num[base_loc][G]-left_G)+max(0,left_num[base_loc][Y]-left_Y);
}

int main(){

	scanf("%d",&N);
	scanf("%s",buf);

	for(int i = 0; i < 3; i++){

		num[i] = 0; //各色の草がいくつあるか
		LOC[0][i] = 0; //インデックス1オリジンで、何番目の草がどこにあるか
	}

	Type type;

	for(int i = 0; i < N; i++){

		switch(buf[i]){
		case 'R':
			type = R;
			break;
		case 'G':
			type = G;
			break;
		case 'Y':
			type = Y;
			break;
		}
		LOC[++num[type]][type] = i;
		//その場所より左に、各色の草がいくつあるかを調べる(0～i-1)
		for(int k = 0; k < 3; k++){
			left_num[i][k] = num[k];
		}
		left_num[i][type] -= 1;
	}

	for(int red = 0; red <= num[R]; red++){
		for(int green = 0; green <= num[G]; green++){
			for(int yellow = 0; yellow <= num[Y]; yellow++){
				for(int i = 0; i < 3; i++){
					dp[red][green][yellow][i] = BIG_NUM;
				}
			}
		}
	}

	for(int i = 0; i < 3; i++){
		dp[0][0][0][i] = 0;
	}

	Type last_color;

	for(int red = 0; red <= num[R]; red++){ //赤の個数
		for(int green = 0; green <= num[G]; green++){ //緑の個数
			for(int yellow = 0; yellow <= num[Y]; yellow++){ //黄色の個数
				for(int i = 0; i < 3; i++){
					last_color = colors[i];

					//自分と同じ色と交差したら非最適→swap前に自分より左にあった自分と同色の草の数が、red-1より多かったら不可
					if(last_color != R && red > 0 && left_num[LOC[red][R]][R] <= red-1 && dp[red-1][green][yellow][last_color] != BIG_NUM){
						dp[red][green][yellow][R] = min(dp[red][green][yellow][R],dp[red-1][green][yellow][last_color]+move_cost(LOC[red][R],red-1,green,yellow));
					}
					if(last_color != G && green > 0 && left_num[LOC[green][G]][G] <= green-1 && dp[red][green-1][yellow][last_color] != BIG_NUM){
						dp[red][green][yellow][G] = min(dp[red][green][yellow][G],dp[red][green-1][yellow][last_color]+move_cost(LOC[green][G],red,green-1,yellow));
					}
					if(last_color != Y && yellow > 0 && left_num[LOC[yellow][Y]][Y] <= yellow-1 && dp[red][green][yellow-1][last_color] != BIG_NUM){
						dp[red][green][yellow][Y] = min(dp[red][green][yellow][Y],dp[red][green][yellow-1][last_color]+move_cost(LOC[yellow][Y],red,green,yellow-1));
					}
				}
			}
		}
	}

	int ans = BIG_NUM;
	for(int i = 0; i < 3; i++){
		ans = min(ans,dp[num[R]][num[G]][num[Y]][i]);
	}

	if(ans == BIG_NUM){

		printf("-1\n");
	}else{

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

	return 0;
}



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

#define ll                      long long int
#define rloopl(i,a,b)           for(ll i=(ll)a;i<=(ll)b;++i)
#define loopl(i,a,b)           for(ll i=(ll)a;i<(ll)b;++i)

int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    ll n,W;
    cin>>n>>W;
    vector<ll> v(n+1);
    vector<ll> w(n+1);
    // int dp[n+5];
    loopl(i,0,n)
    {
        cin>>w[i]>>v[i];
    }    
    ll dp[n+1][W+1];
    rloopl(i,0,n)
    {
        rloopl(j,0,W)
        {
            if(i==0 || j==0)
                dp[i][j] = 0;
            else if(w[i-1]<=j)
                dp[i][j] = max(v[i-1]+dp[i-1][j-w[i-1]], dp[i-1][j]);
            else 
                dp[i][j] = dp[i-1][j];
        }
    }


    cout<<dp[n][W]<<endl;


    return 0;
}

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

int main() {
  int N, C;  cin >> N >> C;
  vector<int> s(N), t(N), c(N);
  vector<int> a(200002, 0);
  vector<int> S(200002, 0);
  for(int i = 0; i < N; ++i) {
    cin >> s[i] >> t[i] >> c[i];
  }
  for(int i = 1; i <= C; ++i) {
    for(int j = 0; j < 200002; ++j) a[j] = 0;
    for(int j = 0; j < N; ++j) if(c[j] == i) a[s[j]*2-1]++, a[t[j]*2]--;
    for(int j = 1; j < 200002; ++j) a[j] += a[j-1];
    for(int j = 0; j < 200002; ++j) if(a[j] > 0) S[j]++;
  }
  int ans = -1;
  for(int j = 0; j < 200002; ++j) ans = max(ans, S[j]);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	
	int a[1000],b,c;
	cin>>b;
	for(int i=0;i<b;i++){
		cin>>a[i];
	}
	for(int i=0;i<b;i++){
		c+=a[i];
	}
	
	sort(a,a+b);
	if(2*a[b-1]<c){cout<<"Yes";}
	else cout<<"No";
	
	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(x) (x).begin(), (x).end()
#define Sort(x) sort((x).begin(), (x).end())
#define Reverse(x) reverse((x).begin(), (x).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for (int i = m; i < n; i++)
#define INF INT_MAX
#define fcout cout << fixed << setprecision(15) // 15桁まで表示
#define en '\n'
using str = string;
using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
using puu = pair<ui, ui>;
using P = pair<int, int>;
using vi = vector<int>;
int gcd(int a, int b) {
  return b ? gcd(b, a % b) : a;
};
int lcm(int a, int b) {
  return a / gcd(a, b) * b;
};
int floor(int a, int b) {
  return (a + b - 1) / b;
};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
};
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
};
const ll mod = 1000000007;
const double PI = acos(-1.0);
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);
  int n;
  cin >> n;
  ll ans=1;
  REP(i, 1, n + 1) ans = (i * ans) % mod;
  cout << ans << en;
}

Measured memory_bytes: 3536