akhauriyash/Code-Regression huggingface dataset:
n=int(input())
xl=[list(map(int,input().split())) for _ in range(n)]
xl.sort(key=lambda x: x[0])
cnt=0
nx,nl=xl[0]
for i in range(1,n):
  x,l=xl[i]
  if nx+nl<=x-l:
    nx=x
    nl=l
  else:
    cnt+=1
    if nx+nl>=x+l:
      nx=x
      nl=l
print(n-cnt)

Measured memory_bytes: 29096
def solve():
    n = int(input())

    W = []
    for i in range(n):
        tmp = list(input())
        W.append(tmp)

    c = ""
    for w in W:
        if W.count(w) > 1:
            return False

    for w in W:
        cc = w[len(w) - 1]
        if c == "" or c == w[0]:
            c = cc
        else:
            return False
    
    return True

if solve():
    print("Yes")
else:
    print("No")
    

Measured memory_bytes: 3064
#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 UNIQ(c) (c).erase(unique(ALL((c))), end((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 N;
  while(cin >> N, N){
	vector<PII> ps(N);
	VI xs_, ys_;
	REP(i,N){
	  cin >> ps[i];
	  xs_.EB(ps[i].FF);
	  ys_.EB(ps[i].SS);
	}
	vector<PII> cs(4);
	REP(i,4){
	  cin >> cs[i];
	  xs_.EB(cs[i].FF);
	  ys_.EB(cs[i].SS);
	}

	SORT(xs_);
	SORT(ys_);
	UNIQ(xs_);
	UNIQ(ys_);
	int MX = SZ(xs_);
	int MY = SZ(ys_);
	map<int,int> zxs, zys;
	REP(i,MX)
	  zxs[xs_[i]] = i;
	REP(i,MY)
	  zys[ys_[i]] = i;

	REP(i,N){
	  ps[i].FF = zxs[ps[i].FF];
	  ps[i].SS = zys[ps[i].SS];
	}
	REP(i,4){
	  cs[i].FF = zxs[cs[i].FF];
	  cs[i].SS = zys[cs[i].SS];
	}

	auto isin = [](vector<PII>& ps, const PII& p){
	  int cnt = 0;
	  for(int i=0;i<SZ(ps);++i){
		int i1 = i, i2 = (i+1) % SZ(ps);
		if(ps[i1].FF != ps[i2].FF) continue;
		if(p.FF < ps[i1].FF &&
		   ((ps[i1].SS <= p.SS && p.SS < ps[i2].SS)
			|| (ps[i2].SS <= p.SS && p.SS < ps[i1].SS)))
		  ++cnt;
	  }
	  return cnt%2 == 1;
	};

	vector<vector<bool>> dom(MY, vector<bool>(MX));
	for(int y=0;y<MY;++y){
	  for(int x=0;x<MX;++x){
		if(isin(ps, MP(x,y)) && !isin(cs, MP(x,y))){
		  dom[y][x] = true;
		}
	  }
	}
	int ans = 0;
	REP(y,MY) REP(x,MX)
	  if(dom[y][x]){
		ans += (xs_[x+1] - xs_[x]) * (ys_[y+1] - ys_[y]);
	  }
	cout << ans << endl;
  }  
  return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std; typedef long long ll; ll dp[105][100005], MOD = 1e9 + 7;
int main() {int n,k;scanf("%i%i",&n,&k);dp[0][0]=1;for(int x=1; x<=n; x++) {ll a;scanf("%lli",&a);for(int y=0;y<=k;y++){dp[x][y]+=dp[x-1][y]-(y-a>0?dp[x-1][y-a-1]:0);if(y>0)dp[x][y]+=dp[x][y-1];dp[x][y]%=MOD;dp[x][y]+=MOD;dp[x][y]%=MOD;}}printf("%lli\n",dp[n][k]%MOD);}


Measured memory_bytes: 81868
#include <stdio.h>

int main(void)
{
	float x[4], y[4];
	float slope1, slope2;
	int i;
	int n;
	
	scanf("%d", &n);
	while (n-- > 0){
		for (i = 0; i < 4; i++){
			scanf("%f %f", &x[i], &y[i]);
		}
		
		slope1 = (y[1] - y[0]) / (x[1] - x[0]);
		slope2 = (y[3] - y[2]) / (x[3] - x[2]);
		if (slope1 == slope2){
			puts("YES");
		}
		else {
			puts("NO");
		}
	}
	
	return (0);
}

Measured memory_bytes: 616
#include <iostream>

using namespace std;

int main() {
    char b;
    cin >> b;
    if (b == 'A')
        cout << "T" << endl;
    if (b == 'T') 
        cout << "A" << endl;
    if (b == 'C')
        cout << "G" << endl;
    if (b == 'G')
        cout << "C" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

string s,ss,x;
 ll a,b,i,j,l=0,k=0;
map<ll,ll>m;
cin>>a;
for(i=1;i<=a;i++)
{
cin>>b;m[b]=i;
}
for(i=1;i<=a;i++)
cout<<m[i]<<" ";
}

Measured memory_bytes: 7040
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef long long ll;
const int N=1e5+5;
int a[N],b[N],n;ll sum;
int main(){
	scanf("%d",&n);
	fp(i,1,n)scanf("%d%d",&a[i],&b[i]);
	fd(i,n,1)sum=(a[i]+sum+b[i]-1)/b[i]*b[i]-a[i];
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
#include <math.h>
using namespace std;

typedef long long ll;

/*
const ll M = 1000000007;
vector<ll> fac(3001);
vector<ll> ifac(3001);
ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}
 
ll comb(ll a, ll b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0 || b < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}
*/


ll lcm(ll a,ll b){
 
  ll r, x, tmp;
  x = a * b;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return x/b;
}

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

bool sosu(ll p){
    bool ans = true;
    double psqrtd = pow(p, 0.5);
    ll psqrt = psqrtd;
    for(ll i = 2; i <= psqrt; i++){
        if(p%i==0)ans = false;
    }
    if(p==1)ans = false;
    return ans;
}



int main(void){
    ll ans = 0;
    ll n;
    cin >> n;
    ll b[n-1];
    for(ll i = 0;i < n-1; i++){
        cin >> b[i];
    }
    for(ll i = 0;i < n-2; i++){
        ans += min(b[i],b[i+1]);
    }
    ans += b[0];
    ans += b[n-2];
    
    cout << ans << endl;
    
    return 0;
}

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

int main() {
  int x;
  int count = 1;
  rep(i, 5){
  	cin >> x;
    if(x == 0){
      cout << count << endl;
      return 0;
    }
    ++count;
  }

  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N, R;
  cin >> N >> R;
  if(N >= 10) cout << R << endl;
  else{
    cout << R+100*(10-N) << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
#define sz(a) ll(a.size())
void solve(){
	ll x;
	cin>>x;
	cout<<(x^1);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    clock_t z=clock();
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++){
        solve();
    }
    debug("Total Time:%.4Lf\n",(ld)(clock()-z)/CLOCKS_PER_SEC);
}

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

bool ok(ll n,ll a,ll b,vector<ll>h,ll middle){
    ll total=0;
    ll res=0;
    for(ll i=0;i<n;i++){
        res=h[i]-b*middle;
        if(res>0)total+=(res+a-b-1)/(a-b);
    }
    return total<=middle;
}

ll binary_search(ll n,ll a,ll b,vector<ll>h){
    ll low=0;
    ll high=1e10;
    while(abs(high-low)>1){
        ll middle=(low+high)/2;
        if(ok(n,a,b,h,middle)) high=middle;
        else low=middle;
    }
    return high;
}

int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    vector<ll>h(n);
    for(ll i=0;i<n;i++) cin>>h[i];
    cout<<binary_search(n,a,b,h)<<endl;
    

}


Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string S = Console.ReadLine();
		int N = S.Length;
		int[,]D = new int[N+2,2];
		D[N+1,0] = 999999999;
		for(var i=N;i>=0;i--){
			int s1 = 0;
          	if(i>=1){
				s1 = int.Parse(S.Substring(i-1,1));
            }
			int n1 = D[i+1,0] + 10-(s1+1);
			int n2 = D[i+1,1] + 10-s1;
			D[i,0] = Math.Min(n1,n2);
			int n3 = D[i+1,0] + s1+1;
			int n4 = D[i+1,1] + s1;
			D[i,1] = Math.Min(n3,n4);
			//Console.Error.WriteLine(D[i,0]+" "+D[i,1]);
		}
		Console.WriteLine(Math.Min(D[0,0],D[0,1]));
	}
}

Measured memory_bytes: 26700
/* The journey is what brings us pleasure, not the destination <3 */

#include<bits/stdc++.h>

#define PI acos(-1)
#define _fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD 1000000007
#define mxx 1000000
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;

int tc;

void solve(){

    ll n,m,k,ans=0;
    string grid[10];
    cin>>n>>m>>k;
    for(int i=0; i<n; i++)cin>>grid[i];

    for(int i=0; i<(1<< n); i++){
        for(int j=0; j<(1<<m); j++){
            int cnt=0;
            for(int p=0; p<n; p++){
                for(int q=0; q<m; q++){
                    if( ((i>>p)&1)==0 && ((j>>q)&1)==0 && grid[p][q] =='#' )cnt++;
                }
            }
            if(cnt==k)ans++;
        }
    }
    cout<<ans<<endl;
}

int main()
{

    _fastIO;

    //cin>>tc; while(tc--)
    solve();

    return 0;
}


Measured memory_bytes: 3632
def C3():
    tmp = []
    import  copy

    for i in range(9):
        tmp.append([])
        tmp[i].append(3 * pow(10, i))
        tmp[i].append(5 * pow(10, i))
        tmp[i].append(7 * pow(10, i))

    tmp2 = [copy.copy(tmp[0])]
    for i in range(1, 9):
        tmp2.append([])
        for j in range(3):
            k = 0
            while True:
                if len(tmp2[i - 1]) <= k:
                    break
                tmp2[i].append(tmp[i][j] + tmp2[i - 1][k])
                k += 1
    N = int(input())
    tmp3 = []
    for i in range(2, 9):
        for j in range(len(tmp2[i])):
            tmp3.append(tmp2[i][j])
    ans = 0
    for i in tmp3:
        s = 0
        f = 0
        t = 0
        for j in list(str(i)):
            if j == "7":
                s += 1
            if j == "5":
                f += 1
            if j == "3":
                t += 1
        if s != 0 and t != 0 and f != 0 and int(i) <= N:
            ans += 1
    print(ans)

C3()

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

int main() {
  char X;
  cin >> X;
  
  if (X == 'A') cout << 'T' << endl;
  if (X == 'T') cout << 'A' << endl;
  if (X == 'C') cout << 'G' << endl;
  if (X == 'G') cout << 'C' << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = 3.141592653589;
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    string s[n];
    cin(i,s);
    sort(s, s + n);
    intl cnt = 1;
    rep(i,n - 1){
        if(s[i] != s[i + 1])cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 9884
#include<bits/stdc++.h>
using namespace std;
double calcAngle(double h, double m)  
{  
    // validate the input  
    if (h <0 || m < 0 || h >12 || m > 60)  
        printf("Wrong input");  
  
    if (h == 12) h = 0;  
    if (m == 60) m = 0;  
  
    // Calculate the angles moved  
    // by hour and minute hands  
    // with reference to 12:00  
    double hour_angle = 0.5 * (h * 60 + m);  
    double minute_angle = 6 * m;  
  
    // Find the difference between two angles  
    double angle = abs(hour_angle - minute_angle);  
  
    // Return the smaller angle of two possible angles  
    angle = min(360 - angle, angle);  
  
    return angle;  
}  
int main(){
 
  double a,b,h,m;
  cin>>a>>b>>h>>m;
  double theta = calcAngle(h,m);
  double pi = 2 * acos(0.0);
  theta = theta * pi / 180.0;
  double ans = a*a + b*b - 2*a*b*cos(double(theta));
  cout<<fixed<<setprecision(9)<<sqrt(ans);
  
}


Measured memory_bytes: 4200
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a;
    cin >> a;
    int b = a;
    int c = 0;
    while(b / 10 != 0)
    {
        c += b % 10;
        b /= 10;
    }
    c += b;
    if(a % c == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }
//V,P(大文字)使用不可

const ll INF=1000000000000000000;

signed main(){
    int n;
    cin>>n;
    V<ll> a(n);
    cinf(n,a);
    sort(all(a));
    ll ans=0;
    V<P> b;
    int l,r;
    if(a[n-1]<=0){
        l=n-2;r=n-1;
        ll cnt=a[n-1];
        while(true){
            b.push_back(P(cnt,a[l]));
            cnt-=a[l];
            if(l==0) break;
            l--;
        }
        cout<<cnt<<endl;
        for(P pp:b) cout<<pp.ft<<' '<<pp.sc<<endl;
    }else if(a[0]>=0){
        r=n-1;
        ll cnt=a[0];
        while(true){
            if(r>1){
                b.push_back(P(cnt,a[r]));
                cnt-=a[r];
            }
            else{
                b.push_back(P(a[1],cnt));
                cnt=a[r]-cnt;
            }
            if(r==1) break;
            r--;
        }
        cout<<cnt<<endl;
        for(P pp:b) cout<<pp.ft<<' '<<pp.sc<<endl;
    }else{
        if(n==2){
            cout<<a[1]-a[0]<<endl;
            cout<<a[1]<<' '<<a[0]<<endl;
        }else{
            int u=lb(all(a),0)-a.begin();
            bool ok=0;
            r=n-1;
            ll cnt=a[0];
            if(u==n-1){
                ok=1;
                r=n-2;
                cnt=a[n-1];
            }
            while(true){
                if(!ok){
                    b.push_back(P(cnt,a[r]));
                    cnt-=a[r];
                    if(r==u+1){
                        a[0]=cnt;
                        cnt=a[u];
                        r=u-1;
                        ok=1;
                        continue;
                    }
                    r--;
                }else{
                    b.push_back(P(cnt,a[r]));
                    cnt-=a[r];
                    if(r==0) break;
                    r--;
                }
            }
            cout<<cnt<<endl;
            for(P pp:b) cout<<pp.ft<<' '<<pp.sc<<endl;
        }
    }
}

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

int N, M, ac, pe, p;
string S;

int main() {
  cin >> N >> M;
  vector<int> wa(N + 1, 1);
  while (M-- && cin >> p >> S) if (wa.at(p)) {
    if (S == "AC") ac++, pe += --wa.at(p), wa.at(p) = 0;
    else wa.at(p)++;
  }

  cout << ac << " " << pe << "\n";
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i = 0; i < N; ++i) cin >> A[i];
    int ret = 0;
    if(N - K <= 0){
        cout << 1 << endl;
        return 0;
    }
    else {
        N -= K;
        ret++;
        while(N > 0){
            ret++;
            N -= K-1;
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

struct BIT {
    BIT(int n) : s(n + 1), n(n) {}
    int sum(int k) {
        int r = 0;
        for (; k > 0; k -= k & -k) r += s[k];
        return r;
    }
    void add(int i, int v) {
        for (int k = i + 1; k <= n; k += k & -k) s[k] += v;
    }
    vector<int> s;
    int n;
};

struct Line {
    bool operator<(const Line& l) {
        return t < l.t;
    }
    double t;
    int16_t a, b, c;
    uint16_t j;
};

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

    int n;
    cin >> n;

    vector<Line> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l[i].a >> l[i].b >> l[i].c;
    }

    BIT b(n);
    int m = (n - 1) * n / 2;
    int h = (m + 1) / 2;

    for (int u = 0; u < 2; u++) {
        for (int i = 0; i < n; i++) {
            l[i].t = (double)l[i].a / l[i].b;
        }
        sort(l.begin(), l.end());

        for (int i = 0; i < n; i++) {
            l[i].j = i;
        }

        double x, x1 = 2e+8, x0 = -x1;
        while (1) {
            x = (x0 + x1) * 0.5;
            if (x1 - x0 < 1e-9 * max(abs(x), 1.0)) break;

            for (int i = 0; i < n; i++) {
                l[i].t = (l[i].c - l[i].a * x) / l[i].b;
            }
            sort(l.begin(), l.end());

            fill(b.s.begin(), b.s.end(), 0);

            int k = m;
            for (int i = 0; i < n; i++) {
                int j = l[i].j;
                k -= b.sum(j);
                b.add(j, 1);
            }
            if (k < h) x0 = x; else x1 = x;
        }

        cout << fixed << setprecision(12) << x << " \n"[u];

        if (u == 1) break;

        for (int i = 0; i < n; i++) {
            swap(l[i].a, l[i].b);
        }
    }

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <limits>

int main() 
{
    int64_t N, K;
    std::cin >> N >> K;

    std::vector<int64_t> As(N);
    for (auto& A : As) {
        std::cin >> A;
    }

    int64_t i = 0;
    while (true) {
        if (K+i >= N) break;

        auto prev = As.at(i);
        auto curr = As.at(K+i);

        if (prev < curr) {
            std::cout << "Yes" << std::endl;
        } else {
            std::cout << "No" << std::endl;
        }

        i++;
    }

    return 0;
}

Measured memory_bytes: 4816
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	string a,b,c; cin>>a>>b>>c;
	if(a[a.size()-1]==b[0] && c[0]==b[b.size()-1]) cout<<"YES";
	else cout<<"NO";
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

/*
AC
h2*w2内の総和がどこを見ても-1になるようにする
正の部分と負の部分を偏らせる（大きい数字を左上に寄せて，小さい数字が右下に来るようにする）
*/


int main(void){
	bool ok=true;
	ll h,w,h2,w2,ans[510][510];
	cin>>h>>w>>h2>>w2;
	if(h%h2==0 && w%w2==0)ok=false;
	rep(i,h)rep(j,w)ans[i][j]=-1000;
	//どちらに余りが出るかで作り方を変える
	if(h%h2!=0){
		rep(i,h/h2+1)rep(j,w)ans[i*h2][j]=(h2-1)*1000;
		rep(i,h/h2+1)reg(j,1,w/w2)ans[i*h2][j*w2-1]-=1;
	}else{//w%w2!=0
		rep(i,h)rep(j,w/w2+1)ans[i][j*w2]=(w2-1)*1000;
		reg(i,1,h/h2)rep(j,w/w2+1)ans[i*h2-1][j*w2]-=1;
	}
	if(ok){
		cout<<"Yes"<<endl;
		rep(i,h){
			rep(j,w)cout<<ans[i][j]<<" ";
			cout<<endl;
		}
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout<<#x<<" "<<x<<"\n";
#define lli long long int
long long int mod= 1000000007,modd=998244353;
int32_t main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);  cout.tie(0);
   lli n,ans=0;
   cin>>n;
   if(n==0) ans=1;
   cout<<ans<<"\n";
   return 0;
}//main


Measured memory_bytes: 3632
#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 r, g, b;
  cin >> r >> g >> b;
  int A = 100 * r + 10 * g + b;
  if(A % 4 ==0 ){
cout << "YES" << endl;
  }else{
cout << "NO" << endl;
  }
    return 0;
}


Measured memory_bytes: 256
use std::io;
use std::io::{Read, Stdin};
use std::str;
use std::str::FromStr;
use std::usize;
use std::cmp;
use std::fmt::Debug;
use std::i64::MAX;
use std::collections::BinaryHeap;
use std::cmp::Ordering;
use std::collections::VecDeque;

static MOD: u64 = 1000000007;

fn main() {
    let mut sc = Scanner::new();
    let n = sc.parse::<usize>();
    let x = (0..2).map(|_| { sc.parse::<String>().into_bytes() }).collect::<Vec<_>>();

    let mut i: usize = 0;
    let mut vertical = false;
    let mut ans = 1;
    while i < n {
        if i == 0 {
            if x[0][i] == x[1][i] {
                ans = 3;
                i += 1;
                vertical = true;
            } else {
                ans = 6;
                i += 2;
                vertical = false;
            }
        } else if x[0][i] == x[1][i] {
            if vertical {
                ans *= 2;
            } else {
                ans *= 1;
            }
            i += 1;
            vertical = true;
        } else {
            if vertical {
                ans *= 2;
            } else {
                ans *= 3;
            }
            i += 2;
            vertical = false;
        }
        ans %= MOD;
    }
    println!("{}", ans);
}

struct Scanner {
    stdin: Stdin,
    buf: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            buf: Vec::with_capacity(256),
        }
    }

    fn parse<T: FromStr>(&mut self) -> T
        where <T as FromStr>::Err: Debug
    {
        self.buf.clear();
        let mut it = self.stdin.lock().bytes();
        let mut c = it.next().unwrap().unwrap();
        while c == ' ' as u8 || c == '\n' as u8 {
            c = it.next().unwrap().unwrap();
        }
        while !(c == ' ' as u8 || c == '\n' as u8) {
            self.buf.push(c);
            c = it.next().unwrap().unwrap();
        }
        str::from_utf8(&self.buf).unwrap().parse::<T>().unwrap()
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void solve(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    if (a!=c&&b!=c)
        cout<<1;
        else
        cout<<0;
               }

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

Measured memory_bytes: 256
#include <iostream>

#define endl '\n'
#define ll long long

using namespace std;

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

    cin >> A >> B >> C;

    int sonzinho = B / A;

    if(sonzinho > C) {
        cout << C << endl;
    }

    else {
        cout << sonzinho << endl;
    }


    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
max_l = 0
min_r = 10 ** 10
for _ in range(m):
  l, r = map(int, input().split())
  max_l = max(max_l, l)
  min_r = min(min_r, r)
print(max(0, min_r - max_l + 1))

Measured memory_bytes: 74604
n = int(input())
a = list(map(int, input().split()))

def gcd(x_,y_):
	x = max(x_, y_)
	y = min(x_, y_)
	if y==0:
		return x
	if x%y == 0:
		return y
	return gcd(y, x%y)

L = [0]*n
R = [0]*n
L[0] = a[0]
R[-1] = a[-1]

for i in range(1,n):
	L[i] = gcd(L[i-1], a[i])
	j = n-1-i
	R[j] = gcd(R[j+1], a[j])

L = [0]+L
R = R + [0]
M = [0]*n
for i in range(n):
	M[i] = gcd(L[i],R[i+1])
print(max(M))

Measured memory_bytes: 14524
"""
author : halo2halo
date : 30, Jan, 2020
"""

import sys

# import itertools
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

S = readline().decode('utf8').rstrip()
m = list('abcdefghijklmnopqrstuvwxyz')

sa = list(S)
sa = list(set(sa))
sa.sort()
ans = ''
for i in m:
    if not (i in sa):
        ans = i
        break

print(ans if ans else 'None')


Measured memory_bytes: 4020
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def main():
    rr = []


    while True:
        w,h = LI()
        if h == 0:
            break
        a = [LI() for _ in range(h)]
        cs = LI()

        def search(s):
            d = collections.defaultdict(lambda: inf)
            d[s] = 0
            q = []
            heapq.heappush(q, (0, s))
            v = collections.defaultdict(bool)
            while len(q):
                k, u = heapq.heappop(q)
                if v[u]:
                    continue
                v[u] = True
                if u[0][0] == h-1 and u[0][1] == w-1:
                    return d

                for ui in range(4):
                    ud = cs[ui]
                    if a[u[0][0]][u[0][1]] == ui:
                        ud = 0
                    di,dj = dd[(u[1]+ui) % 4]
                    ni = u[0][0] + di
                    nj = u[0][1] + dj
                    if ni < 0 or ni >= h or nj < 0 or nj >= w:
                        continue
                    uv = ((ni,nj), (u[1]+ui) % 4)
                    if v[uv]:
                        continue
                    vd = k + ud
                    if d[uv] > vd:
                        d[uv] = vd
                        heapq.heappush(q, (vd, uv))
            return d

        d = search(((0,0), 1))
        r = inf
        for i in range(4):
            if r > d[((h-1,w-1),i)]:
                r = d[((h-1,w-1),i)]
        rr.append(r)

    return '\n'.join(map(str, rr))



print(main())



Measured memory_bytes: 10796
#include<stdio.h>
int main(void){
  char s[9],t[9],u[9];
  int a,b;
  scanf("%s\n%s\n",s,t);
  scanf("%d\n%d\n",&a,&b);
  scanf("%s\n",u);
  if(*s==*u){
    a=a-1;
  }else{
    b=b-1;
  }
  printf("%d %d\n",a,b);
  return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
import sys

input=sys.stdin.readline

H,W,D=map(int,input().split())
A=[[] for i in range(0,H)]
for i in range(0,H):
    A[i]=list(map(int,input().split()))
Q=int(input())
L=[0 for i in range(0,Q)]
R=[0 for i in range(0,Q)]
for i in range(0,Q):
    L[i],R[i]=map(int,input().split())

data=[(0,0) for i in range(0,H*W+1)]
for i in range(0,H):
    for j in range(0,W):
        data[A[i][j]]=(i+1,j+1)
anstable=[[] for i in range(0,D+1)]
for i in range(1,D+1):
    x=(H*W-i)//D
    for j in range(0,x):
        s=data[i+j*D][0]
        t=data[i+j*D][1]
        s2=data[i+(j+1)*D][0]
        t2=data[i+(j+1)*D][1]
        anstable[i].append(abs(s2-s)+abs(t2-t))
    anstable[i]=list(accumulate(anstable[i]))

for i in range(0,Q):
    x=L[i]%D
    if x==0:
        x=D
    if D>=L[i]:
        if R[i]==L[i]:
            print(0)
        else:
            if x!=D:
                print(anstable[x][R[i]//D-1])
            else:
                print(anstable[x][R[i]//D-2])
    else:
        if x!=D:
            print(anstable[x][R[i]//D-1]-anstable[x][L[i]//D-1])
        else:
            print(anstable[x][R[i]//D-2]-anstable[x][L[i]//D-2])


Measured memory_bytes: 68444
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

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

	string s;
	cin >> s;
	int ans = 0;
	rep(i, s.length()) {
		ans += s[i] - '0';
		ans %= 9;
	}

	if (ans == 0) {
		cout << "Yes" << "\n";
	}
	else {
		cout << "No" << "\n";
	}

	return 0;
}


Measured memory_bytes: 3736
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct Node {
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;
	
	z = (Node *)malloc(sizeof(Node));
	z->key   = k;
	z->left  = NIL;
	z->right = NIL;
	
	while(x != NIL) {
		y = x;
		if(z->key < x->key) {
			x = x->left;
		} else {
			x = x->right;
		}
	}
	
	z->parent = y;
	if(y == NIL) {
		root = z;
	} else {
		if( z->key < y->key) {
			y->left = z;
		} else {
			y->right = z;
		}
	}
}

void inorder(Node *u) {
	if(u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}
void preorder(Node *u) {
	if(u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}
	
int main(void) {
	int n, i, x;
	string com;
	scanf("%d",&n);
	
	for(i=0;i<n;i++) {
		cin >> com;
		if(com == "insert") {
			scanf("%d",&x);
			insert(x);
		} else if(com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}


Measured memory_bytes: 26792
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn f(mut n: u32) -> u32 {
    let mut ret: u32 = 0;
    while n % 2 == 0 {
        n /= 2;
        ret += 1;
    }
    ret
}

fn main() {
    let _: usize = read();
    let av: Vec<u32> = read_vec();

    let mut ans: u32 = 0;
    for a in av {
        ans += f(a);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	cin >> N;
	vector<lint> data(N);
	lint max_num = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> data[i];
		max_num = max(max_num, data[i]);
	}

	double half = max_num / 2.0;
	lint diff_min = INF64;
	lint n = data[0];
	for (int i = 0; i < N; i++)
	{
		if (max_num != data[i] && abs(half - data[i]) <= diff_min)
		{
			diff_min = abs(half - data[i]);
			n = data[i];
		}
	}
	cout << max_num << " " << n << endl;

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

int main (){
    string A,B,C;
    cin >> A;
    cin >> B;
    cin >> C;
    string next;
            if(A[0] == 'a'){
                A.erase(0,1);
                next = "A";
            }
            else if(A[0] == 'b'){
                A.erase(0,1);
                next = "B";
            }
            else if(A[0] == 'c'){
                A.erase(0,1);
                next = "C";
            }
    while(true){
            if(next == "A"){
                            if(A[0] == 'a'){
                A.erase(0,1);
                next = "A";
            }
            else if(A[0] == 'b'){
                A.erase(0,1);
                next = "B";
            }
            else if(A[0] == 'c'){
                A.erase(0,1);
                next = "C";
            }
                else if (A == ""){
                    cout << "A";
                    break;
                }
            }
           else if(next == "B"){
                           if(B[0] == 'a'){
                B.erase(0,1);
                next = "A";
            }
            else if(B[0] == 'b'){
                B.erase(0,1);
                next = "B";
            }
            else if(B[0] == 'c'){
                B.erase(0,1);
                next = "C";
            }
               else if(B == ""){
                   cout << "B";
                   break;
               }
           }
        else if(next == "C"){
                        if(C[0] == 'a'){
                C.erase(0,1);
                next = "A";
            }
            else if(C[0] == 'b'){
                C.erase(0,1);
                next = "B";
            }
            else if(C[0] == 'c'){
                C.erase(0,1);
                next = "C";
            }
            else if(C == ""){
                cout << "C";
                break;
            }
                
        }
    }
}
        
          

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

int main(void) {
	int n, i;
	double a[1000], b[1000], c[1000];
	double buf;

	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%lf %lf %lf", &a[i], &b[i], &c[i]);
		if (a[i] <= c[i] && b[i] <= c[i]){
			buf = sqrt((a[i] * a[i]) + (b[i] * b[i]));
			if (sqrt(c[i]*c[i]) == sqrt(buf*buf)){
				printf("YES\n");
			}
			else{
				printf("NO\n");
			}
		}
		else if (a[i] <= b[i] && b[i] >= c[i]){
			buf = sqrt((a[i] * a[i]) +(c[i] * c[i]));
			if (sqrt(b[i]*b[i]) == sqrt(buf*buf)){
				printf("YES\n");
			}
			else{
				printf("NO\n");
			}
		}
		else if (a[i] >= b[i] && a[i] >= c[i]){
			buf = sqrt((b[i] * b[i]) + (c[i] * c[i]));
			if (sqrt(a[i]*a[i]) == sqrt(buf*buf)){
				printf("YES\n");
			}
			else{
				printf("NO\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
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 D;
vector<int> c(26); 
vector<vector<int>> s(365, vector<int>(26));

int cal_score(vector<int> t){
    vector<int> res(D);
    int satis = 0;
    vector<int> last(26, 0);
    rep(d, D){
        satis += s[d][t[d] - 1];
        last[t[d] - 1] = d + 1;
        rep(i, 26){
            satis -= c[i] * (d - last[i] + 1);
        }
        res[d] = satis;
    }
    return res[D - 1];
}

int main(){
    // input 
    cin >> D;
    rep(i, 26) cin >> c[i];
    rep(i, D){
        rep(j, 26){
            cin >> s[i][j];
        }
    }

    // greedy
    vector<int> last(26, 0);
    vector<int> res(D);

    rep(d, D){
        int max_plus = -10000;
        int use = -1;
        rep(i, 26){
            int tmp = s[d][i] + c[i] * (d - last[i] + 1);
            if(max_plus < tmp){
                max_plus = tmp;
                use = i;
            }
        }
        last[use] = d + 1;
        res[d] = use + 1;
    }

    int cur_score = cal_score(res);

    while((clock() / (double)CLOCKS_PER_SEC) <= 1.9){
        int ch_d = rand() % D + 1;
        int ch_c = rand() % 26 + 1;
        int old_c = res[ch_d - 1];
        res[ch_d - 1] = ch_c;
        int new_score = cal_score(res);
        if(cur_score < new_score){
            cur_score = new_score;
        }else{
            res[ch_d - 1] = old_c;
        }
    }

    rep(i, D){
        cout << res[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3716
import networkx as nx

N = int(input())
reds = [tuple(map(int, input().split())) for _ in range(N)]
blues = [tuple(map(int, input().split())) for _ in range(N)]
G = nx.DiGraph()
for rx, ry in reds:
    for bx, by in blues:
        if rx < bx and ry < by:
            G.add_edge("S", (rx, ry), capacity=1)
            G.add_edge((rx, ry), (bx, by), capacity=1)
            G.add_edge((bx, by), "T", capacity=1)
if G.nodes:
    print(nx.maximum_flow_value(G, "S", "T"))
else:
    print(0)

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

#define nn 1200008
#define mod 1000000007
#define ll long long
ll pre[nn];ll n;

void add(ll &x,ll y) {x=(x+y)%mod;}
vector<ll> onit[nn];
ll cnt[nn];
int main()
{
	pre[0]=0;cnt[0]=1;onit[0].push_back(0);
	scanf("%lld",&n);
	for(ll i=1;i<=n;i++)
	{
		ll x;scanf("%lld",&x);
		pre[i]=pre[i-1]^x;
		onit[pre[i]].push_back(i);
		cnt[i]=cnt[i-1]+(pre[i]==0);
	}
	
	ll ans=0;
	for(ll i=1;i<nn;i++)
	{
		ll m=onit[i].size();ll all=0;ll bas=1;
		if(m==1)
		{
			if(pre[n]==0 or pre[n]==i) add(ans,1);
			continue;
		}
		
		for(ll j=1;j<m;j++) 
		{
			all+=1ll*bas*(cnt[onit[i][j]]-cnt[onit[i][j-1]]);
			all%=mod;bas+=all+1;bas%=mod;
			if(pre[n]==0) add(ans,all+1);
		}
		if(pre[n]==0) if(m) add(ans,1);
		if(pre[n]==i) if(m) add(ans,all+1);
	}
	
		ll m=onit[0].size();ll all=1;
		for(ll j=1;j<m-1;j++) all=all*2%mod;
		
		if(pre[n]==0) if(m) add(ans,all);
	
	
	cout<<ans;
	
	return 0;
} 

Measured memory_bytes: 49520
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;

    vector<int> l(N), r(N);
    int sum = 0;

    for (int i = 0; i < N; i++) {
        cin >> l.at(i) >> r.at(i);
        sum += r.at(i) -l.at(i) + 1;
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
from collections import *
from heapq import *
from itertools import *
from fractions import gcd

from decimal import *
import copy
from bisect import *
import time
import sys
import math
input=lambda :sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**7)
K=int(input())
#A,B=map(int,input().split())
#A=list(map(int,input().split()))
z=0
dic=defaultdict(int)
for a in range(1,K+1):
    for b in range(1,K+1):
        d=gcd(a,b)
        dic[d]+=1
for d in dic:

    for c in range(1,K+1):
        z+=dic[d]*gcd(c,d)
print(z)


Measured memory_bytes: 75612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
    int a,b,c;
    bool f=false;
    cin >> a >>b >>c;
    for(int i=0;i<b;i++){
        if((a*i)%b==c){
            f =true;
            break;
        }
    }
    if(f==true) cout <<"YES" <<endl;
    else cout <<"NO"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

int main(){
	int n=get(),k=get();
	LL ans=0;
	fo(i,k+1,n){
		fo(j,0,n/i)
		if (j)ans=ans+max(0,min(n-j*i,i-1)-k+1);
		else ans=ans+max(0,min(n-j*i,i-1)-max(k,1)+1);
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    if(n <= k) cout << n*x << endl;
    else cout << k*x+(n-k)*y << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <deque>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>
#define llint long long
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;

struct edge{
	llint to, cost;
	edge(llint a, llint b){
		to = a, cost = b;
	}
};

llint V, e, r;
vector<edge> G[100005];
llint dist[100005];

void dijkstra(vector<edge> G[], llint S, llint dist[])
{
	for(int i = 0; i <= V; i++) dist[i] = inf;
	dist[S] = 0;
	
	priority_queue< P, vector<P>, greater<P> > Q;
	Q.push( make_pair(0, S) );
	
	llint v, d;
	while(Q.size()){
		d = Q.top().first;
		v = Q.top().second;
		Q.pop();
		if(dist[v] < d) continue;
		for(int i = 0; i < G[v].size(); i++){
			if(dist[G[v][i].to] > d + G[v][i].cost){
				dist[G[v][i].to] = d + G[v][i].cost;
				Q.push( make_pair(dist[G[v][i].to], G[v][i].to) );
			}
		}
	}
}

int main(void)
{
	cin >> V >> e >> r;
	llint u, v, w;
	for(int i = 1; i <= e; i++){
		cin >> u >> v >> w;
		G[u].push_back(edge(v, w));
	}
	
	dijkstra(G, r, dist);
	
	for(int i = 0; i < V; i++){
		if(dist[i] > inf/2) cout << "INF" << "\n";
		else cout << dist[i] << "\n";
	}
	flush(cout);
	
	return 0;
}



Measured memory_bytes: 19416
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.nextLine());

		int[][] map = new int[n][n];
		for (int i = 0; i < n; i++) {
			String[] nico = sc.nextLine().split(" ");
			for (int j = 0; j < n; j++) {
				map[i][j] = Integer.parseInt(nico[j]);
			}
		}
		
		int[][] tmp = new int[n][n + 1];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < tmp[0].length; j++) {
				tmp[i][j] = 0;
			}
		}
		
		for (int i = 0; i < n; i++) {
			for (int j = 1; j < tmp[0].length; j++) {
				if (j > 0) tmp[i][j] = tmp[i][j - 1] + map[i][j - 1];
				else tmp[i][j] = map[i][j];
			}
		}
		
		int max = Integer.MIN_VALUE;
		for (int si = 0; si < n; si++) {
			for (int ei = (si + 1); ei <= n; ei++) {

				for (int sj = 0; sj < n; sj++) {
					for (int ej = (sj + 1); ej <= n; ej++) {
						
						int sum = 0;
						for (int i = si; i < ei; i++) {
							sum = sum + tmp[i][ej] - tmp[i][sj];
						}
						if (max < sum) max = sum;
					}
				}
			}
		}
		
		System.out.println(max);
	}
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int length = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');
            int[] numbers = new int[str.Length];

            for (int i = 0; i < length; i++)
            {
                numbers[i] = int.Parse(str[i]);
            }

            int count1 = 0;
            int length_minus_1 = length - 1;
            bool is_break = false;

            for (int i = 0; i < length_minus_1; i++)
            {
                int count2 = 0;

                for (int i2 = 1; i + i2 < length; i2++)
                {
                    if (numbers[i + i2 - 1] >= numbers[i + i2])
                    {
                        ++count2;
                    }
                    else
                    {
                        i = i + i2 - 1;
                        break;
                    }

                    if (i + i2 == length_minus_1)
                        is_break = true;
                }

                if (count2 > count1)
                {
                    count1 = count2;
                }

                if (is_break)
                {
                    break;
                }
            }

            Console.WriteLine($"{count1}");
        }
    }
}


Measured memory_bytes: 25052
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  vector<int> n(N);
  for(int i=0;i<2*M;i++){
    int c;
    cin>>c;
    n[c-1]++;
  }
  for(int i=0;i<N;i++){
    cout<<n[i]<<endl;
  }
}

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

int main() {
    ll n;
    cin >> n;
    ll cnt = 0;
    for (ll i = 0;i < n;++i) {
        ll d1, d2;
        cin >> d1 >> d2;
        if (d1 == d2)++cnt;
        else cnt = 0;
        if (cnt >= 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3592