akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }

    friend std::istream &operator>>(std::istream &in, mint &o) {
        ll a;
        in >> a;
        o = a;
        return in;
    }

    friend std::ostream &operator<<(std::ostream &out, const mint &o) {
        out << o.x;
        return out;
    }

};

int main() {
    int n;
    cin >> n;
    vector<ll> slimes(n);
    rep(i, n) cin >> slimes[i];

    vector<mint> dp(n + 1);
    mint tot = 0;
    for (int i = 1; i <= n; i++) {
        dp[i] = (tot + i) / i;
        tot += dp[i];
    }

    mint sum = 0;
    rep(i, n - 1)sum += mint(slimes[i + 1] - slimes[i]) * dp[i + 1];

    mint fact = 1;
    rep(i, n) if (i != 0) fact *= i;

    mint ans = sum * fact;

    cout << ans << endl;

}


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

#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define sz(c) int(c.size())
#define clr(v, d)   memset(v, d, sizeof(v))
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define INF             INT64_MAX
#define NINF            INT64_MIN
#define ROW 1001
#define COL 1001

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<pll> vll;
typedef vector<ll> vl;
vi arr(100);
int main(void){

    int n;
    cin>>n;
    int average=0,ans1=0,ans2=0;
    loop(i,n){
        cin>>arr[i];
        average+=arr[i];
    }
    average/=n;

    loop(i,n){
        ans1+=pow(average-arr[i],2);
        ans2+=pow(average+1-arr[i],2);
    }
    cout<<min(ans1,ans2)<<endl;
    return 0;
}


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

using namespace std;

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

    int n, m, x;
    cin >> n >> m >> x;
    int cnt = 0, cnt2 = 0;
    for(int i = 0; i < m; i++)
    {
        int a;
        cin >> a;
        if(a < x)
            cnt++;
        else
            cnt2++;
    }

    cout << min(cnt, cnt2);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll pc[55][55]={};
int main(){
    ll ans,acc;
    pc[0][0]=1;
    for(int i=1;i<55;i++){
        pc[i][0]=1;
        pc[i][i]=1;
        for(int j=1;j<i;j++){
            pc[i][j]=pc[i-1][j]+pc[i-1][j-1];
        }
    }
    ll n,k;cin>>n>>k;
    ll p[2]={};
    for(ll i=0;i<n;i++){
        ll t;cin>>t;
        p[t&1]++;
    }
    acc=0;
    for(ll i=k&1;i<=p[1];i+=2)acc+=pc[p[1]][i];
    ans=(1LL<<p[0])*acc;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;

void func(int i, int& left, int& right)
{
	right = i % 10;
	while (i >= 10) {
		i /= 10;
	}
	left = i % 10;
}

int main()
{
	int n;
	cin >> n;
	vector<vector<ll>> dp(10, vector<ll>(10, 0LL));
	int left, right;
	ll ans = 0LL;

	for (int i = 1; i <= n; i++) {
		func(i, left, right);
		if (left == 0 && right == 0) {
		}
		dp[left][right]++;
	}

	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			ans += dp[i][j] * dp[j][i];
		}
	}

	printf("%lld", ans);

	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int a = 0, b = 0;
    imfor(i, 3) {
        int n;
        cin >> n;
        if (n == 5) {
            a++;
        }
        else if (n == 7) {
            b++;
        }
    }
    if (a == 2 && b == 1) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
let s = read_line () |> Bytes.of_string in
let k = read_int () in
let n = Bytes.length s in
let aa = int_of_char 'a' in
let rec loop i rest =
    if i = n then print_endline @@ Bytes.to_string s else
        let add = if i = n - 1 then rest else (
            let p = int_of_char (Bytes.get s i) - aa in
            if p = 0 then 0 else
                if rest >= 26 - p then 26 - p else 0
        )
        in
        let p = int_of_char (Bytes.get s i) - aa in
        let p = (p + add) mod 26 in
        let () = Bytes.set s i (char_of_int (p + aa)) in
        loop (i + 1) (rest - add)
in
loop 0 k

Measured memory_bytes: 2944
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
const ll MOD = 1000000000000000001;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  string s;
  cin>>s;
  ll ans=0;
  for(ll i=0;i<s.size()/2;i++){
    if(s[i]!=s[s.size()-1-i]) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().rstrip().split()
def S(): return sys.stdin.readline().rstrip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]

mod=10**9+7


class UnionFind:
    def __init__(self, n):
        # 負  : 根であることを示す。絶対値はランクを示す
        # 非負: 根でないことを示す。値は親を示す
        self.table = [-1] * n
        self.size = [1] * n
        # self.group_num = n

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

    def get_size(self, x):
        r = self.root(x)
        return self.size[r]

    def is_same(self, x, y):
        return self.root(x) == self.root(y)

    def union(self, x, y):
        r1 = self.root(x)
        r2 = self.root(y)
        if r1 == r2:
            return
        # ランクの取得
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.size[r1] += self.size[r2]
            if d1 == d2:
                self.table[r1] -= 1
        else:
            self.table[r1] = r2
            self.size[r2] += self.size[r1]
        # self.group_num -= 1


n,m=LI()
U=UnionFind(n)
for _ in range(m):
    a,b=LI()
    U.union(a-1,b-1)

ans=0
for i in range(n):
    ans=max(ans, U.get_size(i))

print(ans)


Measured memory_bytes: 86388
#include <bits/stdc++.h>
#define mem(a, b) memset(a, b, sizeof(a))
#define inf (1e9 + 7)
using namespace std;

int num[305][305], n, m, ans, num2[305], num3[305];
bool vis[305];

bool jg(int a)
{
    mem(vis, 0);
    for(int i = 1;i <= n;i++)
        num2[i] = 1;
    while(1)
    {
        mem(num3, 0);
        for(int i = 1;i <= n;i++)
            num3[num[i][num2[i]]]++;
        bool ff = 0;
        for(int j = 1;j <= m;j++)
        {
            if(num3[j] > a)
                vis[j] = 1, ff = 1;
        }
        if(!ff)
            return true;
        for(int i = 1;i <= n;i++)
        {
            while(vis[num[i][num2[i]]]&&num2[i] <= m)
                num2[i]++;
        }
        for(int i = 1;i <= n;i++)
        {
            if(num2[i] > m)
                return false;
        }
    }
}

int main()
{
    scanf("%d%d", &n, &m);
    ans = m;
    for(int i = 1;i <= n;i++)
        for(int j = 1;j <= m;j++)
            scanf("%d", &num[i][j]);
    int l = 1, r = n;
    while(l <= r)
    {
        int mid = (l + r) / 2;
        if(jg(mid))
            r = mid - 1, ans = mid;
        else
            l = mid + 1;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define VI vector<int>
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60 ; const ll MOD=1e9+7 ;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------
int n;
vector<PII> v;
map<PII, ll> mp;

int main(){
	cin >> n;
	FOR(i,1,n){
		ll x,y; cin >> x >> y;
		v.push_back(MP(x,y));
	}
	sort(ALL(v));
	FOR(i,0,n-2){
		FOR(j,i+1,n-1){
			ll dx = v[j].FI-v[i].FI;
			ll dy = v[j].SE-v[i].SE;
			auto it = mp.find(MP(dx,dy));
			if(it!=mp.end()){
				it->SE += 1;
			}else{
				mp.insert(MP(MP(dx,dy),1));
			}
		}
	}
	//auto mxit = mp;
	ll mx =0;
	for(auto x:mp){
		if(x.SE > mx){
			mx = x.SE;
		}
	}
	cout << n-mx << endl;
    return 0;
}


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

using namespace std;
using ll = long long;

int main(){
  ll N;
  cin >> N;
  vector<ll> as(N);
  for (ll i = 0; i < N; i++){
  	cin >> as.at(i);
  }
  ll m{numeric_limits<ll>::min()};
  for (ll i = 0; i < N; i++){
  	for (ll j = 0; j < N; j++){
      if (i == j) continue;
      m = max(m, abs(as.at(i)-as.at(j)));
    }
  }
  cout << m;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

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

	string l,r;
	l += s[0];
	l += s[1];
	r += s[2];
	r += s[3];
	bool y = true, d = true;

	if (r == "00" || "13" <= r)
		y = false;
	if (l == "00" || l >= "13")
		d = false;

	if (y&d)
		cout << "AMBIGUOUS" << endl;
	else if (y)
		cout << "YYMM" << endl;
	else if (d)
		cout << "MMYY" << endl;
	else
		cout << "NA" << endl;

	return 0;
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <bitset>
#include <iterator>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <random>
#include <numeric>
#include <set>
#include <cassert>
#include <cmath>
#include <cinttypes>

using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os; }
template<class T> istream& operator>>(istream& is, vector<T>& v) { for (auto i = begin(v); i != end(v); i++) is >> *i; return is; }
struct fast_io {
	fast_io& operator>> (int& target) { scanf("%" PRId32, &target);  return *this; }
	fast_io& operator>> (unsigned int& target) { scanf("%" PRIu32, &target);  return *this; }
	fast_io& operator>> (long long& target) { scanf("%" PRId64, &target);  return *this; }
	fast_io& operator>> (unsigned long long& target) { scanf("%" PRIu64, &target);  return *this; }
	template<typename T> fast_io& operator>> (vector<T>& target) { for (auto& value : target) { *this >> value; } return *this; }
	fast_io& operator<< (const int value) { printf("%" PRId32, value); return *this; }
	fast_io& operator<< (const unsigned int value) { printf("%" PRIu32, value); return *this; }
	fast_io& operator<< (const long long value) { printf("%" PRId64, value); return *this; }
	fast_io& operator<< (const unsigned long long value) { printf("%" PRIu64, value); return *this; }
	fast_io& operator<< (const string& value) { printf("%s", value.c_str()); return *this; }
	template<typename T> fast_io& operator<< (const vector<T>& target) { for (auto& value : target) { *this << value << " "; } return *this; }
}; fast_io fio;

template<class ForwardIt, class UnaryPredicate>
ForwardIt first_true(ForwardIt first, ForwardIt last, UnaryPredicate predicate) {
	ForwardIt it;
	typename std::iterator_traits<ForwardIt>::difference_type count, step; count = std::distance(first, last);
	while (count > 0) {
		it = first;	step = count / 2;
		std::advance(it, step);
		if (!predicate(*it)) { first = ++it; count -= step + 1; }
		else count = step;
	}
	return first;
}

#define MOD 1000000007
#define pii pair<int,int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define sort_all(x) sort(all(x))
#define make_unique(x) (x).erase(unique(all(x)), (x).end())


template<typename T>
inline T fast_gcd(T a, T b)
{
	T c;
	while (b)
	{
		c = b;
		b = a % b;
		a = c;
	}
	return a;
}


int main() {

#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif


	int x;
	cin >> x;
	cout << ((x*360)/fast_gcd(x, 360))/x;

	return 0;
}

Measured memory_bytes: 3584
a=list(input())
b=list(input())

L=[0]*(len(a)*2)

if len(a)==len(b):
    for i in range(len(a)):
        L[i*2]=a[i]
        L[i*2+1]=b[i]
else:
  for i in range(len(a)-1):
    L[i*2]=a[i]
    L[i*2+1]=b[i]
  L[-2]=a[-1]
  del L[-1]
 
print("".join(L))

    

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

#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
using namespace std;
const int INF = 1e9 + 5;

int  main() {
   FAST_IO;
   int n, k;cin >> n >> k;
   vector<int> stones(n);
   for (int i = 0; i < n; i++) cin >> stones[i];
   vector<int> dp(n, INF);
   dp[0] = 0;
   for (int i = 0; i < n; i++) { 
      for (int j = i + 1; j <= i + k; j++) {
         if (j < n)
            dp[j] = min(dp[j], dp[i] + abs(stones[j] - stones[i]));
        }
    }
    cout << dp[n - 1];
    return 0;
}

Measured memory_bytes: 4004
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int a,b,m;
    cin>>a>>b>>m;
    int u[a+1],v[b+1];
    int num1=1e9,num2=1e9;
    int mi=1e9;
    for(int i=1;i<=a;i++){
    	cin>>u[i];
    	num1=min(num1,u[i]);
    }
    for(int i=1;i<=b;i++){
    	cin>>v[i];
    	num2=min(num2,v[i]);
    }
    mi=num1+num2;
    int c,d,e;
    for(int i=0;i<m;i++){
    	cin>>c>>d>>e;
    	mi=min(mi,u[c]+v[d]-e);
    }
    cout << mi<<endl;
    return 0;
}


Measured memory_bytes: 1024
X = input()
Y = input()
m = len(X)
n = len(Y)
res=[[m + n for j in range(n + 1)] for i in range(m + 1)]
for i in range(m + 1):
    res[i][0] = i
for j in range(n + 1):
    res[0][j] = j
for i in range(1,m+1):
    for j in range(1,n+1):
        a=1
        if X[i-1]==Y[j-1]:
            a=0
        res[i][j]=min(a+res[i-1][j-1], 1+res[i-1][j], 1+res[i][j-1])
print(res[m][n])
        


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

int main(){
  int N, D;
  cin >> N >> D;
  vector<vector<int>> X(N, vector<int>(D));
  for(int i = 0; i < N; i++){
    for(int j = 0; j < D; j++){
      cin >> X[i][j];
    }
  }
  int ans = 0;
  for(int i = 0; i < N; i++){
    for (int j = i+1; j < N; j++){
      int norm = 0;
      for (int k = 0; k < D; k++){
        int diff = abs(X[i][k] - X[j][k]);
        norm += diff * diff;
      }
      // check whether norm = k for some k
      bool flag = false;
      for (int k = 0; k <= norm; k++){
        if( k * k == norm){
          flag = true;
        }
      }
      if(flag) {
        ans ++;
      }
    }
  }
  cout << ans << endl;
}


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

using namespace std;

#define LL long long 
#define ULL unsigned LL
#define LD long double 

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int ile[4] = {0};
	// AC, WA, TLE, RE
	int n;
	cin>>n;
	string s;
	for(int i=0; i<n; i++) {
		cin>>s;
		if(s == "AC")
			ile[0]++;
		else if(s == "WA")
			ile[1]++;
		else if(s == "TLE")
			ile[2]++;
		else
			ile[3]++;
	}
	cout<<"AC x "<<ile[0]<<"\nWA x "<<ile[1]<<"\nTLE x "<<ile[2]<<"\nRE x "<<ile[3];
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    string s;cin>>s;
    ll res=0;
    bool jud=false;
    rep(i,s.size()){
        if(i==0){
            res+=(s[i]-'0');
            continue;
        }
        if(s[i]=='9'||jud)res+=9;
        else{
            res+=8;
            jud=true;
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  for(;;){
    int n;
    cin >> n;
    if(n==1) break;
    vector<int> v;
    vector<bool> w(n+1,true);
    int d = 6;
    bool bAdd2 = true;
    while(d <= n){
      if(w[d]){
        for(int i=d; i<=n; i+=d){
          w[i] = false;
        }
        if(n % d == 0) v.push_back(d);
      }
      if(bAdd2){
        d += 2;
      }else{
        d += 5;
      }
      bAdd2 = !bAdd2;
    }
    cout << n << ":";
    for(int i=0; i<v.size(); i++){
      cout << " " << v[i];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1252
class PQ
  def initialize(&block)
    @heap = [nil]
    @cmp = block || lambda{|x, y| x <=> y}
  end

  def empty?
    @heap.size == 1
  end

  def insert(value)
    @heap.push(value)
    up_heap
  end

  def bulk_insert(values)
    values.each{|value| insert(value)}
  end
  
  def up_heap(k = @heap.size - 1)
    while true
      return if k == 1

      parent = k / 2
      if @cmp.(@heap[parent], @heap[k]) == -1
        @heap[parent], @heap[k] = @heap[k], @heap[parent]
        k = parent
      else
        return
      end
    end
  end

  def top
    @heap[1]
  end

  def pop
    if empty?
      nil
    elsif @heap.size == 2
      @heap.pop
    else
      value = @heap[1]
      @heap[1] = @heap.pop
      down_heap
      value
    end
  end

  def down_heap(k = 1)
    loop do
      child1 = 2 * k
      child2 = 2 * k + 1
      if @cmp.(child1, @heap.size)  >= 0
        return
      elsif @cmp.(child2, @heap.size)  >= 0
        large_child = child1
      else
        large_child = (@cmp.(@heap[child1], @heap[child2]) > 0) ? child1 : child2
      end

      if @cmp.(@heap[large_child], @heap[k]) > 0
        @heap[large_child], @heap[k] = @heap[k], @heap[large_child]
        k = large_child
      else
        return
      end
    end
  end
end


require 'set'

def value(t)
  $a[t[0]] + $b[t[1]] + $c[t[2]]
end

def main
  x, y, z, k = gets.split(/\s+/).map(&:to_i)
  $a = gets.split(/\s+/).map(&:to_i)
  $b = gets.split(/\s+/).map(&:to_i)
  $c = gets.split(/\s+/).map(&:to_i)

  $a.sort!
  $b.sort!
  $c.sort!

  done = Set.new
  q = PQ.new
  t = [x - 1, y - 1, z - 1]
  q.insert([value(t), t])

  k.times do
    value, t = q.pop
    puts value
    t1 = [t[0] - 1, t[1], t[2]]
    t2 = [t[0], t[1] - 1, t[2]]
    t3 = [t[0], t[1], t[2] - 1]
    if !done.member?(t1) && t[0] - 1 >= 0
      q.insert([value(t1), t1])
      done.add(t1)
    end
    if !done.member?(t2) && t[1] - 1 >= 0
      q.insert([value(t2), t2])
      done.add(t2)
    end
    if !done.member?(t3) && t[2] - 1 >= 0
      q.insert([value(t3), t3])
      done.add(t3)
    end

  end
end

main


Measured memory_bytes: 15180
x,y = map(int,input().split())
if abs(x) == abs(y):
  print(1)
  exit()
if x*y > 0:
  if x < y:
    print(y-x)
  else:
    print(x-y+2)
elif x*y < 0:
  print(abs(abs(x)-abs(y))+1)
else:
  if x < y:
    print(y-x)
  else:
    print(abs(x+y)+1)

Measured memory_bytes: 9188
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
3 5
0 0 1
0 1 2
0 2 3
1 0 2
1 1 2

output:
1
2
"""

import math
import sys

INIT_MAX = pow(2, 31) - 1


class RMQ(object):
    def __init__(self, in_data):
        """
        Init a SegmentTree with update and find for range minimum queries.
        """
        n_num, q_num = map(int, in_data[0].split())
        self.queries = map(lambda x: x.split(), in_data[1:])
        self.ext_heap_length = pow(2, math.ceil(math.log2(n_num)))
        self.dat = [INIT_MAX] * (2 * self.ext_heap_length - 1)

    # let A[k]=a
    def update(self, k, a):
        k += self.ext_heap_length - 1
        self.dat[k] = a
        while k > 0:
            k = (k - 1) // 2
            self.dat[k] = min(self.dat[k * 2 + 1], self.dat[k * 2 + 2])

    # get min(A[s] A[s+1] ... A[t])
    def find(self, s, t, k=0, left=0, right=float('inf')):
        if right <= s or t <= left:
            return INIT_MAX
        elif s <= left <= right <= t:
            return self.dat[k]
        else:
            vl = self.find(s, t, k * 2 + 1, left, (left + right) // 2)
            vr = self.find(s, t, k * 2 + 2, (left + right) // 2, right)
            return min(vl, vr)

    def cmd_exec(self):
        for query in self.queries:
            cmd, ele_1, ele_2 = map(int, query)
            if cmd == 0:
                self.update(ele_1, ele_2)
            elif cmd == 1:
                # assert ele_1 <= ele_2
                res = self.find(s=ele_1, t=ele_2 + 1, right=self.ext_heap_length)
                print(res)

        return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    case = RMQ(in_data=_input)
    case.cmd_exec()

Measured memory_bytes: 19672
use proconio::*;

#[fastout]
#[allow(non_snake_case)]
fn main() {
    input! {
        mut A: i32, B: i32, mut C: i32, D: i32
    }
    let mut i = 0;
    while A > 0 && C > 0 {
        if i % 2 == 0 {
            C -= B;
        } else {
            A -= D;
        }
        i += 1;
    }
    println!("{}",
        if i % 2 == 1 {
            "Yes"
        } else {
            "No"
        }
    )
}


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


struct RMQ{
public:
    const int inf=(1ll<<31ll)-1ll;
    int n;
    vector<int> dat;

    RMQ(int n_){
        n=1;
        while(n<n_) n*=2;
        dat.resize(2*n-1);
        for(int i=0;i<2*n-1;i++) dat[i]=inf;
    }

    // k??????(0-index)?????????a????????´
    void update(int k,int a){
        k+=n-1;
        dat[k]=a;
        while(k>0){
            k=(k-1)/2;
            dat[k]=min(dat[k*2+1],dat[k*2+2]);
        }
    }

    // [a,b)???????°????(???????????????????????¨???)
    // k:???????????????
    // [l,r)?????????k?????????
    int query(int a,int b,int k,int l,int r){
        if(r<=a or b<=l) return inf;

        if(a<=l and r<=b){  //[a,b)???[l,r)????????¨???????????§??????
            return dat[k];
        }
        else{
            int vl=query(a,b,k*2+1,l,(l+r)/2);
            int vr=query(a,b,k*2+2,(l+r)/2,r);
            return min(vl,vr);
        }
    }

    // [a,b)???????°????????±???????.
    int query(int a,int b){
        return query(a,b,0,0,n);
    }
};

int main(){
    int n,q;
    cin>>n>>q;
    RMQ rmq(n);
    for(int i=0;i<q;i++){
        int com,x,y;
        cin>>com>>x>>y;
        if(com==0){
            rmq.update(x,y);
        }else{
            cout << rmq.query(x,y+1) << endl;
        }
    }
}

Measured memory_bytes: 3896
S = input()

S_left = S[:len(S)//2]

if len(S) % 2 == 0:
    S_right = S[len(S)//2:]
else:
    S_right = S[len(S)//2+1:]

count = 0

for s1, s2 in zip(S_left, reversed(S_right)):
    if not s2 == s1:
        count += 1
        
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
vector <int> a;
vector <int> all;
int n,m;


int main() {

  while(1) {
    scanf("%d%d",&n,&m);
    if(n == 0 && m ==0) break;
    a.resize(n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);

    a.push_back(0);
    all.clear();

    for(int i=0;i<a.size();i++) 
      for(int j=i;j<a.size();j++)
	all.push_back(a[i]+a[j]);

    sort(all.begin(),all.end());

    int ans = 0;
    int allsize = all.size();
    int b = 0;
    for(int i=allsize-1;i>= 0;i--) {
      for(int j=b;j<allsize;j++) {
	int sum = all[i] + all[j];
	if(sum > m) break;
	b++;
	if(ans < sum) ans = sum;
      }
      if(ans == m) break;
    }

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

Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
long long gcd(int a,int b)
{
	return b==0?a:gcd(b,a%b);
}
int main()
{
	long long a,b;
	cin >> a >> b;
	cout << (a*b)/gcd(a,b) << endl;
	return 0;
} 

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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

signed main() {
    int A,B;
    cin>>A>>B;
    cout<<A*B<<endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll min(ll a, ll b)
{
    if(a<b)
        return a;
    else
        return b;
}
int main()
{
    ll n,i,j;
    cin>>n;
    ll h[n],dp[n];
    for(i=0;i<n;i++)
    {
        cin>>h[i];
    }
    dp[0]=0;
    for(i=1;i<n;i++)
    {
         dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1920
// AOJ 1369: Distribution Center
// 2017.11.3 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int yp[100002];
int l[200002], r[200002];

char buf[20], *bp;
int getint()
{
	int n = 0;
	while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
	return n;
}

int main()
{
	int n, m, i, x, xmin, xmax;

	fgets(bp=buf, 20, stdin);
	n = getint(), bp++, m = getint();
	fgets(bp=buf, 20, stdin);
	x = getint(), bp++, yp[x] = getint();
	xmin = xmax = x;
	i = m-1; while (i--) {
		fgets(bp=buf, 20, stdin);
		x = getint(), bp++, yp[x] = getint();
		if (x < xmin) xmin = x;
		else if (x > xmax) xmax = x;
	}

	for (i = 1; i <= n; i++) l[i] = i;
	memcpy(r, l, sizeof(int)*(n+1));

	for (x = xmin; x <= xmax; x++) {
		if (yp[x]) i = yp[x], l[i+1] = l[i], r[i] = r[i+1];
	}
	printf("%d", r[1]-l[1]+1);
	for (i = 2; i <= n; i++) printf(" %d", r[i]-l[i]+1);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 3748
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        boolean ans = false;
        for (int i = 0; i < n.length(); i++) {
            if (n.charAt(i) == '7')
                ans = true;
        }
        if (ans)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}

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

using namespace std;

int main()
{
  int n;
  while(cin >> n, n != -1){
    vector<int> four;
    four.push_back(n % 4);
    n /= 4;
    while(n > 0){
      four.push_back(n % 4);
      n /= 4;
    }
    reverse(four.begin(), four.end());
    for(int i = 0; i < four.size(); i++) cout << four[i];
    cout << endl;
  }
  return 0;
}
 

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

int main(){
    int H,W;
    cin >> H >> W;
    string a[H];
    bool check_x[W] = {},check_y[H] = {};
    for(int i=0;i<H;i++){
        cin >> a[i];
    }    
    int cnt;
    for(int i=0;i<H;i++){
        cnt = 0;
        for(int j=0;j<W;j++){
            if(a[i][j] == '.'){
                cnt++;
            }
        }
        if(cnt == W){
            check_x[i] = true;
        }
    }
    for(int j=0;j<W;j++){
        cnt = 0;
        for(int i=0;i<H;i++){
            if(a[i][j] == '.'){
                cnt++;
            }
        }
        if(cnt == H){
            check_y[j] = true;
        }
    }

    for(int i=0;i<H;i++){
        if(check_x[i]){
            continue;
        }
        for(int j=0;j<W;j++){
            if(check_y[j]){
                continue;
            }
            cout << a[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int N;
    scanf("%d", &N);
    int a[N];

    int t = 0;
    for (int i = 0; i < N; i++)
    {
        scanf("%d", &a[i]);
        if (a[i] % 2 != 0){
            t = t;
        }
        else if ((a[i] % 2 == 0) && ((a[i] % 3 == 0) || (a[i] % 5 == 0)))
            {
                t = t;
        }
        else
        {
                t++;
            }

    }
    if (t == 0)
    {
        printf("APPROVED");
    }else{
    printf("DENIED");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>

int main()
{
  int n, d, x;
  int a[120];

  std::cin >> n;
  std::cin >> d >> x;
  for (int i = 0; i < n; ++i) {
    std::cin >> a[i];
  }
  int t = 0;

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < d; ++j) {
      if (a[i]*j + 1 <= d) {
        t++;
      } else {
        break;
      }
    }
  }

    std::cout << t+x << std::endl;
  return 0;
}


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

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner scn = new Scanner(System.in);
		int[]a=new int[scn.nextInt()];
		int k=scn.nextInt();
		for(int i=0;i<a.length;i++)a[i]=scn.nextInt();
		System.out.println(solve(a, k));
		
	}
	
	public static int solve(int[]a, int k) {
		int[]dp=new int[a.length];
		Arrays.fill(dp, Integer.MAX_VALUE);
		dp[0]=0;
		for(int i=1;i<a.length;i++) {
			for(int j=1;j<=k;j++) {
				dp[i]=Math.min(dp[i], i-j>=0?(dp[i-j]+Math.abs(a[i]-a[i-j])):Integer.MAX_VALUE);
			}
		}
		return dp[dp.length-1];
	}
	

}


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

int main(){
    int n, m;
    while(cin >>n >>m){
        if(n == 0 && m == 0) break;
        vector<int> field, dice;
        int now = 1;
        field.push_back(-1);
        dice.push_back(-1);
        for(int i = 0; i < n; i++){
            int tmp;
            cin >>tmp;
            field.push_back(tmp);
        }
        for(int i = 0; i < m; i++){
            int tmp;
            cin >>tmp;
            dice.push_back(tmp);
        }
        for(int i = 1; i <= m; i++){
            now += dice[i];
            now += field[now];
            if(now >= n){
                cout <<i <<endl;
                break;
            }
        }
    }
    return 0;
}

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

using namespace std;

long long maxi,n,W,i,gr,p[101],w[101],d[101][100010];

int main()
{
    cin>>n>>W;
    for(i=1;i<=n;i++)
    {
        cin>>w[i]>>p[i];
    }

    d[1][w[1]]=p[1];
    for(i=2;i<=n;i++)
    {
        for(gr=0;gr<=W;gr++)
        {
            d[i][gr]=d[i-1][gr];
            if(gr-w[i]>=0)d[i][gr]=max(d[i][gr],d[i-1][gr-w[i]]+p[i]);
        }
    }

    for(gr=0;gr<=W;gr++)
        maxi=max(maxi,d[n][gr]);

    cout<<maxi;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int ans = 0;
    int maxv = 0;
    for (int i = 0; i < n; i++)
    {
        int in;
        cin >> in;
        if(maxv<=in)
        {
            ans++;
            maxv = in;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
main :: IO ()
main = do
  sss <- getContents
  let s = map (map strToInt) $ map (splitBy ',') $ lines sss
      ans = foldl1 makeNex s
  putStrLn (show (head ans))
splitBy :: Char -> String -> [String]
splitBy c l = foldr f [[]] l
                where f x acc
                        | x == c = []:acc
                        | otherwise = (x : (head acc)) : (tail acc)

strToInt :: String -> Int
strToInt str = read str

makeNex :: [Int] -> [Int] -> [Int]
makeNex y x = if (length x) > (length y)
                then zipWith (+) x (makeNex2 (0:y)++[0])
                else zipWith (+) x (makeNex2 y)

makeNex2 (_:[]) = []
makeNex2 (y1:y2:ys) = (max y1 y2) : (makeNex2 (y2:ys))

Measured memory_bytes: 5368
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    queue<int> que;
    que.push(0);
    vector<bool> flg(n, false);
    flg[0] = true;

    vector<int> ans(n);
    while(!que.empty()) {
        int now_room = que.front();
        que.pop();
        for ( auto q: g[now_room] ) {
            if ( flg[q] ) continue;
            que.push(q);
            flg[q] = true;
            ans[q] = now_room + 1;
        }
    }

    cout << "Yes" << endl;

    for ( int i = 1; i < n; ++i ) {
        cout << ans[i] << endl;
    }
    
    return 0;
}


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

typedef long long ll;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18


int main() {
    int R; cin >> R;
    if(R<1200) cout << "ABC" << endl;
    else if(1200<=R && R<2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int sum = 0;
  for (int i = 0; i < s.size(); i++) sum += s.at(i) - '0';
  if (stoi(s) % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int N, S[1<<18];

  cin >> N;

  int M = 1 << N;

  multiset<int> ss;

  for(int i=0; i<M; i++) {
    cin >> S[i];
    ss.insert(S[i]);
  }

  sort(S, S+M, greater<int>());

  priority_queue<int> que;

  que.push(S[0]);

  for(int i=0; i<N; i++) {
    priority_queue<int> que2 = que;
    int l = 1 << i;
    int r = 1 << (i+1);

    for(int j=l; j<r; j++) {
      int t = que.top();
      que.pop();

      auto s = ss.lower_bound(t);
      if(s == ss.begin()) {
        puts("No");
        return 0;
      }

      s--;

      int s2 = *s;
      ss.erase(s);

      //debug(s2);

      if (s2 < t) {
        que2.push(s2);
      } else {
        puts("No");
        return 0;
      }
    }

    que = que2;
  }

  puts("Yes");

  return 0;
}


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

int main()
{
  int H, W;
  cin >> H >> W;
  vector<vector<char>> data(H, vector<char>(W));
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      cin >> data[i][j];
    }
  }
  for (int i = 0; i < H + 2; i++)
  {
    for (int j = 0; j < W + 2; j++)
    {
      if (i == 0 or i == H + 1 or j == 0 or j == W + 1)
      {
        if (j == W + 1)
          cout << "#" << endl;
        else
          cout << "#";
      }
      else
      {
        cout << data[i - 1][j - 1];
      }
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<int> arr1(n), arr2(n),arr(n);
	int cnt = 1;
	map<vector<int>, int> mp;
	for(int i=0; i<n; i++) cin>>arr1[i];
	for(int i=0; i<n; i++) cin>>arr2[i];
	for(int i=0; i<n; i++) arr[i] = i+1;
	do{
		mp[arr] = cnt++;
	}while(next_permutation(arr.begin(), arr.end()));
	cout<<abs(mp[ arr1 ] - mp[ arr2 ])<<endl;
}


Measured memory_bytes: 5248
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h> 
#include <set>

using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
using vi = vector<int>;
const int MOD = 1e9 + 7;

bool IsPrime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) return false; }
    return true;
}


int main() {
    ll N, M;
    cin >> N >> M;
    if (2 * N <= M) cout << N + (M - 2 * N) / 4 << endl;
    else cout << M / 2 << endl;
}

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

#define REP(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

// 最大公約数
int gcd(int a, int b) {
   if (a%b == 0) {
       return(b);
   } else {
       return(gcd(b, a%b));
   }
}

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

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

    ll ans = 0;
    REP(i, K) {
        REP(j, K) {
            ll tmp = 0;
            tmp = gcd(i, j);
            REP(m, K) {
                ans = ans + gcd(tmp, m);
            }
        }
    }

    cout << ans << endl;
}

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

immutable uint mod = 10^^9 + 7;
alias mint = ModInt!mod;

void main() {
    auto s = readln.chomp;
    auto t = readln.chomp;
    auto n = s.length.to!int;
    auto m = t.length.to!int;
    auto dp = new mint[][](n+1, m+1);
    dp[0][0] = mint(1);

    foreach (i; 0..n) {
        dp[i+1] = dp[i].dup;
        foreach (j; 0..m) {
            if (s[i] == t[j]) {
                dp[i+1][j+1] += dp[i][j];
            }
        }
    }

    dp[n][m].writeln;
}

struct ModInt(uint mod) {
    import std.conv : to;

    uint n;

    this(int n) {
        this.n = (n % mod + mod) % mod;
    }

    this(long n) {
        this.n = (n % mod + mod) % mod;
    }

    private this(uint n) {
        this.n = n;
    }

    string toString() {
        return to!string(this.n);
    }

    private uint normilize(uint n) {
        return n < mod ? n : n - mod;
    }

    ModInt pow(uint n, long x) {
        long ret = 1;
        long a = n;
        while (x) {
            if (x & 1) ret = ret * a % mod;
            a = a * a % mod;
            x >>= 1;
        }
        return ModInt(to!ulong(ret));
    }

    ModInt opBinary(string op)(ModInt rhs) {
        static if (op == "+") {
            return ModInt(normilize(n + rhs.n));
        } else if (op == "-") {
            return ModInt(normilize(n + mod - rhs.n));
        } else if (op == "*") {
            return ModInt(to!uint(to!long(n) * rhs.n % mod));
        } else if (op == "/") {
            return this * pow(rhs.n, mod-2);
        } else if (op == "^^") {
            return pow(this.n, rhs.n);
        }
    }

    ModInt opBinary(string op, T)(T rhs) {
        static if (op == "^^") {
            return pow(this.n, rhs);
        }
    }

    ModInt opOpAssign(string op)(ModInt rhs) {
        return mixin ("this=this"~op~"rhs");
    }
}



Measured memory_bytes: 10312
h, w = [int(i) for i in input().split()]
a = [["." for i in range(w)] for j in range(h)]
out = []
for i in range(h):
    a[i] = input()
    for j in range(w):
        if a[i][j] == "#":
            out.append(a[i])
            break

out2 = ["" for j in range(len(out))]
blankLine = ""
for i in range(len(out)):
    blankLine += "."
for j in range(w):
    strTmp = ""
    for i in range(len(out)):
        strTmp += out[i][j]
    if strTmp != blankLine:
        for i in range(len(out)):
            out2[i] += out[i][j]
for i in range(len(out2)):
    print(out2[i])

Measured memory_bytes: 3188
n=int(input())
a=[]
for i in range(n):
    x,y=input().split()
    a.append((i+1,x,int(y)))
a.sort(key=lambda x:x[2],reverse=True)
a.sort(key=lambda x:x[1])
for i in range(n):
    print(a[i][0])

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

int n,i,j,r;
int a[100010];

int main()
{
    scanf("%d",&n);
    for(auto &x:a)scanf("%d",&x);//cin>>x;
    sort(a,a+n);
    for(;i<n;i++)a[i]==a[j]?:(r+=i-j-((i-j)<a[j]?0:a[j]),j=i);
    cout<<r+i-j-((i-j)<a[j]?0:a[j]);
}

Measured memory_bytes: 640
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;



int main() {
 
  long long a[3],i,n;
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[0]+a[1]==a[2])
        cout<<"Yes";
    else
        cout<<"No";
}


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

int main() { 
    int n, ans = 1;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a, a+n);
    long long sum = 0, ans_m = 0;
    for(int i = 0; i < n-1; ++i) {
        sum += a[i];
        if(a[i+1] <= sum*2) {
            ans_m++;
        } else {
            ans_m = 0;
        }
    }

    cout << ans+ans_m << '\n';

    return 0;
}


Measured memory_bytes: 640