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

int main() {
  int N;
  cin >> N;
  vector<int> V(N), C(N);
  int ans = 0;
  for (int i=0; i<N; i++) {
    cin >> V[i];
  }
  for (int i=0; i<N; i++) {
    cin >> C[i];
  }
  for (int i=0; i<N; i++) {
    cin >> V[i] >> C[i];
    ans += max(0,V[i]-C[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		int N = S.length();
		int flag = 0;
		loop:for (int i=(int)'a';i<(int)'a'+26;i++) {
			char tmp=(char)150;
			for (int j=0;j<N;j++) {
				if (S.charAt(j)==(char)i) {
					if (tmp==(char)150) {
						tmp = T.charAt(j);
					} else {
						if (tmp!=T.charAt(j)) {
							System.out.println("No");
							flag = 1;
							break loop;
						}
					}
				}
			}
			tmp=(char)150;
			for (int j=0;j<N;j++) {
				if (T.charAt(j)==(char)i) {
					if (tmp==(char)150) {
						tmp = S.charAt(j);
					} else {
						if (tmp!=S.charAt(j)) {
							System.out.println("No");
							flag = 1;
							break loop;
						}
					}
				}
			}
		}
		if (flag==0) {
			System.out.println("Yes");
		}
	}
}

Measured memory_bytes: 28796
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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 main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M);
  vector<int> s;
  vector<int> g;

  rep(i, M) {
    cin >> a[i] >> b[i];
    if (a[i] == 1)
      s.pb(b[i]);
    if (b[i] == N)
      g.pb(a[i]);
  }
  sort(all(g));

  rep(i, s.size()) {
    if (binary_search(all(g), s[i])) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 2812
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
long long n;
long long f[400];
int main()
{
    scanf("%d",&n);
    f[0]=2;
    for(int i=0;i<=n;i++)
    f[i]=f[i-1]*2+2;
    cout<<f[n]<<endl;
    return 0;
}

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

using namespace std; 

int main() {

	int n; 

	scanf("%d", &n); 

	int gem[n], cost[n]; 

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

	}

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

	int maxProfit = 0; 

	for(int i = 0; i < n; i++) {
		int profit = gem[i] - cost[i]; 

		if(profit > 0) {
			maxProfit += profit; 
		}
	}

	cout << maxProfit << endl; 


	return 0; 
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            //ここから
            long[] num = IO.ReadLineToLongArray();
            long a = num[0];
            long b = num[1];
            long c = num[2];
            long d = num[3];
            long lcm = Func.LCM(c, d);

            long ans = b - a + 1 - (b / c - (a-1) / c + b / d - (a-1) / d - (b / lcm - (a-1) / lcm));
            //ここまで
            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }

    class Func
    {
        long mod = 1000000007;
        static public void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }
        static public long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }
        static public long LCM(long a, long b) { return (long)a * b / GCD(a, b); }
        static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); }
        static public int Conbin(int n, int m) { return Factorial(n) / (Factorial(n - m) * Factorial(m)); }
        static public void Factoring(long num, ref long[] vs)
        {
            if (num == 1)
            {
                vs[1]++;
            }
            for (long i = 2; i < (long)Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    vs[i]++;
                    Factoring(num / i, ref vs);
                }
            }
            vs[1]++;
        }
    }

    class IO
    {
        static public string ReadLineToString() { return Console.ReadLine(); }
        static public int ReadLineToInt() { return int.Parse(Console.ReadLine()); }
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public string[] ReadLineToStringArray() { return Console.ReadLine().Split(' ').ToArray(); }
        static public int[] ReadLineToIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] ReadLineToLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<string> ReadLineToStringList() { return Console.ReadLine().Split(' ').ToList(); }
        static public List<int> ReadLineToIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
    }
}

Measured memory_bytes: 13396
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0
int dc=100000;
#define MAX 100010


int main(){
  if(df)printf("*** debug mode ***\n");
  int a;
  scanf("%d",&a);
  char s[30000];scanf(" %s",s);

  printf("%s",(a>=3200)?s:"red");
  return 0;
}


/// confirm df==0 ///

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

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

  int size = S.length();
  vector<int> vi(size + 1);
  for (int i = 0; i < size; i++) {
    if (S[i] == '<') {
      vi[i + 1] = vi[i] + 1;
    }
  }

  reverse(vi.begin(), vi.end());
  for (int i = 0; i < size; i++) {
    if (S[size - (i + 1)] == '>') {
      if (vi[i] >= vi[i + 1]) {
        vi[i + 1] = vi[i] + 1;
      }
    }
  }

  long long res = 0;
  for (int i = 0; i < vi.size(); i++) {
    res += vi[i];
  }
  cout << res << '\n';
}


Measured memory_bytes: 2844
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;

int main() {
  ll h, w;
  cin >> h >> w;
  if (min(h, w) == 1) {
	  cout << 1 << endl;
	} else {
	  cout << (h * w + 1) / 2 << endl;
	}

  return 0;
}


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

const int H = 111;
const int W = 111;
const int MAXT = 1111;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,1,0,-1};

int sx, sy, T;
int G[H][W];
int record[MAXT];
bool vis[2][H][W][4];

void show(int w, int h) {
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cout << G[i][j];
    }
    cout << endl;
  }
}

int main() {
  while (1) {
    { // input
      int n, t;
      if (cin >> n >> sx >> sy >> t); else break;
      ++sx; ++sy;
      sx *= 2; sy *= 2;
      memset(G, 0, sizeof(G));
      while (n--) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        ++a; ++b; ++c; ++d;
        a *= 2; b *= 2; c *= 2; d *= 2;
        for (int y = min(b, d); a == c && y <= max(b, d); ++y)
          G[y][a] += 1;
        for (int x = min(a, c); b == d && x <= max(a, c); ++x)
          G[b][x] += 1;
      }
      memset(record, -1, sizeof(record));
      T = 0;
      for (int i = 0; i < t; ++i) {
        int d, dir;
        char c;
        cin >> d >> c;
        T += d;
        if (c == 'E') dir = 0;
        if (c == 'N') dir = 1;
        if (c == 'W') dir = 2;
        if (c == 'S') dir = 3;
        record[T] = dir;
      }
    }

    memset(vis, 0, sizeof(vis));
    for (int i = 0; i < 4; ++i) 
      vis[0][sy][sx][i] = true;

    for (int i = 0; i < T; ++i) {
      const int now = i & 1;
      const int next = 1 - now;
      memset(vis[next], 0, sizeof(vis[next]));
      for (int y = 0; y < H; ++y) {
        for (int x = 0; x < W; ++x) {
          for (int nd = 0; nd < 4; ++nd) {
            if (!vis[now][y][x][nd]) continue;
            int nx = x, ny = y;
            nx += dx[nd];
            ny += dy[nd];
            if (!G[ny][nx]) continue;
            nx += dx[nd];
            ny += dy[nd];
            if (!G[ny][nx]) continue;
            for (int nnd = 0; nnd < 4; ++nnd) {
              if ((nnd + 2) % 4 == nd) continue;
              if (record[i+1] != -1 &&
                  nd != record[i+1] &&
                  nnd != record[i+1]) continue;
              int nnx = nx;
              int nny = ny;
              nnx += dx[nnd];
              nny += dy[nnd];
              if (!G[nny][nnx]) continue;
              nnx += dx[nnd];
              nny += dy[nnd];
              if (!G[nny][nnx]) continue;
              vis[next][ny][nx][nnd] = true;
            }
          }
        }
      }
    }

    for (int x = 0; x < W; ++x) {
      for (int y = 0; y < H; ++y) {
        bool ok = false;
        for (int nd = 0; nd < 4; ++nd) {
          if (vis[T&1][y][x][nd]) ok = true;
        }
        if (ok) {
          cout << x/2-1 << " " << y/2-1 << endl;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1324
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int         long long   
#define double      long double
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
#define f(i,n)      for(int i=0;i<n;i++)
#define fastio      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)      (v).begin(),(v).end()
#define rall(v)     (v).rbegin(),(v).rend()
#define gcd(a,b)    __gcd((a),(b))
#define fill(a,value) memset(a,value,sizeof(a));
#define minn(v)     *min_element(v.begin(), v.end());
#define maxx(v)     *max_element(v.begin(), v.end());
#define print(x)    cout<<(x)<<endl;
#define sum(v)+x    accumulate(v.begin(), v.end(),x);
typedef pair<int,int> pii;  
typedef vector<int> vi;
signed main() 
{
    fastio;
    cout << fixed << setprecision(12);
    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<string> v;
    for(int i=0;i<=9;i++)
    {
        for(int j=0;j<=9;j++)
        {
            for(int k=0;k<=9;k++)
            {
                string t="";
                t+=to_string(i);
                t+=to_string(j);
                t+=to_string(k);
                v.pb(t);
                
            }
        }
    }
    int ans=0;
    for(auto x:v)
    {
        int j=0;
        for(int i=0;i<n;i++)
        {
            if(s[i]==x[j])
            {
                j+=1;
            }
            if(j==3)
            {
                ans++;
                break;
            }
        }
    }
    print(ans)
    return 0;
}

Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
# define pb push_back
# define FOR(i,a,n) for(int i=a;i<n;i++)
# define mp make_pair
# define RFOR(i,a,n) for(int i=n;i>a;i--)
# define pii pair<long long int,long long int>
#define ub upper_bound
#define lb lower_bound
#define MOD 1000000007
typedef long long int ll;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
        cout.tie(0);
	
	string str;
	cin>>str;
	ll k;
	k=str[str.size()-1]-'0';
	if(k==2||k==4||k==5||k==7||k==9)
	cout<<"hon"<<endl;
	else if(k==0||k==1||k==6||k==8)
	cout<<"pon"<<endl;
	else
	cout<<"bon"<<endl;
	
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  vector<char> vec(12);
  rep(i,12){
    cin >> vec[i];
  }
  rep(i,4){
    cout << vec[i];
  }
  cout << " ";
  FOR(i,4,12){
    cout << vec[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  string S;
  long long K;
  cin >> S >> K;
  char ans{'1'};
  for (int i = 0; i != K; ++i) {
    if (S[i] != ans) {
      ans = S[i];
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define mod 1000000007
#define inf 1e18+9
#define fr first
#define sc second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pll pair<ll,ll>
#define vll vector<ll>
#define umap unordered_map<ll,ll>
#define lpq priority_queue<ll,vector<ll>,greater<ll>>
ll globe=0;
ll powe(ll n,ll r){if(!r)return 1;else if(r%2==0)return powe(n*n,r/2);else return n*powe(n*n,(r-1)/2);}
 
int32_t main(){
 
	ios::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
 
	ll t=1;
	//cin>>t;
	while(t--){
	    ll n,u=0;
	    cin>>n;
	    vll a(n);
	    vector<ll> ump(200001,0);
	    vector<ll> h(200001,0);
	    for(ll i=0;i<n;i++){
	        cin>>a[i];
	        if(ump[a[i]]==0)
	            u++;
	        ump[a[i]]++;
	    }
	    vll b=a;
	    sort(b.begin(),b.end());
	    b.erase(unique(b.begin(),b.end()),b.end());
	    ll sm=0;
	    for(ll i=0;i<b.size();i++){
	        sm+=((ump[b[i]]*(ump[b[i]]-1))/2);
	    }
	    for(ll i=0;i<b.size();i++){
	        ll k=sm;
	        k-=((ump[b[i]]*(ump[b[i]]-1))/2);
	        ump[b[i]]--;
	        k+=((ump[b[i]]*(ump[b[i]]-1))/2);
	        h[b[i]]=k;
	    }
	    for(ll i=0;i<n;i++){
	        cout<<h[a[i]]<<endl;
	    }
	}
 
	return 0;
 
}
//BitMasking->setBit: n|(1<<i); unsetBit: n&!(1<<i); checkBit: n&(1<<i);
//ll idx=upper_bound(v.begin(),v.end(),val)-v.begin();
//v.erase(unique(v.begin(),v.end()),v.end());
//ll cnt=count(v.begin(),v.end(),val);
//bool f=find(v.begin(),v.end(),val);

Measured memory_bytes: 8832
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    set<int> st;
    rep(i, N) {
        if(st.count(A[i])) {
            cout << "NO" << endl;
            return 0;
        }
        st.insert(A[i]);
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 10368
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

ll N, A;
ll X[50];
ll ans = 0;

ll dp[55][55][2600];

void solve(ll idx, ll num, ll sum){
    // not use idx-th card
    dp[idx + 1][num][sum] += dp[idx][num][sum];

    // use idx-th card
    ll tmp = dp[idx][num][sum];
    num++;
    sum += X[idx];
    if(num * A == sum)ans += tmp;
    dp[idx + 1][num][sum] += tmp;
}

int main(){
    
    dp[0][0][0] = 1;
    
    cin >> N >> A;
    rep(i, N)cin >> X[i];
    rep(idx, N)rep(num, N)rep(sum, 2500)solve(idx, num, sum);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 56448
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll n,k;cin>>n>>k;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];a[i]--;
    }

    ll p=0;
    while(k){
        vector<int> b(n);
        if(k%2==1){
            p=a[p];
        }
        rep(i,n){
            b[i]=a[a[i]];
        }
        swap(a,b);
        k/=2;
    }
    cout<<p+1<<endl;
    return 0;
}


Measured memory_bytes: 4784
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

int main() {

    int a, b;
    cin >> a >> b ;

    vector<int> v(3);

    v[0] = a + b;
    v[1] = a - b;
    v[2] = a * b;


    int ans =  *max_element(v.begin(), v.end());
    cout << ans << '\n';

}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  char c; cin >> c;
  cout << (isupper(c) ? "A\n" : "a\n");
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;
template <typename T>
T sq(T x){
  return x * x;
}

signed main (){
  int H,W,N;
  cin >> H >> W >> N;
  if(H >= W){
    rep(i,W+1){
      if(i * H >=N){
        cout << i << endl;
        return 0;
      }
    }

  }else{
    rep(i,H+1){
      if (i * W >= N) {
        cout << i << endl;
        return 0;
      }
    }
  }
  return 0;
}


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

#define LL long long
#define RG register

using namespace std;
template<class T> inline void read(T &x) {
	x = 0; RG char c = getchar(); bool f = 0;
	while (c != '-' && (c < '0' || c > '9')) c = getchar(); if (c == '-') c = getchar(), f = 1;
	while (c >= '0' && c <= '9') x = x*10+c-48, c = getchar();
	x = f ? -x : x;
	return ;
}
template<class T> inline void write(T x) {
	if (!x) {putchar(48);return ;}
	if (x < 0) x = -x, putchar('-');
	int len = -1, z[20]; while (x > 0) z[++len] = x%10, x /= 10;
	for (RG int i = len; i >= 0; i--) putchar(z[i]+48);return ;
}
const int N = 1e5 + 10, inf = 1e9;
int a[N][2];
pair<int, int> b[N];
struct Edge {
	int to, nxt;
} g[2000010];
int lst[N], gl, cnt, tim, scc, n, dfn[N], low[N];
void add(int x, int y) { g[++gl] = (Edge) {y, lst[x]}; lst[x] = gl; }
void clear() {
	memset(lst, 0, sizeof(lst)); gl = 0;
	cnt = n << 1; tim = 0; scc = 0;
	memset(dfn, 0, sizeof(dfn));
}
#define lson (o << 1)
#define rson (o << 1 | 1)
int id[N], bel[N];
int build(int o, int l, int r) {
	if (l == r) return id[o] = b[l].second;
	int mid = (l + r) >> 1;
	id[o] = ++cnt; add(id[o], build(lson, l, mid)); add(id[o], build(rson, mid + 1, r));
	return id[o];
}
void link(int o, int l, int r, int L, int R, int p) {
	if (L <= l && r <= R) return add(p, id[o]);
	int mid = (l + r) >> 1;
	if (L <= mid) link(lson, l, mid, L, R, p);
	if (R > mid) link(rson, mid + 1, r, L, R, p);
}
bool in[N];
stack<int> stk;
void tarjan(int u) {
	dfn[u] = low[u] = ++tim;
	in[u] = 1; stk.push(u);
	for (int i = lst[u]; i; i = g[i].nxt) {
		int v = g[i].to;
		if (!dfn[v]) tarjan(v), low[u] = min(low[u], low[v]);
		else if (in[v]) low[u] = min(low[u], dfn[v]);
	}
	if (low[u] == dfn[u]) {
		scc++;
		while (in[u]) {
			bel[stk.top()] = scc;
			in[stk.top()] = 0; stk.pop();
		}
	}
	return ;
}
bool check(int d) {
	clear();
	build(1, 1, n * 2);
	for (int i = 1; i <= n; i++)
		for (int j = 0; j < 2; j++) {
			int l = lower_bound(b + 1, b + 1 + 2 * n, make_pair(a[i][j] - d + 1, -inf)) - b;
			int r = upper_bound(b + 1, b + 1 + 2 * n, make_pair(a[i][j] + d - 1, inf)) - b - 1;
			int x = lower_bound(b + 1, b + 1 + 2 * n, make_pair(a[i][j], (j ^ 1) * n + i)) - b;
			if (l < x) link(1, 1, 2 * n, l, x - 1, j * n + i);
			if (x < r) link(1, 1, 2 * n, x + 1, r, j * n + i);
		}
	for (int i = 1; i <= cnt; i++)
		if (!dfn[i]) tarjan(i);
	for (int i = 1; i <= n; i++)
		if (bel[i] == bel[n + i]) return 0;
	return 1;
}
int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	read(n);
	for (int i = 1; i <= n; i++) read(a[i][0]), read(a[i][1]);
	for (int i = 1; i <= n; i++) {
		b[2 * i - 1] = make_pair(a[i][0], i + n);
		b[2 * i] = make_pair(a[i][1], i);
	}
	sort(b + 1, b + 1 + 2 * n);
	int l = 0, r = 1e9;
	while (l <= r) {
		int mid = l + ((r - l) >> 1);
		if (check(mid)) l = mid + 1;
		else r = mid - 1;
	}
	printf("%d\n", l - 1);
	return 0;
}


Measured memory_bytes: 13440
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define ll  long long
#define endl '\n'
#define pi 3.14159265
//seen soln
int main()
{       
    IOS;
    ll n;
    cin>>n;
    vector<ll> v(n+1);
    for(ll i=1;i<=n;i++)
    	cin>>v[i];
    ll ans=0;
    for(ll i=1;i<n;i++)
    {
    	ans+=v[i]/2;
    	if(v[i]%2)
    	{
    		if(v[i+1]>0)
    		{
    			ans++;
    			v[i+1]--;
    			v[i]=0;
    		}
    	}
    }
    ans+=v[n]/2;
    cout<<ans;
}   

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int a, b, c;
    int k;
    cin >> a >> b >> c;
    cin >> k;
    if (max(a, max(b, c)) == a) {
        cout << a * pow(2, k) + b + c << endl;
    }
    else if (max(a, max(b, c)) == b) {
        cout << b * pow(2, k) + a + c << endl;
    }
    else {
        cout << c * pow(2, k) + a + b << endl;
    }
}

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

int main() {
  int a, p;
  cin >> a >> p;
  
  int ans = (a * 3 + p) / 2;
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
/*
Hanit Banga
*/

#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <map>
#include <set>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false)

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

const int N = 5e3 + 5;

bool f[N][N] = {0}, g[N][N] = {0};
int a[N];

int main()
{
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];

	sort(a + 1, a + n + 1);
	int ans = n;
	for (int i = 1; i <= n; ++i)
	{
		if (a[i] >= k)
		{
			n = i - 1;
			ans = n;
			break;
		}
	}	

	for (int i = 0; i <= n + 1; ++i)
		f[i][0] = g[i][0] = true;

	for (int j = 1; j < k; ++j)
	{
		for (int i = 1; i <= n; ++i)
		{
			f[i][j] = f[i - 1][j];
			if (j >= a[i])
				f[i][j] |= f[i - 1][j - a[i]];
		}

		for (int i = n; i >= 1; --i)
		{
			g[i][j] = g[i + 1][j];
			if (j >= a[i])
				g[i][j] |= g[i + 1][j - a[i]];
		}
	}

	for (int i = 1; i <= n; ++i)
	{
		int l = k - 1, x = 0;
		while (l >= 0 and !f[i - 1][l])
			--l;

		x = max(x, l);
		for (int r = 1; r < k; ++r)
		{
			if (!g[i + 1][r])
				continue;

			while (l >= 0 and l + r >= k and !f[i - 1][l])
				--l;

			x = max(x, l + r);
		}

		// cout << a[i] << ' ' << x << endl;
		if (x >= k - a[i])
		{
			--ans;
			// cout << a[i] << endl;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 49152
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<queue>
#include<map>
#define int long long

using namespace std;

int read()
{
	int ans=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}

int n,d,ans;

signed main()
{
	n=read();d=read();
	for(int i=1;i<=n;++i)
	{
		int a=read(),b=read();
		if(sqrt(a*a+b*b)<=d)
			ans++;
	}
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 3736
#include<bits/stdc++.h>
            using namespace std;
            #define int long long


            int32_t main()
            {
         
         
                #ifndef ONLINE_JUDGE
                freopen("input.txt", "r", stdin);
                freopen("output.txt", "w", stdout);
                #endif
         
                ios_base::sync_with_stdio(false);
                cin.tie(NULL);
         

                int r;
                cin>>r;

                cout<<fixed<<setprecision(4)<<2*M_PI*r;               



            }

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

int main() {

	string s; cin >> s;
	string ans;
	if (s[0] == '9' || s[1] == '9') ans = "Yes";
	else ans = "No";	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3616
import math

N, K = map(int, input().split())
mod = 1000000007


def nCr(n: int, r: int):
    if n == r:
        return 1
    if r > n:
        return 0
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))


for i in range(1, K+1):
    print(nCr(N-K+1, i) * nCr(K-1, i-1) % mod if N-K+1 >= i else 0)


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#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(ALL((c)))
#define RSORT(c) sort(RALL((c)))

#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;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


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

  int a, b, c;
  cin >> a >> b >> c;
  cout << (b-a==c-b? "YES":"NO")<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
using namespace std;

typedef long long ll;

#define MOD 1000000007
#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

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

    p((n - 1) * (m - 1));
}

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

int main(){

  while(1){
    int x, y;
    cin>>x>>y;
    if(x == 0 && y == 0) break;

    if(x > y) swap(x, y);
    cout<<x<<" "<<y<<endl;
  }

  return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>

typedef long long ll;
using namespace std;

struct RSQ{
  //Ranged Sum Query

  int n;
  vector<int> node;
  //1-indexed

  RSQ(int size){
    int t=1;
    while(t<size){
      t*=2;
    }

    node.clear();
    node.resize(t*2,0);
    n=t;
  }

  void add(int i,int val){
    i=i+n;
    while(i>0){
      node[i]+=val;
      i/=2;
    }
  }

  int getSum(int s,int t,int k=1,int left=0,int right=-1){
    if(right<0)right=n;

    if(right<=s||left>=t){
      return 0;
    }

    if(left>=s&&right<=t){
      return node[k];
    }

    return getSum(s,t,k*2,left,(left+right)/2)+getSum(s,t,k*2+1,(left+right)/2,right);
  }
};

int main(void){
  int n,q,c,x,y,i;
  cin>>n>>q;

  RSQ tree(n);

  for(i=0;i<q;i++){
    scanf("%d %d %d",&c,&x,&y);
    //cin>>c>>x>>y;
    x--;
    if(c==0){
      tree.add(x,y);
    }
    else{
      printf("%d\n",tree.getSum(x,y));
    }
  }

  return 0;
}



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

using ll = long long;
#define int long long
using P = pair<int, int>;

#define LOG(variable) cerr << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cerr << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
template<typename T = int>
T in() {T a; cin >> a; return a;}
int CountSub(string s, string sub) {
  int counter = 0;
  auto pos = s.find(sub);
  while(pos != string::npos) {
    ++counter;
    pos = s.find(sub, pos+sub.size());
  }
  return counter;
}
/***** MAIN *****/
signed main() {
  string s; cin >> s;
  if(s == "RRR") {
    cout << 3 << endl;
    return 0;
  }
  int counter = CountSub(s, "RR");
  if(counter == 1) {
    cout << 2 << endl;
    return 0;
  }
  counter = CountSub(s, "R");
  if(counter) {
    cout << 1;
  } else {
    cout << 0;
  }
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 3624
n = int(input())
a = tuple(map(int,input().split()))
b = tuple(map(int,input().split()))
l = tuple(x+1 for x in range(n))
c,d = 0,0
cnt = 0
from itertools import permutations
for k in permutations(l):
    cnt += 1
    if a ==k:
        c = cnt
    if b ==k:
        d = cnt
print(abs(c-d))


Measured memory_bytes: 3188
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int i,j,h,w;
    while(1){
        scanf("%d %d\n",&h,&w);
        
        if(h == 0 && w == 0){
            break;
        }
        else{
            for(i=1;i<=h;i++){
                for(j=1;j<=w;j++){
                    if(i % 2 == 1){
                        if(j % 2 == 1){
                            printf("#");
                        }else{
                            printf(".");
                        }
                    }else{
                        if(j % 2 == 1){
                            printf(".");
                        }else{
                            printf("#");
                        }
                    }
                }
                printf("\n");
            }
            printf("\n");
        }
    }
    return 0;
}



Measured memory_bytes: 2024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
#include <cstdlib>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    cout << (a - 1) * (b - 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int a[100005],b[100005],c[100005];

struct hmm
{
    long long u,d;
};
hmm x[100005];


int main()
{

    scanf("%d",&n);
    int i;
    for(i=0; i<n; i++)
        scanf("%d",&a[i]);
    for(i=0; i<n; i++)
        scanf("%d",&b[i]);
    for(i=0; i<n; i++)
        scanf("%d",&c[i]);
    sort(a,a+n);
    sort(b,b+n);
    sort(c,c+n);

    int ind;
    for(i=0; i<n; i++)
    {
        if(a[n-1]>=b[i])
            ind  = upper_bound(a,a+n,b[i]-1)-a;
        else ind = n-1;
        while(a[ind]>=b[i])
            ind--;

      //  cout<<ind<<" ";
        x[i].u = ind+1;

        if(c[n-1]>=b[i])
            ind  = upper_bound(c,c+n,b[i])-c;
        else ind = n;
        x[i].d = n-ind;

       // cout<<ind<<endl;





    }
    long long ans=0;

    for(i=0; i<n; i++)
    {
        //cout<<x[i].u<<" "<<x[i].d<<endl;

        ans+= (x[i].u*x[i].d);
    }
    printf("%lld\n",ans);


}





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

int main()
{
    int a,b,c,k;
    scanf("%d%d%d%d",&a,&b,&c,&k);
    if(k<a)printf("%d",k);
    else if(k<a+b) printf("%d",a);
    else printf("%d",a-(k-a-b));
}


Measured memory_bytes: 3828
n = int(input())
red = []
for i in range(n):
    red.append(list(map(int, input().split())))
blue = []
for i in range(n):
    blue.append(list(map(int, input().split())))
red_sort = sorted(red, key=lambda x: x[1], reverse=True)
blue_sort = sorted(blue)
count = 0
flag = [0]*n
for b in blue_sort:
    for i,r in enumerate(red_sort):
        if r[0] < b[0] and r[1] < b[1] and flag[i] == 0:
            count += 1
            flag[i] = 1
            break
print(count)

Measured memory_bytes: 3064
import java.io.{BufferedReader, InputStream, InputStreamReader}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}

object Main {
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N = sc.nextInt()
    val W = sc.nextInt()
    val w = Array.ofDim[Int](N + 1)
    val v = Array.ofDim[Int](N + 1)
    val w1 = sc.nextInt()
    v(1) = sc.nextInt()
    (2 to N) foreach { i =>
      w(i) = sc.nextInt() - w1
      v(i) = sc.nextInt()
    }

    val dp = Array.ofDim[Int](N + 1, 301 * 100 + 300 + 1)
    for {
      i <- 1 to N
      j <- 0 to 3 * i
      jj <- 0 to i
    } {
      val k = jj * 301 + j
      val pre_v = k - w(i) - 301
      dp(i)(k) =
        if (pre_v >= 0) max(dp(i - 1)(pre_v) + v(i), dp(i -1)(k))
        else dp(i -1)(k)
    }
    val (ans, _) = (dp(N).zipWithIndex filter { case (_, k) =>
      k % 301 + (k / 301).toLong * w1 <= W
    }).maxBy(_._1)
    println(ans)
  }

  def main(args: Array[String]): Unit = {
    solve()
  }



  private class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

}


Measured memory_bytes: 42796
/* be name Khoda */
// VJUDGE
#include <bits/stdc++.h>
using namespace std;

const int N = 1100, MOD = 1e9 + 7;
int ax[] = {0, -1},
	ay[] = {-1, 0};
int dp[N][N], n, m;
char c[N][N];

int _sum(int a, int b) {
	return (a + b) % MOD;
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			cin >> c[i][j];
	dp[0][0] = 1;
	for (int i = 0; i < n; i++)
		for (int j = (i == 0); j < m; j++) {
			if (c[i][j] == '.') {
				int x1 = i - 1,
					y1 = j,
					x2 = i,
					y2 = j - 1;
				if (x1 >= 0)
					dp[i][j] = _sum(dp[i][j], dp[x1][y1]);
				if (y2 >= 0)
					dp[i][j] = _sum(dp[i][j], dp[x2][y2]);
			}
//			cout << i << "  " << j << " ==> " << dp[i][j] << endl;
		}
	cout << dp[n - 1][m - 1] << endl;
}
		

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);

  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int sum = 0;
  rep(i, n) sum += a.at(i);
  if (a.at(m-1) < sum / (4.0 * m)) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto N = RD;
	auto AB = new long[][](N);
	foreach (i; 0..N)
	{
		AB[i] = [RD, RD];
	}

	AB.sort!"a[0] < b[0]"();
	long x;
	if (N % 2)
	{
		x = AB[$/2][0];
	}
	else
	{
		x = AB[$/2-1][0] + AB[$/2][0];
	}

	AB.sort!"a[1] < b[1]"();
	long y;
	if (N % 2)
	{
		y = AB[$/2][1];
	}
	else
	{
		y = AB[$/2-1][1] + AB[$/2][1];
	}

	auto ans = y-x+1;
	writeln(ans);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 24780
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,i,j,a[3],x,y,z;
	cin>>n;
	for(i=0;i<n;i++){
		for(j=0;j<3;j++){
	cin>>a[j];
		}
		sort(a,a+3);
	x=a[2]*a[2];
	y=a[1]*a[1];
	z=a[0]*a[0];
		if(x==(y+z)){
		cout<<"YES"<<endl;
		}
		else{
		cout<<"NO"<<endl;
		}
	}
return 0;
}


Measured memory_bytes: 3164
#include<stdio.h>                                                               
#include<string.h>
#include<stdlib.h>

int main(void){
    char str[3];
    scanf("%s",str);

    if(strcmp(str,"AAA")==0 || strcmp(str,"BBB")==0){
        printf("No\n");
    }else{
        printf("Yes\n");
    }   


    return 0;
}

Measured memory_bytes: 128
n = input()

dp = [[0] * 2 for _ in range(2)]

digit = int(n[-1])

dp[0][0] = 10 - digit
dp[0][1] = digit

for i in range(1, len(n) + 1):
    if i == len(n):
        digit = 0
    else:
        digit = int(n[-i-1])

    if i % 2 == 0:
        dp[0][0] = min(dp[1][0] + 10 - digit - 1, dp[1][1] + 10 - digit)
        dp[0][1] = min(dp[1][0] + digit + 1, dp[1][1] + digit)
    else:
        dp[1][0] = min(dp[0][0] + 10 - digit - 1, dp[0][1] + 10 - digit)
        dp[1][1] = min(dp[0][0] + digit + 1, dp[0][1] + digit)


print(min(dp[0][1], dp[1][1]))


Measured memory_bytes: 5492
n = int(input())

a = [0] * n

a = list(map(int, input().split()))

sum = 1
cnt = 0
if 0 in a:
    print(0)
else:
    for i in a:
        sum *= i
        if sum > 1000000000000000000:
            print(-1)
            cnt = 1
            break
    if cnt == 0:
        print(sum)


Measured memory_bytes: 85428
n = int(input())
ct, cx, cy = 0, 0, 0 
for i in range(n):
    t, x, y = map(int, input().split())
    if abs(ct-t) < abs(cx-x) + abs(cy-y) or (abs(ct-t) + abs(cx-x) + abs(cy - y)) % 2 != 0:
        print('No')
        break
    else:
        ct = t 
        cx = x
        cy = y
else:
    print('Yes')

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

int main()
{
  int K, T;
  cin >> K >> T;

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

  sort(a, a+T);

  // for (int i = 0; i < T; i++) {
  //   cout << a[i] << ' ';
  // } cout << endl;

  int min_day;
  min_day = max(a[T-1] - 1 - (K - a[T-1]),0);

  cout << min_day << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>

using namespace std;
using ll = long long;

static const ll INF = 1e+18;

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

    vector<ll> s(A);
    for (auto&& si : s) {
        cin >> si;
    }

    s.insert(s.begin(), -INF);
    s.insert(s.end(), +INF);

    vector<ll> t(B);
    for (auto&& ti : t) {
        cin >> ti;
    }

    t.insert(t.begin(), -INF);
    t.insert(t.end(), +INF);

    for (int i = 0; i < Q; ++i) {
        ll xi;
        cin >> xi;

        auto it_s = lower_bound(s.begin(), s.end(), xi);
        ll s_a = *it_s;
        ll s_b = *(it_s-1);

        auto it_t = lower_bound(t.begin(), t.end(), xi);
        ll t_a = *it_t;
        ll t_b = *(it_t-1);

        ll ans = INF;

        for(auto&& sj : { s_a, s_b }) {
            for(auto&& tj : { t_a, t_b }) {
                ll len = min(abs(sj - xi), abs(tj - xi)) + abs(sj - tj);
                ans = min(len ,ans);
            }
        }

        std::cout << ans << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3696
#include "bits/stdc++.h"
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    cout << (c%gcd(a,b)==0?"YES":"NO") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

vector<int> res;
bool bfs(vector<int> B, vector<int> C) {
  vector<bool> done(B.size(), false);
  for(int n=0; n<B.size(); n++) {
    // for(int i=0; i<C.size(); i++)
    //   cout << C[i] << ' ';
    // cout << endl;

    for(int i=B.size()-1; i>=0; i--) {
      if(!done[i]) {
	if(C[i] > 0) {
	  C[i]--;
	} else if(C[i] == 0) {
	  res.push_back(B[i]);
	  // cout << i+1 << ' ' << B[i] << endl;
	  done[i] = true;
	  break;
	} else {
	  return false;
	}
      }
    }
  }

  for(int i=0; i<C.size(); i++) {
    if(!done[i])
      return false;
  }
  return true;
}

int main(){
  int N;
  cin >> N;
  vector<int> B(N), C(N);
  for(int i=0; i<N; i++) {
    cin >> B[i];
    C[i] = (i+1) - B[i];
  }

  if(bfs(B, C)) {
    for(int i=res.size()-1; i>=0; i--)
      cout << res[i] << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}


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

int kewa(int nm) {
	int kt = 0;
	while(nm > 0)
	{
		kt += nm % 10;
		nm /= 10;
	}
	return kt;
}

int main() {
	int N,a,b;
	cin >> N >> a >> b;
	int cnt = 0;
	for(int i = 1 ;i <= N;i++)
	{
		int kt = kewa(i);
		if(kt <= b && kt >= a)
		{
			cnt += i;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;
const int maxv=2*(100+10);
int N,M,E;
vector<int> g[maxv];
int vis[maxv];
int match[maxv];
void add_edge(int from,int to)
{
    g[from].push_back(to);
    g[to].push_back(from);
}
bool dfs(int t)
{
    vis[t]=1;
    for(int i=0;i<g[t].size();i++)
    {
        int v=g[t][i],w=match[v];
        if(w<0||(!vis[w]&&dfs(w)))
        {
            match[t]=v;
            match[v]=t;
            return true;
        }
    }
    return false;
}
void binrary_match()
{
    memset(match,-1,sizeof(match));
    int res=0;
    for(int i=0;i<N+M;i++)
    {
        if(match[i]<0)
        {
            memset(vis,0,sizeof(vis));
            if(dfs(i)) res++;
        }
    }
    printf("%d\n",res);
}
int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d%d%d",&N,&M,&E);
    int u,v;
    for(int i=0;i<E;i++)
    {
        scanf("%d%d",&u,&v);
        add_edge(u,N+v);
    }
    binrary_match();
    return 0;
}

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

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

	int a_count = 0;
	for (int i = 0; i < a; i++) {
		if ('0' <= s[i] && s[i] <= '9') a_count++;
	}

	int b_count = 0;
	for (int i = a + 1; i < a+b+1; i++) {
		if ('0' <= s[i] && s[i] <= '9') b_count++;
	}

	if (s[a] == '-' && a_count == a && b_count == b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll power(ll x, ll y,  ll p) 
{ 
    ll res = 1;      
    x = x % p;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;x = (x*x) % p; 
    } return res%p; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
ll prime[1000005]; 
void SieveOfEratosthenes(int n) 
{     
    for (int i = 1; i <=n; ++i)
    {
        prime[i]=i;
    }
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p]==p) 
        { 
            for (int i=p*p; i<=n; i += p) 
            {
                if(prime[i]==i)
                    prime[i] = p; 
            }
        } 
    } 
} 
ll pr[1000002];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    SieveOfEratosthenes(1000000);
    std::vector<ll> v(n);
    ll gc=0;
    ll mini=1e6;
    for (int i = 0; i < n; ++i)
    {
        cin>>v[i];
        gc=__gcd(gc,v[i]);
        mini=min(mini,v[i]);
    }
    if(gc!=1)
    {
        cout<<"not coprime"<<'\n';
        return 0;
    }
    ll fl=0;
    for (int i = 0; i < n; ++i)
    {
        ll xx=v[i];
        while(xx!=1)
        {
            ll p=prime[xx];
            if(pr[p]!=i+1 && pr[p]!=0)
            {
                fl=1;
            }
            pr[p]=i+1;
            xx=xx/p;
        }
    }
    if(fl)
    {
        cout<<"setwise coprime\n";
    }
    else
    {
        cout<<"pairwise coprime"<<'\n';
    }
}


Measured memory_bytes: 26624