akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    int N,A,B;
    cin >> N >> A >> B;
    int border=A+B;
    string S;
    cin >> S;
    int pass=0;
    int fo=1;
    rep(i,N){
        if(S[i]=='a'){
            if(pass<border){
                pass++;
                cout << "Yes" << endl;
                continue;
            }
        }
        else if(S[i]=='b'){
            if(pass<border && fo<=B){
                fo++,pass++;
                cout << "Yes" << endl;
                continue;
            }
        }
        cout << "No" << endl;
    }
}

Measured memory_bytes: 848
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

struct FastIO
{
  FastIO() {
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(0); 
  }
} fastio;


#define dump1(v) for(auto i:v) std::cout << i << ' '; std::cout << "\n";
#define dump2(v) for(auto i:v) { for(auto j:i) std::cout << j << ' '; std::cout << "\n"; }


struct Edge
{
	int a,b,c;
	Edge(int a,int b,int c) : a(a),b(b),c(c) {}
	bool operator<(const Edge e)const{ return c<e.c; }
};
using Graph = std::vector<std::vector<Edge> >;
using n_node = std::pair<int, int>; // cost, int
struct Dijkstra
{
	const int INF = 1e16;
	std::vector<int> dist;
	Dijkstra(Graph& g, int s) : dist(g.size(),INF) {
		std::priority_queue<n_node,std::vector<n_node>,std::greater<n_node> > next;
		next.emplace(0,s);
		while(!next.empty()) {
			auto t = next.top(); next.pop();
			int i=t.second;int cost=t.first;
			if(dist[i]!=INF) continue;
			dist[i] = cost;
			for(auto e:g[i]) {
				next.emplace(cost+e.c,e.b);
			}
		}
	}
};

signed main() {
	int n,m,s,t;
	std::cin >> n >> m >> s >> t;
	s--;t--;
	Graph ga(n);
	Graph gb(n);
	rep(i,m) {
		int u,v,a,b;
		std::cin >> u >> v >> a >> b;
		u--;v--;
		ga[u].emplace_back(u,v,a); ga[v].emplace_back(v,u,a);
		gb[u].emplace_back(u,v,b); gb[v].emplace_back(v,u,b);
	}
	Dijkstra da(ga,s),db(gb,t);

	std::vector<int> min_reduce(n);
	int min = da.dist[n-1]+db.dist[n-1];
	min_reduce[n-1] = min;
	for(int i=n-2;i>=0;i--) {
		min = std::min(min,da.dist[i]+db.dist[i]);
		min_reduce[i] = min;
	}

	const int start = 1e15;

	rep(i,n) print(start-min_reduce[i]);

	return 0;
}


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
            line = line.OrderByDescending(o => o).ToArray();
            var first = int.Parse(line[0].ToString() + line[1].ToString());

            Console.WriteLine(first + line[2]);
        }
    }
}


Measured memory_bytes: 13396
import sys
from collections import defaultdict, deque
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

n, q = map(int, readline().split())
G = defaultdict(list)
for _ in range(n-1):
    a, b = map(int, readline().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
count = [0] * n
for _ in range(q):
    p, x = map(int, readline().split())
    count[p-1] += x


def dfs(root, x):
    ans[root] = count[root] + x
    for i in G[root]:
        if ans[i] == -1:
            dfs(i, ans[root])


ans = [-1] * n
ans[0] = count[0]
q = deque([0])
while q:
    root = q.pop()
    for i in G[root]:
        if ans[i] == -1:
            q.append(i)
            ans[i] = ans[root] + count[i]

# dfs(0, 0)
print(*ans)


Measured memory_bytes: 113188
import numpy as np
N = int(input(''))
A1 = np.array(list(map(int, input('').split(' '))))

def func(A):
    step = 0
    for k in range(0,N-1):
        if A[k] > A[k+1]:
            add = A[k] - A[k+1]
            step += add
            A[k+1] += add
    return step
        
print(func(A1))

Measured memory_bytes: 50792
#include <cstdio>
#include <cmath>
#include <iostream>
#include <cstdlib>
#include <string>
#include <iomanip>
#include <ctime>
#include <set>
#include <sstream>
#include <map>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
int ans=1,q,k;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	scanf("%d",&q);
	scanf("%d",&k);
	while(q--)
	{
		ans+=min(ans,k);
	}
	printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 256
N = int(input())
S = []
for i in range(N):
    s = int(input())
    S.append(s)
dp = [[False]*(10**4+1) for i in range(N+1)]
for i in range(N+1):
    dp[i][0] = True
for i in range(N):
    s = S[i]
    for j in range(10**4+1):
        if j-s >= 0:
            dp[i+1][j] = dp[i][j] or dp[i][j-s]
        else:
            dp[i+1][j] = dp[i][j]
ans = 0
for i in range(10**4+1):
    j = 10**4-i
    if dp[N][j]==True and j%10!=0:
        ans = j
        break
print(ans)

Measured memory_bytes: 48492
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static boolean solve() {
		int n = in.nextInt();
		int k = in.nextInt();
		int m = in.nextInt();
		if (n + k + m == 0) return false;

		ArrayList<Integer> list = new ArrayList<>();
		for (int i=0; i<n; i++) {
			list.add(i+1);
		}

		int pos = m - 1;
		k = k - 1;
		while (list.size() > 1) {
			list.remove(pos);
			pos = (pos + k) % list.size();
		}

		out.println(list.get(0));

		return true;
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		while(solve());
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 44524
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         -92233720368547758ll
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  3005
ll arr[N][N];
ll dp[N][N][4];
void solve()
{
    ll r,c,t;
    cin>>r>>c>>t;
    rep(i,0,t)
    {
        ll x,y,z;
        cin>>x>>y>>z;
        arr[x][y]=z;
    }
    
    rep(i,1,r+1)
    {
        rep(j,1,c+1)
        {
            ll res=0;
            rep(k,0,4)
            {
                res=max(res,dp[i-1][j][k]);
            } 
            dp[i][j][0]=max(res,dp[i][j-1][0]);
            dp[i][j][1]=max(dp[i][j][0]+arr[i][j],dp[i][j-1][1]);
            dp[i][j][2]=max(dp[i][j-1][1]+arr[i][j],dp[i][j-1][2]);
            dp[i][j][3]=max(dp[i][j-1][2]+arr[i][j],dp[i][j-1][3]);
        }
    }
    // rep(k,0,4)
    // {
    //     rep(i,1,r+1)
    //     {
    //         rep(j,1,c+1)
    //         {
    //             cout<<dp[i][j][k]<<" ";
    //         }
    //         cout<<endl;
    //     }
    //     cout<<endl;
    // }
    ll ans=0;
    rep(i,0,4)
    ans=max(ans,dp[r][c][i]);
    cout<<ans<<endl;

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 355720
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define lr(i,l,r) for(int i=l;(l>r?i>=r:i<=r);(l>r?--i:++i))

using namespace std;

template<class T> void umin(T &a, T b) { a = min(a, b); }
template<class T> void umax(T &a, T b) { a = max(a, b); }

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

const int mod = 1e9+7;
const int N = 2e5+5;

void solve(){
	int n;
	cin>>n;
	int a[n+1],b[n+1],c[n];
	forn(i,n)cin>>a[i];
	forn(i,n)cin>>b[i];
	forn(i,n-1)cin>>c[i];
	a[0]=-1000;
	int ans=0;
	forn(i,n){
		if(a[i]-a[i-1]==1){
			ans+=c[a[i-1]];
		}
		ans+=b[a[i]];
	}
	cout<<ans;

}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)
		solve();
	return 0;
}

Measured memory_bytes: 3640
import math
N, D = map(int, input().split())
X = [0]*N
for x in range(N):
    X[x] = list(map(int, input().split()))

ans = 0
for i in range(N-1):
    for j in range(N-i-1):
        j += i+1
        dis2 = 0
        for t in range(D):
            dis2 += (X[i][t]-X[j][t])**2
        dis = math.sqrt(dis2)
        if dis - math.floor(dis)==0.0:
            ans += 1

print(ans)

Measured memory_bytes: 3064
#include<cstdio>
int main() {
  int n, a, x, i, j;
  long long p[6001], pp[6001];
  scanf("%d%d", &n, &a);
  for (i = 0; i <= 6000; i++) {
    p[i] = 0;
  }
  p[3000] = 1;
  for (i = 0; i < n; i++) {
    scanf("%d", &x);
    x -= a;
    for (j = 500; j <= 5500; j++) {
      pp[j + x] = p[j];
    }
    for (j = 500; j <= 5500; j++) {
      p[j] += pp[j];
    }
  }
  printf("%lld", p[3000] - 1);
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <math.h>
#include <utility>
#include <algorithm>
#include <functional>
#include <vector>
#include <numeric>
#include <bits/stdc++.h>

#define int long long

struct edge {
    int to;
    int cost;
};

using namespace std;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vb = vector<bool>;
using qi = queue<int>;
using P = pair<int, int>;
using graph = vector<vector<edge>>;
// using graph = vector<vector<int>>;


#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define delim(i, n) cout << (i == n-1 ? "\n" : " ");

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

const int inf = 1LL << 60;
// const int inf = 100000000;
const int mod = 1000000007;

const int maxn = 300;
int n, m, k;

vi dx = {-1, 0, 0, 1};
vi dy = {0, -1, 1, 0};

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

    cin >> n;
    int cnt = 0;
    bool flag = false;
    REP(i, n) {
        int d1, d2; cin >> d1 >> d2;
        if (d1 == d2) cnt++;
        else cnt = 0;
        if (cnt == 3) flag = true;
    }
    
    if (flag) cout << std::fixed << std::setprecision(10) << "Yes" << "\n";
    else cout << std::fixed << std::setprecision(10) << "No" << "\n";
}

Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<tuple>
#define LL long long
#define TT std::tuple<int,int,int>
int ans;
int sx, sy;
int dx[] = { 0,1,-1,0 };
int dy[] = { -1,0,0,1 };
int W, H, N;
char map[1010][1010];
bool used[1010][1010];
int bfs(int &sx,int &sy,char m) {
	std::queue<TT> q;
	q.push(TT{ sx,sy,0 });
	while (true) {
		TT t = q.front();
		q.pop();
		int a, b, c;
		std::tie(a, b, c) = t;
		for (int i = 0; i < 4; i++) {
			int rx = a + dx[i];
			int ry = b + dy[i];
			if (1 <= rx&&rx <= H && 1 <= ry&&ry <= W) {
				if (map[rx][ry] == m) {
					sx = rx;
					sy = ry;
					return c + 1;
				}
				if (map[rx][ry] != 'X'&&!used[rx][ry]) {
					q.push(TT{ rx,ry,c + 1 });
					used[rx][ry] = true;
				}
			}
		}
	}
}

int main() {
	std::cin >> H >> W >> N;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			std::cin >> map[i][j];
			if (map[i][j] == 'S') {
				sx = i;
				sy = j;
			}
		}
	}
	char m = '0';
	for (int i = 0; i < N; i++) {
		m++;
		used[sx][sy] = true;
		ans+=bfs(sx, sy,m);
		for (int j = 1; j <= H; j++) {
			for (int k = 1; k <= W; k++) {
				used[j][k] = false;
			}
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 5152
#include<iostream>
#include<vector>
#include<map>
using namespace std;
typedef long long int ll;
vector<ll>dat;
map<ll, ll >res;
ll rest(ll a,ll b){
    if(b>=dat.size()){
        return 1e8;
    }
    return abs(dat[a]-dat[b]);
}
ll m(ll i){
    if(res.count(i))return res[i];
    if(i>=dat.size()-1){
        return 0;
    }
    res[i]=min(rest(i,i+1)+m(i+1),rest(i,i+2)+m(i+2));
    return res[i];
}
int main(){
    ll a,aux;
    cin>>a;
    for(ll i=0;i<a;i++){
        cin>>aux;
        dat.push_back(aux);
    }
    cout<<m(0)<<endl;
    return 0;
}


Measured memory_bytes: 14828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forn(i, n) for (ll i = 0; i < n; ++i)
#define forn1(i, n) for (ll i = 1; i <= n; ++i)
#define pb push_back
#define fr first
#define sc second
const ld eps = 1e-9;
//#define DEBUG
int main()
{
  //FastIO;
  #ifdef DEBUG
    freopen("input.txt", "r", stdin);
  #endif
  ll n, k;
  cin >> n >> k;
  ll a[n], b[n];
  for (int i = 0; i < n; ++i){
    cin >> a[i];
  }
  forn(i, n)
  {
    cin >> b[i];
  }
  sort(a, a + n);
  sort(b, b + n);
  ll l = 0, r = 1e12;
  while(r > l)
  {
    ll kk = k;
    bool ok = true;
    ll m = (l + r) / 2;
    for (int i = 0; i < n; ++i){
      if (b[i] * a[n - i - 1] > m)
      {
        ll h = (a[n - i - 1] - m / b[i]);
        if (h <= kk){
          kk -= h;
        }
        else{
          ok = false;
          break;
        }
      }
    }
    if (ok){
      r = m;
    }
    else{
      l = m + 1;
    }
    //cout << m << " " << l << " " << r << "\n";
  }
  cout << l << "\n";
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;

int N, M, R;
int INF = 1e9;

void warshall_floyd(vector<vector<int>>& dist) {
    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
}

int main() {
    cin >> N >> M >> R;
    vector<vector<int>> dist(N, vector<int>(N, INF));
    vector<int> r(R);
    for (int i = 0; i < R; i++) {
        cin >> r[i];
        r[i]--;
    }
    sort(r.begin(), r.end());
    int A, B, C;
    for (int i = 0; i < M; i++) {
        cin >> A >> B >> C;
        A--; B--;
        dist[A][B] = C;
        dist[B][A] = C;
    }
    warshall_floyd(dist);
    int ans = 1e9;
    do {
        int tmp = 0;
        for (int i = 0; i < R - 1; i++) {
            tmp += dist[r[i]][r[i + 1]];
        }
        ans = ans > tmp? tmp: ans;
    } while (next_permutation(r.begin(), r.end()));
    cout << ans << endl;
}



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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}

long long dp[100005];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, best = 0; long long w, a, b; cin >> n >> w;

    for(int j = 0; j <= 100000; ++j)
        dp[j] = 1e10;

    dp[0] = 0;

    for(int i = 0; i < n; ++i){
        cin >> a >> b;
        for(int v = 100000; v >= b; --v){
            dp[v] = min(dp[v], a + dp[v - b]);
            if(dp[v] <= w)
                best = max(best, v);
        }
    }

    cout << best << "\n";

    return 0;

}


Measured memory_bytes: 1024
import scala.io.StdIn._
object Main extends App {
  val Array(n, m) = readLine.split(" ").map(_.toInt)
  val lights = Array.fill(m)(readLine.split(" ").tail.map(_.toInt - 1))
  val conds = readLine.split(" ").map(_.toInt).zip(lights)

  def checkStatus(s: Int): Boolean = {
    def checkLight(cond: (Int, Array[Int])): Boolean = {
      cond._2.count(l => ((1 << l) & s) != 0) % 2 == cond._1
    }
    conds.forall(checkLight)
  }

  println((0 until (1 << n)).count(checkStatus))
}

Measured memory_bytes: 26360
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define fastio ios_base::sync_with_stdio(false); cout.tie(NULL);
using namespace std;

int main()
{
	fastio;
	string s;
	cin>>s;
	if(s=="ABC")
		cout<<"ARC";
	else
		cout<<"ABC";
	return 0;
}


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

#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
template <class T, class S> void reader(T *x, S *y){reader(x);reader(y);}
void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
template<class T> void writerLn(T x){writer(x,'\n');}


#define incID(i, l, r) for(int i = (l); i < (r); i++)
#define inc(i, n) incID(i, 0, n)
template<typename T> bool setmin(T &a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T &a, T b) { if(b <= a) { return false; } else { a = b; return true; } }


// ---- ----

int n, k;
list<int> vec[100000];
bool has[100000];
int mi[100000];
int ma[100000];

void prod(int x, int y) {
	if(has[y]) {
		bool flag = true;
		if(has[x] && (mi[x] - mi[y]) % 2 == 0) { flag = false; }
		setmax(mi[x], mi[y] - 1);
		setmin(ma[x], ma[y] + 1);
		has[x] = true;
		if(mi[x] > ma[x]) { flag = false; }
		if(! flag) {
			puts("No");
			exit(0);
		}
	}
}

bool dfs(int node, int pre) {
	if(pre != -1) { prod(node, pre); }
	for(auto && i : vec[node]) {
		if(i != pre) {
			dfs(i, node);
			prod(node, i);
		}
	}
}

int main() {
	reader(&n);
	inc(i, n - 1) {
		int a, b;
		reader(&a, &b);
		a--; b--;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	fill(mi, mi + n, -1000000);
	fill(ma, ma + n,  2000000);
	reader(&k);
	inc(j, k) {
		int v, p;
		reader(&v, &p);
		v--;
		mi[v] = p;
		ma[v] = p;
		has[v] = true;
	}
	
	dfs(0, -1);
	dfs(0, -1);
	
	puts("Yes");
	inc(i, n) { writerLn(mi[i]); }
	
	return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  double ans = 0;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    double a;
    cin >> a;
    ans += 1. / a;
  }
  printf("%.10f\n", 1. / ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define INF 1145141919
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int ny, nx;
typedef long long int ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
////////////////////////////////////////////////////////////////////
int main()
{
    double a,b,t; cin >> a >> b >> t;
    double now=0;
    int ans=0;

    while(t+0.5>now+a){
        now+=a;
        ans+=b;
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"


string st;


bool operator<(const string& l, const string& r) {
	if (l.size() == r.size()) {
		for (int i = 0; i < l.size(); ++i) {
			if (l[i] != r[i])return l[i] < r[i];
			
		}
		return false;
	}
	else {
		return l.size() < r.size();
	}
}

string memo[51][51];
string getans(const int l, const int r) {
	if (memo[l][r] != "#")return memo[l][r];
	{
		string ans;
		bool ok = true;
		for (int c = l; c < r; ++c) {
			if (!isdigit(st[c])) {
				if (st[c] == '?') {
					ans.push_back('9');
				}
				else {
					ok = false;
				}
			}
			else {
				if (c == l&&st[c] == '0'&&r-l!=1)ok = false;
				ans.push_back(st[c]);
			}
		}
		if (ok)return memo[l][r]=ans;
	}
	if (r - l < 6)return "";
	else
	{
		bool canl, canr;
		if (st[l] == '?') {
			canl = true; canr = true;
		}
		else if (st[l] == 'L') {
			canl = true; canr = false;
		}
		else if (st[l] == 'R') {
			canl = false; canr = true;
		}
		else if (isdigit(st[l])) {
			canl = false; canr = false;
		}
		else if (st[l] == ',') {
			canl = false; canr = false;
		}
		else {
			canl = false; canr = false;
		}
		if ((st[l + 1] == '(' || st[l + 1] == '?') && (st[r - 1] == ')' || st[r - 1] == '?')) {

		}
		else {
			canl = false;
			canr = false;
		}
		string ans;
		for (int conma = l + 3; conma <= r - 3; ++conma) {
			if (st[conma] == '?' || st[conma] == ',') {

				string lst = getans(l + 2, conma);
				string rst = getans(conma + 1, r - 1);
				if (!lst.empty() && !rst.empty()) {
					if (canl) {
						if (ans < lst)ans = lst;
					}
					if (canr) {
						if (ans < rst)ans = rst;
					}
				}
			}
		}
		return memo[l][r]=ans;
	}
	
}

int main() {
	cin >> st;
	for (int i = 0; i <= 50; ++i) {
		for (int j = 0; j <= 50; ++j) {
			memo[i][j] = '#';
		}
	}
	string ans=getans(0, st.size());
	if (ans.empty())ans = "invalid";
	cout << ans << endl;
	return 0;
}

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

#define int long long
#define ffor(i,n) for(int i = 0;i < (n); ++i)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pii>
#define ff first
#define ss second
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    int n;
    cin >> n;
    map<string,int> mp;
    for(int i = 0;i < n; ++i){
        string s;
        cin >> s;
        mp[s]++;
    }
    int maxi = 0;
    for(auto x : mp){
        maxi = max(maxi,x.second);
    }
    set<string> st;
    for(auto x : mp){
        if(x.second == maxi){
            st.insert(x.first);
        }
    }
    for(auto x : st){
        cout << x << '\n';
    }
}

Measured memory_bytes: 33280
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
using namespace std;
using ll = long long;
int main()
{

	ll a = 0, b = 0, c = 0, d = 0, e = 0;
	string s, t;
	ll n, m, h, w, X;
	ll k;
	ll A[60] = {};
	ll memo[4000] = {};
	ll memo2[4000] = {};
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;
	m = -10000000000;
	m = max(m, c);

	for (int i = 0; i < a; i++)
	{
		cin >> n;
		m = max(m, n);
	}
	h = 100000000000;
	h = min(h, d);

	for (int i = 0; i < b; i++)
	{
		cin >> n;
		h = min(h, n);
	}
	if (h<=m||c>d)
	{
		cout << "War" << endl;

	}
	else
	{
		cout << "No War" << endl;

	}


	//cout << sum << endl;
	//cout <<  endl;

	return 0;
}

//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}



Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
num_map = {}
for a in A:
    if a in num_map:
        num_map[a] += 1
    else:
        num_map[a] = 1

keys = num_map.keys()
nums = list(num_map.values())
sum_kind = len(keys)
nums.sort()

cnt = sum_kind
ans = 0
for num in nums:
    if cnt <= K:
        break
    else:
        ans += num
        cnt -= 1
print(ans)


Measured memory_bytes: 32184
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

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

typedef struct ql_t {
  int a;
  int b;
  int c;
  int d;
} ql_t;

int main(void)
{
  int n, m, q;
  cin >> n >> m >> q;
  vector<ql_t> ql;
  rep(i,q) {
    ql_t tmp;
    cin >> tmp.a >> tmp.b >> tmp.c >> tmp.d;
    ql.push_back(tmp);
  }

  int l[11];
  int result = 0;
  for (l[10] = 1; l[10] <= m; l[10]++) {
    for (l[9] = 1; l[9] <= m; l[9]++) {
      if (l[10] < l[9]) continue;
      for (l[8] = 1; l[8] <= m; l[8]++) {
        if (l[9] < l[8]) continue;
        for (l[7] = 1; l[7] <= m; l[7]++) {
          if (l[8] < l[7]) continue;
          for (l[6] = 1; l[6] <= m; l[6]++) {
            if (l[7] < l[6]) continue;
            for (l[5] = 1; l[5] <= m; l[5]++) {
              if (l[6] < l[5]) continue;
              for (l[4] = 1; l[4] <= m; l[4]++) {
                if (l[5] < l[4]) continue;
                for (l[3] = 1; l[3] <= m; l[3]++) {
                  if (l[4] < l[3]) continue;
                  for (l[2] = 1; l[2] <= m; l[2]++) {
                    if (l[3] < l[2]) continue;
                    for (l[1] = 1; l[1] <= m; l[1]++) {
                      if (l[2] < l[1]) continue;
                      int tmpRes = 0;
                      for (ql_t x:ql) {
                        if (l[x.b] - l[x.a] == x.c) {
                          tmpRes += x.d;
                        }
                      }
                      result = max(result, tmpRes);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }

  cout << result << endl;
}


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

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

    int n;
    cin >> n;
    vector<ll> a(n), b;
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    vector<pair<int, int>> x;

    int k = -1;
    while (k < n - 1 && a[k + 1] <= 0)
        k++;

    if (k == -1)
    {
        forx(i, 1, n - 1)
        {
            x.push_back(make_pair(a[0], a[i]));
            a[0] -= a[i];
        }
        x.push_back(make_pair(a[n - 1], a[0]));
        cout << x[x.size() - 1].first - x[x.size() - 1].second << endl;

        for (auto i : x)
            cout << i.first << ' ' << i.second << endl;

        return 0;
    }

    rep(i, k)
    {
        x.push_back(make_pair(a[n - 1], a[i]));
        a[n - 1] -= a[i];
    }
    forx(i, k + 1, n - 1)
    {
        x.push_back(make_pair(a[k], a[i]));
        a[k] -= a[i];
    }

    if (k != n - 1)
        x.push_back(make_pair(a[n - 1], a[k]));

    cout << x[x.size() - 1].first - x[x.size() - 1].second << endl;

    for (auto i : x)
        cout << i.first << ' ' << i.second << endl;

    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <stdarg.h>
#include <assert.h>
#include <ctype.h>

using namespace std;
typedef long long int lli;
typedef vector<int> iv;
typedef vector<bool> bv;
typedef vector<string> sv;
typedef vector<long long int> llv;
typedef vector<double> dv;

#define sor_(vec) sort(vec.begin(),vec.end())
#define rev_(vec) reverse(vec.begin(),vec.end())
#define rep(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define reps(i,n,s) for(int i=static_cast<int>(s);i<static_cast<int>(n);i++)
#define isposi(num) if(num>0)
const long long mod = 1000000007;

void printm(char const *format,...){
    va_list arguments;
    va_start(arguments,format);
    unsigned index=0;
    while (format[index]!='\0') {
        if(format[index]=='%'){
            index++;
            if(format[index]=='d')printf("%d",va_arg(arguments, int));
            else if(format[index]=='c')printf("%c",va_arg(arguments, int));
            else if(format[index]=='x')printf("%x",va_arg(arguments,int));
            else if(format[index]=='o')printf("%o",va_arg(arguments,int));
            else if(format[index]=='f')printf("%f",va_arg(arguments, double));
            else if(format[index]=='s')printf("%s",va_arg(arguments, char const *));
            else if(format[index]=='p')printf("%p",va_arg(arguments,void*));
            else if(format[index]=='y')printf("Yes");
            else if(format[index]=='n')printf("No");
            else if(format[index]=='%')printf("%%");
            else assert(!"Unknown format with %.");
        }
        else printf("%c",format[index]);
        index++;
    }
    va_end(arguments);
    return;
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long int n,k;
    std::cin>>n>>k;;
    if(n-(k*(n/k))>abs((n-(k*(n/k)))-k))std::cout<<abs((n-(k*(n/k)))-k);
    else std::cout<<n-(k*(n/k));
    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
x = gets.split.map(&:to_i)
y = x.sort

med_small = y[N/2 -1]
med_large = y[N/2]

0.upto(N-1) do |i|
  if x[i] >= med_large
    puts med_small
  else
    puts med_large
  end
end


Measured memory_bytes: 23396
#include<iostream>
#include<vector>
#include<deque>

class graph_list{
private:
    int origin;
    int size;
    int initial_point;
    std::deque< std::pair< int, int > > deq;
    
public:
    std::vector< std::vector< std::pair< int, int > > > list;
    std::vector< std::vector< int > > dist;
    
    graph_list(int origin_in,int N){
        origin = origin_in;
        size = N;
        list.resize(size);
        dist.assign(size, std::vector< int >(size, 0x7FFFFFFF));
        for(int i=0; i<size; i++){
            dist[i][i] = 0;
        }
    }
    
    void connect(int a, int b, int cost){
        std::pair< int, int > tmp(b-origin, cost);
        list[a-origin].push_back(tmp);
        std::pair< int, int > tmp2(a-origin, cost);
        list[b-origin].push_back(tmp2);
    }
    
    void dist_calc(int point){
        initial_point = point;
        std::pair< int, int > tmp(initial_point, 0);
        deq.push_back(tmp);
        while(!deq.empty()){
            std::pair< int, int > tmp = deq[0];
            sub_dist_calc(tmp.first, tmp.second);
            deq.pop_front();
        }
    }
    
    void sub_dist_calc(int point, int cost){
        for(int i=0; i<list[point - origin].size(); i++){
            
            int move_cost = cost + list[point - origin][i].second;
            if(dist[initial_point - origin][list[point - origin][i].first] < move_cost){
                continue;
            }else{
                dist[initial_point - origin][list[point - origin][i].first] = move_cost;
                dist[list[point - origin][i].first][initial_point - origin] = move_cost;
                std::pair< int, int > tmp(list[point - origin][i].first +origin, move_cost);
                deq.push_back(tmp);
            }
        }
    }
    
};

int main(){
    int N, X, Y;
    std::cin >> N >> X >> Y;
    
    graph_list G(1, N);
    for(int i=1; i<=N-1; i++){
        G.connect(i, i+1, 1);
    }
    G.connect(X, Y, 1);
    
    for(int i=1; i<=N; i++){
        G.dist_calc(i);
    }
    
    std::vector< int > ans(N-1, 0);
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            if(G.dist[i][j] > 0){ ans[G.dist[i][j]-1]++; }
        }
    }
    for(int i=0; i<N-1; i++){
        std::cout << ans[i] << std::endl;
    }
}


Measured memory_bytes: 16128
import numpy as np
import math
import collections
import fractions
import itertools

def iput(): return int(input())
def mput(): return map(int, input().split())
def lput(): return list(map(int, input().split()))

def solve():
    n = int(input())
    cost = 0
    a, b = [0]*n, [0]*n
    for i in range(n):
        a[i], b[i] = mput()
    inc = 0
    for i in range(n-1, -1, -1):
        a[i] += inc
        mult = math.ceil(a[i]/b[i])*b[i]
        cost += mult - a[i]
        inc += mult - a[i]
    print(cost)
    return 0

if __name__ == "__main__":
    solve()


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


long A[100000 + 1];
long B[100000];
int main(int argc, char *argv[])
{
	long N;
	long i;
	long sum;

	scanf("%ld", &N);
	for (i = 0; i < N + 1; i++) {
		scanf("%ld", &A[i]);
	}
	for (i = 0; i < N; i++) {
		scanf("%ld", &B[i]);
	}
	sum = 0;
	for (i = 0; i < N; i++) {
		if (A[i] > B[i]) {
			 sum += B[i];
		}
		else {
			sum += A[i];
			if (A[i+1] > (B[i] - A[i])) {
				 sum += (B[i] - A[i]);
				 A[i + 1] -= (B[i] - A[i]);
			}
			else {
				sum += A[i + 1];
				A[i+1] = 0;
			}
		}
	}
	printf("%ld\n", sum);
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll h,w,n;cin>>h>>w>>n;
    ll sr,sc;cin>>sr>>sc;
    string s,t;cin>>s>>t;
    ll lx=1,hx=h,ly=1,hy=w;
    for(ll i=n-1;i>=0;i--){
        if(t[i]=='R')ly = max(ly-1 , 1ll);
        if(t[i]=='D')lx = max(lx-1 , 1ll);
        if(t[i]=='L')hy = min(hy+1 , w);
        if(t[i]=='U')hx = min(hx+1 , h);

        if(s[i]=='R')hy--;
        if(s[i]=='D')hx--;
        if(s[i]=='L')ly++;
        if(s[i]=='U')lx++;

       if(hx<lx || hy<ly)return cout<<"NO" , 0;
    }
    if(hx<sr || sr<lx || hy<sc || sc<ly)return cout<<"NO" , 0;
    cout<<"YES";
}

Measured memory_bytes: 920
n = int(input())
l = []
l = input().split()
l = list(map(int,l))

list_up = []
for i in range(1,n+1):
    list_up += [i]

x = 0
for i in range(n):
    if l[i] != list_up[i]:
        x += 1

if x == 0 or x == 2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
#include <cstdio>
using namespace std;
const int mapSize = 1e6 + 5, mod = 1e9 + 7;
int fac[mapSize * 2], inv[mapSize * 2];
void Init() {
	fac[1] = inv[1] = 1;
	for (int i = 2; i <= (int) 2e6 + 1; ++i) {
		fac[i] = 1ll * fac[i - 1] * i % mod;
		int res = mod % i, div = mod / i;
		inv[i] = 1ll * inv[res] * (mod - div) % mod;
	}
	for (int i = 2; i <= (int) 2e6 + 1; ++i)
		inv[i] = 1ll * inv[i] * inv[i - 1] % mod;
	fac[0] = inv[0] = 1;
}
int C(int down, int up) {
	return 1ll * fac[down] * inv[up] % mod * inv[down - up] % mod;
}
int rowSum(int rowId, int colL, int colR) {
	int tmp1, tmp2, ret = ((tmp1 = (C(rowId + 1 + colR, colR)) - (tmp2 = C(rowId + colL, colL - 1))) % mod + mod) % mod;
	return ret;
}
int main() {
	Init();
	int r1, c1, r2, c2;
	scanf("%d%d%d%d", &r1, &c1, &r2, &c2);
	int ans = 0;
	for (int rowId = r1; rowId <= r2; ++rowId)
		ans = (ans + rowSum(rowId, c1, c2)) % mod;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 15744
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        
        //int a = stdIn.nextInt();
        //int b = stdIn.nextInt();
        //int n = stdIn.nextInt();
        //int k = stdIn.nextInt();
        String s = stdIn.next();
        
        switch(s){
            case "A":
                System.out.println("T");
                break;
            case "T":
                System.out.println("A");
                break;
            case "G":
                System.out.println("C");
                break;
            case "C":
                System.out.println("G");
                break;
            
        }
        
        //System.out.println();
        //System.out.print();
    }
}


Measured memory_bytes: 19156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(){
  ll n;
  cin>>n;
  for(int i=0;i<=n/4;i++)for(int j=0;j<=n/7;j++)if(i*4+j*7==n){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class Nomura_C
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string s = Console.ReadLine();

            char[] char_s = s.ToCharArray();

            

            ////?位置のリストアップ
            for (int Count = 0; Count < s.Length; Count++)
            {
                if (char_s[Count] == '?')
                {
                    char_s[Count] = 'D';
                }
            }
            string result = new string(char_s);

            Console.WriteLine(result);

            Console.Out.Flush();

        }

        class Global
        {

            public static string Left(string str, int len)
            {
                if (str == null || len <= 0)
                {
                    return "";
                }

                if (str.Length >= len && str.Length >= 0)
                {
                    return str.Substring(0, len);
                }
                else
                {
                    return str;
                }
            }


            public static string Right(string str, int len)
            {
                if (str.Length >= len && str.Length >= 0)
                {
                    return str.Substring(str.Length - len);
                }
                else
                {
                    return "";
                }
            }

            public static string Middle(string str, int Left, int Right)
            {
                if (str.Length >= 0)
                {
                    return str.Substring(Left - 1, (Right - Left) + 1);
                }
                else
                {
                    return "";
                }
            }

            //素数判定
            static bool IsPrimeNumber(int number)
            {
                double i = number;
                // 平方根を求める
                double x = Math.Sqrt(i);
                // 平方根以下の値で割り切れるのか確認する
                // 最小値は2
                for (double j = 2; j <= x; j++)
                {
                    if ((number % j) == 0) { return false; }
                }
                if (number == 1) { return false; }
                return true;
            }

            public static long CalcGCD(long a, long b)
            {
                if (b == 0) { return a; }
                return CalcGCD(b, a % b);
            }
            //最小公倍数
            public static long CalcLCM(long a, long b)
            {
                return a * b / CalcGCD(a, b);
            }
        }
    }
}


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

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

  // シミュレーション
  int light = 0; // 光っているボタン
  int ans = -1;
  for (int i = 0; i < N; i++) {
    light = a[light] - 1;
    if (light == 1) {
      ans = i + 1;
      break;
    }
  }

  // 解答
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

S = input()
T = input()
print('Yes' if S == T[:-1] else 'No')


Measured memory_bytes: 65220
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (1e+18) + 7;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

ll mod_pow(ll a, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%mod;
		a = a * a%mod; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 500;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

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

void solve() {
	int n,k; cin >> n>>k;
	vector<ld> a(n);
	rep(i, n) {
		cin >> a[i];
		a[i] = (a[i] + 1) / 2.0;
	}
	vector<ld> ra(n + 1);
	rep(i, n)ra[i + 1] = ra[i] + a[i];
	ld ans = 0;
	rep(i, n - k + 1) {
		ld sum = ra[i + k] - ra[i];
		ans = max(ans, sum);
	}
	cout << ans << endl;
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(10);
	//init_f(); init();
	//int t; cin >> t; rep(i, t)solve();
	//while(cin>>n,n)solve();
	solve();
	stop
		return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  vector<vector<Int> > G(n);
  for(Int i=1;i<n;i++){
    Int x,y;
    cin>>x>>y;
    x--;y--;
    G[x].emplace_back(y);
    G[y].emplace_back(x);
  }
  
  vector<Int> dp(n,-1);
  function<Int(Int)> dfs=
    [&](Int v){
      Int &res=dp[v];
      if(~res) return res;
      res=0;
      for(Int u:G[v]){
	if(a[u]>=a[v]) continue;
	res|=!dfs(u);
      }	
      return res;
    };  
  
  vector<Int> ans;
  for(Int i=0;i<n;i++)
    if(dfs(i)) ans.emplace_back(i+1);

  for(Int i=0;i<(Int)ans.size();i++){
    if(i) cout<<" ";
    cout<<ans[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int H,W,N;
    int sy,sx;
    int HP;
    int ans=0;
          cin>>H>>W>>N;
    char map[H][W];
    int step[H][W];
    for(int i = 0; i < H; i++)
        for(int j = 0; j < W; j++)
        {
            cin>>map[i][j];
            step[i][j]=-1;
            if(map[i][j]=='S') {
                sy=i;
                sx=j;
        }   
        }
    for(HP=1;HP<=N;HP++){
        queue<pair<int,int> > q;
        q.push(make_pair(sy,sx));
        step[sy][sx]=0;
        while(1){
            int y,x;
            pair<int,int> point=q.front();
            q.pop();
            y=point.first;
            x=point.second;
            if(map[y][x]=='0'+HP){
                ans+=step[y][x];
                for(int i = 0; i < H; i++){
                    for(int j = 0; j < W; j++){
                        step[i][j]=-1;
                    }
                    }
                sy=y;
                sx=x;
                break;
            }
            if(y>0 && map[y-1][x]!='X' && step[y-1][x]==-1) {
                step[y-1][x]=step[y][x]+1;
                q.push(make_pair(y-1,x));
            }
            if(y<H-1 && map[y+1][x]!='X' && step[y+1][x]==-1) {
                step[y+1][x]=step[y][x]+1;
               q.push(make_pair(y+1,x));
            }
            if(x>0 && map[y][x-1]!='X' && step[y][x-1]==-1) {
                step[y][x-1]=step[y][x]+1;
                q.push(make_pair(y,x-1));
            }
            if(x<W-1 && map[y][x+1]!='X' && step[y][x+1]==-1) {
                step[y][x+1]=step[y][x]+1;
                q.push(make_pair(y,x+1));
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 7972