akhauriyash/Code-Regression huggingface dataset:
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 10e9;
const int MAX_V = 201;

void SugarWater() {
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;

	int all = 0;
	int suger = 0;
	double best = 0.0;
	for (size_t i = 0; i <= 30; i++)
	{
		int aw = i * a * 100;
		if (aw > f) break;
		for (size_t j = 0; j <= 30; j++)
		{
			int bw = j * b * 100;
			if (aw + bw > f) break;
			if (aw + bw == 0) continue;
			int water = aw + bw;
			for (size_t k = 0; k <= 3000; k++)
			{
				int line = i * a + j * b;
				int as = c * k;
				if (line * e < as) break;
				for (size_t ii = 0; ii <= 3000; ii++)
				{
					int bs = d * ii;
					if (line * e < as + bs) break;
					int sumsuger = as + bs;
					int ab = sumsuger + water;
					if (ab > f) break;
					if (ab * suger <= sumsuger * all) {
						all = water + sumsuger;
						suger = sumsuger;
					}
				}
			}
		}
	}

	cout << all << " " << suger << endl;
}

int main() {
	SugarWater();
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n;
    cin >> n;
    vint p(n), q(n);
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];

    vint r(n);
    rep(i, n) r[i] = i+1;

    int pn, qn;
    int count = 1;
    do {
        if (r == p) pn = count;
        if (r == q) qn = count;
        count++;
    } while( next_permutation(all(r)) );

    int ans = abs(pn - qn);

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

Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

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

#define v vector
#define ALL(x) x.begin(),x.end()
#define rALL(x) x.rbegin(),x.rend()
#define endl '\n'
#define F first
#define S second
#define DEBUG

template<typename T> void DBG(const char* name, T&& H) {
	cerr << name << " = " << H << ')' << endl;
}

template<typename T, typename... Args> void DBG(const char* names, T&& H, Args&&... args) {
	const char* NEXT = strchr(names+1, ',');
	cerr.write(names, NEXT-names) << " = " << H << " |";
	DBG(NEXT+1, args...);
}

#ifdef DEBUG
	#define dbg(...) cerr << __FUNCTION__ << ' ' <<__LINE__ << " : (", DBG(#__VA_ARGS__, __VA_ARGS__)
#else
	#define dbg(...)
#endif

using ll = long long;
using ld = long double;

const long long mod = 998244353;
const long double PI = acos(-1.0);
const long long INF = 1e18;
const int maxN = 2e5+1;

void Solve() {
	int x;
	cin >> x;
	if(x >= 30) {
		cout << "Yes" << endl;
	}	
	else cout << "No" << endl;
}

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

	int tt = 1;
	while(tt --) {
		Solve();
	}
	
	return 0;
}

Measured memory_bytes: 3648
from collections import defaultdict
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def solve():
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        exit()

    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    d_a = defaultdict(int)
    for a in A:
        d_a[a] += 1

    d_b = defaultdict(int)
    for b in B:
        d_b[b] += 1

    ans = 0
    for v in set(A + B):
        ans += v*max(d_a[v], d_b[v])
    print(ans)


while True:
    solve()



Measured memory_bytes: 5996
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

// 特定の文字列を数える関数
size_t count(const string& str, const string& sub, const size_t ini = 0, const size_t fin = string::npos) {
	size_t pos = str.find(sub, ini);
	size_t cnt = 0;
	while (pos < fin) {
		cnt += 1;
		pos = str.find(sub, pos + sub.length());
	}
	return cnt;
}

int main() {

	int N;
	int A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	A--;
	B--;
	C--;
	D--;

	string S;
	cin >> S;

	int c1, c2;
	bool jdg = false;

	if (C < D) {
		c1 = count(S, "##", A, C);
		c2 = count(S, "##", B, D);
		if (c1 == 0 && c2 == 0) {
			jdg = true;
		}
	}
	else {
		int c3;
		c1 = count(S, "##", A, C);
		c2 = count(S, "##", B, D);
		c3 = count(S, "...", B - 1, D);
		if (c1 == 0 && c2 == 0 && c3 > 0) {
			jdg = true;
		}
	}

	if (jdg == true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3768
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<tuple>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

struct edge{int to,cost;};

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

	int n,m;
	cin >> n >> m;

	int i=n;
	if(m%2==1){
		if(n%2==0) i++;
		for(;i<=m;i+=2){
			if(m%i == 0) break;
		}
	}
	else{
		for(;i<=m;i++){
			if(m%i == 0) break;
		}
	}
	cout << m/i << "\n";

	return 0;
}

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

int main() {
  string s; cin >> s;
  int size = s.size();
  int c = 0, ans = 0;
  for(int i = 0; i < size; i++) {
    if(s[i] == 'A' || s[i] == 'C' ||
       s[i] == 'G' || s[i] == 'T') ++c;
    else if(ans < c) {ans = c; c = 0;}
    else c = 0;
  }
  ans = max(ans, c);
  cout << ans << endl;
  return 0;
}

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

int A[100000];

int partiton( int A[], int p, int r ){
  int x = A[r];
  int i = p-1;
  for( int j=p; j<r; j++ ){
    if( A[j] <= x ){
      i += 1;
      swap( A[i], A[j] );
    }
  }
  swap( A[i+1], A[r] );

  return i+1;
}

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

  for( int i=0; i<n; i++ ){
    cin >> A[i];
  }

  int p = partiton( A, 0, n-1 );

  for( int k=0; k<n; k++ ){
    if( k != p ){
      if( k != n-1 ){
        cout << A[k] << " ";
      }else{
        cout << A[k] << endl;
      }
    }else{
      cout << "[" << A[k] << "] ";
    }
  }

  return 0;
}


Measured memory_bytes: 3468
n = int(input())
al = [int(input())-1 for _ in range(n)]
used = [False]*n
s = 0
res = 0
used[s] = True
while s!=1:
    s = al[s]
    if used[s]:
        print(-1)
        exit()
    used[s] = True
    res += 1
print(res)

Measured memory_bytes: 7852
#include <iostream>

int main(){
    int n;
    std::cin >> n;
    std::string s="No";
    
    for(int i=1;i<=9;++i){
        int temp=n/i;
        
        if(n%i==0&&temp<10){
            s="Yes";
            break;
        }
    }
    
    std::cout << s << std::endl;
    return 0;
}

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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  ll a,b,c;
  cin>>a>>b>>c;
  ll t=a;
  for(int i=0;i<300;i++){
    if(t%b==c){
      printf("YES\n");return 0;
    }
    t+=a;
  }
  printf("NO\n");return 0;

  return 0;
}


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

using namespace std;

#define ll long long int
#define ld long double
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007
const int N = 1e6 + 5;
ll cnt[N];
ll gcd(ll a, ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b , a%b);
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;
    ll a[n];
    for(int i = 0 ; i < n; i++){
        cin>>a[i];
    }
    ll gc = a[0];
    for(int i = 1; i < n; i++){
        gc = gcd(gc, a[i]);
    }
    if(gc > 1){
        cout<<"not coprime";
        return 0;
    }
    for(int i = 0; i < n; i++){
        ll t = a[i];
        for(int j = 2; j*j <= t; j++){
            if(t % j == 0){
                while(t % j == 0){
                    t /= j;
                }
                cnt[j]++;
            }
        }
        if(t > 1){
            cnt[t]++;
        }
    }
    bool flag = 1;
    for(auto it : cnt){
        if(it > 1){
            flag = 0;
            break;
        }
    }
    if(flag){
        cout<<"pairwise coprime";
    }else{
        cout<<"setwise coprime";
    }
}

Measured memory_bytes: 19204
#include <iostream>

using namespace std;

int main(){

int a,b,c;

cin >> a >> b >> c ;


if(a>b){
 if(b>c){
   cout << c <<" "<< b <<" " << a << endl;
 }else if(a>c){
   cout << b <<" "<< c <<" " << a << endl;
 }else{
   cout << b <<" "<< a <<" " << c << endl;
 } 
}else if(b<c){
   cout << a <<" "<< b <<" " << c << endl;
}else if(a < c){
   cout << a <<" "<< c <<" " << b << endl;
}else{
   cout << c <<" "<< a <<" " << b << endl;
}



 return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll q;cin>>q;
  for(ll i=0;i<q;i++){
    ll x,y;
    cin>>x>>y;
    if(x>y)swap(x,y);
    
    long double k=sqrt(x*y-0.75)-x+0.5;
    ll lk=k;
    
    ll ans=x-1+k+(x*y-1)/(x+k);
    cout<<ans-(x!=y)<<endl;
  }
}


Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int n,s;
    while(cin >> n >> s,n){
        function<int(int,int,int)> rec = [&](int now,int sum,int dep){
            if(dep == n){
                return (int)(sum == s);
            }
            int ret = 0;
            for(int i = now; i <= 9; i++){
                ret += rec(i+1,sum+i,dep+1);
            }
            return ret;
        };
        cout << rec(0,0,0) << endl;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    // cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}



Measured memory_bytes: 3084
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;

/*
struct point
{
long long dist; long long name;
bool operator<(const point& rhs) const {
return dist > rhs.dist;
}
};
*/

double f(ll x, double p) {
	return double(x) / p;
}

int main() {
	cout.precision(13);

	ll x; double p;
	cin >> x >> p;	p /= 100;

	if (x % 2 == 0) {
		x /= 2;
		cout << f(x, p) << endl;
	}
	else {
		ll y = x / 2;
		x = y + 1;
		cout << 1+ (f(x, p)* (1-p) + f(y, p)*p) << endl;
	}
}

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

int main(){
  int a;
  cin >> a;
  int k = a/1000;
  int l = (a-k*1000)/100;
  int m = (a-k*1000-l*100)/10;
  int n = (a-k*1000-l*100-m*10);
  if((k-l)*(l-m)*(m-n)==0){
    cout << "Bad" << endl;
  }
  else{
    cout << "Good" << endl;
  }
}
  

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define inv(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); }
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class BStringRotation {
  public : static void solve(std::istream & cin, std::ostream &cout){
      string S, T;
      cin>>S>>T;
      rep(i, S.size()){
        string temp = S.substr(i, S.size() - i) + S.substr(0, i);
        if (temp == T){
          cout<<"Yes"<<endl;
          return;
        }
      }
      cout<<"No"<<endl;
  }
};


signed main() {
  BStringRotation solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
inpl = lambda: list(map(int,input().split()))
from collections import defaultdict

class UnionFind:
    def __init__(self, N=None):
        if N is None or N < 1:
            self.parent = defaultdict(lambda: -1)
        else:
            self.parent = [-1]*int(N)

    def root(self, n):
        if self.parent[n] < 0:
            return n
        else:
            m = self.root(self.parent[n])
            self.parent[n] = m
            return m

    def merge(self, m, n):
        rm = self.root(m)
        rn = self.root(n)
        if rm != rn:
            if -self.parent[rm] < -self.parent[rn]:
                rm, rn = rn, rm
            self.parent[rm] += self.parent[rn]
            self.parent[rn] = rm

    def size(self, n):
        return -self.parent[self.root(n)]
    
    def connected(self, m, n):
        return self.root(m) == self.root(n)
    
    def groups(self):
        if isinstance(self.parent,list):
            return list(map(lambda x: x<0, self.parent)).count(True)
        else: # self.parent: defaultdict
            return list(map(lambda x: x<0, self.parent.values())).count(True) 

class CountUp:
    def __init__(self, start=0):
        self.index = start-1

    def __call__(self):
        self.index += 1
        return self.index

N = int(input())
uf = UnionFind()
for _ in range(N):
    x, y = inpl()
    uf.merge(2*x+1,2*y)

Ng = uf.groups()
nx = [0]*Ng
ny = [0]*Ng
gi = defaultdict(CountUp())
for k in uf.parent.keys():
    if k % 2:
        nx[gi[uf.root(k)]] += 1
    else:
        ny[gi[uf.root(k)]] += 1

ans = sum([ nx[g]*ny[g] for g in range(Ng) ]) - N
print(ans)

Measured memory_bytes: 16104
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int N;
    cin >> N;
    if (N == 0){
      break;
    }
    vector<int> A(N, 0), L(N);
    for (int i = 0; i < N; i++){
      int M;
      cin >> M >> L[i];
      vector<int> d(17, 0);
      for (int j = 0; j < M; j++){
        int S, E;
        cin >> S >> E;
        d[S - 6]++;
        d[E - 6]--;
      }
      for (int j = 0; j < 16; j++){
        d[j + 1] += d[j];
      }
      bool ok = true;
      for (int j = 0; j < 16; j++){
        if (d[j] >= 2){
          ok = false;
        }
        if (d[j] == 1){
          A[i] += 1 << j;
        }
      }
      if (!ok){
        L[i] = 0;
      }
    }
    vector<int> dp(1 << 16, 0);
    for (int i = 0; i < (1 << 16); i++){
      for (int j = 0; j < N; j++){
        if ((i & A[j]) == 0){
          dp[i + A[j]] = max(dp[i + A[j]], dp[i] + L[j]);
        }
      }
    }
    cout << dp[(1 << 16) - 1] << endl;
  }
}


Measured memory_bytes: 3344
#include <iostream>

using namespace std;

int main() {
    int n; cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ans = 0;
    for(int i = 1; i < n; i++) {
        if(a[i] == a[i - 1]) {
            a[i] = 0;
            ans++;
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int S = scan.nextInt();
        int W = scan.nextInt();
        if (W < S) {
            System.out.println("safe");
        } else {
            System.out.println("unsafe");
        }
    }
}


Measured memory_bytes: 27108
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#include <unordered_map>

using namespace std;

typedef long long ll;

void solve() {
	int n;
	cin >> n;
	vector<int> a(n), b(n);

	for (int i = 0; i < n; i++) {
		int f, t;
		cin >> f >> t;
		a[i] = f;
		b[i] = t;
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	if (n % 2) {
		cout << b[n / 2] - a[n / 2] + 1;
	}
	else {
		cout << (b[n / 2 - 1] + b[n / 2]) - (a[n / 2 - 1] + a[n / 2]) + 1;
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		cout << '\n';
	}
}

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

const int maxn = 10000;
//const int mod = 1e9+7;

int n,mod;
string s;

void solve(){
	cin>>n>>mod>>s;
	if(__gcd(10,mod)==1){
		map<ll,ll> mp; mp[0] = 1;
		ll pot=1,pre=0,ans=0;
		for(int i=n-1;i>=0;--i){
			pre+=(s[i]-'0')*pot;
			pre%=mod;
			ans+=mp[pre];
			mp[pre]++;
			pot*=10LL;
			pot%=mod;
			if(pot==0)
				pot=1;
		}
		cout<<ans<<endl;
	}
	else{
		ll ans=0;
		for(int i=0;i<n;++i){
			if((s[i]-'0')%mod==0)
				ans+=i+1;
		}
		cout<<ans<<endl;
	}
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 4048
H, W, D = map(int, input().split())
# 1, 2, ..., H*Wの座標を記録
G = [(-10**9, -10**9) for _ in range(H * W + 1)]

for i in range(H):
    line = list(map(int, input().split()))
    for j in range(W):
        grid = int(line[j])
        G[grid] = (i, j)

# 1,2,...,H*Wまで行くために必要なコスト
cost = [0 for _ in range(H * W + 1)]
for i in range(D + 1, H * W + 1):
    cost_x = abs(G[i][0] - G[i - D][0])
    cost_y = abs(G[i][1] - G[i - D][1])
    cost[i] = cost[i - D] + cost_x + cost_y

ans = []

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    tmp = cost[r] - cost[l]
    ans.append(tmp)

# print(G)
# print(cost)

for i in ans:
    print(i)


Measured memory_bytes: 86320
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e18;

int32_t main(){
	IOS;
	int n,k;
	cin>>n;
	k=2;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	int dp[n];
	for(int i=0;i<n;i++) dp[i]=1e18;
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<=i+k&&j<n;j++){
			dp[j]=min(dp[j],abs(a[j]-a[i])+dp[i]);
		}
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>

using namespace std;

int a, b, c;
bool flag;

int main()
{
	cin >> a >> b >> c;
	for (register int i = 0; i <= 1000; i++)
	{
		int ans = a * i;
		if (ans%b == c) { flag = 1; break; }
	}
	if(flag) printf("YES\n");
	else printf("NO\n");
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var i int
	fmt.Scan(&i)
	list := []int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}
	fmt.Println(list[i-1])
}


Measured memory_bytes: 512
n,*z=`dd`.split.map &:to_i
t=(e=[*0...n]).dup
a=z.shift n+1
n.downto(1){|i|a[i]-=a[i-1]}
k,*z=z
z.map{|x|t[x-2],t[x-1]=t[x-1],t[x-2]}
(k%2>0&&e.map!{|q|t[q]};t=t.map{|q|t[q]};k/=2)while k>0
k,*a=a
n.times{|i|p k;k+=a[e[i]]}

Measured memory_bytes: 55616
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

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

		int N = sc.nextInt();
		int M = sc.nextInt();
		
		PriorityQueue<Integer> yenQ = new PriorityQueue<>(Collections.reverseOrder());
		for (int i=0; i<N; i++) {
			yenQ.add(sc.nextInt());
		}
		
		for (int i=0; i<M; i++) {
			yenQ.add(yenQ.poll() / 2);
		}

		long sum = 0;
		for (Integer yen : yenQ) {
			sum += yen;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 59524
import math
from decimal import *


def read():
    N, K = list(map(int, input().strip().split()))
    return N, K


def solve(N, K):
    # 得点nのとき、x回連続で表が出たらK以上になる
    getcontext().prec = 10
    prob = []
    for n in range(1, N+1):
        x = max(0, math.ceil(math.log2(K / n)))
        prob.append(Decimal.from_float(0.5) ** Decimal(x))
    return sum(prob) / Decimal(N)


if __name__ == '__main__':
    inputs = read()
    print("%.10f" % solve(*inputs))


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

int main() {
    int K, X; cin >> K >> X;
    if(K * 500 >= X) cout << "Yes\n";
    else cout << "No\n";
}

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

int x[111];
int main() {
    int n, s = 0;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> x[i], s += x[i];
    s /= n;
    int m = 1e9;
    for(int i = 0; i < 2; i++) {
        int a = 0;
        for(int j = 0; j < n; j++)
            a += (x[j] - s - i) * (x[j] - s - i);
        m = min(m, a);
    }
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int ans=0;
  if(a>=b){
    ans+=a;
    a--;
  }
  else{
    ans+=b;
    b--;
  }
  if(a>=b) {
    ans+=a;
  }
  else{
    ans+=b;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long t=1;
    //cin>>t;
    for(long long q=0;q<t;q++){
        int n,s;
        cin>>n>>s;
        int a[n];
        for(long long i=0;i<n;i++){
            cin>>a[i];
        }
        long long dp[n][s+1];
        for(int i=0;i<n;i++){
            for(int j=0;j<s;j++)
                dp[i][j+1]=0;
            dp[i][0]=i+2;
        }
        long long ans=0;
        if(a[0]<=s)
            dp[0][a[0]]=1;
        if(s==a[0])
            ans=n;
        for(int i=1;i<n;i++){
            if(s-a[i]>=0)
                ans=(ans+dp[i-1][s-a[i]]*(n-i))%998244353;
            for(int j=1;j<=s;j++){
                dp[i][j]=dp[i-1][j];
                if(j-a[i]>=0){
                    dp[i][j]=(dp[i-1][j]+dp[i-1][j-a[i]])%998244353;
                }
            }
        }
        cout<<ans<<"\n";
    }
}


Measured memory_bytes: 70656
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author MaxHeap
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    APluralForm solver = new APluralForm();
    solver.solve(1, in, out);
    out.close();
  }

  static class APluralForm {

    public void solve(int testNumber, InputReader in, PrintWriter out) {
      String s = in.next();
      if (s.charAt(s.length() - 1) == 's') {
        out.println(s + "es");
      } else {
        out.println(s + "s");
      }
    }

  }

  static class InputReader {

    private InputStream stream;
    private static final int DEFAULT_BUFFER_SIZE = 1 << 16;
    private static final int EOF = -1;
    private byte[] buf = new byte[DEFAULT_BUFFER_SIZE];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int read() {
      if (this.numChars == EOF) {
        throw new UnknownError();
      } else {
        if (this.curChar >= this.numChars) {
          this.curChar = 0;

          try {
            this.numChars = this.stream.read(this.buf);
          } catch (IOException ex) {
            throw new InputMismatchException();
          }

          if (this.numChars <= 0) {
            return EOF;
          }
        }

        return this.buf[this.curChar++];
      }
    }

    public String next() {
      int c;
      while (isSpaceChar(c = this.read())) {
      }

      StringBuilder result = new StringBuilder();
      result.appendCodePoint(c);

      while (!isSpaceChar(c = this.read())) {
        result.appendCodePoint(c);
      }

      return result.toString();
    }

    public static boolean isSpaceChar(int c) {
      return c == 32 || c == 10 || c == 13 || c == 9 || c == EOF;
    }

  }
}



Measured memory_bytes: 36288
<?php
    fscanf(STDIN,"%d",$N);
    
    $A = array_map('intval',explode(" ",trim(fgets(STDIN))));
    
    for($i=1;$i<=$N;$i++){
        $ans[$A[$i-1]] = $i;
    }
    ksort($ans);
    // var_dump($ans);
    
    $ansx = implode(" ",$ans);
    
    echo $ansx;
    
?>

Measured memory_bytes: 28316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb(x) (x&-(x))
const int N = 101010;

int main(){
	int a,b;
	cin>>a>>b;
	int c;
	c=(int)((a+b)/2.+0.5);
	cout<<c<<endl;




    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

struct ST {
  int prev;
  int node;
  int dist;
};
bool operator<(const ST& a, const ST& b){
  return a.dist > b.dist;
}

ll ret[3005];
int N;
vector<int> G[3005];

void solve(int st){
  vector<int> dist(3005, -1);
  priority_queue<ST> que;
  que.push((ST){-1,st,0});
  while(!que.empty()){
    ST st = que.top(); que.pop();
    if(dist[st.node] != -1) continue;
    dist[st.node] = st.dist;
    rep(i,G[st.node].size()){
      if(dist[G[st.node][i]] != -1) continue;
      que.push((ST){st.node, G[st.node][i], st.dist+1});
    }
  }
  REP(i,st+1,N){
    ret[dist[i]]++;
  }
}

int main(){
  int X, Y;
  cin >> N >> X >> Y;
  X--;
  Y--;

  rep(i,N-1){
    G[i].push_back(i+1);
    G[i+1].push_back(i);
  }
  G[X].push_back(Y);
  G[Y].push_back(X);
  
  rep(i,N){
    solve(i);
  }

  REP(i,1,N){
    cout << ret[i] << endl;
  }
  
  return 0;
}



Measured memory_bytes: 384
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(100000)

def main():
    N = int(input())
    sides = [[] for _ in range(N-1)]
    
    for i in range(N-1):
        a,b = map(int, input().split())
        sides[a-1].append((b-1,i))

    ans = [[None] for _ in range(N-1)]

    def dfs(focus,parent_color):
        color = 1
        for child,index in sides[focus]:
            if parent_color == color:
                color += 1 #もし親の色と被っていた場合はその色を飛ばす
            ans[index] = color
            if child < N-1:
                dfs(child,color)
            color += 1 #同じ親から続く次の辺の色を変更する

    dfs(0,0)

    print(max(ans))
    for color in ans:
        print(color)


if __name__ == "__main__":
    main()


Measured memory_bytes: 88196
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Data.List

solve :: Integer -> [(Integer,Integer)] -> Integer
solve 0 _  = 0
solve _ [] = 0
solve m ((a,b):xs) = let c = min m b
                      in (c * a) + solve (m - c) xs

main :: IO ()
main = do
    [_,m] <- map read . words <$> getLine :: IO [Integer]
    ab <- sortOn fst . map ((\[a,b] -> (a,b)) . map (fst . fromJust . BS.readInteger) . BS.words) . BS.lines <$> BS.getContents
    print $ solve m ab


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


int abc(char a, char b, char c)
{
	if (a == b && b == c)
	{
		return 0;
	}
	else
	{
		if (a == b || b == c || c == a)
		{
			return 1;
		}
		else
		{
			return 2;
		}
	}
}
int main()
{
	int n;
	string a, b, c;
	cin >> n >> a >> b >> c;
	int ans = 0;
	int i = 0;
	while (n>i)
	{
		ans += abc(a[i], b[i], c[i]);
		i++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i,j,s,max,c[5],n;
  while(~scanf("%d",&n)){
    int c[15]={0};
    c[n]++;
    max=s=1;
    for(i=0;i<4;i++){
      scanf(",%d",&n);
      if(c[n]==0)s++;
      c[n]++;
      if(max<c[n])max=c[n];
    }
    if(max==4)printf("four card\n");
    if(max==3){
      if(s==2)printf("full house\n");
      else    printf("three card\n");
    }
    if(max==2){
      if(s==3)printf("two pair\n");
      if(s==4)printf("one pair\n");
    }
    if(max==1){
      if(c[2]==0){
	c[14]=c[1];
	c[1]=0;
      }
      for(i=s=0;c[i]==0;i++);
      for(j=0;j<5;j++)s+=c[i+j];
      if(s==5)printf("straight\n");
      else    printf("null\n");
    }
  }
  return 0;
}

Measured memory_bytes: 580
import numpy as np
MOD = 998244353

N,S = map(int,input().split())
A = list(map(int,input().split()))
coefs = np.array([0]*(S+1))
coefs[0] = 1

for i in range(N):
    tmp = coefs[:]
    coefs = coefs*2
    coefs[A[i]:] += tmp[:-A[i]]
    coefs%=MOD
    
print(coefs[-1])
    



Measured memory_bytes: 27304
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
using namespace std;
int main() {
	string s;
	cin >> s;
	if (s == "Sunny") {
		cout << "Cloudy" << endl;
		return 0;
	}
	else if (s == "Cloudy") {
		cout << "Rainy" << endl;
		return 0;
	}
	else if (s == "Rainy") {
		cout << "Sunny" << endl;
		return 0;
	}
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class MainClass
{
	static void Main(string[] args)
	{
		AnswerA();
	}
	public static void AnswerA()
	{
      var input = Console.ReadLine().Split(' ').Select(ulong.Parse).ToArray();
      ulong X = input[0];
      ulong Y = input[1];

      ulong cnt = 0;
      ulong tmp = X;
      ulong pretmp = X;
      do
      {
        cnt++;
        tmp *= 2;
      } while (tmp<=Y);
      Console.WriteLine(cnt.ToString());
	}
}

Measured memory_bytes: 13396
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String s[] = new String[n];
        String march = "MARCH";
        long[] d = new long[5];
        for(int i=0;i<n;i++){
            s[i] = scanner.next();
            for(int j=0;j<5;j++){
                if(s[i].charAt(0) == march.charAt(j)){
                    d[j]++;
                    break;
                }
            }
        }

        int[] x = {0,0,0,0,0,0,1,1,1,2};
        int[] y = {1,1,1,2,2,3,2,2,3,3};
        int[] z = {2,3,4,3,4,4,3,4,4,4};
        long allCount = 0;
        for(int i=0;i<10;i++){
            allCount += d[x[i]] * d[y[i]] * d[z[i]];
        }
        System.out.println(allCount);
    }

}


Measured memory_bytes: 62808
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll h, w, n,k=0,col=1;
	in(h);
	in(w);
	in(n);
	vll a(n);
	vector<vll> ans(h, vll(w));
	rep(i, 0, n) {
		in(a[i]);
	}

	rep(i, 0, h) {
		rep(j, 0, w) {
			k++;
			if (i % 2 == 0) {
				ans[i][j] = col;
			}
			else {
				ans[i][w - j - 1] = col;
			}
			if (k == a[col - 1]) {
				col++;
				k = 0;
			}
		}
		rep(j, 0, w) {
			outs(ans[i][j]);
		}
		outn("");
	}
	return 0;

}


Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author zhangyong
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n;
            n = in.nextInt();
            long[] arr = new long[n];
            long sum = 0;
            for (int i = 0; i < arr.length; i++) {
                arr[i] = in.nextLong();
                sum += arr[i];
            }
            long x = 0;
            long min = Long.MAX_VALUE;
            for (int i = 0; i < n - 1; i++) {
                x += arr[i];
                min = Math.min(min, Math.abs(sum - 2 * x));
            }
            out.println(min);
        }

    }
}



Measured memory_bytes: 64264
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;

int main()
{
	int n, k;
	
	map<char, int> point;
	char cant = 0;
	string str;
	int ans = 0;
	cin >> n >> k;
	cin >> point['s'];
	cin >> point['p'];
	cin >> point['r'];
	cin >> str;
	
	for (int i = 0; i < n; i++) {
		if (i >= k) {
			cant = str[i - k];
		}
		if (cant != str[i]) {
			//printf("%+d", point[str[i]]);
			ans += point[str[i]];
		} else {
			str[i] = 1;
		}
	}

	printf("%d", ans);

	return 0;
}



Measured memory_bytes: 512
import bisect,sys
import math
from collections import deque

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac =fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV
        
    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s+=a
        yield s


sys.setrecursionlimit(200005)


def main():
    X = iRaw()
    yakusus = []
    for x in range(1,int(math.sqrt(X))+1):
        if X%x ==0:
            yakusus.append(x)
    a = 1
    while True:
        a5 = a**5
        for y in yakusus:
            b = a -y
            b5 = b**5
            if a5-b5==X:
                return " ".join([str(a),str(b)])
        a+=1


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 68220
#include<stdio.h>
#include<iostream>
#include<vector>
#include <fstream>
#include<math.h>
#include <numeric>
#include<algorithm>

using namespace std;

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if ((a+b) == (c+d)){
        cout << "Balanced" << endl;
    }

    if ((a+b) < (c+d)){
        cout << "Right" << endl;
    }

    if ((a+b) > (c+d)){
        cout << "Left" << endl;
    }
}


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

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N; string s;
    cin >> N >> s;

    string t = s.substr(0, N / 2);
    cout << ((s == t + t) ? "Yes" : "No") << "\n";

    return 0;
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
#define MOD 1000000007

template<int mod>
struct ModInt{
	int x;
	ModInt():x(0){}
	ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){}
	ModInt &operator+=(const ModInt &p){
		if((x+=p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator-=(const ModInt &p){
		if((x+=mod-p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator*=(const ModInt &p){
		x=(int)(1LL*x*p.x%mod);
		return *this;
	}
	ModInt &operator/=(const ModInt &p){
		*this*=p.inverse();
		return *this;
	}
	ModInt &operator^=(long long p){
		ModInt res = 1;
		for (; p; p >>= 1) {
			if (p & 1) res *= *this;
			*this *= *this;
		}
		return *this = res;
	}
	ModInt operator-()const{return ModInt(-x);}
	ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
	ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
	ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
	ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
	ModInt operator^(long long p)const{return ModInt(*this)^=p;}
	bool operator==(const ModInt &p)const{return x==p.x;}
	bool operator!=(const ModInt &p)const{return x!=p.x;}
	explicit operator int() const { return x; }						   // added by QCFium
	ModInt operator=(const int p) {x = p; return ModInt(*this);} // added by QCFium
	ModInt inverse()const{
		int a=x,b=mod,u=1,v=0,t;
		while(b>0){
			t=a/b;
			a-=t*b;
			std::swap(a,b);
			u-=t*v;
			std::swap(u,v);
		}
		return ModInt(u);
	}
	friend std::ostream &operator<<(std::ostream &os,const ModInt<mod> &p){
		return os<<p.x;
	}
	friend std::istream &operator>>(std::istream &is,ModInt<mod> &a){
		long long x;
		is>>x;
		a=ModInt<mod>(x);
		return (is);
	}
};
typedef ModInt<MOD> mint;

struct MComb {
	std::vector<mint> fact;
	std::vector<mint> inversed;
	MComb(int n) { // O(n+log(mod))
		fact = std::vector<mint>(n+1,1);
		for (int i = 1; i <= n; i++) fact[i] = fact[i-1]*mint(i);
		inversed = std::vector<mint>(n+1);
		inversed[n] = fact[n] ^ (MOD-2);
		for (int i = n - 1; i >= 0; i--) inversed[i]=inversed[i+1]*mint(i+1);
	}
	mint ncr(int n, int r) {
		return (fact[n] * inversed[r] * inversed[n-r]);
	}
	mint npr(int n, int r) {
		return (fact[n] * inversed[n-r]);
	}
	mint nhr(int n, int r) {
		assert(n+r-1 < (int)fact.size());
		return ncr(n+r-1, r);
	}
};

int main() {
	int n = ri();
	int a[n];
	mint lcm = 1;
	for (auto &i : a) i = ri();
	int max[1000001];
	memset(max, 0, sizeof(max));
	for (int i = 0; i < n; i++) {
		int t = a[i];
		for (int j = 2; j * j <= t; j++) {
			int cnt = 0;
			while (t % j == 0) t /= j, cnt++;
			max[j] = std::max(max[j], cnt);
		}
		if (t > 1) max[t] = std::max(max[t], 1);
	}
	for (int i = 2; i <= 1000000; i++) lcm *= mint(i) ^ max[i];
	std::cerr << lcm << std::endl;
	mint res = 0;
	for (auto &i : a) res += lcm / i;
	std::cout << res << std::endl;
	return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <sstream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <stdio.h>

using namespace std;

#define fo(i,n) for(int i=0; i<(int)n; i++)
#define rep(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define pii pair<int,int>

int n;
vector<int> t[1010];
vector<int> vis;
int sum[1010];
int v[1445];
void update(int x) {
    for(;x<=1441; x+=x&-x) v[x]++;
}
int get(int x) {
    int s = 0;
    for (;x>=1; x-=x&-x) s+=v[x];
    return s;
}

int parse(string s) {
    string h = s.substr(0,2);
    string m = s.substr(3,2);
    return atoi(h.c_str())*60 + atoi(m.c_str());
}

int main() {

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    while (cin>>n && n!=0) {
        string s, last;
        cin>>last;
        s = last;
        for (int i=0; i<1000; i++) sum[i] = 0;
        for (int i=0; i<=n; i++) {
            if (i!=0 && i!=n) cin>>s;
            if (last!=s || i==0 || i==n) {

                if (i!=0) {
                    for (int j=0; j<t[0].size(); j+=2) {
                        for (int k=t[0][j]; k<t[0][j+1]; k++) update(k);
                    }
                    for (int j=1; j<1000; j++) {
                        for (int k=0; k<t[j].size(); k+=2) sum[j] += get(t[j][k+1]-1) - get(t[j][k]-1);
                    }
                }

                for (int j=0; j<1445; j++) v[j] = 0;
                for (int j=0; j<vis.size(); j++) t[vis[j]].clear();
                vis.clear();

                if (i==n) break;

                last = s;

            }
            string hour;
            cin>>hour;
            int tmp = parse(hour);
            cin>>hour;
            string id;
            cin>>id;
            vis.push_back(atoi(id.c_str()));
            t[atoi(id.c_str())].push_back(tmp);
        }

        int m = 0;
        for (int i=1; i<1000; i++) m = max(m, sum[i]);
        printf("%d\n",m);
    }

    return 0;

}

Measured memory_bytes: 1316