akhauriyash/Code-Regression huggingface dataset:
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    S = [iss() for _ in range(N)]
    S.sort()
    di = {}
    mx = 0
    for s in S:
        if s in di:
            di[s] += 1
            mx = max(di[s], mx)
        else:
            di[s] = 0

    ret = []
    for s in di:
        if di[s] == mx: ret.append(s)
    print(*sorted(ret), sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 35608
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define isin(i,a,b) ((a) <= (i) && (i) < (b))
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll  = long long;
using unit= unsigned;
using ull = unsigned long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vvi = vector<vi>;
using vp  = vector<P>;
void _main(); int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T>string join(const v(T)&v){ stringstream s; rep(i,0,sz(v))s<<' '<<v[i]; return s.str().substr(1); }
template<class T>istream &operator>>(istream&i, v(T)&v){ fore(x,v){ i >> v; } return i; }
template<class T>ostream &operator<<(ostream&o, const v(T)&v){ o<<"["; fore(x,v)o<<x<<","; o<<"]"; return o; }
template<class T>ostream &operator<<(ostream&o, const deque<T>&v){ o<<"deq["; fore(x,v)o<<x<<","; o<<"]"; return o; }
template<class T>ostream &operator<<(ostream&o, const set<T>&v){ o<<"{"; fore(x,v)o<<x<<","; o<<"}"; return o; }
template<class T>ostream &operator<<(ostream&o, const unordered_set<T>&v){ o<<"{"; fore(x,v)o<<x<<","; o<<"}"; return o; }
template<class T>ostream &operator<<(ostream&o, const multiset<T>&v){ o<<"{"; fore(x,v)o<<x<<","; o<<"}"; return o; }
template<class T>ostream &operator<<(ostream&o, const unordered_multiset<T>&v){ o<<"{"; fore(x,v)o<<x<<","; o<<"}"; return o; }
template<class T1,class T2>ostream &operator<<(ostream &o, const pair<T1,T2>&p){ o<<"("<<p.fi<<","<<p.se<<")"; return o; }
template<class TK,class TV>ostream &operator<<(ostream &o, const map<TK,TV>&m){ o<<"{"; fore(x,m)o<<x.fi<<"=>"<<x.se<<","; o<<"}"; return o; }
template<class TK,class TV>ostream &operator<<(ostream &o, const unordered_map<TK,TV>&m){ o<<"{"; fore(x,m)o<<x.fi<<"=>"<<x.se<<","; o<<"}"; return o; }
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
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; }
template<class T>T gcd(T a, T b){ if (b==0){ return a; }else{ return gcd(b, a%b); }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
constexpr double eps = 1e-10;
constexpr int inf = INT_MAX / 2;
constexpr ll infl = 1LL << 60;

void _main() {
  int r;
  cin >> r;
  int ans = 3 * r * r;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <iostream>
#include <limits>
#include <climits>
#include <functional>
#include <numeric>

using namespace std;

#define alloc(type,n) (type*)calloc(sizeof(type),(n));
typedef long long lli;

int n,ma,mb;
vector<int> a;
vector<int> b;
vector<int> c;

int dp[401][401][41];

int solve(int x,int y,int z){
	if(dp[x][y][z]) return dp[x][y][z];
	if(z == 0) return dp[x][y][z] = 400001;
	if(x-a[z] < 0 || y-b[z] < 0) return dp[x][y][z] = solve(x,y,z-1);
	int cost = min(solve(x-a[z],y-b[z],z-1)+c[z],solve(x,y,z-1));
	if(a[z] == x && b[z] == y) return dp[x][y][z] = min(c[z],cost);
	return dp[x][y][z] = cost;
}


int main(){
	cin >> n >> ma >> mb;
	a = vector<int>(n);
	b = vector<int>(n);
	c = vector<int>(n);
	for(int i = 0;i < n;i++){
		cin >> a[i] >> b[i] >> c[i];
	}
	dp[a[0]][b[0]][0] = c[0];

	int res = 400001;
	for(int i = 1;ma*i <= 400 && mb*i <= 400;i++){
		int cost = solve(ma*i,mb*i,n-1);
		res = min(cost,res);
	}
	if(res == 400001){
		cout << -1 << endl;
		return 0;
	}
	cout << res << endl;


	return 0;
}


Measured memory_bytes: 23552
import java.util.*;
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		boolean[] isPrime = new boolean[1000000+10];
		Arrays.fill(isPrime, true);
		isPrime[0]=isPrime[1]=false;
		for(int i = 2; i*i <= isPrime.length;i++){
			if(isPrime[i]){
				for(int j = i+i; j < isPrime.length; j+=i){
					isPrime[j]=false;
				}
			}
		}
		Scanner cin = new Scanner(System.in);
		while(true){
			int n = cin.nextInt();
			if(n==0){
				break;
			}
			int count = 0;
			for(int i = 2; i <= n/2;i++){
				if(isPrime[i] && isPrime[n-i]){
					count++;
				}
			}
			System.out.println(count);
		}
	}

}

Measured memory_bytes: 13000
import java.util.*;
public class Main  {
   public static void main(String[] args)  {
      Scanner sc = new Scanner(System.in);
      
      int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
      
      int k = sc.nextInt();       
                  
      System.out.println(a[k-1]);
               
   }        
}


Measured memory_bytes: 23508
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <list>
#include <stack>

using namespace std;

/* constant */

const int INF = 1 << 30;
const int mod = 1000000007;
const int MAX_N = 100000;

/* typedef */

typedef long long ll;

/* global variables */

vector< vector<int> > Adj(MAX_N, vector<int>());
vector<int> link(MAX_N, -1);
int n;

/* function */
void bfs(int start);

/* main */
int main() {

    int m; cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int u, v; cin >> u >> v;
        Adj[u].push_back(v);
        Adj[v].push_back(u);
    }

    for (int i = 0; i < n; i++) {
        if (link[i] == -1) {
            bfs(i);
        }
    }

    int q; cin >> q;
    for (int i = 0; i < q; i++) {
        int u, v; cin >> u >> v;
        if (link[u] == link[v]) {
            cout << "yes" << '\n';
        }
        else {
            cout << "no" << '\n';
        }
    }
}

void bfs(int start) {
    
    link[start] = start;
    queue<int> q;
    q.push(start);

    while (!q.empty()) {

        int cur = q.front(); q.pop();

        for (auto v : Adj[cur]) {

            if (link[v] == -1) {
                link[v] = start;
                q.push(v);
            }

        }

    }
}



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

int main()
{
  while (true)
  {
    int n;
    cin >> n;
    if (!static_cast<bool>(n)) break;

    int DP[30 + 3] = {0};
    DP[0] = 1;

    for (int i = 1; i <= n; ++i)
    {
      for (int j = 0; j < 3; ++j)
      {
        DP[i + j] += DP[i - 1];
      }
    }

    int ans = (((DP[n] + 9) / 10) + 364) / 365;

    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 2996
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
string N;
const int MAX_D = 20;
int dp[MAX_D][2]; //(pos, small)
int M;
void init()
{
    for (int i = 0; i < MAX_D; i++)
    {
        for (int j = 0; j < 2; j++)
        {
            dp[i][j] = -INF;
        }
    }
}
int main()
{
    init();
    cin >> N;
    M = N.size();
    dp[0][0] = 0;
    int result = 0;

    for (int i = 0; i < M; i++)
    {
        for (int j = 0; j < 2; j++)
        {
            if (dp[i][j] <= -INF)
            {
                continue;
            }
            int max_val = 9;
            if (j == 0)
            {
                max_val = N[i] - '0';
            }
            for (int k = 0; k < max_val; k++)
            {
                dp[i + 1][1] = max(dp[i + 1][1], dp[i][j] + k);
            }
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + max_val);
            // cerr << i << " " << j << " " << dp[i][j] << " " << max_val << endl;
        }
    }
    for (int j = 0; j < 2; j++)
    {
        result = max(result, dp[M][j]);
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
program main
	implicit none
    integer n,k,i
    integer,allocatable::x(:)
    integer::ans=0
    read *,n
    read *,k
    allocate(x(n))
    read *,x(:)
    do i=1,n
    	ans=ans+min(x(i),abs(x(i)-k))
    end do
    print '(i0)',ans*2
end program main

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,v;
	while(cin>>N>>M) {
		VI w(N);
		VI s(N);
		map<ll, ll> m;
		REP(i, N) {
			cin>>w[i];
			s[i] = (i>0?s[i-1]:0)+w[i];
			m[s[i]%M]++;
		}
//		DD(m);
		ll ans = 0;
		ll k=0;
		REP(i, N) {
//			DD(k);
			ans += m[k];
//			DD(m[k]);
			if(0)
			{
				ll cnt=0;
				ll z = 0;
				RANGE(j, i, N) {
					z+=w[j];
					if(z%M==0) {
						cnt++;
//						DD(j);
					}
				}
//				DD(cnt);
			}
			k = (k+w[i]%M+M)%M;
			m[s[i]%M]--;
//			DD(m);
		}
		
		cout<<ans<<endl;
//		break;
	}
	
	return 0;
}


Measured memory_bytes: 5760
S=str(input())
sr=S[::-1]
sr=sr.replace('b','D')
sr=sr.replace('d','B')
sr=sr.replace('p','Q')
sr=sr.replace('q','P')

sr=sr.replace('D','d')
sr=sr.replace('B','b')
sr=sr.replace('P','p')
sr=sr.replace('Q','q')

if S==sr:
    print('Yes')
else:
    print('No')


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
//const int mod = 100000;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  ll a, b, c;
  cin >> a >> b >> c;
  if(c-a-b <= 0) {
    cout << "No" << endl;
    return 0;
  }
  if(4*a*b < (c-a-b)*(c-a-b)) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3572
import Data.Char

baseConvertTo :: Integer -> Integer -> [Integer]
baseConvertTo b n
  | n < b = [n]
  | otherwise =  (n `mod` b) : baseConvertTo b (n `div` b)

fill :: Int -> a -> [a] -> [a]
fill n y xs
  | l < n = take (n - l) (repeat y) ++ xs
  | otherwise = xs
  where l = length xs


f :: Integer -> [Char]
f n = g n 26 1
  where
    g n s k
      | n <= s = map (chr . (+ 0x61) . fromIntegral) $ fill k 0 $ reverse $ baseConvertTo 26 (n - 1)
      | otherwise = g (n - s) (s * 26) (k + 1)


main :: IO ()
main = do
  n <- readLn :: IO Integer
  
  putStrLn $ f n


Measured memory_bytes: 3964
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する


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

    int N;
    cin >> N;

    vector<ll> D(N);
    map<ll, int> Dtov;
    rep(i, 0, N) cin >> D[i];
    rep(i, 0, N) Dtov[D[i]] = i + 1;

    sort(D.rbegin(), D.rend());

    vector<vector<int> > G(N + 1, vector<int>());//自分の親
    vector<vector<int> > rG(N + 1, vector<int>());//自分の子供
    vector<int> childs(N + 1, 1); //部分木の数

    for (int i = 0; i < N - 1; ++i) {
//        ll dec = N - 2 * (1 + rG[Dtov[D[i]]].size());
        ll dec = N - 2 * childs[Dtov[D[i]]];
//        if (find(all(D), D[i] - dec) == D.end()) {
//            cout << -1 << endl;
//            return 0;
//        }

        if (*lower_bound(all(D), D[i] - dec) == D[i] - dec) {
            cout << -1 << endl;
            return 0;
        }

        G[Dtov[D[i]]].push_back(Dtov[D[i] - dec]);
        rG[Dtov[D[i] - dec]].push_back(Dtov[D[i]]);
        childs[Dtov[D[i] - dec]] += childs[Dtov[D[i]]];
    }

    function<ll(int, int)> treesize = [&](int v, int dist) {
        ll ret = dist;

        for (auto e : rG[v]) {
            ret += treesize(e, dist + 1);
        }

        return ret;
    };

    ll min_tree_size = treesize(Dtov[D.back()], 0);
    if (min_tree_size != D.back()) {
        cout << -1 << endl;
        return 0;
    }

    for (int i = 1; i <= N; ++i) {
        for (auto e : G[i]) {
            cout << i << " " << e << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 22912
import itertools
import numpy as np

N ,M, X = map(int, input().split())
l = []
for i in range(N):
    l.append(list(map(int, input().split())))


zeroone = [0, 1]
zeroone_list = list(itertools.product(zeroone, repeat=N))

ans = float('inf')

for i in range(len(zeroone_list)):
    temp_l = [0]*(M+1)
    for j in range(N):
        if zeroone_list[i][j] == 1:
            temp_l = list(np.array(temp_l) + np.array(l[j]))

    if min(temp_l[1:M+1]) >= X:
        ans = min(ans, temp_l[0])

if ans == float('inf'):
    print(-1)
else:
    print(ans)

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


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define f(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
ll a[100000];
ll pre(ll i,ll k){
ll ans=0;
for(ll j=i;j<=k;j++){
ans+=a[j];
}
return ans;
}
int main(){
ll n;
cin>>n;

f(i,1,n+1)cin>>a[i];

ll dp[n+1][n+1];
f(i,0,n+1){
  f(j,0,n+1){
    dp[i][j]=0;
  }
}
ll ma=1e17;
for(ll l=2;l<=n;l++){
for(ll i=1;i<=n-l+1;i++){
ll j=i+l-1;
dp[i][j]=ma;
for(ll k=i;k<j;k++){
 // cout<<" "<<i<<" "<<j<<" "<<k<<" "<<" "<<pre(i,k)<<" "<<pre(k+1,j)<<endl;
  ll val=dp[i][k]+dp[k+1][j]+pre(i,j);
//  cout<<i<<" "<<j<<" "<<val<<endl;
  if(dp[i][j]>=val){
    dp[i][j]=val;
  }

}
//cout<<" fi "<<dp[i][j]<<endl;

}

 }
// f(i,0,n+1){
//   f(j,0,n+1){
//     cout<<dp[i][j]<<" ";
//   }cout<<endl;
// }
cout<<dp[1][n]<<endl;




    }





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

using namespace std;

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

    int dp[n+1][3];
    memset(dp,0,sizeof(dp[0][0]) *(n+1) * 3);

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

        int a[3];

        for(int j=0;j<3;j++){
           cin >> a[j];
        }

        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(j != k){
                    dp[i][k] = max(dp[i][k], dp[i-1][j]+ a[k]);
                }

            }
        }
    }

    cout << max(dp[n][0],max(dp[n][1],dp[n][2])) << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
const int maxn = int(1e5) + 7;
int n, same[maxn];
struct Ans {
    bool data[maxn];
    bool & operator [] (int index) {
        return data[(index + n) % n];
    }
} S;
void gao(int cur, int other) {
    bool flag = true;
    if (S[cur]) flag = false;
    if (same[cur] ^ flag) S[cur * 2 - other] = S[other];
    else S[cur * 2 - other] = !S[other];
}
bool check(int cur) {
    bool flag = true;
    if (S[cur]) flag = false;
    if (same[cur] ^ flag) return S[cur - 1] == S[cur + 1];
    return S[cur - 1] ^ S[cur + 1];
}
int main() {
//    freopen("in.txt", "r", stdin);
    scanf("%d", &n);
    char ch;
    for (int i = 0; i < n; i++) scanf(" %c", &ch), same[i] = ch == 'o';
    bool flag = false;
    for (int i = 1; i >= 0 && (!flag); i--)
        for (int j = 1; j >= 0 && (!flag); j--) {
            S[0] = bool(i), S[1] = bool(j);
            gao(0, 1);
            for (int cur = 1; cur < n - 2; cur++) gao(cur, cur - 1);
            if (check(n - 2) && check(n - 1)) flag = true;
        }
    if (flag) for (int i = 0; i < n; i++) printf("%c%s", S[i] ? 'S' : 'W', i == n - 1 ? "\n" : "");
    else puts("-1");
    return 0;
}

Measured memory_bytes: 768
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;


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

	vector<ll> c(n + 1);

	for (int i = 2; i <= n; i++)
	{
		int x = i;
		for (int j = 2; j <= x; j++)
		{
			while (x > 0 && x % j == 0)
			{
				c.at(j)++;
				x /= j;
			}
		}
	}

	ll ans = 1;
	for (int i = 0; i <= n; i++)
	{
		if (c.at(i) > 0)
		{
			ans *= c.at(i) + 1;
			ans %= mod;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		out((int) Math.ceil((nd() + nd()) / 2.0));

	}

	/*
	 * 以下メソッド集
	 */

	public static void permutation(String q, String ans) {
		// Base Case
		if (q.length() <= 1) {
			System.out.println(ans + q);
		}
		// General Case
		else {
			for (int i = 0; i < q.length(); i++) {
				permutation(q.substring(0, i) + q.substring(i + 1),
						ans + q.charAt(i));
			}
		}
	}

	static char[][] same(char[][] c, int h, int w) {

		char[][] a = new char[h][w];
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				a[i][j] = c[i][j];
			}
		}
		return a;

	}

	static int countkuro(char[][] c) {

		int count = 0;
		for (char[] cc : c) {
			for (char ccc : cc) {
				if ('#' == ccc) {
					count++;
				}
			}
		}
		return count;
	}

	static void debug() {

		out("---");
	}

	static void debug(Object a) {

		out("-------");
		out(a);
		out("-------");
	}

	static int ketasuu(int n) {

		String str = "" + n;
		return str.length();
	}

	static int account(String str) {

		String target = "AC";
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if (target.equals(str.substring(i, i + target.length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {

		return sc.nextInt();
	}

	static long nl() {

		return sc.nextLong();
	}

	static double nd() {

		return sc.nextDouble();
	}

	static String n() {

		return sc.next();
	}

	static char[] nc() {

		return sc.next().toCharArray();
	}

	static int kaijo(int n) {

		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {

		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {

		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {

		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(Object obj) {
		System.out.println(obj);
	}

	static void outn(Object obj) {
		System.out.print(obj);
	}

	static double max(double d, double e) {

		return Math.max(d, e);
	}

	static long max(long a, long b) {

		return Math.max(a, b);
	}

	static long min(long d, long e) {

		return Math.min(d, e);
	}

	static int min(int a, int b) {

		return Math.min(a, b);
	}
}

class XY {

	int h;
	int w;
	int d;

	XY(int h, int w, int d) {
		this.h = h;
		this.w = w;
		this.d = d;
	}
}


Measured memory_bytes: 37380
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int K = scanner.nextInt();
    int[] A = new int[N];
    int max = 0;
    for (int i = 0; i < N; i++) {
      A[i] = scanner.nextInt();
      max = Math.max(max, A[i]);
    }
    if (K > max) {
      System.out.println("IMPOSSIBLE");
      return;
    }

    int gcd = A[0];
    for (int i = 0; i < N; i++) gcd = gcd(gcd, A[i]);
    if (K % gcd == 0) {
      System.out.println("POSSIBLE");
    } else {
      System.out.println("IMPOSSIBLE");
    }
  }

  static int gcd(int i, int j) {
    if (i > j) return gcd(j, i);
    while (i > 0) {
      int r = j % i;
      j = i;
      i = r;
    }
    return j;
  }
}


Measured memory_bytes: 50572
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define pb(v) push_back(v)
#define all(s) s.begin(),s.end()

int main() {
	//code
	
     ios_base::sync_with_stdio(false); 
     cin.tie(NULL);
      
        int n;
        cin>>n;
        int a[n],s=0;
        f(i,0,n)cin>>a[i],s+=a[i];
        
        int m;
        cin>>m;
        int x,y;
        f(i,0,m)
        {
        	cin>>x>>y;
        	cout<<s-a[x-1]+y<<endl;
		}
        
        
 return 0;

}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
def input():
	return sys.stdin.readline()[:-1]

n = int(input())
c = list(map(int, input().split()))
ans = [n*(n+1)//2 for _ in range(n)]
for i in range(n):
	c[i] -= 1
adj = [[] for _ in range(n)]
for _ in range(n-1):
	a, b = map(int, input().split())
	adj[a-1].append(b-1)
	adj[b-1].append(a-1)

s = 0
dp = [0 for _ in range(n)]

def dfs(x, p):
	global s
	pres = s + dp[c[x]]
	for v in adj[x]:
		if v == p:
			continue
		dp[c[x]] = -s
		dfs(v, x)
		ans[c[x]] -= (s+dp[c[x]]) * (s+dp[c[x]]+1) // 2
	s += 1
	dp[c[x]] = pres - s
	return

dfs(0, -1)
for i in range(n):
	ans[i] -= (s+dp[i]) * (s+dp[i]+1) // 2

print(*ans, sep="\n")

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

int main(){
  int a,b,N;
  cin >> a >> b >> N;

  int A[1000] = {0};
  int count1 = 0,count2 = 0;
  for(int i = a; i < b; i++){
    A[i] = 1;
    count1++;
  }

  int x,y;
  for(int i = 0; i < N; i++){
    cin >> x >> y;
    for(int i = x; i < y; i++){
      A[i] = 0;
    }
  }

  for(int i = 0; i < 1000; i++){
    if(A[i] == 1)count2++;
  }
  if(count1 == count2)cout << '0' << endl;
  else cout << '1' << endl;

  return 0;
}



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

int main(void)
{
  	char	s[200002];
  	char	t[200002];
  	int		i;
  	int		len;
  	int		cnt;
  
  	scanf("%s", s);
  	scanf("%s", t);
  
  	len = strlen(s);
  	cnt = 0;
  	for(i=0; i<len; i++)
    {
      	if(s[i] != t[i])
        {
          	cnt++;
        }
    }
  	printf("%d", cnt);
  	return (0);
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vi a(n);
    rep(i,n) cin>>a[i];
    vi b(n);
    RFOR(i,n,1){
        int p=0;
        for(int j=i-1; j<n; j+=i)
            if (b[j]) p=1-p;
        if (p!=a[i-1]) b[i-1]=1;
    }
    vi ans;
    rep(i,n)if(b[i]) ans.pb(i+1);
    cout<<ans.size()<<"\n";
    rep(i,ans.size()){
        if (i>0) cout<<" ";
        cout<<ans[i]<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3320
#include<stdio.h>
int main()
{
    int a,b,c;
    while(scanf("%d%d%d",&a,&b,&c)!=EOF)
    {
        if(a<b)
        {
            if(b<c)
                printf("Yes\n");
            else
                printf("No\n");
        }
        else
            printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 1008
import sys
s=input()
t=input()

sn=[ord(s[i]) for i in range(len(s))]
tn=[ord(t[i]) for i in range(len(t))]

sn.sort()
tn.sort(reverse=True)

for i in range(min(len(tn), len(sn))):
    if tn[i] > sn[i]:
        print('Yes')
        sys.exit()
    elif tn[i] < sn[i]:
        print('No')
        sys.exit()

if len(tn) > len(sn):
    print('Yes')
else:
    print('No')

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

int main() {
  int D, G, p[11], c[11];
  cin >> D >> G;
  for (int i = 0; i < D; ++i) {
    cin >> p[i] >> c[i];
  }

  int ans = 1e9;
  for (int mask = 0; mask < (1 << D); ++mask) {
    int s = 0, num = 0, rest_max = -1;
    for (int i = 0; i < D; ++i) {
      if (mask >> i & 1) {
        s += 100 * (i + 1) * p[i] + c[i];
        num += p[i];
      } else {
        rest_max = i;
      }
    }
    if (s < G) {
      int s1 = 100 * (rest_max + 1);
      int need = (G - s + s1 - 1) / s1;
      if (need >= p[rest_max]) {
        continue;
      }
      num += need;
    }
    ans = min(ans, num);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll maxi = a * c;
    maxi = max(maxi, a * d);
    maxi = max(maxi, b * c);
    maxi = max(maxi, b * d);
    cout << maxi << "\n";
    return 0;
}

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

int	main() {
	int N, M;
	cin >>N >>M;
	vector<int> A(N);
	for (int i=0; i<N; i++)
		cin >>A.at(i);
	sort(A.begin(), A.end());
	reverse(A.begin(), A.end());
	while (true) {
		int AA=A.at(0)/2;
		int i=0;
		while ((i<N)&&(M>0)&&(A.at(i)>=AA)) {
			A.at(i) /=2;
			M--;
			i++;
		}
		if (0==M)
			break;
		sort(A.begin(), A.end());
		reverse(A.begin(), A.end());
	}
	long S=0;
	for (int i=0; i<N; i++)
		S +=A.at(i);
	cout <<S <<endl;
	return 0;
};


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

using namespace std;

int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int N;
  cin >> N;
  vector < long double > dp(N + 1);
  dp[0] = 1;
  for (int coin = 0; coin < N; ++coin) {
    double p_heads;
    cin >> p_heads;
    for (int i = coin + 1; i >= 0; --i)
      dp[i] = (i == 0 ? 0 : dp[i - 1] * p_heads) + dp[i] * (1 - p_heads);
  }
  long double ans = 0;
  for (int heads = 0; heads <= N; ++heads) {
    int tails = N - heads;
    if (heads > tails)
      ans += dp[heads];
  }
  cout << fixed << setprecision(10) << ans;
}


Measured memory_bytes: 3904
#include <cstdio>
#include <cstring>
int a[10001]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{int k;
	scanf("%d",&k);printf("%d\n",a[k-1]);return 0;
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int x[] = {400, 800, 1200, 1600, 2000, 2400, 2800, 3200, 5000};
int a[mx2];

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

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

        for(int j = 0; j <= 8; j++){
            if(a[i] < x[j]){
                a[i] = j;
                break;
            }
        }
    }

    set<int> st;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(a[i] < 8)
            cnt++, st.In(a[i]);
    }

    int x = st.size();
    if(x == 0)
        cout << 1 << ' ' << n << '\n';
    else
        cout << x << ' ' << n - cnt + x << '\n';
    return 0;
}


Measured memory_bytes: 3628
inp=list(map(int,input().split()))
x=inp[0]
k=inp[1]
d=inp[2]
if x<0:
    flag=1
else:
    flag=0
if x==0:
    if k%2==0:
        print (0)
    else:
        print (d)
else:
    ini=x
    x=abs(x)
    a=x%d
    z=(x-a)//d
    if z>=k:
        if flag==1:
            final=ini+k*d
        else:
            final=ini-k*d
        print (abs(final))
    else:
        if flag==1:
            a=-1*a
        k-=z
        final=a
        if k%2==0:
            print (abs(final))
        else:
            if final<0:
                final+=d
                print (abs(final))
            else:
                final-=d
                print (abs(final))

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 100002;

int n, fact[N], inv[N], mod = 1e9 + 7;
vector <int> a;

int powlog(int a, int b){
    if(b == 0) return 1;
    int ret = powlog(a, b / 2);
    if(b % 2) return 1LL * ret * ret % mod * a % mod;
    return 1LL * ret * ret % mod;
}
int C(int n, int r){
    if(r > n) return 0;
    return 1LL * fact[n] * inv[n - r] % mod * inv[r] % mod;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    fact[0] = 1;
    for(int i = 1 ; i < N ; i++){
        fact[i] = 1LL * i * fact[i - 1] % mod;
    }
    inv[N - 1] = powlog(fact[N - 1], mod - 2);
    for(int i = N - 2 ; i >= 0 ; i--){
        inv[i] = 1LL * (i + 1) * inv[i + 1] % mod;
    }
    cin >> n;
    n++;
    a.resize(n);
    for(auto &i : a){
        cin >> i;
        i--;
    }
    vector <int> las(n, -1);
    int f = -1;
    for(int i = 0 ; i < n ; i++){
        if(las[a[i]] != -1){
            f = n - i - 1;
            f += las[a[i]];
            break;
        }
        las[a[i]] = i;
    }
    for(int k = 1 ; k <= n ; k++){
        cout << (C(n, k) - C(f, k - 1) + mod) % mod << "\n";
    }
}


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

int main()
{
    long long n,a=0;
    std::cin >> n;
    for (int i = 0; i < 5; i++) {
        long long tmp;
        std::cin >> tmp;
        if (a == 0 || a > tmp)
            a = tmp;
    }

    long long ans = n/a + (n%a ? 1 : 0) + 4;
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pii;
#define X first
#define Y second
const int N = 1e5 + 87;
pii p[N];
mt19937 ran(time(0));
struct treap
{
    int p,s,k,l,r;
} t[N * 2];
int mem_ptr;
int new_treap(int k)
{
    int o = ++mem_ptr;
    t[o].p = ran();
    t[o].s = 1;
    t[o].k = k;
    t[o].l = t[o].r = 0;
    return o;
}
void pull(int o)
{
    t[o].s = t[t[o].l].s + 1 + t[t[o].r].s;
}
int meld(int a,int b)
{
    if (!a || !b)
        return a ? a : b;
    if (t[a].p > t[b].p) {
        t[a].r = meld(t[a].r, b);
        pull(a);
        return a;
    } else {
        t[b].l = meld(a,t[b].l);
        pull(b);
        return b;
    }
}
void split(int o,int k,int & a,int & b)
{
    if (!o) {
        a = b = 0;
        return;
    }
    if (p[t[o].k].X < k) {
        a = o;
        split(t[o].r,k,t[a].r,b);
        pull(a);
    } else {
        b = o;
        split(t[o].l,k,a,t[b].l);
        pull(b);
    }
}
void insert(int & r,int k)
{
    int a,b;
    split(r,p[k].X,a,b);
    r = meld(meld(a,new_treap(k)),b);
}

map<int,int> ma,ms;
queue<int> q;
bitset<N> vis;
int w[N];
int cal(int & o,int l,int r)
{
    int a,b,c;
    split(o,l,a,b);
    split(b,r+1,b,c);
    int ret = t[b].s;
    o = meld(meld(a,b),c);
    return ret;
}
void walk(int o)
{
    if (!o)
        return;
    if (!vis[t[o].k]) {
        q.push(t[o].k);
        vis[t[o].k] = 1;
    }
    walk(t[o].l);
    walk(t[o].r);
}
void upd(int & o,int l,int r)
{
    int a,b,c;
    split(o,l,a,b);
    split(b,r+1,b,c);
    walk(b);
    o = meld(a,c);
}
int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,a,b;
    cin >> n >> a >> b;
    --a,--b;
    for (int i = 0; i < n; ++i) {
        cin >> p[i].X >> p[i].Y;
        insert(ma[p[i].X+p[i].Y], i);
        insert(ms[p[i].X-p[i].Y], i);
    }
    int d = abs(p[a].X - p[b].X) + abs(p[b].Y - p[a].Y);
    for (int i = 0; i < n; ++i) {
        w[i] = cal(ma[d + p[i].X + p[i].Y], p[i].X, p[i].X+d-1)
            + cal(ms[d + p[i].X - p[i].Y], p[i].X+1, p[i].X+d)
            + cal(ma[-d + p[i].X + p[i].Y], p[i].X-d+1, p[i].X)
            + cal(ms[-d + p[i].X - p[i].Y], p[i].X-d, p[i].X-1);
    }
    q.push(a);
    vis[a] = 1;
    int ans = 0;
    while (q.size()) {
        int i = q.front();
        q.pop();
        ans += w[i];
        upd(ma[d + p[i].X + p[i].Y], p[i].X, p[i].X+d-1);
        upd(ms[d + p[i].X - p[i].Y], p[i].X+1, p[i].X+d);
        upd(ma[-d + p[i].X + p[i].Y], p[i].X-d+1, p[i].X);
        upd(ms[-d + p[i].X - p[i].Y], p[i].X-d, p[i].X-1);
    }
    cout << ans / 2 << endl;
}


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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  string N;
  cin>>N;
  int cnt(0);
  for(int i(0);i<4;i++){
    if(N[i] == '2') cnt++;
  }
  cout << cnt << endl;
  return 0;
}



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

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

  map<char, int> mn;
  for (char c = 'a';; c++) {
    mn[c] = 1e9;
    if (c == 'z') {
      break;
    }
  }

  for (int i = 0; i < n; i++) {
    map<char, int> cnt;

    string s;
    cin >> s;
    for (int j = 0; j < s.size(); j++) {
      cnt[s[j]]++;
    }

    for (char c = 'a';; c++) {
      mn[c] = min(mn[c], cnt[c]);
      if (c == 'z') {
        break;
      }
    }
  }

  string ans = "";
  for (char c = 'a';; c++) {
    for (int i = 0; i < mn[c]; i++) {
      ans = ans + c;
    }

    if (c == 'z') {
      break;
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	scanf("%d", &n);
	set<string> s;
	for (int i = 0; i < n; i++) {
		string t;
		cin >> t;
		s.insert(t);
	}
	vector<long long> a(5);
	for (auto t : s) {
		if (t[0] == 'M')
			a[0]++;
		else if (t[0] == 'A')
			a[1]++;
		else if (t[0] == 'R')
			a[2]++;
		else if (t[0] == 'C')
			a[3]++;
		else if (t[0] == 'H')
			a[4]++;
	}
	long long ans = 0;
	for (int i = 0; i < 3; i++) {
		for (int j = i + 1; j < 4; j++) {
			for (int k = j + 1; k < 5; k++) { ans += a[i] * a[j] * a[k]; }
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 10112
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int k,n;
  int max = 0;
  cin >> k >> n;
  int i;
  vector<int> a(200001);
  for(i=0;i<n;i++){
    cin >> a.at(i);
  }
  for(i=0;i<n-1;i++){
    if(max<(a.at(i+1)-a.at(i))){
      max = (a.at(i+1)-a.at(i));
    }
  }
  if(max<(k-a.at(n-1)+a.at(0))){
    max = (k-a.at(n-1)+a.at(0));
  }
  cout << k - max << "\n";
}

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

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	string s;
	cin >> s;
	
	int n = s.size();
	
	int ans = INF;
	for(int i = 0; i < n - 2; ++i){
		string sp;
		for(int k = i; k <= i + 2; ++k){
			sp += s[k];
		}
		int v = stoi(sp);
		ans = min(ans, abs(v - 753));
	}
	
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

const int N=105,M=1e7+5;

typedef long long LL;

int n,tot,p[M],f[N],vis[N],now,ans,s1,a[N],s2,b[N],cnt;

bool bz[M],Bit[M],g[N][N],u1[N],u2[N];

bool Check(int x)
{
	if (vis[x]==now) return 0;
	vis[x]=now;
	for (int i=1;i<=s2;i++) if (g[x][i])
	{
		if (!f[i] || Check(f[i]))
		{
			f[i]=x; return 1;
		}
	}
	return 0;
}

int main()
{
	bz[1]=1;
	for (int i=2;i<M;i++)
	{
		if (!bz[i]) p[tot++]=i;
		for (int j=0;j<tot && i*p[j]<M;j++)
		{
			bz[i*p[j]]=1;
			if (i%p[j]==0) break;
		}
	}
	scanf("%d",&n);
	for (int x,i=1;i<=n;i++)
	{
		scanf("%d",&x);
		Bit[x]^=1;
	}
	for (int i=1;i<M;i++) if (Bit[i]^Bit[i-1])
	{
		if (i&1) a[++s1]=i;else b[++s2]=i;
	}
	for (int i=1;i<=s1;i++) for (int j=1;j<=s2;j++) if (!bz[abs(a[i]-b[j])]) g[i][j]=1;
	for (now=1;now<=s1;now++) ans+=Check(now);
	for (int i=1;i<=s2;i++) if (f[i]) u1[f[i]]=u2[i]=1;
	for (int i=1;i<=s1;i++) if (!u1[i]) cnt++;
	ans+=(cnt/2)*2;
	cnt=0;
	for (int i=1;i<=s2;i++) if (!u2[i]) cnt++;
	ans+=(cnt/2)*2;
	if (cnt&1) ans+=3;
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N, K;
    cin >> N >> K;
    vec A(N+1);
    REP(i,1,N+1) cin >> A[i];

    REP(i,K+1,N+1) {
        if(A[i] > A[i-K]) PR("Yes");
        else PR("No");
    }

    return 0;
}

/*



*/

Measured memory_bytes: 4776
#include<iostream>
#include<string>
#define PLUS 0
#define MINUS 1
using namespace std;

string num;
int op[5];

bool dfs(int pos,int ans);
int main(){
  cin>>num;
  dfs(1,num[0]-'0');
  
  cout<<num[0];
  for(int i=1;i<=3;i++){
    if(op[i]==PLUS){
      cout<<'+';
    }else{
      cout<<'-';
    }
    cout<<num[i];
  }
  cout<<"=7"<<endl;
  return(0);
}

bool dfs(int pos,int ans){
  if(pos==4){
    if(ans==7){
      return(true);
    }
    return(false);
  }
  
  op[pos]=PLUS;
  if(dfs(pos+1,ans+num[pos]-'0')==true){
    return(true);
  }
  op[pos]=MINUS;
  return(dfs(pos+1,ans-num[pos]+'0'));
}
   

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
   int N, i, j, k, x, m, minj;

   scanf("%d", &N);

   int A[N];

   for(i = 0; i < N; i++) {
      scanf("%d", &A[i]);
   }

   m = 0;

   for(i = 0; i < N; i++){
      minj = i;
      for(j = i; j < N; j++){
         if (A[j] < A[minj]){
            minj = j;
         }
      }
      if (minj != i){
            x = A[i];
            A[i] = A[minj];
            A[minj] = x;
            m++;
      }
   }

   for(k = 0; k < N - 1; k++) {
      printf("%d ", A[k]);
   }
   printf("%d\n", A[N - 1]);

   printf("%d\n", m);

   return 0;
}


Measured memory_bytes: 2140
import java.util.Scanner;

/**
 * https://abc058.contest.atcoder.jp/tasks/abc058_a
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		sc.close();
		
		String ans = b-a == c-b ? "YES" : "NO";
 
		System.out.println(ans);
		

	}

}

Measured memory_bytes: 22608