akhauriyash/Code-Regression huggingface dataset:
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;

mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int grid[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> grid[i][j];
        }
    }
    int vis[3][3];
    memset(vis, 0, sizeof(vis));
    int n;
    cin >> n;
    while(n--){
        int x;
        cin >> x;
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                if(grid[i][j] == x){
                    vis[i][j] = 1;
                }
            }
        }
        bool ok = true, ok1 = true, ok2 = true;
        for(int i = 0; i < 3; i++){
            ok &= vis[0][i];
            ok1 &= vis[1][i];
            ok2 &= vis[2][i];
        }
        if(ok || ok1 || ok2){
            cout << "Yes";
            return 0;
        }
        ok = true, ok1 = true, ok2 = true;
        for(int i = 0; i < 3; i++){
            ok &= vis[i][0];
            ok1 &= vis[i][1];
            ok2 &= vis[i][2];
        }
        if(ok || ok1 || ok2){
            cout << "Yes";
            return 0;
        }
        ok = true;
        for(int i = 0; i < 3; i++){
            ok &= vis[i][i];
        }
        if(ok){
            cout << "Yes";
            return 0;
        }
        ok = true;
        for(int i = 2, j = 0; i >= 0; i--, j++){
            ok &= vis[j][i];
        }
        if(ok){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

void solve(long long X, long long A) {
    if (X < A) {
        cout << "0" << endl;
    } else {
        cout << "10" << endl;
    }
}

int main() {
    long long X;
    scanf("%lld", &X);
    long long A;
    scanf("%lld", &A);
    solve(X, A);
    return 0;
}


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

void solve(){
    string s; cin >> s;
    for(int i = 0; i < 26; i++){
        char ch = 'a' + i;
        int cnt = 0;
        for(int j = 0; j < s.size(); ++j){
            if(s[j] == ch) cnt++;
        }
        cnt %=2;
        if(cnt!=0){
            cout << "No" <<endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

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

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(x) ll t; cin >> t; x.push_back(t);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<string> vvs;

const static ll MOD = 1e9 + 7;

int main() {
    ll n;
    cin >> n;
    for(ll i = 1; i <= 9; i++) {
        double div = (double) n / i;
        if (ceil(div) == floor(div) && 1 <= div && div <= 9) {
            MSG("Yes")
            exit(0);
        }
    }

    MSG("No")
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        String w = cin.next();
        String allChars = "abcdefghijklmnopqrstuvwxyz";
        if (w.length() < 26) {
            int firstUnused = allChars
                    .chars()
                    .filter((int n) -> (w.indexOf(n) == -1))
                    .findFirst()
                    .orElse(-1);
            System.out.println(w + (char)firstUnused);
        } else {
            String rev = (new StringBuffer(allChars)).reverse().toString();
            if (rev.equals(w)) {
                System.out.println("-1");
                return;
            }

            StringBuffer buf = new StringBuffer(w);
            for (int i = w.length() - 1; i >= 0; i--) {
                int c = buf.charAt(i);
                buf.setLength(buf.length() - 1);
                if (c != (int)'z') {
                    for (int c2 = c + 1; c2 <= (int)'z'; c2++) {
                        if (buf.toString().indexOf(c2) == -1) {
                            System.out.println(buf.toString() + (char)(c2));
                            return;
                        }
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 26708
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a[10];
    cin>>a;
    int A=0,B=0;
    for(int i=0;i<=2;i++)
    {
       if(a[i]=='A')
        A++;
       else
        B++;
    }
    if(A&&B)
        cout<<"Yes";
    else
        cout<<"No";
return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

void solve(int in){
  int ans = 0;
  if(in > 1) ans = 1;
  for(int i = 2; i * i <= in; i++){
    if(in%i == 0){
      if(i != in/i) ans += in/i;
      ans += i;
    }
  }
 
  if(ans > in) cout << "abundant number" << endl;
  if(ans == in) cout << "perfect number" << endl;
  if(ans < in) cout << "deficient number" << endl;
}

int main(){
  int in;
  while(cin >> in && in) solve(in);
  return 0;
}

Measured memory_bytes: 1152
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    int[] a = new int[N];

    // 2で割り切れない数値
    int count1 = 0;
    
    // 4で割り切れる数値
    int count2 = 0;

    // 4で割り切れないが2で割り切れる数値
    int count3 = 0;

    for (int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
      if (a[i] % 2 != 0) {
        count1++;
      } else if (a[i] % 4 == 0) {
        count2++;
      } else {
        count3++;
      }
    }

    sc.close();

    String result = "No";

    if (count3 == 0) {
      if (count1 <= count2 + 1) {
        result = "Yes";
      }      
    } else {
      if (count1 == count2) {
        result = "Yes";
      }
    }

    System.out.println(result);

  }

}

Measured memory_bytes: 50896
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,ll>
const ll MOD=998244353;
const int INF=1e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;
    sort(s.begin(),s.end());
    bool flag=1;
    rep(i,3) {
        if ((s[i]!=s[i+1]) ^ (i%2!=0)) flag=0;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0; 
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    ll d, g; cin >> d >> g;
    vector<ll> p(d), c(d);
    rep(i, d) cin >> p[i] >> c[i];
    ll ans = INF;
    rep(i, (1<<d)) {
        ll sum = 0;
        ll cnt = 0;
        rep(j, d) {
            if(i&(1<<j)) {
                sum += 100 * (j + 1) * p[j] + c[j];
                cnt += p[j];
            }
        }
        //cout << d << ' ' << g << ' ' << ans << ' ' << sum << endl;
        if(sum >= g) {chmin(ans, cnt); continue;}
        for(ll j=d-1; j>=0; j--) {
            if(!(i&(1<<j))) {
                Rep(k, 1, p[j]) {
                    sum += 100 * (j + 1);
                    cnt++;
                    if(sum >= g) chmin(ans, cnt);
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3644
#include <stdio.h>

int a ;
int b ;
int c ;
int T ;

int main ( )
{
	while ( scanf ( "%d" , &T ) == 1 ) {
		while ( T-- ) {
			scanf ( "%d %d %d" , &a , &b , &c ) ;
			if ( a * a + b * b == c * c || a * a + c * c == b * b || b * b + c * c == a * a ) {
				printf ( "YES\n" ) ;
			}
			else {
				printf ( "NO\n" ) ;
			}
		}
	}
}

Measured memory_bytes: 1008
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <functional>
#include <cmath>
#include <cstdint>
#include <mutex>
#include <thread>
#include <bitset>

using namespace std;

int main()
{
	int n, m, a;
	int sum = 0;
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> a;
		sum += a;
	}

	n -= sum;
	if (n < 0)
		n = -1;

	cout << n;

	return 0;
}

Measured memory_bytes: 3624
n = gets.to_i
nums = []
n.times {
    nums.push( gets.to_i )
}

cnt = n
for i in ( 0 ... nums.length )
	if 2 == nums[i]
		next
	end
	if 0 == nums[i]%2
		cnt-=1
		next
	end
	3.step( Math.sqrt(nums[i]), 2 ) { |j|
		if 0 == nums[i]%j
			cnt-=1
			break
		end
	}
end

puts( cnt )

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

int main() {
  int a, b, i;
  int num = 0;
  int h = 0;

  cin >> a >> b;
  num = b - a;

  for (i=0; i < num+1; i++)
    h = h + i;

  cout << h-b << endl;
}


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

int main()
{
  int N ;
  cin>>N ;
  int A[2][N]  ;
  int i,j ;
  for(i=0;i<2;i++) for(j=0;j<N;j++) cin>>A[i][j] ;
  
  int X=0 ;
  int num_c=0 ;  //所有しているキャンディーの個数
  int max=0 ;
  while(X<N){
    for(i=0;i<=X;i++) num_c+=A[0][i] ;
    for(i=X;i<N;i++) num_c+=A[1][i] ;
    if(num_c>max) max=num_c ;
    X++ ;
    num_c=0 ;
  }
    
  cout<<max<<endl ;

  
  return 0 ;
}


Measured memory_bytes: 256
from collections import deque

n = int(input())
graph = [[] for _ in range(n+1)]
for i in range(n-1):
  u, v, w = map(int, input().split())
  graph[u].append((v, w))
  graph[v].append((u, w))
  
parent = [0] * (n+1)
ans = [0] * (n+1)

q = deque([1])
while q:
  x = q.popleft()
  for y, w in graph[x]:
    if(y == parent[x]):
      continue
    parent[y] = x
    ans[y] = ans[x]^(w&1)
    q.append(y)
      
for i in range(1, n+1):
  print(ans[i])

Measured memory_bytes: 39828
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;

import std.math;

void main() {
    int h, w, d;
    scan(h, w, d);

    auto a = iota(h).map!(i => readln.split.to!(int[])).array;
    foreach (i ; 0 .. h) a[i][] -= 1;

    auto r = new int[](h*w);
    auto c = new int[](h*w);

    foreach (i ; 0 .. h) {
        foreach (j ; 0 .. w) {
            r[a[i][j]] = i;
            c[a[i][j]] = j;
        }
    }

    int cost(int i, int j) {
        return abs(r[i] - r[j]) + abs(c[i] - c[j]);
    }

    auto dp = new long[](h*w);
    foreach_reverse (i ; 0 .. h*w - d) {
        dp[i] = dp[i+d] + cost(i, i+d);
    }

    debug {
        writeln(dp);
    }

    int q;
    scan(q);

    while (q--) {
        int li, ri;
        scan(li, ri);
        li--, ri--;
        writeln(dp[li] - dp[ri]);
    }
}


void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 9852
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int X; cin >> X;
    if(400 <= X and X <= 599) cout << 8 << endl;
    else if(X <= 799) cout << 7 << endl;
    else if(X <= 999) cout << 6 << endl;
    else if(X <= 1199) cout << 5 << endl;
    else if(X <= 1399) cout << 4 << endl;
    else if(X <= 1599) cout << 3 << endl;
    else if(X <= 1799) cout << 2 << endl;
    else if(X <= 1999) cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 3632
//#pragma GCC optimize ("O3")
//#pragma GCC target ("tune=native")
//#pragma GCC target ("avx")
//#include <bits/stdc++.h>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);

#define N 100010
ll n, c;
P v[N];
ll x[N], y[N];

ll solve(){
	mset(x, 0);
	mset(y, 0);
	ll s = 0, res = 0;
	rep(i, n){
		s += v[i].snd;
		x[i] = s-v[i].fst;
	}
	s = 0;
	for(int i = n-1; i >= 0; i--){
		s += v[i].snd;
		y[i] = max(y[i+1], s-(c-v[i].fst)*2);
	}
	rep(i, n) chmax(res, x[i]+y[i+1]);
	return res;
}
int main(){
	INIT;
	cin>>n>>c;
	rep(i, n){
		cin>>v[i].fst>>v[i].snd;
	}
	sort(v, v+n);
	ll res = solve();
	rep(i, n) v[i].fst = c-v[i].fst;
	reverse(v, v+n);
	chmax(res, solve());
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 3328
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let odd = (n + 1) / 2;
    let even = n / 2;
    println!("{}",odd * even); 
}


Measured memory_bytes: 4352
N = int(input())
S = input()
S = [i for i in S]
cnt = 0
K = int(N/2)

if N%2==0:
    for i in range(0, K):
        if S[i]!=S[i+K]:
            cnt += 1
elif N%2==1:
    cnt += 1

if cnt==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
n = int(input())
li = list(map(int,input().split()))
ans = 0
x = 0

for i in range(1,n):
    if li[i] == li[i-1]:
        x += 1
    else:
        ans += (x+1)//2
        x = 0

ans += (x+1)//2
print(ans)

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

int main() {

    int n,x;
    cin >> n >> x;
    int ans = 1;
    for (int i = 1; i <= n; i++) {
        if (ans <= x) {
            ans = ans*2;
        }else {
            ans = ans + x;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
//2017-10-21
//miaomiao
//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define pb push_back
#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define Forr(i, a, b) for(int i = (a); i >= (int)(b); --i)

#define LOG 20
#define N (200000+5)

vector<int> G1[N], G2[N];

int n, ans, dep2[N], u1[N], v1[N], f[N][LOG];
bool reach[N];

void Dfs2(int now, int D, int F){
	dep2[now] = D; f[now][0] = F;
	For(i, 1, 18) f[now][i] = f[f[now][i-1]][i-1];

	For(i, 0, G2[now].size()-1)
		if(G2[now][i] != F) Dfs2(G2[now][i], D+1, now);
}

void Dfs1(int now, int D, int F){
	if(dep2[now] <= D) return;
	
	reach[now] = true; ans = max(ans, dep2[now]);
	For(i, 0, G1[now].size()-1)
		if(G1[now][i] != F) Dfs1(G1[now][i], D+1, now);
}

int Dis(int u, int v){
	if(dep2[u] < dep2[v]) swap(u, v);

	int ret = 0;
	Forr(i, 18, 0) if(dep2[f[u][i]] >= dep2[v]){
		ret += 1<<i; u = f[u][i];
	}
	if(u == v) return ret;
	
	Forr(i, 18, 0) if(f[u][i] ^ f[v][i]){
		ret += (1<<i) << 1;
		u = f[u][i]; v = f[v][i];
	}
	return ret + 2;
}

void Check(){
	int u, v;

	For(i, 1, n) ++dep2[i];
	For(i, 1, n-1){
		u = u1[i], v = v1[i];
		if(!reach[u] && !reach[v]) continue;
		if(Dis(u, v) >= 3){puts("-1"); return;}
	}

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

int main(){
	int st1, st2, u, v;

	scanf("%d%d%d", &n, &st1, &st2);
	
	For(i, 1, n-1){
		scanf("%d%d", &u, &v);
		G1[u].pb(v); G1[v].pb(u);
		u1[i] = u; v1[i] = v;
	}
	For(i, 1, n-1){
		scanf("%d%d", &u, &v);
		G2[u].pb(v); G2[v].pb(u);
	}

	Dfs2(st2, 0, 0); Dfs1(st1, 0, 0);
	Check();

	return 0;
}

Measured memory_bytes: 54524
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
  int n;
  cin >> n;
  vector<string> S(n);
  string test[4]={"AC","WA","TLE","RE"};
  vector<int> count(4);
  for(string &e:S)cin>>e;
  for(int j=0;j<n;j++){
    for(int i=0;i<4;i++){
      if(test[i]==S[j]){
        count[i]++;
      }
    }
  }
  for(int i=0;i<4;i++){
     cout << test[i] << " x " << count[i] << endl;
     } 
  return 0;
}

Measured memory_bytes: 6416
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt(),d=sc.nextInt();
		int ac = Math.abs(a-c);
		int ab = Math.abs(a-b);
		int bc = Math.abs(b-c);

		if(ac<=d || ab<=d && bc<=d) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int all[15],two[15];
int solve(string x,int pos,bool e3=false,bool e5=false,bool e7=false) {
    if(pos==x.size()) {
        return (e3&&e5&&e7);
    }
    int left = x.size()-pos-1;
    int res = 0;
    
    if(x[pos] == '3') {
        res += solve(x,pos+1,1,e5,e7);
    }else if(x[pos] <= '5' && x[pos] > '3') {
        if(x[pos] == '5') res += solve(x,pos+1,e3,1,e7); // 取 5
        res += all[left];//取 3
        int cnt = e5 + e7;
        if(cnt == 2) {
            res += 3*two[left];
            if(left)
                res += 3;
            else
                res += 1;
        } else if(cnt == 1) {
            res += 2*two[left];
            if(left)
                res += 1;
            
        } else {
            res += two[left];
        }
    } else if(x[pos]>'5' && x[pos] <= '7') {
        if(x[pos] == '7') res += solve(x,pos+1,e3,e5,1); // 取 7
        //以下取 3
        res += all[left];//取 3
        int cnt = e5 + e7;
        if(cnt == 2) {
            res += 3*two[left];
            if(left)
                res += 3;
            else
                res += 1;
        } else if(cnt == 1) {
            res += 2*two[left];
            if(left)
                res += 1;
            
        } else {
            res += two[left];
        }
        //以下取 5
        res += all[left];
        cnt = e3 + e7;
        if(cnt == 2) {
            res += 3*two[left];
            if(left)
                res += 3;
            else
                res += 1;
        } else if(cnt == 1) {
            res += 2*two[left];
            if(left)
                res += 1;
            
        } else {
            res += two[left];
        }
    }else if(x[pos] >'7') {
        res += all[left+1];
        int cnt = e5+e3+e7;
        if(cnt == 3) {
            res += two[left+1]*3;
            res += 3;
        } else if(cnt == '2'){
            res += two[left+1]*2;
            res += 1;
        }else if(cnt == '1'){
            res += two[left+1];
        }
    }
    return res;
}
int main()
{
    for(int i=1;i<=10;++i) {
        two[i] = powl(2,i);
        two[i] -= 2;
        all[i] = powl(3,i);
        all[i] -= two[i]*3;
        all[i] -= 3;
    }

    string x;
    cin>>x;
    int ans = solve(x,0);
    if(x.size()>3) {
        for(int i=3;i<x.size();++i)
        ans += all[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fore(i,a,b) for(int i = a; i < b; i++)
#define fst first
#define snd second
#define ll long long
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int>
#define piii pair<int, pii>
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define mp make_pair

using namespace std;


int main(){
    string S,T;
    cin>>S>>T;
    int ans = 0;
    fore(i,0,sz(S)){
        if(S[i]!=T[i]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3836
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b,c; cin>>a>>b>>c;
	if (c>=a&&c<=b) cout<<"Yes";
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())

a = list()

for i in range(N):
        s,p = input().split()
        p = int(p)      
        a.append([s,p,i+1])

a.sort(key = lambda x: x[1], reverse = True)

a.sort(key = lambda x: x[0])

for i in a:
        print(i[2])


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdbool.h>

int main(void)
{
    int n, a, b;
    bool result = false;
    do{
        scanf("%d", &n);
        scanf("%d", &a);
        scanf("%d", &b);
        if((1 <= n && n <= 20) && (1 <= a && a <= 50) && (1 <= b && b <= 50)){
            result = true;
        }
    }while(result == false);

    int na = n * a;
    if (na <= b){
        printf("%d\n", na);
    }else{
        printf("%d\n", b);
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
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 long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}


int main(){
    string s;
    cin >> s;
    cout << "A";
    if (s[1]=='B'){
        cout << "R";
    }else{
        cout << "B";
    }
    cout << "C"<< endl;
}


Measured memory_bytes: 3628
import fractions
a, b, k = map(int, input().split())
l = []
gcd = fractions.gcd(a, b)
for i in range(1, int(gcd**0.5)+1):
    if gcd%i==0:
        l.append(i)
        if i != gcd//i:
            l.append(gcd//i)
l.sort(reverse = True)
print(l[k-1])


Measured memory_bytes: 5176
#include <cstdint>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

int main(void)
{
    std::string s;
    std::cin >> s;

    int64_t a = s.at(0) - '0';
    int64_t b = s.at(1) - '0';
    int64_t c = s.at(2) - '0';
    int64_t d = s.at(3) - '0';

    auto solve = [&]() {
        for (int64_t i=0; i < 8; ++i) {
            int64_t ans = a;
            ans += ((i&0x1) == 0) ? b : -b;
            ans += ((i&0x2) == 0) ? c : -c;
            ans += ((i&0x4) == 0) ? d : -d;
            if (ans == 7) return i;
        }
        return 0l;
    };

    int32_t flag = solve();

    std::string ans_str = 
        std::to_string(a) +
        (((flag&0x1) == 0) ? "+" : "-") +
        std::to_string(b) +
        (((flag&0x2) == 0) ? "+" : "-") +
        std::to_string(c) +
        (((flag&0x4) == 0) ? "+" : "-") +
        std::to_string(d) +
        "=7";

    std::cout << ans_str << std::endl;

    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func factorize(x int64) map[int64]int {
	m := make(map[int64]int)
	for i := int64(2); i*i <= x; i++ {
		for x%i == 0 {
			m[i]++
			x /= i
		}
	}
	if x != 1 {
		m[x] = 1
	}
	return m
}

func main() {
	var n int64
	fmt.Scan(&n)
	m := factorize(n)
	ans := 0
	for _, v := range m {
		b := 1
		for b <= v {
			v -= b
			b++
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1856
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int V = Integer.parseInt(sc.next());
		int E = Integer.parseInt(sc.next());
		int[] cnt = new int[V];
		ArrayList<ArrayList<Integer>> edge = new ArrayList<ArrayList<Integer>>();
		for (int i=0;i<V;i++) {
			ArrayList<Integer> add = new ArrayList<Integer>();
			edge.add(add);
		}
		for (int i=0;i<E;i++) {
			int s = Integer.parseInt(sc.next());
			int t = Integer.parseInt(sc.next());
			edge.get(s).add(t);
			cnt[t]++;
		}

		ArrayList<Integer> ans = new ArrayList<Integer>();
		ArrayDeque<Integer> queue = new ArrayDeque<Integer>();
		for (int i=0;i<V;i++) {
			if (cnt[i]==0) {
				ans.add(i);
				queue.add(i);
			}
		}

		while (!queue.isEmpty()) {
			Integer rem = queue.remove();
			for (Integer i : edge.get(rem)) {
				cnt[i]--;
				if (cnt[i]==0) {
					ans.add(i);
					queue.add(i);
				}
			}
		}
		for (Integer i : ans) {
			System.out.println(i);
		}
	}
}


Measured memory_bytes: 73408
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
const int Dx[] = {-1,0,1,0},Dy[] = {0,-1,0,1};
#define INF 1e+8
#define EPS 1e-8
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = (j); i < (k); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
int X,Y;
int l,m,n,o;
bool vis[52][52][52][52];
class P{
	public:
	int ax,ay,bx,by;
	int cnt;
	P(int ax,int ay,int bx,int by,int cnt):ax(ax),ay(ay),bx(bx),by(by),cnt(cnt){}
};
bool c(int stage[52][52],int f,int i){
	if(f == 0){
		if(o+Dy[i] >= 0 && o+Dy[i] <= Y && n+Dx[i] >= 0 && n+Dx[i] <= X &&
			m+dy[i] >= 0 && m+dy[i] <= Y && l+dx[i] >= 0 && l+dx[i] <= X)return true;
		else return false;
	}
	if(f == 1){
		if(m+dy[i] >= 0 && m+dy[i] <= Y && l+dx[i] >= 0 && l+dx[i] <= X)return true;
		else return false;
	}
	if(f == 2){
		if(o+Dy[i] >= 0 && o+Dy[i] <= Y && n+Dx[i] >= 0 && n+Dx[i] <= X)return true;
		else return false;
	}
}
int main(){
	while(scanf("%d%d",&X,&Y),(X|Y)){
		int tx,ty;
		scanf("%d%d",&tx,&ty);
		int kx,ky;
		scanf("%d%d",&kx,&ky);
		int stage[52][52];
		rep(i,Y)rep(j,X)scanf("%d",&stage[i][j]);
		int check = -1;
		queue<P> Q;
		Q.push(P(tx-1,ty-1,kx-1,ky-1,0));
		X--;Y--;
		memset(vis,false,sizeof(vis));
		while( Q.size() ){
			P p = Q.front();Q.pop();
			if(p.cnt == 100)break;
			if(p.ax == p.bx && p.ay == p.by){check=p.cnt;break;}
			l = p.ax;m = p.ay;n = p.bx,o = p.by;
			//printf("D:%d %d %d %d\n",l,m,n,o);
			rep(i,4){
				if(stage[m+dy[i]][l+dx[i]] == 0 && c(stage,1,i) && !vis[l+dx[i]][m+dy[i]][n][o] &&
					(stage[o+Dy[i]][n+Dx[i]] == 1 || o+Dy[i] < 0 || o+Dy[i] > Y || n+Dx[i] < 0 || n+Dx[i] > X) ){
					Q.push(P(l+dx[i],m+dy[i],n,o,p.cnt+1));
					vis[l+dx[i]][m+dy[i]][n][o] = true;
				}
				else if(stage[o+Dy[i]][n+Dx[i]] == 0 && c(stage,2,i) && !vis[l][m][n+Dx[i]][o+Dy[i]] &&
					(stage[m+dy[i]][l+dx[i]] == 1 || m+dy[i] < 0 || m+dy[i] > Y || l+dx[i] < 0 || l+dx[i] > X) ){
					Q.push(P(l,m,n+Dx[i],o+Dy[i],p.cnt+1));
					vis[l][m][n+Dx[i]][o+Dy[i]] = true;
				}
				else if(c(stage,0,i) && stage[m+dy[i]][l+dx[i]] == 0 && stage[o+Dy[i]][n+Dx[i]] == 0 && !vis[l+dx[i]][m+dy[i]][n+Dx[i]][o+Dy[i]]){
					Q.push(P(l+dx[i],m+dy[i],n+Dx[i],o+Dy[i],p.cnt+1));
					vis[l+dx[i]][m+dy[i]][n+Dx[i]][o+Dy[i]] = true;
				}
			}
		}
		(check != -1) ? printf("%d\n",check) : puts("NA");
	}
	return 0;
}

Measured memory_bytes: 8520
L, R = [int(lr) for lr in input().split()]
if R//2019 != L//2019:
  print(0)
else:
  ans = 2019
  for i in range(L, R):
    for j in range(i+1, R+1):
      mod = (i*j) % 2019
      if ans > mod:
        ans = mod
  print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------
const ll B = 512;
struct SqrtComposition
{
    ll N, K;
    vector<ll> data;
    vector<ll> backet;
    SqrtComposition(ll n) : N(n)
    {
        K = (N + B - 1) / B;
        data.assign(K * B, INF);
        backet.assign(K, INF);
    }
    void update(ll i, ll val)
    {
        ll k = i / B;
        data[i] = val;
        ll mn = val;
        for (ll j = k * B; j < (k + 1) * B; j++)
        {
            chmin(mn, data[j]);
        }
        backet[k] = mn;
    }
    ll getmin(ll a, ll b)
    {
        ll ans = INF;
        for (ll k = 0; k < K; k++)
        {
            ll l = k * B;
            ll r = (k + 1) * B;
            if (r <= a || b <= l)
            {
                continue;
            }
            if (a <= l && r <= b)
            {
                chmin(ans, backet[k]);
            }
            else
            {
                for (ll i = max(l, a); i < min(r, b); i++)
                {
                    chmin(ans, data[i]);
                }
            }
        }
        return ans;
    }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, q;
    cin >> n >> q;
    SqrtComposition h(n);
    while (q--)
    {
        ll a, b, c;
        cin >> a >> b >> c;
        if (a == 0)
        {
            h.update(b, c);
        }
        else
        {
            cout << h.getmin(b, c + 1) << endl;
        }
    }
}


Measured memory_bytes: 3536
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits.h>
#include <cmath>
#include <map>
using namespace std;
using P=pair<int,int>;
using PP=pair<P,P>;
using ll=long long;
#define int long long
struct Point{
    int x,y;
};
signed main(){
    Point s,t;
    cin>>s.x>>s.y>>t.x>>t.y;
    int n;
    cin>>n;
    vector<Point> o(n);
    vector<int> r(n);
    for(int i=0;i<n;i++){
        cin>>o[i].x>>o[i].y>>r[i];
    } 
    vector<vector<double>> dis(n+2,vector<double>(n+2));
    for(int i=0;i<n+2;i++){
        dis[i][i]=0;
    }
    for(int i=0;i<n;i++){
        dis[0][i+1]=max((double)0,sqrt((o[i].x-s.x)*(o[i].x-s.x)+(o[i].y-s.y)*(o[i].y-s.y))-r[i]);
        dis[i+1][0]=dis[0][i+1];
    }
    for(int i=0;i<n;i++){
        dis[n+1][i+1]=max((double)0,sqrt((o[i].x-t.x)*(o[i].x-t.x)+(o[i].y-t.y)*(o[i].y-t.y))-r[i]);
        dis[i+1][n+1]=dis[n+1][i+1];
    }
    dis[0][n+1]=sqrt((s.x-t.x)*(s.x-t.x)+(s.y-t.y)*(s.y-t.y));
    dis[n+1][0]=sqrt((s.x-t.x)*(s.x-t.x)+(s.y-t.y)*(s.y-t.y));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i==j)continue;
            dis[i][j]=max((double)0,sqrt((o[i-1].x-o[j-1].x)*(o[i-1].x-o[j-1].x)+(o[i-1].y-o[j-1].y)*(o[i-1].y-o[j-1].y))-(r[i-1]+r[j-1]));
        }
    }
    using di=pair<double,int>;
    vector<double> ret(n+2,LLONG_MAX);
    priority_queue<di,vector<di>,greater<>> task;
    ret[0]=0;
    task.push(di(0,0));
    while(!task.empty()){
        di p=task.top();
        task.pop();
        if(ret[p.second]<p.first)continue;
        for(int i=0;i<n+2;i++){
            if(ret[i]>p.first+dis[p.second][i]){
                ret[i]=p.first+dis[p.second][i];
                task.push(di(ret[i],i));
            }
        }
    }
    cout<<fixed<<setprecision(16)<<ret[n+1]<<endl;
}

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

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int N, M;
    scan(N, M);

    auto deg = new int[](N);

    foreach (i ; 0 .. M) {
        int ai, bi;
        scan(ai, bi);
        ai--, bi--;
        deg[ai]++;
        deg[bi]++;
    }

    deg.each!(d => d.writeln);
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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

int n, k;
int w[100001];

int check(ll p){
  int idx = 0;
  for(int i = 0; i < k; i++){
    ll s = 0;
    while(s + w[idx] <= p){
      s += w[idx];
      idx++;
      if(idx == n) return n;
    }
  }
  return idx;
}

int main(){

  cin >> n >> k;
  for(int i = 0; i < n; i++) cin >> w[i];
  ll left = 0, mid;
  ll right = 100000 * 10000; // ??????????????° * 1????????????????????§??????
  while(left+1 < right){
    mid = (right + left) / 2;
    ll v = check(mid);
    if(v >= n) right = mid;
    else left = mid;
  }
  cout << right << endl;
  return 0;
}


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

int main() {
  int N, 
      K,
      num = 1;
  
  cin >> N >> K;
  
  for (int i = 0; i < N; i++) {
    if (num < K) {
    num *= 2;
    } else {
    num += K;
    }
  }
  
  cout << num << endl;
}


Measured memory_bytes: 256
from sys import stderr, setrecursionlimit
from functools import reduce
from operator import add
import statistics
setrecursionlimit(2147483647)


def f():
    return [int(i) for i in input().split()]


def debug(*x, sep=" ", end="\n"):
    for item in x:
        stderr.write(str(item))
        stderr.write(sep)
    stderr.write(end)


n, k = f()
h = []
for i in range(n):
    h.append(int(input()))

h.sort()
min_dif = 10**10
for i in range(n-k+1):
    t = h[i+k-1] - h[i]
    if min_dif > t:
        min_dif = t
print(min_dif)


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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

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;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
const LL mod=1e9+7;
int n,k;
vector<int>v[N];
LL ans=1;
int cnt[N][3];
void bfs(int now,int pre){
	cnt[now][1]=v[now].size()-(pre?1:0);
	for(auto k:v[now]){
		if(k==pre)continue;
		cnt[now][2]+=cnt[k][1];
		bfs(k,now);
	}
}
void dfs(int now,int pre,int one=0,int two=0){
	int need=k-one-two;
	need=max(need,0);
	ans=ans*need;
	ans%=mod;
	int cnt=0;
	for(auto k:v[now]){
		if(k==pre)continue;
		dfs(k,now,1,one+cnt++);
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>k;
	for(int i=1;i<n;i++){
		int s,t;
		cin>>s>>t;
		v[s].pb(t);
		v[t].pb(s);
	}
	bfs(1,0);
	dfs(1,0);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 14208
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int n;
bool can[105][105];
vector<int> g[205];
int match[205];
bool used[205];

void add_edge(int u, int v) { g[u].push_back(v), g[v].push_back(u); }

bool dfs(int v) {
	used[v] = true;
	for (auto& c : g[v]) {
		int u = c, w = match[u];
		if (w < 0 || !used[w] && dfs(w)) {
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}

int matching() {
	int res = 0;
	memset(match, -1, sizeof(match));
	for (int v = 0; v < 205; ++v) {
		if (match[v] < 0) {
			memset(used, 0, sizeof(used));
			if (dfs(v)) res++;
		}
	}
	return res;
}

void solve() {
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (can[i][j]) add_edge(i, n + j);
		}
	}
	printf("%d\n", matching());
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	vector<P> a(n), c(n);
	rep(i, n) {
		cin >> a[i].first >> a[i].second;
	}
	rep(i, n) {
		cin >> c[i].first >> c[i].second;
	}
	rep(i, n) {
		rep(j, n) {
			if (a[i].first < c[j].first && a[i].second < c[j].second) {
				can[i][j] = true;
			}
		}
	}
	solve();
	return 0;
}


Measured memory_bytes: 384
def sarch(s):
    key = 0
    for i in range(len(s)):
        if s[i] == "#":
            key = i
    return key

def judge(s):
    key = 0
    for i in s:
        if i == "#":
            key = 1
            break
    return key

H, W = map(int, input().split())
A = [["0" for i in range(W)] for j in range(H)]
for i in range(H):
    S = input()
    for j in range(W):
        A[i][j] = S[j]
key = "Possible"
for i in range(1, H):
    if judge(A[i][0:sarch(A[i - 1])]) != 0:
        key = "Impossible"
        break
print(key)

Measured memory_bytes: 3188
x = 0
listen = []
first = []
last = []
n = int(input())
for i in range(n):
 listen.append(input())
 first.append(listen[i][:1])
 last.append(listen[i][-1:])
 if i > 0:
  if first[i] != last[i-1]:
   x = 1
 for k in range(i):
  if listen[k] == listen[i]:
   x = 1
if x == 0:
 print ('Yes')
else:
 print ('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }

    ll ans = 0;
    for(int i = 0; i <= k; i++){
        for(int m = 0; m <= min(i, (int)n); m++){

            for(int j = 0; j <= m; j++){
                vector<ll> have;
                for(int s = 0; s < j; s++){
                    have.push_back(v[s]);
                }

                for(int s = 0; s < m-j ; s++){
                    have.push_back(v[n-1-s]);
                }

                sort(all(have));reverse(all(have));

                ll tmpsum = 0;
                for(int s = 0; s < min(have.size()-(i-m),have.size()); s++){
                    tmpsum += have[s];
                }
                ans = max(ans, tmpsum);
            }

        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
X = list(map(int, input().split()))

if N >= M:
    print(0)
    exit(0)

X.sort()

aida = []
kyori_sum = 0
for i in range(M-1):
    kyori_sum += abs(X[i]-X[i+1])
    aida.append(abs(X[i]-X[i+1]))

aida.sort(reverse=True)
for i in range(N-1):
    kyori_sum -= aida[i]
print(kyori_sum)


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

using namespace std;

int a[55];

int main() {
	int n;
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	
	int res = 0;
	
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) res += a[i] * a[j];
	}
	
	printf("%d\n", res);
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
#define pi 3.1415926535898
using namespace std;
const int N=3e5+10;
const int mod=1e9+7;
char mp[2020][2020];
int dis[2020][2020];
int vis[2020][2020];
int h,w,x11,y11,x2,y2;
int sum=inf;
int dx[4]= {0,0,1,-1};
int dy[4]= {1,-1,0,0};
struct A
{
    int x,y,v;
    A(int x=0,int y=0,int v=0):x(x),y(y),v(v) {}
    bool operator<(const A&o)const
    {
        return v>o.v;
    }
};
int main()
{
    cin>>h>>w;
    cin>>x11>>y11;
    cin>>x2>>y2;
    for(int i=1; i<=h; i++)
    {
        for(int j=1; j<=w; j++)
        {
            cin>>mp[i][j];
        }
    }
    memset(dis,inf,sizeof(dis));
    priority_queue<A>q;
    q.push(A(x11,y11,dis[x11][y11]));
    dis[x11][y11]=0;
    while(!q.empty())
    {

        int x=q.top().x;
        int y=q.top().y;
        q.pop();
        if(vis[x][y])
        {
            continue;
        }
        vis[x][y]=1;
        for(int i=0; i<4; i++)
        {
            int xx=x+dx[i];
            int yy=y+dy[i];
            if(xx>=1&&xx<=h&&yy>=1&&yy<=w&&mp[xx][yy]!='#')
            {
                if(dis[xx][yy]>dis[x][y])
                {
                    dis[xx][yy]=dis[x][y];
                    q.push(A(xx,yy,dis[xx][yy]));
                }
            }
        }
        for(int i=-2; i<=2; i++)
        {
            for(int j=-2; j<=2; j++)
            {
                int xx=x+i;
                int yy=y+j;
                if(xx>=1&&xx<=h&&yy>=1&&yy<=w&&mp[xx][yy]!='#')
                {
                    if(dis[xx][yy]>dis[x][y]+1)
                    {
                        dis[xx][yy]=dis[x][y]+1;
                        q.push(A(xx,yy,dis[xx][yy]));
                    }
                }
            }
        }
    }
    if(dis[x2][y2]==inf)
    {
        cout<<-1<<endl;
    }
    else
    {
        cout<<dis[x2][y2]<<endl;
    }
    return 0;
}


Measured memory_bytes: 29320
# import bisect
from collections import Counter, defaultdict, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n, m = list(map(int,ipti().split()))

    if n == 1 and m == 1:
        print(1)
    elif n == 1:
        print(m-2)
    elif m == 1:
        print(n-2)
    else:
        print((n-2)*(m-2))

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
    int n;
    

    cin >> n;
    int A[n];

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

    for(int i = n - 1; i >= 0; i--){
        if(i == 0){
            printf("%d\n", A[i]);
        }
        else{
            printf("%d ", A[i]);
        }

    }
    return 0;
}


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

int main() {
  int a,b,c = 0;
  scanf("%d %d %d", &a, &b, &c);
  if (a < b && b < c) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 2608