akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb push_back
#define sz(v) (v).size()
#define all(v) (v).begin(),(v).end()
#define mp make_pair
#define fi first
#define se second
#define inf 1000000000
#define mod 1000000007
using namespace std;
template <typename T> void chmax(T &x,T y){x=x>y?x:y;return;}
template <typename T> void chmin(T &x,T y){x=x<y?x:y;return;}
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pi;

int n,a[105],b[105];

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i]>>b[i];
	for(int i=1;i<=n-2;i++)
	{
		if(a[i]==b[i]&&a[i+1]==b[i+1]&&a[i+2]==b[i+2])
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

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

int main() {
	int n, m;
	cin >> n >> m;
	bool a[n] = {}, b[n] = {};
	for (int i = 0;i < m;i++) {
		int aa, bb;
		scanf("%d%d", &aa, &bb);
		if (aa == 1)a[bb - 1] = true;
		if (bb == n)b[aa - 1] = true;
	}
	for (int i = 0;i < n;i++) {
		if (a[i] == true && b[i] == true) {
			printf("POSSIBLE\n");
			return 0;
		}
	}
	printf("IMPOSSIBLE\n");
}

Measured memory_bytes: 640
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    int N = readln.chomp.to!int;
    long[] xs, ys;
    foreach (_; 0..N) {
        auto xy = readln.split.to!(long[]);
        xs ~= xy[0];
        ys ~= xy[1];
    }
    long max_a = long.min, min_a = long.max, max_b = long.min, min_b = long.max;
    foreach (i; 0..N) {
        auto a = xs[i] - ys[i];
        max_a = max(max_a, a);
        min_a = min(min_a, a);

        auto b = xs[i] + ys[i];
        max_b = max(max_b, b);
        min_b = min(min_b, b);
    }
    writeln(max(max_a - min_a, max_b - min_b));
}

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


int main()
{
    int n;
    cin >> n;
    int f1 = 1, f2 = 1;
    int temp;
    if(n == 0 && n == 1){
        cout << 1 << endl;
        return 0;
    }
    for(int i = 0; i < n - 1; i++){
        temp = f2;
        f2 = f1 + f2;
        f1 = temp;
    }
    cout << f2 << endl;
    
    return 0;
}


Measured memory_bytes: 3112
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoderSolve.Tool;

namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;

        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            var cin = new Scanner();
            var input = cin.SplitReader();
            int H = input[0];
            int W = input[1];
            int[,] a = new int[H, W];
            for(var i = 0; i < H; i++)
            {
                var p = cin.SplitReader();
                for(var j = 0; j < W; j++)
                {
                    a[i, j] = p[j];
                }
            }
            long N = 0;
            List<Tuple<int, int, int, int>> ans = new List<Tuple<int, int, int, int>>();
            for(var i = 0; i < H; i++)
            {
                //if (W == 1) { break; }
                for(var j = 0; j < W - 1; j++)
                {
                    if (a[i, j] % 2 != 0) 
                    {
                        N++;
                        a[i, j + 1]++;
                        ans.Add(new Tuple<int, int, int, int>(i, j, i, j + 1));
                    }
                }
            }

            
            for(var i = 0; i < H - 1; i++)
            {
                if (a[i, W - 1] % 2 != 0)
                {
                    N++;
                    a[i + 1, W - 1]++;
                    ans.Add(new Tuple<int, int, int, int>(i, W - 1, i + 1, W - 1));
                }
            }

            Console.WriteLine(N);
            foreach(var x in ans)
            {
                Console.WriteLine($"{x.Item1 + 1} {x.Item2 + 1} {x.Item3 + 1} {x.Item4 + 1}");
            }

            Console.Out.Flush();
        }

        

    }

    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for(var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
    }

    struct Pair<T> : IComparable<Pair<T>> where T : IComparable<T>
    {
        public T variable;
        public int index;

        public Pair(T val, int i)
        {
            variable = val;
            index = i;
        }

        public int CompareTo(Pair<T> otherPair)
        {
            return variable.CompareTo(otherPair.variable);
        }

        public int CompareIndex(Pair<T> otherPair)
        {
            return index.CompareTo(otherPair.index);
        }
    }



}






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

public class Program{
  public static void Main(){
    var n = Int32.Parse(Console.ReadLine());
    var l = new Int32[n];
    for(var i=0; i<n; i++) l[i] = Int32.Parse(Console.ReadLine())-1;
    var j = 0;
    var c = 0;
    var tmp = 0;
    while(true){
      if(l[j]==-1){
        c = -1;
        break;
      }
      if(j==1) break;
      tmp = l[j];
      l[j] = -1;
      j = tmp;
      c++;
    }
    Console.WriteLine(c.ToString());
  }
}


Measured memory_bytes: 15300
n,m=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(n)]
ans=0
cnt=0
AB.sort(key=lambda x:x[0])
for a,b in AB:
    if b<=m:
        m-=b
        ans+=b*a
    else:
        ans+=a*m
        break
print(ans)

Measured memory_bytes: 29024
from collections import defaultdict
import sys
H,W=map(int,input().split())
Ch,Cw=map(int,input().split())
Dh,Dw=map(int,input().split())
smat=[[x=="." for x in input()] for _ in range(H)]
#print(smat)

graph=defaultdict(list)
#graph[i]: iから出る道の[重み,行先]の辞書
for i in range(H):
  for j in range(W):
    if not smat[i][j]:
      continue
    
    for k in [-1,1]:
      if 0<=i+k<H and smat[i+k][j]:
        graph[i*W+j].append(((i+k)*W+j,0))
      if 0<=j+k<W and smat[i][j+k]:
        graph[i*W+j].append((i*W+j+k,0))

    for k1 in [-1,1]:
      for k2 in [-1,1]:
        if 0<=i+k1<H and 0<=j+k2<W and smat[i+k1][j+k2]:
          graph[i*W+j].append(((i+k1)*W+j+k2,1))

    for k in range(-2,3):
      if i-2>=0 and 0<=j+k<W and smat[i-2][j+k] :
        graph[i*W+j].append(((i-2)*W+j+k,1))
      if i+2<H and 0<=j+k<W and smat[i+2][j+k] :
        graph[i*W+j].append(((i+2)*W+j+k,1))
        
    for k in range(-1,2):
      if 0<=i+k<H and j-2>=0 and smat[i+k][j-2]:
        graph[i*W+j].append(((i+k)*W+j-2,1))
      if 0<=i+k<H and j+2<W and smat[i+k][j+2]:
        graph[i*W+j].append(((i+k)*W+j+2,1))

dist_mat=[-1]*(H*W)
queue=[(Ch-1)*W+Cw-1]
d=0
while queue:
  new_queue=set()

  while queue:
    u=queue.pop()
    if u==(Dh-1)*W+Dw-1:
      print(d)
      sys.exit(0)
    dist_mat[u]=d
    
    for v,w in graph[u]:
      if dist_mat[v]!=-1:
        continue
      if w==0:
        queue.append(v)
      else:
        new_queue.add(v)

  queue=list(new_queue)
  d+=1
#print(dist)

print(-1)

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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 5000000000000000;
constexpr auto MOD = 1000000007;


int main() {

	string s;
	cin >> s;
	reverse(all(s));

	bool pos = true;

	int i = 0;

	while (i < s.size()) {

		if (s[i] == 'm'){
			if (s.size() > i + 4 &&
				s[i + 1] == 'a' &&
				s[i + 2] == 'e' &&
				s[i + 3] == 'r' &&
				s[i + 4] == 'd') {
				i += 5;
				continue;
			}
		}

		if (s[i] == 'r') {
			if (s.size() > i + 5 &&
				s[i + 1] == 'e' &&
				s[i + 2] == 's' &&
				s[i + 3] == 'a' &&
				s[i + 4] == 'r'&&
				s[i + 5] == 'e') {
				i += 6;
				continue;
			}
		}

		if (s[i] == 'r') {
			if (s.size() > i + 6 &&
				s[i + 1] == 'e' &&
				s[i + 2] == 'm' && 
				s[i + 3] == 'a' &&
				s[i + 4] == 'e' && 
				s[i + 5] == 'r' &&
				s[i + 6] == 'd') {
				i += 7;
				continue;
			}
		}

		if (s[i] == 'e'){
			if (s.size() > i + 4 &&
				s[i + 1] == 's' &&
				s[i + 2] == 'a' &&
				s[i + 3] == 'r' &&
				s[i + 4] == 'e'){
				i += 5;
				continue;
			}
		}

		pos = false;
		break;
	}

	if (pos)cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;


int main()
{
    ll N, M, R;
    cin >> N >> M >> R;
    vllvll Graph(N+1, vll(N+1, inf));

    vll r(R);
    rep(i, 0, R) cin >> r[i];
    rep(i, 0, M) {
        ll a, b, c;
        cin >> a >> b >> c;
        Graph[a][b] = c;
        Graph[b][a] = c;
    }


    rep(k, 1, N+1) {
            rep(i, 1, N+1) {
                    rep(j, 1, N+1) {
                            Graph[i][j] = min(Graph[i][j], Graph[i][k] + Graph[k][j]);
                    }
            }
    }

    sort(all(r));
    ll ans = inf;
    do {
            ll sm = 0;
            rep(i, 0, R-1) {
                    sm += Graph[r[i]][r[i+1]];
            }
            chmin(ans, sm);
    } while (next_permutation(all(r)));

    cout << ans << endl;
}



Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>

int main(){
  char s[100005];
  scanf("%s", s);
  int ans = 0, turn = 1, len = strlen(s);
  for(int i=1; i<len; i++)
    if(s[i] != s[i-1])
      ans++;

  printf("%d\n", ans);
  return 0;
}


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

template<class E>
using nega_queue=priority_queue<E,vector<E>,greater<E>>;

UL N;
ULL D[100];
vector<pair<UL,ULL>> E[100];

int main() {
 scanf("%u",&N);
 rep(i,N){
  UL u,k; scanf("%u%u",&u,&k);
  rep(j,k){
   UL v,c; scanf("%u%u",&v,&c);
   E[u].push_back({v,c});
  }
 }
 rep(i,N) D[i]=~0u;
 nega_queue<pair<ULL,UL>> G;
 G.push({0,0});
 int ans=0;
 while(G.size()){
  ULL d=G.top().first;
  UL p=G.top().second;
  G.pop();
  if(D[p]!=~0u) continue;
  D[p]=d;
  for(auto e:E[p]) G.push({d+e.second,e.first});
 }
 rep(i,N) printf("%u %llu\n",i,D[i]);
 return 0;
}



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

int main() {
  long long N; cin >> N;
  float n = N;
  long long x = sqrt(n);
  
  for(int i = x; i > 0; i--){
    if(N % i == 0){
      cout << i + N/i - 2 << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <set>
#include <utility>

using namespace std;

int main(){
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    double maxScore = -1;
    int ans1, ans2;
    queue<pair<int, int>> q;
    set<pair<int, int>> s;
    q.push(make_pair(a, 0));
    q.push(make_pair(b, 0));
    while(q.size()){
        auto status = q.front();
        q.pop();
        if(f < 100 * status.first + status.second){
            continue;
        }
        if(s.count(status)){
            continue;
        }
        s.insert(status);
        if(maxScore < 100. * status.second / (100 * status.first + status.second)){
            maxScore = 100. * status.second / (100 * status.first + status.second);
            ans1 = 100 * status.first + status.second;
            ans2 = status.second;
        }
        q.push(make_pair(status.first + a, status.second));
        q.push(make_pair(status.first + b, status.second));
        if(status.second + c <= status.first * e){
            q.push(make_pair(status.first, status.second + c));
        }
        if(status.second + d <= status.first * e){
            q.push(make_pair(status.first, status.second + d));
        }
    }
    cout << ans1 << " " << ans2 << "\n";
}


Measured memory_bytes: 640
fn sliding_minimum_elements<T>(a: &[T], l: usize) -> Vec<T> 
where T: Ord + Clone {
    assert!(a.len() >= l && l > 0);
    let mut d = std::collections::VecDeque::<(T, usize)>::new();
    for (i, a) in a[..(l - 1)].iter().enumerate() {
        while !d.is_empty() {
            if d.back().unwrap().0 >= *a {
                d.pop_back();
            } else {
                break;
            }
        }
        d.push_back((a.clone(), i));
    }
    let mut b = Vec::with_capacity(a.len() - l + 1);
    for (i, a) in a[(l - 1)..].iter().enumerate() {
        while !d.is_empty() {
            if d.back().unwrap().0 >= *a {
                d.pop_back();
            } else {
                break;
            }
        }
        d.push_back((a.clone(), i + l - 1));
        if d.front().unwrap().1 < i {
            d.pop_front();
        }
        b.push(d.front().unwrap().0.clone());
    }
    b
}

use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let l: usize = it.next().unwrap().parse().unwrap();
    let a: Vec<u32> = (0..n).map(|_| it.next().unwrap().parse().unwrap()).collect();
    let ans = sliding_minimum_elements(&a, l);
    let mut out = String::new();
    for a in ans {
        out.push_str(&a.to_string());
        out.push(' ');
    }
    out.pop();
    println!("{}", out);
}

fn main() {
    run();
}



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

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	vector<bool> buy(n), sell(n);
	rep(i,n) cin >> a[i];

	ll ans = 0;
	ll money = 1000;
	ll kabu = 0;

	buy[0] = true, sell[0] = false;
	buy[n-1] = false, sell[n-1] = true;
	for (int i=1;i<=n-2;i++) {
		if (a[i-1]<=a[i] && a[i]>a[i+1]) sell[i] = true;
		else sell[i] = false;
		if (a[i-1]>=a[i] && a[i]<a[i+1]) buy[i] = true;
		else buy[i] = false;
	}

	rep(i,n) {
		if (buy[i]) {
			ll num_buy = money / a[i];
			kabu += num_buy;
			money -= num_buy * a[i];
		}
	 	else if (sell[i]) {
			 money += kabu * a[i];
			 kabu = 0;
		}
		//printf("%d %lld %lld\n", i, money, kabu);
	}

	ans = max(1000LL, money);

	buy[0] = false;
	money = 1000;
	kabu = 0;

	rep(i,n) {
		if (buy[i]) {
			ll num_buy = money / a[i];
			kabu += num_buy;
			money -= num_buy * a[i];
		}
	 	else if (sell[i]) {
			 money += kabu * a[i];
			 kabu = 0;
		}
		//printf("%d %lld %lld\n", i, money, kabu);
	}

	ans = max(ans, money);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

lint gcd(lint x, lint y)
{
    return x == 0 ? y : gcd(y % x, x);
}

lint f(lint n, lint C, lint D)
{
    if (n <= 0)
        return 0LL;

    lint LCM = C / gcd(C, D) * D;
    return n - n / C - n / D + n / LCM;
}

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    lint A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << f(B, C, D) - f(A - 1, C, D) << "\n";
    return 0;
};


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;

template <typename T> 
using V = vector<T>;

template <typename T>
using VV = vector<V<T>>;

struct Idx {
    ll i1, i2;
};

const ll S = (1ll << 18) + 10;
V<Idx> memo(S, Idx{0, 0});
V<ll> ans(S, 0);

int main() {
    ll N;
    cin >> N;
    V<ll> A(1ll << N);
    for (ll &a : A) cin >> a;
    memo[1] = (A[0] < A[1] ? Idx{1, 0} : Idx{0, 1});
    ans[1] = A[0] + A[1];
    for (ll i = 2; i < A.size(); i++) {
        ll idx1 = i, idx2 = 0;
        if (A[idx1] < A[idx2]) swap(idx1, idx2);
        bitset<60> bi(i);
        for (ll j = 0; j < 60; j++) {
            if (!bi.test(j)) continue;
            ll idx = (bi ^ bitset<60>(1ll << j)).to_ullong();
            V<ll> tmp = {idx1, idx2, memo[idx].i1, memo[idx].i2};
            sort(tmp.begin(), tmp.end(), [&](ll a, ll b){ return A[a] > A[b]; });
            auto ite = unique(tmp.begin(), tmp.end());
            tmp.erase(ite, tmp.end());
            idx1 = tmp[0];
            idx2 = tmp[1];
        }
        memo[i] = Idx{idx1, idx2};
        ans[i] = max(ans[i - 1], A[idx1] + A[idx2]);
    }
    for (ll i = 1; i < A.size(); i++) cout << ans[i] << '\n';
    return 0;
}


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

int main() {
  int N;
  cin>>N;
  N--;//列車はN-1個
  vector<int> C(N);
  vector<int> S(N);
  vector<int> F(N);
  vector<int> total;
  vector<int> answer;//最終的な配列
  for(int i=0;i<N;i++){
    cin>>C.at(i)>>S.at(i)>>F.at(i);
  }
  
  for(int i=0;i<N;i++){
    int ans=0;//累計時間
    for(int j=i;j<N;j++){
      ans=max(ans,S.at(j));//始発が出ているか
      if(ans%F.at(j)!=0)ans+=F.at(j)-(ans%F.at(j)); //電車を待つか
      ans+=C.at(j); //電車で移動
      total.push_back(ans);
    }
    answer.push_back(total.at(N-i-1));
    total={};
  }
  answer.push_back(0);
  for(int i=0;i<N+1;i++){
    cout<<answer.at(i)<<endl;
  } 
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())
s = list(input())
for i in s:
  if i == "a" and (a + b) != 0:
    a -= 1
    print("Yes")
  elif i == "b" and (a + b) != 0 and b != 0:
    b -=1
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 4712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
  ll fact[1000000], inv[1000000], fact_inv[1000000];
  fact[1] = inv[1] = fact_inv[1] = 1;
  fact[0] = inv[0] = fact_inv[0] = 1;
  for (ll i = 2; i < 1000000; i++) {
      fact[i] = fact[i - 1] * i % MOD;
      inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
      fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
  }
  ll lis[1000000];
  ll n, k;
  cin >> n >> k;
  for(ll i = 0; i <= n-k+1; i++){
    lis[i] = fact[n-i] * fact_inv[n-k+1-i] % MOD;
    lis[i] = lis[i] * fact_inv[k-1] % MOD;
  }
  ll a[100000];
  rep(i, n) cin >> a[i];
  sort(a, a+n);
  ll ans = 0;
  for(ll i = 1; i <= n-k+1; i++){
    ll tmp = (a[n-i] - a[i-1]) % MOD;
    tmp = tmp * lis[i] % MOD;
    ans = (ans + tmp) % MOD;
  }
  ans = (ans + MOD) % MOD;
  cout << ans <<endl;
}



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

int main() {
   int N;
   int a;
   int count = 0;
   cin >> N;
   for(int i = 0; i < N; ++i){
     cin >> a;
     while ( a % 2 == 0 ) {
       a = a / 2;
       count++;
     }
   }
   cout << count << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
  ll n;
  cin >> n;
  if (n % 1000 == 0)
    cout << 0 << endl;
  else
  {
    ll b = 0;
    while (b < n)
    {
      b+=1000;
    }
    cout << b - n << endl;
  }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;

int main(){
  string s;cin >> s;
  int n;cin >> n;
  int a=s[0]-'0';
  for(int i=1;i<s.length();i+=2){
    if(s[i]=='+') a+=s[i+1]-'0';
    else a*=s[i+1]-'0';
  }
  int b=0,t=1;
  bool c=false;
  for(int i=1;i<s.length();i+=2){
    if(s[i]=='+'){
      if(c){
        b+=t*(s[i-1]-'0');
      }
      else b+=s[i-1]-'0';
      t=1;
    }
    else if(s[i]=='*'){
      c=true;
      t*=s[i-1]-'0'; 
    }
  }
  b+=(s[s.length()-1]-'0')*t;
  if(n==a&&n==b) puts("U");
  else if(n==a&&n!=b) puts("L");
  else if(n!=a&&n==b) puts("M");
  else puts("I");
  return 0;
}



Measured memory_bytes: 3228
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h,w,k;
    cin>>h>>w>>k;
    string s[11];
    for(int i=0;i<h;i++)cin>>s[i];
    int dp[12][1010];
    for(int i=0;i<12;i++){
        for(int j=0;j<1010;j++)dp[i][j]=0;
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            dp[i+1][j+1]=dp[i][j+1]+dp[i+1][j]-dp[i][j]+(s[i][j]=='1');
        }
    }
    if(dp[h][w]-dp[0][w]-dp[h][0]+dp[0][0]<=k){
        cout<<0<<endl;
        return 0;
    }
    int res=mod;
    for(int bit=0;bit<(1<<h);bit++){
        int cnt=0;
        set<int> vy;
        for(int i=0;i<h;i++){
            if(bit&(1<<i)){
                vy.insert(i+1);
                cnt++;
            }
        }
        if(!vy.count(h)){
            vy.insert(h);
        }
        int ny=0,nx=0;
        for(int x=0;x<=w;x++){
            for(auto y:vy){
                if(dp[y][x]-dp[ny][x]-dp[y][nx]+dp[ny][nx]>k){
                    cnt++;
                    nx=x-1;
                    if(nx==0)cnt+=mod;
                }
                ny=y;
                if(ny==h)ny=0;
            }
        }
        res=min(res,cnt);
    }
    cout<<res<<endl;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;cin>>s;
    int ans=0;
    int suc=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
            suc++;
        }
        else{
            ans=max(ans,suc);
            suc=0;
        }
    }
    ans=max(ans,suc);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;
ll const MAX_N = 3000;
double dp[MAX_N + 5][MAX_N + 5];

int main() {
    INIT;
    ll N;
    cin >> N;
    vector<double> p(N);
    rep(i, N) cin >> p[i];
    rep(i, MAX_N + 5) rep(j, MAX_N + 5) dp[i][j] = 0.0;

    dp[1][0] = 1 - p[0];
    dp[1][1] = p[0];

    reps(i, 1, N) {
        rep(j, N + 5) {
            if (j == 0) {
                dp[i + 1][j] = dp[i][j] * (1 - p[i]);
            } else if (j == i + 1) {
                dp[i + 1][j] = dp[i][j - 1] * p[i];
            } else if (j > i + 1) {
                dp[i + 1][j] = 0;
            } else {
                dp[i + 1][j] = dp[i][j - 1] * p[i] + dp[i][j] * (1 - p[i]);
            }
        }
    }

    // rep(i, N + 1) {
    //     rep(j, N + 1) { cout << fixed << setprecision(4) << dp[i][j] << " ";
    //     } cout << endl;
    // }

    double ans = 0;
    reps(i, N / 2 + 1, N + 1) { ans += dp[N][i]; }
    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 74420
#include <iostream>

using namespace std;

int main() {

    int a, b, c;

    cin >> a >> b >> c;

    if (((a == b) && (b != c)) || ((a == c) && (b != c)) || ((b == c) && (a != b))) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;

  if(e -a > k) cout << ":(" << endl;
  else cout << "Yay!" << endl;


  return 0;
}

Measured memory_bytes: 3572
#include <stdio.h>
 
int main(){
  int A,B;
  int i,j;
 
  scanf("%d %d",&A,&B);
  
  if(A%3==0){
    printf("Possible\n");
  }else if(B%3==0){
    printf("Possible\n");
  }else if((A+B)%3==0){
    printf("Possible\n");
  }else{
printf("Impossible\n");}
  return 0;
}

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

int main() {
  int N;
  int a[20];
  cin >> N;
  for(int i=0;i!=N;i++){
    cin >> a[i];
  }
  sort(a,a+N);
  int b=0;
  for(int i=0;i!=N-1;i++){
    b+=a[i];
  }
  if(b>a[N-1]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    vector<vector<int>> e(n);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        bool f = true;
        for(auto&& j : e[i]){
            if(h[i] <= h[j]){
                f = false;
                break;
            }
        }
        if(f){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 8704
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
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;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int X, N; cin >> X >> N;
  vector<bool> p(101, false);
  REP(i, N){
    int a; cin >> a;
    p[a] = true;
  }
  int ans = 0;
  int res = abs(X-0);
  REP(i, 102){
    if(p[i]) continue;
    if(res > abs(X-i)){
      res = abs(X-i);
      ans = i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3656
#include <stdio.h>
#include <string.h>

typedef struct {
	int height;
	int num;
} FIELD;

FIELD field[ 27 ][ 27 ];
const int dx[ 4 ] = { -1, 0, 1, 0 }, dy[ 4 ] = { 0, -1, 0, 1 };
const int roll[ 2 ][ 4 ][ 2 ] = { { { 1, 0 }, { 2, 1 }, { 0, 3 }, { 3, 2 } }, { { 1, 2 }, { 0, 1 }, { 2, 3 }, { 3, 0 } } };
const int l[ 12 ] = { 3, 1, 4, 2, 2, 5, 0, 3, 4, 0, 5, 1 };

void move( int, int, int, int );

int main( void ) {
	int n, x, y, t, f, count[ 7 ];

	while ( scanf( "%d", &n ), n ) {
		memset( count, 0, sizeof( int ) * 7 );
		memset( field, 0, sizeof( FIELD ) * 729 );

		while ( n-- ) {
			scanf( "%d %d", &t, &f );

			move( 13, 13, t - 1, f - 1 );
		}

		for ( y = 0; y < 27; y++ )
			for ( x = 0; x < 27; x++ )
				count[ field[ x ][ y ].num ]++;

		for ( x = 1; x < 6; x++ )
			printf( "%d ", count[ x ] );
		printf( "%d\n", count[ 6 ] );
	}

	return 0;
}

void move( int x, int y, int t, int f ) {
	int i, ff;

	ff = 0;
	for ( i = 0; ; i++ ) {
		if ( i == t || i == 5 - t )
			continue;
		if ( i == f )
			break;

		ff++;
	}

	for ( i = 0; i < 2; i++ ) {
		int d = roll[ t % 2 ][ ff ][ i ], nx = x + dx[ d ], ny = y + dy[ d ];

		if ( field[ x ][ y ].height > field[ nx ][ ny ].height )
			switch ( d ) {
				case 0:
					move( nx, ny, 5 - l[ t < 3 ? t * 4 + ff : 23 - t * 4 - ff ], f );
					return;
				case 1:
					move( nx, ny, f, 5 - t );
					return;
				case 2:
					move( nx, ny, l[ t < 3 ? t * 4 + ff : 23 - t * 4 - ff ], f );
					return;
				case 3:
					move( nx, ny, 5 - f, t );
					return;
			}
	}

	field[ x ][ y ].height++;
	field[ x ][ y ].num = t + 1;

	return;
}

Measured memory_bytes: 604
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int total_n = sc.nextInt();
        int select_m = sc.nextInt();
        int a[] = new int[total_n];

        double vote_count = 0;

        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
            vote_count += a[i];
        }

        int count_valid = 0;

        for (int i = 0; i < a.length; i++) {
            if (a[i] >= vote_count * (1 / (4.0 * ((double) select_m)))) {
                count_valid++;
            }
        }

        if (count_valid >= select_m) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define PI 3.14159265358979
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, 0};
int dx[]={1, -1, 0, 0, 0};

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
bool compare_by(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second > b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int counter(int x){
    if(!x)return 0;
    return counter(x>>1)+(x&1);
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;int M;
    cin>>N>>M;
    if(M==N){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3584
//Bi-smi llāh

#include<bits/stdc++.h>
using namespace std;
#define nn '\n'
#define pb push_back
#define F(i, n) for(int i = 0; i < n; ++i)
#define Fe(i, n) for(auto i: n)
#define  ll long long int



int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
  if(s[2] == s[3] and s[4] == s[5]){
      cout << "Yes\n";
    }else cout << "No\n";
	return 0;
	}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
inline void read(int &x){
    x=0;char ch;bool flag = false;
    while(ch=getchar(),ch<'!');if(ch == '-') ch=getchar(),flag = true;
    while(x=10*x+ch-'0',ch=getchar(),ch>'!');if(flag) x=-x;
}
#define rg register int
#define rep(i,a,b) for(rg i=(a);i<=(b);++i)
#define per(i,a,b) for(rg i=(a);i>=(b);--i)
const int maxn = 1024;
int a[maxn];
int main(){
    int n;read(n);n <<= 1;
    rep(i,1,n) read(a[i]);
    sort(a+1,a+n+1);
    int ans = 0;
    rep(i,1,n) ans += a[i++];
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(){
  int a,b,c,d,e,k;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&d);
  scanf("%d",&e);
  scanf("%d",&k);
  if((b-a>k)||(c-b>k)||(d-c>k)||(e-d>k)||(c-a>k)||(d-b>k)||(e-c>k)||(d-a>k)||(e-b>k)||(e-a>k)){
    printf(":(");
  }
  else{
    printf("Yay!");
  }
  getchar();
  return 0;
}


Measured memory_bytes: 128
MOD = 10**9+7

def ok?(i,j,k,l)
  if i ==1 && l== 3 && (j == 2 || k == 2)
    return false
  end

  s = "#{j}#{k}#{l}"

  if s.include?("123") || s.include?("132") || s.include?("213")
    return false
  end

  return true
end

N = gets.to_i

dp = Array.new(N+1) {Array.new(4){Array.new(4){Array.new(4,0)}}}
#dp[n][i][j][k] は，末尾がijkで条件をみたすn文字の場合の数
#i,j,k は0,1,2,3のときT,A,G,Cにそれぞれ対応

dp[0][0][0][0] = 1

for n in 1..N do
  for i in 0..3 do
    for j in 0..3 do
      for k in 0..3 do
        for l in 0..3 do
          if ok?(i,j,k,l)
            dp[n][j][k][l] += dp[n-1][i][j][k] % MOD
          end
        end
      end
    end
  end
end

ans = 0

for i in 0..3 do
  for j in 0..3 do
    for k in 0..3 do
      ans += dp[N][i][j][k] % MOD
    end
  end
end

puts ans % MOD


Measured memory_bytes: 2172
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

bool isPrime(int n) {
    if (n < 2)
        return false;
    if (n == 2)
        return true;
    if (n % 2 == 0)
        return false;

    for (int i = 3; i * i <= n; i += 2) {
        if (n % i == 0)
            return false;
    }
    return true;
}

void main() {
    string s;
    while ((s = readln.chomp) != null) {
        int n = s.to!int;

        int ans = 0;
        for (int i = 1; i <= n; i++) {
            int a = i;
            int b = n - i + 1;
            if (isPrime(a) && isPrime(b))
                ans++;
        }
        writeln(ans);
    }
}

Measured memory_bytes: 2376
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int mod =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
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;
}

ll RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string N=in<string>();
    bool flg=false;
    REP(i,N.size()){
        if(N[i]=='7')flg=true;
    }
    isYes(flg);
    return 0;
}


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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    string S, T;
    cin >> S;
    cin >> T;

    rep(i, S.size())
    {
        if(S[i]!=T[i])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

 

 

    return 0;
}



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

#define  ll long long
#define  il inline
#define INF 0x3f3f3f3f
#define pii pair<int,int>

const int mod = 1e9 + 7;
const int maxn = 1e5 + 5;
const int maxm = 2e5 + 10;
const double PI = acos(-1.0);

ll n;
struct Node{
    ll a,b;
}nodes[3];
ll dp[5000 * 5000 + 5];

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    cin >> n ;
    for(int i = 0; i < 3; i++){
        cin >> nodes[i].a;
    }
     for(int i = 0; i < 3; i++){
        cin >> nodes[i].b;
    }
    for(int i = 0; i <= n ; i++)
        dp[i] = i*1ll;

    for(int i = 0; i < 3; i++){
        for(int j = nodes[i].a;j <= n;j++)
            {
                dp[j]=max(dp[j],dp[j - nodes[i].a] + nodes[i].b);
            }
    }
    n = dp[n];
    for(int i = 0; i <= n ; i++)
        dp[i] = i*1ll;
    for(int i = 0; i < 3; i++) swap(nodes[i].a,nodes[i].b);
    for(int i=0; i<3; i++){
        for(int j = nodes[i].a;j <= n;j++)
            {
                dp[j]= max (dp[j],dp[j - nodes[i].a] + nodes[i].b);
            }
    }
    n = dp[n];
    cout << n << endl;
    return 0;

}


Measured memory_bytes: 195584
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 998244353
#define N 100005  //check the limits, man
int main()
{
    int n,m,i,x,a;
    in2(n,m);
    vii vp(n);
    rep(i,n)
        in2(vp[i].F,vp[i].S);
    sort(all(vp));
    ll ans=0;
    x=0,i=0;
    ll temp;
    while(x<m)
    {
        a=min(vp[i].S,m-x);
        x+=a;
        temp=a,temp*=vp[i].F;
        i++;
        ans+=temp;
    }
    llout(ans);
}





Measured memory_bytes: 1024
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: i64 = read();
    let a: i64 = read();
    let b: i64 = read();
    let c: i64 = read();
    let d: i64 = read();
    let e: i64 = read();

    let min_i = *[a, b, c, d, e].iter().min().unwrap();
    let ans = (n + min_i - 1) / min_i + 4;

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#define N 100000
using namespace std;

int main()
{
    int n;
	while(cin>>n)
    {
    	int sk[N],tp=0;
		while(n)
		{
	        int k=n%-2;
	        int t=n/-2;
	        if (k<0)
			{
	            k+=2;
	            t++;
	        }
	        n=t;
	        sk[++tp]=k;
    	}
    	for (int i=tp;i>=1;i--)
     	   cout<<sk[i];
     	cout<<endl;
    	if (tp==0) 
			cout<<0<<endl;

    	

	}
    
    return 0;

} 


Measured memory_bytes: 256
from sys import stdin

[K, S] =  [int(x) for x in (stdin.readline().rstrip().split())]

# combination of given X, Y, Z, that satisfy
# 0<= X, Y, Z <= K
# 0<= S <=3K
# X+Y+Z = S
# 2<= K<=2500

count = 0

for i in range(K+1):
    for j in range(K+1):
        if i+j<=S and K+i+j>=S:
            count+=1

print(count)






Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long N, A, B;
        N = scanner.nextLong();
        A = scanner.nextLong();
        B = scanner.nextLong();
        /*if (N == 1) {
            if (A == B) {
                System.out.println("1");
            } else {
                System.out.println("0");
            }
        } else {
            if (A > B) {
                System.out.println("0");
            } else {
                System.out.println((long)(B - A) * (N - 2) + 1);
            }
        }*/
        if (B - A < 0) {
            System.out.println("0");
            return;
        }
        if (N == 1) {
            if (A == B) {
                System.out.println("1");
            } else {
                System.out.println("0");
            }
            return;
        }
        /*long min = 0, max = 0;
        for (int i = 0; i < N - 1; i++) {
            min += A;
            max += B;
        }
        min += B;
        max += A;*/
        System.out.println((B - A) * (N - 2) + 1);
    }
}

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

t=[]
x=[]
y=[]

for i in range(n):
    a,b,c=map(int,input().split())
    t.append(a)
    x.append(b)
    y.append(c)
for i in range(n):
    if x[i]+y[i]>t[i] or (x[i]+y[i])%2!=t[i]%2:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 11740
// ABC068 B - Break Number
#include <stdio.h>

int main(void) {
    int N;
    scanf("%d", &N);

    if (N == 1) {
        printf("1\n");
        return 0;
    }
    int result = 2;
    while (N >= result * 2) {
        if (N <= result) {
            break;
        }
        result *= 2;
    }
    printf("%d\n", result);
    return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-

import sys

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    token = lines[0].split(" ")
    n = int(token[0])

    a = [int(e) for e in lines[1].split(" ")]

    return (n, a)


def solve(n, a):

    total = 0
    for i in range(n):
        total = total + (1/a[i])

    result = 1 / total

    return result


def main():
    # 出力

    print("%s" % solve(*parse_input()))

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  vector<char> list;
  for (int i=0; i<s.size(); i++) {
    if (s.at(i) == '0' || s.at(i) == '1') {
      list.push_back(s.at(i));
    } else {
      if (list.size()) {
        list.pop_back();
      }
    }
  }
  for (int i=0; i<list.size(); i++) {
    cout << list.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 256