akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main() {
  Cin(int, n);
  Cins(int, n, vi);
  Cins(int, n, ci);

  for (int i = 0; i < n; ++i) vi[i] = max(0, vi[i] - ci[i]);

  cout << accumulate(all(vi), 0) << endl;
}

int main() {
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

long a1045(long *a,long p,long g,int d,int n){
  long x,y;
  if(d==n) return (p>g)?(p-g):(g-p);

  x=a1045(a+1,p+a[0],g,d+1,n);
  y=a1045(a+1,p,g+a[0],d+1,n);
  return (x<y)?x:y;
}
int main(){
  long a[20];
  int i,n;
  while(scanf("%d",&n)){
    if(n==0) break;
    for(i=0;i<n;i++) scanf("%ld",&a[i]);
    printf("%ld\n",a1045(&a[0],0,0,0,n));
  }
  return 0;
}

Measured memory_bytes: 600
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.lang.Math;

public class Main {
	public static void main(String[] args) {
		FS reader = new FS();
		// write reader
		int a = reader.nextInt();
		int b = reader.nextInt();
      	if (a <= 5) b = 0;
        else if (a <= 12) b /= 2;
      	System.out.println(b);
	}
	
	public static void solver() {
		// write logic
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Measured memory_bytes: 21076
#include <stdio.h>
#include <stdlib.h>

int stack[100];
int top = 0;

bool isFull()
{
	if (top == 199) {
		return true;
	}
	return false;
}

bool isEmpty()
{
	if (top == -1) {
		return true;
	}
	return false;
}

int pop()
{
	if (isEmpty()) {
		printf("Stack is empty.\n");
		exit(EXIT_FAILURE);
	}
	return stack[--top];
}

void push(int x)
{
	if (isFull()) {
		printf("Stack is full.\n");
		exit(EXIT_FAILURE);
	}
	else {
		stack[top] = x;
		top++;
	}
}

int main(int argc, char** argv)
{
	char s[200];

	while (scanf("%s",s) != EOF)
	{
		if (s[0] == '+') {
			int x = pop();
			int y = pop();
			push(y + x);
		}
		else if (s[0] == '-') {
			int x = pop();
			int y = pop();
			push(y - x);
		}
		else if (s[0] == '*') {
			int x = pop();
			int y = pop();
			push(y * x);
		}
		else {
			int x = atoi(s);
			push(x);
		}
	}
	printf("%d\n", pop());

	return 0;
}

Measured memory_bytes: 2744
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy

def j(q):
    if q==1: print("Heisei")
    else:print("TBD")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())


#n = ip()                              #入力整数1つ
#h,w= (int(i) for i in input().split())      #入力整数横2つ
#n,x,y = (int(i) for i in input().split())    #入力整数横3つ
#n,a,b,c= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
l = len(a)
print(a[0],end='')
print(l-2,end='')
print(a[l-1])


Measured memory_bytes: 13604
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll a,b;
  cin>>a>>b;
  string s;
  cin>>s;
  bool judge=false;
  if(s[a]=='-'&&s.size()==a+b+1) judge=true;
  for(int i=0;i<a;i++){
    if(s[i]=='-') judge=false;
  }
  for(int i=a+1;i<a+b+1;i++){
    if(s[i]=='-') judge=false;
  }
  if(judge) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
char a[100001];
string k1="Second\n",k2="First\n";
int main(){
    int f=0;
    while(cin>>a){
        f=strlen(a);
        if(f%2){
            if(a[0]==a[f-1])
                cout<<k1;
            else cout<<k2;
        }
        else {
            if(a[0]==a[f-1])
                cout<<k2;
            else cout<<k1;
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

using P = pair<int, int>;
vvi adj;
vi score;
vi color;
map<P, i64> weight;
constexpr i64 INIT = -1e18;
 
bool hasScore = true;
bool isBipartite_ = false;
 
void dfsColor(int v, int c) {
    if (color[v] != -1) {
        if (color[v] != c) {
            isBipartite_ = true;
        }
        return;
    }
    color[v] = c;
    for (int a: adj[v]) {
        dfsColor(a, !c);
    }
}
 
bool isBipartite() {
    dfsColor(0, 0);
    return isBipartite_;
}
 
i64 illegalScoreDif;
 
void dfsScore(int v, i64 s) {
    // update hasScore
    if (score[v] != INIT) {
        if (score[v] != s) {
            illegalScoreDif = abs(score[v] - s);
            hasScore = false;
            return;
        }
        return;
    }
    score[v] = s;
    for (int a: adj[v]) {
        dfsScore(a, weight[P(v,a)] - s);
    }
}
 
int main() {
    int n, m;
    cin >> n >> m;
    adj = vvi(n);
    score = vi(n, INIT);
    color = vi(n, -1);
    for (int i = 0; i < m; i++) {
        int u, v, s;
        cin >> u >> v >> s;
        u--;
        v--;
        weight[P(u,v)] = s;
        weight[P(v,u)] = s;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    
    if (!isBipartite()) {
        dfsScore(0, 0);
        if (hasScore) {
            vi blackScores, whiteScores;
            for (int i = 0; i < n; i++) {
                if (color[i] == 0) {
                    blackScores.push_back(score[i]);
                } else {
                    whiteScores.push_back(score[i]);
                }
            }
            sort(blackScores.begin(), blackScores.end());
            sort(whiteScores.begin(), whiteScores.end());
            i64 toAdd = 1 - blackScores.front();
            i64 maxScore = whiteScores.front() - toAdd;
            if (maxScore < 1) {
                cout << 0 << endl;
            } else {
                cout << maxScore << endl;
            }
        } else {
            cout << 0 << endl;
        }
    } else {
        dfsScore(0, 0);
        hasScore = true;
        score = vi(n, INIT);
        if (illegalScoreDif % 2 == 1) {
            cout << 0 << endl;
            return 0;
        }
        dfsScore(0, illegalScoreDif / 2);
        if (hasScore) {
            for (int i = 0; i < n; i++) {
                if (score[i] < 1) {
                    cout << 0 << endl;
                    return 0;
                }
            }
            cout << 1 << endl;
        } else {
            cout << 0 << endl;
        }
    }
}


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

using namespace std;

int main(){

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

    while( true ){

        int n, a, b, c, x;
        
        cin >> n >> a >> b >> c >> x;

        if(n == 0 && a == 0 && b == 0 && c == 0 && x == 0)
            break;

        vector<int> y(n);
        for( auto &x : y )
            cin >> x;

        int index = 0;

        for(int i = 0;i < 10001; i++) {

            if( y[index] == x )
                index++;

            if(index == n){
                cout << i << endl;
                break;
            }

            x = (a * x + b) % c;

        }

        if(index != n)
            cout << -1 << endl;

    }

    return 0;

}


Measured memory_bytes: 3156
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int count = 0;
    string s1;
    string s2;
    cin >> s1;
    cin >> s2;
    int n = s1.length();
    for (int i=0;i<n;i++){
        if(s1[i] != s2[i]){
            count ++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3912
n_book_a, n_book_b, limit_time = map(int, input().split(" "))
read_time_a = [int(i) for i in input().split(" ")]
read_time_b = [int(i) for i in input().split(" ")]

read_sum_time_a = [0]  # 1冊も読まないパターン
for i in range(n_book_a):
    read_sum_time_a.append(read_sum_time_a[i] + read_time_a[i])
    
read_sum_time_b = [0]  # 1冊も読まないパターン
for i in range(n_book_b):
    read_sum_time_b.append(read_sum_time_b[i] + read_time_b[i])

# print(read_sum_time_a)
# print(read_sum_time_b)

ans = 0
i_b = n_book_b  # 数が大きい方から一通り確認していく
for i_a, time_a in enumerate(read_sum_time_a):
    # print(time_a)
    # read_sum_time_aがlimit_time以下の場合についてのみ調べる
    if time_a > limit_time:
        break
    else:     
        while read_sum_time_b[i_b] + time_a > limit_time:
            i_b += -1
            # i_a + i_bがansより大きいと気に更新をサラッと書くとこうなる(i_a, i_bはA, Bの冊数)
        ans = max(ans, i_a + i_b)
        # print(f"ans: {ans}")
    
print(ans)


Measured memory_bytes: 47556
#include <iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1<<30;
const int mod=1000000007;    
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int n,k,dist[4001],cnt;
vector<int> v[4001];

void dfs(int x){
  if(dist[x]>k&&x<n)cnt++;
  rep(i,v[x].size()){
    int next=v[x][i];
    if(dist[next]==inf){
      dist[next]=dist[x]+1;
      dfs(next);
      }
    }
  }
  
int main(){
  cin>>n>>k;
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    v[a].push_back(n+i);
    v[n+i].push_back(a);
    v[n+i].push_back(b);
    v[b].push_back(n+i);
    }
  int ans=inf;
  rep(i,2*n-1){
    rep(i,2*n-1)dist[i]=inf;
    cnt=0;
    dist[i]=0;
    dfs(i);
    ans=min(ans,cnt);
    }
  cout<<ans<<endl;
  return 0;  
  }


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <map>
using namespace std;
map<string,int> table;
int main()
{
    string word,frequent,longest;;
    size_t N = 0;
    while(cin >> word)
    {
        table[word]+=1;
        if(table[word]>N)
        {
            N = table[word];
            frequent = word;
        }
        if(word.size()>longest.size())
            longest=word;
    }
    cout << frequent << " " << longest << endl;
}


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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << fixed;
    int n;
    cin >> n;
    V<ll> v;
    ll ans = 0;
    for (int ph = 0; ph < n; ph++) {
        ll a, b;
        cin >> a >> b;
        v.push_back(a + b);
        ans -= b;
    }
    sort(v.begin(), v.end(), greater<>());
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) ans += v[i];
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define __ <<' '<<
#define ___ <<' '
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {IoSetup() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout <<fixed<<setprecision(12);
    cerr <<fixed<<setprecision(12);
}}IoSetup;

using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,1,0,-1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    string s;
    cin >> s;

    for(int i = 0; i < s.size(); i++) {
        if(s[i] == '?')
            cout << 'D' ;
        else
            cout << s[i];
    }

  
    return 0;
}



Measured memory_bytes: 3796
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector
//#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	string a,b;
	cin>>a>>b;
	int len1=a.length();
	int len2=b.length();
	string k="";
	if(len1==len2){
		if(a==b) cout<<"EQUAL"<<endl;
		else{
			if(a<b) cout<<"LESS"<<endl;
			else cout<<"GREATER"<<endl;
		}
	}else{
		if(len1>len2) cout<<"GREATER"<<endl;
		else cout<<"LESS"<<endl;
	}



return 0;
}


Measured memory_bytes: 256
n = int(input())
h = []

h = list(map(int, input().split()))

count = 0
count_list = [0]

for i in range(n-1):
	if(h[i+1] <= h[i]):
		count += 1
		count_list.append(count)
	else:
		count = 0

print(max(count_list))

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
   	#endif
    int n;
    cin>>n;
    int temp=n;
    int sum=0;
    while(temp>0){
    	sum+=temp%10;
    	temp/=10;
    }
    cout<<((n%sum==0)?"Yes":"No");
   return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>
int main(void)
{
	int S,h,m,s;
	scanf("%d" , &S);
	h = S/3600;
	m = (S-3600*h)/60;
	s = S-3600*h-60*m;
	printf("%d:%d:%d\n",h,m,s);
	
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    double v[n];

    for(int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(v, v + n);
    double ans = (v[0] + v[1]) / 2;

    for(int i = 1; i < n - 1; i++) {
        ans = (ans + v[i + 1]) / 2;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
   
public class Main {
    public static void main( String args[] ) {
        Scanner scan = new Scanner( System.in );
          
        double a				= scan.nextDouble();
        double b				= scan.nextDouble();
        double C				= scan.nextDouble();
		final double radianC	= Math.toRadians( C );
		final double ab				= a * b;
          
        final double sinC = Math.sin( radianC );
        final double cosC = Math.cos( radianC );
          
          
        // S
        double S = ab * sinC / 2;
          
        // L
        double L = a + b + Math.sqrt( a * a + b * b - 2 * ab * cosC );
          
        // h
        double h = b * sinC;
          
        System.out.print(S + "\n" + L + "\n" + h + "\n");
          
    }
      
}

Measured memory_bytes: 18188
import java.util.*;

public class Main {
    static int modP = 1000000007;
    static long inf  = 1 << 61;
    static int[] x4 = {-1, 0, 0, 1};
    static int[] y4 = {0, -1, 1, 0};

    static int[] a;

    public static void main(String[] args) {
        input();
        solve();
    }

    static void solve() {
       Arrays.sort(a);
       int ans = 0;
       for(int i = 2; i >= 1; i--) {
           ans += a[i-1] - a[i];
       }
       print(Math.abs(ans));
    }

    static void input() {
        Scanner in = new Scanner(System.in);
        a = new int[3];
        a[0] = in.nextInt();
        a[1] = in.nextInt();
        a[2] = in.nextInt();
    }

    static void print(String s) {
        System.out.println(s);
    }

    static void print(char c) {
        System.out.println(c);
    }

    static void print(int i) {
        System.out.println(i);
    }

    static void print(long i) {
        System.out.println(i);
    }

    static void print(float i) {
        System.out.println(i);
    }

    static void printArray2D(int[][] array, char del) {
        int r = array.length;
        int c = array[0].length;
        for(int i = 0; i < r; i++) {
            for(int j = 0; j < c; j++) {
                System.out.format("%3d", array[i][j]);
                if(j != c-1) System.out.print(del);
                else System.out.print('\n');
            }
        }
    }
}

Measured memory_bytes: 24020
LEN = 100005

n, q = map(int, input().split())
name = [None] * LEN
time = [None] * LEN

for i in range(n):
  name[i], time[i] = map(str, input().split())

head = 0
tail = n
curr = 0
done = 0

while True:
  if int(time[head]) > q:
    name[tail] = name[head]
    time[tail] = int(time[head]) - q
    curr += q

    if LEN == head + 1:
      head = 0
    else:
      head += 1

    if LEN == tail + 1:
      tail = 0
    else:
      tail += 1
    
  else:
    # Process done
    done += 1
    curr += int(time[head])
    print("{} {}".format(name[head], curr))

    if (done == n):
      break

    if LEN == head + 1:
      head = 0
    else:
      head += 1



Measured memory_bytes: 12896
C = 'abcdefghijklmnopqrstuvwxyz'
N = int(input())
def dfs(s):
  l = len(s)
  if l >= N:
    print(s)
    return
  for i in range(l+1):
    if len(set(s)) < i:
      continue
    dfs(s+C[i])
dfs('')

Measured memory_bytes: 51288
import bisect

def search_idx_options(input_list, input_list_len, target_val):
  idx_left = bisect.bisect_left(input_list, target_val)
  if idx_left == -1: idxs = [0]
  elif  idx_left == input_list_len: idxs = [input_list_len-1]
  else: idxs = [idx_left-1, idx_left]
  return idxs

A,B,Q = map(int,input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]

for x in [int(input()) for _ in range(Q)]:
  ans_list = []

  for s_idx in search_idx_options(S, A, x):
    if s_idx >= A: continue
    for t_idx in search_idx_options(T, B, S[s_idx]):
      if t_idx >= B: continue
      ans_list.append(abs(x-S[s_idx]) + abs(S[s_idx]-T[t_idx]))

  for t_idx in search_idx_options(T, B, x):
    if t_idx >= B: continue
    for s_idx in search_idx_options(S, A, T[t_idx]):
      if s_idx >= A: continue
      ans_list.append(abs(x-T[t_idx]) + abs(T[t_idx]-S[s_idx]))
 
  print(min(ans_list))

Measured memory_bytes: 94168
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    int n;
    cin>>n;
    int ans=0;
for(int i=1;i<=n;i++){
    if(i<10)ans++;
    else if(i>=100&i<1000)ans++;
    else if(i>=10000&&i<100000)ans++;


}

cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ld double
#define ll long long
#define all(x) x.begin(),x.end()
const int mod=1e9+7;
#define fi first
#define se second
#define sync  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf (ll)1e16

const ld pi=(4.0*atan(1));
ll n;
vector<pair<ll,ll>> v;

ll po(ll x,ll y,ll md=mod){
    ll res=1;
    x%=md;
    
    while(y>0){
        if (y&1){
            res=(res*x)%md;
        }
        
        y>>=1;
        x=(x*x)%md;
    }
    return res;
}
void solve(){
   string s,t;
   cin>>s>>t;
   t=t.substr(0,(ll)s.size());
   
   if (s==t){
       cout<<"Yes\n";
   }
   else
   cout<<"No\n";
   
}

int main() {
    
    sync
    ll tt=1;
    //cin>>tt;
    cout<<fixed<<setprecision(12);
    for (ll tc=1;tc<=tt;tc++){
       solve();
    }
    
	return 0;
}

Measured memory_bytes: 3648
#[allow(unused_imports)]
use std::cmp;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let a: usize = sc.read();

    let ans = a + a * a + a * a * a;
    println!("{}", ans);
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define FI first
#define SE second
#define MP make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;
typedef pair < ll , ll > pll;

const double PI = acos(-1);
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;
const int INF = 1e9;
	

ll addMod(ll a, ll b){
	if(a + b >= MOD) return a + b - MOD;
	return a + b;
}

ll mulMod(ll a, ll b){
	return (a*b)%MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a,b/2);
	tmp = mulMod(tmp,tmp);
	if(b%2 == 1) tmp = mulMod(tmp,a);
	return tmp;
}

ll GCD(ll a, ll b){
	if(a > b) return GCD(b,a);
	if(a == 0) return b;
	return GCD(b%a,a);
}

//////////////////////////////////////////////



int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	cout << n * (n + 1) / 2 << endl;
	return 0;
}

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

int main()
{
  int n;
  cin >> n;
  int ans = 0;
  int a[n];
  rep(i, n) cin >> a[i];
  rep(i, n){
    if((i + 1) % 2 && a[i] % 2) ans++;
  }
  cout << ans << endl;

  return 0;
}


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

int main(){
  unsigned long long n;
  cin>>n;
  string s;
  while(n){ //nが1以上
     n--;
     s+='a'+(n%26);
     n/=26;
  }
  reverse(s.begin(),s.end());
  cout<<s<<endl;
}


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

using namespace std;

int main()
{
    int N;
    while (cin >> N, N) {
        vector<int> a(N), b(N);
        for (int i = 0; i < N; i++) {
            cin >> a[i];
        }
        for (int i = 0; i < N; i++) {
            cin >> b[i];
        }
        
        sort(a.rbegin(), a.rend());
        sort(b.rbegin(), b.rend());
        
        bool found = 0;
        int aw = 0, bw = 0, bidx = 0;
        for (int i = 0; i < N-1; i++) {
            if (a[i] > b[bidx]) {
                aw++;
            } else {
                bw++;
                bidx++;
            }
            if (aw > bw) {
                found = 1;
                cout << i+1 << endl;
                break;
            }
        }
        if (!found) {
            cout << "NA" << endl;
        }
    }        
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll N,L,T;
ll x[100010],d[100010];
vector<ll> res;

int main(){
  cin>>N>>L>>T;
  ll R=T%L;
  rep(i,N)cin>>x[i]>>d[i];
  ll cnt=0;
  rep(i,N){
    if(d[i]==1){
      res.push_back((x[i]+R)%L);
      cnt+=T/L;
      if(L-x[i]<R)cnt++;
    }else{
      res.push_back((x[i]-R+L)%L);
      cnt-=T/L;
      if(x[i]<R)cnt--;
    }
  }
  cnt%=N;
  if(cnt<0)cnt+=N;
  sort(all(res));
  rep(i,N){
    cout<<res[(i+cnt)%N]<<endl;
  }
  return 0;
}


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

using namespace std;

using ll = long long;

int main() {
  string s;
  cin >> s;
  unordered_map<char, bool> mp;
  for (const auto &c : s) {
    mp[c] = 1;
  }
  if (mp['S'] == mp['N'] && mp['E'] == mp['W'])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a[ohara],b[ohara],c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
pair<ll,ll> p[ohara];

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    rep(i,n){
        cin>>a[i]>>b[i];
        p[i]=make_pair(a[i]+b[i],i);
    }
    sort(p,p+n);
    reverse(p,p+n);
    rep(i,n){
        if(i%2==0)tmp+=a[p[i].second];
        else tmpp+=b[p[i].second];
    }
    Cout(tmp-tmpp);
    return 0;
}


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

char a[3][3];

int main()
{
    int i, j;

    for(i=1; i<=3; i++)
        for(j=1; j<=3; j++)
            cin >> a[i][j];

    cout << a[1][1] << a[2][2] << a[3][3];
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    ll N, M; cin >> N >> M;
    if(N == 1 && M == 1) cout << 1 << endl;
    else if(N == 1 || M == 1) cout << max(N, M) - 2 << endl;
    else if(N <= 2 || M <= 2) cout << 0 << endl;
    else cout << (N - 2) * (M - 2) << endl;
}


Measured memory_bytes: 256
s=input()

N=len(s)
g=0
p=0
w=0
l=0

for i in range(N):
    if g==p:
        g+=1
        if s[i]=="p":
            l+=1
    else:
        p+=1
        if s[i]=="g":
            w+=1
print(w-l)

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

typedef long long ll;
typedef unsigned long long ull;

const int INF = 999999999;

int main(){
   int a,b,c;cin >> a>>b>>c;
   cout << (b/a<=c?b/a:c);
   return 0;
}

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

int main(){
    int n, in;
    vector <int> val;

    cin >> n;
    for( int i = 0; i < n; i++ ){
        cin >> in;
        val.push_back( in );
    }
    int max = val[ 1 ] - val[ 0 ];
    int min = val[ 0 ];
    for( int i = 0; i < n - 1; i++ ){
        if( max <= val[ i + 1 ] - min ){
            max = val[ i + 1 ] - min;
        }
        if( min >= val[ i + 1 ] ){
            min = val[ i + 1 ];
        }
    }

    cout << max << endl;

    return 0;
}



Measured memory_bytes: 3928
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <complex>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define EQ(a,b) (abs((a)-(b))<eps)

using namespace std;

typedef long double ld;
typedef complex<ld> P;
typedef vector<P> VP;
const ld eps = 1e-8, pi = acos(-1.0);

ld dot (P a, P b) { return real(conj(a) * b); }
ld cross (P a, P b) { return imag(conj(a) * b); }

namespace std {
  bool operator<(const P &lhs, const P &rhs) {
    return lhs.real() == rhs.real() ? lhs.imag() < rhs.imag() : lhs.real() < rhs.real();
  }
}

struct sq {
  P p;
  ld sz;
  sq(P p_, ld sz_) : p(p_), sz(sz_) {}
};

bool operator<(const sq& l, const sq& r) { return l.p < r.p; }

pair<int, int> f(const VP& vp, sq s) {
  ld margin = s.sz / sqrt(2.0);
  P c = s.p + P(s.sz / 2.0, s.sz / 2.0);
  int mx = 0;
  int mn = 0;
  for(P p : vp) {
    if(abs(p-c) <= 1 + margin) {
      ++mx;
      if(abs(p-c) <= 1 - margin) {
        ++mn;
      }
    }
  }
  return make_pair(mx, mn);
}

int calc(const VP& vp) {
  std::priority_queue<pair<int, sq>> q;
  int mx_of_mn = 0;
  sq start(P(), 10.0);
  q.push(make_pair(f(vp,start).first, start));
  while (!q.empty()){
    auto p = q.top(); q.pop();
    if (mx_of_mn >= p.first) return mx_of_mn;
    REP(i,2)REP(j,2){
      P c = p.second.p + P(i * p.second.sz / 2, j * p.second.sz / 2);
      sq ns(c, p.second.sz / 2);
      auto rng = f(vp, ns);
      mx_of_mn = max(mx_of_mn, rng.second);
      q.push(make_pair(rng.first, ns));
    }
  }
  return mx_of_mn;
}

int main() {
  while(1){
    int n;
    cin >> n;
    if(!n) break;
    VP vp;
    REP(i,n){
      ld x,y;
      cin >> x >> y;
      vp.emplace_back(x,y);
    }
    cout << calc(vp) << endl;
  }
  return 0;
}

Measured memory_bytes: 1416
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<string>
#define LL long long
#define li i<<1
#define ri i<<1|1
using namespace std;
inline LL read()
{
    char c=getchar();LL x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
const int maxn=1e6+5;
int n,m,a[maxn],pos[maxn],ans[maxn],num[maxn],res;
struct Q{
	int i,l,r;
}q[maxn];  // 询问
// 添加 

bool cmp(Q a,Q b){
	return pos[a.l]==pos[b.l]?a.r<b.r:a.l<b.l;
}
int main()
{
	n=read(); // n个数 
	m=read(); // m个询问 
	int size=sqrt(n); // 块的大小
	for(int i=1;i<=n;++i){
		a[i]=read();
		pos[i]=i/size;  // 分块 
	}
//	m=read();
	for(int i=1;i<=m;++i){ // 查询 
		q[i].l=read();
		q[i].r=read();
		q[i].i=i;
	}
	sort(q+1,q+m,cmp); // 根据块排序 
	int l=q[1].l,r=q[1].l-1;  // l=1,r=0
	// 莫队核心 扩展答案 
	for(int i=1;i<=m;++i){
		while(q[i].l<l) res+=!num[a[--l]]++;
		while(q[i].l>l) res-=!--num[a[l++]];
		while(q[i].r<r) res-=!--num[a[r--]];
		while(q[i].r>r) res+=!num[a[++r]]++;
		ans[q[i].i]=res;
	}
	// 输出答案 
	for(int i=1;i<=m;++i)
		printf("%d\n",ans[i]);
	return 0;
}



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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int N;
  cin>>N;
  vector<ll>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  vector<ll>m(200001);
  for(int i=0;i<N;i++)m[A[i]]++;
  vector<ll>less(N);
  for(int i=0;i<N;i++)less[i]=m[A[i]]-1;
  ll sum=0;
  for(int i=0;i<=200000;i++){
    sum+=(m[i]*(m[i]-1))/2;
  }
  for(int i=0;i<N;i++){
    cout<<sum-less[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include <math.h>

using namespace std;
//for (int i = 0; i < N; i++){}

long long N, M;
bool vis[8];
int graph[8][8];
int cnt = 0;
int res = 0;

int dfs(int x){
    if(vis[x] == true) return 0;
    cnt++;
    if(cnt == N){
        res++;
        cnt--;
        return 0;
    }

    vis[x] = true;

    for(int i=0;i<N;i++){
        if(graph[x][i] == 1){
            dfs(i);
        }
    }
    vis[x] = false;
    cnt--;
}

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

    int a[M], b[M];
    int x, y;
    for (int i = 0; i < 8; i++){
        for (int j = 0; j < 8; j++){
            graph[i][j] = 0;
        }
    }
    for (int i = 0; i < M; i++){
        cin >> x >> y;
        graph[x-1][y-1] = 1;
        graph[y-1][x-1] = 1;
    }
    dfs(0);
    cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
    int ans=1000;
    char s[11];
    scanf("%s",s);
    for(int i=2;i<strlen(s);i++){
        int tmp=(s[i-2]-'0')*100+(s[i-1]-'0')*10+(s[i]-'0');
        if(ans>abs(tmp-753)) ans=abs(tmp-753);
    }
    printf("%d",ans);
}

Measured memory_bytes: 128
#include <deque>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int n, m, k; cin >> n >> m >> k;
    long long a[n]; for (int i = 0; i < n; i++) cin >> a[i];
    long long dp[2][n];
    int cur = 0, prev = 1;
    for (int i = 0; i < n; i++) dp[prev][i] = a[i];
    for (int kk = 1; kk < k; kk++) {
        deque<pair<int, long long> > deq;
        for (int i = kk; i < n; i++) {
            while (!deq.empty() && deq.front().first < i-m) deq.pop_front();
            while (!deq.empty() && deq.back().second <= dp[prev][i-1]) deq.pop_back();
            deq.push_back({i-1, dp[prev][i-1]});
            dp[cur][i] = deq.front().second + a[i]*(kk+1);
        }
        swap(prev, cur);
    }
    cout << *max_element(dp[prev]+k-1, dp[prev+1]) << endl;
}


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

int main() {
    int N;
    cin >> N;
    
    int result = 0;
    for(int i = 0; i < N; i++)
    {
        int l,r;
        cin >> l >> r;
        result += r - l + 1;
    }
    cout << result << endl;
}


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

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;




const int INF = 1000000;
const int mod = 1e9 + 7;


string calc(int n){
	string ret = "";
	for(int i=0; i<5; i++){
		ret += (char)('0' + n % 2);
		n /= 2;
	}
	reverse(all(ret));
	return ret;
}

int main(){
	map<char,string> m;
	rep(i,26) m[(char)('A' + i)] =calc(i);
	m[' '] = calc(26);
	m['.'] = calc(27);
	m[','] = calc(28);
	m['-'] = calc(29);
	m['\''] = calc(30);
	m['?'] = calc(31);
	map<string,char> mm;
	mm["101"] = ' ';
	mm["000000"] = '\'';
	mm["000011"] = ',';
	mm["10010001"] = '-';
	mm["010001"] = '.';
	mm["000001"] = '?';
	mm["100101"] = 'A';
	mm["10011010"] = 'B';
	mm["0101"] = 'C';
	mm["0001"] = 'D';
	mm["110"] = 'E';
	mm["01001"] ='F';
	mm["10011011"] = 'G';
	mm["010000"] = 'H';
	mm["0111"] = 'I';
	mm["10011000"] = 'J';
	mm["0110"] = 'K';
	mm["00100"] = 'L';
	mm["10011001"] = 'M';
	mm["10011110"] = 'N';
	mm["00101"] = 'O';
	mm["111"] = 'P';
	mm["10011111"] = 'Q';
	mm["1000"] = 'R';
	mm["00110"] = 'S';
	mm["00111"] = 'T';
	mm["10011100"] = 'U';
	mm["10011101"] = 'V';
	mm["000010"] = 'W';
	mm["10010010"] = 'X';
	mm["10010011"] = 'Y';
	mm["10010000"] = 'Z';
	string s;
	while(getline(cin,s)){
		string t ="";
		for(int i=0; i<s.size(); i++){
			t+=m[s[i]];
		}
		string ans = "";
		for(int i=0; i<t.size(); i++){
			int j=i;
			string str ="";
			while(mm[str] ==  (char)0 && j<t.size()) str += t[j++];
			//cout<<mm[str]<<endl;
			if(mm[str] != 0) ans += mm[str];
			i=j-1;
		}
		cout<<ans<<endl;
	}

}

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

void chmax(ll& a, ll b) { a = max(a, b); }
void chmin(ll& a, ll b) { a = min(a, b); }

using P = pair<int, int>;

const int MAX_N = 1e5+5;
const int INF = 1001001001;

vector<int> a, ans;
vector<int> to[MAX_N];
int dp[MAX_N];

ll modnum = 1e9+7;

using Graph = vector<vector<int>>;
Graph G(MAX_N);

ll dfs(int k, int now, int from=-1) {
    if(k < G[now].size()) {
        // 色が足りない場合は作れない
        return 0;
    }

    
    int use_num;
    if(from == -1) {
        // 根だけは特別
        use_num = k-1;
    } else {
        use_num = k-2;
    }
    
    ll case_num=1;
    for(auto e : G[now]) {
        // 親には戻らない
        if(e == from) continue;

        // kPcを求める部分
        // kはuse_numでループ毎に-1していく
        // cは色の数でなく、この頂点からの子の数(つまりこの頂点からの辺から親への辺を引いた数ということ)
        case_num *= use_num;
        use_num--;
        case_num %= modnum;

        // さらに子へと進む
        case_num *= dfs(k, e, now);
        case_num %= modnum;
    }
    return case_num;
}

int main() {
    int n,k; cin >> n >> k;
    rep(i, n-1) {
        int a,b; cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    ll ans = k*dfs(k,0);
    ans %= modnum;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 13952
#include <iostream>

 

using namespace std;

 

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


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

int main() {

	int nums[2][3000];

	int i = 0;

	int x, y;

	while (true) {

		cin >> x >> y;

		if (x == 0 && y == 0) break;

		if (x > y) {
			nums[0][i] = y;
			nums[1][i] = x;
		}
		else {
			nums[0][i] = x;
			nums[1][i] = y;
		}
		i++;
	}

	for (int j = 0; j < i; j++) {
		cout << nums[0][j] << " " << nums[1][j] << endl;
	}

	return 0;
}


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

const int MAX_N = 1e5+10;
int N, M;
int A[MAX_N];

void solve()
{
	priority_queue<double> prices;
	for(int i=0;i<N;++i) prices.push(A[i]);
	for(int i=0;i<M;++i){
		double cur = prices.top(); prices.pop();
		prices.push(cur/2);
	}
	ll ans = 0;
	while(!prices.empty()){
		ans += floor(prices.top());
		prices.pop();
	}
	cout << ans << endl;
}

int main()
{
	cin >> N >> M;
	for(int i=0;i<N;++i)cin >> A[i];
	solve();
	return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

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

int main()
{
    cout << fixed << setprecision(15);
    string S;
    cin >> S;

    if(S[0] == '9'){
        cout << "Yes" << endl;
        return 0;
    }
    if(S[1] == '9'){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

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

int main(){
    int n, alice = 0, bob = 0;
    cin >> n;
    vector<int> vec;
    for(int i = 0; i < n; i++){
        int c;
        cin >> c;
        vec.push_back(c);
    }
    sort(vec.rbegin(), vec.rend());
    for(int i = 0; i < n; i++){
        if(i % 2 == 0) alice += vec[i];
        else bob += vec[i];
    }
    cout << alice - bob << endl;
    return 0;
}

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

int main()
{
	int n,i,A=0,B=0;
	cin>>n;
	int a[n+1];
	
	for(i=1;i<=n;i++)
	    cin>>a[i];
	    
	sort(a+1,a+n+1);
	
	for(i=1;i<=n;i++)
	{
		if(i%2==0) B+=a[i];
		else A+=a[i];
	}
	
	if(A>B)
	   cout<<A-B;
	else
	   cout<<B-A;
	   
	return 0; 
}

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

using namespace std;

map<string, int> words;

vector<string> A;

int main()
{
    int n; cin >> n;
    int id = 0;
    for (int i = 0; i < n; i++)
    {
        string a; cin >> a;
        words[a]++;
        id = max(id, words[a]);
    }

    for (map<string,int>::iterator it = words.begin(); it != words.end(); ++it)
    {
        if (it->second == id)
            A.push_back(it->first);
    }

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

    for (int i = 0; i < A.size(); i++)
        cout << A[i] << endl;

    return 0;
}


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

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >
#define smaller_queue_p  priority_queue <pll, vector<pll>, greater<pll> >
//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    bool yes = true;
    if (s[0] != 'A') yes = false;
    string t = s.substr(2);
    t.erase(t.end() - 1);
    int cnt = 0;
    for (auto c : t) if (c == 'C') cnt++;
    if (cnt != 1) yes = false;
    for (auto c : s) {
        if (c == 'A' || c == 'C') continue;
        if (c < 'a' || c > 'z') yes = false;
    }
    if (s[1] == 'C') yes = false;
    if (*(s.end() - 1) == 'C') yes = false;
    cout << (yes ? "AC" : "WA") << endl;
    return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int t[100005];
int x[100005];
int y[100005];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d%d",&t[i],&x[i],&y[i]);
	}
	int xx=0,yy=0,tt=0;
	bool flag=true;
	for(int i=0;i<n;i++){
		int v=abs(x[i]-xx)+abs(y[i]-yy);
		if(v>t[i]-tt)flag=false;
		else{
			int rest=t[i]-tt-v;
			if(rest%2==1)flag=false;
		}
		tt=t[i];
		xx=x[i];
		yy=y[i];
	}
	printf("%s\n",flag?"Yes":"No");
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;
const int MAX = 510000;
const int MOD = 1000000007;

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();
    int n, k;
    cin >> n >> k;
    rep(i, 1, k + 1)
    {
        ll ans = COM(n - k + 1, i);
        ans *= COM(k - 1, i - 1);
        ans %= MOD;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 12160