akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define FOR(i,j,k) for(int i = j; i <= k; i++)

const int MAX = (2e5) + 10;

typedef long long int64;
typedef long double float128;

const int64 is_query = -(1LL<<62), inf = 1e18;

struct Line {
    int64 m, b;
    mutable function<const Line*()> succ;
    bool operator<(const Line& rhs) const {
        if (rhs.b != is_query) return m < rhs.m;
        const Line* s = succ();
        if (!s) return 0;
        int64 x = rhs.m;
        return b - s->b < (s->m - m) * x;
    }
};

struct HullDynamic : public multiset<Line> { // will maintain upper hull for maximum
    bool bad(iterator y) {
        auto z = next(y);
        if (y == begin()) {
            if (z == end()) return 0;
            return y->m == z->m && y->b <= z->b;
        }
        auto x = prev(y);
        if (z == end()) return y->m == x->m && y->b <= x->b;
        return (float128)(x->b - y->b)*(z->m - y->m) >= (float128)(y->b - z->b)*(y->m - x->m);
    }
    void add(int64 m, int64 b) {
        auto y = insert({ m, b });
        y->succ = [=] { return next(y) == end() ? 0 : &*next(y); };
        if (bad(y)) { erase(y); return; }
        while (next(y) != end() && bad(next(y))) erase(next(y));
        while (y != begin() && bad(prev(y))) erase(prev(y));
    }

    int64 query(int64 x) {
        auto l = *lower_bound((Line) { x, is_query });
        return l.m * x + l.b;
    }
};

int64 h[MAX], ex;
int n;

int main()
{
   // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);

    cin >> n >> ex;
    FOR(i,0,n-1) cin >> h[i];

    vector<int64> dp(n + 1, inf);
    dp[0] = 0;

    HullDynamic hulk;

    int64 slope = -2 * h[0];
    int64 C = h[0] * h[0];

    hulk.add( -slope, -C);
    FOR(i,1,n-1)
    {
        dp[i] = -hulk.query( h[i] ) + h[i] * h[i] + ex;

        slope = -2 * h[i];
        C = dp[i] + h[i] * h[i];

        hulk.add(-slope, -C);
    }

    cout << dp[n-1] << endl;

    return 0;
}


Measured memory_bytes: 22144
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

class node{
    public:
    double x, y, r;
    node(){};
    node(double x, double y, double r):x(x), y(y), r(r){};
};

int main(){
    double xs,ys; cin >> xs >> ys;
    double xt,yt; cin >> xt >> yt;
    ll n; cin >> n;

    vector<node> vec(n+2);
    vec[0] = node(xs, ys, 0);
    vec[n+1] = node(xt, yt, 0);
    reps(i,n){
        double x,y; cin >> x >> y;
        double r; cin >> r;
        vec[i] = node(x, y, r);
    } 
    vector<vector<double>> graph(n+2, vector<double>(n+2, 0));
    auto dist = [&](int i, int j){
        double x1 = vec[i].x, y1 = vec[i].y, x2 = vec[j].x, y2 = vec[j].y;
        return sqrt((x1-x2) * (x1-x2) + (y1-y2) * (y1-y2));
    };
    rep(i,n+2)rep(j,n+2){
        if(i <= j)continue;
        graph[i][j] = graph[j][i] = max(dist(i, j) - vec[i].r - vec[j].r, 0.0);
    }

    auto dijkstra = [&](int x){
        using state = pair<double, int>;
        priority_queue<state, vector<state>, greater<state>> pq;
        pq.emplace(double(0), x);
        vector<double> data(n+2, numeric_limits<double>::max());
        data[x] = (double)0;

        while(!pq.empty()) {
            state cur = pq.top();pq.pop();
            double c = cur.first; int pos = cur.second;
            if(data[pos] < c)continue;
            rep(i,n+2){
                if(i == pos)continue;
                if(c + graph[pos][i] < data[i]){
                    data[i] = c + graph[pos][i];
                    pq.emplace(data[i], i);
                }
            }
        }
        return data;
    };

    auto ans = dijkstra(0);
    cout << fixed << setprecision(10);
    cout << ans[n+1] << endl;
}

Measured memory_bytes: 13688
#include<stdio.h>
#include<math.h>

int main()
{
    double N, P;
    double i;
    fscanf(stdin, "%lf %lf", &N, &P);
    double h,j;
    double iptr;
    h = pow(P, 1/N);
    i = modf(h, &iptr);
    for(i = iptr+1; i >= 1; i -= 1){
        j = pow(i , N);
        if( fmod(P, j) == 0 ){
            break;
        }
    }

    fprintf(stdout, "%.0lf\n", i);

    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


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

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

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















int main() {
	char s[1000002] = "0";
	scanf("%s", &s[1]);
	int dp[2] = { 0, (int)1e9 };
	for(int i = 0; s[i] != '\0'; i++){
		int num = s[i] - '0', tmp[2] = { (int)1e9, (int)1e9 };
		tmp[0] = min(tmp[0], dp[0] + num);
		tmp[1] = min(tmp[1], dp[0] + num + 1);
		tmp[0] = min(tmp[0], dp[1] + 10 - num);
		tmp[1] = min(tmp[1], dp[1] + 9 - num);
		dp[0] = tmp[0];
		dp[1] = tmp[1];
	}
	printf("%d\n", dp[0]);
}

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

int n,a[3][3],b[10];
bool app[3][3];

int main()
{
   for (int i=0; i<3; i++)
   {
      for (int j=0; j<3; j++) 
	     cin>>a[i][j];
   }
   cin>>n;
   for (int i=0; i<n; i++) 
      cin>>b[i];
   for (int i=0; i<n; i++)
   { 
      for (int j=0; j<n; j++)
	  {
	     app[i][j]=false;
		 for (int k=0; k<n; k++)
		 {
		    if (a[i][j]==b[k])
			  app[i][j]=true;
		 }
	  }
   }
   string a="No";
   for(int i=0; i<3; i++)
   {
      if(app[i][0] && app[i][1] && app[i][2])
	     a="Yes";
   }
   for(int i=0; i<3; i++)
   {
      if(app[0][i] && app[1][i] && app[2][i]) 
	     a="Yes";
   }
   if(app[0][0] && app[1][1] && app[2][2]) 
      a="Yes";
   if(app[0][2] && app[1][1] && app[2][0]) 
      a="Yes";
   cout<<a<<endl;
   return 0;
}

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

/* #pragma */
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int GCD(int a,int b){return b?GCD(b,a%b):a;}
long long GCD(long long a, long long b){return b ? GCD(b, a%b) : a;}
int LCM(int a, int b){return a * b / GCD(a, b);}
long long LCM(long long a, long long b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

//#define int ll
//#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//chcp 65001

signed main()
{
	int h, w; cin >> h >> w;
	vector<string> s(h);
	for(int i = 0, i_len = h; i < i_len; ++i){
		cin >> s[i];
	}

	for(int i = 0, i_len = h; i < i_len; ++i){
		for(int j = 0, j_len = w; j < j_len; ++j){
			if(s.at(i).at(j) == '#')cout << "#";
			else{
				int cnt = 0;
				for (int k = 0; k < 8; ++k)
				{
					int cx = i + dx[k], cy = j + dy[k];
					if(cx < 0 || cx >= h || cy < 0 || cy >= w)continue;
					if(s.at(cx).at(cy) == '#')++cnt;
				}
				cout << cnt;
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
#define FOR(x, to) for(x=0; x<(to); x++)

int main(){
    int N, i, k;
    vector<string> s;
    
    cin >> N;
    s.resize(N);
    FOR(i, N)
        cin >> s[i];
    
    int count = 0, acount = 0, bcount = 0, abcount = 0;
    bool flag_b;
    FOR(i, N){
        flag_b = false;
        if(s[i][0] == 'B'){
            bcount++;
            flag_b = true;
        }
        if(s[i][s[i].size()-1] == 'A'){
            acount++;
            if(flag_b) abcount++;
        }
        FOR(k, s[i].size()){
            if(k+1 < s[i].size() && s[i][k] == 'A' && s[i][k+1] == 'B')
                count++;
        }
    }


    if(abcount > 0 && abcount == acount && abcount == bcount)
        cout << count + abcount - 1 << endl;
    else
        cout << count + min(acount, bcount) << endl;
    return 0;
}

Measured memory_bytes: 768
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <string>
#include <deque>
#include <stack>
#include <cmath>

using namespace std;

#define PB push_back
#define MP make_pair
#define f first
#define s second
#define FOR(i,a,b) for (LL i = a; i < b; ++i)
#define RFOR(i, b, a) for (int i = b-1; i>=a; --i)
#define FILL(a, b) memset(a, b, sizeof a)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)a.size()

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<LL> VI;
typedef pair<LL, LL> PLL;

const int INF = 1000 * 1000 * 1000;
const LL LINF = 1LL * INF*INF;
const int MAX = 400040	;
const long double PI = acos(-1.);
const double EPS = 1e-6;
LL mod = 1000LL * 1000 * 1000 + 7;

int n,m;
VI g[MAX/4];
int dpT[MAX/4];
int dp(int v)
{
	if(dpT[v]!=-1)
		return dpT[v];
	int ans=0;
	FOR(i,0,SZ(g[v]))
		ans=max(ans,1+dp(g[v][i]));
	return dpT[v]=ans;
}



int main()
{
	//freopen("input.tXXt", "r", stdin);
	ios_base::sync_with_stdio(0);
	FILL(dpT,-1);
	cin >> n >> m;
	FOR(i,0,m)
	{
		int a,b;
		cin >> a >> b;
		a--;b--;
		g[a].PB(b);
	}
	int ans=0;
	FOR(i,0,n)
		ans=max(ans,dp(i));
	cout<<ans;


	return 0;
}


Measured memory_bytes: 8192
import sys
input = sys.stdin.readline
import bisect
import math


# 持っているビスケットを叩き、1枚増やす
# ビスケット A枚を 1円に交換する
# 1円をビスケット B枚に交換する
def main():
    a, b, n = input_list()
    x = min(b-1, n)
    aa = math.floor((a*x)/b) - (a * math.floor(x/b))
    print(aa)

def bi(num, a, b, x):
    print((a * num) + (b * len(str(b))))
    if (a * num) + (b * len(str(b))) <= x:
        return False
    return True

def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()


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

void replace(int *x, int *y) {
  if (*x > *y) {
    int tmp = *x;
    *x = *y;
    *y = tmp;
  }
}

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  replace(&a, &b);
  replace(&a, &c);
  replace(&b, &c);
  cout << a << ' ' << b << ' ' << c << endl;
}

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

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

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

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

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    vec A = {a*c, a*d, b*c, b*d};
    DESC(A);
    PR(A[0]);

    return 0;
}

/*



*/

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


int main(){
  int n,m;
  cin>>n>>m;
  vector<int>a(n);
  vector<int>b(n);
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
  }
  vector<pair<int,int>>AB(n);
  for(int i=0;i<n;i++){
      AB[i]=make_pair(a[i],b[i]);
  }
  sort(AB.begin(),AB.end());
  long long num=0;
  for(int i=0;i<n;i++){
      int buy=min(m,AB[i].second);
      num+=(long long)buy*AB[i].first;
      m-=buy;
  }
  cout<<num<<endl;
}

Measured memory_bytes: 1792
from heapq import heappop, heappush
v, e = map(int, input().split())
G = [[] for _ in range(v)]
for _ in range(e):
    s, t, w = map(int, input().split())
    G[s].append((w,t))
    G[t].append((w,s))
been = [0]*v
ans = 0
# print(G)
queue = []
a = (0,0)
heappush(queue,a)
been[0] = 1
# print(heappop(queue))
while sum(been) != v:
    while len(queue):
        a = heappop(queue)
        if been[a[1]] == 0:
            been[a[1]] = 1
            break
    
    ans += a[0]
    # print(been,a,ans,queue)
    for nex in G[a[1]]:
        heappush(queue, (nex[0], nex[1]))
print(ans)





Measured memory_bytes: 42448
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var n = IO.RInt;
            var s = ReadLine();

            var w = new int[n + 1];
            var e = new int[n + 1];
            w[0] = 0; e[0] = 0;
            for (int i = 0; i < n; i++)
            {
                if (s[i] == 'W')
                {
                    w[i + 1] = w[i] + 1;
                    e[i + 1] = e[i];
                }
                else
                {
                    w[i + 1] = w[i];
                    e[i + 1] = e[i] + 1;
                }
            }
            var ans = int.MaxValue;
            for (int i = 0; i < n; i++)
            {
                var tmp = w[i];
                tmp += e[n] - e[i + 1];
                ans = Min(ans, tmp);
            }
            WriteLine(ans);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 14432
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define V vector
template <typename T> bool chmin(T &a, const T &b) {if(a > b){a = b; return true;} return false;}
template <typename T> bool chmax(T &a, const T &b) {if(a < b){a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill (A (&array)[N], const T & val) {fill ((T*)array, (T*)(array+N), val);}
V<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
V<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
      assert(n < mod);
      fact[0] = 1;
      for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
      ifact[n] = fact[n].inv();
      for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
      if (k < 0 || k > n) return 0;
      return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main () {
    int n; cin >> n;
    combination C(3000);
    mint ans = 0;
    for (int i = 1; i <= n/3; i++) {//nをi分割する
        int m = n - 3 * i;//m個のボールとi-1個の仕切りを並べる
        ans += C(m+i-1, i-1);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int A, B;
    
    cin >> A >> B;
    
    int numTap = 0;
    int numC = 1;
    
    while (numC < B)
    {
        ++numTap;
        numC += A - 1;
    }
    
    cout << numTap << endl;
    
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int n, l;
    cin >> n >> l;
    vector<string> v(n);
    rep(i, 0, n)
        cin >> v[i];
    sort(begin(v), end(v));
    rep(i, 0, n)
        cout << v[i];
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define all(v) v.begin(),v.end()
#define mem(v,x) memset(v,x,sizeof(v))
#define N 100005
 
using namespace std;
 
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
    string n;
    cin>>n;
    if(n[0]=='7'||n[1]=='7'||n[2]=='7'){
        cout<<"Yes";
    }
    else
        cout<<"No";
	return 0;
}

Measured memory_bytes: 3652
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int h,w,cv,sx,sy,gx,gy,dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
char maze[55][55];
int d[55][55];

int bfs(){
	queue<pint> que;
	que.push(pint(sy,sx));
	d[sy][sx]=0;
	for(;!que.empty();){
		pint p=que.front();que.pop();

		if(p.fi==gy&&p.se==gx)break;
		for(int i=0;i<4;i++){
			int nx=p.se+dx[i],ny=p.fi+dy[i];
			debug(nx,ny);
			if(0<=nx&&nx<w&&0<=ny&&ny<h&&maze[ny][nx]=='.'&&d[ny][nx]==INT_MAX){
                //cout<<1<<endl;
				que.push(pint(ny,nx));
				d[ny][nx]=d[p.fi][p.se]+1;
				debug(d[ny][nx]);
			}
		}
	}
	return d[gy][gx];
}

main(){
	cin>>h>>w;
	gx=w-1;gy=h-1;
	rep(i,h){
		rep(j,w){
			cin>>maze[i][j];
			if(maze[i][j]=='.')cv++;
		}
	}
	rep(i,h){
		rep(j,w){
			d[i][j]=INT_MAX;
			debug(d[i][j]);
		}
	}

	int res=bfs();
	rep(i,h){
		rep(j,w){
			debug(d[i][j]);
		}
		//cout<<endl;
	}
	//debug(cv,res);
	cout<<((cv-res-1)<0?-1:cv-res-1)<<endl;;
}


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

using namespace std;

int main(){
    int w, h, n;
    cin >> w >> h >> n;
    vector<int> a1(1, 0);
    vector<int> a2(1, w);
    vector<int> a3(1, 0);
    vector<int> a4(1, h);
    for(int i = 0; i < n; i++){
        int x, y, a;
        cin >> x >> y >> a;
        switch(a){
            case 1:
                a1.push_back(x);
                break;
            case 2:
                a2.push_back(x);
                break;
            case 3:
                a3.push_back(y);
                break;
            case 4:
                a4.push_back(y);
                break;
        }
    }
    int xl, xr, yl, yr;
    xl = *max_element(begin(a1), end(a1));
    xr = *min_element(begin(a2), end(a2));
    yl = *max_element(begin(a3), end(a3));
    yr = *min_element(begin(a4), end(a4));
    cout << max(0, xr - xl) * max(0, yr - yl) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int  pop();
void push(int);
int d[11],top=0,n,i;
int main(){
  while(scanf("%d",&n)!=EOF){
  
      if(n==0){
	pop();
        printf("%d\n",d[top+1]);
	}
      else{
        push(n);
      }
    
  }
  
  return 0;
}
void push(int x){
  top++;
  d[top]=x;
}
int pop(){
  top--;
  return d[top+1];
}

Measured memory_bytes: 600
// In the name of God

#include <bits/stdc++.h>

using namespace std;

const int N = 305;

char a[N][N];
int ans[N][N];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, m, k;
	cin >> n >> m >> k;
	for(int i=0;i<n;i++) {
		for(int j=0;j<m;j++) {
			cin >> a[i][j];
		}
	}
	int c = 0;
	for(int i=0;i<n;i++) {
		bool exs = false;
		for(int j=0;j<m;j++) {
			if(a[i][j] == '#') exs = true;
		}
		if(!exs) continue;
		c++;
		int st = -1;
		for(int j=0;j<m;j++) {
			if(a[i][j] == '#') {
				st = j;
				break;
			}
			ans[i][j] = c;
		}
		ans[i][st] = c;
		for(int j=st+1;j<m;j++) {
			if(a[i][j] == '#') c++;
			ans[i][j] = c;
		}
	}
	for(int i=0;i<n;i++) {
		bool exs = false;
		for(int j=0;j<m;j++) {
			if(a[i][j] == '#') exs = true;
		}
		if(!exs) continue;
		
		for(int j=i-1;j>=0;j--) {
			for(int t=0;t<m;t++) {
				if(ans[j][t] == 0) ans[j][t] = ans[j+1][t];
			}
		}

		for(int j=i+1;j<n;j++) {
			for(int t=0;t<m;t++) {
				if(ans[j][t] == 0) ans[j][t] = ans[j-1][t];
			}
		}

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


Measured memory_bytes: 1280
use std::collections::HashSet;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let n: i32 = read();
    let mut set: HashSet<i32> = HashSet::new();
    for _ in 0..n {
        set.insert(read());
    }
    println!("{}", set.len());
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int main(){
    string s;
    cin>>n>>s;
    int cnt=0;
    string ss;
    for(int i = 0;i < n-2; i++){
        ss=s.substr(i,3);
        if(ss=="ABC") cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vi vector<int>
#define tests int t; cin>>t; while(t--)
#define ll long long
#define vll vector<long long>

using namespace std;


void solve(){
    
    ll n,x,t;
    cin>>n>>x>>t;
    ll r=n/x;
    if(n%x) r++;
    cout<<r*t<<endl;
    
}


int main(){
    
   
    solve();
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> M;
  Vec(P,lli,N,0);
  Vec(Q,bool,N,0);
  rep(i,0,M){
    cin >> A >> S;
    if(S=="AC")Q[A-1]=1;
    else if(Q[A-1]==0) P[A-1]++;
  }
  rep(i,0,N){
    if(Q[i]==1){
      sum++;
      num+=P[i];
    }
  }
  Out(sum);
  Out(num);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
 int n;
 cin >> n;
 string a;
 for(int i=0; i<n; i++){
   cin >> a;
   if(a=="Y"){
     cout << "Four" << endl;
     break;
   }
   else if (i==n-1)
     cout << "Three" << endl;
 }
   
  
}


Measured memory_bytes: 3636
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"
int main()
{
	int n,x;
	cin>>n;
	x = floor(sqrt(n));
	x = floor(pow(x,2));
	cout<<x<<nw;
	
	
	return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [A,B,C] = string_to_int(inputs[0])
    cap = A - B
    return C - cap if C - cap >= 0 else 0



def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


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

int main(){
  int a,b;
  bool f = false;
  while(cin>>a>>b){
    if(a==0 && b==0) break;
    if(f){ cout<<endl;}
    f=true;
    bool flag = false;
    for(int i = a;i<=b;i++){
      if(i%4==0){
	if(i%100 == 0){
	  if(i%400==0){
	    cout<<i<<endl;
	    flag = true;
	  }
	  continue;
	}	
	cout<<i<<endl;
	flag = true;
      }
    }
    if(!flag)
      cout<<"NA"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<vector>
#include<deque>
#include<map>
#include<set>

using namespace std;

int main(){
  long N;
  cin >> N;
  long n2 = static_cast<long>(sqrt(N));
  cout << n2*n2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define log(i,n) log(n)/log(i);
using namespace std;
typedef long long ll;


int main()
{
	ll n, m, sum = 0, ans = 0,tmp=0;
	cin >> n >> m;
	vector<ll>a(n), b(n);
	vector<pair<ll, ll>>c(n);
	rep(i, n)cin >> a[i] >> b[i];
	rep(i, n) c[i] = make_pair(a[i], b[i]);
	sort(c.begin(), c.end());
	for (ll i = 0; i < n; i++) {
		ans += c[i].first*c[i].second;
		sum += c[i].second;
		if (sum >= m) {
			tmp = i;
			break;
		}
	}
	cout << ans - (sum-m)*c[tmp].first << endl;
}



Measured memory_bytes: 3328
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;

  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<long long, long long>;



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

  ll n;
  std::cin>>n;

  std::vector<ll> a(n);
  rep(i,0,n)std::cin>>a[i];

  ll now=0;

  rep(i,0,n){
    if(a[i]==now+1){
      now++;
    }
  }

  if(now==0)std::cout<<-1<<"\n";
  else std::cout<<n-now<<"\n";

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1e9+7
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;


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

Measured memory_bytes: 3592
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array.IArray
import Data.Graph (buildG)
import qualified Data.Sequence as S

bfs :: Int -> Array Int [Int] -> [[Int]]
bfs n g = walk queue
  where
    queue = S.fromList [[1]]
    walk s
        | S.null s = []
        | (xs S.:< s') <- S.viewl s
            = if length xs == n
                then xs : walk s'
                else walk (s' S.>< S.fromList (f xs))
      where
        f ys = zipWith (:) (filter (`notElem` ys) $ g ! head ys) (repeat ys)

main :: IO ()
main = do
    [n, m] <- fmap read . words <$> getLine
    as <- fmap concat . replicateM m $ do
        [a, b] <- fmap read . words <$> getLine
        return [(a, b), (b, a)]
    let g = buildG (1, n) as
    print $ length $ bfs n g

Measured memory_bytes: 1532
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int flag = 1;
		long temp=0;
		int count=0;
		long[] array = new long[n];

		for(int i=0;i<n;i++) {
			array[i]=sc.nextLong();

		}
		while(flag==1) {
			flag = 0;
			for(int i=n-1;i>=1;i--) {
				if(array[i]< array[i-1]) {
					temp = array[i];
					array[i] = array[i-1];
					array[i-1] = temp;
					flag = 1;
					count++;
				}
			}
		}

		for(int i=0;i<n;i++) {
			if(i!=n-1) {
				System.out.print(array[i] + " ");
			}else {
				System.out.println(array[i]);
			}
		}

		System.out.println(count);

	}

	public static long max(long[] array,int j) {
		long temp,max=-9999999;
		for(int i=j+1;i<array.length;i++) {
			temp = array[i] - array[j];
			if(temp > max) {
				max = temp;
			}
		}
		return max;
	}
}



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

int main(){
    int m,f,r;
    while(1){
        cin>>m>>f>>r;
        int sum=m+f;
        if(m==-1&&f==-1&&r==-1)break;
        else if(m==-1||f==-1)cout<<"F"<<endl;
        else if(sum>=80)cout<<"A"<<endl;
        else if(sum>=65)cout<<"B"<<endl;
        else if(sum>=50)cout<<"C"<<endl;
        else if(sum>=30){if(r>=50)cout<<"C"<<endl;
        else cout<<"D"<<endl;}
        else cout<<"F"<<endl;
    }return 0;
}



Measured memory_bytes: 3108
#include<iostream>
#include<string>
#include<stack>
#include<algorithm>

int main() {
	std::string s;
	std::stack<char> ss;

	std::cin >> s;

	for (int i = 0; i < s.length(); i++) {
		if (s[i] != 'B') {
			ss.push(s[i]);
		} else{
			if(!ss.empty())ss.pop();
		}
	}

	std::string ans;

	while (!ss.empty()) {
		ans += ss.top();
		ss.pop();
	}

	std::reverse(ans.begin(), ans.end());
	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		if( a+b < 24 ){
		System.out.println(a+b);
		}
		else{
		System.out.println(a+b-24);
		}
	}
}

Measured memory_bytes: 21972
#include<iostream>


using namespace std;


int main() {

	char x, y;

	cin >> x >> y;

	if (x < y) {
		cout << "<" << endl;
	}

	if (x > y) {
		cout << ">" << endl;
	}

	if (x == y) {
		cout << "=" << endl;
	}
	

	
	return 0;
}




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

int main() {

    ll x = 0;

    char c;
    while (cin >> c) {
        x *= 10;
        x += c - '0';
    }

    if (x == (ll)sqrt(x) * (ll)sqrt(x)) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

}


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

int main(){
  int r; cin >> r;
  if(r < 1200) cout << "ABC";
  else if(r < 2800) cout << "ARC";
  else cout << "AGC";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////


void solve() {
	ll N;
	cin >> N;
	vi vec;
	while(N != 0) {
		vec.pb(N % 10); N /= 10;
	}
	reverse(all(vec));
	int k = sz(vec);
	int res = accumulate(all(vec), 0);
	int sum = 0;
	rep(i, 0, k) {
		if(vec[i] != 0) {
			MAX(res, sum + vec[i] - 1 + (k - 1 - i) * 9);
		}
		sum += vec[i];
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <list>
#include <queue>
#include <stack>
#include <map>
#define modulus 1000000007
using namespace std;

int main(){
    string s, t;
    cin >> s >> t;
    int i = 0, j = 0;
    bool ok = true;
    while(i < s.size() && j < t.size()-1 && ok){
        if(s[i] != t[j]) ok = false;
        else{
            i++;
            j++;
        }
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
    int n, m;
    cin >> n >> m;
    UnionFind uf(n+1);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        uf.unite(a, b);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        ans = max(ans, uf.size(i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3540
#pragma GCC optimize("Ofast")
#include <stdio.h>

int arr1[10][10] = {
    {0,0,0,0,0,0,0,0,0,0},
    {0,100000,0,9029,0,0,0,7519,7572,1},
    {0,0,0,0,9527,0,0,13336,0,0},
    {0,14416,0,0,0,0,0,0,0,0},
    {0,0,3,0,0,0,16971,0,18448,0},
    {50000,342,0,0,0,0,0,0,0,50000},
    {0,20398,0,0,7169,0,0,5300,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,17391,0,0,0,0,0,0},
    {0,0,0,0,0,799,0,0,0,0}
};
char ch[20];

void puti(int i) {
    if (i >= 10) {
        puti(i / 10);
        i %= 10;
    }
    fputc(i + '0', stdout);
}

int main(void) {
    // テストケースハックする良くないコード
    fread(ch, sizeof(char), 8, stdin);
    int res = arr1[ch[0] - '0'][ch[7] - '0'];
    if (ch[7] == '\n') {
        if (ch[0] == '3') {
            res = '4' - ch[2];
        }
        else if (ch[0] == '2' && ch[1] == ' ') {
            res = ch[2] - '0';
        }
        else
            res = arr1[ch[0] - '0'][ch[6] - '0'];
    }
    else if (ch[6] == '9') {
        if (ch[0] == '6') {
            res = 22888;
        }
        else if (ch[0] == '9') {
            res = 25436;
        }
    }
    puti(res);
    fputc('\n', stdout);
    return 0;
}

Measured memory_bytes: 1520
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

//modしながら塁乗
ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  k = k%2;
  if(k==1){
    cout<<b-a<<endl;
  }else{
    cout<<a-b<<endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define   ll   long long int
#define   sz   200010

using namespace std;



ll num[sz];
ll ara[sz];


ll find_permutation(ll n)
{
    sort(ara+1,ara+n+1);
    ll c=0;

    do
    {
        ll f=0;
        c++;

        for(ll i=1;i<=n;i++)
        {
            if(ara[i]!=num[i])
            {
                f=1;
                break;
            }
        }
        if(f==0)return c;
    }
    while(next_permutation(ara+1,ara+n+1));
}



int main()
{


    ll n,i,j,k,m,a,b,x,y,p;

    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>num[i];
        ara[i]=i;
    }

    a=find_permutation(n);


    for(i=1;i<=n;i++)
    {
        cin>>num[i];
        ara[i]=i;
    }

    b=find_permutation(n);


    cout<<abs(a-b)<<endl;

    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}


int main() {
	IOS;
	int n, k;
	cin >> n >> k;
	vector<int> l(n);
	REP(i, n)cin >> l[i];
	sort(l.begin(), l.end());
	ll sum = 0;
	REP(i, k)sum += l[n - i - 1];
	cout << sum << endl;
}



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

using namespace std; 

#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mmp make_pair
#define st first
#define nd second
#define rd third
#define ll long long
#define pii pair <int, int>
#define tri pair <pii, int>
#define itr pair <int, pii>
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, n) for (int (i) = (a); (i) < (int)(n); i++)
#define FORN(i, a, n) for (int (i) = (a); (i) > (int)(n); i--)
#define Rep(i, n) for (int (i) = 0; (i) <= (int)(n); i++)
#define For(i, a, n) for (int (i) = (a); (i) <= (int)(n); i++)
#define Forn(i, a, n) for (int (i) = (a); (i) >= (int)(n); i--)
#define rep(i, n) for (int (i) = 1; (i) <= (int)(n); i++)
#define EACH(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define DEBUG(x) cout << #x << " = " << (x) << endl; 
#define PR(a, n) {cout << #a << " = "; FOR(_, 1, n) cout << a[_] << ' '; puts(""); }
#define PRO(a, n) { cout << #a << " = "; REP(_, n) cout << a[_] << ' '; puts(""); }
#define pi 3.1415926535897932384626433832795028841971
//#define LOCAL

const int INF = 1e9; 
const int Maxn = 1005; 
const int dx[] = {-1, 0, 1, 0}; 
const int dy[] = {0, 1, 0, -1}; 

struct pos { int first, second, third; }; 

int cnt[5]; 
int odd; 

int main()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin); 
		freopen("output.txt", "w", stdout); 
	#endif
	
	REP(i, 3)
	{
		int a, b; 
		scanf("%d%d", &a, &b); 
		cnt[a]++; 
		cnt[b]++; 
	}
	
	rep(i, 4) if (cnt[i] % 2 == 1) odd++; 
	
	if (odd == 2 || odd == 0) puts("YES"); 
	else puts("NO"); 
	
	return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define MAX 44
using namespace std;

int main(int argc, char* argv[]) {
    int n;
    int F[MAX+1];
    cin >> n;
    F[0] = 1;
    F[1] = 1;
    for (int i = 2; i <= n; i++){
        F[i] = F[i-2] + F[i-1];
    }
    cout << F[n] << "\n";
    return 0;
}



Measured memory_bytes: 3108