akhauriyash/Code-Regression huggingface dataset:
const [meta,a,b,c] = require('fs').readFileSync('/dev/stdin', 'utf-8').split('\n');

const [X,Y,Z,K] = meta.trim().split(' ').map(i => parseInt(i));
const A = a.trim().split(' ').map(i => parseInt(i)).slice(0,X).sort((a,b)=>b-a);
const B = b.trim().split(' ').map(i => parseInt(i)).slice(0,Y).sort((a,b)=>b-a);
const C = c.trim().split(' ').map(i => parseInt(i)).slice(0,Z).sort((a,b)=>b-a);

const result = [];
const queue = [{
    p: A[0]+B[0]+C[0],
    x: 0,
    y: 0,
    z: 0
}];

const done = {};

const addToQueue = (p,x,y,z) => {
    if (!queue.find(v => v.p === p && v.x === x && v.y === y && v.z === z)
    && !done[`${x},${y},${z}`]) {
        queue.push({p,x,y,z});
    }
}

const min = (i,arr) => Math.min(i,arr.length - 1);

Array.from(Array(K)).forEach(() => {
    const largest = queue.sort((a,b)=>a.p-b.p).pop();
    result.push(largest);
    const {x,y,z} = largest;
    done[`${x},${y},${z}`] = true;
    addToQueue(A[min(x+1,A)]+B[y]+C[z],min(x+1,A),y,z);
    addToQueue(A[x]+B[min(y+1,B)]+C[z],x,min(y+1,B),z);
    addToQueue(A[x]+B[y]+C[min(z+1,C)],x,y,min(z+1,C));
});

console.log(result.map(v => v.p).join('\n'));

Measured memory_bytes: 18720
while 1:
    def solver(a, b, c, d, e, f):
        answer = []

        if d == 0:
            y = f / e
            x = (c - b * y)/a

        else:
            m = a / d

            d = d * m
            e = e * m
            f = f * m

            y = (c - f)/(b - e)

            x = (c - b * y)/a

            if x == -0:
                x = 0
            if y == -0:
                y = 0

        answer.append(x)
        answer.append(y)
        return answer

    try:
        p_1, p_2, p_3, p_4, p_5, p_6 = map(float, raw_input().split())

        ans = []
        ans = solver(p_1, p_2, p_3, p_4, p_5, p_6)

        print "%.3f %.3f" % (ans[0], ans[1])

    except:
        break

Measured memory_bytes: 4704
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>

using namespace std;


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

	if (A <= 5) {
		cout << 0 << endl;
	}
	else if (A <= 12) {
		cout << B / 2 << endl;
	}
	else {
		cout << B << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  
  int n_intervals, budget;
  //read in number of intervals, and budget
  cin >> n_intervals >> budget;

  //pair with probability of attack and distance (of each interval)
  pair<int, int> PD[10010];
  
  int p, d;
  while (!(n_intervals == 0 && budget == 0)) { //while not end of input
    for (int i = 0; i < n_intervals; i++) {
      // read distance and probability 
      cin >> d >> p;
      PD[i] = make_pair(p,d); // store in array
    }
    
    //sort the array in descending order
    sort(PD, PD + n_intervals);
    reverse(PD, PD + n_intervals);

    int i = 0;
    
    while (budget > PD[i].second && i < n_intervals) {
      //while budget bigger than distance of current interval
      budget -= PD[i++].second; //subtract from budget
    }

    
    if (i < n_intervals) {
      PD[i].second -= budget; //subtract from current interval budget (remainder)
    }

    int sum = 0; //sum of expected attacks
    for (; i < n_intervals; i++) {
      sum += PD[i].first * PD[i].second;
    }
    cout << sum << endl; // print output

    cin >> n_intervals >> budget; //read new input
  }

  return 0;

  
}
    
      
      
      
    
    

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

int main(){
    int n, i, d;
    cin >> d >> n;
    if(n == 100){
        n++;;
    }
    for(i=0; i<d; i++){
        n *= 100;
    }
    cout << n;
    return 0;
}

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

int main(){
  string A, B;
  cin >> A >> B;
  int cnt=0;
  if(A.size()>B.size()) cout << "GREATER" << endl;
  else if(A.size()<B.size()) cout << "LESS" << endl;
  else{
    for(int i=0; i<A.size(); i++){
      if(A.at(i)>B.at(i)){
        cout << "GREATER" << endl;
        break;
      }
      else if(A.at(i)<B.at(i)){
        cout << "LESS" << endl;
        break;
      }
      else cnt++;
    }
  }
  if(cnt==A.size()) cout << "EQUAL" << endl;
}

Measured memory_bytes: 256
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

const string YES = "YES";
const string NO = "NO";

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

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


void solve(long long n, std::vector<long long> a){
    set<int> s;
    for(auto& x : a)
        s.emplace(x);
    cout << (s.size() == n ? "YES" : "NO") << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x, y;
cin >> x >> y;
if(y%2 == 0)
{
	if(y>=2*x && y<=4*x)
		cout << "Yes" << endl;
	else 
		cout << "No" << endl;
}
else 
	cout << "No" << endl;
return 0;
}

Measured memory_bytes: 3604
# include <iostream>
# include <cstdio>
# include <algorithm>
# include <cmath>
# include <cstring>
using namespace std;
int main()
{
	char a[100];
	gets(a);
	for(int i=0;i<strlen(a);i++)
	{
		if(a[i]=='C')
		{
			for(int j=i+1;j<strlen(a);j++)
				if(a[j]=='F')
				{
					cout<<"Yes";
					return 0;
				}
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
using namespace std;

const long long inf = 1e10;
const long long mod = 1e9+7;

typedef vector<vector<int> > G;
G graph;

int color[100050];

bool dfs(int u, int c){
    color[u] = c;
    for(int i=0; i<graph[u].size(); i++){
        int v = graph[u][i];
        if(color[v] == c){
            return false;
        }
        if(color[v] == 0 && !dfs(v, -c) ){
            return false;
        }
    }   
    return true;
}

int main(void){
    long long n, m;
    cin >> n >> m;
    graph = G(n);
    for(int i=0; i<m; i++){
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    long long B=0, W=0;
    if(dfs(0, 1)){
        for(int i=0; i<n; i++){
            if(color[i] == 1){
                B++;
            }else if(color[i] == -1){
                W++;
            }
        }
        cout << B*W - m << endl;
    }else{
        cout << ( (n*(n-1)) /2) - m << endl;
    }
    
    return 0;
}

Measured memory_bytes: 6516
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text.RegularExpressions;

namespace ConsoleApp23
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var alice = 0;
            var bob = 0;
            var isAliceTurn = true;

            foreach (var card in Console.ReadLine().Split(' ')
                .Select(int.Parse).OrderByDescending(c => c))
            {
                if (isAliceTurn)
                {
                    alice += card;
                    isAliceTurn = false;
                }
                else
                {
                    bob += card;
                    isAliceTurn = true;
                }
            }

            Console.WriteLine((alice - bob).ToString());
        }
    }
}


Measured memory_bytes: 13396
$,=$";
($K,$N)=glob<>;
if($K%2){
	@_=($K+1>>1)x$N;
	$i=$#_;
	for(1..$N/2){
		if($_[$i]){
			--$_[$i]
		}elsif(--$_[--$i]){
			while(++$i<$N){
				$_[$i]=$K
			}
		}
	}
	print grep$_,@_
}else{
	print$K/2,($K)x($N-1)
}


Measured memory_bytes: 14592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using Graph = vector<vector<pii>>;
const int MOD = 1e9 + 7;

struct binomial {
    vector<ll> inv, fac, finv;

    binomial(int N) : inv(N + 1), fac(N + 1), finv(N + 1) {
        inv[1] = 1;
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        for (int i = 2; i <= N; ++i) {
            inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD;
            fac[i] = fac[i - 1] * i % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }

    ll calc(int a, int b) {
        return (fac[a] * finv[b] % MOD) * finv[a - b] % MOD;
    }
};

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

    int n, k;
    cin >> n >> k;
    binomial b(n + 1);

    ll ans = 0;
    for (int i = 0; i <= min(n - 1, k); ++i) {
        ans += b.calc(n, i) * b.calc(n - 1, i) % MOD;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4992
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>

using namespace std;
struct Node{Node *parent, *left, *right; int key;};
Node T[10000];
int D[10000];
int H[10000];

Node *root, *NIL;


void print_preorder(Node *r){
    if(r==NIL) return;
    cout<<" "<<r->key;
    print_preorder(r->left);
    print_preorder(r->right);
}

void print_inorder(Node *r){
    if(r==NIL) return;
    print_inorder(r->left);
    cout<<" "<<r->key;
    print_inorder(r->right);
}

//void print_postorder(int r){
//    if(r==-1) return;
//    print_postorder(T[r].left);
//    print_postorder(T[r].right);
//    cout<<" "<<r;
//}

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z=(Node *)malloc(sizeof(Node));
    z->key=k;
    z->left=NIL;
    z->right=NIL;

    while(x!=NIL){
        y=x;
        if(z->key<x->key){
            x=x->left;
        }else{
            x=x->right;
        }
    }
    z->parent=y;
    if(y==NIL){
        root = z;
    }else{
        if(z->key<y->key){
            y->left=z;
        }else{
            y->right=z;
        }
    }
}

int main()
{
    int n,i,x;
    string com;

    cin>>n;
    for(i=0;i<n;i++){
        cin>>com;
        if(com=="insert"){
            cin>>x;
            insert(x);
        }else if(com=="print"){
            print_inorder(root);
            cout<<endl;
            print_preorder(root);
            cout<<endl;

        }
    }

    return 0;
}


Measured memory_bytes: 26504
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 1e5 + 7;
const int mod = 1e9 + 7;
inline int add(int x, int y) {int res = x + y; if (res >= mod) res -= mod; return res;}
int dp[101][MAXN], sum[MAXN];
int main()
{
    int n, K; scanf("%d%d", &n, &K);
    dp[0][0] = 1; sum[0] = 1; for (int j = 1; j <= K; j++) sum[j] = add(sum[j - 1], dp[0][j]);
    for (int i = 1, a; i <= n; i++)
    {
        scanf("%d", &a);
        dp[i][0] = 1; for (int j = 1; j <= K; j++) dp[i][j] = add(sum[j], j - a - 1 < 0 ? 0 : mod - sum[j - a - 1]);
        sum[0] = 1; for (int j = 1; j <= K; j++) sum[j] = add(sum[j - 1], dp[i][j]);
    }
    printf("%d\n", dp[n][K]);
    return 0;
}

Measured memory_bytes: 39680
#include<iostream>
#include<cmath>
#include<iomanip>
#include<string>
#include<vector>
using namespace std;

int main(){
    vector<int> a;
    int n,r;
    cin>>n;
    
    
    int maxv=-2000000000, minv=2000000000;
    
    for(int i=0; i<n; i++){
        cin>>r;
        maxv=max(maxv, r-minv);
        minv=min(minv, r);
    }
    cout<<maxv<<endl;
}



Measured memory_bytes: 3104
# 二部ぐらふ、知らなかった
from collections import defaultdict


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * (n+1)

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n + 1) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N = int(input())
U = UnionFind(2*10**5)
for i in range(N):
    x, y = map(int, input().split())
    U.union(x, y+10**5)
ans = 0
Roots = U.roots()
D = {x: [] for x in Roots}
for i in range(2*10**5+1):
    D[U.find(i)].append(i)
for x in Roots:
    ss = D[x]
    sx = 0
    sy = 0
    for c in ss:
        if c <= 10**5:
            sx += 1
        else:
            sy += 1
    ans += sx*sy
ans -= N
print(ans)

Measured memory_bytes: 130564
S = input()
cnt = 0
ml = 0

for i in range(len(S)):
  for j in range (i+1, len(S)+1):
    cnt = S[i:j].count("A") + S[i:j].count("T") + S[i:j].count("G") + S[i:j].count("C")
    if cnt == len(S[i:j]) and cnt > ml:
      ml = cnt
      
    
print(ml)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
using ll = long long;

int main() {
	int n;
	cin >> n;
	int a[3 * n];
	for (int i = 0;i < 3 * n;i++)cin >> a[i];
	sort(a, a + 3 * n);
	reverse(a, a + 3 * n);
	ll ans = 0;
	for (int i = 1;i <= 2 * n;i += 2) {
		ans += a[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
public class ABC125A {
    public static void Main() {
        int A, B, T;
        string[] str = System.Console.ReadLine().Split(' ');
        A = int.Parse(str[0]);
        B = int.Parse(str[1]);
        T = int.Parse(str[2]);
        System.Console.WriteLine(T / A * B);
    }
}

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

int main(){
  long N, K;
  cin >> N >> K;
  vector<long> A(N+1);
  for(int i=1; i<=N; i++){
    cin >> A[i];
  }
  if(N>=K){
    int town=1;
    for(int i=1; i<=K; i++){
      town = A[town];
    }
    cout << town << endl;
    return 0;
  }
  vector<int> visit(N+1,-1);
  int town=1;
  visit[1]=0;
  int l=0;
  for(int i=1; i<=N; i++){
    l++;
    town = A[town];
    if(visit[town]!=-1) break;
    visit[town]=l;
  }
  long rep = l-visit[town];
  K =(K-l) %rep;
  for(int i=0; i<K; i++){
    town = A[town];
  }
  cout << town << endl;
  return 0;
}


Measured memory_bytes: 5560
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int main(){
   int n,l;
   cin>>n>>l;
   string s[n];
   rep(i,n)cin>>s[i];
   sort(s,s+n);
   rep(i,n)cout<<s[i];
   cout<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N_MAX 200000
int main(int argc, char **argv) {
	int n, k;
	scanf("%i%i", &n, &k);
	int a[N_MAX + 1];
	for(int i = 1; i <= n; ++i) {
		scanf("%i", &a[i]);
	}
	int s = 1, t = 1000000000;
	while(s <= t) {
		int m = (s + t) / 2;
		int c = 0;
		for(int i = 1; i <= n; ++i) {
			c += (a[i] - 1) / m;
		}
		if(c > k) {
			s = m + 1;
		} else {
			t = m - 1;
		}
	}
	printf("%i\n", s);
	return 0;
}

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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr int INF = 1001001001;

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; }

int main() {
    int n;
    cin >> n;
    int cnt = 0, mx = 0;
    rep (i, n) {
        int d1, d2;
        cin >> d1 >> d2;
        if (d1 == d2) cnt++;
        else {
            chmax(mx, cnt);
            cnt = 0;
        }
    }
    chmax(mx, cnt);
    if (mx >= 3)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string.h>
#include <queue>
#include <stack>
#include <utility>
#include <queue>
#include <cmath>
#define mp make_pair
#define pii pair<int,int> 
#define ff first
#define ss second

using namespace std;

int month[20]={0,31,29,31,30,31,30,31,31,30,31,30,31};
string days[10]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
int a,b,c,d;
int main()
{
	while(1)
	{
		scanf("%d %d",&a,&b);
		c=0;
		if(a==0&&b==0)
		{
			break;
		}
		for(int i=1;i<a;i++)
		{
			c+=month[i];
		}
		c+=b+2;
		d=c%7;
		//printf("%d\n",c);
		cout<<days[d]<<endl;
	}
	return 0;
}

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

#define ll long long
#define ull unsigned long long
#define ld long double
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define fo(i,start,end) for(int i=start;start<end?i<end:i>end;start<end?i+=1:i-=1)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vop vector<pll>
#define vov vector<vector<ll>>
#define endl "\n"
using namespace std;
const ld pi=3.14159265358979323;

const long long mod1=1e9+7;
const long long mod2=1e18;
const ll mod3=9e18;
const ll N=1e9+7;

long long power(ll  x, ll n){if(n==0)return 1;ll temp=power(x,n/2);if(n%2==0)return temp*temp;else return x*temp*temp;}

ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return (a*b)/(gcd(a,b));}
void swap(int* a, int* b){int t = *a;*a = *b;*b = t;}
bool f(ll x,ll y){return x>y;}

ll MAX(ll a,ll b){return a>b?a:b;}
ll MIN(ll x,ll  y){return x>y?y:x;}

ll pmod(ll a, ll b,ll mod)//a^b%mod
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b/=2;
        a=(a*a)%mod;
    }
    return ans;
}

bool cmp2( pair<ll,ll> &a,
           pair<ll,ll> &b)
{
    return a.second>b.second;
}


void solve() {
   ll n;
   cin>>n;
   ll arr[n+1];
   fo(i,1,n+1)cin>>arr[i];
   ll ans[n+1];
    ans[0]=ans[1]=0;
   ans[2]=abs(arr[2]-arr[1]);
   for(ll i=3;i<n+1;i++){
       ll x1=ans[i-1]+abs(arr[i]-arr[i-1]);
       ll x2=ans[i-2]+abs(arr[i]-arr[i-2]);
       ans[i]=MIN(x1,x2);


   }

   cout<<ans[n];




}

























int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin) ;
    freopen("output.txt" , "w" , stdout) ;
    //freopen("error.txt" , "w" , stderr) ;
#endif








    ll t;
    t=1;
    //  cin>>t;
    //  cin.ignore();
    while(t--){

        solve();
    }




    return 0;


}

////vll adj[100001];
////ll vis[100001];
////ll sssp[100001];

Measured memory_bytes: 5172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
vector<string> s(101);
vector<string> t(101);

int main(){
  int N,M,i;
  map<string,int> ss;
  map<string,int> tt;
  set<string> jud;

  cin>>N;
  for(i=0;i<N;i++){
    cin>>s[i];
    jud.insert(s[i]);
    ss[s[i]]+=1;
  }
  cin>>M;
  for(i=0;i<M;i++){
    cin>>t[i];
    tt[t[i]]+=1;
  }

  int ans=0;
  for(auto itr=jud.begin();itr!=jud.end();itr++){
    // cout<<*itr<<endl;
    int a=ss[*itr]-tt[*itr];
    ans=max(a,ans);
  }
  cout<<ans<<endl;


}


Measured memory_bytes: 256
//AtCoder Beginner Contest 134 - B
#include<bits/stdc++.h>
#define ll long long
using namespace std;


int main(){
	int n,d;
	scanf("%d %d",&n,&d);
	int ans=(n%(2*d+1))? (n/(2*d+1))+1:(n/(2*d+1));
	printf("%d",ans);
	
} 

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

 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll n,m;
  cin >> n >> m;
  if(n==1){
    if(m==1) cout << 1 << endl;
    else if(m==2) cout << 0 << endl;
    else cout << m - 2 << endl; 
  }
  else if(m==1){
   if(n==2) cout << 0 << endl;
   else cout << n-2 << endl;
  }
  else if(n==2 || m==2){
    cout << 0 << endl;
  }
  else{
   ll ans = n*m - (n-2)*2 - (m-2)*2 - 4;
  cout << ans << endl;
     
  }
  return 0; 
  
}

Measured memory_bytes: 764
import numpy as np

a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]

list_ = set(a+b+c)
n = int(input())

a = np.array([a, b, c])

for _ in range(n):
  x = int(input())
  if x in list_:
    a = np.where(a==x,0,a)

if np.sum(a==0) < 3:
  print('No')
  quit()

for i in range(3):
  if sum(a[:,i]) == 0:
    print('Yes')
    quit()

for i in range(3):
  if sum(a[i,:]) == 0:
    print('Yes')
    quit()

if a[0,0]+a[1,1]+a[2,2] == 0 or a[0,2]+a[1,1]+a[2,0] == 0:
  print('Yes')
  quit()

print('No')

Measured memory_bytes: 20920
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;

int main() {
    string S;
    cin >> S;

    if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * f.cc: F - I hate Shortest Path Problem
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_W = 200000;

/* typedef */

typedef pair<int,int> pii;
typedef set<pii> spii;
typedef multiset<int> msi;

/* global variables */

spii rset;
msi mls;

/* subroutines */

/* main */

int main() {
  int h, w;
  scanf("%d%d", &h, &w);

  for (int i = 0; i < w; i++) {
    rset.insert(pii(i, i));
    mls.insert(0);
  }

  for (int k = 1; k <= h; k++) {
    int ak, bk;
    scanf("%d%d", &ak, &bk);
    ak--;

    spii::iterator sit = rset.lower_bound(pii(ak, -1));
    int maxx = -1;
    while (sit != rset.end() && sit->first < bk) {
      int y = sit->first, x = sit->second;
      if (maxx < x) maxx = x;
      sit = rset.erase(sit);
      msi::iterator mit = mls.lower_bound(y - x);
      mls.erase(mit);
    }

    if (bk < w && maxx >= 0) {
      rset.insert(pii(bk, maxx));
      mls.insert(bk - maxx);
    }

    if (mls.empty()) puts("-1");
    else printf("%d\n", *mls.begin() + k);
  }

  return 0;
}


Measured memory_bytes: 22476
package main

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

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

var sc = newScanner()

func scanInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanString() string {
	if sc.Scan() {
		return sc.Text()
	}
	panic(sc.Err())
}

func main() {
	n, q := scanInt(), scanInt()
	tree := newTree(n)
	for i := 0; i < q; i++ {
		p, x := scanInt()-1, scanInt()
		debug("p", p, "x", x)
		setCounters(tree, p, x)
	}
	updateCounters(tree)
	for i := 0; i < n; i++ {
		separator := " "
		if i == n-1 {
			separator = "\n"
		}
		fmt.Print(tree[i].counter, separator)
	}
}

func debug(a ...interface{}) {
	// fmt.Println(a...)
}

type Node struct {
	id       int
	children []Node
	counter  int
}

func newTree(n int) map[int]*Node {
	tree := make(map[int]*Node)
	path := make(map[int][]int)
	for i := 0; i < n; i++ {
		tree[i] = &Node{id: i, counter: 0, children: []Node{}}
		debug(i, n, tree[i])
	}

	for i := 0; i < n-1; i++ {
		a, b := scanInt()-1, scanInt()-1
		path[a] = append(path[a], b)
		path[b] = append(path[b], a)
	}
	processed := make(map[int]bool)
	processed[0] = true
	for parentList := []int{0}; len(parentList) > 0; {
		nextParentList := []int{}
		for _, parent := range parentList {
			for _, v := range path[parent] {
				if _, exists := processed[v]; !exists {
					tree[parent].children = append(tree[parent].children, *tree[v])
					nextParentList = append(nextParentList, v)
					processed[v] = true
				}
			}
		}
		parentList = nextParentList
	}

	for i := 0; i < len(tree); i++ {
		debug(i, tree[i])
	}
	return tree
}

func setCounters(tree map[int]*Node, p, x int) {
	debug("p", p, "x", x)
	tree[p].counter += x
}

type PrevCurrentNode struct {
	prev    int
	current int
}

func updateCounters(tree map[int]*Node) {
	for targetLayer := []PrevCurrentNode{{0, 0}}; len(targetLayer) > 0; {
		nextLayer := []PrevCurrentNode{}
		for _, v := range targetLayer {
			prevNode := v.prev
			node := v.current
			if node != 0 {
				tree[node].counter += tree[prevNode].counter
			}
			for _, child := range tree[node].children {
				nextLayer = append(nextLayer, PrevCurrentNode{node, child.id})
			}
		}
		targetLayer = nextLayer
		debug(targetLayer)
	}
}


Measured memory_bytes: 87040
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
using ll = long long;
int main() {
    int a,b,c,K;
    bool flag = false;
    cin >> a >> b >> c >> K;
    for(int i=0;i<=K;i++){
        for(int j=0;j<=K;j++){
            for(int k=0;k<=K;k++){
                int x = a * (1 << i), y = b * (1 << j), z = c * (1 << k);
                if(i + j + k <= K && x < y && y < z) flag = true;
            }
        }
    }
    if(flag == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

#define lld long long
#define pi pair<int,int>
#define pl pair<lld,lld>
#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())

int n,q;
int A[21];
bool flg[2010];

void solved(int idx, int value){
    if(idx == n){
        flg[value] = true;
    } else {
        solved(idx+1,A[idx]+value);
        solved(idx+1,value);
    }
    return;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    mem0(flg);
    solved(0,0);
    cin >> q;
    for (int i = 0; i < q; i++) {
        int m;
        cin >> m;
        if (flg[m]) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
    
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#ifdef BTK
#include<dvector.h>
#define DEBUG if(1)
#else
#define DEBUG if(0)
#endif

#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
    
int main(){
    int N;
    cin>>N;
    map<int,int> cnt;
    REP(i,N){
        int a;
        cin>>a;
        cnt[a]++;
    }
    int res=0;
    for(auto &it:cnt)res+=it.se%2;
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
using namespace std;

int main()
{
    char a[21];
    cin>>a;
    for(int i=0;i<3;i++)
    {
        cout<<a[i];
    }

    return 0;
}


Measured memory_bytes: 3652
n,k = map(int,input().split())
p = list(map(int,input().split()))
p = [(1+x)/2 for x in p]
s = 0
start = 0
end = k-1
s = sum(p[start:end+1])
res = s
while end+1<n:
    s -= p[start]
    start+=1
    end+=1
    s += p[end]
    res = max(s,res)

print(res)



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

#define all(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

 // 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    ll X, Y; cin >> X >> Y;
    if((X + Y) % 3 != 0){
        cout << 0 << endl;
        return 0;
    }

    ll n = (-X + Y * 2) / 3;
    ll m = (X * 2 - Y) / 3;
    if(n < 0 || m < 0){
        cout << 0 << endl;
        return 0;
    }

    COMinit();
    cout << COM((X + Y) / 3, n) << endl;
}


Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int N;
  string S;
  cin >> N;
  cin >> S;
  
  int num2;
  
  for(int i = 0;i < S.size();++i){
    num2 = S[i] + N;
    if(num2 > 90){
      num2 = num2 - 26;
    }
    S[i] = (char)num2;
  }
  
       
  cout << (string)S << endl;
    
}

Measured memory_bytes: 256
import math
a, b, h, m = map(int, input().split())

pi = math.pi

m_rad = 2 * pi * m / 60
h_rad = 2 * pi * h / 12 + 2 * pi / 12 * m / 60

"""
余弦定理： sqrt(a^2 + b^2 - 2abcosΘ)
cos(-Θ) = cos(Θ)
cos(2pi - Θ) = cos(Θ) 
"""

ans = math.sqrt(a * a + b * b - 2 * a * b * math.cos(m_rad - h_rad))
print("{:.12f}".format(ans))

Measured memory_bytes: 62464
# describe Abc134B do
#   context 'test' do
#     it 'sample' do
#       expect(Abc134B.calc(6, 2)).to be(2)
#       expect(Abc134B.calc(14, 3)).to be(2)
#       expect(Abc134B.calc(20, 4)).to be(3)
#     end
#   end
# end

class Abc134B
  def self.input()
    n, d = STDIN.gets.split(/\s/).map(&:to_i)
    [n, d]
  end

  def self.output(result)
    puts result
  end

  def self.calc(n, d)
    (n.to_f / (2 * d + 1)).ceil
  end

  def self.main()
    n, d = input()
    result = calc(n, d)
    output(result)
  end
end

if __FILE__ == $0
  Abc134B.main
  exit
end

Measured memory_bytes: 1916
#include <stdio.h>
#define D_SIZE_BUFF 200
#define TRUE 0
#define FALSE 1

int main()
{
    char s[D_SIZE_BUFF];
    int size=0;
    
    int flag_gusu_fumiyasui = TRUE;
    int flag_kisu_fumiyasui = TRUE;

    // get input data
    for(int i=0; i<D_SIZE_BUFF; i++){s[i]='0';}
    scanf("%s", s);
    
    // size count
    for(int i=0; i<D_SIZE_BUFF; i++)
    {
        if(s[i]=='L'||s[i]=='R'||s[i]=='U'||s[i]=='D')
        size++;
    }

    //             .     .     .
    // judge gusu [0][1][2][3][4]   1,3,... is gusu
    for(int i=0; i<size; i++)
    {
        // gusu igai skip
        if(i%2==0) continue;
        if(s[i]=='L'||s[i]=='U'||s[i]=='D')
        {
            ;
        }
        else
        {
            flag_gusu_fumiyasui = FALSE;
            break;
        }
    }

    //                .     .
    // judge kisu [0][1][2][3][4]   0,2,... is kisu
    for(int i=0; i<size; i++)
    {
        // kisu igai skip
        if(i%2==1) continue;
        if(s[i]=='R'||s[i]=='U'||s[i]=='D')
        {
            ;
        }
        else
        {
            flag_kisu_fumiyasui = FALSE;
            break;
        }
    }

    // judge matome
    if( flag_gusu_fumiyasui == TRUE && flag_kisu_fumiyasui == TRUE)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    
    return 0;
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

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

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}



int main(){
    unsigned long long a;
    long double b;
    cin >> a >> b;

    cout << setprecision(20) <<floorl(a*b) << endl;
}


Measured memory_bytes: 3796
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	string s;
	cin>>s;
	int n = s.size();
	int l = 0, r = n-1;
	int cnt = 0;
	while(l<r){
		if(s[l]==s[r]){
			l++; r--;
			continue;
		}
		if(s[l]=='x'){
			cnt++;
			l++;
		} else if(s[r]=='x'){
			cnt++;
			r--;
		} else {
			cout<<-1<<endl;
			return 0;
		}
	}
	cout<<cnt<<endl;
	return 0;
}


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

int main() {


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

    deque<int> deq;


    int i=0;
    if(n%2==0) {
        deq.push_front(a[0]);
        deq.push_front(a[1]);
        i=2;
    } else if(n%2==1) {
        deq.push_front(a[0]);
        i=1;
    }

    while(i<n) {
        deq.push_back(a[i]);
        deq.push_front(a[i+1]);
        i+=2;
    }


    while(!deq.empty()) {
        cout << deq.front() << " ";
        deq.pop_front();
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 3840
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
#include <cstring>
using namespace std;
#define N 105
int b[N],n,a[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&b[i]);
	int len=n;
	for(int i=n;i;i--)
	{
		bool flag=0;
		for(int j=len;j;j--)
			if(b[j]==j)
			{
				a[i]=b[j];flag=1;
				for(int k=j;k<len;k++)b[k]=b[k+1];
				break;
			}
		if(!flag)return puts("-1"),0;len--;
	}
	for(int i=1;i<=n;i++)printf("%d\n",a[i]);
}

Measured memory_bytes: 256
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(n)]
ans = 0
for i in range(n):
  x = 0
  for j in range(m):
    x += a[i][j] * b[j]
  if x + c > 0:
    ans += 1
print(ans)


Measured memory_bytes: 9168
n, m = map(int, input().split())
d = [input().split() for i in range(m)]

ac = [0] * n
wa = [0] * n

for el in d:
    if ac[int(el[0]) - 1] == 0:
        if el[1] == 'AC':
            ac[int(el[0]) - 1] += 1
        else:
            wa[int(el[0]) - 1] += 1
        
result = [0] * 2
for i in range(n):
    if ac[i] > 0:
        result[0] += 1
        result[1] += wa[i]
        
print(result[0], result[1])

Measured memory_bytes: 33676
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include<bits/stdc++.h>  
#define endl "\n"
using namespace std;
	typedef long long ll;
	const int maxn=100005;
	const int inf=0x3f3f3f3f;
	int a[maxn][3]; 
	int dp[maxn][3];
	int n;
	int main(){
		cin>>n;
		for(int i=1;i<=n;i++)
			cin>>a[i][0]>>a[i][1]>>a[i][2];
		for(int i=2;i<=n+1;i++){
			dp[i][0]=max(dp[i-1][1]+a[i-1][0],dp[i-1][2]+a[i-1][0]);
			dp[i][1]=max(dp[i-1][0]+a[i-1][1],dp[i-1][2]+a[i-1][1]);
			dp[i][2]=max(dp[i-1][0]+a[i-1][2],dp[i-1][1]+a[i-1][2]);
		}
		int ans=-1;
		for(int j=0;j<3;j++)
			ans=max(ans,dp[n+1][j]);
		cout<<ans<<endl;
	}

Measured memory_bytes: 5972
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef pair<P, int> PP;
vector<int> G[100000];
int dfs(int k) {
	int len = G[k].size();
	if (len == 0)return 0;
	vector<int> v;
	rep(i, len) {
		v.push_back(dfs(G[k][i]));
	}
	sort(v.begin(), v.end(), greater<int>());
	int ma = 0;
	rep(i, len) {
		ma = max(ma, v[i] + i+1);
	}
	return ma;
}
int main() {
	int n; cin >> n;
	Rep(i,1, n) {
		int a; cin >> a; a--;
		G[a].push_back(i);
	}
	cout << dfs(0) << endl;
	return 0;
}

Measured memory_bytes: 15104
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
int main()
{
    int n;
    cin>>n;
    int k;
    cin>>k;
    int a[n+1];
     int dp[n+1];
    for(int i=0;i<=n;i++)
    dp[i]=1000000007;
    for(int i=1;i<=n;i++)
     cin>>a[i];
    dp[1]=0;
   dp[2]=abs(a[1]-a[2]);
    if(n==2)
    {cout<< dp[2]<<endl;return 0;}
    for(int i=3;i<=n;i++)
     {
         for(int j=i-k;j<i;j++)
          {if(j<1)
           continue;
           dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
           }
     }
     cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
// I make this just for fun because i'm done
// Aimi Haraguni >> Konomi Suzuki >> Yui >>  Ikimono Gakari >> Garnidelia >> Kalafina >> Eir Aoi.   .. dude? 
// problems that involves any kind of persistent data structures are the best of the best, are not them?
 
// #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
 
#define pb emplace_back
#define ff  first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define sz(x) ll(x.size())
#define all(v) (v).begin(), (v).end()
#define FER(i,a,b) for(ll i=ll(a); i< ll(b); ++i)
#define IFR(i,a,b) for(ll i=ll(a); i>=ll(b); --i )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
 
#define N 31000000
// #define M 19
 
// #define mod  11092019
#define mod1 1000000007
#define mod2 1000000009
#define bas 987625403
#define sqr(x) (x)*(x)  
#define INF 2000000000
 
using namespace std;
using namespace __gnu_pbds;
 
typedef int ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii > tri;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> S_t;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

inline ll mul(ll a, ll b, ll mod) { return (long long) a*b%mod;}
inline ll add(ll a, ll b, ll mod) { return a+b < mod? a+b: a+b-mod;}
inline void Mul(ll &a, ll b, ll mod) { a = (long long) a*b%mod;}
inline ll bp(ll a, ll p, ll mod){
	ll ret;
	for(ret = 1; p; p>>=1, Mul(a, a, mod)) (p & 1) && (Mul(ret, a, mod), 1);
	return ret;
}
static inline void read(ll &x) { cin>>x;}

int main(){
	fastio;
	ll x, y; cin>>x>>y;
	ll c = y-2*x;
	if(c < 0 or c&1){
		cout<<"No\n";
	}
	else{
		c>>=1;
		if(c > x) cout<<"No\n";
		else cout<<"Yes\n";
	}
	return 0;
}

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

int cnt_digits(ll N){
  int digits=0;

  while(N>0){
    N/=10;
    digits++;
  }
  return digits;
}

int main(void){
  ll N;
  cin >> N;

  int ans=cnt_digits(N); // 1*N=N max(cnt_digits(1),cnt_digits(N))=cnt_digits(N)

  for(ll A=1LL;A*A<=N;++A){
    if(N%A!=0) continue;
    const ll B=N/A;

    const int cur=max(cnt_digits(A),cnt_digits(B));

    if(ans>cur){
      ans=cur;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3644
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

using namespace std;

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

    std::sort(a.begin(), a.end());
    std::sort(b.begin(), b.end(), std::greater<>());

    cout << (a < b ? "Yes" : "No") << endl;

    return 0;
}


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


int main()
{
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b>=d&&d>=a)
  cout<<a<<endl;
  else if(a+b>=d&&d<=a)
  cout<<d<<endl;
  else if(a+b-d<0)
  cout<<a+(-1*(d-a-b));
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(p,a,b)    for(int p=a;p<b;p++)
#define INF 0x3f3f3f3f
#define mul(x) x*x*(x-=1)


int main() {
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("o2.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    string s,t;
    cin>>s>>t;
    if(t.substr(0,s.length())==s)cout<<"Yes";
    else cout<<"No";
    
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    const int INF = 1e9;
    int dp[100010];
    dp[0] = 0;

    for(int n = 1; n <= 100000; n++) {
        dp[n] = INF;
        int power = 1;
        while(power <= n) {
            dp[n] = min(dp[n], dp[n-power]+1);
            power *= 6;
        }

        power = 1;
        while(power <= n) {
            dp[n] = min(dp[n], dp[n-power]+1);
            power *= 9;
        }
    }

    cout << dp[N];

    cout << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define N 101
using namespace std;

struct card{
  int num;
  char ch;
  bool operator < (card a)const{return num<a.num;}
  bool operator == (card a)const{return num==a.num&&ch==a.ch;}
};

void BubbleSort(card *A,int n){
  for(int i=0;i<n-1;i++)
    for(int j=n-1;j>=i+1;j--)
      if(A[j] < A[j-1]) swap(A[j],A[j-1]);
}

void SelectionSort(card *A,int n){
  for(int i=0;i<n-1;i++){
    int idx = i;
    for(int j=i;j<n;j++)if(A[j]<A[idx])idx = j;
    swap(A[i],A[idx]);
  }
}

void pr(card *A,int n){
  for(int i=0;i<n;i++){
    if(i)cout<<" ";
    cout<<A[i].ch<<A[i].num;
  }
  cout<<endl;

}

bool isStable(card *A,card *B,int n){
  for(int i=0;i<n;i++) if(!(A[i]==B[i])) return 0;
  return 1;
}

int main(){
  int n;
  cin>>n;
  card A[N],B[N];
  for(int i=0;i<n;i++) cin>>A[i].ch>>A[i].num,B[i] = A[i];
  BubbleSort(A,n);
  SelectionSort(B,n);
  
  pr(A,n);
  cout<<"Stable"<<endl;
  pr(B,n);
  cout<<(isStable(A,B,n)? "Stable":"Not stable")<<endl;
    
  return 0;
}

Measured memory_bytes: 3076
W, H, N = map(int, input().split())

left, bottom = 0, 0
right, top = W, H

for x, y, a in (map(int, input().split()) for _ in range(N)):
  
  if a == 1:
    left = max(left, x)
  elif a == 2:
    right = min(right, x)
  elif a == 3:
    bottom = max(bottom, y)
  else:
    top = min(top, y)

print(max(0, right-left) * max(0, top-bottom))
    



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

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

 int main() {
     int h,w; cin >> h >> w;
     vector<vector<char> > c(h, vector<char>(w));
     rep(i, h) rep(j, w) cin >> c[i][j];

     vector<vector<char> > ans(2*h, vector<char>(w));

     int ans_i=0;
     rep(i, h) {
         rep(j, w) {
             ans[ans_i][j] = c[i][j];
             ans[ans_i+1][j] = c[i][j];
         }
         ans_i+=2;
     }

     rep(i, 2*h) {
         rep(j, w) {
             cout << ans[i][j];
         }
         cout << endl;
     }

     return 0;

 }


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
namespace 令和{
    class ABC{
        static void Main(){
            
            int n = int.Parse(Console.ReadLine());
            List<int[]>[] tonari = new List<int[]>[n+1];
            int[] ans = new int[n+1];
            for(int i=0;i<n+1;i++){
                tonari[i] = new List<int[]>();
                ans[i] = -1;
            }
            for(int i=1;i<n;i++){
          	    int u;int v;int w;
                string[] uvw = Console.ReadLine().Split();
                u = int.Parse(uvw[0]);
                v = int.Parse(uvw[1]);
                w = int.Parse(uvw[2]);
                tonari[u].Add(new int[2]{v,w});
                tonari[v].Add(new int[2]{u,w});
            }

            Queue<int> q = new Queue<int>();
            q.Enqueue(1);
            ans[1] = 0;

            while(q.Count>0){
                int p = q.Dequeue();
                foreach(int[] tnr in tonari[p]){
                    if(ans[tnr[0]]==-1){
                        if(tnr[1]%2==0){
                            ans[tnr[0]] = ans[p];
                        }else{
                            ans[tnr[0]] = 1-ans[p];
                        }
                        q.Enqueue(tnr[0]);
                    }
                }
            }
            for(int i=0;i<n;i++){
                Console.WriteLine(ans[i+1]);
            }


        }
    }
}


Measured memory_bytes: 39368