akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push


#define MOD 1000000009LL
#define EPS 1e-8

int main()
{
	int N;
	cin >> N;
	int ans = 0;
	for( int n = 1; n <= N; ++n )
	{
		int num = 0;
		for( int i = 1; i <= n; ++i )
		{
			if( n % i == 0 && i % 2 == 1 )
			{
				++num;
			}
		}

		if( num == 8 )
		{
			++ans;
		}
	}
	cout << ans << endl;

	return 0;
}


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

int main(){
  string S; cin >> S;
  int countA, countB, countC;
  countA = 0;
  countB = 0;
  countC = 0;

  for(int i = 0; i < 3; i++){
    if(S[i] == 'a'){
      countA++;
    }
    else if(S[i] == 'b'){
      countB++;
    }
    else if(S[i] == 'c'){
      countC++;
    }
  }

  if(countA == 1 && countB == 1 && countC == 1){
    cout << "Yes";
  }
  else{
    cout << "No";
  }

	return 0;
}

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

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

using namespace std;

int n, m, r;
long long sd[200][200];
long long ld[200][200];
int z[1000];
long long dp[200][1000];

int main(){
	while(1){
		scanf("%d%d", &n, &m);
		if(n == 0 && m == 0){
			break;
		}

		rep(i, n){
			fill(sd[i], sd[i] + n, 2e10);
			fill(ld[i], ld[i] + n, 2e10);
			sd[i][i] = 0;
			ld[i][i] = 0;
		}

		rep(i, m){
			int x, y, t;
			char c;
			scanf("%d%d%d %c", &x, &y, &t, &c);
			--x;
			--y;
			if(c == 'S'){
				sd[x][y] = sd[y][x] = t;
			}
			else{
				ld[x][y] = ld[y][x] = t;
			}
		}

		rep(k, n){
			rep(i, n){
				rep(j, n){
					sd[i][j] = min(sd[i][j], sd[i][k] + sd[k][j]);
					ld[i][j] = min(ld[i][j], ld[i][k] + ld[k][j]);
				}
			}
		}

		scanf("%d", &r);
		rep(i, r){
			scanf("%d", z + i);
			--z[i];
		}

		rep(j, r){
			rep(i, n){
				if(j == 0){
					dp[i][j] = (i == z[j] ? 0 : 2e10);
				}
				else{
					dp[i][j] = dp[i][j - 1] + ld[z[j - 1]][z[j]];
					rep(k, n){
						dp[i][j] = min(dp[i][j], dp[k][j - 1] + ld[z[j-1]][k] + sd[k][i] + ld[i][z[j]]);
					}
				}
			}
		}

		long long result = 2e10;
		rep(i, n){
			result = min(result, dp[i][r - 1]);
		}

		printf("%lld\n", result);
	}
	return 0;
}

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

int main()
{
	int n;
    cin>>n;
    long a[n];
    for(int i = 0; i < n; ++i)
        cin>>a[i];
    long cost[n] = {0};
    cost[0] = 0;
    cost[1] = abs(a[1] - a[0]);
    for(int i = 2; i < n; ++i)
        cost[i] = min(cost[i - 1] + abs(a[i] - a[i-1]), cost[i - 2] + abs(a[i] - a[i-2]));
    cout<<cost[n-1];
    return 0;
}

Measured memory_bytes: 1792
// Try AtCoder
// author: Leonardone @ NEETSDKASU
package main

import "fmt"

func abs(x int) int {
    if x < 0 { return -x }
    return x
}

const MOD = 1e9 + 7

func main() {
    var n, m int
    fmt.Scan(&n, &m)
    switch abs(n - m) {
    case 0:
        tmp := 1
        for i := 1; i <= n; i++ {
            tmp = (tmp * i) % MOD
        }
        for i := 1; i <= m; i++ {
            tmp = (tmp * i) % MOD
        }
        tmp = (2 * tmp) % MOD
        fmt.Println(tmp)
    case 1:
        tmp := 1
        for i := 1; i <= n; i++ {
            tmp = (tmp * i) % MOD
        }
        for i := 1; i <= m; i++ {
            tmp = (tmp * i) % MOD
        }
        fmt.Println(tmp)
    default:
        fmt.Println(0)
    }
    
}

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

int main(){
  ll n, k;  cin >> n >> k;
  vector<ll> h(n);
  rep(i,n) cin >> h[i];
  sort(h.begin(), h.end());
  if(n<k)
    rep(i,n) h[n-1-i] = 0;
  else
    rep(i,k) h[n-1-i] = 0;
  ll ans = 0;
  rep(i,n) ans+=h[i];
  cout << ans << endl; 
  return 0;
}

Measured memory_bytes: 1792
def isOK(index, key, in_ls):
    if key<in_ls[index]: return True
    else: return False

def bs(in_ls, key):
    ng = -1
    ok = len(in_ls)
    while 1<abs(ok - ng):
        mid = (ng + ok)//2
        if isOK(mid, key, in_ls): ok = mid
        else: ng = mid
    return ok

def main():
    n = int(input())
    a_list = list(map(int, input().split(" ")))
    b_list = list(map(int, input().split(" ")))
    c_list = list(map(int, input().split(" ")))
    #a < b < c

    a_sorted = list(sorted(a_list))
    b_sorted = list(sorted(b_list))
    c_sorted = list(sorted(c_list))

    bc_dict = {}
    score = 0
    score_list = [0 for i in range(n)]
    for i, b in enumerate(b_sorted[::-1]):
        ok = bs(c_sorted, b)
        score+=n - ok
        score_list[n-i-1]+=score

    total = 0
    for a in a_sorted:
        ok = bs(b_sorted, a)
        if ok==n:
            continue
        total+=score_list[ok]

    print(total)

if __name__=="__main__":
    main()


Measured memory_bytes: 29512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
    int a, b, c, k;
    scanf("%d%d%d%d", &a, &b, &c, &k);
    int max_n = max({a, b, c});
    int max_nk = max_n;
    rep(i, k) max_nk *= 2;
    printf("%d\n", a + b + c - max_n + max_nk);
    return 0;
}

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

t = 0
task = []
for i in range(n):
    a,b = map(int,input().split())
    task.append([b,a])

task.sort()
ans = "Yes"
for i in range(n):
    t += task[i][1]
    if task[i][0] < t:
        ans = "No"
        break

print(ans)

Measured memory_bytes: 38124
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

class CombinationPascal {
   public:
    CombinationPascal(int n) {
        N = n;
        dp.assign(n + 1, vector<ll>(n + 1));

        dp[0][0] = 1;
        REP(i, 1, n + 1) {
            REP(j, 0, i + 1) {
                if (j - 1 >= 0)
                    dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
                else
                    dp[i][j] = dp[i - 1][j];
            }
        }
    }

    ll cnr(int n, int k) {
        return dp[n][k];
    }

   private:
    int N;
    vector<vector<ll>> dp;
};

int main() {
    int N, P; cin >> N >> P;
    vector<int> A(N);
    int odd = 0, even = 0;
    REP(i, 0, N) {
        cin >> A[i];
        if (A[i] % 2 == 0) even++;
        else odd++;
    }

    CombinationPascal comb(odd);
    ll ans = 0;
    for(int i = P; i <= odd; i += 2) {
        ans += pow(2, even) * comb.cnr(odd, i);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    string line;
    string[] words;
    int[][string] map;
    while (true) {
        line = readln;
        if (line.empty) break;
        line = line.chomp;
        string[] _ = line.split(" ").array;
        string word = _[0];
        int page = _[1].to!int;
        words ~= word;
        map[word] ~= page;
    }
    words = words.sort.uniq.array;
    foreach (word; words) {
        writeln(word);
        writefln("%(%s %)", map[word].sort);
    }

}

Measured memory_bytes: 1168
fun main(args: Array<String>) {
    val (n, k) = readIntList()
    val a = readIntList()

    for (i in k + 1..n) {
        if (a[i - 1] > a[i - k - 1]) {
            println("Yes")
        } else {
            println("No")
        }
    }
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)

Measured memory_bytes: 68564
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

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

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

bool isAGCT(string s) {
  rep(i,s.size()) {
    if (s[i]!='A'&&s[i]!='T'&&s[i]!='G'&&s[i]!='C') return false;
  }
  return true;
}

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

  string s;
  cin >> s;

  int res = 0, n = s.size();
  for (int i = 0; i < n; ++i) {
    for (int j = 0; i+j <= n; ++j) {
      if (isAGCT(s.substr(i,j))) chmax(res, j);
    }
  }

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <cstring>
#include <string>
#include <unordered_set>

using namespace std;

int main()
{
    int n = 0;
    scanf("%d", &n);
    char cmd[7];
    char str[13];
    unordered_set<string> ss;
    for (int i = 0; i < n; ++i) {
        scanf("%s %s", cmd, str);
        if (cmd[0] == 'i') {
            ss.emplace(str);
        } else if (cmd[0] == 'f') {
            if (ss.find(str) != ss.end()) {
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }
}


Measured memory_bytes: 28496
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int n;
	int num[110];
	while(n=in()){
		int i;
		for(i=0;i<n;i++){
			cin>>num[i];
		}
		int g=in();
		int a=0,b=n-1;
		int res=0;
		while(res++,num[(a+b)/2]!=g){
//cout<<a<<" "<<b<<endl;
			if(num[(a+b)/2]>g)b=(a+b)/2-1;
			else a=(a+b)/2+1;
			if(a>b)break;
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

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(){
  int n;
  cin >> n;
  vector<int> ans(0);
  rep(i,55556){
    if(isprime(i)&&i%5==1) ans.push_back(i);
    if(ans.size()==n) break;
  }
  rep(i,ans.size()){
    cout << ans[i] << " ";
  }cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	double n,a,b,c,d,e;cin>>n>>a>>b>>c>>d>>e;
	ll ans=ceil(n/min({a,b,c,d,e}))+4;
	cout<<ans<<"\n";
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>

using namespace std;

char buffer[1048576];
int main() {
  scanf("%s", buffer);
  int w;
  scanf("%d", &w);
  int n = strlen(buffer);
  string ans;
  for (int i = 0; i < n; i += w) {
    ans.push_back(buffer[i]);
  }
  printf("%s\n", ans.c_str());
  return 0;
}


Measured memory_bytes: 256
N=int(input())
Alist=list(map(int,input().split()))
Blist=list(map(int,input().split()))
Clist=list(map(int,input().split()))

b_sum=sum(Blist)

for i in range(N-1):
    if Alist[i]+1==Alist[i+1]:
        b_sum+=Clist[Alist[i]-1]

print(b_sum)

Measured memory_bytes: 3064
data = list(map(int,input().split(" ")))
stdnt = []
for i in range(data[0]):
	stdnt.append(list(map(int,input().split(" "))))
point = []
for i in range(data[1]):
	point.append(list(map(int,input().split(" "))))
def check(st,po):
	for i in range(len(st)):
                distance = []
                for j in range(len(po)):
                        distance.append(abs(st[i][0]-po[j][0])+abs(st[i][1]-po[j][1]))
                print(distance.index(min(distance)) + 1)
check(stdnt,point)


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

int main()
{
  int x, coin500, coin5;
  cin >> x;
  coin500 = x / 500;
  x -= coin500 * 500;
  coin5 = x / 5;
  cout << coin500 * 1000 + coin5 * 5 << endl;
  return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define sci(x) scanf("%d",&x);
#define scd(x) scanf("%lf",&x);

int main()
{
    ll n,ar[200],ans=0;
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>ar[i];
        ans+=ar[i];
    }
    ll k=(ans/n);
    ll p=k;
    if(ans%n!=0)
        k++;
    //cout<<k<<endl;
    ll res=0,res2=0;
    for(ll i=0;i<n;i++)
    {
        res2+=((p-ar[i])*(p-ar[i]));
        res+=((k-ar[i])*(k-ar[i]));
    }
    cout<<min(res,res2)<<endl;
//    cout<<"res2=>"<<res2<<endl;
//    cout<<res<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);
typedef long long ll;
using namespace std;
int main()
{
    IOS;
    int n;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    long long cnt = 0;
    for (int i = 0; i < n - 1; i++)
    {
        if (arr[i + 1] >= arr[i])
            continue;
        cnt += (arr[i] - arr[i + 1]);
        arr[i + 1] = arr[i];
    }
    cout << cnt;
}

Measured memory_bytes: 4368
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define pb push_back
const int N=100005;
const int MOD=1e9+7;
 

// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
 
 
 
int32_t main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  /* stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?)
  * do smth instead of nothing and stay organized
*/
int n,w;
cin>>n>>w;
int wts[n],price[n];
for(int i=0;i<n;i++)
{
	
	cin>>wts[i];
	cin>>price[i];
}
int dp[n+2][w+2];
for(int i=0;i<=n;i++)
{
	for(int ww=0;ww<=w;ww++)
	{
		if(i==0|| ww==0)
		{
			dp[i][ww]=0;
		}
		else
		{
			int inc=0,exc=0;
			if(wts[i-1]<=ww)
			{
				inc=price[i-1]+dp[i-1][ww-wts[i-1]];
			}
			exc=dp[i-1][ww];
			dp[i][ww]=max(inc,exc);
			
		}
	}
	
}

cout<<dp[n][w];

}


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

typedef pair<int, int> P;

int sx, sy, tx, ty;

int main() {
  cin >> sx >> sy >> tx >> ty;

  vector<char> o;
  for (int y=sy; y<ty; y++) o.push_back('U');
  for (int x=sx; x<tx; x++) o.push_back('R');
  for (int y=sy; y<ty; y++) o.push_back('D');
  for (int x=sx; x<tx; x++) o.push_back('L');

  o.push_back('L');
  for (int y=sy; y<ty+1; y++) o.push_back('U');
  for (int x=sx; x<tx+1; x++) o.push_back('R');
  o.push_back('D');
  o.push_back('R');
  for (int y=sy; y<ty+1; y++) o.push_back('D');
  for (int x=sx; x<tx+1; x++) o.push_back('L');
  o.push_back('U');

  for (auto c : o) cout << c; cout << "\n";
  return 0;
}


Measured memory_bytes: 256
//created by krishna
#include <bits/stdc++.h>
using namespace std;
#define endl "\n" 
typedef long long ll;
typedef unsigned long long ull;
#define debug(x) cout<<"the value of "<<#x<<" is "<<x<<endl;
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int x,n;
    cin>>x>>n;
    vector<int>arr(n);
    for(auto& i:arr)
        cin>>i;
    unordered_map<int,int>ma;
    for(auto i:arr)
        ma[i]=1;
    int right,left;
    for(int i=x;;i++){
        if(ma[i]==0){
            right=i;
            break;
        }
    }
    for(int i=x;;i--){
        if(ma[i]==0){
            left=i;
            break;
        }
    }
    if(right-x<x-left)
        cout<<right<<endl;
    else 
        cout<<left<<endl;
}

Measured memory_bytes: 3536
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main() {
	int n,k;
	cin >> n >> k;
	int h[100000];
	rep(i, n) {
		cin >> h[i];
	}
	sort(h, h + n);
	int ans = 1000000000;
	for (int i = 0; i < n - k + 1; i++) {
		ans = min(h[i + k - 1] - h[i], ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
N = int(input())
AB = [[] for i in range(N)]
for i in range(N):
    A, B = map(int, input().split())
    AB[i] = [A, B, A+B]

AB.sort(key=lambda x:x[2], reverse=True)

ta = 0
for i in range(N):
    if i % 2 == 0:
        ta += AB[i][0]
    else:
        ta -= AB[i][1]
print(ta)


Measured memory_bytes: 24412
#include <stdio.h>

int main() {
	int i;

	int input;
	int pasta = 100000, juce = 100000;

	for(i = 0; i < 3; i++) {
		scanf("%d", &input);
		if(input < pasta)
			pasta = input;
	}

	for(i = 0; i < 2; i++) {
		scanf("%d", &input);
		if(input < juce)
			juce = input;
	}

	printf("%d\n", pasta + juce - 50);
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <random>
#include <functional>

#include <fstream>
#include <vector>
#include <algorithm>

#define ll long long int

using namespace std;

bool isPrime(ll n)
{
    if(n == 1)
    {
        return false;
    }
    for(ll i = 2; i*i <= n; i++)
    {
        if(n % i == 0)
        {
            return false;
        }
    }
    
    return true;
}

int main(void)
{

    
    ll n, res, tmp;
    vector<ll> a;
    
    res = 0;
    
    cin >> n;
    
    for(ll i = 0; i < n; i++)
    {
        cin >> tmp;
        a.push_back(tmp);
    }
    
    sort(a.begin(), a.end(), greater<ll>());
    
    res = a[0];
    ll k = 1;
    
    for(ll i = 2; i < n;)
    {
        for(ll j = 0; (j < 2)&&(i < n); j++)
        {
            i++;
            res += a[k];
        }
        k++;
    }
    
    cout << res;
    
    return 0;
}

Measured memory_bytes: 5368
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
//================================================

int a = 0, b = 0, c, d, n, k = 0;
string s, t;



int main()
{
	cin >> n >> a >> b;
	cout << min(a, b) << " " << max(a + b - n, 0) << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return ReadLine().Split().Select(int.Parse).ToList(); }

        static int N;
        static int[][] A;
        static long[] dp;
        static readonly long Mod = 1000000000 + 7;
        static void Main(string[] args)
        {
            N = Sarray()[0];
            A = new int[N][];

            for (var i = 0; i < N; ++i)
                A[i] = Sarray();

            dp = new long[1<<N];
            dp[0] = 1;
            for (int bit = 0; bit < (1 << N); ++bit)
            {
                var pos = -1;
                for (var i = 0; i < N; ++i)
                { if ((bit & (1 << i)) != 0) ++pos; }
                for (var i = 0; i < N; ++i)
                {
                    if (((bit & (1 << i)) != 0) && (0 != A[pos][i]))
                    {
                        dp[bit] += dp[bit ^ (1 << i)];
                        dp[bit] %= Mod;
                    }
                }
            }
            WriteLine(dp[(1 << N) - 1]);
        }
    }
}

Measured memory_bytes: 29780
N,x = map(int,input().split())
ls = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    if ls[i]+ls[i+1] <= x:
        continue
    else:
        eat = - x + ls[i] + ls[i+1]
        ls[i+1] -= eat
        if ls[i+1] < 0:
            ls[i+1] = 0
        ans += eat
print(ans)

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n+2);
    a[0]=0;
    for(int i=1;i<n+1;i++){
        cin >> a[i];
    }
    a[n+1]=0;
    long long res=0;
    for(int i=1;i<n+2;i++){
        res+=abs(a[i]-a[i-1]);
    }
    for(int i=1;i<n+1;i++){
        long long ans=res;
        ans-=abs(a[i]-a[i-1]);
        ans-=abs(a[i+1]-a[i]);
        ans+=abs(a[i+1]-a[i-1]);
        cout << ans << endl;
    }
}

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] a = sc.next().toCharArray();
		if((a[0] == a[1] && a[0] == a[2]) || (a[1] == a[2] && a[1] == a[3])) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 22996
x=input()
N=len(x)
maxl=0
for i in range(N):
  if (x[i]=="A")or(x[i]=="T")or(x[i]=="G")or(x[i]=="C"):
    j=1
    while (i+j<N):
      if ((x[i+j]=="A")or(x[i+j]=="T")or(x[i+j]=="G")or(x[i+j]=="C")):
        j=j+1
      else:
        break
    if maxl<j:
      maxl=j
      maxi=i
    
print(maxl)

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


int main() {
  string s;
  cin>>s;
  int g=0,p=0;
  for(int i=0;i<s.size();i++){
  	if(s[i]=='p') p++;
    else g++;
  }
  if(s.size()%2==0) cout<<s.size()/2-p<<endl;
  else cout<<s.size()/2-p<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
  
int main() {
  int N;
  cin >> N;
  int a=1000000;
  
  rep(i,N) {
    int x;
    cin >> x;
    int j = 0;
    while (x%2==0){
      x /= 2;
      j++;
    }
    a=min(a,j);
  }
  cout << a;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

W = read().rstrip()

N = len(W)

def Z_algorithm(S):
    # 共通接頭辞の長さを返す
    N=len(S)
    arr = [0]*N
    arr[0] = N
    i,j = 1,0
    while i<N:
        while i+j<N and S[j]==S[i+j]:
            j += 1
        arr[i]=j
        if not j:
            i += 1
            continue
        k = 1
        while i+k<N and k+arr[k]<j:
            arr[i+k] = arr[k]
            k += 1
        i += k; j -= k
    return arr

def is_periodic_left(W):
    Z = Z_algorithm(W)
    is_periodic = [False] * N
    for p in range(1,N//2 + 10):
        for i in range(p,N,p):
            if Z[i] >= p:
                is_periodic[p + i - 1] = True
            else:
                break
    return is_periodic

L = is_periodic_left(W)
R = is_periodic_left(W[::-1])[::-1]

if not L[-1]:
    answer = (1,1)
elif len(set(W)) == 1:
    answer = (N,1)
else:
    x = sum(not(x or y) for x,y in zip(L,R[1:]))
    answer = (2,x)
print('\n'.join(map(str,answer)))

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

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    cout << (char)toupper(a[0]) << (char)toupper(b[0]) << (char)toupper(c[0]) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<utility>
#include<vector>
#include<stack>
#include<queue>
#include<cstring>
#include<set>
#include<map>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define st first
#define nd second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long lo;
const int mod=1000000007,N=500005;
lo a,b,c,d,e,f,g=1,h[N],arr[N];
string s;
vector<lo>v;
 
void solve(){
	cin >> a;
	lo x=100,say=0;
	while(x<a){
		x+=x/100;
		say++;
	}
	cout << say << endl;
}
 
int main(){
	#ifdef local
		freopen("in.txt","r",stdin);
		freopen("out.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// cin >> g;
	while(g--)solve();
}

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

int n, m, a[300][300], c[300], ans;
bool removed[300];

int main() {
	cin >> n >> m;
	ans = n;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j) {
			cin >> a[i][j];
			--a[i][j];
		}

	for (int i = 0; i < m; ++i) { //iコ除外
		fill(c, c + m, 0);
		for (int j = 0; j < n; ++j) {
			for (int k = 0; k < m; ++k) {
				if (removed[a[j][k]])
					continue;
				++c[a[j][k]];
				break;
			}
		}

		int idx = 0;
		for (int j = 0; j < m; ++j)
			if (c[j] > c[idx])
				idx = j;
		ans = min(ans, c[idx]);
		removed[idx] = 1;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3980
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#define forn(i, n) for (long long i = 0; i < (long long) (n); ++i)
#define pb emplace_back
#define endl '\n'

template<typename T> void _dbg(const char*_s,T _h) { cerr<<_s<<" = "<<_h<<"\n"; }

template<typename T, typename... Ts> void _dbg(const char*_s,T _h,Ts... _t) {
    for(int _b=0;((_b+=*_s=='(')-=*_s==')')!=0||*_s!=',';)cerr<<*_s++;
    cerr<<" = "<<_h<<",";_dbg(_s+1,_t...);
}

#define int long long

#ifdef LOCAL
    #define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
    #define dbg(...)
#endif

const int N = 2 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n;
int a[N];
int dp[N][N];

bool read() {
    if (!(cin >> n))
        return false;

    forn (i, n) cin >> a[i];

    return true;
}

void solve(int id = 0) {
    vector< pair<int, int> > p;

    forn (i, n)
        p.pb(a[i], i);

    sort(p.begin(), p.end());
    reverse(p.begin(), p.end());

    forn (i, n) {
        forn (l, i + 1) {
            int r = i - l;
            dp[l + 1][r] = max(dp[l + 1][r], dp[l][r] + p[i].first * abs(p[i].second - l));
            dp[l][r + 1] = max(dp[l][r + 1], dp[l][r] + p[i].first * abs(n - 1 - r - p[i].second));
        }
    }

    int ans = 0;

    forn (l, n + 1)
        ans = max(ans, dp[l][n - l]);

    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int T;
    //cin >> T;
    T = 1;

    while (read())
        solve(T++);

    return 0;
}


Measured memory_bytes: 26264
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int K;
	cin >> K;
	vector<int> A(K);
	for (int i = 0; i < K; i++) cin >> A[i];


	auto judge1 = [&](auto x) {
		for (int i = 0; i < K; i++) {
			x -= x % A[i];
		}
		return x >= 2;
	};

	auto judge2 = [&](auto x) {
		for (int i = 0; i < K; i++) {
			x -= x % A[i];
		}
		return x == 2;
	};

	auto binary_search = [&](auto f, auto ng_in, auto ok_in) {

		auto ng = ng_in;
		auto ok = ok_in;

		while (abs(ok - ng) > 1) {
			auto mid = (ok + ng) / 2;

			if (f(mid)) ok = mid;
			else ng = mid;
		}

		return ok;
	};

	auto m = binary_search(judge1, 0LL, LINF);
	if (!judge2(m)) {
		cout << -1 << "\n";
		return 0;
	}

	cout << m << endl;
	cout << binary_search(judge2, LINF, m) << endl;

	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007

int now;

int main(){
  int ans=0;
  string s;cin>>s;
  int n=s.length();
  vector<int> dp(13),dp2(13);

  dp[0]=1;

  int idx=0;
  int ke=1;

  for(int i=n-1;i>=0;i--){
    if (s[i]=='?'){
      for(int k=0;k<13;k++){
        for(int j=0;j<10;j++){
          idx=((ke*j)%13+k)%13;
          dp2[idx]+=dp[k];
          dp2[idx]%=MOD;
        }
      }
    }else{
      int d=s[i]-48;
      for(int k=0;k<13;k++){
        int j=d;
          idx=((ke*j)%13+k)%13;
          dp2[idx]+=dp[k];
          dp2[idx]%=MOD;
      }
    }

    REP(j,13){
      dp[j]=dp2[j];
      dp2[j]=0;
    }

    ke*=10;
    ke%=13;
  }



  cout<<dp[5]<<endl;
  return 0;
}

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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long Int;
typedef pair<Int, Int> P;

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

bool sosuu(int x){
	bool b = 1;
	if(x == 1) b = 0;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			b = 0;
			break;
		}
	}
	return b;
}

int n, a[100001], sum = 0;
bool b[100001] = {0};

int main(){
	cin >> n;
	
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(i == 0) sum += abs(a[i]);
		else sum += abs(a[i]-a[i-1]);
		if(i == n-1) sum += abs(a[i]);
	}
	a[n] = 0;
	for(int i = 0; i < n; i++){
		if(i == 0){
			if(a[i] > 0 && a[i+1] < a[i]){
				b[i] = 1;
			}
			if(a[i] < 0 && a[i+1] > a[i]){
				b[i] = 1;
			}
		}
		else if(i == n-1){
			if(a[i] > 0 && a[i] > a[i-1]){
				b[i] = 1;
			}
			if(a[i] < 0 && a[i] < a[i-1]){
				b[i] = 1;
			}
		}
		else{
			if(a[i-1] < a[i] && a[i] > a[i+1]){
				b[i] = 1;
			}
			if(a[i-1] > a[i] && a[i] < a[i+1]){
				b[i] = 1;
			}	
		}
	}
	
	vector<int> v;
	
	for(int i = 0; i < n; i++){
		if(b[i]) v.push_back(a[i]);
	}
	int cnt = 0;
	for(int i = 0; i < n; i++){
		if(b[i]){
			cout << sum - abs(a[i]-a[i-1]) - abs(a[i]-a[i+1]) + abs(a[i-1]-a[i+1]) << endl;
			cnt++;
		}
		else{
			cout << sum << endl;
		}
	}
	
	return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

class Parsing{
private:
  string parse;
  int pos;
public:
 
  Parsing(string s){
    parse = s;
    pos = 0;
  }
  int fact(){
    if(parse[pos] == '('){
      pos++;
      int p = expression();
      pos++;
      return p;
    }else{
      int p=0;
      
      while('0' <= parse[pos] && parse[pos] <= '9'){
    p *= 10;
    p += parse[pos]-'0';
    pos++;
      }
      return p;
    }
  }
 
 int term(){
    int p = fact();
    while(parse[pos] == '*' || parse[pos] == '/'){
      if(parse[pos] == '*'){pos++;p *= fact();}
      else {pos++;p /= fact();}
    }
    return p;
  }
 
 int expression(){
    int p = term();
    while(parse[pos] == '+' || parse[pos] == '-'){
      if(parse[pos] == '+'){pos++;p+=term();}
      else {pos++;p-=term();}
    }
    return p;
  } 
 
};


void compute() {

}

char op[2] = {'+','-'};

int main() {
  string s;
  cin >> s;
  rep(i,2) {
    string a = (( i == 0 ) ? "+" : "-");
    rep(j,2) {
      string b = (( j == 0 ) ? "+" : "-");
      rep(k,2) {
	string c = (( k == 0 ) ? "+" : "-");
	string t = s[0] + a + s[1] + b + s[2] + c + s[3];
	Parsing par = Parsing(t);
	if( par.expression() == 7 ) {
	  cout << t << "=7" << endl;
	  return 0;
	}
      }
    }
  }
  
  compute();
  return 0;
}


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

int n, m, a, b;
int main() {
  cin >> n >> m;
  set<pair<int, int>> st;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    st.insert(make_pair(a, b));
  }
  bool ret = false;
  for (int i = 2; i <= n - 1; i++) {
    if (st.count(make_pair(1, i)) && st.count(make_pair(i, n))) {
      ret = true;
    }
  }
  cout << (ret ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}


Measured memory_bytes: 9600
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
ll dp[2][4];
int now = 0;
int t[3];
ll p2[32];
void BreakNumber() {
	int n;
	cin >> n;
	int v = 2;
	int res = 1;
	while (n >= v)
	{
		res = v;
		v <<= 1;
	}
	cout << res << endl;
}
int main() {
	BreakNumber();
	return 0;
}



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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<pair<T, T>>& vp) {
	for (int i = 0; i < vp.size(); ++i) {
		s << "(" << vp[i].first << "," << vp[i].second << ")" << ( i+1 == vp.size() ? "" : ",\t" );
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char const* argv[])
{
	LL n;
	cin >> n;
	VL a(n);
	cin >> a;
	VL rui(n+1), ruir(n+1);
	rui[0] = 0; ruir[n] = 0;

	for (int i = 0; i < n; i++) {
		rui[i+1] = rui[i] + a[i];
	}
	LL ans = rui[n];
	for (int i = 0; i < n; i++) {
		ans = min(ans, abs((rui[n] - rui[i]) - rui[i]));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
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 int ll;
    
#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << n / 3 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db; 
typedef string str; 
 
typedef pair<int,int> pi;
typedef pair<ll,ll> pl; 
typedef pair<db,db> pd; 
 
typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<db> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 
typedef vector<pd> vpd;
typedef vector<vi> vvi; 
 
typedef set<int> si;
 
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() 
#define rsz resize
#define ins insert 
#define ft front() 
#define bk back()
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define lb lower_bound 
#define ub upper_bound
#define ts to_string 
 
int cdiv(int a, int b) { return a/b+!(a<0||a%b == 0); }
str tb(int x) {str ans; int c = x; for(int i = log2(x); i >= 0; --i){if(pow(2,i) <= c){ ans += "1"; c-=pow(2,i); } else { ans += "0"; } } return ans;}
bool ispr(int x){ for(int i = 2; i <= x/2; ++i){ if(x%i == 0){ return false; } }return true; } 
 
const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5; 
const ll INF = 1e18; 
 
void solve(){
	string s, s1; cin >> s >> s1;
	s+=s1[sz(s1)-1];
	cout << (s == s1 ? "Yes" : "No");	
}
 
int main(){
	std::ios::sync_with_stdio(0); std::cin.tie(0);
	
	bool isT = 0;
	if(isT){
		int t; cin >> t; while(t--){
			solve();
			cout << "\n";
		}
		return 0;
	}
	solve();
	cout << "\n";		
	return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#define INF 2000000000
using namespace std;

int count_comp;

void merge(int a[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  
  int l[n1 + 1], r[n2 + 1];
  for (int i = 0; i < n1; i++) {
    l[i] = a[left + i];
  }
  l[n1] = INF;
  for (int i = 0; i < n2; i++) {
    r[i] = a[mid + i];
  }
  r[n2] = INF;

  int p = 0, q = 0;
  for (int i = left; i < right; i++) {
    count_comp++;
    if (l[p] < r[q]) {
      a[i] = l[p++];
    } else {
      a[i] = r[q++];
    }
  }
}

void mergeSort(int a[], int left, int right) {
  if (left + 1 == right) return;
  int mid = (left + right) / 2;
  mergeSort(a, left, mid);
  mergeSort(a, mid, right);
  merge(a, left, mid, right);
}

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

  count_comp = 0;
  mergeSort(a, 0, n);

  cout << a[0];
  for (int i = 1; i < n; i++) {
    cout << ' ' << a[i];
  }
  cout << endl;
  cout << count_comp << endl;

  return 0;
}

Measured memory_bytes: 6960
import sys
readline = sys.stdin.readline

def main():
    N = int(readline())
    A = list(map(int, readline().rstrip().split()))
    d = {}
    for i, a in enumerate(A):
        if a in d.keys():
            d[a] += 1
        else:
            d[a] = 1

    for i in range(1, N+1):
        if i in d.keys():
            print(d[i])
        else:
            print(0)


if __name__ == '__main__':
    main()

Measured memory_bytes: 33520
#include <stdio.h>
#define MAX 500000

void Merge(int [],int,int,int);
void Merge_Sort(int [],int,int);


int total;

int main(void){
    int A[MAX];
    int i,n;

    //要素の個数を指定
    scanf("%d",&n);

    //読み込む
    for(i=0;i<n;i++)
        scanf("%d",&A[i]);


    Merge_Sort(A,0,n);

    //ソートされた数列を表示させる
    for(i=0;i<n-1;i++)
        printf("%d ",A[i]);
    printf("%d\n%d\n",A[i],total);

    return 0;
}


//Merge_Sortから送られてきたデータを結合する。
void Merge(int A[],int left,int mid,int right){
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1 + 1];
    int R[n2 + 1];
    int i,j,k;

    for(i = 0;i < n1;i++)
        L[i] = A[left + i];

    for(i = 0;i < n2;i++)
        R[i] = A[mid + i];

    L[n1] = 1000000000;
    R[n2] = 1000000000;

    i = 0;
    j = 0;

    for(k = left;k < right;k++){
        if(L[i] < R[j])
            A[k] = L[i++];
        else
            A[k] = R[j++];

        total++;
    }
}


//ここで分割できるだけ分割する
void Merge_Sort(int A[],int left,int right){
    int mid;

    // 2つになるまで分割して行く
    if(left + 1 < right){
        mid = (left + right)/2;
        Merge_Sort(A,left,mid);
        Merge_Sort(A,mid,right);
        Merge(A,left,mid,right);
    }
}

Measured memory_bytes: 4504
# https://atcoder.jp/contests/abc150/tasks/abc150_c
import sys
from itertools import *


def S(): return sys.stdin.readline().rstrip()


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def LS(): return list(sys.stdin.readline().rstrip().split())


N = I()
p = tuple(LI())
q = tuple(LI())

all = list(range(1, N+1))

all = list(permutations(all, N))


a = (all.index(p))
b = (all.index(q))

print(abs(a-b))

Measured memory_bytes: 44656
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

int main(void) {
  string s;
  cin>>s;
  for(int i=0; i<s.size(); i++) {
    int ans = 0;
    if(s[i] == 'R') {
      if(i+1 < s.size() and s[i+1] == 'L') {
	int cnt = 0;
	for(int j = i+1; j<s.size() and s[j] == 'L'; j++) cnt++;
	ans += cnt / 2 + 1;
	cnt = 0;
	for(int j = i-1; j>=0 and s[j] == 'R'; j--) cnt++;
	ans += cnt / 2;
      }
    } else {
      if(i-1 >= 0 and s[i-1] == 'R') {
	int cnt = 0;
	for(int j = i-1; j>=0 and s[j] == 'R'; j--) cnt++;
	ans += cnt / 2 + 1;
	cnt = 0;
	for(int j = i+1; j<s.size() and s[j] == 'L'; j++) cnt++;
	ans += cnt / 2;
      }
    }
    std::cout << ans << " ";
  }

  return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define INFLL (1LL << 60)
#define INF (1 << 30)
using namespace std;
typedef long long ll;

template<class T> inline void chmin(T& a, T b) { if (a > b) a = b; }
template<class T> inline void chmax(T& a, T b) { if (a < b) a = b; }

//（素集合データ構造）
//https://atcoder.jp/contests/atc001/tasks/unionfind_a
class UnionFind
{
	vector<int> pr, rank;
public:
	UnionFind(int n) {
		pr.resize(n);
		rank.resize(n, 0);	//rank	子どもの深さ
		for (int i = 0; i < n; ++i) pr[i] = i;	//頂点iの親を格納する
	}
	int root(int x) {
		if (x == pr[x]) return x;
		else return pr[x] = root(pr[x]);	//経路圧縮
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	bool unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (rank[x] < rank[y]) {
			pr[x] = y;	//子どもを深く持つ方を親にする
		}
		else {
			pr[y] = x;
			if (rank[x] == rank[y]) ++rank[x];
		}
		return true;
	}
};

//最小全域木
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_2_A&lang=jp
namespace MinTree
{
	struct Edge {
		int from, to, cost;
		Edge() {};
		Edge(int f, int t, ll c) {
			from = f; to = t; cost = c;
		}
	};
	//引数：辺(fromとtoがある)、頂点数
	//コストの小さい辺から順につないでいく。
	//閉路ができないように、UnionFindでデータを管理する
	ll kruskal(vector<Edge>& edges, int vnum) {
		sort(edges.begin(), edges.end(), [](Edge a, Edge b) {
			return a.cost < b.cost;
			});
		UnionFind uf = UnionFind(vnum);
		ll cmin = 0;
		for (Edge e : edges) {
			if (uf.unite(e.from, e.to)) {
				cmin += e.cost;
			}
		}
		return cmin;
	}
	//ある頂点から順に探索する
	//※dijkstraの場合は、ある地点sから、地点tへの移動の最小コストを見る。pqは累積コストで管理する。
	ll prim(vector<vector<Edge>>& graph, int start)
	{
		using CostPair = pair<ll, int>;
		vector<bool> used(graph.size(), false);
		priority_queue<CostPair, vector<CostPair>, greater<CostPair>> pq;
		pq.push(CostPair(0, start));
		ll sumcost = 0;
		while (!pq.empty()) {
			CostPair cp = pq.top(); pq.pop();
			ll c = cp.first; int v = cp.second;
			if (used[v]) continue;	//探索済みの点は省略
			used[v] = true;
			sumcost += c;
			for (Edge e : graph[v]) {
				if (used[e.to]) continue;
				pq.push(CostPair(e.cost, e.to));	//pqはその辺のコストで管理
			}
		}
		return sumcost;
	}
	void exec1()
	{
		int V, E; cin >> V >> E;
		vector<Edge> es(E);
		rep(i, E) cin >> es[i].from >> es[i].to >> es[i].cost;
		cout << kruskal(es, V) << endl;
	}
	void exec2()
	{
		int V, E; cin >> V >> E;
		vector<vector<Edge>> graph(V);
		rep(i, E) {
			int from, to, cost; cin >> from >> to >> cost;
			graph[from].push_back(Edge(-1, to, cost));
			graph[to].push_back(Edge(-1, from, cost));
		}
		cout << prim(graph, 0) << endl;
	}
}


int main()
{
	MinTree::exec1();
	return 0;
}



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

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

  int a;
  map<int, int> M;
  for (int i = 0; i < N; i++) {
    cin >> a;
    M[a]++; M[a+1]++; M[a-1]++;
  }

  int ans = 0;
  for (auto i = M.begin(); i != M.end(); i++) {
    ans = max(ans, i->second);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4736