akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays
import java.util.ArrayList
import java.util.ArrayDeque

const val MOD: Long = (1e9+7).toLong()
fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun <T : Comparable<T>> Iterable<T>.argmax(): Int? = withIndex().maxBy{it.value}?.index
fun <T : Comparable<T>> Iterable<T>.argmin(): Int? = withIndex().minBy{it.value}?.index

fun main(args: Array<String>) {
    val reader = System.`in`.bufferedReader()
    val (n, m) = reader.readLine()!!.split(" ").map{it.toInt()}
    val l = Array(m, {0})
    val r = Array(m, {0})
    for (i in 0..m-1) {
        val (x, y) = reader.readLine()!!.split(" ").map{it.toInt()}
        l[i] = x
        r[i] = y
    }
    l.sort()
    r.sort()

    val x = l.last()
    val y = r[0]

    if (y >= x) {
        println(y+1-x)
    } else {
        println(0)
    }
}


Measured memory_bytes: 60708
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    int W,H,N;
    cin >> W >> H >> N;
    int minx=0,miny=0,maxx=W,maxy=H;
    rep(i,N){
        int x,y,a;
        cin >> x >> y >> a;
        if(a==1) minx=max(minx,x);
        if(a==2) maxx=min(maxx,x);
        if(a==3) miny=max(miny,y);
        if(a==4) maxy=min(maxy,y);
    }
    int ans=(maxx-minx)*(maxy-miny);
    if(minx>maxx || miny>maxy) ans=0;
    cout << ans << endl;
}

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

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define FOR(n) for(int i = 0;i < n;i++)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define ipow(x,y) LL(pow(x,y))

//Debug
#define TEST cout << "OK\n"

const double PI = M_PI;
const long long INF = int(999999999);
const long long MOD = int(1000000007);

//Settings
const bool DO_BENCHMARK = false;
const int DOUBLE_ACCURACY = 15;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    void solve();
    if(DO_BENCHMARK){
        clock_t clock_start = clock();
        solve();
        clock_t clock_end = clock();
        const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
        cout << "\n" << time << "[ms]\n";
    }
    else solve();
}

void solve(){
    LL N, A, B;
    cin >> N >> A >> B;
    LL ans = 0;
    if(abs(A-B)%2==1){
        ans = min(N-max(A,B),min(A,B)-1);
        ans++;
        if(N-max(A,B) < min(A,B)-1){
            if(A > B){
                A = N;
                B += ans;
            }
            else{
                B = N;
                A += ans;
            }
        }
        else{
            if(A < B){
                A = 1;
                B -= ans;
            }
            else{
                B = 1;
                A -= ans;
            }
        }
    }
    ans += abs(A-B)/2;
    cout << ans << endl;
}


Measured memory_bytes: 256
from math import sqrt
from functools import reduce

N = int(input())

def koch(p1, p2, n):
	if n == 0:
		return [p1, p2]
	else:
		c1 = [(2*p1[0] + p2[0])/3, (2*p1[1] + p2[1])/3]
		c3 = [(p1[0] + 2*p2[0])/3, (p1[1] + 2*p2[1])/3]
		c2 = [(p1[0] + p2[0]) / 2 + 1/sqrt(3) * (p1[1] - p2[1])/2, (p1[1] + p2[1]) / 2 + 1/sqrt(3) * (p2[0] - p1[0])/2]
		return koch(p1, c1, n-1)[:-1] + koch(c1, c2, n-1)[:-1] + koch(c2, c3, n-1)[:-1] + koch(c3, p2, n-1)


for p in koch([0.0, 0.0], [100.0, 0.0], N):
	print('{:.6f} {:.6f}'.format(p[0], p[1]))



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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type / Class / Struct Definitions:
using ll = long long;
using ull = unsigned long long;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    string str;
    cin >> str;
    stack<int> pt;
    stack<pair<int, int>> area;
    rep(i, str.size()) {
        if(str[i] == '\\') {
            pt.push(i);
        } else if(str[i] == '/' && !pt.empty()) {
            int j = pt.top();
            int a = i - j;
            pt.pop();
            if(area.empty()) {
                area.push(make_pair(j, a));
            } else {
                while(!area.empty()) {
                    if(area.top().first > j) {
                        a += area.top().second;
                        area.pop();
                    } else {
                        break;
                    }
                }
                area.push(make_pair(j, a));
            }
        }
    }

    //put ans
    vector<int> ans;
    while(!area.empty()) {
        ans.emplace_back(area.top().second);
        area.pop();
    }
    reverse(all(ans));
    int sum = 0;
    rep(i, ans.size()) {
        sum += ans[i];
    }
    cout << sum << endl;
    cout << ans.size();
    rep(i, ans.size()) {
        cout << " " << ans[i];
    }
    cout << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}


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

int main()
{

    int num;
    std::cin >> num;

    int ini = num / 100;
    int ter = num % 100;

    if(1<=ini && ini<=12)
    {
        if(1<=ter && ter<=12)
            std::cout << "AMBIGUOUS" << std::endl;
        else
            std::cout << "MMYY" << std::endl;
    }
    else
    {
        if (1<=ter&&ter<=12)
            std::cout << "YYMM" << std::endl;
        else
            std::cout << "NA" << std::endl;
    }


    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scanner =new Scanner(System.in);
		String lineA = scanner.next();
		String lineB = scanner.next();
		String lineC = scanner.next();

		String next = lineA.substring(0,1);
		lineA = lineA.substring(1);
		while (true) {
			if (next.equals("a")) {
				if (lineA.length() == 0) {
					System.out.println("A");
					break;
				}else{
					next = lineA.substring(0,1);
					lineA = lineA.substring(1);
				}
			}else if (next.equals("b")) {
				if (lineB.length() == 0) {
					System.out.println("B");
					break;
				}else{
					next = lineB.substring(0,1);
					lineB = lineB.substring(1);
				}
			}else if (next.equals("c")) {
				if (lineC.length() == 0) {
					System.out.println("C");
					break;
				}else{
					next = lineC.substring(0,1);
					lineC = lineC.substring(1);
				}
			}
		}

		scanner.close();
	}

}


Measured memory_bytes: 27000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;


int main(){
    ll N, X, Y;
    cin>>N>>X>>Y;
    X--;
    Y--;
    vector<ll> D(N, 0);
    rep(i, N){
        rep(j, N){
            if(i>=j)continue;
            ll K=abs(i-X)+1+abs(j-Y);
            K=min(K, j-i);
            D[K]++;

        }
    }
    rep(i, N-1){
        cout<<D[i+1]<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
// template {{{

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

#define loop(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) loop(i, 0, n)
#define rloop(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define rrep(i, n) rloop(i, 0, n)
#define eb emplace_back
#define ef emplace_front
#define pb pop_back
#define pf pop_front
#define all(c) std::begin(c), std::end(c)
#define mp std::make_pair
#define mt std::make_tuple
#define fi first
#define se second
#define popcnt __builtin_popcountll

using uint = unsigned;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

template<typename T>
using max_pq = priority_queue<T, vector<T>, less<T>>;

template<typename T>
using min_pq = priority_queue<T, vector<T>, greater<T>>;

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

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
const int dx8[] = {-1, -1, 0, 1, 1, 1, 0, -1};
const int dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
inline T sq(T x){ return x * x; }

template<typename T, typename U>
inline bool chmax(T &x, U y){ if (x >= y) return false; x = y; return true; }

template<typename T, typename U>
inline bool chmin(T &x, U y){ if (x <= y) return false; x = y; return true; }

template<typename T>
inline void sort(T &c){ std::sort(std::begin(c), std::end(c)); }

template<typename T>
inline void reverse(T &c){ std::reverse(std::begin(c), std::end(c)); }

template<typename T>
inline void unique(T &c){ std::sort(std::begin(c), std::end(c)); c.erase(std::unique(all(c)), std::end(c)); }

// }}}

struct FenwickTree {
	FenwickTree(size_t n): n(n), val(n + 1){}
	
	void chmax(int k, ll x){
		k++;
		while (k <= n){
			::chmax(val[k], x);
			k += k & -k;
		}
	}

	ll max(int k){
		ll res = 0;
		while (k > 0){
			::chmax(res, val[k]);
			k -= k & -k;
		}
		return res;
	}

private:
	int n;
	vector<ll> val;
};

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

	FenwickTree t(n + 1);
	rep(i, n){
		int x;
		cin >> x;
		t.chmax(x, t.max(x) + x);
	}

	cout << (ll)n * (n + 1) / 2 - t.max(n + 1) << endl;
}

Measured memory_bytes: 3620
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

using graph = vector<vector<PII>>;

void dfs(const graph &g, VI &c, int u, int col) {
	c[u] = col;
	for (auto v : g[u]) {
		if (c[v.first] != -1)continue;
		dfs(g, c, v.first, (col + v.second) & 1);
	}
}

int main() {
	int n;
	scanf("%d", &n);
	
	auto g = graph(n);
	REP(i, n-1) {
		int u, v, w;
		scanf("%d%d%d", &u, &v, &w);
		u--, v--;
		g[u].PB(MP(v, w % 2));
		g[v].PB(MP(u, w % 2));
	}
	VI color(n, -1);
	dfs(g, color, 0, 0);
	REP(i, n) {
		printf("%d\n", color[i]);
	}
	return 0;
}

Measured memory_bytes: 8192
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

int main()
{
    int n, k; cin>>n>>k;
    vector<int> p(n);
    vector<double> s(n+1);
    for(auto& e: p) cin>>e;
    for(int i=0; i<n; ++i)
        s[i+1]=s[i]+(p[i]+1)*0.5;

    double res=0;
    for(int i=k; i<=n; ++i)
        res=max(res, s[i]-s[i-k]);

    printf("%.9f\n", res);

}


Measured memory_bytes: 2560
# -*- coding: utf-8 -*-
"""
Set Operation - Set Union
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_9_A&lang=jp

"""
_ = input()
A = set([int(a) for a in input().split()])
_ = input()
B = set([int(b) for b in input().split()])
print(*sorted(A | B), sep='\n')



Measured memory_bytes: 69200
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <map>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<int> v(n);
	long long sum = 0;
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
		sum += v[i];
	}
	if (n == 1) {
		cout << "YES" << endl;
		return 0;
	}
	long long val = n * 1LL * (n + 1) / 2;
	if (sum % val) {
		cout << "NO" << endl;
	} else {
		long long cnt = sum / val;
		vector<long long> res(n);
		for (int i = 0; i < n; ++i) {
			long long diff = v[i] - v[(i - 1 + n) % n];
			long long val = cnt - diff;
			if (val < 0 || val % n) {
				cout << "NO" << endl;
				return 0;
			} else {
				res[(i - 1 + n) % n] = val / n;
			}
		}

		long long allres = 0;
		for (int i = 0; i < n; ++i) {
			allres += res[i];
		}
		if (allres != cnt) {
			cout << "NO" << endl;
		} else {
			cout << "YES" << endl;
		}
	}
}

Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<math.h>
#define N 2000005
using namespace std;

int a[N],b[N],k,lena,lenb;

void swap(int &a,int &b){ int c=a; a=b; b=c; }

int main(){
	scanf("%d%d%d",&lena,&lenb,&k);
	char ch; int llen;
	for (int i=1;i<=lena;i++){ cin>>ch; a[i]=ch-'0'; }
	for (int i=1;i<=lenb;i++){ cin>>ch; b[i]=ch-'0'; }
	for (int i=1;i<=lena/2;i++) swap(a[i],a[lena-i+1]); 
	for (int i=1;i<=lenb/2;i++) swap(b[i],b[lenb-i+1]); 
	int len=max(lena,lenb);
	for (int i=len;i>0;i--){
		int s=0,kk=k;
		while (a[i+s]==1&&b[i+s]==1&&kk>0){
			a[i+s]=0; a[i+s+1]++;
			b[i+s]=0; b[i+s+1]++;
			s++; kk--; 
			int sa=s,sb=s;
			while (a[i+sa]==2){ a[i+sa]=0; a[i+sa+1]++; sa++; }
			while (b[i+sb]==2){ b[i+sb]=0; b[i+sb+1]++; sb++; }
			s=max(sa,sb);
		}
		llen=max(llen,s+i);
	}
	int sa=0,sb=0;
	while (!a[llen-sa]) sa++;
	while (!b[llen-sb]) sb++;
	for (int i=llen-sa;i>0;i--) printf("%d",a[i]);
	printf("\n");
	for (int i=llen-sb;i>0;i--) printf("%d",b[i]);
}

Measured memory_bytes: 19840
n, m = map(int, input().split())
digits = [-1]*n
for _ in range(m):
    s, c = map(int, input().split())
    s -= 1
    if digits[s] == -1 or digits[s] == c:
        digits[s] = c
    else:
        print(-1)
        break
else:
    if n == 1:
        print(0 if digits[0] == -1 else digits[0])
    else:
        if digits[0] == 0:
            print(-1)
        else:
            ans = ''
            for i, d in enumerate(digits):
                if i == 0 and d == -1:
                    ans += '1'
                elif i > 0 and d == -1:
                    ans += '0'
                else:
                    ans += str(d)
            print(ans)


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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH ;//<<"reached line "<<__LINE__<<endl
#define DMP(x) ;//<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

const int Vmax=415;
vi g[Vmax];
int w[Vmax];
bool vis[Vmax],appear[Vmax];
void No(){
	cout<<"NO"<<endl;
	exit(0);
}
void Yes(){
	cout<<"YES"<<endl;
	exit(0);
}
void dfs(int v,vi&dst){
	if(vis[v])return;
	dst.PB(v);
	vis[v]=true;
	for(auto to:g[v])dfs(to,dst);
}

signed main(){
	int n=read(),h=read();
	REP(i,n){
		int a=read(),b=read(),c=read(),d=read();
		int from,to;
		if(c==0)
			from=a-1;
		else
			from=c-1+h;
		if(d==0)
			to=b-1+h;
		else
			to=d-1;
		;//<<from<<" -> "<<to<<endl;
		g[from].PB(to);
		g[to].PB(from);
		w[from]++;
		w[to]--;
		appear[from]=1;
		appear[to]=1;
	}
	REP(i,Vmax)if(appear[i]&&!vis[i]){
		vi idx;
		dfs(i,idx);
		bool s=false,t=false;
		;//<<idx<<endl;
		for(auto j:idx){
			if(w[j]>0){
				s=true;
				if(h<=j)No();
			}else if(w[j]<0){
				t=true;
				if(j<h)No();
			}
		}
		if(!s||!t)No();
	}
	Yes();
}

Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define 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 eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
const int MOD = 1e9+7;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class T>
inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T>
inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    vc<pair<bool,int>> v;
    int A[N],B[N];
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];
    rep(i,N){
        if(!i || A[i-1]!=A[i]){
            v.eb(true,A[i]);
        } else {
            v.eb(false,A[i]);
        }
    }
    int ans=1;
    rep(i,N){
        if(v[N-i-1].fi && v[N-i-1].se>B[N-i-1]){
            ans=0; break;
        }
        if(!i || B[N-i-1]!=B[N-i]){
            if(B[N-i-1]>v[N-i-1].se) {
                ans=0; break;
            }
            v[N-i-1].fi=true;
        }
        chmin(v[N-i-1].se,B[N-i-1]);
    }
    if(ans==0) cout << ans << endl;
    else {
        rep(i,N){
            if(v[i].fi) continue;
            else ans=(ans*v[i].se)%MOD;
        }
        cout << ans << endl;
    }

}

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

signed main(){
	int n=read(),m=read();
	vector<vi> rng(m+1);
	vi cnt(m+1,0);
	REP(i,n){
		int l=read(),r=read()-1;
		rng[l].PB(r);
		cnt[l]++;
	}
	for(int i=m;i>=1;i--)cnt[i-1]+=cnt[i];
	int edgeL=-1,mn=cnt[0];
	REP(i,m){
		mn=min(mn-1,cnt[i+1]-1);
		if(mn<0)break;
		edgeL=i;
	}
	priority_queue<int> pq;
	for(int i=m;i>=0;i--){
		if(i<=edgeL)
			pq.pop();
		for(auto t:rng[i])pq.push(t);
	}
	cnt.assign(m+1,0);
	while(!pq.empty()){
		int t=pq.top();pq.pop();
		cnt[t]++;
	}
	REP(i,m)cnt[i+1]+=cnt[i];
	int edgeR=m;mn=cnt[m];
	for(int i=m-1;i>=0;i--){
		mn=min(mn-1,cnt[i]-1);
		if(mn<0)break;
		edgeR=i;
	}
	cout<<n-min(m,(edgeL+1)+(m-edgeR))<<endl;
}

Measured memory_bytes: 11136
N, M = map(int, input().split(' '))

ans = []
for n in range(N):
    ans.append(0)

for m in range(M):
    a,b = map(int, input().split(' '))
    ans[a-1] += 1
    ans[b-1] += 1

for a in ans:
    print(a)

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	ll a, b, t;cin >> a >> b >> t;
	cout << (t / a) * b << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
  int n, m, x, y, d, cx, cy;
  std::cin >> n >> m;

  if (m > n) {
    x = m;
    y = n;
  } else {
    x = n;
    y = m;
  }

  d = x % y;
  cx = x;
  cy = y;
  while (true) {
    if (d == 0) {
      std::cout << cx << std::endl;
      break;
    } else if (x % y != 0) {
      d = cx % cy;
      cx = cy;
      cy = d;
    
    } else {
      std::cout << d << std::endl;
      break;
    }
  }
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int H, W;
vector<vector<char>> c(50,vector<char>(50));
vector<vector<int>> visit(50, vector<int>(50,0));
int sy = 0, sx = 0;
int gy, gx;
int wall_Count = 0;
int dy[4] = {0, 1, 0, -1};
int dx[4] = {-1, 0, 1, 0};
void bfs(){
    queue<pair<int, int>> que;
    que.push(make_pair(sy,sx));
    
    while(!que.empty()){
        pair<int, int> p = que.front();
        que.pop();
        
        for(int i = 0; i < 4; i++){
            int next_Y = p.first + dy[i];
            int next_X = p.second + dx[i];
            if(next_Y >= 0 && next_X >= 0 && next_Y < H && next_X < W && c[next_Y][next_X] != '#' && visit[next_Y][next_X] == 0){
                visit[next_Y][next_X] = visit[p.first][p.second] + 1;
                if(next_Y == gy && next_X == gx) return;
                
                que.push(make_pair(next_Y, next_X));
            }
        }
        
    }
}


int main(void){
    
    cin >> H >> W;
    gy = H-1; gx = W-1;
    
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> c[i][j];
            if(c[i][j] == '#') wall_Count++;
        }
    }
    
    int square = H * W;
    
    bfs();
    
    int ans = square - (wall_Count + visit[gy][gx]) - 1; // スタート位置があるからマイナス1をしている
    cout << ( (visit[gy][gx] != 0) ? ans : -1) << endl;
}


Measured memory_bytes: 256
def main():
    mod=1000000007
    n,k=map(int,input().split())
    m=2*n
    Fact=[1] #階乗
    for i in range(1,m+1):
        Fact.append(Fact[i-1]*i%mod)
    Finv=[0]*(m+1) #階乗の逆元
    Finv[-1]=pow(Fact[-1],mod-2,mod)
    for i in range(m-1,-1,-1):
        Finv[i]=Finv[i+1]*(i+1)%mod
    def comb(n,r):
        if n<r:
            return 0
        return Fact[n]*Finv[r]*Finv[n-r]%mod
    
    if k>=n-1:
        return comb(2*n-1,n-1)
    ans=1
    for i in range(1,k+1):
        ans+=comb(n,i)*comb(n-1,n-i-1)
        ans%=mod
    return ans
    
if __name__=='__main__':
    print(main())

Measured memory_bytes: 71280
#!/usr/bin/env python
import os
import operator
from collections import defaultdict
import sys
from io import BytesIO, IOBase
import bisect

# def power(x, p):
#     res = 1
#     while p:
#         if p & 1:
#             res = res * x % 1000000007
#         x = x * x % 1000000007
#         p >>= 1
#     return res;

def main():
    # for _ in range(int(input())):
    #     n=int(input())
    #     n,k=map(int,input().split())
    #     arr=[int(k) for k in input().split()]
    #n=int(input())
    # n,k=map(int,input().split())
    # arr=[int(k) for k in input().split()]
    s=input()
    t=input()
    ans=0
    for i in range(len(s)):
        if s[i]!=t[i]:
            ans+=1
    print(ans)





















BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()

Measured memory_bytes: 10052
A = int(input())
listA = list(map(int,input().split()))
min_n = listA[0]
for i in range(len(listA)):
    if min_n < listA[i]:
        min_n = listA[i]-1
    elif min_n > listA[i]:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 14224
// In His Name

#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define gcd __gcd
#define int long long
#define ull unsigned long long

using namespace std;

typedef pair<int, int> pii;

const int MAX_N = 1e2 + 10, MAX_W = 1e5 + 10;
int n, W, v[MAX_N], w[MAX_N], dp[MAX_N][MAX_W];

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> W;
	for (int i = 0 ; i < n ; i++)
		cin >> w[i] >> v[i];
	for (int i = 0 ; i <= n ; i++){
		for (int j = 0 ; j <= W ; j++){
			if (i == 0 || j == 0){
				continue;
			}
			if (w[i - 1] <= j){
				dp[i][j] = max (dp[i - 1][j] , dp[i - 1][j - w[i - 1]] + v[i - 1]);
				continue;
			}
			dp[i][j] = dp[i - 1][j];
		}
	}
	cout << dp[n][W];
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a.at(i);
    }
    int mi=a.at(0);
    int ma=-1000000000;
    for(int j=1;j<n;j++){
        ma=max(ma,a.at(j)-mi);
        mi=min(mi,a.at(j));
    }
    cout<<ma<<endl;
}


Measured memory_bytes: 3528
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;

#define io(F) string t_="";ifstream fin(t_+F+".in");ofstreamfout(t_+F+".out")
#define qio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
#define graph unordered_map<int, unordered_set<int>>
typedef long long ll;

int main() {
	double ans = 3.1415926535;
	double r; cin >> r;
	ans *= 2*r;
	println(ans);
}


Measured memory_bytes: 3788
from sys import stdin,setrecursionlimit
from itertools import groupby
setrecursionlimit(10**7)
s = ['1', '1', '1', '2', '1', '2', '1', '5', '2', '2', '1', '5', '1', '2', '1', '14', '1', '5', '1', '5', '2', '2', '1', '15', '2', '2', '5', '4', '1', '4', '1', '51']
k = int(stdin.readline().rstrip())
print(s[k-1])

Measured memory_bytes: 3060
//include
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <map>
#include <sstream>
#include <utility>
//マクロとか
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n) + 1; i++)
#define all(vecto) vecto.begin(), vecto.end()
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
using ll = long long;

//自前の関数たち
//最大公約数
ll GCD(ll a, ll b)
{
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

//最小公倍数
ll LCM(ll a, ll b)
{
    return (a * b) / GCD(a, b);
}

//namespace my
namespace my {
    //配列の最大値or最小値を数値で返す関数
    int max_element(std::vector<int> vec){
        std::sort(vec.begin(), vec.end());
        return vec.at(vec.size() - 1);
    }
    int min_element(std::vector<int> vec){
        std::sort(vec.begin(), vec.end());
        return vec.at(0);
    }
}

//yes,noを出力するやつ
void ans(bool qus)
{
    if (qus == true)
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;
}

void Ans(bool qust)
{
    if (qust == true)
        std::cout << "YES" << std::endl;
    else
        std::cout << "NO" << std::endl;
}

//std名前空間を使用
using namespace std;

////////////////////////////////////////////////////////////////////////////////
//スタート


int main()
{
    int n;
    cin >> n;
    vector<int> vec(n);
    rep(i,n){
        cin >> vec[i];
    }

    int maxv = -2000000000;
    int minv = vec[0];

    for (int i = 1; i < n; i++)
    {
        maxv = max(maxv, vec[i]-minv);
        minv = min(minv, vec[i]);
    }

    cout << maxv << endl;
}


Measured memory_bytes: 3560
#include<stdio.h>
int main(void){
  int N,i,ans=0;
  scanf("%d",&N);
  int p[N];
  for(i=0;i<N;i++){
    scanf("%d",&p[i]);
  }
  for(i=1;i<N-1;i++){
    if((p[i]>p[i-1] && p[i]<p[i+1]) || (p[i]<p[i-1] && p[i]>p[i+1])){
      ans=ans+1;
    }
  }
 printf("%d",ans);
  return 0;
}

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

int main(){
	 int h,n,s=0;
	 cin>>h>>n;
	 int a[n+1];
	 for(int i=1;i<=n;++i)
	 {
	   cin>>a[i];
	   s+=a[i];
     }
	 if(s<h)
	 cout<<"No";
	 else
	 cout<<"Yes";
	 return 0;
	 } 
     


Measured memory_bytes: 640
import collections
import fractions
range = xrange; input = raw_input


class Dinic:
    """Dinic Algorithm: find max-flow
       complexity: O(EV^2)
       used in GRL6A(AOJ)
    """
    class edge:
        def __init__(self, to, cap, rev):
            self.to, self.cap, self.rev = to, cap, rev

    def __init__(self, V, E, source, sink):
        """ V: the number of vertexes
            E: adjacency list
            source: start point
            sink: goal point
        """
        self.V = V
        self.E = [[] for _ in range(V)]
        for fr in range(V):
            for to, cap in E[fr]:
                self.E[fr].append(self.edge(to, cap, len(self.E[to])))
                self.E[to].append(self.edge(fr, 0, len(self.E[fr])-1))
        self.maxflow = self.dinic(source, sink)

    def dinic(self, source, sink):
        """find max-flow"""
        INF = float('inf')
        maxflow = 0
        while True:
            self.bfs(source)
            if self.level[sink] < 0:
                return maxflow
            self.itr = [0] * self.V
            while True:
                flow = self.dfs(source, sink, INF)
                if flow > 0:
                    maxflow += flow
                else:
                    break

    def dfs(self, vertex, sink, flow):
        """find augmenting path"""
        if vertex == sink:
            return flow
        for i in range(self.itr[vertex], len(self.E[vertex])):
            self.itr[vertex] = i
            e = self.E[vertex][i]
            if e.cap > 0 and self.level[vertex] < self.level[e.to]:
                d = self.dfs(e.to, sink, min(flow, e.cap))
                if d > 0:
                    e.cap -= d
                    self.E[e.to][e.rev].cap += d
                    return d
        return 0

    def bfs(self, start):
        """find shortest path from start"""
        que = collections.deque()
        self.level = [-1] * self.V
        que.append(start)
        self.level[start] = 0

        while que:
            fr = que.popleft()
            for e in self.E[fr]:
                if e.cap > 0 and self.level[e.to] < 0:
                    self.level[e.to] = self.level[fr] + 1
                    que.append(e.to)

while True:
    M, N = map(int, input().split())
    if M == 0 and N == 0:
        break
    blue, red = [], []
    while True:
        for x in input().split():
            blue.append(int(x))
        if len(blue) == M:
            break
    while True:
        for x in input().split():
            red.append(int(x))
        if len(red) == N:
            break
    V = M + N + 2
    edge = [[] for _ in range(V)]
    for i, b in enumerate(blue):
        for j, r in enumerate(red):
            if fractions.gcd(b, r) != 1:
                edge[i].append((M+j, 1))
    for i in range(M):
        edge[M+N].append((i, 1))
    for j in range(N):
        edge[M+j].append((M+N+1, 1))
    print(Dinic(V, edge, M+N, M+N+1).maxflow)

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end(), greater<>());
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (abs(a[0] - 2 * ans) > abs(a[0] - 2 * a[i])) {
      ans = a[i];
    }
  }
  cout << a[0] << " " << ans << endl;
  return 0;
}


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

int main() {

	int a;
	int b;
	int c;

	cin >> a;
	cin >> b;
	cin >> c;

	int d;

	d = a;
	a = b;
	b = d;

	d = c;
	c = a;
	a = d;

	cout << a << " " << b << " " << c << "\n";

}

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

#define MAXN 2010

bitset<2000010> f;
int a[MAXN],n,sum;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",a+i),sum+=a[i];
	f[0]=1;
	for(int i=n;i>=1;--i)f|=f<<a[i];
	for(int i=(sum+1)>>1;i<=sum;++i)
		if(f[i])
			return printf("%d\n",i),0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i, n) for (int i = 0; i < int(n); i++)
#define FOR1(i, m, n) for (int i = int(m); i < int(n); i++)
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))

int main(int argc, char *argv[]) {
  int N;
  int num_odd = 0;
  int num_4 = 0;

  cin >> N;

  FOR(i, N) {
    int a;

    cin >> a;

    if (a % 4 == 0)
      num_4 ++;
    if (a % 2 == 1)
      num_odd ++;
  }

  if (num_odd <= num_4 ||
      (num_odd - 2 < num_4 && num_odd + num_4 == N))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

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

const int dx[] = {-1,0,1,0}; const int dy[] = {0,1,0,-1};

const ll INF = LLONG_MAX/2;

int main() {
	int town_n, order_n;
	while(cin >> town_n >> order_n, town_n|order_n){
		vvll E_stk(town_n, vll(town_n, INF));
		vvll E(town_n, vll(town_n, INF));

		int order, from, to, cost;
		bool made = true;
		REP(i, order_n){
			cin >> order;
			if(!order){
				if(!made){
					E = E_stk;
					made = true;
					REP(i, town_n) REP(j, town_n) REP(k, town_n){
						E[j][k] = E[j][k] < E[j][i] + E[i][k] ? E[j][k] : E[j][i] + E[i][k];
					}
				}
				cin >> from >> to;
				from--; to--;
				cout << (E[from][to] == INF ? -1 : E[from][to]) << endl;
			}else{
				made = false;
				cin >> from >> to >> cost;
				from--; to--;
				E_stk[from][to] = cost < E_stk[from][to] ? cost : E_stk[from][to];
				E_stk[to][from] = cost < E_stk[to][from] ? cost : E_stk[to][from];
			}
		}
	}
}

Measured memory_bytes: 1364
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;

#define EVEN(x) ( mu[x] == x || ( mu[x] != x && phi[mu[x]]!= mu[x] ) )
#define ODD(x) ( mu[x] != x && phi[ mu[x] ] == mu[x] && phi[x] != x  )
#define OUTER(x) ( mu[x] !=x && phi[ mu[x] ] == mu[x] && phi[x] == x )


struct Match{
    ll n;
    vector<vector<ll> > g;
    Match(){}
    Match( ll n ):n(n){
	g = vector<vector<ll> >(n);
    }
    void add_edge(ll a,ll b){
	g[a].push_back(b);
	g[b].push_back(a);
    }

    //マッチングの枝を返す.
    vector< mp > calc(){
	vector< mp > res;
	//Initilize
	vector<ll> mu(n),phi(n),rho(n),scanned(n);
	iota( mu.begin() , mu.end() , 0 );
	iota( phi.begin() , phi.end() , 0 );
	iota( rho.begin() , rho.end() , 0 );
	ll x = -1;
	while(1){
	    if( x < 0 ){ //select even
		for( x = 0 ; x < n && ( scanned[x] || !EVEN(x) ) ; x++ );
		if( x == n )break; 
	    }
	    ll y = -1; // select incident
	    for( auto e:g[x] ) if( OUTER( e ) || ( EVEN(e) && rho[e] != rho[x] ) ) y = e;
	    if( y == -1 ) scanned[x] = true , x = -1;
	    else if( OUTER( y ) ) phi[y] = x;//growth
	    else{
		vector<ll> dx(n,-2),dy(n,-2); //!TRICK! x%2 -->  x>=0
		for(ll k=0,w=x; dx[w] < 0 ; w = k%2 ? mu[w]:phi[w]) dx[w] = k++;
		for(ll k=0,w=y; dy[w] < 0 ; w = k%2 ? mu[w]:phi[w]) dy[w] = k++;
		bool vertex_disjoint = true;
		for(ll v=0;v<n;v++)if( dx[v]>=0 && dy[v]>0 ) vertex_disjoint = false;
		if( vertex_disjoint ){//argument
		    for(ll v=0;v<n;v++)if( dx[v]%2 ) mu[ phi[v] ] = v , mu[v] = phi[v] ;
		    for(ll v=0;v<n;v++)if( dy[v]%2 ) mu[ phi[v] ] = v , mu[v] = phi[v] ;
		    mu[x] = y , mu[y] = x , x = -1;
		    for(ll v=0;v<n;v++) phi[v] = rho[v] = v ,scanned[v] = false;
		}else{ //shirink
		    ll r = x,d = n;
		    for(ll v=0;v<n;v++)if( dx[v] >= 0 && dy[v] >= 0 && rho[v] == v && d > dx[v] ) d = dx[v] , r = v;
		    for(ll v=0;v<n;v++)if( dx[v] <= d && dx[v]%2 && rho[ phi[v] ] != r ) phi[ phi[v] ] = v;
		    for(ll v=0;v<n;v++)if( dy[v] <= d && dy[v]%2 && rho[ phi[v] ] != r ) phi[ phi[v] ] = v;
		    if( rho[x] != r ) phi[x] = y;
		    if( rho[y] != r ) phi[y] = x;
		    for(ll v=0;v<n;v++)if( dx[ rho[v] ] >= 0 || dy[ rho[v] ] >= 0 ) rho[v] = r;
		}
	    }
	}
	for(ll u = 0; u < n ; u++) if( u < mu[u] ) res.push_back( mp( u,mu[u] ) );
	return res;
    }

    ll MaximumMatch(){
	return calc().size() ;
    }

};


int main(){
    ll n;
    cin>>n;
    vector< mp > point(2*n);
    Match match(2*n);
    for(ll i=0;i<2*n;i++){
	ll a,b;
	cin>>a>>b;
	point[i] = mp(a,b);
    }
    for(ll i=0;i<n;i++){
	for(ll j=n;j<2*n;j++){
	    if( point[i].first < point[j].first && point[i].second < point[j].second ){
		match.add_edge( i , j );
	    }
	}
    }
    cout<<match.MaximumMatch()<<endl;
    return 0;
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod 1000000007
int getTheAnswer() {
    return 42;
}

using namespace std;
using ll=long long;

class ALphabet {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        char c;
        cin>>c;
        if (c>='A'&&c<='Z')
            cout<<"A";
        else cout<<"a";
	}
};


int main() {
	ALphabet solver;
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3644
A = [input().split() for _ in range(3)]
N = int(input())
B = [input() for _ in range(N)]

for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            A[i][j] = 0

if A[0][0] == A[1][1] == A[2][2] or A[0][2] == A[1][1] == A[2][0]:
    print('Yes')
    exit()

for n in range(3):
    if A[0][n] == A[1][n] == A[2][n] or A[n][0] == A[n][1] == A[n][2]:
        print('Yes')
        exit()

print('No')

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

vector<pair<int, int > > vec;
void op1(int n){
	for(int i = 2; i <= n; i++){
		vec.push_back({i - 1, i});
	}
}

void op2(int n){
	for(int i = n; i >= 2; i--){
		vec.push_back({i, i - 1});
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n;
	cin>>n;
	vector<int> a(n);
	int mn = 0, mx = 0;
	for(int i = 0; i < n; i++){
		cin>>a[i];
		mx = max(mx, a[i]);
		mn = min(mn, a[i]);
	}
	if(mx == 0){
		op2(n);
	}else if(mn == 0){
		op1(n);
	}else if(mx + mn >= 0){
		int ind;
		for(int i = 0; i < n; i++){
			if(a[i] == mx)ind = i;
		}
		for(int i = 0; i < n; i++){
			if(i == ind)continue;
			vec.push_back({ind + 1, i + 1});
		}
		op1(n);
	}else{
		int ind;
		for(int i = 0; i < n; i++){
			if(a[i] == mn)ind = i;
		}
		for(int i = 0; i < n; i++){
			if(i == ind)continue;
			vec.push_back({ind + 1, i + 1});
		}
		op2(n);
	}
	cout<<vec.size()<<'\n';
	for(auto x : vec){
		cout<<x.first<<" "<<x.second<<'\n';
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
const ll INF=1e15;
#define int long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false)
const double pi = acos(-1.0);
int gcd (int a, int b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
int lcm (int a, int b) {
    return a / gcd(a, b) * b;
}

long long binpows(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)  //impar
            res = res * a;
        a = a * a;
        b >>= 1;  // /2
    }
    return res;
}
const int mod=1e9+7;
int binpow(int a, int b, int m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
//CHECAR SE PRECISA DE LONG LONG
int n;
int k;
vector<int> v;
int dp[123456];
int resolve(int pos){
	if(pos==n-1)
		return 0;
	int &x=dp[pos];
	if(x!=-1)
		return x;
	x=INF;
	for(int i=pos+1; i<=min(n-1,pos+k); i++){
		x=min(x,resolve(i)+(abs(v[pos]-v[i])));
	}
	return x;
}
void solve(){
	cin>>n>>k;
	v.resize(n);
	memset(dp,-1,sizeof(dp));
	for(int i=0; i<n; i++){
		cin>>v[i];
	}
	cout<<resolve(0)<<endl;
}
//revise as variaveis e a ordem nas funções
signed main(){
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 9580
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1e18;
//const ll mod = 1000000007;
int D;
int c[26];
int s[600][26];
ll ans = 0;
ll Last[26];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> D;
    for(int i = 0; i < 26; i++) cin >> c[i];
    for(int i = 0; i < D; i++) {
        for(int j = 0; j < 26; j++) cin >> s[i][j];
    }
    for(int i = 0; i < 26; i++) {
        Last[i] = -1;
    }
    for(int i = 0; i < D; i++) {
        ll t;
        cin >> t;
        t--;
        ans += s[i][t];
        Last[t] = i;
        for(int j = 0; j < 26; j++) {
            ans -= c[j] * (i - Last[j]);
        }
        cout << ans << endl;
    }
    return 0;
}


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

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

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

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int main(){
    ll n, m; cin>>n>>m;
    vector<int> a(n+10);
    for(int i=0; i<n; i++) cin>>a[i];

    vector<ll> sum(n+10, 0);
    for(int i=1; i<=n; i++) {
        sum[i] = sum[i-1] + a[i-1];
    }

    map<int, ll> mod_sum;
    for(int i=0; i<=n; i++) {
        mod_sum[sum[i] % m]++;
    }

    ll ans=0;
    for(auto i : mod_sum){
        ans += (i.second*(i.second - 1)) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5376