akhauriyash/Code-Regression huggingface dataset:
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=998244353;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
struct UnionFind{
    vector<int>par,siz;
    UnionFind(int x){
        par.resize(x);
        siz.resize(x);
        rep(i,x){
            par[i]=i;
            siz[i]=1;
        }
    }
    int find(int x){
        if(par[x]==x)return x;
        return par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x),y=find(y);
        if(x==y)return;
        if(siz[x]<siz[y])swap(x,y);
        par[y]=x;
        siz[x]+=siz[y];
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return siz[find(x)];
    }
};
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,m,a[200010],b[200010];
    cin>>n>>m;
    UnionFind uf(n);
    rep(i,m){
        cin>>a[i]>>b[i];
        a[i]--,b[i]--;
        uf.unite(a[i],b[i]);
    }
    set<int>st;
    rep(i,n)st.insert(uf.find(i));
    cout<<st.size()-1<<endl;
    return 0;
}


Measured memory_bytes: 8360
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N , sum=0 , Max , ans;
  cin>>N;
  vector<int> input(N);
  for(int i=0;i<N;i++){
    cin>>input.at(i);
    sum+=input.at(i);
  }
  Max=*max_element(input.begin(),input.end());
    ans=sum-Max;
  if(ans>Max){
    cout<<"Yes"<<endl;
  }
   else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
def divide_into_three(X, Y):
    minimum = float("inf")
    for x in range(1, X):
        b1 = x * Y
        if not all(((X - x) & 1, Y & 1)):
            b2 = b3 = ((X - x) * Y) >> 1
        else:
            s, l = sorted((X - x, Y))
            b2 = s * (l >> 1)
            b3 = s * l - b2
        diff = max((b1, b2, b3)) - min((b1, b2, b3))
        minimum = min(minimum, diff)
    return minimum

H, W = map(int, input().split())
print(min(divide_into_three(H, W), divide_into_three(W, H)))

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

ll MOD = 1000000007;
ll lcm(ll a, ll b) { return (a / __gcd(a, b) * b); }

int main() {
  //
  int n;
  cin >> n;
  map<int, int> m;
  rep(i, n) {
    int a;
    cin >> a;
    if (m.find(a) == m.end()) {
      m[a] = 1;
    } else {
      m[a]++;
    }
  }
  int t = !(n & 1);
  for (auto& x : m) {
    if (t == !(n & 1)) {
      if (x.first != t) {
        cout << 0 << endl;
        return 0;
      }
      if (n & 1) {
        if (x.second != 1) {
          cout << 0 << endl;
          return 0;
        }
      } else {
        if (x.second != 2) {
          cout << 0 << endl;
          return 0;
        }
      }
    } else if (x.first != t || x.second != 2) {
      cout << 0 << endl;
      return 0;
    }
    t += 2;
  }
  ll ans = 1;
  rep(i, n / 2) { ans = (ans << 1) % MOD; }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <string>
#include <vector>
#include <iomanip>
#include <map>

using namespace std;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

typedef long long ll;
typedef long double ld;

const ll SIZE = 1e5 * 3 + 10;

vector<vector<ll>> graph;
ll dsu[SIZE];
set<ll> s;
ll find(int v) {
    if (dsu[v] == v) return v;
    else return dsu[v] = find(dsu[v]);
}

void uni(int v, int u) {
    v = find(v);
    u = find(u);
    if (u != v) {
        dsu[u] = v;
    }
}

int main() {
    fastInp;

    ll n, m;
    cin >> n >> m;

    for (int i = 0; i < n; i++) dsu[i] = i;
    for (int i = 0; i < m; i++) {
        ll x, y, z;
        cin >> x >> y >> z;
        z %= 2;
        x--; y--;
        uni(x, y);
    }

    for (int i = 0; i < n; i++) {
        ll v = find(i);
        s.insert(v);
    }

    cout << s.size() << "\n";

    return 0;
}



Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef vector<vector<ll> > Graph;
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; }
const ll INF = 1e18;


int main(){
    int n,k;
    cin >> n >> k;
    vector<int>d(k);
    rep(i,k)cin>>d[i];
    vector<bool>v(10,false);
    rep(i,k)v[d[i]]=true;
    for(int i=n;i<=100000;i++){
        bool flag =false;
        int tmp = i;
        while(tmp>0){
            int now = tmp % 10;
            if(v[now])flag = true;
            tmp /= 10;
        }
        if(flag)continue;
        cout << i << endl;
        return 0;
    }

    return 0;
}


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

vector<long long> enum_divisors(long long n) {
    vector<long long> res;
    for (long long i = 1LL; i * i <= n; i++) {
        if (n % i == 0) {
            res.emplace_back(i);
            if (i != n / i) res.emplace_back(n / i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

int main() {
    long long N, M; cin >> N >> M;
    long long ans = 1;
    for (long long d: enum_divisors(M)) {
        if (d * N <= M) ans = max(ans, d);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ALL(a) (a).begin(),(a).end()
#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
const ll LINF = 1e11;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

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

    int n, k;
    cin >> n >> k;

    cout << n - (k - 1) << endl;
    return 0;
}


Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#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 FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;
void solve() {
    LL N,D;
    R(N,D);
    int an=0;
    FOR(i,1,N){
        LL x,y;
        R(x,y);
        if(x*x+y*y<=D*D)an++;
    }
    W(an);
}
int main(){
#define MULTITEST 0
#if MULTITEST    
    CASET{
        solve();
    }
#else
    solve();
#endif
    return 0;
}


Measured memory_bytes: 3748
#include<iostream>
#include<deque>
using namespace std;
int N,M,K;
long A;
deque<pair<long,int> >P[301];
main()
{
	cin>>N>>M>>K;
	P[0].push_back(make_pair(0,N));
	for(int i=0;i<N;i++)
	{
		cin>>A;
		for(int j=K;j--;)
		{
			if(P[j].empty())continue;
			while(P[j].front().second+M<i)P[j].pop_front();
			long nxt=P[j].front().first+A*(j+1);
			while(!P[j+1].empty()&&P[j+1].back().first<=nxt)P[j+1].pop_back();
			P[j+1].push_back(make_pair(nxt,i));
		}
	}
	cout<<P[K][0].first<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <bitset>

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

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

	for (int i = 1; i <= B; i++) {
		if (i*A % B == C) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;

	return 0;
}

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

int flg[1000001];

int main(void){
	int j;
	int n,a,b;
	int x,ans;

	while(scanf("%d%d%d",&n,&a,&b) && (n||a||b)){
		memset(flg,0,sizeof(flg));
		ans = n;

		for(j=0;j<a;j++){
			x = b*j;
			while(x <= n){
				if(flg[x] == 0) ans--;
				flg[x] = 1;
				x += a;
			}
		}

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

	return 0;
}

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

int gcd(int x, int y);

const int INF = 1001001001;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/


int main() {
    int h, w;
    cin >> h >> w;
    vector<string> field(h);
    rep(i, h){
        cin >> field[i];
    }

    rep(i, w + 2) cout << '#';
    cout << endl;
    rep(i, h) {
        cout << '#';
        cout << field[i];
        cout << '#' << endl;;
    }
    rep(i, w + 2) cout << '#';

    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}
	if(a>b){
		printf("a > b\n");
	}
	if(a==b){
		printf("a == b\n");
	}

return 0;
}

Measured memory_bytes: 580
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;

public class Main {
	public static void main (String[] args) {
	    Scanner s=new Scanner(System.in);
	    int n=s.nextInt();
        int m=s.nextInt();
        int ss=0;
        while(m-->0)
        ss+=s.nextInt();
        if(n>=ss)
		System.out.println(n-ss);
		else
		System.out.println(-1);
	}
}

Measured memory_bytes: 46204
// ----- In the name of ALLAH, the Most Gracious, the Most Merciful -----

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

#define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define dloop(i,n) for(int i=n-1;i>=0;i--)
#define iii tuple<int,int,int>
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define int long long
#define ld long double
#define pb push_back
#define endl "\n"
#define setbits __builtin_popcountll
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007
#define inf (int)1e18

int32_t main(){
	NINJA;

	int r,g,b; cin >> r >> g >> b;
	int k; cin >> k;
	while(k!=0 && r>=g){
		g *= 2;
		k--;
	}

	while(k!=0 && g>=b){
		b*=2;
		k--;
	}

	if(r<g && g<b) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

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

int main()
{
    int flag=0;
    long long n,i;
    cin>>n;
    long long s = sqrt(n);
    for(i=s;i>=2;i--){
        if(n%i==0){flag=1; break;}
    }
    if(flag==1) cout<<(i-1)+(n/i-1);
    else cout<<n-1;
}


Measured memory_bytes: 256
Public Class Program
  Shared Sub Main()
    Dim n As String = Cin.Str()
    Dim k As Integer = Cin.Int()
    Dim dp(0 To n.Length(), 0 To k + 1, 0 To 1) As Long
    dp(0, 0, 1) = 1
    For digit As Integer = 1 To n.Length()
      Dim d As Integer = Integer.Parse(n(digit - 1))
      For countNot0 As Integer = 0 To k 
        If d = 0 Then
          dp(digit, countNot0, 1) += dp(digit - 1, countNot0, 1)
        Else
          dp(digit, countNot0 + 1, 1) += dp(digit - 1, countNot0, 1)
          dp(digit, countNot0, 0) += dp(digit - 1, countNot0, 1)
          dp(digit, countNot0 + 1, 0) += dp(digit - 1, countNot0, 1) * (d - 1)
        End If
        dp(digit, countNot0 + 1, 0) += dp(digit - 1, countNot0, 0) * 9
        dp(digit, countNot0, 0) += dp(digit - 1, countNot0, 0)
      Next
    Next
    Console.WriteLine((dp(n.Length(), k, 1) + dp(n.Length(), k ,0)).ToString())
  End Sub
End Class

Public Class Cin
  Public Shared Function Str() As String
    Return Console.ReadLine().Trim()
  End Function
  Public Shared Function Int() As Integer
    Return Integer.Parse(Str())
  End Function
  Public Shared Function Lng() As Long
    Return Long.Parse(Str())
  End Function
  Public Shared Function Dbl() As Double
    Return Double.Parse(Str())
  End Function
  Public Shared Function StrArr(Optional separator As String = " ") As String()
    Return Str().Split(separator)
  End Function
  Public Shared Function IntArr(Optional separator As String = " ") As Integer()
    Return Array.ConvertAll(Of String, Integer)(StrArr(separator), AddressOf Integer.Parse)
  End Function
  Public Shared Function LngArr(Optional separator As String = " ") As Long()
    Return Array.ConvertAll(Of String, Long)(StrArr(separator), AddressOf Long.Parse)
  End Function
  Public Shared Function DblArr(Optional separator As String = " ") As Double()
    Return Array.ConvertAll(Of String, Double)(StrArr(separator), AddressOf Double.Parse)
  End Function
End Class

Measured memory_bytes: 13268
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
using namespace std;
typedef long long LL;
const int N=2e5;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
int x[N];
//移动后相对位置还是不变的，同时，去掉编号后，两个相遇的蚂蚁同时转向等价于同时不转向
//所以可以求出T时间之后的情况
//因为这是一个环，所以要考虑开始点的变化，顺时针经过环则开始点+1，逆时针经过环则开始点-1
int main()
{
	int n=gi(),L=gi(),T=gi(),i,all=0,uni=T/L,p=T%L;
	for (i=0;i<n;i++) {
		x[i]=gi();
		if (gi()==1) {
			all+=uni+(p>=L-x[i]);
			(x[i]+=p)%=L;
		} else {
			all-=uni+(p>x[i]);
			x[i]=(x[i]-p+L)%L;
		}
	}
	all=(all%n+n)%n;
	sort(x,x+n);
	for (i=all;i<n;i++) printf("%d\n",x[i]);
	for (i=0;i<all;i++) printf("%d\n",x[i]);
	return 0;
}


Measured memory_bytes: 1536
#include <cstdio>

int main (){
    char S[10];
    scanf("%s",S);
    int maxlength=0;
    int length=0;
    bool flag=0;
    for (int i = 0; i < 10; i++){
        if(S[i]=='A'||S[i]=='T'||S[i]=='G'||S[i]=='C'){
            if(flag==1){
                length++;
                if(maxlength<length) maxlength=length;
            }
            else{
                length=1;
                if(maxlength<length) maxlength=length;
                flag=1;
            }
        }
        else flag=0;
    }
    printf("%d",maxlength);
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<map>

using namespace std;

int dx[4]={1,-1,4,-4};
map<string,int>res;


void bfs(void){
  queue<string>que;

  que.push("01234567");

  while(!que.empty()){

    string v=que.front();

    que.pop();

    int pos=0;
    for(int i=0;i<8;i++)
      if(v[i]=='0')pos=i;

    for(int i=0;i<4;i++){
      if(0 <= pos+dx[i] && pos+dx[i]<8 && 
	 !(pos==3 && i==0) && !(pos==4 && i==1)){
	string u=v;
	swap(u[pos],u[pos+dx[i]]);

	if(res[u]==0){
	  que.push(u);
	  res[u]=res[v]+1;
	}
      }
    }
  }
}

int main(void){
  int in;
  
  res["01234567"]=1;

  bfs();

  while(true){
    string s;
    for(int i=0;i<8;i++){
      if(!(cin >> in))return 0;
      s+=in+'0';
    }

    cout << res[s]-1 << endl;
  }

  return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#define rep( i, n ) for ( i = 0 ; i < n ; i++ )
typedef long long ll ;
using namespace std ;

int main()
{
  int a = 0 ;
  int b = 0 ;
  int c = 0 ;
  
  cin >> a  >> b >> c ;

  int ans
    = c - (a-b) > 0
    ? c - (a-b)
    : 0 ;
  cout << ans << endl ;
  
  return 0 ; 
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int N;
  cin >> N;
  long ans = 0;
  for (int i = 0; i < N; i++)
  {
    int l, r;
    cin >> l >> r;
    ans += (r - l + 1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
require 'pp'

# Nと空白区切の入力値を数値の配列で返却する
def gets_n_and_i_list()
  return gets.chomp.to_i, gets.chomp.split(" ").map(&:to_i)
end

N, a_list = gets_n_and_i_list
a_hash = a_list.map.with_index do |a, i|
  [a, i+1]
end.to_h

ans = []
N.times do |i|
  ans.push(a_hash[i+1])
end
puts ans.join(" ")

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

using namespace std;

//#define debug

#ifdef debug
#define mode cout << "--- debug mode ---" << endl
#define dump(i) cout << "[*] " #i ": " << i << " (line: " << __LINE__ << ")" << endl
#else
#define mode
#define dump(i)
#endif

constexpr int MAX = 100001;

int main() {
  mode;

  bool table[MAX];
  dump("asdf");
  for (int i = 0; i < MAX; ++i) {
    table[i] = true;
  }
  for (int i = 2; i < sqrt(MAX); ++i) {
    if (table[i]) {
      for (int j = 0; i * (j + 2) < MAX; ++j) {
        table[i * (j + 2)] = false;
      }
    }
  }
  table[0] = false;
  table[1] = false;

  int num[100001];
  for (int i = 0; i < 100001; ++i) {
    if (table[i] && table[(i + 1) / 2]) {
      num[i] = 1;
    } else {
      num[i] = 0;
    }
  }

  for (int i = 0; i < 100000; ++i) {
    num[i + 1] = num[i + 1] + num[i];
  }

  int q;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int f, s;
    cin >> f >> s;
    cout << num[s] - num[f - 1] << endl;
  }

  return 0;
}

Measured memory_bytes: 1152
# include <bits/stdc++.h>
    # define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    # define int long long
      
    using namespace std;
      
    const int N = 1e3 + 7;
    const int INF = 1e18;
    const int mod = 1e9 + 7; 
      
    int32_t main() {
        speed;
    	int k, ans = 0;
    	cin >> k;
     
    	for ( int a = 1; a <= k; a++ ) {
    		for ( int b = 1; b <= k; b++ ) {
    			for ( int c = 1; c <= k; c++ ) {
    				ans += __gcd( __gcd( a, b), c );
    			}
    		}
    	}
    	cout << ans;
    }

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

ll wt[102], val[102];
ll dp[102][100002];

int main() {

  int n, w;
  cin >> n >> w;
  for (int i = 1; i <= n; ++i) cin >> wt[i] >> val[i];

  for (int pos = 1; pos <= n; ++pos) {
    for (int s = 0; s <= w; ++s) {
      dp[pos][s] = dp[pos - 1][s];
      if ( s - wt[pos] >= 0 ) 
        dp[pos][s] = max( dp[pos][s], val[pos] + dp[pos - 1][s - wt[pos]] );
    }
  }

  cout << dp[n][w] << endl;
  return 0;
}

Measured memory_bytes: 78336
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
int main()
{
    int a;
    long long x=0,y=0,mi=0,sum=0;
    int s[200005];
    cin>>a;
    for(int i=0;i<a;i++)
    {
        cin>>s[i];
    }
    for(int i=0;i<a;i++)
    {
        sum+=s[i];
        mi+=abs(s[i]);
    }
    for(int i=0;i<a-1;i++)
    {
        x+=s[i];
        y=sum-x;
       if(x-y<0)
       {
           if(mi>y-x) mi = y-x;
       }
       if(x-y>=0)
       {
           if(mi>x-y) mi = x-y;
       }
    }
    cout<<mi<<endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,mod,C[3030][3030],S[3030][3030],pom[3030],po[3030],ans;
inline int kpow(int a,int b)
{
	int s=1;
	for(;b;b>>=1,a=1ll*a*a%mod)
		if(b&1)s=1ll*s*a%mod;
	return s;
}
int main()
{
	scanf("%d %d",&n,&mod);
	for(int i=0;i<=n;++i)
	{
		S[i][0]=i==0;
		for(int j=1;j<=n;++j)S[i][j]=(S[i-1][j-1]+1ll*S[i][j-1]*(i+1))%mod;
	}
	for(int i=0;i<=n;++i)
	{
		C[i][0]=1;
		for(int j=1;j<=i;++j)(C[i][j]=C[i-1][j-1]+C[i-1][j])>=mod?C[i][j]-=mod:0;
	}
	pom[0]=2,po[0]=1;
	for(int i=1;i<=n;++i)pom[i]=1ll*pom[i-1]*pom[i-1]%mod,po[i]=(po[i-1]<<1)%mod;
	for(int i=0;i<=n;++i)
	{
		int res=0,w=1;
		for(int j=0;j<=n;++j)res=(res+1ll*S[j][i]*pom[n-i]%mod*w)%mod,w=1ll*w*po[n-i]%mod;
		if(i&1)ans=(ans+1ll*(mod-res)*C[n][i])%mod;
		else ans=(ans+1ll*res*C[n][i])%mod;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 71808
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    int n, k;
    cin >> n >> k;
    map<int, int> m;
    rep(i, n)
    {
        int a;
        cin >> a;
        m[a]++;
    }
    vector<pair<int, int>> mm;
    for (auto &i : m)
    {
        mm.push_back({-i.second, i.first});
    }
    int ans = 0;
    sort(all(mm));
    for (auto &i : mm)
    {
        //        cout << i.first << " " << i.second << endl;
    }

    for (int i = 0; i < k; i++)
    {
        if (i >= mm.size())
        {
            break;
        }
        ans += mm[i].first;
    }
    cout << n + ans << endl;
    //    cout << mm.size() << endl;
    return 0;
}

Measured memory_bytes: 12792
def main():
    N = int(input())
    S = input()
    MOD = 10**9 + 7
    from collections import Counter
    c = Counter(S)
    ans = 1
    for v in c.values():
        ans *= (v+1)
        ans %= MOD
    print(ans-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39408
def main(n, k):
    no_sweet = [x + 1 for x in range(n)]
    for _ in range(k):
        input()
        for v in map(int, input().split()):
            if v in no_sweet:
                no_sweet.remove(v)
    print(len(no_sweet))


if __name__ == "__main__":
    n, k = map(int, input().split())
    main(n, k)


Measured memory_bytes: 9168
# -*- coding:utf-8 -*-

def main():
    while True:
        try:
            v=float(input())

            flag=True
            i=1

            while flag:
                h=19.6*(5*i-5)
                if h>=v**2:
                    flag=False
                    print(i)

                elif h<v**2:
                    i+=1

        except:
            break
            
    
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 7428
#include<stdio.h>
#include<string.h>
#define N 1001

void LCS(char *x,char *y){
  int i,j,m,n;
  int c[N][N];
  n=strlen(x);
  m=strlen(y);
  for(i=1;i<=n;i++) c[i][0]=0;
  for(j=0;j<=m;j++) c[0][j]=0;
  
  for(i=1;i<=n;i++){
    for(j=1;j<=m;j++){
      if(x[i-1]==y[j-1]) c[i][j] = c[i-1][j-1]+1;
      else  if(c[i-1][j]>=c[i][j-1]) c[i][j] = c[i-1][j];
      else c[i][j]=c[i][j-1];
    }
  }
  printf("%d\n",c[n][m]);
}



int main(){
  int n,i;
  char x[N],y[N];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%s",x);
    scanf("%s",y);
    LCS(x,y);
  }
  return 0;
}

Measured memory_bytes: 4520
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
int a,b,c,d;
a= s[0]-'0';
b= s[1]-'0';
c= s[2]-'0';
d= s[3]-'0';
int month = a*10+b;
int year= c*10 +d;
if(month<=12 && month>0&&year<=12 &&year>0){cout<<"AMBIGUOUS";}
else if(month<=12&&month>0){cout<<"MMYY";}
else if(month>12||month<=0){
    if(year>12||year<=0){cout<<"NA";}
    else cout<<"YYMM";
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define _GLIBCXX_DEBUG
int main()
{
    int n,m;
    cin>>n;
    vector<string> s(n);
    rep(i,n)cin>>s[i];
    cin>>m;
    vector<string> t(m);
    rep(i,m)cin>>t[i];
    vector<int> b(n),r(n),get(n);
    rep(i,n){
        rep(j,n){
            if(s[i]==s[j])b[i]++;
        }
        rep(k,m){
            if(s[i]==t[k])r[i]++;
        }
        get[i]=b[i]-r[i];
    }
    sort(begin(get),end(get),greater<int>());
    if(get[0]>=0)cout<<get[0]<<endl;
    else cout<<0<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
 
int main() {
    char str[1200];
    int i;
    gets(str);
    for (i = 0; str[i]; i++) {
        if (islower(str[i])) {
            printf("%c", toupper(str[i]));
        } else {
            printf("%c", tolower(str[i]));
        }
    }
    printf("\n");
    return 0;
}

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

int main() {
	string str; cin >> str ;
    if ( (str[0] == str[1] && str[1] == str[2] ) || ( str[1] == str[2] && str[2] == str[3] )  ) 
      cout << "Yes" ;
    else cout << "No" ;
}

Measured memory_bytes: 256
def solve():
	s=input()
	if(len(s)%2==0):
		print("No")
		return 
	else :
		n=len(s)//2
		str1=s[:n]
		str2=s[n+1:]
		# print(str1,str2)
		if(str1==str2):
			print("Yes")
		else:
			print("No")
if __name__ == "__main__":
	solve()

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

using namespace std;

int vy[] = {1, 0, -1, 0};
int vx[] = {0, 1, 0, -1};
bool field[12][12], chk[12][12];

void dfs(int y, int x){
  chk[y][x] = true;
  for(int i = 0; i < 4; ++i){
    int ny = y + vy[i];
    int nx = x + vx[i];
    if(ny >= 0 && ny < 12 && nx >= 0 && nx < 12 && field[ny][nx] && !chk[ny][nx]) dfs(ny, nx);
  }
}

int main(){

  int cnt;
  char bit;

  while(1){

    cnt = 0;
    
    for(int i = 0; i < 12; ++i){
      for(int j = 0; j < 12; ++j){
	cin >> bit;
	field[i][j] = (bit - '0') ? 1 : 0;
      }
    }
    
    if(cin.eof()) break;

    for(int i = 0; i < 12; ++i){
      for(int j = 0; j < 12; ++j){
	chk[i][j] = false;
      }
    }
    
    for(int i = 0; i < 12; ++i){
      for(int j = 0; j < 12; ++j){
	if(field[i][j] && !chk[i][j]){
	  dfs(i, j);
	  ++cnt;
	}
      }
    }
    
    cout << cnt << endl;

  }
  
}

Measured memory_bytes: 1144
/**
 *    Creator :  bizarre
 *    Date : 4/2020
 *    Problem Number : 425
**/
#include <bits/stdc++.h>
using namespace std;
#define bizarre     ios_base::sync_with_stdio( false ), cin.tie( nullptr ), cout.tie( nullptr );
/*
vector<int> prime_Numbers;
int primes[1000005];
void prime(int n)
{
    primes[1]=primes[0]=0;
    for(int i=2; i<=n; i++)
        primes[i]=true;
    for(int i=2; i<=n; i++)
    {
        if(primes[i]==true)
        {
            prime_Numbers.push_back(i);
            for(int j=i+i; j<=n; j+=i)
                primes[j]=false;
        }
    }
    for(int i=2; i<=n; i++)
        primes[i]+=primes[i-1];
}

void move1step(long long& a, long long& b, long long q)
{
    long long c= a-q*b;
    a=b;
    b=c;
}
long long egcd(long long r0,long long r1,long long& x0,long long& y0)
{
    long long x1=0,y1=1;
    x0=1;
    y0=0;
    while(r1)
    {
        long long q=r0/r1;
        move1step(r0,r1,q);
        move1step(x0,x1,q);
        move1step(y0,y1,q);
    }
    return r0;
}
bool  solve (long long a, long long b, long long c,long long&x, long long& y)
{
    long long g=egcd(a,b,x,y);
    int m=c/g;
    x*=m;
    y*=m;
    return c%g==0;
}



int npr(long long n, long long r)
{
    return (fact[n] * inv[n - r]) % mod;
}

int gcd(int a, int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
void PrimeFactorization(int n)
{
    for(int i=2; i*i<=n; i++)
    {
        int c=0;
        if(n%i==0)
        {
            while(n%i==0)
            {
                n/=i;
            }

        }
    }

}
const int inf = 2e9, mod = 1e9 + 7,N=1e5+5;
long long fact[N], inv[N];
long long fp(long long base, long long exp)
{
    if (exp == 0)
        return 1;
    long long ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}
void pre(long long n)
{
    fact[0] = 1;
    inv[0] = 1;
    for (long long i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}
int ncr(long long n, long long r)
{
    return (((fact[n] * inv[n - r]) % mod) * inv[r]) % mod;
}
long long ncrtane(long long n, long long r)
{
    long long ans=1,cntr=1;
    for(int i=n;i>n-r;i--)
    {
        ans*=i;
        ans/=cntr;
        cntr++;
    }
    return ans;
}
*/
int dp[3003][3003];
int main()
{
    bizarre
    string s,t;
    cin>>s>>t;
    memset(dp,0,sizeof dp);
    for(int i=1;i<=s.size();i++)
    {
        for(int j=1;j<=t.size();j++)
        {
            if(s[i-1]==t[j-1])
                dp[i][j]=dp[i-1][j-1]+1;
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    int i=s.size();
    int j=t.size();
    string c="";
    while(i&&j)
    {
        if(s[i-1]==t[j-1])
        {
            c+=s[i-1];
            i--;
            j--;
        }
        else
        {
            if(dp[i-1][j]>=dp[i][j-1])
                i--;
            else
                j--;
        }
    }
    reverse(c.begin(),c.end());
    cout << c;
    return 0;
}


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

int main(int argc, const char * argv[]) {
    uint32_t N;
    cin >> N;
    
    uint32_t n = N % 10;
    switch (n) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon";
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon";
            break;
        default:
            cout << "bon";
            break;
    }

    return 0;
}


Measured memory_bytes: 3572
import sys
sys.setrecursionlimit(10 ** 7)

H, W = map(int, input().split())
F = [list(input()) for _ in range(H)]

move = [(-1, 0), (1, 0), (0, -1), (0, 1)]
seen = [[0] * W for _ in range(H)]

# Fの点を頂点とするグラフを考える。グラフの連結成分に'#'がbコ, '.'がwコある場合、
# b*wが条件を満たす

def dfs(sy, sx):
    seen[sy][sx] = 1
    b, w = 1, 0
    
    for dy, dx in move:
      ny = sy + dy
      nx = sx + dx
      if 0 <= ny < H and 0 <= nx < W and F[ny][nx] != F[sy][sx] and not seen[ny][nx]:
        p = dfs(ny, nx)
        b += p[1]  # 逆にしている
        w += p[0]  # 天才か？
    return (b, w)
        
count = 0
for i in range(H):
    for j in range(W):
        if not seen[i][j]:
            b, w = dfs(i, j)
            count += b * w

print(count)

Measured memory_bytes: 157448
#include<iostream>
using namespace std;
int main()
{
int n,i,s=0,min=1005893,b;	
cin>>n;
for(i=0;i<n;i++)
{
cin>>b;	
if(min>b)
{
min=b;
s++;	
}
}	
cout<<s<<endl;	
	
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int time[86400]={},h,m,s,i,n,sum,ans;
  while(scanf("%d",&n)){
    if(n==0) break;
    for(i=0;i<n;i++){
      scanf("%d:%d:%d",&h,&m,&s);
      s+=3600*h+60*m;
      time[s]+=1;
      scanf("%d:%d:%d",&h,&m,&s);
      s+=3600*h+60*m;
      time[s]-=1;
    }
    ans=0;
    sum=0;
    for(i=0;i<86400;i++){
      sum+=time[i];
      time[i]=0;
      if(sum>ans) ans=sum;
    }
    printf("%d\n",ans);
  }
  return 0;
}




Measured memory_bytes: 2080
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        int result = 0;
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        Integer stick[] = new Integer[n];
        
        for (int i=0; i < n; i++){
            stick[i] = sc.nextInt();
        }
            
        Arrays.sort(stick,Collections.reverseOrder());
        
        int sum = 0;
        
        for (int i=0; i < k; i++){
            sum += stick[i];
        }
        
        System.out.println(sum);
        
        sc.close();
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define M 1000005
#define ll long long

ll n, p;

int main(){
	cin >> n >> p;
	if (n == 1){
		cout << p;
		return 0;
	}
	for (ll i = (ll)sqrt(p); i > 0; i--){
		if (p % (ll)pow(i, n) == 0){
            cout << i;
            break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
def div(x):
    a = x //(-2)
    if a*(-2) > x:
        a+=1
    return a
n = int(input())
bi = ""
flag = 0
if n == 0:
    flag = 1
while n != 0:
    x = div(n)
    if n % (-2) != 0:
        bi = "1"+bi
    elif x != 0:
        bi = "0"+bi 
    n = x
print("0" if flag == 1 else bi)

Measured memory_bytes: 3064
local l = io.read("*n")
local fact = {}
local c = 1
while c * 2 <= l do
  table.insert(fact, c)
  c = c * 2
end
local ret = {}
local n = #fact + 1
for i = 1, n - 1 do
  table.insert(ret, {i, i + 1, 0})
  table.insert(ret, {i, i + 1, fact[i]})
end
local rem = l - 1 - (2 * fact[#fact] - 1)
local offset = 2 * fact[#fact]
for i = #fact, 1, -1 do
  if fact[i] <= rem then
    table.insert(ret, {i, n, offset})
    rem = rem - fact[i]
    offset = offset + fact[i]
  end
end
print(n .. " " .. #ret)
for i = 1, #ret do
  print(ret[i][1] .. " " .. ret[i][2] .. " " .. ret[i][3])
end


Measured memory_bytes: 508
H, W = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(10)]
for i in range(10):
    for k in range(10):
        for l in range(10):
            C[k][l] = min(C[k][l], C[k][i]+C[i][l])
ans = 0
for _ in range(H):
    k = list(map(int, input().split()))
    for i in k:
        if i == -1:
            continue
        ans += C[i][1]
print(ans)

Measured memory_bytes: 9144
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
S = []
c = 0
s = sum(A)
table = [0] * 100010
# A = pd.Series(A)
# for a in A:
#     print(a)

for i in A:
    table[i] += 1

for i in range(Q):
    B, C = map(int,input().split())
    # if B in A:
    # c = A.count(B)
    c = table[B]
    s += (C - B) * c
    table[C] += table[B]
    table[B] = 0
    # print(s)
        # print((C - B) * c) 
        # string = ",".join(A)
        # string_new = string.replace(B,C)
        # A =  string_new.split(",")
        # s = sum(map((lambda x: int(x)), A))
    S.append(s)

        # A.replace(B, C,c)
        # while B in A:
        #     A[A.index(B)] = C
    # for a in A:
    #     print(a)
    # else:
        # S.append(s)



for s in S:
    print(s)


Measured memory_bytes: 20864
#include <bits/stdc++.h>
using namespace std;
static const int N = 1e5 + 4;
static const int LN = 19;

int mx, my, n;

inline int get_point(int x, int y)
{
    if (y == 0) return x;
    if (x == mx) return mx + y;
    if (y == my) return mx + my + (mx - x);
    if (x == 0) return mx + my + mx + (my - y);
    return -1;
}

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

typedef pair<int, int> num;
vector<num> c;
map<int, int> dis;

int a[N * 2];

struct rmq
{
    int min[LN][N * 2], max[LN][N * 2];
    inline void build(int n, int *a)
    {
        for (int i = 0; i < n; i ++) min[0][i] = max[0][i] = a[i];
        for (int j = 1; j < LN; j ++)
            for (int i = 0; i < n - (1 << j); i ++)
            {
                max[j][i] = std::max(max[j - 1][i], max[j - 1][i + (1 << (j - 1))]);
                min[j][i] = std::min(min[j - 1][i], min[j - 1][i + (1 << (j - 1))]);
            }
    }
    inline pair<int, int> query(int l, int r)
    {
        if (l == r) return make_pair(min[0][l], max[0][l]);
        int sz = 8 * sizeof(int) - __builtin_clz(r - l) - 1;
        return make_pair(
            std::min(min[sz][l], min[sz][r - (1 << sz) + 1]),
            std::max(max[sz][l], max[sz][r - (1 << sz) + 1])
        );
    }
}rmq;

int main()
{
   	mx = read();
   	my = read();
   	n = read();
    for (int i = 0, x1, y1, x2, y2; i < n; ++i)
    {
        scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
        int p1 = get_point(x1, y1),
            p2 = get_point(x2, y2);
        if (p1 != -1 && p2 != -1)
        {
            if (p1 > p2) swap(p1, p2);
            c.push_back(num(p1, p2));
            dis.insert(make_pair(p1, 0));
            dis.insert(make_pair(p2, 0));
        }
    }
    int ct = 0;
    for (auto &kv : dis) kv.second = ct ++;
    for (auto &p : c)
    {
        p.first = dis[p.first], p.second = dis[p.second];
        a[p.first] = p.second;
        a[p.second] = p.first;
    }
    rmq.build(ct, a);

    sort(c.begin(), c.end());
    for (auto p : c) if (p.second >= p.first + 2)
    {
        auto val = rmq.query(p.first + 1, p.second - 1);
        if (val.first < p.first || val.second > p.second)
        {
            puts("NO");
            return 0;
        }
    }

    puts("YES"); return 0;
}


Measured memory_bytes: 39796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int x,y,z;
    cin >> x >> y >> z;
    cout << (x-z) / (y+z) << endl;
}


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


int main()
{
    int n;
    cin >> n;
    vector<int> a;
    rep(i, n){ int tmp; cin >> tmp; a.push_back(tmp);}

    double ans_div = 0;
    rep(i, n){
        ans_div += (double)1.0 / a[i];
    }
    printf("%.15f\n", (double)1/ans_div);
}



Measured memory_bytes: 256
h,w = map(int,input().split())
A = [list(input()) for i in range(h)]
mod = 10**9+7
dp = [[0]*w for i in range(h)]
dp[0][0] = 1
for y in range(h):
    for x in range(w):
        if A[y][x] == '#':
            dp[y][x] = 0
        else:
            if y != 0:
                dp[y][x] += dp[y-1][x]
            if x != 0:
                dp[y][x] += dp[y][x-1]
            dp[y][x] %= mod
print(dp[-1][-1])


Measured memory_bytes: 87664
#include <iostream>
using namespace std;
int main(void){
  int n,k,p;
  cin >> n;
  for(int i=0; i<n; i++){
      cin >> k >> p;
      int x;
      x=k%p;
      if(x==0){
          cout << p << endl;
      }
      else{
          cout << x << endl;
      }
  }
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int N; cin >> N;
    vector<int> A(N); unordered_map<int, int> mp;
    REP(i, 0, N) {
        cin >> A[i]; mp[A[i]] = i;
    }

    sort(ALL(A));

    int ans = 0;
    REP(i, 0, N) {
        if ((i % 2 == 0) != (mp[A[i]] % 2 == 0)) ans++;
    }
    cout << ans / 2 << endl;
    return 0;
}

Measured memory_bytes: 7712
n,m,x = map(int,input().split())
a = list(map(int,input().split()))

if x >= max(a) or x <= min(a):
    print(0)
else:
    cnt = 0
    for i in range(m):
        if a[i] > x:
            cnt += 1
    print(min(cnt,len(a)-cnt))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	char a , b;
	scanf(" %c %c" , &a , &b);
	if(a == 'H')
	{
		printf("%c\n" , b == 'H' ? 'H' : 'D');
	}
	else
	{
		printf("%c\n" , b == 'H' ? 'D' : 'H');
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

const ll mod = 998244353;
const ll sz = 5e5;

ll fact[sz];

ll bpow(ll x, ll p) {
	if (p == 0)
		return 1;
	if (p % 2)
		return (bpow(x, p - 1) * x) % mod;
	else {
		ll b = bpow(x, p / 2);
		return (b * b) % mod;
	}
}

ll inv(ll a) {
	return bpow(a, mod - 2);
}

ll cnk(ll n, ll k) {
	return fact[n] * inv(fact[n - k]) % mod * inv(fact[k]) % mod;
}

inline void solve() {
	ll n, m, k;
	cin >> n >> m >> k;
	ll otv = 0;

	fact[0] = 1;
	for (int i = 1; i < sz; i++) {
		fact[i] = (fact[i - 1] * i) % mod;
	}


	for (int i = 0; i <= k; i++) {
		ll b = n - i;
		otv += (cnk(n - 1, b - 1) * m % mod * bpow(m - 1, b - 1)) % mod;
		otv %= mod;
	}

	cout << otv;
}

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

Measured memory_bytes: 7556
#include <cstdio>
#include <algorithm>
using namespace std;

int main(int argc, char *argv[]) {
	char rcv[21];
	char out[21];
	fscanf(stdin, "%s\n", rcv);
	int cnt = 0;
	for (int i = 0; i < 21; i++) {
		if (rcv[i] == '\0') {
			for (int j = i-1; j !=-1; j--) {
				out[cnt] = rcv[j];
				cnt++;
			}
			out[cnt] = '\0';
			break;
		}
	}
	printf("%s\n", out);
	
	return 0;
}

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

int main() {
    string s, t;
    int q, r = 0;
    cin >> s >> q;
    for(int i = 0; i < q; i++) {
        int x;
        cin >> x;
        if(x < 2) {
            r = !r;
            continue;
        }
        char c;
        cin >> x >> c;
        (r ^ x&1 ? t : s) += c;
    }
    reverse(t.begin(), t.end());
    t += s;
    if(r)
        reverse(t.begin(), t.end());
    cout << t << endl;
    return 0;
}


Measured memory_bytes: 1128
#include<bits/stdc++.h>
using namespace std;
long long a,b,n;
long long check(long long x)
{
	return a*x/b-a*(x/b);
}
int main()
{
	cin>>a>>b>>n;
	long long l=0,r=n,ans=0;
	while(r-l>=1000000)
	{
		long long lmid=l+(r-l)/3,rmid=r-(r-l)/3;
		if(check(lmid)<=check(rmid))
			l=lmid;
		else
			r=rmid;
	}
	while(l<=r&&l<=n)
	{
		ans=max(ans,check(l));
		l++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstring>
#define INF 100000000
#define W 100
#define H 100
using namespace std;
char s[W][H];
int dp[W][H];
int h,w;
int func(int y,int x){
	if(dp[y][x]!=-1)
	return dp[y][x];
	if(y==h-1&&x==w-1)
		return dp[y][x]=s[y][x]-'0';
	int a=INF,b=INF;
	if(y+1<h)
	a=func(y+1,x)+s[y][x]-'0';
	if(x+1<w)
	b=func(y,x+1)+s[y][x]-'0';
	//if(y==1&&x==2)
	//cout<<a<<"    "<<b<<' '<<endl;
	return dp[y][x]=min(a,b);
}
int main(){
	cin>>h>>w;
	for(int i=0;i<h;i++)
		cin>>s[i];
	memset(dp,-1,sizeof(dp));
	cout<<func(0,0)<<endl;
	/*for(int i=0;i<h;i++){
	for(int j=0;j<w;j++)
		cout<<dp[i][j];
		cout<<endl;
	}
	*/
	return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n;
    string s,t;
    cin >> n >> s >> t;
    for(int i = 0;i < s.size();i++)
    {
        bool flag = true;
        for(int j = 0;i + j < s.size();j++)
        {
            if(s[i + j] != t[j])
            {
                flag = false;
                break;
            }
        }
        if(flag)
        {
            cout << i + t.size() << "\n";
            return 0;
        }
    }
    string r = s + t;
    cout << r.size() << "\n";

    return 0;
}

Measured memory_bytes: 256