akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 9e18;

signed main() {
    int N, K;
    cin >> N >> K;
    map<int, int> count;
    for (int i = 0; i < N; i++) {
        int temp;
        cin >> temp;
        count[temp]++;
    }
    int ans = N;
    priority_queue<int> check;
    for (auto temp : count) check.push(temp.second);
    for (int i = 0; i < K && !check.empty(); i++) {
        int temp = check.top();
        check.pop();
        ans -= temp;
    }
    cout << ans << endl;
}


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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

constexpr long long mod = 1000000007;

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

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

    int n;
    cin >> n;
    string s;
    cin >> s;

    int b = 0, w = 0;

    rep(i, n) {
        if (s[i] == '#') {
            b++;
        } else {
            w++;
        }
    }
    int num = min(b, w);

    b = 0;
    rep(i, n) {
        if (s[i] == '.') {
            w--;
        } else {
            b++;
        }

        num = min(num, b + w);
    }

    cout << num << endl;
}

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

int main() {
  int a, b; cin >> a >> b;
  
  int ans = -1;
  for (int i = 1; i <= 20000; ++i) {
    int s8 = i * .08, s10 = i * .10;
    if (s8 == a && s10 == b) {
      ans = i;
      break;
    }
  }
  
  cout << ans << endl;
}

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


int main() {
    ll n;
    cin>>n;
    ll s=0;
    unordered_map<ll,ll> m;
    rep(i,n){
        ll a;
        cin>>a;
        s+=a;
        m[a]++;
    }
    ll q;
    cin>>q;
    while(q--){
        ll b,c;
        cin>>b>>c;
        s+=m[b]*(c-b);
        m[c]+=m[b];
        m[b]=0;
        cout<<s<<endl;
    }
}

Measured memory_bytes: 6940
#include<bits/stdc++.h>
//using namespace std;
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb push_back
#define mp std::make_pair
#define endl "\n"
using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=std::pair<ll,ll>;
const ll MOD=1e9+7;
//const ll MOD=998244353;
//const ll MOD=100000;
const ll MAX=1e7;
const ll INF=(1ll<<60);
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
struct Binary_indexed_tree{
    int N;
    vi bit;
    Binary_indexed_tree(int n):N(n){
        bit.resize(N+1,0);
    }
    void add(int x,int a){
        for(x;x<=N;x+=(x&-x)) bit[x]+=a;
    }
    ll sum(int x){
        ll ret=0;
        for(x;x>0;x-=(x&-x)) ret+=bit[x];
        return ret;
    }
};
struct Union_Find{
    ll N;
    vi par;
    vi siz;
    Union_Find(int n):N(n){
        par.resize(N);
        siz.resize(N,1);
        rep(i,0,N) par[i]=i;
    }
    ll root(ll X){
        if(par[X]==X) return X;
        return par[X]=root(par[X]);
    }
    bool same(ll X,ll Y){
        return root(X)==root(Y);
    }
    void unite(ll X,ll Y){
        X=root(X);
        Y=root(Y);
        if(X==Y) return;
        par[X]=Y;
        siz[Y]+=siz[X];
        siz[X]=0;
    }
    ll size(ll X){
        return siz[root(X)];
    }
};
ll modpow(ll X,ll Y){
    ll sum=X,cnt=1;
    vi A;
    while(cnt<=Y){
        A.pb(sum);
        sum*=sum;
        sum%=MOD;
        cnt*=2;
    }
    int M=A.size();
    ll ret=1;
    REP(i,1,M){
        if(Y>=(1ll<<M-i)){
            Y-=(1ll<<M-i);
            ret*=A[M-i];
            ret%=MOD;
        }
    }
    return ret;
}
ll 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;
    }
}
ll COM(ll n,ll r){
    if(n<r||n<0||r<0) return 0;
    return fac[n]*finv[r]%MOD*finv[n-r]%MOD;
}
signed main(){
    ll N; cin>>N;
    vii A(N,vi(N));
    rep(i,0,N){
        rep(j,0,N) cin>>A[i][j];
    }
    vi dp((1ll<<N));
    rep(i,0,(1ll<<N)){
        std::bitset<16> bit(i);
        rep(j,0,N-1){
            rep(k,j+1,N){
                if(bit.test(j)&&bit.test(k)) dp[i]+=A[j][k];
            }
        }
    }
    rep(i,0,(1ll<<N)){
        std::bitset<16> bit(i);
        vi C;
        rep(j,0,N){
            if(!bit.test(j)) C.pb(j);
        }
        rep(j,0,(1ll<<C.size())){
            ll X=0;
            rep(k,0,C.size()){
                if((j&(1ll<<k))==0) X+=(1ll<<C[k]);
            }
            dp[i|X]=std::max(dp[i|X],dp[i]+dp[X]);
        }
    }
    cout<<dp[(1ll<<N)-1]<<endl;
}


Measured memory_bytes: 896
n = int(input())
a = 0
for i in [1,3,5]:
    max = pow(10, i)
    min = pow(10, i-1)
    if n >= max-1:
        a += 9 * min
    elif n >= min:
        a += n-min+1
        break
    else:
        break
print(a)

Measured memory_bytes: 2940
n = int(input())

# 素因数分解
# √n+1までを対象に因数分解
# 素数のみを対象に処理しなくても2で引っかかる場合は4、6などは対象にならない。
prime = []
for i in range(2, int(n**0.5)+1): 
  cnt = 0
  while n%i == 0:
    n //= i # 割り切れる場合に最後の処理で余りが1になり、ループを抜ける
    cnt += 1
  prime.append(cnt) # 因数分解した回数を保持
  if n == 1:
    break

# 対象が素数であった場合は１を結果として保持
if n > 1:
  prime.append(1)
  
ans = 0
for x in prime:
  for i in range(1, x+1):
    if x >= i: # 素数の数をカウント
      ans += 1
      x -= i
    else:
      break
print(ans)

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

using namespace std;

#define K 300001

int n;
int res = 0;
pair<int, int> a[K];

int longest = 0;

int max(int a, int b) {
	return (a > b ? a : b);	
}

int dL = 0, dR = 1000000009;

#define FOE(i, s, t) for (int i = s; i <= t; i++)
#define FOD(i, s, t) for (int i = s; i >= t; i--)

int main() {
	scanf("%d", &n);
	
	FOE(i, 1, n) {
		scanf("%d%d", &a[i].first, &a[i].second);	
	}
	
	sort(a + 1, a + n + 1);
	a[0].first = -1;
	
	int low = 1;
	
	FOE(i, 2, n) if (a[i].second < a[low].second) low = i;
	FOE(i, 1, n) if (i != low && a[i].second - a[i].first + 1 > longest) longest = a[i].second - a[i].first + 1;
	
	int rl = a[n].first;
	res = max(0, a[low].second - rl + 1) + longest;
	
	FOD(i, n, 1) {
		int rl = max(a[i - 1].first, a[low].first);
		if (dR > a[i].second) dR = a[i].second;
		if (dL < a[i].first) dL = a[i].first;
		
		int sres = max(0, a[low].second - rl + 1) + max(0, dR - dL + 1); 
		// kick myself
		if (sres > res) res = sres;
	}
		
	printf("%d\n", res);
}


Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int64, n)
	var zero bool
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
		if a[i] == 0 {
			zero = true
		}
	}

	if zero {
		fmt.Println(0)
		return
	}

	max := int64(1e18)
	ans := int64(1)
	for i := 0; i < n; i++ {
		if ans > max/a[i] {
			ans = -1
			break
		}
		ans *= a[i]
		if ans > max {
			ans = -1
			break
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 6304
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include<functional>

typedef unsigned long long LL;

using namespace std;

int main() {
	string S;
	cin >> S;
	int length = S.length();
	vector<int> ret(length, 0);
	int tmpr = 1;
	int tmpl = 0;
	for (int i = 0; i < length - 1; i++) {
		if (S[i] == 'R') {
			if (S[i + 1] == 'L') {
				ret[i]+= tmpr;
				ret[i+1] += tmpl;
				tmpr = 1;
				tmpl = 0;
			}
			else {
				int t = tmpl;
				tmpl = tmpr;
				tmpr = t + 1;
			}
		}
	}
	tmpl = 1;
	tmpr = 0;
	for (int i = length - 1; i > 0; i--) {
		if (S[i] == 'L') {
			if (S[i - 1] == 'R') {
				ret[i] += tmpl;
				ret[i - 1] += tmpr;
				tmpl = 1;
				tmpr = 0;
			}
			else {
				int t = tmpr;
				tmpr = tmpl;
				tmpl = t + 1;
			}
		}
	}
	for (int i = 0; i < length; i++) {
		if (i != length - 1) {
			cout << ret[i] << " ";
		}
		else {
			cout << ret[i];
		}
	}
	cout << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <set>

using namespace std;

void show(set<int> s) {
	for (auto x: s) {
		cout << x << " ";
	}
	cout << endl;
}

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

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

	set<int> nums = {p[0]};
	int asc_parts = 1;
	for (int i = 0; i < k; i++) {
		nums.insert(p[i]);

		if  (p[i] > p[i - 1]) {
			asc_parts++;
		} else {
			asc_parts = 1;
		}
	}

	bool has_initial = false;
	if (asc_parts == k) {
		has_initial = true;
	}

	int ans = 1;
	for (int i = k; i < n; i++) {
		if  (p[i] > p[i - 1]) {
			asc_parts++;
		} else {
			asc_parts = 1;
		}

		int mini = *nums.begin();
		int maxi = *prev(nums.end());

		// printf("i %d, mini %d, maxi %d, p[i - k] %d, p[i] %d : ", i, mini, maxi, p[i - k], p[i]);
		// show(nums);

		if (asc_parts >= k) {
			if (has_initial) {
				// printf("  has_initial\n");
			} else {
				has_initial = true;
				ans++;
			}
		} else if (mini == p[i - k] && maxi < p[i]) {
			// printf("  do nothing\n");
		} else {
			ans++;
		}

		nums.erase(p[i - k]);
		nums.insert(p[i]);
	}

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


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n;
    scanf("%d",&n);
    if(n==2) return cout<<-1<<endl,0;
    if(n==3) return puts("aa.\n..a\n..a"),0;
    vector<string> q={"aabc","ddbc","bcaa","bcdd"},
            p={"aabbc","cdd.c","c..ba","a..ba","accdd"},
            h={".llkkj","iihh.j","ggfe..","..fedd","c...ba","c...ba"},
            s={".nnmmll","kkjji..","hhggi..","f....ed","f....ed","....cba","....cba"};
    vector<string> ans(n,string(n,'.'));
    fr(i,n/4){
        fr(I,4) fr(J,4){
            ans[4*i+I][4*i+J]=q[I][J];
        }
    }
    if(n%4==1) fr(i,5) fr(j,5) ans[n-5+i][n-5+j]=p[i][j];
    if(n%4==2) fr(i,6) fr(j,6) ans[n-6+i][n-6+j]=h[i][j];
    if(n%4==3) fr(i,7) fr(j,7) ans[n-7+i][n-7+j]=s[i][j];
    fr(i,n) cout<<ans[i]<<"\n";
}

Measured memory_bytes: 2304
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Int32;
using static System.Math;

class Program
{

    static void Main(string[] args)
    {
        label:
        WriteLine(hoge() ? "Yes" : "No");
    }

    static bool hoge()
    {
        var sp = ReadLine().Split();
        int n00 = Parse(sp[0]);
        int n01 = Parse(sp[1]);
        int n02 = Parse(sp[2]);
        sp = ReadLine().Split();
        int n10 = Parse(sp[0]);
        int n11 = Parse(sp[1]);
        int n12 = Parse(sp[2]);
        sp = ReadLine().Split();
        int n20 = Parse(sp[0]);
        int n21 = Parse(sp[1]);
        int n22 = Parse(sp[2]);
        if (n00 - n01 != n10 - n11) return false;
        if (n00 - n01 != n20 - n21) return false;
        if (n00 - n02 != n10 - n12) return false;
        if (n00 - n02 != n20 - n22) return false;
        if (n00 - n10 != n01 - n11) return false;
        if (n00 - n10 != n02 - n12) return false;
        if (n00 - n20 != n01 - n21) return false;
        if (n00 - n20 != n02 - n22) return false;
        return true;
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop") 
#define ll long long int
#define ps push_back
#define pb pop_back
#define fs first
#define sc second
#define mkp make_pair
#define mod 1000000007
const int N=1e5;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll i,j,k,l,n;
	cin>>n;
	ll ar[n+1];	
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}
	
	ll an[n+1];
	an[1]=0; an[2]=abs(ar[2]-ar[1]);
	for(i=3;i<=n;i++){
		k=an[i-2]+abs(ar[i-2]-ar[i]);
		l=an[i-1]+abs(ar[i-1]-ar[i]);
		if(k<l) an[i]=k;
		else an[i]=l;
	}
	cout<<an[n];
	return 0;
}

Measured memory_bytes: 1792
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N = I()
b = LI()

ans = []
while b:
    n = len(b)
    flag = False
    for i in range(n)[::-1]:
        if b[i] == i+1:
            ans.append(i+1)
            flag = True
            break
    if not flag:
        print(-1)
        exit()
    b.pop(i)

for a in ans[::-1]:
    print(a)

Measured memory_bytes: 38512
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int A, B, C;
        A = cin.nextInt();
        B = cin.nextInt();
        C = cin.nextInt();
        int ans = A + B + C + Math.Max(A, Math.Max(B, C)) * 9;
        Console.WriteLine(ans);
    }

}






class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long N, long long T, std::vector<long long> c, std::vector<long long> t){
    vector<pll> vp;
    rep(i, N){
        vp.push_back(pll(c[i], t[i]));
    }
    sort(vp.begin(), vp.end());
    rep(i, N){
        if(vp[i].second <= T){
            cout << vp[i].first << endl;
            return;
        }
    }
    cout << "TLE" << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vector<P> p(n);
  for(int i=0;i<n;++i) {
    cin >> p[i].first;
    p[i].second = i;
  }
  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());
  multiset<int> ms;
  ms.insert(-1);
  ms.insert(-1);
  ms.insert(n);
  ms.insert(n);
  ll su = 0;
  for(int i=0;i<n;++i) {
    ll val = p[i].first;
    int pos = p[i].second;
    auto it = ms.lower_bound(pos);
    int l1, l2, r1, r2;
    r1 = *it++;
    r2 = *it--;
    it--;
    l1 = *it--;
    l2 = *it;
    su += (l1 - l2) * (r1 - pos) * val;
    su += (r2 - r1) * (pos - l1) * val;
    ms.insert(pos);
  }
  cout << su << endl;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string s;
  cin >> s;
  if(s[0]!=s[1] && s[1]!=s[2] && s[2]!=s[0]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

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

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

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int a1 = 0, a2 = 0;
        for (int j = 0; j <= i; j++) {
            a1 += A[0][j];
        }
        for (int j = i; j < N; j++) {
            a2 += A[1][j];
        }
        ans = max(ans, a1 + a2);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b);
#define chmin(a, b) a = min(a, b);
using namespace std;
using ll = long long;
using P = pair<int,int>;

std::vector<int> compute_grundy(std::vector<std::vector<int>>& to) {
	int sz = to.size();
	std::vector<int> vsorted(sz);
	std::vector<int> indeg(sz);
	for(int i = 0; i < sz; i++) {
		for(int j: to[i]) {
			indeg[j]++;
		}
	}
	std::vector<int> avail;
	for(int i = 0; i < sz; i++) if (indeg[i] == 0) avail.push_back(i);
	int nxt_idx = 0;
	while(!avail.empty()) {
		int u = avail.back(); avail.pop_back();
		vsorted[nxt_idx++] = u;
		for(int v: to[u]) if (--indeg[v] == 0) avail.push_back(v);
	}
	std::vector<int> grundy(sz), used(sz, -1);
	for(int i = sz - 1; i >= 0; i--) {
		int u = vsorted[i];
		for(int v: to[u]) used[grundy[v]] = u;
		int g = 0;
		while(used[g] == u) g++;
		grundy[u] = g;
	}
	return grundy;
}

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	vector<vector<int>> to(k+1);
	rep(i, k+1) {
		for(int ai: a) {
			if (i + ai > k) break;
			to[i+ai].push_back(i);
		}
	}
	auto grd = compute_grundy(to);
	cout << (grd[k] > 0 ? "First" : "Second") << endl;
}


Measured memory_bytes: 58620
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define mod 1000000007
#define maxn 200001
#define f(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rf(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);i--)
#define pb(x) push_back((ll)(x))
#define pf(x) push_front((ll)(x))
#define nl cout << "\n";
 
void ini(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}

int main(){
	ini();
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	ll x,y;
	cin >> x >> y;

	if(y>=2*x && y<=4*x && y%2==0){
		cout <<"Yes";
	}else{
		cout <<"No";
	}

}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <queue>
#define nmax 100005
using namespace std;
vector <int> v[nmax];
int n, m, x, y, dp[nmax];

int calculatedp(int i)
{
    dp[i] = 1;
    for (auto it : v[i]) {
        if (dp[it] == 0)
            dp[it] = calculatedp(it);
        dp[i] = max(dp[i], dp[it] + 1);
    }
    return dp[i];
}
int main()
{
    int i, j;
    cin >> n >> m;
    for (i = 1; i <= m; i ++) {
        cin >> x >> y;
        v[x].push_back(y);
    }
    for (i = 1; i <= n; i++)
        if (dp[i] == 0)
            dp[i] = calculatedp(i);
    j = 0;
    for (i = 1; i <= n; i++)
        j = max(j, dp[i]);
    cout << j - 1;

    return 0;
}


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

using namespace std;

int main(){
	int n, h;
	cin >> n >> h;
	int mx = 0;
	multiset<int> st;
	for(int i = 0; i < n; ++i){
		int a, b;
		cin >> a >> b;
		mx = max(mx, a);
		st.insert(b);
	}
	int cnt =0 ;
	while(!st.empty() && *st.rbegin() >= mx && h > 0){
		h -= *st.rbegin();
		st.erase(--st.end());
		++cnt;
	}
	if(h > 0){
		cnt += (mx + h - 1) / mx;
	}
	cout << cnt << '\n';
}

Measured memory_bytes: 4992
import java.util.Scanner;

//Scanner sc = new Scanner(System.in);

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
//		int[][] R = new int[N][N];
		for(int i = 0; i < N; i++){
			A[i] = sc.nextInt();
		}
		
		int min = getMin(A[0], A[1]);
		if(min > 1){
			for(int i = 2; i < N; i++){
				min = getMin(min, A[i]);
				if(min == 1) break;
				
			}

		}
				
		System.out.println(min);
	}
	
	static int getMin(int a, int b){
		if(a == 0) return b;
		return getMin(b%a, a);
	}
		
		
}


Measured memory_bytes: 49792
#include <stdio.h>

int main()
{
    int a,b;
    scanf("%d %d",&a,&b);

    int i;
    if(a > b)
    {

        for (i = 0; i < a; i++)
        {
            printf("%d",b);
        }
    }
    else
    {
        for (i = 0; i < b; i++)
        {
            printf("%d",a);
        }
        
    }
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main() {
	int x; cin >> x;
	switch (x%7){
	case 2:
		cout << "sat\n"; break;
	case 3:
		cout << "sun\n"; break;
	case 4:
		cout << "mon\n"; break;
	case 5:
		cout << "tue\n"; break;
	case 6:
		cout << "wed\n"; break;
	case 0:
		cout << "thu\n"; break;
	case 1:
		cout << "fri\n"; break;
	default: break;
	}
}

Measured memory_bytes: 3092
N,M = map(int,input().split())
A_s = list(map(int,input().split()))
BC_s = []
for _ in range(M):
  tempB,tempC = map(int,input().split())
  BC_s.append([tempB,tempC])
BC_s = reversed(sorted(BC_s, key=lambda x:x[1]))
D = []
A_s = sorted(A_s)

A_s_size = N
for BC in BC_s:
    B = BC[0]
    C = BC[1]
    if A_s_size == 0:
        break
    elif A_s_size < B:
        D.extend([C]*A_s_size)
        A_s_size -= A_s_size
    else:
        D.extend([C]*B)
        A_s_size -= B
minLength = min(N,len(D))
for i in range(minLength):
    if A_s[i] < D[i]:
        A_s[i] = D[i]
    else:
        break
print(sum(A_s[-N:]))


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

typedef long long ll;

ll N, K;
ll A[100000];
ll b[100];

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> A[i];
	int c = 0;
	ll k = K;
	while (k > 0) {
		k /= 2;
		c++;
	}
	for (int i = 0; i < c; i++) {
		b[i] = 0;
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < c; j++) {
			b[j] += (A[i] >> j) % 2;
		}
	}

	ll x = 0;
	for (int i = c - 1; i >= 0; i--) {
		if (2 * b[i] < N && x + ((ll)1 << i) <= K) x += ((ll)1 << i);
	}

	ll sum = 0;
	for (int i = 0; i < N; i++) {
		sum += (A[i] ^ x);
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 1024
use std::io::Read;

fn main() {
    let mut s: Vec<char> = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().chars().collect()
    };
    s.sort();
    if s[0] == s[1] && s[2] == s[3] && s[0] != s[2] {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramA
    {
        static void Main(string[] args)
        {

            var inputs = Console.ReadLine().Split(" ");
            var n = long.Parse(inputs[0]);
            var m = long.Parse(inputs[1]);
            var k = long.Parse(inputs[2]);

            var result = 0;

            for (var i = n; i <= m; i++)
            {
                if (i % k == 0)
                {
                    result++;
                }

            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 27232
import java.util.Scanner;

/**
 *
 * @author kouki
 */
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();
        if (B / A >= C) {
            System.out.println(C);
        } else if (B / A < C) {
            System.out.println(B / A);
        } else {
        }
    }

}

Measured memory_bytes: 22996
N = int(input())
S = list(input())

cnt = 0

ans = []

for s in S:
    if s =="(":
        if cnt >= 0:
            cnt += 1
            ans.append(s)
        else:
            ans.append(s)
            cnt = 0 - cnt
            for _ in range(cnt):
                ans.insert(0, s)
            cnt = 1
    else:
        if cnt <= 0:
            cnt -= 1
            ans.append(s)
        else:
            ans.append(s)
            cnt -= 1

if cnt > 0:
    for _ in range(cnt):
        ans.append(")")
elif cnt < 0:
    cnt = 0 - cnt
    for _ in range(cnt):
        ans.insert(0, "(")

print(''.join(ans))

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    string a,b,c;
    cout << 0 << endl;
    cin >> a;
    if(a == "Vacant") return 0;
    cout << (n-1)/2 << endl;
    cin >> b;
    if(b == "Vacant") return 0;
    cout << (n+1)/2 << endl;
    cin >> c;
    if(c == "Vacant") return 0;
    ll sup, inf;
    string ss, si;
    if((n+1)/2%2 == 0){
        if(a == b){
            sup = 0;
            inf = (n-1)/2;
            ss = a;
            si = b;
        }else{
            sup = (n+1)/2;
            inf = n;
            ss = c;
            si = a;
        }
    }else{
        if(a == b){
            sup = (n+1)/2;
            inf = n;
            ss = c;
            si = a;
        }else{
            sup = 0;
            inf = (n-1)/2;
            ss = a;
            si = b;
        }
    }
    while(true){
        ll tmp = (sup+inf)/2;
        cout << tmp << endl;
        string s;
        cin >> s;
        if(s == "Vacant") return 0;
        ll m = tmp - sup + 1;
        if(m%2){
            if(s == ss){
                sup = tmp;
                ss = s;
            }else{
                inf = tmp;
                si = s;
            }
        }else{
            if(s == ss){
                inf = tmp;
                si = s;
            }else{
                sup = tmp;
                ss = s;
            }
        }
    }

    return 0;
}


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

int main() {
    int n, num;
    char mark;
    int cards[4][13];
    for(int i=0; i<4; i++){
        for(int j=0; j<13; j++){
            cards[i][j]=0;
        }
    }
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> mark >> num;
        if(mark == 'S'){
            cards[0][num-1]=1;
        }
        else if(mark == 'H'){
            cards[1][num-1]=1;
        }
        else if(mark == 'C'){
            cards[2][num-1]=1;
        }
        else if(mark == 'D'){
            cards[3][num-1]=1;
        }
    }
    for(int i=0; i<4; i++){
        for(int j=0; j<13; j++){
            if(cards[i][j]==0){
                if(i==0){
                    cout << "S ";
                }
                else if(i==1){
                    cout << "H ";
                }
                if(i==2){
                    cout << "C ";
                }
                if(i==3){
                    cout << "D ";
                }
                cout << j+1 << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    string N_str, Q_str;
    int N, Q;
    string S;
    cin >> N_str >> Q_str;
    cin >> S;
    N = stoi(N_str);
    Q = stoi(Q_str);
    int AC_from_top[N];
    int answer[Q];

    int k = 0;
    AC_from_top[0] = 0;
    //cout << 0;
    for (int n = 0; n < N; n++)
    {
        if (S[n] == 'A' && S[n + 1] == 'C')
        {
            k++;
        }
        AC_from_top[n + 1] = k;
        //cout << k;
    }

    for (int i = 0; i < Q; i++)
    {
        int correct_num = 0;
        string l_str, r_str;
        int l, r;
        cin >> l_str >> r_str;
        l = stoi(l_str);
        r = stoi(r_str);
        answer[i] = AC_from_top[r - 1] - AC_from_top[l - 1];
    }

    for (int i = 0; i < Q; i++)
    {
        cout << answer[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

using P1 = array<int, 26>;
using P2 = array<char, 365>;

int ii = 365;
struct state{
    array<int, 26> prv;
    array<char, 365> ans;
    int val1, val2;
    bool operator<(const state &a) const { return val1+val2*2.3 > a.val1+a.val2*2.3; }
    state(P1 a, P2 b, int x, int y) : prv(a), ans(b), val1(x), val2(y) {};
};


int main() {
    int d;
    cin >> d;
    array<int, 26> A{};
    for (auto &&k : A) cin >> k;
    vector<array<int, 26>> v(d);
    for (int i = 0; i < d; ++i) {
        for (int j = 0; j < 26; ++j) {
            scanf("%d", &v[i][j]);
        }
    }
    vector<int> ans(d);
    int W = 400;
    vector<state> a;
    a.emplace_back(P1{}, P2{}, 0, 0);
    fill(a[0].prv.begin(),a[0].prv.end(), -1);
    for (int i = 0; i < d; ++i) {
        ii--;
        priority_queue<state> Q;
        for (auto &&s : a){
            s.val2 = 0;
            for (int l = 0; l < 26; ++l) {
                s.val1 -= (i-s.prv[l])*A[l];
                s.val2 -= (i-s.prv[l])*A[l];
            }
            for (int k = 0; k < 26; ++k) {
                state ss(s);
                ss.ans[i] = k;
                ss.val1 += v[i][k]+s.prv[k]*A[k];
                ss.val2 += s.prv[k]*A[k];
                ss.prv[k] = i;
                ss.val1 -= s.prv[k]*A[k];
                ss.val2 -= s.prv[k]*A[k];
                Q.emplace(ss);
                if(Q.size() > W) Q.pop();
            }
        }
        a.clear();
        while(!Q.empty()) a.emplace_back(Q.top()), Q.pop();
    }
    sort(a.begin(),a.end(), [&](state a, state b){ return a.val1 < b.val1; });
    for (auto &&m : a.back().ans) {
        printf("%d\n", m+1);
    }
    return 0;
}

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

int main(){
	int yama;
	int a = 0;
	int b = 0;
	int c = 0;

	for (int i = 0; i < 10; i++){
		cin >> yama;
		if (a < yama){
			c = b;
			b = a;
			a = yama;
		}
		else if (b < yama || a == yama){
			c = b;
			b = yama;
		}
		else if (c < yama || b == yama){
			c = yama;
		}
	}
	cout << a << endl << b << endl << c << endl;

	return 0;
}


Measured memory_bytes: 3080
#include <stdio.h>


int gcd(int a, int b) {
  if (b > a)
    return gcd(b, a);

  if (a%b == 0)
    return b;

  return gcd(b, a%b);
}

int main() {
  int a,b;
  scanf("%d %d", &a, &b);

  printf("%d\n", gcd(a, b));

  return 0;
}



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

char A[ 5 ];
char B[ 5 ];

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

	cin >> A;
	cin >> B;

	if( A[ 0 ] == B[ 2 ] && A[ 1 ] == B[ 1 ] && A[ 2 ] == B[ 0 ] )
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}






Measured memory_bytes: 256
import java.io.InputStreamReader;
import java.io.LineNumberReader;

/**
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_9_C
 * 
 * @author eitatsuro
 * 
 */
public class Main {
    
    public static final int WIN_POINTS=3;
    public static final int EVEN_POINTS=1;
    
    public static void main(String[] args) {
        try {
            LineNumberReader lineNumReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String inputStr = null;
            long turnNum = 0;
            String taro = null;
            String hanako = null;
            long taroPoint=0;
            long hanakoPoint=0;
            
            while ((inputStr = lineNumReader.readLine()) != null) {
                
                // ????????????????????°?????????.
                if (lineNumReader.getLineNumber() == 1) {
                    turnNum = Integer.parseInt(inputStr);
                }
                
                if (lineNumReader.getLineNumber() > 1) {
                    String[] line = inputStr.split(" ");
                    taro = line[0];
                    hanako = line[1];
                    
                    // ??????
                    if (taro.compareTo(hanako) < 0) {
                        hanakoPoint += WIN_POINTS;
                    } else if (taro.compareTo(hanako) == 0) {
                        taroPoint += EVEN_POINTS;
                        hanakoPoint += EVEN_POINTS;
                    } else {
                        taroPoint += WIN_POINTS;
                    }
                }


                
                if (lineNumReader.getLineNumber() == turnNum+1) {
                    System.out.print(taroPoint);
                    System.out.print(" ");
                    System.out.println(hanakoPoint);
                    break;
                }
            }
            
            lineNumReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    }
    
    public static String shuffle(String original, int h) {
        StringBuilder shuffledStr = new StringBuilder(original);
        String temp = shuffledStr.substring(0, h);
        shuffledStr.delete(0, h);
        shuffledStr.append(temp);
        return shuffledStr.toString();
        
    }
}

Measured memory_bytes: 25208
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
using namespace std;

const char *p;

int solve() {
  int ret = 0;
  
  ++p;
  if(*p == '[') {
    vector<int> v;
    while(*p == '[') v.push_back(solve());
    sort(v.begin(), v.end());
    for(int i = v.size()/2; i>=0; i--) ret += v[i];
  } else {
    char *e;
    ret = strtol(p, &e, 10)/2 + 1;
    p = e;
  }
  ++p;
  return ret;
}

int main() {
  int n;
  string s;
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin>>s;
    p = s.c_str();
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 1284
program main
  implicit none
  character(len=100000) :: S1
  character(len=700000) :: S
  character(len=300000) :: Sout
  character(len=1) :: c
  integer :: i,Q,j,j2,N, ii
  integer :: t, f
  integer :: l,r
  logical :: flag 
  read(*,*) S1
  read(*,*) Q
  N = len_trim(S1)
  l = 350000 - N/2
  r = l + N -1
  S(l:r)  = S1(1:N)
  flag=.true.
  do i = 1, Q
     read(*,*) t
     if (t == 1) then
        backspace(5)
        read(*,*) t
        if (flag ) then
           flag = .false.
        else
           flag = .true.
        end if
     else
        backspace(5)
        read(*,*) t, f, C
        if ( f == 1 ) then
           if (flag) then
              l = l-1
              S(l:l) = C
           else
              r = r+1
              S(r:r) = C
           end if
        else
           if ( .not. flag) then
              l = l-1
              S(l:l) = C
           else
              r = r+1
              S(r:r) = C
           end if
        end if
        N = N + 1
     end if
  end do

  if (flag) then
     Sout(1:N) = S(l:r)
  else
     do i = 1,N
        Sout(i:i) = S(r-i+1:r-i+1)
     end do
  end if
  write(*,'(a)') trim(Sout(1:N))
end program main

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

int main(){
	string s;
	cin >> s;
	int flag = 0;
	for(int i=0; i<s.length(); i++){
		if((i+1)%2==1){
			if(s[i]=='R'||s[i]=='U'||s[i]=='D'){
				continue;
			}
			else{
				cout << "No";
				flag = 1;
				break;
			}
		}
		else{
			if(s[i]=='L'||s[i]=='U'||s[i]=='D'){
				continue;
			}
			else{
				cout << "No";
				flag = 1;
				break;
			}
		}
	}
	if(flag==0)
		cout << "Yes";

}

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

int main() {
  int n;
  cin >> n;
  int m = n;
  int s = 0;
  while (m) {
    s += m%10;
    m /= 10;
  }
  if (n % s == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
VI prd;
VI sqn;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  prd=VI(8,0);
  prd[0]=1;
  const in bs=200;
  in bpw=1;
  in cop=0;
  for(in i=0;i<8;++i){
    while(prd[i]<bpw){
      ++cop;
      prd[i]+=prd[i-1];
    }
    for(in j=i+1;j<8;++j){
      ++cop;
      prd[j]+=prd[j-1];
    }
    sqn.PB(prd[7]);
    bpw*=bs;
  }
  sort(all(sqn));
  reverse(all(sqn));
  in k;
  cin>>k;
  VI ac(sz(sqn));
  forv(i,sqn){
    while(k>=sqn[i]){
      ++cop;
      ++ac[i];
      k-=sqn[i];
    }
  }
  assert(cop<=5000);
  string cod="0FESTIVAL";
  prd=VI(8,0);
  prd[0]=1;
  bpw=1;
  in nx=sz(ac)-1;
  for(in i=0;i<8;++i){
    while(prd[i]<bpw){
      cout<<cod[i];
      prd[i]+=prd[i-1];
    }
    for(in j=i+1;j<8;++j){
      prd[j]+=prd[j-1];
      cout<<cod[j];
    }
    bpw*=bs;
    forn(j,ac[nx])
      cout<<cod[8];
    --nx;
  }
  cout<<endl;
  return 0;
}


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

#define vd vector<double>
 
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define vc vector<char>
#define vcc vector< vector<char> >
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
// #define mp make_pair
//#define endl '\n'
 
int main() {
    int h, w;
    cin >> h >> w;
    vcc a(h, vc(w));
    int leaves = h * w;
    queue<pii> qu;
    rep(i,h){
        rep(j,w){
            char c;
            cin >> c;
            a[i][j] = c;
            if(c == '#'){
                leaves--;
                qu.push(pii(i,j));
            }
        }
    }
    int ans = 0;
    for(ans=0;; ans++){
        if(leaves == 0) break;
        queue<pii> _qu;
        while(!(qu.empty())){
            int i0 = qu.front().first, j0 = qu.front().second;
            qu.pop();
            rep(k,4){
                int ni = i0 + dx[k], nj = j0 + dy[k];
                if(!(in(ni, 0, h)) || !(in(nj, 0, w))) continue;
                if(a[ni][nj] == '#') continue;
                a[ni][nj] = '#';
                _qu.push(pii(ni, nj));
                leaves--;
            }
        }
        qu = _qu;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9600
#include <stdio.h>


using namespace std;

class CSolver{
public:
	CSolver();
	int solve();
	int in_a_;
	int in_b_;
	int out_length_;
	int out_area_;
};

CSolver::CSolver(){
	in_a_ = 0;
	in_b_ = 0;
};

int CSolver::solve(){
	scanf("%d %d", &in_a_,&in_b_);
	out_length_ = (in_a_+ in_b_) * 2;
	out_area_ = in_a_ * in_b_;
	printf("%d %d\n", out_area_ , out_length_);
	return 0;
};

int main(){

	CSolver mysol;

	mysol.solve();

	return 0;
}

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


void solve(long long X){
  long long n = 0;
  long long bank = 100;
  while (bank < X) {
    bank *= 1.01;
    n++;
  }
  cout << n << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;

void test();

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vector<int> a(n);
	f(i,0,n){
		cin >> a[i];
	}
	int ans =0 ;
	f(i,1,n-1){
		vector<int> temp = {a[i],a[i-1],a[i+1]};
		sort(all(temp));
		if(a[i]==temp[1]){
			ans++;
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

struct UnionFind {
	vector<int> par, sz;
	UnionFind(int n) {
		par.resize(n);
		sz.resize(n);
		for(int i = 0; i < n; i++) {
			par[i] = i;
			sz[i] = 1;
		}
	}
	int find(int x) {
		return x == par[x] ? x : par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if(x == y) return;
		if(sz[x] < sz[y]) swap(x, y);
		sz[x] += sz[y];
		par[y] = x;
	}
	bool areSame(int x, int y) {
		return find(x) == find(y);
	}
	int size(int x) {
		return sz[find(x)];
	}
};

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n;
	cin >> n;
	pair<pii, int> a[n];
	for(int i = 0; i < n; i++) {
		cin >> a[i].fi.fi >> a[i].fi.se;
		a[i].se = i;
	}
	sort(a, a + n);
	stack<int> s;
	UnionFind uf(n);
	for(int i = 0; i < n; i++) {
		int cur = -1;
		if(!s.empty() && a[s.top()].fi.se < a[i].fi.se) {
			cur = s.top();
		}
		while(!s.empty() && a[s.top()].fi.se < a[i].fi.se) {
			uf.unite(i, s.top());
			s.pop();
		}
		if(cur != -1) {
			s.push(cur);
		}
		else {
			s.push(i);
		}
	}
	int ans[n];
	for(int i = 0; i < n; i++) {
		ans[a[i].se] = uf.size(i);
	}
	for(int i = 0; i < n; i++) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 12696
N, M = map(int,input().split())
A = list(map(int,input().split()))
BC = list(list(map(int,input().split())) for i in range(M))
A.sort()
BC = sorted(BC,key = lambda x:x[1],reverse = True)
X = []

for B,C in BC:
    for i in range(min(B,N-len(X))):
        X.append(C)
for i in range(N-len(X)):
    X.append(0)
ans = 0
for i in range(N):
    ans += max(A[i],X[i])
print(ans)

Measured memory_bytes: 34648
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int tt;
int m,n;
bool prime[20001];
int pt[20001];
bool ok[20001];
int main(void){
	scanf("%d",&tt);
	memset(pt,false,sizeof(pt));
	for(int i=0;i*i<=20000;i++){
		for(int j=i;j*j+i*i<=20000;j++){
			pt[i*i+j*j]=true;
		}
	}
	for(int cc=0;cc<tt;cc++){
		scanf("%d %d",&m,&n);
		bool flag=true;
		for(int i=0;i*i<=m*m+n*n;i++){
			if(!flag)break;
			for(int j=i;j*j+i*i<=m*m+n*n;j++){
				if(i*i+j*j<=1)continue;
				if(!flag)break;
				if((m*m+n*n)%(i*i+j*j)!=0)continue;
				if(!pt[(m*m+n*n)/(i*i+j*j)])continue;
				if(abs(m)==abs(i) && abs(n)==abs(j))continue;
				if(abs(n)==abs(i) && abs(m)==abs(j))continue;
				int k=i*i+j*j;
				int d=i*m+j*n;
				if(abs(d)%k==0)flag=false;
				d=i*n-j*m;
				if(abs(d)%k==0)flag=false;
				i=-i;
				d=i*m+j*n;
				if(abs(d)%k==0)flag=false;
				d=i*n-j*m;
				if(abs(d)%k==0)flag=false;
				j=-j;
				d=i*m+j*n;
				if(abs(d)%k==0)flag=false;
				d=i*n-j*m;
				if(abs(d)%k==0)flag=false;
				i=-i;
				d=i*m+j*n;
				if(abs(d)%k==0)flag=false;
				d=i*n-j*m;
				if(abs(d)%k==0)flag=false;
				j=-j;
				//if(!flag)printf("%d %d\n",i,j);
			}
		}
		printf("%c\n",flag?'P':'C');
	}
	return 0;
}

Measured memory_bytes: 1120
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i];

  map<Int, Int> cnt;
  for(Int x:as) cnt[x]++;

  Int ans=0;
  vector<Int> vs;
  for(auto p:cnt){
    if(p.second>=4)
      chmax(ans,p.first*p.first);
    if(p.second>=2)
      vs.emplace_back(p.first);
  }

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

  if(vs.size()>=2u) chmax(ans,vs[0]*vs[1]);

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


Measured memory_bytes: 7296