akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    cout << abs(n - 2) * abs(m - 2) << '\n';
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
t = 0
t += b[a[0]-1]
for i in range(1,n):
    t += b[a[i]-1]
    if a[i] - a[i-1] == 1:
        t += c[a[i-1]-1]
print(t)

Measured memory_bytes: 9132
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)
#define FORR(i,n,m) for(ll i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define pi 	3.14159265358979323846

int main(){
	
	ll n,m,l;
	cin >> n >> m >> l;
	
	ll A[100][100];
	REP(i,n){
		REP(j,m){
			cin >> A[i][j];
		}
	}
	
	ll B[100][100];
	REP(i,m){
		REP(j,l){
			cin >> B[i][j];
		}
	}
	
	REP(i,n){
		REP(j,l){
			ll op = 0;
			REP(k,m){
				op += A[i][k]*B[k][j];
				//printf("<%d><%d>",(int)A[n][k],(int)B[k][m]);
				//printf("(%d)",(int)op);
			}
			//printf("[%d][%d]",(int)i,(int)j);
			cout << op;
			if(!(j==l-1)){
				cout << " ";
			}
		}
		cout << endl;
	}	return 0;
}


Measured memory_bytes: 3220
#include <stdio.h>

int main(void)
{
	int i, x = 1;

	for (i = 0; x != 0; i++)
	{
		scanf("%d", &x);

		if (x != 0)
		{
			printf("Case %d: %d\n",i + 1, x);
		}
	}

	return 0;
}


Measured memory_bytes: 2056
n=gets.to_i

a=[]
n.times do
  h={}
  gets.chomp.chars.each do |c|
    if h.key?(c)
      h[c]+=1
    else
      h[c]=1
    end
  end
  a<< h
end

b=a[0]
b.each do |c, k|
  (1...a.size).each do |i|
    if a[i].key?(c)
      b[c]=[b[c], a[i][c]].min
    else
      b[c]=0
    end
  end
end

s=''
b.sort.each do |c, k|
  k.times do
    s<< c
  end
end

puts s


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

#define F first
#define S second
#define MP make_pair
#define PB push_back

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < ll > vl;

const int MAXN = 300500;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int LOG = 18;
const double EPS = 1e-9;
const double PI = 3.1415926535;

int height[MAXN];
int value[MAXN];
ll dp[MAXN];

struct segment_tree {
    ll tree[2 * MAXN];

    void update(int pos, ll val) {
        for(; pos >= 1; pos = pos / 2)
            tree[pos] = max(tree[pos], val);
    }

    ll query(int pos) {
        ll best = 0;
        for(; pos > 1; pos = pos / 2)
            if(pos % 2 == 1)
                best = max(best, tree[pos - 1]);
        return best;
    }
};

int base(int n) {
    int k = 1;
    while(k <= n) {
        k = k * 2;
    }
    return k;
}

int main() {
    int N, b;
    segment_tree T;

    cin >> N;
    for(int i = 0; i < N; i++)
        cin >> height[i];
    for(int i = 0; i < N; i++)
        cin >> value[i];

    b = base(N);
    for(int i = 0; i < N; i++) {
        int pos = b + height[i];
        ll best = T.query(pos);
        dp[height[i]] = best + value[i];
        T.update(pos, dp[height[i]]);
    }

    ll ans = 0;
    for(int i = 0; i <= N; i++)
        ans = max(ans, dp[i]);
    cout << ans << endl;

    return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  int n; cin >> n;
  int ans = 0;
  int a = 0, b = 0, ba = 0;
  for (int i = 0; i < n; ++i) {
    string s; cin >> s;
    for (int j = 0; j < (int)s.size(); ++j) {
      if (s[j] == 'A' && s[j+1] == 'B') ++ans;
    }
    if (s[0] == 'B' && s.back() == 'A') ++ba;
    else if (s[0] == 'B') ++b;
    else if (s.back() == 'A') ++a;
  }
  ans += max(ba-1, 0);
  if (ba && a) {
    --a;
    ++ans;
  }
  if (ba && b) {
    --b;
    ++ans;
  }
  ans += max(min(a, b), 0);
  printf("%d", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


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

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++)
 
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 long long INF = 1LL << 60;


int main () {
    int  a, b, c, d;
    cin >> a>> b >> c >> d;

    if(abs(a-c) <= d) cout << "Yes" << endl;
    else if (abs(a-b) <= d && abs(b-c) <=d) cout << "Yes" << endl;
    else cout << "No" << endl;



}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vi v(n);
	REP(i, n) {
		char c; cin >> c;
		if (c == 'T')v[i] = 1;
		else v[i] = 0;
	}
	auto f = [&](int a, int b) {
		if (a == 1) {
			return b;
		}
		return 1;
	};

	int a = v[0];
	FOR(i, 1, n) {
		a = f(a, v[i]);
	}
	if (a)cout << "T" << endl;
	else cout << "F" << endl;
}


Measured memory_bytes: 3344
a,b = map(int, input().split())

if a > b:
    big = a
    small = b
elif b > a:
    big = b
    small = a
elif a == b:
    big = a
    small = b

sum = big
big = big - 1
if big > small:
    sum += big
else:
    sum += small

print(sum)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int n;
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		sc.close();

		int ret = 0;
		for(int i = 1 ; i <= n ; i++) {

			if(String.valueOf(i).length() % 2 == 1) {

				ret++;

			}

		}
		System.out.println(ret);

	}

}


Measured memory_bytes: 26324
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//String s = sc.next();
		//String t = sc.next();
		//String g = sc.next();
		long n = sc.nextLong();
		long m = sc.nextLong();
		long k = sc.nextLong();
		long l = sc.nextLong();
		//String buff="Christmas";
		long count=0;
		long[] array=new long[3];

		/*for(long i=n;i<25;i++) {
			buff+=" Eve";
		}*/
		Arrays.sort(array);

		/*if() {
			System.out.println("TBD");
		}else {
			System.out.println("Heisei");
		}*/
		System.out.println(n*m-k*m-l*(n-k));
		//System.out.println(Math.abs(array[2]-array[1])+Math.abs(array[1]-array[0]));
	}
}




Measured memory_bytes: 23892
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#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 UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
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); }
//
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();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N;
  cin >> N;
  int a[110];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  int ans = INF;
  for (int i = -100; i <= 100; i++) {
    int sum = 0;
    for (int j = 0; j < N; j++) {
      sum += (i - a[j]) * (i - a[j]);
    }
    chmin(ans, sum);
  }

  cout << ans << endl;

  return 0;
}


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


using namespace std;
using ll = long long;


int main() {
    string st;
    cin >> st;
    int mx = 0, cur = 0;
    for(int i = 0; i < (int) st.length(); i++) {
        if(st[i] == 'R') {
            cur++;
            mx = max(mx, cur);
        } else {
            cur = 0;
        }
    }
    cout << mx << "\n";
    return 0;
}



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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);


	long long n,x= 1e9+7,sum=0;
	cin>>n;
	long long a[n],b[n];
	
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		b[i]=a[i];
		
	}
	for(int i=n-2;i>=0;i--)
		a[i] += a[i+1];
	for(int i=0;i<n-1;i++)
	{
		sum += ((a[i+1]%x)*(b[i]%x))%x;
		sum %=x;
	}

	cout<<sum%x<<'\n';
    return 0;
		
}

Measured memory_bytes: 6732
a = int(input())
b = []
S = []
H = []
C = []
D = []
check = [1,2,3,4,5,6,7,8,9,10,11,12,13]
for i in range(a):
    b.append(input().split())
for i in range(len(b)):
    if b[i][0] == "S":
        S.append(int(b[i][1]))
    elif b[i][0] == "H":
        H.append(int(b[i][1]))
    elif b[i][0] == "C":
        C.append(int(b[i][1]))
    else:
        D.append(int(b[i][1]))

set_S = list(set(check)-set(S))
set_S.sort()
set_H = list(set(check)-set(H))
set_H.sort()
set_C = list(set(check)-set(C))
set_C.sort()
set_D = list(set(check)-set(D))
set_D.sort()
for i in set_S:
    print("S",i)
for i in set_H:
    print("H",i)
for i in set_C:
    print("C",i)
for i in set_D:
    print("D",i)


Measured memory_bytes: 5620
N,K = map(int,input().split())
P = list(input())
count = 0
count2 = 0
for i in range(N-1):
    if P[i] == P[i+1]:
        count2 += 1
if P[0] == 'L':
    for i in range(N - 1):
        if P[i] == 'L' and P[i + 1] == 'R':
            count += 1
    if P[N-1] == 'L':
        print(count2 + 2*min(K,count))
    else:
        if K >= count:
            print(count2 + 2 * count - 1)
        else:
            print(count2 + (2*K))
else:
    for i in range(N - 1):
        if P[i] == 'R' and P[i + 1] == 'L':
            count += 1
    if P[N-1] == 'R':
        print(count2 + 2*min(K,count))
    else:
        if  K >= count:
            print(count2 + 2*count -1)
        else:
            print(count2 + 2*K)



Measured memory_bytes: 4084
n,m,s=map(int,input().split())

edge=[[]for _ in range(n)]
for _ in range(m):
  a,b,c=map(int,input().split())
  edge[a].append((b,c))
#print(edge)

from heapq import heappop,heappush
ans=[10 ** 20] * n
ans[s]=0
h=[[0,s]]
while h:
  c, v = heappop(h)
  if ans[v] < c:
    continue
  for u,t in edge[v]:
    if c + t < ans[u]:
      ans[u] = c + t
      heappush(h,[c + t,u])
#出力
for i in ans:
  if i == 10 ** 20:
    print("INF")
  else:print(i)
   


Measured memory_bytes: 91320
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <limits>
#include <numeric>
#include <iomanip>
#include <cstdlib>
#include <iterator>
#include <functional>

using namespace std;

typedef unsigned                    ui;
typedef int                         si;
typedef long                        sl;
typedef long long                   ll;
typedef unsigned long long          ull;

#ifdef LOCALHOST
std::ifstream in("input.txt", std::ifstream::in);
#endif // LOCALHOST

#ifdef LOCALHOST
#define is in
#else
#define is cin
#endif // LOCALHOST

int main(int argc, char *argv[])
{
    std::ios_base::sync_with_stdio(false);

    ll n, W;
    cin >> n >> W;

    vector<ll> w(n + 1, 0);
    vector<ll> v(n + 1, 0);

    ll V = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> w[i] >> v[i];
        V += v[i];
    }

    ll answer = 0;
    vector<vector<ll>> dp(V + 1, vector<ll>(n + 1, 1e18));
    for (int i = 0; i <= n; ++i) {
        dp[0][i] = 0;
    }
    // for (int i = 0; i <= V; ++i) {
    //     dp[i][0] = 0;
    // }

    for (int item = 1; item <= n; ++item) {
        // cerr << "item = " << item << endl;
        for (int value = V; value >= 0; --value) {
            dp[value][item] = dp[value][item - 1];
            if (v[item] + value <= V) {
                dp[value + v[item]][item] = min(dp[value + v[item]][item - 1], dp[value][item - 1] + w[item]);
            }
            // cerr << item << " " << value  << ", ";
        }
        // cerr << endl;
    }

    for (int item = 1; item <= n; ++item) {
        for (int value = 1; value <= V; ++value) {
            if (dp[value][item] <= W) {
                answer = value;
            }
            // cerr << dp[value][item] << " ";
        }
        // cerr << endl;
    }

    cout << answer << endl;

    return 0;
}


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

#define fst first
#define snd second
#define INF 0x3FFFFFFF
#define PI (2*acos(0))

using namespace std;

typedef long long ll;
typedef complex<double> pt;

int main() {
  int n, k;
  cin >> n >> k;
  int counter = 0;
  int val = 1;
  while (counter < n) {
    if (2 * val < val + k) val *= 2;
    else val += k;
    counter++;
  }
  cout << val << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define INF 100000000
#define MOD 1000000007
using namespace std;


int main(){
    int T=0;
    int S=0;
    
    string x;
    cin >> x;
    
    for(int i=0; i<x.length(); i++){
        if(x[i]=='S'){
            S++;
        }
        
        if(x[i]=='T'){
            if(S>0){
                S--;
            }else{
                T++;
            }
        }
    }
    
    cout<<T+S<<endl;
    return 0;
}


Measured memory_bytes: 640
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());

    let n: i64 = io.read();
    let s: i64 = io.read();

    // 🐦
    let mut sq = (n as f64).sqrt() as i64;
    let mut ans = -1;

    if s == n {
        io.writeln(n + 1);
        return;
    }

    for b in 2..sq + 3 {
        if f(b, n) == s {
            io.writeln(b);
            return;
        }
    }

    for bb in (1..sq + 3).rev() {
        if f((n - s) / bb + 1, n) == s {
            io.writeln((n - s) / bb + 1);
            return;
        }
    }
    io.writeln(-1);
}

fn f(b: i64, n: i64) -> i64 {
    if b < 2 {
        return -1i64;
    }
    let mut n = n;
    let mut ret = 0i64;
    while n > 0 {
        ret += n % b;
        n /= b;
    }
    ret
}

static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int N;
int S,T;
vector<int> g[100010];

int depth[100010];
void dfs(int now,int par,int d){
    depth[now]=d;
    for(auto nex:g[now]){
        if(nex==par) continue;
        dfs(nex,now,d+1);
    }
}

bool used[100010];
vector<int> path;
bool rfs(int now,int par){
    if(now==T){
        path.push_back(now);
        return used[T]=true;
    }
    for(auto nex:g[now]){
        if(nex==par) continue;
        if(rfs(nex,now)==false) continue;
        else{
            path.push_back(now);
            used[now]=true;
            return true;
        }
    }
    return false;
}

int dp[100010];
int find(int now,int par){
    if(used[now]) return -1;
    for(auto nex:g[now]){
        if(nex==par) continue;
        dp[now]=max(dp[now],find(nex,now)+1);
    }
    return dp[now];
}

int main(){
  cin>>N;
  cin>>S>>T;
  S--;T--;
  rep(i,N-1){
      int a,b;
      cin>>a>>b;
      a--;
      b--;
      g[a].push_back(b);
      g[b].push_back(a);
  }

  dfs(S,-1,0);
  rfs(S,-1);
  reverse(path.begin(),path.end());
  int n=(path.size()-1-1)/2;
  int tar=path[n];
  /*for(auto p:path) cout<<p<<" ";
  cout<<endl;*/

  for(int i=0;i<=n;i++) used[path[i]]=false;

  int ans=find(tar,-1)+n;
  if(path.size()%2) ans++;
  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 10240
#include "bits/stdc++.h"
using namespace std;

int main() {
	string S;
	cin >> S;
	int A = 0, Z = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'A') {
			A = i;
			break;
		}
	}
	for (int i = S.size() - 1; i >= 0; i--) {
		if (S[i] == 'Z') {
			Z = i;
			break;
		}
	}
	cout << (Z - A) + 1 << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

//Circles Intersection
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t--!=0){
			double[][] c = new double[2][3];
			for(int i=0;i<2;i++)for(int j=0;j<3;j++)c[i][j]=sc.nextDouble();
			int ans = 0;
			double d = Math.sqrt((c[0][0]-c[1][0])*(c[0][0]-c[1][0]) + (c[0][1]-c[1][1])*(c[0][1]-c[1][1]));
			if(d > c[0][2]+c[1][2])ans=0;
			else {
				if(d+Math.min(c[0][2], c[1][2]) < Math.max(c[0][2], c[1][2])){
					ans = c[0][2]<c[1][2]?-2:2;
				}
				else ans = 1;
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
import java.util.Scanner;
import java.util.HashMap;
import java.util.Map;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int cap = scan.nextInt();
        int[] weights = new int[n];
        int[] values = new int[n];

        for(int i = 0 ; i < n ; i++) {
            weights[i] = scan.nextInt();
            values[i] = scan.nextInt();
        }
        // first approach = top-down 
        //System.out.println(helper(0, weights, values, cap, new HashMap<Integer, Map<Integer, Long>>()));
        // second approach = bottom-up.
        // we build the weights table and find out if we are including the new item or not. 
        long[][] dp = new long[n+1][cap+1];
        for(int index = 0 ; index <= n ; index++) {
            // Row signifies set of all the elements until this row index. 
            for(int weight = 0 ; weight <= cap ; weight++) {
                // column signifies for the current weight index what is the optimal packing.
                if(index == 0 || weight == 0){
                    dp[index][weight] = 0;
                } else {
                    //Not including this item for this weight = dp[index-1][weight]
                    //Including this item for this weight = values[index-1]+dp[index-1][weight-weights[index-1]]
                    long notIncluding = dp[index-1][weight];
                    long including = (weight >= weights[index-1]) ? values[index-1]+dp[index-1][weight-weights[index-1]] : 0;
                    dp[index][weight] = Math.max(notIncluding, including);
                }
            }
        }
        System.out.println(dp[n][cap]);
    }

    private static long helper(int index, int[] weights, int[] values, int cap, Map<Integer, Map<Integer, Long>> cache){
        long pick = 0;
        if(cache.containsKey(index) && cache.get(index).containsKey(cap)) return cache.get(index).get(cap);
        if(cap < 0) return 0;
        if(index == weights.length) return 0;
        if(cap >= weights[index]){
            pick = values[index]+helper(index+1, weights, values, cap-weights[index], cache);
        }
        long nopick = helper(index+1, weights, values, cap, cache);
        cache.putIfAbsent(index, new HashMap<>());
        long max = Math.max(pick, nopick);
        cache.get(index).put(cap, max);
        return max;
    }
}


Measured memory_bytes: 127700
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

long H, W;
vector<string> S;
vector<long> uf;

long find(long i) {
  if (uf[i] == -1) return i;
  long root = find(uf[i]);
  uf[i] = root;
  return root;
}

void foo(long h, long w, long hh, long ww) {
  if (hh < 0 || ww < 0 || hh >= H || ww >= W) return;
  if (S[h][w] == S[hh][ww]) return;
  long root = find(h * W + w);
  long rootroot = find(hh * W + ww);
  if (root == rootroot) return;
  uf[root] = rootroot;
}

void solve() {
  cin >> H >> W;
  S = vector<string>(H);
  rep (i, H) cin >> S[i];
  uf = vector<long>(H * W);
  rep (i, H*W) uf[i] = -1;
  rep (h, H) rep (w, W) {
    foo(h, w, h-1, w);
    foo(h, w, h+1, w);
    foo(h, w, h, w-1);
    foo(h, w, h, w+1);
  }
  unordered_map<long, long> black;
  unordered_map<long, long> white;
  rep (h, H) {
    rep (w, W) {
      long i = h * W + w;
      long root = find(i);
      if (S[h][w] == '#') black[root]++;
      else white[root]++;
    }
  }

  long ans = 0;
  for (auto it: black) ans += it.second * white[it.first];

  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    double R;
    cin >> R;
    put_double(2.0 * R * 3.1415926);
}


Measured memory_bytes: 3784
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int r = scanner.nextInt();
        writer.println(3 * r * r);

        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        int nextInt() {
            return Integer.valueOf(next());
        }

        long nextLong() {
            return Long.valueOf(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

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

int main(){
  
  int i;
  string S;
  cin >> S;
  
  if (S[2] == S[3] && S[4] == S[5]){
    
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

unsigned long long conv(int base,const string& fact){
  unsigned long long res = 0;
  unsigned long long digit = 1ULL;
  for(int i = fact.size() - 1; i >= 0; i--){
    if('A' <= fact[i] && fact[i] <= 'Z'){
      res += (fact[i] - 'A' + 10) * digit;
      digit *= base;
    }
    else{
      res += (fact[i] - '0') * digit;
      digit *= base;
    }
  }
  return res;
}

int main(){
  int base;
  string fact;
  while(cin >> base >> fact){
    if(base == 0 && fact == "0") break;
    unsigned long long init = conv(base,fact);
    unsigned long long prime_factor[37] = {};
    memset(prime_factor,0,sizeof(prime_factor));
    for(int i = 2; i <= base; i++){
      while(base % i == 0){
        prime_factor[i]++;
        base /= i;
      }
    }

    unsigned long long res = numeric_limits<unsigned long long>::max();
    for(unsigned long long i = 2; i <= 36; i++){
      if(prime_factor[i] == 0) continue;
      unsigned long long count = 0;
      unsigned long long tmp = init;

      while(tmp > 0){
        count += tmp / i;
        tmp /= i;
      }
      res = min(res,count / prime_factor[i]);
    }

    if(res == numeric_limits<unsigned long long>::max()) res = 0;    
    cout << res << endl;
  }
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var abc = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            if (abc[2] <= abc[0] + abc[1]) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 11220
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner in = new Scanner(System.in);
	int cnt=0;
	String pattern;
	
	String first = in.nextLine();
	while(in.hasNext()){
	    pattern = in.next();
	    if(pattern.equalsIgnoreCase(first))cnt++;
	    else if(pattern.equals("END_OF_TEXT"))break;
	}
	System.out.println(cnt);
    }
}
	    
	



Measured memory_bytes: 26380
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std::endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

namespace ModFunctions {
	const int F = 2e5 + 10;

	int fact[F], inv_fact[F];

	inline void add(int &a, int b) {
		a += b;
		if (a >= MOD) {
			a -= MOD;
		}
	}

	inline void sub(int &a, int b) {
		a -= b;
		if (a < 0) {
			a += MOD;
		}
	}

	inline int mul(int a, int b) {
		return int((1ll * a * b) % MOD);
	}

	inline int power(int a, ll b) {
		int res = 1;
		while (b > 0) {
			if (b & 1) {
				res = mul(res, a);
			}
			a = mul(a, a);
			b >>= 1;
		}
		return res;
	}

	inline int inv(int a) {
		a %= MOD;
		if (a < 0) {
			a += MOD;
		}
		int b = MOD, u = 0, v = 1;
		while (a) {
			int t = b / a;
			b -= t * a;
			swap(a, b);
			u -= t * v;
			swap(u, v);
		}
		assert(b == 1);
		if (u < 0) {
			u += MOD;	
		}
		return u;
	}

	void pre_build() {
		fact[0] = 1;
		for (int i = 1; i < F; ++i) {
			fact[i] = mul(fact[i - 1], i);
		}
		inv_fact[F - 1] = inv(fact[F - 1]);
		for (int i = F - 2; i >= 0; --i) {
			inv_fact[i] = mul(inv_fact[i + 1], i + 1);
		}
	}

	int choose(int x, int y) {
		if (x < y) {
			return 0;
		}
		return mul(fact[x], mul(inv_fact[y], inv_fact[x - y]));
	}
}

using namespace ModFunctions;

int n, m;
set < int > bad;
int dp[N];

void test_case();
int solve(int step);

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	test_case();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void test_case() {
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int x;
		cin >> x;
		bad.insert(x);
	}
	memset(dp, -1, sizeof(dp));
	cout << solve(n) << "\n";
}

int solve(int step) {
	auto &ans = dp[step];
	if (ans == -1) {
		if (step == 0) {
			ans = 1;
		} else {
			ans = 0;
			auto updt = [&](int prv) {
				if (prv >= 0 && !bad.count(prv)) {
					add(ans, solve(prv));
				}
			};
			updt(step - 1);
			updt(step - 2);
		}
	}
	return ans;
}

Measured memory_bytes: 5376
import sys
def input():
	return sys.stdin.readline().strip()


N = int(input())
CAB = []
for i in range(N):
	A, B = list(map(int, input().split()))
	C = A + B
	CAB.append((C, A, B))

CAB.sort(reverse=True)

ans = 0
for i in range(N):
	if i % 2 == 0:
		ans += CAB[i][1]
	else:
		ans -= CAB[i][2]

print(ans)

Measured memory_bytes: 57856
MOD = 10**9 + 7

def modpow(a: int, p: int, mod: int) -> int:
    # return a**p (mod MOD) O(log p)
    res = 1
    while p > 0:
        if p & 1 > 0:
            res = res * a % mod
        a = a**2 % mod
        p >>= 1
    return res

def comb(N, x):
    numerator = 1
    for i in range(N-x+1, N+1):
        numerator = numerator * i % MOD
    denominator = 1
    for j in range(1, x+1):
        denominator = denominator * j % MOD
    d = modpow(denominator, MOD-2, MOD)
    return numerator * d
    
n,a,b=map(int,input().split())

ans = (modpow(2,n,MOD)-1 - comb(n,a) - comb(n,b)) % MOD
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int k;
vector<int> pvec;
bool prime[1500005];

int main(void)
{
  for(int i = 2; i < 50005; i++){
    if(prime[i]) continue;
    for(int j = 2*i; j < 1500005; j+=i) prime[j] = true;
  }
  for(int i = 2; i < 1500005; i++){
    if(!prime[i]) pvec.push_back(i);
  }

  while(1){
    cin >> k;
    if(k == 0) break;
    int u = *lower_bound(pvec.begin(), pvec.end(), k);
    if(u == k){
      cout << 0 << endl;
      continue;
    }
    int l = *(lower_bound(pvec.begin(), pvec.end(), k) - 1);
    cout << u - l << endl;
  }
  return 0;
}



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

using namespace std;

const int MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;i++)
#define rep2(i, m, n) for(int i=m;i<n;i++)
#define rrep(i, n, m) for(int i=n;i>=m;i--)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#ifdef __DEBUG
#include "cpp-pyprint/pyprint.h"
#endif

void Main() {
    ll L, R;
    cin >> L >> R;
    long long ans = MOD;
    if (R - L + 1 >= 2019) {
        cout << 0 << endl;
    }else{
        for (ll i = L; i <= R; ++i) {
            for (ll j = L; j <= R; ++j) {
                if (i == j) {
                    continue;
                }else{
                    ans = min(ans, i * j % 2019);
                }
            }
        }
        cout << ans << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


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

bool w(char x){
  if(x=='.'){
    return true;
  }else{
    return false;
  }
}

int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<char>> A(H+2,vector<char>(W+2));
  for(int i=0;i<H+2;i++){
    for(int j=0;j<W+2;j++){
      if(i==0||i==H+1){
        A.at(i).at(j) = '.';
      }else if(j==0||j==W+1){
        A.at(i).at(j) = '.';
      }else{
        cin >> A.at(i).at(j);
      }
    }
  }
  bool ok = true;
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      if(A.at(i).at(j) == '#'){
        if(w(A.at(i-1).at(j))&&w(A.at(i+1).at(j))&&w(A.at(i).at(j-1))&&w(A.at(i).at(j+1))){
          ok = false;
        }
      }
    }
  }
  if(ok){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

char g[1010][1010],pat[5][5];
int h,w;
string ch="JOI";

bool match(int x, int y){
  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      if(g[y+i][x+j]!=pat[i][j])return false;
    }
  }
  return true;
}

int count(int x, int y) {
  int res=0;
  for(int i=-1;i<1;i++){
    for(int j=-1;j<1;j++){
      int nx=x+j,ny=y+i;
      if(nx>=0 && ny>=0 && match(nx,ny))res++;
    }
  }
  return res;
}


int solve() {
  
  int res=0;

   for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(match(j,i))res++;
    }
  }
   
   int mx=res;
   for(int i=0;i<h;i++){    
     for(int j=0;j<w;j++){
       char tmp=g[i][j];

       int c=count(j,i);
       for(int k=0;k<3;k++){
	 g[i][j]=ch[k];
	 mx = max(mx,res-c+count(j,i));
       }

       g[i][j]=tmp;
     }
   }
   return mx;
}

int main(void){

  cin >> h >> w;
  
  fill(g[0],g[1010],NULL);
  fill(pat[0],pat[5],NULL);

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> g[i][j];
    }
  }

  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      cin >> pat[i][j];
    }
  }
  
  cout << solve() << endl;

  return 0;
}

Measured memory_bytes: 2204
n = int(input())
a = list(map(int, input().split()))
flag = 0
for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 3 == 0 or a[i] % 5 == 0:
            pass
        else:
            flag = 1
if flag == 1:
    print('DENIED')
else:
    print('APPROVED')

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

int main(void)
{
    long long x, k, d; cin >> x >> k >> d;
    long long s = abs(x) / d;
    long long p, q;
    if (x >= 0)
    {
        p = x - d * s;
        q = p - d;
    }
    else
    {
        p = x + d * s;
        q = p + d;
    }
    
    if (k <= s) 
    {
        if (x >= 0) cout << abs(x - d*k) << endl;
        else cout << abs(x + d*k) << endl;
    }
    else
    {
        if (x >= 0)
        {
            p = x - d * s;
            q = p - d;
        }
        else
        {
            p = x + d * s;
            q = p + d;
        }
        long long t = (k - s) % 2;
        if (t == 0) cout << abs(p) << endl;
        else cout << abs(q) << endl;
    }
}


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

string aa[3];

void split(string s) {
    cout << s.length() << endl;
    for (int i = 0; i < (int)s.length(); i++) {
        cout << s[i] << endl;
    }
}

int main(void){
    // Your code here!
    
    string s;
    int i = 0;
    while(cin>>s){
        aa[i] = s;
        i++;
    }
    
    string a_t = aa[1];
    string b_t = aa[0];
    string c_t = aa[2];
    
    cout << c_t << " " << b_t << " " << a_t << " " << endl;
    //split(s);
    
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    map<int,int> mp;
    vector<int> V(1000,1001);
    for(int i = 2; i <= N; i++){
        bool flag = true;
        for(int j = 2; j < i; j++){
            if(i % j == 0){
                flag = false;
                break;
            }
        }
        if(flag == true) V[i] = i;
    }
    sort(V.begin(),V.end());

    for(int i = 2; i <= N; i++){
        int I = i;
        while(I > 1){
            for(int j = 0; V[j] != 1001; j++){
                while(I%V[j] == 0){
                    I /= V[j];
                    mp[V[j]]++;
                }
            }
        }
    }
    long long ans = 1;
    for(auto p : mp){
        ans *= p.second + 1;
        ans %= 1000000007;
        //cout << p.first << "  "<< p.second << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

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

#define REP(i, n) for(ll i = 0; i < n; i++)
















int main(){
    ll n, m;
    cin >> n >> m;
    cout << ((n == m)? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
A, B, K = map(int,input().split())

val1 = K-A

if val1 > 0:
    val2 = B-val1
    if val2 > 0:
        print(str(0)+' '+str(val2))
    else:
        print(str(0)+' '+str(0))
else:
    print(str(-val1)+' '+str(B))

Measured memory_bytes: 3060
import copy
import itertools
import sys

if sys.version[0] == '2':
    range, input = xrange, raw_input

drc = [(-1, 0), (0, 1), (1, 0), (0, -1)]
C_NUM = 6

def dfs(r, c, now_c, next_c):
    tmp_board[r][c] = next_c
    for dr, dc in drc:
        nr, nc = r + dr, c + dc
        if 0 <= nr < H and 0 <= nc < W and tmp_board[nr][nc] == now_c:
            dfs(nr, nc, now_c, next_c)


while True:
    H, W, C = map(int, input().split())
    if not (H | W | C):
        break
    board = [[int(x) - 1 for x in input().split()] for _ in range(H)]
    ans = 0
    for ope in itertools.product(range(C_NUM), repeat=5):
        # print(ope)
        if ope[0] == board[0][0] or ope[-1] != C - 1 or any(ope[i] == ope[i + 1] for i in range(4)):
            continue
        tmp_board = copy.deepcopy(board)
        for color in ope:
            dfs(0, 0, tmp_board[0][0], color)
        dfs(0, 0, tmp_board[0][0], -1)
        cand = sum(row.count(-1) for row in tmp_board)
        if cand > ans:
            ans = cand
    print(ans)

Measured memory_bytes: 6468
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

using namespace std;

void Fast_Read_Out()
{
	ios_base::sync_with_stdio(0);
	cin.tie(), cout.tie();
}

void Random()
{
	unsigned int seed;
	asm("rdtsc" : "=A" (seed));
	srand(seed);        
}

unsigned int Time()
{
	 unsigned int time = clock() / 1000.00;
	 return time;
}

const int inf = int(1e9) + 123;
const int N = int(1e5) + 213;

long long a[N], b[N], c[N];
vector <long long> vc, va;

int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif 
	Random();
	Fast_Read_Out();
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) cin >> b[i];
	for(int i = 1; i <= n; i++) cin >> c[i];
	sort(a + 1, a + n + 1);
	sort(b + 1, b + n + 1);
	sort(c + 1, c + n + 1);
	for(int i = 1; i <= n; i++)
	{
		va.pb(a[i]);
		vc.pb(c[i]);
	}
	long long ans = 0;
	for(int i = 1; i <= n; i++)
	{
		long long cur = b[i];
		long long amount_a = lower_bound(all(va), cur) - va.begin();
		long long amount_c = vc.end() - (upper_bound(all(vc), cur));
		ans += amount_a * amount_c;
	}
	cout << ans;
	#ifdef JUDGE
//		cout << Time() << endl;
	#endif
}
// Easy Peasy Lemon Squeezy

Measured memory_bytes: 4340
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int a = parseInt(sc.next());
		int b = parseInt(sc.next());
		sc.close();
		int mn = Math.min(a,b);
		int mx = Math.max(a,b);
		for (i = 0; i < mx; i++) {
			out.print(mn);
		}
		out.println();
	}
}


Measured memory_bytes: 22608
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#define ALL(X) X.begin(), X.end()
#define SZ(A) int((A).size())
#define RALL(X) X.rbegin(), X.rend()
#define FOR(B) for (size_t i = 0; i < B; i++)
#define FOR2(B) for (size_t j = 0; j < B; j++)
#define FORE(B) for (size_t i = 1; i <= B-1; i++)
#define FORC(A, B) for (size_t i = A; i < B; i++)
#define PRINT(X) cout << X << endl
#define PRINTALL(E, X) { FOR(X) {cout << E[i] << endl; } }
#define PRINTSIDE(E, X) { FOR(X) {cout << E[i] << " ";} }
#define READALLI(V, N) FOR(N) {int x; cin >> x; V.push_back(x); }
#define READALL(V, N) FOR(N) {LL x; cin >> x; V.push_back(x); }
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXN 100000
#define SQRSIZE  317
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VII;
typedef vector<LL>VL;
typedef vector<PII> VPII;
typedef map<int, int> MII;
typedef map<char, int>MCI;
typedef map<string, int> MSI;
typedef set<int> SI;
const int INF = (1 << 30);


int main() {

    int num = 0;
    cin >> num;
    string ans;

    while(num % 10){
        if(num % 10 == 9)
           ans = "1" + ans;
        else
            ans = "9" + ans;

        num /= 10;
    }
    cout << ans << endl;

    return 0;
}






Measured memory_bytes: 256
def main():
    A, B, C, K = [int(x) for x in input().split()]
    ans = 0

    if A >= K:
        print(K)
        return
    
    ans += A
    K -= A

    if B >= K:
        print(ans)
        return
    
    K -= B

    print(ans - K)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9176
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	N, X := nextInt(), nextInt()
	x := make([]int, N+1)
	x[0] = X
	for i := 1; i < N+1; i++ {
		x[i] = nextInt()
	}
	sort.Ints(x)

	// fmt.Println(x)
	// min := 1000000000000
	n := make([]int, N+1)
	n[0] = 0
	for i := 1; i < N+1; i++ {
		n[i] = gcd(n[i-1], abs(x[i]-x[i-1]))
	}
	fmt.Println(n[N])
	// res := make([]int, len(n))
	// res[0] = n[1]
	// for i := 1; i < len(n)-1; i++ {
	// 	gcd(n[i])

	// }

	// fmt.Println(n)

}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}

	return gcd(b, a%b)
}

func abs(a int) int {
	if a < 0 {
		return -1 * a
	}
	return a
}


Measured memory_bytes: 3840