akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <iomanip>
#include <unordered_map>
using namespace std;
#define ll long long 
#define pi pair<ll,ll>
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rrep(i,a) for(ll i=a;i>=0;i--)
ll mod=1e9+7;
/*ll power(ll x,ll n)
{
    ll ans=1;
    while(n)
    {
       if(n&1)
       ans=(ans*x)%mod;
       n>>=1;
       x=(x*x)%mod;
    }
   // ans%=mod;
    return ans;
}
/*
struct comp {
    bool operator()(const pair& x, const pair& y) const {
        if (x.second != y.second)
            return x.second < y.second;

        return x.first < y.first;
    }
};
void dfs(int source,vector<int> graph[],vector<int> &path,bool status[])
{
 path.push_back(source);
 status[source]=0;
 //int j=graph[source].size();
 for(int i=0;i<graph[source].size();i++)
 {
     if(status[graph[source][i]]==1)
     dfs(graph[source][i],graph,path,status);
 }
 return;
}*
bool solve(int i,int j,string s)
{
    while(i<j)
    {
      if(s[i]<s[j])
      return 0;
      if(s[i]>s[j])
      return 1;
      i++;
      j--;
    }
    return 1;
}
bool isprime(ll x)
{
    for(ll i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)
        return 0;
    }
    return 1;
    
}
ll lg(ll x,ll n)
{
    ll ans=0;
    while(x/n!=0)
    {
        ans++;
        x/=n;
    }
    return ans;
}*/


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,j,k,q,t,y,x,k1,i1,j1,z,x1,y1,m,d,p;
     string s;
     cin>>s;
     n=s.length();
     ll ans=0;
     x=0;
     for(i=0;i<n;i++)
     {
      if(s[i]!='R')
      {
          ans=max(ans,x);
          x=0;
      }
      else
      x++;
     }
     ans=max(ans,x);
     cout<<ans;
    
}



Measured memory_bytes: 3648
import sys
from fractions import Fraction
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = list(map(int, input().split()))
    deno = 0
    for i in a:
        deno += Fraction(1, i)
    print(float(1/deno))

if __name__ == '__main__':
    main()

Measured memory_bytes: 10328
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >>d;
  int l = a+b;
  int r = c+d;
  if( l == r){
    cout << "Balanced";
  }
  else if( l <r){
    cout << "Right";
  }
  else{
    cout << "Left";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
int a[200010];
int ans[200010];
int main(){
int n;
scanf("%d",&n);
for(int i=2;i<=n;i++)scanf("%d",&a[i]);
for(int i=2;i<=n;i++)ans[a[i]]++;
for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
}

Measured memory_bytes: 5252
#include<iostream>

using namespace std;

int M1, D1, M2, D2;

int main() {
	cin >> M1 >> D1;
	cin >> M2 >> D2;
	if (D2 == 1 && (M1 + 1 == M2 || (M1 == 12 && M2 == 1))) {
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = list(iss())
    s = set(S)
    print('yes' if len(S) == len(s) else 'no')

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const int N = 1e6+6;
int a[12][1004];
int sm[12][1004];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int h,w,k;
    cin>>h>>w>>k;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            char c;
            cin>>c;
            a[i][j] = c-'0';
        }
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            sm[i][j] = sm[i-1][j] + sm[i][j-1]+a[i][j]-sm[i-1][j-1];
        }
    }
    ///    0010101
    ///    7654321
    ///     001 01 01
    char hell,hano;
    int ans = w*h;
    for(int i=0;i<(1<<h);i++){
        int tmp = 0;
        for(int j=0;j<h;j++){
            if(i&(1<<j)){
                    tmp++;
            }
        }
        int lstj = 0;
        for(int j=1;j<=w;j++){
            int lstl = 0;
            for(int l=0;l<=h;l++){
                if(i&(1<<l) or l==h){
                    /// x1-1 = lstl, y1-1 = lstj ,x2 = l, y2 = j
                    if(sm[l][j]-sm[l][lstj]-sm[lstl][j]+sm[lstl][lstj] >k){
                        if(j==lstj+1){
                            goto hell;
                        }else{
                            tmp++;
                            lstj = j-1;
                            break;
                        }
                    }
                    lstl = l;
                }
            }
        }
        ans = min(ans,tmp);
        hell:;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if (r <= x && x + r <= w && r <= y && y + r <= h) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

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

    vector<int> v(n);
    for(int i = 0; i < n; i++)
        cin >> v[i];
    sort(v.rbegin(), v.rend());

    int ans = 0;
    for(int i = 0; i < k; i++)
        ans += v[i];
    cout << ans << endl;
}


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

int max(int n, int m){
 	return (n>m) ? n : m;
}

int main(void){
 	int N, T;
    cin >> N >> T;
    int *A, *B;
  	A = new int[N];
  	B = new int[N];
    for(int i=0; i<N; i++){
		cin >> A[i] >> B[i];
    }
  
  	// DP1: 料理[0] 〜 料理[i-1] で j 分以内に完食できる組み合わせのうち B の合計の最大値
	int **DP1 = new int*[N];
	for (int i = 0; i < N; i++) {
    	DP1[i] = new int[T];	
	}
	
  	for (int j = 0; j<T; j++){
		DP1[0][j] = (A[0] <= j ) ? B[0] : 0 ;
    }
  	
  	for (int i = 1; i<N; i++) {
		DP1[i][0] = 0;
      	for( int j = 1; j<T; j++){
        DP1[i][j] = (j-A[i] >= 0) ? max( DP1[i-1][j], DP1[i-1][j-A[i]]+B[i] ) : DP1[i-1][j];     
        }
    }
  	
  	/*
    for (int i = 0; i<N; i++) {
     	for( int j = 0; j<T; j++){
    		cout << DP1[i][j] << " "; 
        }
      	cout << endl;
    }
	*/
  
    // DP2: 料理[i-1] 〜 料理[N-1] で j 分以内に完食できる組み合わせのうち B の合計の最大値
	int **DP2 = new int*[N];
	for (int i = 0; i < N; i++) {
    	DP2[i] = new int[T];	
	}
	
  	for (int j = 0; j<T; j++){
		DP2[N-1][j] = (A[N-1] <= j ) ? B[N-1] : 0 ;
    }
  	
  	for (int i = N-2; i>=0; i--) {
      	DP2[i][0] = 0;
     	for( int j = 1; j<T; j++){
        DP2[i][j] = (j-A[i] >= 0) ? max( DP2[i+1][j], DP2[i+1][j-A[i]]+B[i] ) : DP2[i+1][j];     
        }
    }
  	
 	/*
    for (int i = 0; i<N; i++) {
     	for( int j = 0; j<T; j++){
    		cout << DP2[i][j] << " "; 
        }
      	cout << endl;
    }
    */
  	
  	int *f = new int[N];
 	int temp, tempmax;
  
  	for (int i = 0; i < N; i++) {
        temp = 0;
  		tempmax = 0;
  		for (int j = 0; j < T; j++) {
          	if (i==0) { temp = DP2[i+1][T-1-j]; } 
          	else if (i==N-1) { temp = DP1[i-1][j]; }
         	else { temp = DP1[i-1][j] + DP2[i+1][T-1-j];}
			if (temp > tempmax) { tempmax = temp; }
        }
      	// f[i]: 料理[i] 以外を組み合わせて (T-1) 分以内に完食するときの B の合計の最大値
  		f[i] = tempmax;
    }        
    
  	temp = 0;
	tempmax = 0;
	for (int i = 0; i<N; i++) {
  		temp = f[i] + B[i];
      	if (temp > tempmax) {tempmax = temp;}
    }  

  	cout << tempmax << endl;
  
 	delete[] A;
    delete[] B;
	for (int i = 0; i < N; i++) {
    	delete[] DP1[i];
      	delete[] DP2[i];
	}
	delete[] DP1;
	delete[] DP2;
  	delete f;
	return 0;
}

Measured memory_bytes: 70784
class Result(val problem: String, val isAC: Boolean)

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    var ac = 0
    var wa = 0
    val results = Array(m) {
        readLine()!!.split(" ").let { Result(it.first(), it.last() == "AC") }
    }.groupBy { it.problem }.map {
        var s = 0
        var f = 0
        for (i in it.value.indices) {
            if (it.value[i].isAC) {
                s++
                break
            } else {
                f++
            }
        }
        ac += s
        if (s > 0) wa += f
    }
    println("$ac $wa")
}


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

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    long N;
    scan(N);

    if (N % 2) {
        writeln(0);
        return;
    }

    long d = 10;
    long ans;

    while (d <= N) {
        ans += N / d;
        d *= 5;
    }

    writeln(ans);
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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

#define INF 99999999
#define FER 0.0000000001

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;

struct Edge
{
	int s, t, w;
	Edge(int s,int t,int w):s(s),t(t),w(w){}
	Edge() :Edge(-1, -1, -1) {}
	bool operator<(const Edge& e)const
	{
		return w != e.w ? w < e.w : (s != e.s ? s < e.s : t < e.t);
	}
};


struct P
{
	double x, y;
	P(double x, double y) :x(x), y(y) {}
	P() :P(0, 0) {}
	P operator+(const P& v)const
	{
		return P(x + v.x, y + v.y);
	}
	P operator-(const P& v)const
	{
		return P(x - v.x, y - v.y);
	}
	P operator*(const double v)const
	{
		return P(x*v, y*v);
	}
	bool operator==(const P& v)const
	{
		return abs(x - v.x) <= 0.0000000000001&&abs(y - v.y) <= 0.00000000000001;
	}
	bool operator!=(const P& v)const
	{
		return abs(x - v.x) > 0.0000000000001 || abs(y - v.y) > 0.00000000000001;
	}

	double dot(const P& v)const
	{
		return x*v.x + y*v.y;
	}
	double cross(const P& v)const
	{
		return x*v.y - y*v.x;
	}
	double length()const
	{
		return sqrt(x*x + y*y);
	}
	double length2()const
	{
		return (x*x + y*y);
	}

	bool operator<(const P& v)const
	{
		return x<v.x || (x == v.x) && y < v.y;
	}
	bool operator>(const P& v)const
	{
		return x>v.x || (x == v.x) && y > v.y;
	}
};

struct Rectangle
{
	ll h;
	int p;
	Rectangle(ll h,int p):h(h),p(p){}
};

ll h[100001];

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

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

	stack<Rectangle> rs;

	ll ans = 0;
	for (int i = 0; i < N; i++)
	{
		if (rs.empty())
		{
			rs.push(Rectangle(h[i], i));
		}
		else
		{
			if (rs.top().h < h[i])
			{
				rs.push(Rectangle(h[i], i));
			}
			else if (rs.top().h>h[i])
			{
				int tp = i;
				while (!rs.empty() && rs.top().h>h[i])
				{
					Rectangle tr = rs.top();
					rs.pop();
					ans = max(ans, tr.h*(i - tr.p));
					tp = tr.p;
				}
				rs.push(Rectangle(h[i], tp));
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 5304
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define moder 1000000007
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
using namespace std;
int n,p,q[20010],a[20010],b[20010];
signed main(){
	cin>>n;
	rep(i,n){
		cin>>p;
		q[p-1]=i;
	}
	rep(i,n-1)cout<<40000*(i)+1<<" ";
	cout<<40000*(n-1)+1<<endl;
	rep(i,n-1)cout<<40000*(n-i-1)+q[i]+1<<" ";
	cout<<q[n-1]+1<<endl;
	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<cstdlib>
#include<algorithm>
#include<climits>
#include<queue>
#include<stack>
#include<cmath>
#include<iterator>
typedef long long ll;
using namespace std;
#define rep(x, y)   for (ll i = x; i <= y; i ++)
#define repi(x, y)  for (ll i = x; i >= y; i --)
priority_queue< ll > cancel;
ll weight[200005];
ll value[200005];
int main()
{
    ll test=1;
    // cin>>test;
    for(ll z=0;z<test;z++)
    {
        ll n,W;
        cin>>n>>W;
        ll dp[W+5][n+5];
        for(ll i=1;i<=n;i++)
        {
            cin>>weight[i];
            cin>>value[i];
        }

        for(ll i=0;i<=n;i++)
        {
            dp[0][i]=0;
        }

        for(ll i=1;i<=W;i++)
        {
            dp[i][0]=0;
        }

        for(ll i=0;i<=W;i++)
        {
            for(ll j=1;j<=n;j++)
            {
                if(weight[j]>i)
                {
                    dp[i][j]=dp[i][j-1];
                }
                else
                {
                    dp[i][j]=max(dp[i][j-1],dp[i-weight[j]][j-1]+value[j]);
                }  
            }
        }
        cout<<dp[W][n]<<endl;
    }
}

Measured memory_bytes: 85644
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<complex>
using namespace std;
typedef long long int llint;
int main(){
	char a, b, c;
	cin >> a >> b >> c;
	int ans = 700;
	if (a == 'o'){
		ans += 100;
	}
	if (b == 'o'){
		ans += 100;
	}
	if (c == 'o'){
		ans += 100;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 
 
const int N = 10000, OO = 1e9 + 7, T = 410, M = 998244353, P = 6151, SQ = 800, lg = 32;
typedef pair <int, int> pii;
int dp[N], a[N];

int32_t main() {
	use_fast;
	int n, s;
	cin >> n >> s;
	int ans = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		for(int j = s; j > a[i]; j--) 
			dp[j] = (dp[j] + dp[j - a[i]]) % M;
		dp[a[i]] = (dp[a[i]] + (i + 1)) % M;
		ans = (ans + dp[s]) % M;
	}
	cout << ans << endl;
	return 0; 
} 
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/

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

#define INF (1 << 29)

using namespace std;

int V, E, L, M, A, H, P, Q, R, C;

int main()
{
	while (true)
	{
		scanf("%d", &V);
		scanf("%d", &M);
		scanf("%d", &L);
		scanf("%d", &E);
		scanf("%d", &A);
		scanf("%d", &H);

		if (V == 0) { break; }

		vector<vector<pair<int, int> > > G(V);

		vector<bool> ok(V, false);

		for (int i = 0; i < L; i++)
		{
			scanf("%d", &C);

			ok[C] = true;
		}

		for (int i = 0; i < E; i++)
		{
			scanf("%d", &P);
			scanf("%d", &Q);
			scanf("%d", &R);

			G[P].push_back(make_pair(Q, R));
			G[Q].push_back(make_pair(P, R));
		}

		vector<vector<int> > dp(V, vector<int>(M + 1, INF));

		dp[A][M] = 0;

		for (int rep = 0; rep < V - 1; rep++)
		{
			for (int i = 0; i < V; i++)
			{
				if (i != A)
				{
					for (int j = 0; j <= M; j++)
					{
						for (int k = 0; k < G[i].size(); k++)
						{
							if (G[i][k].second + j <= M)
							{
								dp[i][j] = min(dp[i][j], dp[G[i][k].first][j + G[i][k].second] + G[i][k].second);
							}
						}
					}
				}

				if (ok[i])
				{
					int t = INF;

					for (int j = 0; j <= M; j++)
					{
						t = min(dp[i][j], ++t);

						dp[i][j] = t;
					}
				}
			}
		}

		int ret = INF;

		for (int i = 0; i <= M; i++)
		{
			ret = min(ret, dp[H][i]);
		}

		if (ret != INF)
		{
			printf("%d\n", ret);
		}
		else
		{
			printf("Help!\n");
		}
	}

	return 0;
}

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

int main()
{
    string s, t;
    cin >> s >> t;
    int n, m;
    n = s.size();
    m = t.size();
    for(int i = 0; i <= n - m; i++){
        bool f = true;
        for(int j = 0; j < m; j++){
            if(s[(n - 1) - (i + j)] != '?' && s[(n - 1) - (i + j)] != t[(m - 1) - j]){
                f = false;
            }
        }
        if(f){
            for(int j = 0; j < n - (i + m); j++){
                if(s[j] == '?'){
                    s[j] = 'a';
                }
            }
            for(int j = n - (i + m); j < n - i; j++){
                s[j] = t[j - (n - (i + m))];
            }
            for(int j = n - i; j < n; j++){
                if(s[j] == '?'){
                    s[j] = 'a';
                }
            }
            cout << s << endl;
            return 0;
        }
    }
    cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 
 
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		long ans = 0;
		long A = I.nextLong();
		long B = I.nextLong();
		if (A==1) ans+=300000;
		if (A==2) ans+=200000;
		if (A==3) ans+=100000;
		if (B==1) ans+=300000;
		if (B==2) ans+=200000;
		if (B==3) ans+=100000;
		if (A==1&&B==1) ans+=400000;
		O.pln(ans);
	}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
	}
}

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

ll mpower(ll a,ll b,ll c){
  int z;
  if(b==0){
    z=1;
    z%=c;
    return z;
  }
  if(b==1){
    z=a;
    z%=c;
    return z;
  }
  else{
    return (((mpower(a,b/2,c))*(mpower(a,b/2,c))%c)*mpower(a,b%2,c)%c);
  }
}
//aのｂ乗をｃで割った余り
const int MAX = 510000;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

// 二項係数計算
long long 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;
}

int main(){
  COMinit();
  ll mod=998244353;
  ll n,m,k;
  cin>>n>>m>>k;
  if(n==1){
    cout<<m<<endl;
    return 0;
  }
  ll ans=0,p=1;
  for(int i=0;i<=k;i++){
    p=1;
    p*=m;
    p*=mpower(m-1,n-1-i,mod);
    p%=mod;
    p*=COM(n-1,i);
    p%=mod;
    ans+=p;
    ans%=mod;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 15592
#include<iostream>
#include<vector>

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    int a[m][2];
    for(int i=0;i<m;i++)cin >> a[i][0] >> a[i][1];
    bool check[n];
    for(int i=1;i<n;i++)check[i] = false;

    for(int i=0;i<m;i++){
        if(a[i][0]==1)check[a[i][1]] = true;
        if(a[i][1]==1)check[a[i][0]] = true;
    }

    for(int i=0;i<m;i++){
        if(a[i][0]==n && check[a[i][1]]){
            cout << "POSSIBLE" << endl;
            return 0;
        }
        if(a[i][1]==n && check[a[i][0]]){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#include<math.h>
#define ll long long
#define ld long double
#define Summon_Tourist ios::sync_with_stdio(false);cin.tie(0);
ll gcd(ll a , ll b) { return b==0?a: gcd( b, a%b); }
ll lcm(ll a , ll b) { return a/gcd(a,b) * b ; }
ll inf = 1e9 + 7;
ll modexp( ll base ,ll power)
 {
     if( power == 0  ) return 1;
     if( power & 1) return base*modexp( base , power-1 )%inf;
     return modexp(base*base%inf,power/2);
 }
 int main()
{
  Summon_Tourist
  //freopen("input.txt" , "r" , stdin ) ;
  ll x,n;
  cin>>x>>n;
  vector<ll> a(n);
  ll l,r;
  unordered_map<ll,ll> mp;
  for( ll i = 0 ; i<n ; i++ ) { cin>>a[i];mp[a[i]] = 1;}
  for( ll i = x ; i>=0 ; i++ ){
    if(!mp[i]){ r = i ;break ; }
  }
  for( ll i = x ; i<=x ; i--)
  {
      if(!mp[i]){ l = i ; break ;}
  }
  if( (x-l) <= (r-x) ) cout<<l;
  else cout<<r;

  return 0;

}


Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

//inline int read(){int t = 0;int neg=1;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1;continue;}t=t*10+c-48;}return neg*t;}
//inline int readl(){long long t = 0;long long neg=1ll;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1ll;continue;}t=t*10+c-48;}return neg*t;}

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pi;
typedef pair<lli,lli> plli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<pi> vpi;
typedef vector<plli> vplli;
const lli M=1000000007ll;

int main(){
	fast_io 
	char c;
	cin>>c;
	if(c=='a' or c=='e' or c=='i' or c=='o' or c=='u') cout<<"vowel\n";
	else cout<<"consonant\n";
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	int n;
	cin >> n;
	int s = 0;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
		s += t;
	}
	int ans = s;
	int c = 0;
	for (auto t : a) {
		c += t;
		ans = min(ans, abs(c - (s - c)));
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int q1 = scanner.nextInt();
			if (q1 == 0)
				break;
			int b = scanner.nextInt();
			int c1 = scanner.nextInt();
			int c2 = scanner.nextInt();
			int q2 = scanner.nextInt();
			int count = -1;
			for (int i = q2; i >= 1; i--) {
				int aa = i * c1;
				int bb = Math.max((q1 - i), 0) * c2;
				if (aa + bb <= b) {
					count = i;
					break;
				}
			}
			if (count == -1) {
				System.out.println("NA");
			} else {
				int ans = (b - count * c1) / c2;
				System.out.println(count + " " + ans);
			}
		}

	}
}

Measured memory_bytes: 20416
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define per(i,n) for(int i=(n)-1; i>=0; i--)
#define chmin(a,b) a = min(a,b)
using namespace std;
using vi = vector<int>;
using vv = vector<vi>;
const int MOD = 1000000007;

int main(){
    int n;cin>>n;
    
    vector<long long> dp(n+1,MOD);
    dp[0] = 0;
    
    vi a;
    a.push_back(1);
    int b = 6;
    while(b<=n){
        a.push_back(b);
        b *= 6;
    }
    b = 9;
    while(b<=n){
        a.push_back(b);
        b *= 9;
    }
    
    sort(a.rbegin(), a.rend());
    
    rep(i,a.size()){
        for(int j=0; j+a[i]<=n; j++){
            chmin( dp[j+a[i]], dp[j]+1 );
        }
    }
    
    cout << dp[n] << endl;
    
    return 0;
}

Measured memory_bytes: 3972
n = int(input())
a = list( map(int, input().split()))
p = 10**9+7

len_max = len(list(format(max(a), 'b')))

bin_list = [0]*len_max

for a_ in a:
    for i in range(1,len_max+1):
        if a_ & (1<<(i-1)):
            bin_list[-i] += 1

ans = 0
for i in range(1,len_max+1):
    num_1 = bin_list[-i]%p
    ans += 2**(i-1)%p * num_1 * (n-num_1)%p

print(ans%p)

Measured memory_bytes: 122936
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n; cin >> n;
    map<int, int> mp;
    for(int i = 0; i < n; i++) {
        int a; cin >> a;
        if(mp[a] > 0) mp[a]--;
        else mp[a]++;
    }

    int ans = 0;
    for(auto i = mp.begin(); i != mp.end(); i++) {
        ans += i -> second;
    }

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


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define ll long
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int s, k;
	cin >> k >> s;
	int count = 0;
	for (int i = 0; i <= k; i++) {
		for (int j = 0; j <= k; j++) {
			int z = s - i - j;
			if (z >= 0 && z <= k) {
				count++;
			}
		}
	}
	cout << count << endl;

}

Measured memory_bytes: 3548
#include <iostream>
#include <algorithm>

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

using namespace std;

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

P tx[1 << 19];
P ty[1 << 19];

P update(P* t, int i, int x, int k, int l, int r){
	if(i < l || r <= i){
		return t[k];
	}
	if(i <= l && r <= i + 1){
		return t[k] = P(x, x);
	}
	int m = (l + r) / 2;
	P p = update(t, i, x, 2 * k + 1, l, m);
	P q = update(t, i, x, 2 * k + 2, m, r);
	return t[k] = P(
		min(p.first, q.first),
		max(p.second, q.second)
	);
}
void update(P* t, int i, int x){
	update(t, i, x, 0, 0, 1 << 18);
}

P query(P* t, int a, int b, int k, int l, int r){
	if(b <= l || r <= a){
		return P(1e7, 0);
	}
	if(a <= l && r <= b){
		return t[k];
	}
	int m = (l + r) / 2;
	P p = query(t, a, b, 2 * k + 1, l, m);
	P q = query(t, a, b, 2 * k + 2, m ,r);
	return P(
		min(p.first, q.first),
		max(p.second, q.second)
	);
}
P query(P* t, int a, int b){
	return query(t, a, b, 0, 0, 1 << 18);
}

int n;
int d;
int x[200000];
int y[200000];
P b[200000];

int main(){
	cin >> n >> d;
	rep(i, n){
		int v;
		cin >> x[i] >> y[i] >> v;
		b[i] = P(v, i);
	}
	sort(b, b + n);
	rep(i, n){
		update(tx, i, x[b[i].second]);
		update(ty, i, y[b[i].second]);
	}
	ll ans = 0;
	int s = 0, t = 0;
	while(s <  n){
		while(t < n && b[t].first <= b[s].first + d){
			++t;
		}
		P p = query(tx, s, t);
		P q = query(ty, s, t);
		ll dx = p.second - p.first;
		ll dy = q.second - q.first;
		ans = max(dx * dy, ans);
		++s;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 12536
// JOI - Prelim  0630
// 電子レンジ (Microwave)
#include <bits/stdc++.h>

using namespace std;

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

void sub()
{
    // 1 行目には、もともとの肉の温度 A が書かれている
    // 2 行目には、目的の温度 B が書かれている
    // 3 行目には、凍った肉を1度温めるのにかかる時間 C が書かれている
    // 4 行目には、凍った肉を解凍するのにかかる時間 D が書かれている
    // 5 行目には、凍っていない肉を1度温めるのにかかる時間 E が書かれている
    const auto A(cin2var<int64_t>());
    const auto B(cin2var<int64_t>());
    const auto C(cin2var<int64_t>());
    const auto D(cin2var<int64_t>());
    const auto E(cin2var<int64_t>());

    int64_t  a = 0;
    uint64_t t = 0;
    for (a = A; a < 0; ++a) {
        t += C;
    }
    if (A <= 0) {
        t += D;
    }
    for (auto i = a; i < B; ++i) {
        t += E;
    }
    cout << t << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    sub();
    return 0;
}


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

int main()
{
  int k;
  cin >> k;
  int ans = 0;
  for (int i = 1; i <= k; i++)
  {
    for (int j = 1; j <= k; j++)
    {
      for (int l = 1; l <= k; l++)
      {
        ans += gcd(gcd(i, j), l);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3676
import math

x = int(input())

def Eratos(n):
    P,L = [],[True for _ in range(n+1)]
    for i in range(2,int(math.sqrt(n))+1):
        if L[i]:
            for j in range(2,n//i+1):
                L[i*j] = False
    for i in range(2,n+1):
        if L[i]:
            P.append(i)
    return P

def b_search(A,key,left,right):
    mid = (left+right)//2
    if key <= A[0]:
        return A[0]
    elif key > A[len(A)-1]:
        return 10**9
    else:
        if A[mid] < key and key <= A[mid+1]:
            return A[mid+1]
        elif key > A[mid]:
            return b_search(A,key,mid,right)
        else:
            return b_search(A,key,left,mid)

P = Eratos(10**6)
ans = b_search(P,x,0,len(P))
print(ans)


Measured memory_bytes: 14060
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint solve (int n, vector<lint> &a){
    lint ret = 0;
    priority_queue<lint> que;
    multiset<lint> a_num;
    set<lint> num;
    for (int i=0; i<n; ++i){
        a_num.insert(a[i]);
        num.insert(a[i]);
    }
    for (auto itr = num.begin(); itr != num.end(); ++itr){
        lint k = *itr;
        if(a_num.count(k) >= 4){
            que.push(k);
        }
        if(a_num.count(k) >= 2){
            que.push(k);
        }
    }
    if(que.size() < 2){
        ret = 0;
    }
    else {
        lint l1, l2;
        l1 = que.top();
        que.pop();
        l2 = que.top();
        que.pop();
        ret = l1 * l2;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<lint> a(n);
    for (int i=0; i<n; ++i){
        cin >> a[i];
    }
    cout << solve(n, a) << "\n";
    return 0;
}

Measured memory_bytes: 10368
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

#define MAX_V (200+2)

struct edge{int to,cap,rev;};

vector<edge> G[MAX_V];  //グラフのパス
int level[MAX_V];       //始点からの距離
int iter[MAX_V];        //どこまで調べたか

// fromからtoへ向かう、容量capの辺をグラフに追加する
void add_edge(int from,int to,int cap){
    G[from].push_back(  (edge){ to  ,cap,(int)G[to  ].size()   }  );
    G[to  ].push_back(  (edge){ from,0  ,(int)G[from].size()-1 }  );
}

// sからの最短距離をBFSで計算する
void bfs(int s){
    rep(i,MAX_V)level[i]=-1;
    queue<int> que;
    level[s]=0;
    que.push(s);
    while(!que.empty()){
        int v=que.front();que.pop();
        
        rep(i,G[v].size()){
            edge &e=G[v][i];
            if(e.cap>0 && level[e.to]<0){
                level[e.to]=level[v]+1;
                que.push(e.to);
            }
        }
    }
}

//増加パスをDFSで探す
int dfs(int v,int t,int f){
    if(v==t)return f;
    for(int &i=iter[v];i<G[v].size();i++){
        edge &e=G[v][i];
        if(e.cap>0&&level[v]<level[e.to]){
            int d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}

// sからtへの最大流を求める
int max_flow(int s,int t){
    if(s==t)return INF;
    int flow=0;
    for(;;){
        bfs(s);
        if(level[t]<0)return flow;
        memset(iter,0,sizeof(iter));
        int f;
        while((f=dfs(s,t,INF))>0){
            flow+=f;
        }
    }
}


int main(){
    int v,e,s,t;
    cin>>v>>e>>s>>t;
    s--,t--;
    
    
    int d[201][201], c[201][201], eg[201][201];
    rep(i,201)rep(j,201)d[i][j] = INF;
    rep(i,201)d[i][i] = 0;
    rep(i,201)rep(j,201)eg[i][j] = INF;
    
    rep(i,e){
        int u,v,dir,cost;
        cin>>u>>v>>dir>>cost;
        u--,v--;
        d[u][v] = dir;
        eg[u][v] = dir;
        c[u][v] = cost;
    }
    
    rep(k,v){
        rep(i,v){
            rep(j,v){
                d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    
    rep(i,v){
        rep(j,v){
            if(eg[i][j]!=INF){
                if( d[s][i]+eg[i][j] == d[s][j] ){
                    add_edge(i,j,c[i][j]);
                }
            }
        }
    }
    
    cout<<max_flow(s,t)<<endl;
    

}



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

const int offset = 1 << 20;
int st[2 * offset];
int in[offset];

int minimum(int a, int b) {
    a += offset;
    b += offset;

    int rv = 1e9 + 7;
    while(a <= b) {
        if(a % 2 == 1) rv = min(rv, st[a++]);
        if(b % 2 == 0) rv = min(rv, st[b--]);
        a /= 2; b /= 2;
    }
    return rv;
}


void add(int k, int x) {
    k += offset;
    st[k] = x;
    for(k /= 2; k >= 1; k /= 2) {
        st[k] = min(st[k * 2], st[k * 2 + 1]);
    }
}

int main() {
    int n, k;
    scanf("%d %d", &n, &k);

    for(int i = 0; i < n; i++) {
        scanf("%d", &in[i]);
        add(i, in[i]);
    }

    int maxx = 0;
    for(int i = 1; i < n; ++i) {
        int v = minimum(0, i - 1);
        if(in[i] - v > maxx) {
           maxx = in[i] - v;
        }
    }

    int res = 0;
    set< int> st;
    st.insert(in[0]);
    for(int i = 1; i < n; ++i) {
        if(st.count(in[i] - maxx)) res++;
        st.insert(in[i]);
    }
    printf("%d\n", res);
}

Measured memory_bytes: 11520
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
ll a, b, c,n, i, j, k,  m, t, arr[200005], ar[200005],arrr[200005],temp[200005];
bool cmp(const ll a, const ll b)
{
    return a > b;
}
int main() {
    string s;
    cin >> n >> m >> a >> b >> c;
    for (i = 0; i < a; i++)
        cin >> arr[i];
    for (i = 0; i < b; i++)
        cin >> ar[i];
    for (i = 0; i < c; i++)
        cin >> arrr[i];
    sort(arr, arr + a,cmp); sort(ar, ar + b,cmp); sort(arrr, arrr + c,cmp);
    ll sum = 0;
    j = 0;
    for (i = 0; i < n; i++)
        sum += arr[i],temp[j++]=arr[i];
    for (i = 0; i < m; i++)
        sum += ar[i],temp[j++]=ar[i];
    sort(temp, temp + j);
    for (i = 0; i < c; i++) {
        if (arrr[i] < temp[0])
            break;
    }
    c = i;
    for (i = 0; i < j; i++) {
        if (arrr[0] < temp[i])
            break;
    }
    b = i;
    b = b < c?b:c;
    ll maxn = 0,tem=0;
    for (i = 0; i < b; i++) {
        tem =tem+( arrr[i] - temp[i]);
        maxn = maxn > tem ? maxn : tem;
    }
    sum += maxn;
    /*b < c ? b : c; j = 0;
    sort(arrr, arrr + b);
    for (i = 0; i < b; i++)
    {
        if (temp[i] < arrr[j])
        {
            sum = sum - temp[i] + arrr[j];
            j++;
        }
        if (j == b)
            break;
    }*/
    cout << sum;
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();


// bool cmp(pair<int,int>p,pair<int,int>q) {
//     return p.first>q.first;//descending by first
//     return p.first<q.first;//ascending by first
//     return p.second>q.second;//descending by second
//     return p.second<q.second;//ascending by second
// }

bool cmp(int p,int q) {
    return p>q;//descending
    // return p<q;//ascending
}

int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }
    return 0;
}
int clue() {

    string s,t;
    cin>>s>>t;
    int n=t.size();
    t.erase(n-1,1);
    if(s==t) {cout<<"Yes"<<endl;}
    else {cout<<"No"<<endl;}
    // cout<<s<<" "<<t<<endl;
    return 0;
}

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

#define pb push_back
#define INF 1e9
#define mod 998244353
#define mod2 1000000007
#define dbg(x) cout << (#x) << " --> " << x << "\n";
#define dbgarr(y)                                                                                            \
  cout << (#y) << " --> " << '\n';                                                                           \
  for(auto& x : y) cout << x << '\n';
using namespace std;

typedef priority_queue<int, vector<int>, greater<int>> minPq;
typedef priority_queue<int> maxPq;
typedef long long ll;

void goodLuckHaveFun() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
/* clang-format off */
  #ifdef _DEBUG
  freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
  #endif
  /* clang-format on */
}

int dp[3001][3001];

int main() {
  goodLuckHaveFun();
  string s, t;
  cin >> s >> t;

  for(int i = 1; i <= s.length(); ++i) {
    for(int j = 1; j <= t.length(); ++j) {
      if(s[i - 1] == t[j - 1]) {
        dp[i][j] = dp[i - 1][j - 1] + 1;
      } else {
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
      }
    }
  }
  string res = "";
  int x      = s.length();
  int y      = t.length();

  while(dp[x][y] > 0) {
    if(s[x-1] == t[y-1]) {
      res += s[x-1];
      --x;
      --y;
    } else {
      if(dp[x-1][y] == dp[x][y]){
        x--;
      }else{
        y--;
      }
    }
  }
  cout << string(res.rbegin(),res.rend()) << '\n';
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
//#define MOD 1e9+7
using namespace std;
#define MOD 1000000007
long long int ar[200005];
int main()
{

    int n, k;
    cin >> n >> k;
    ar[0]=0;
    for(int i=1;i<=n;i++)
    {
        ar[i]=ar[i-1]+i;
    }
    /*for(int i=0;i<=n;i++)
    {
        cout << ar[i]  << " ";
    }*/
    //cout << endl;
    int ans=0;
    for(int j=k;j<=n+1;j++)
    {
        long long  p=(ar[n]-ar[n-j]);
      long long  int q=(ar[j-1]);
        //cout << p << " " << q << endl;
        p=(p-q)+1;
        //cout << p << endl;
        ans=((ans%MOD)+(p%MOD))%MOD;
    }
    cout << ans << endl;
     return 0;
}


Measured memory_bytes: 5196
def main():
    N = int(input())
    A = input().split()
    S = 0
    for n in range(N):
        A[n] = int(A[n])
        S += A[n]
    ans = S
    for n in range(N)[1::2]:
        ans -= 2 * A[n]
    prev = ans
    print(str(ans) + " ", end="")
    for n in range(N)[1:]:
        ans = 2 * A[n - 1] - prev
        prev = ans
        if n == N - 1:
            print(ans)
        else:
            print(str(ans) + " ", end="")

if __name__ == '__main__':
    main()


Measured memory_bytes: 11324
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define PI pair<int,int>
#define PL pair<long int,long int>
#define PLL pair<ll,ll>
#define Tcase int t;cin>>t;while(t--)
#define MOD 1000000007
ll sum=0;
int main(){
  int n,k;
  cin>>n>>k;
  ll first=0,last=0;
  for(int i=0;i<k;i++){
  first+=i;
  }
  for(int i=0;i<k;i++){
  last+=(n-i);
  }
  sum=((sum)%MOD+(last-first+1)%MOD)%MOD;
  //cout<<"wa      "<<first<<"  "<<last<<endl;
  for(int i=k+1;i<=n+1;i++){
        int f=i;
    first+=i-1;last+=n-i+1;
  /*for(int i=0;i<f;i++){
  first+=i;
  }
  for(int i=0;i<f;i++){
  last+=(n-i);
  }*/
  //cout<<"wa  "<<first<<"    "<<last<<"\n";
  sum=((sum)%MOD+(last-first+1)%MOD)%MOD;
  }
  cout<<sum<<"\n";
return 0;
}


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

int main()
{
	int n;
	cin >> n;
	if (n == 0)
	{
		cout << 1 << endl;
	}
	else if (n == 1)
	{
		cout << 2 << endl;
	}
	else if (n == 2)
	{
		cout << 1 << endl;
	}
	else
	{
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
(function(input) {
    var n = Number(input);
    var a = [];
    for (var i = 1; i <=n; i++) {
        if (i % 3 === 0) {
            a.push(i);
            continue;
        }
        var x = i;
        do {
            if (x % 10 === 3) {
                a.push(i);
                break;
            }
            x = Math.floor(x / 10);
        } while (x)
    }
    console.log(' ' + a.join(' '));
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 10068
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
set<ll> mp;
ll s[100000],a,b,c,d,ans,n;
int main(void){
    cin>>n;
    mp.insert(0);
    mp.insert(n+1);
    for(ll i=1;i<=n;i++){
        cin>>a;
        a--;
        s[a]=i;
    }
    for(ll i=n-1;i>=0;i--){
        mp.insert(s[i]);
        auto itr=mp.find(s[i]);
        auto itr2=itr;
        itr++;
        c=*itr;
        if(c==n+1)d=n+1;
        else {
            itr++;
            d=*itr;
        }
        itr2--;
        b=*itr2;
        if(b==0)a=0;
        else {
            itr2--;
            a=*itr2;
        }
        ans+=((d-c)*(s[i]-b)+(b-a)*(c-s[i]))*(i+1);
    }
    cout<<ans<<endl;
}


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

#define thegamebegins   ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define fileio          freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define int             long long
#define float           long double
#define test            int T; cin>>T; for(int i=1; i<=T; ++i)
#define in(a,n)         for(int i=0; i<(n); ++i)  cin>>a[i]
#define r0              return 0
#define E               "\n"
#define S               " "
#define elif            else if 
#define M               1000000007
#define fi(i,x,y)       for(int i=(x); i<(y); ++i)
#define fb(i,x,y)       for(int i=(x); i>=(y); --i)
#define fa(i,s)         for(auto i:(s))
#define fp(i,s)         for(auto i=(s).begin(); i!=(s).end(); ++i)
#define pf(i,s)         for(auto i=(s).rbegin(); i!=(s).rend(); ++i)
#define all(s)          (s).begin(), (s).end()
#define rev(s)          (s).rbegin(), (s).rend()
#define sz(s)           (int)(s).size()
#define vi              vector <int>
#define vpii            vector <pair <int,int> >
#define mii             map <int,int>
#define pii             pair <int,int>
#define seti            set <int>
#define setd            set <int,greater <int> >
#define sortd(a,n)      sort(a, a+n, greater<int>())
#define pb              push_back
#define fr              first
#define sc              second
#define lb              lower_bound
#define ub              upper_bound
#define er              equal_range
 
const int INF = 0x3f3f3f3f;

signed main()
{
    thegamebegins

    int k,a,b;  cin>>k>>a>>b;
    int first = (a/k)*k;
    if((first>=a && first<=b) || (first+k>=a && first+k<=b))    cout<<"OK";
    else    cout<<"NG";
    r0;
}


Measured memory_bytes: 3652
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

int in[3];
int main() {
	for (int i = 0; i < 3; i++) scanf("%d", &in[i]);
	sort(in, in + 3);
	return !printf("%d\n", in[2] - in[0]);
}

Measured memory_bytes: 256